]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: make gcore-1.in and gstack-1.in shellcheck-clean
authorSimon Marchi <simon.marchi@efficios.com>
Fri, 19 Sep 2025 20:44:14 +0000 (16:44 -0400)
committerSimon Marchi <simon.marchi@polymtl.ca>
Sat, 20 Sep 2025 00:28:57 +0000 (20:28 -0400)
Fix all the warnings pasted below, mostly by accepting shellcheck's
suggestions.

The only exception is $GDBARGS in gstack.  There, we actually want the
space-splitting, I suppose, so I chose to just ignore the warning on
that line.  In any case, I'm not looking to change the existing behavior
in this patch.

The warnings:

    $ shellcheck gstack-1.in gcore-1.in

    In gstack-1.in line 135:
    "$GDB" --quiet -nx $GDBARGS <<EOF |
                       ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.

    Did you mean:
    "$GDB" --quiet -nx "$GDBARGS" <<EOF |

    In gcore-1.in line 130:
    binary_path=`dirname "$0"`
                ^------------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.

    Did you mean:
    binary_path=$(dirname "$0")

    In gcore-1.in line 132:
    if test "x$binary_path" = x. ; then
            ^-------------^ SC2268 (style): Avoid x-prefix in comparisons as it no longer serves a purpose.

    Did you mean:
    if test "$binary_path" = . ; then

    In gcore-1.in line 136:
      binary_basename=`basename "$0"`
                      ^-------------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.

    Did you mean:
      binary_basename=$(basename "$0")

    In gcore-1.in line 150:
        binary_path_from_env=`which "$0"`
                             ^----------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.

    Did you mean:
        binary_path_from_env=$(which "$0")

    In gcore-1.in line 151:
        binary_path=`dirname "$binary_path_from_env"`
                    ^-- SC2006 (style): Use $(...) notation instead of legacy backticks `...`.

    Did you mean:
        binary_path=$(dirname "$binary_path_from_env")

    In gcore-1.in line 159:
    gdb_binary_basename=`basename "$gdb_binary"`
                        ^----------------------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.

    Did you mean:
    gdb_binary_basename=$(basename "$gdb_binary")

    For more information:
      https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ...
      https://www.shellcheck.net/wiki/SC2006 -- Use $(...) notation instead of le...
      https://www.shellcheck.net/wiki/SC2268 -- Avoid x-prefix in comparisons as ...

Change-Id: I0eeaf5dc968df1ebafce58d9a9053d149f7f7859
Reviewed-By: Sébastien Darche <sdarche@efficios.com>
Reviewed-By: Keith Seitz <keiths@redhat.com>
gdb/gcore-1.in
gdb/gstack-1.in

index c8da3c6d3ac65e646bda54a331729c3e78f237f3..fe2bb3d650adf146cb609592501f1cda6a681290 100755 (executable)
@@ -127,13 +127,13 @@ fi
 
 # Attempt to fetch the absolute path to the gcore script that was
 # called.
-binary_path=`dirname "$0"`
+binary_path=$(dirname "$0")
 
-if test "x$binary_path" = x. ; then
+if test "$binary_path" = . ; then
   # We got "." back as a path.  This means the user executed
   # the gcore script locally (i.e. ./gcore) or called the
   # script via a shell interpreter (i.e. sh gcore).
-  binary_basename=`basename "$0"`
+  binary_basename=$(basename "$0")
 
   # If the gcore script was called like "sh gcore" and the script
   # lives in the current directory, "which" will not give us "gcore".
@@ -147,8 +147,8 @@ if test "x$binary_path" = x. ; then
     # The gcore script was not found in ".", which means the script
     # was called from somewhere else in $PATH by "sh gcore".
     # Extract the correct path now.
-    binary_path_from_env=`which "$0"`
-    binary_path=`dirname "$binary_path_from_env"`
+    binary_path_from_env=$(which "$0")
+    binary_path=$(dirname "$binary_path_from_env")
   fi
 fi
 
@@ -156,7 +156,7 @@ if [ -z "$gdb_binary" ]; then
    gdb_binary="$binary_path/@GDB_TRANSFORM_NAME@"
 fi
 
-gdb_binary_basename=`basename "$gdb_binary"`
+gdb_binary_basename=$(basename "$gdb_binary")
 
 # Check if the GDB binary is in the expected path.  If not, just
 # quit with a message.
index f2ed6b804c9f91e14061a93e4f8dd41a86bd97bf..ac5e8d4327837d0a1778b91e768eff22388e44bb 100755 (executable)
@@ -132,6 +132,7 @@ EOF
          )
 
 # Run GDB and remove some unwanted noise.
+# shellcheck disable=SC2086
 "$GDB" --quiet -nx $GDBARGS <<EOF |
 set width 0
 set height 0