Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH] [gdb/config/djgpp] Make djcheck.sh and djconfig.sh shellcheck-clean
Date: Mon, 31 Aug 2026 12:08:26 +0200	[thread overview]
Message-ID: <20260831100826.3521717-1-tdevries@suse.de> (raw)

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


             reply	other threads:[~2026-08-31 10:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-31 10:08 Tom de Vries [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260831100826.3521717-1-tdevries@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox