* [PATCH] [gdb/config/djgpp] Make djcheck.sh and djconfig.sh shellcheck-clean
@ 2026-08-31 10:08 Tom de Vries
2026-08-31 11:47 ` Eli Zaretskii
0 siblings, 1 reply; 5+ messages in thread
From: Tom de Vries @ 2026-08-31 10:08 UTC (permalink / raw)
To: gdb-patches
Make gdb/config/djgpp/{djcheck.sh,djconfig.sh} shellcheck-clean:
- add missing quotes
- add "|| exit 1" after cd
- use printf instead of echo -n
- use $()
- disable SC2016 for "configure --prefix='${DJDIR}' assuming ${DJDIR} is
indeed not meant to be expanded
I don't have a djgpp setup, so I can't test this.
---
gdb/config/djgpp/djcheck.sh | 20 ++++-----
gdb/config/djgpp/djconfig.sh | 81 ++++++++++++++++++------------------
gdb/contrib/shellcheck.sh | 4 +-
3 files changed, 52 insertions(+), 53 deletions(-)
diff --git a/gdb/config/djgpp/djcheck.sh b/gdb/config/djgpp/djcheck.sh
index fa75d03f776..24224ccc955 100644
--- a/gdb/config/djgpp/djcheck.sh
+++ b/gdb/config/djgpp/djcheck.sh
@@ -17,31 +17,31 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-ORIGDIR=`pwd`
-GDB=${ORIGDIR}/../gdb.exe
-SUBDIRS=`find $ORIGDIR -type d ! -ipath $ORIGDIR`
+ORIGDIR=$(pwd)
+GDB="${ORIGDIR}/../gdb.exe"
+SUBDIRS=$(find "$ORIGDIR" -type d ! -ipath "$ORIGDIR")
for d in $SUBDIRS
do
- cd $d
+ cd "$d" || exit 1
echo "Running tests in $d..."
for f in *.out
do
- test -f $f || break
- base=`basename $f .out`
+ test -f "$f" || break
+ base=$(basename "$f" .out)
if test "${base}" = "dbx" ; then
options=-dbx
else
options=
fi
- $GDB ${options} < ${base}.in 2>&1 \
+ $GDB ${options} < "${base}.in" 2>&1 \
| sed -e '/GNU gdb /s/ [.0-9][.0-9]*//' \
-e '/^Copyright/s/[12][0-9][0-9][0-9]/XYZZY/g' \
-e '/Starting program: /s|[A-z]:/.*/||' \
-e '/main (/s/=0x[0-9a-f][0-9a-f]*/=XYZ/g' \
- > ${base}.tst
- if diff --binary -u ${base}.out ${base}.tst ; then
- rm -f ${base}.tst
+ > "${base}.tst"
+ if diff --binary -u "${base}.out" "${base}.tst" ; then
+ rm -f "${base}.tst"
fi
done
done
diff --git a/gdb/config/djgpp/djconfig.sh b/gdb/config/djgpp/djconfig.sh
index b630e6c0c58..789509c92b8 100644
--- a/gdb/config/djgpp/djconfig.sh
+++ b/gdb/config/djgpp/djconfig.sh
@@ -40,30 +40,30 @@ unset CDPATH
# then only forward slashes (/) in the directories. It should be
# an absolute path.
-if [ x$1 = x ]; then
- srcdir=`pwd`
+if [ "$1" = "" ]; then
+ srcdir=$(pwd)
else
- srcdir=`cd $1 && pwd`
+ srcdir=$(cd "$1" && pwd) || exit 1
shift
fi
# Make sure they don't have some file names mangled by untarring.
-echo -n "Checking the unpacked distribution..."
-if ( ! test -f ${srcdir}/bfd/ChangeLog.0203 || \
- ! test -f ${srcdir}/gdb/ChangeLog.002 || \
- ! test -f ${srcdir}/opcodes/ChangeLog.0203 || \
- ! test -f ${srcdir}/readline/config.h-in ) ; then
- if ( ! test -f ${srcdir}/bfd/ChangeLog.0203 ) ; then
- notfound=${srcdir}/bfd/ChangeLog.0203
+printf "Checking the unpacked distribution..."
+if ! test -f "${srcdir}/bfd/ChangeLog.0203" || \
+ ! test -f "${srcdir}/gdb/ChangeLog.002" || \
+ ! test -f "${srcdir}/opcodes/ChangeLog.0203" || \
+ ! test -f "${srcdir}/readline/config.h-in"; then
+ if ! test -f "${srcdir}/bfd/ChangeLog.0203"; then
+ notfound="${srcdir}/bfd/ChangeLog.0203"
else
- if ( ! test -f ${srcdir}/gdb/ChangeLog.002) ; then
- notfound=${srcdir}/gdb/ChangeLog.002
+ if ! test -f "${srcdir}/gdb/ChangeLog.002"; then
+ notfound="${srcdir}/gdb/ChangeLog.002"
else
- if ( ! test -f ${srcdir}/readline/config.h-in ) ; then
- notfound=${srcdir}/readline/config.h-in
+ if ! test -f "${srcdir}/readline/config.h-in"; then
+ notfound="${srcdir}/readline/config.h-in"
else
- if ( ! test -f ${srcdir}/opcodes/ChangeLog.0203 ) ; then
- notfound=${srcdir}/opcodes/ChangeLog.0203
+ if ! test -f "${srcdir}/opcodes/ChangeLog.0203"; then
+ notfound="${srcdir}/opcodes/ChangeLog.0203"
fi
fi
fi
@@ -85,40 +85,40 @@ else
fi
# Where is the directory with DJGPP-specific scripts?
-DJGPPDIR=${srcdir}/gdb/config/djgpp
+DJGPPDIR="${srcdir}/gdb/config/djgpp"
echo "Editing configure scripts for DJGPP..."
TMPFILE="${TMPDIR-.}/cfg.tmp"
# We need to skip the build directory if it is a subdirectory of $srcdir,
# otherwise we will have an infinite recursion on our hands...
-if test "`pwd`" = "${srcdir}" ; then
+if test "$(pwd)" = "${srcdir}" ; then
SKIPDIR=""
SKIPFILES=""
else
- SKIPDIR=`pwd | sed -e "s|${srcdir}|.|"`
+ SKIPDIR=$(pwd | sed -e "s|${srcdir}|.|")
SKIPFILES="${SKIPDIR}/*"
fi
# We use explicit /dev/env/DJDIR/bin/find to avoid catching
# an incompatible DOS/Windows version that might be on their PATH.
for fix_dir in \
- `cd $srcdir && /dev/env/DJDIR/bin/find . -type d ! -ipath "${SKIPDIR}" ! -ipath "${SKIPFILES}"`
+ $(cd "$srcdir" && /dev/env/DJDIR/bin/find . -type d ! -ipath "${SKIPDIR}" ! -ipath "${SKIPFILES}")
do
- if test ! -f ${fix_dir}/configure.orig ; then
- if test -f ${srcdir}/${fix_dir}/configure ; then
- mkdir -p ${fix_dir}
- cp -p ${srcdir}/${fix_dir}/configure ${fix_dir}/configure.orig
+ if test ! -f "${fix_dir}/configure.orig" ; then
+ if test -f "${srcdir}/${fix_dir}/configure" ; then
+ mkdir -p "${fix_dir}"
+ cp -p "${srcdir}/${fix_dir}/configure" "${fix_dir}/configure.orig"
fi
fi
- if test -f ${fix_dir}/configure.orig ; then
- sed -f ${DJGPPDIR}/config.sed ${fix_dir}/configure.orig > $TMPFILE
- update $TMPFILE ${fix_dir}/configure
- touch ./${fix_dir}/configure -r ${fix_dir}/configure.orig
- rm -f $TMPFILE
+ if test -f "${fix_dir}/configure.orig" ; then
+ sed -f "${DJGPPDIR}/config.sed" "${fix_dir}/configure.orig" > "$TMPFILE"
+ update "$TMPFILE" "${fix_dir}/configure"
+ touch "./${fix_dir}/configure" -r "${fix_dir}/configure.orig"
+ rm -f "$TMPFILE"
fi
- if test -f ${fix_dir}/INSTALL ; then
- mv ${fix_dir}/INSTALL ${fix_dir}/INSTALL.txt
+ if test -f "${fix_dir}/INSTALL" ; then
+ mv "${fix_dir}/INSTALL" "${fix_dir}/INSTALL.txt"
fi
done
@@ -134,7 +134,7 @@ export CONFIG_SHELL=/dev/env/DJDIR/bin/sh.exe
# force to have the ltmain.sh script to be in DOS text format,
# otherwise the resulting ltconfig script will have mixed
# (UNIX/DOS) format and is unusable with Bash ports before v2.03.
-utod $srcdir/ltmain.sh
+utod "$srcdir/ltmain.sh"
# Give the configure script some hints:
export LD=ld
@@ -159,16 +159,16 @@ export lt_cv_sys_max_cmd_len=12288
# Force depcomp to use _deps rather than .deps as the name of the
# subdirectory where the *.Po dependency files are put. File names
# with leading dots are invalid on DOS 8+3 filesystems.
-export DEPDIR=${DEPDIR:-_deps}
+export DEPDIR="${DEPDIR:-_deps}"
# The configure script needs to see the `install-sh' script, otherwise
# it decides the source installation is broken. But "make install" will
# fail on 8+3 filesystems if it finds a file `install-', since there
# are numerous "install-foo" targets in Makefile's. So we rename the
# offending file after the configure step is done.
-if test ! -f ${srcdir}/install-sh ; then
- if test -f ${srcdir}/install-.sh ; then
- mv ${srcdir}/install-.sh ${srcdir}/install-sh
+if test ! -f "${srcdir}/install-sh" ; then
+ if test -f "${srcdir}/install-.sh" ; then
+ mv "${srcdir}/install-.sh" "${srcdir}/install-sh"
fi
fi
@@ -176,10 +176,11 @@ fi
# support, which is nearly impossible to be supported in the current way,
# since it relies on file names which will never work on DOS.
echo "Running the configure script..."
-$srcdir/configure --srcdir="$srcdir" --prefix='${DJDIR}' \
+# shellcheck disable=SC2016 # $DJDIR is not expanded here.
+"$srcdir/configure" --srcdir="$srcdir" --prefix='${DJDIR}' \
--disable-shared --disable-nls --verbose --enable-build-warnings=\
--Wimplicit,-Wcomment,-Wformat,-Wparentheses,-Wpointer-arith,-Wuninitialized $*
+-Wimplicit,-Wcomment,-Wformat,-Wparentheses,-Wpointer-arith,-Wuninitialized "$@"
-if test -f ${srcdir}/install- ; then
- mv ${srcdir}/install- ${srcdir}/install-.sh
+if test -f "${srcdir}/install-" ; then
+ mv "${srcdir}/install-" "${srcdir}/install-.sh"
fi
diff --git a/gdb/contrib/shellcheck.sh b/gdb/contrib/shellcheck.sh
index 2a0425eeaab..2661d48b391 100755
--- a/gdb/contrib/shellcheck.sh
+++ b/gdb/contrib/shellcheck.sh
@@ -41,9 +41,7 @@ for f in "$@"; do
# Skip generated files.
continue
;;
- gdb/config/djgpp/djcheck.sh \
- | gdb/config/djgpp/djconfig.sh \
- | gdb/contrib/gdb-add-index.sh \
+ gdb/contrib/gdb-add-index.sh \
| gdb/gdb_buildall.sh \
| gdb/gdb_mbuild.sh \
| gdb/testsuite/lib/pdtrace.in)
base-commit: 4d0228f6d409f0d74effbb19430c4c87d1762f55
--
2.51.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] [gdb/config/djgpp] Make djcheck.sh and djconfig.sh shellcheck-clean
2026-08-31 10:08 [PATCH] [gdb/config/djgpp] Make djcheck.sh and djconfig.sh shellcheck-clean Tom de Vries
@ 2026-08-31 11:47 ` Eli Zaretskii
2026-08-31 11:54 ` Tom de Vries
0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2026-08-31 11:47 UTC (permalink / raw)
To: Tom de Vries; +Cc: gdb-patches, DJ Delorie
> From: Tom de Vries <tdevries@suse.de>
> Date: Mon, 31 Aug 2026 12:08:26 +0200
>
> Make gdb/config/djgpp/{djcheck.sh,djconfig.sh} shellcheck-clean:
> - add missing quotes
> - add "|| exit 1" after cd
> - use printf instead of echo -n
> - use $()
> - disable SC2016 for "configure --prefix='${DJDIR}' assuming ${DJDIR} is
> indeed not meant to be expanded
What's the problem with `foo` that you replace it with $() everywhere?
I don't remember, but there's a risk that DJGPP ports of Bash might
not support the latter.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] [gdb/config/djgpp] Make djcheck.sh and djconfig.sh shellcheck-clean
2026-08-31 11:47 ` Eli Zaretskii
@ 2026-08-31 11:54 ` Tom de Vries
2026-08-31 12:15 ` Eli Zaretskii
2026-09-01 7:41 ` Tom de Vries
0 siblings, 2 replies; 5+ messages in thread
From: Tom de Vries @ 2026-08-31 11:54 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gdb-patches, DJ Delorie
On 8/31/26 1:47 PM, Eli Zaretskii wrote:
>> From: Tom de Vries <tdevries@suse.de>
>> Date: Mon, 31 Aug 2026 12:08:26 +0200
>>
>> Make gdb/config/djgpp/{djcheck.sh,djconfig.sh} shellcheck-clean:
>> - add missing quotes
>> - add "|| exit 1" after cd
>> - use printf instead of echo -n
>> - use $()
>> - disable SC2016 for "configure --prefix='${DJDIR}' assuming ${DJDIR} is
>> indeed not meant to be expanded
>
> What's the problem with `foo` that you replace it with $() everywhere?
>
Here ( https://www.shellcheck.net/wiki/SC2006 ) it's mentioned:
...
Rationale
Backtick command substitution `...` is legacy syntax with several issues.
It has a series of undefined behaviors related to quoting in POSIX.
It imposes a custom escaping mode with surprising results.
It's exceptionally hard to nest.
$(...) command substitution has none of these problems, and is therefore
strongly encouraged.
...
> I don't remember, but there's a risk that DJGPP ports of Bash might
> not support the latter.
I suppose I can suppress this rule in the entire directory using a
.shellcheckrc entry.
Thanks,
- Tom
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] [gdb/config/djgpp] Make djcheck.sh and djconfig.sh shellcheck-clean
2026-08-31 11:54 ` Tom de Vries
@ 2026-08-31 12:15 ` Eli Zaretskii
2026-09-01 7:41 ` Tom de Vries
1 sibling, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2026-08-31 12:15 UTC (permalink / raw)
To: Tom de Vries; +Cc: gdb-patches, dj
> Date: Mon, 31 Aug 2026 13:54:56 +0200
> Cc: gdb-patches@sourceware.org, DJ Delorie <dj@delorie.com>
> From: Tom de Vries <tdevries@suse.de>
>
> On 8/31/26 1:47 PM, Eli Zaretskii wrote:
> >> From: Tom de Vries <tdevries@suse.de>
> >> Date: Mon, 31 Aug 2026 12:08:26 +0200
> >>
> >> Make gdb/config/djgpp/{djcheck.sh,djconfig.sh} shellcheck-clean:
> >> - add missing quotes
> >> - add "|| exit 1" after cd
> >> - use printf instead of echo -n
> >> - use $()
> >> - disable SC2016 for "configure --prefix='${DJDIR}' assuming ${DJDIR} is
> >> indeed not meant to be expanded
> >
> > What's the problem with `foo` that you replace it with $() everywhere?
> >
>
> Here ( https://www.shellcheck.net/wiki/SC2006 ) it's mentioned:
> ...
> Rationale
>
> Backtick command substitution `...` is legacy syntax with several issues.
>
> It has a series of undefined behaviors related to quoting in POSIX.
> It imposes a custom escaping mode with surprising results.
> It's exceptionally hard to nest.
>
> $(...) command substitution has none of these problems, and is therefore
> strongly encouraged.
> ...
>
> > I don't remember, but there's a risk that DJGPP ports of Bash might
> > not support the latter.
>
> I suppose I can suppress this rule in the entire directory using a
> .shellcheckrc entry.
Thanks, maybe DJ will have an opinion or suggestions.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] [gdb/config/djgpp] Make djcheck.sh and djconfig.sh shellcheck-clean
2026-08-31 11:54 ` Tom de Vries
2026-08-31 12:15 ` Eli Zaretskii
@ 2026-09-01 7:41 ` Tom de Vries
1 sibling, 0 replies; 5+ messages in thread
From: Tom de Vries @ 2026-09-01 7:41 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gdb-patches, DJ Delorie
On 8/31/26 1:54 PM, Tom de Vries wrote:
>> I don't remember, but there's a risk that DJGPP ports of Bash might
>> not support the latter.
>
> I suppose I can suppress this rule in the entire directory using
> a .shellcheckrc entry.
I've submitted a v2 using that approach (
https://sourceware.org/pipermail/gdb-patches/2026-September/229886.html ).
Thanks,
- Tom
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-09-01 7:41 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-31 10:08 [PATCH] [gdb/config/djgpp] Make djcheck.sh and djconfig.sh shellcheck-clean Tom de Vries
2026-08-31 11:47 ` Eli Zaretskii
2026-08-31 11:54 ` Tom de Vries
2026-08-31 12:15 ` Eli Zaretskii
2026-09-01 7:41 ` Tom de Vries
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox