From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH v2] [gdb/contrib] Make gdb-add-index.sh shellcheck-clean
Date: Wed, 23 Sep 2026 09:13:43 +0200 [thread overview]
Message-ID: <20260923071343.2887804-1-tdevries@suse.de> (raw)
Make gdb-add-index.sh shellcheck-clean:
- drop x in "xa" != "xb" comparison
- eliminate tmp_files
- drop dwz_file=$(echo $dwz_file) and strip leading spaces using
sed instead
Also for clarity:
- use $file instead of $1
- use set -- after consuming last argument
Changes in v2:
- use "$file" instead of $1
- to eliminate tmp_files, don't use $@ but list tmp files explicitly in
cleanup function
Versions:
- v1 https://sourceware.org/pipermail/gdb-patches/2026-September/230364.html
---
gdb/contrib/gdb-add-index.sh | 38 +++++++++++++++++++++---------------
gdb/contrib/shellcheck.sh | 4 ----
2 files changed, 22 insertions(+), 20 deletions(-)
diff --git a/gdb/contrib/gdb-add-index.sh b/gdb/contrib/gdb-add-index.sh
index 4a30c5c5536..0c7797d23ed 100755
--- a/gdb/contrib/gdb-add-index.sh
+++ b/gdb/contrib/gdb-add-index.sh
@@ -82,7 +82,7 @@ case ${opt} in
;;
esac
# Break from loop if the first character of OPT is not '-'.
-[ "x$(printf %.1s "$opt")" != "x-" ]
+[ "$(printf %.1s "$opt")" != "-" ]
do
shift
done
@@ -93,10 +93,11 @@ if test $# != 1; then
fi
file="$1"
+set --
if test -L "$file"; then
if ! command -v readlink >/dev/null 2>&1; then
- echo "$myname: 'readlink' missing. Failed to follow symlink $1." 1>&2
+ echo "$myname: 'readlink' missing. Failed to follow symlink $file." 1>&2
exit 1
fi
@@ -135,8 +136,7 @@ if $READELF -S "$file" | grep -q " \.gnu_debugaltlink "; then
dwz_file=$($READELF --string-dump=.gnu_debugaltlink "$file" \
| grep -A1 "'\.gnu_debugaltlink':" \
| tail -n +2 \
- | sed 's/.*]//')
- dwz_file=$(echo $dwz_file)
+ | sed 's/.*] *//')
if $READELF -S "$dwz_file" | grep -E -q " \.(gdb_index|debug_names) "; then
# Already has an index, skip it.
dwz_file=""
@@ -154,19 +154,25 @@ set_files ()
debugstrerr="${fpath}.debug_str.err"
}
-tmp_files=
-for f in "$file" "$dwz_file"; do
- if [ "$f" = "" ]; then
- continue
- fi
- set_files "$f"
- tmp_files="$tmp_files $index4 $index5 $debugstr $debugstrmerge $debugstrerr"
-done
-
-rm -f $tmp_files
-
# Ensure intermediate index file is removed when we exit.
-trap "rm -f $tmp_files" 0
+cleanup ()
+{
+ for f in "$file" "$dwz_file"; do
+ if [ "$f" = "" ]; then
+ continue
+ fi
+ set_files "$f"
+ rm -f \
+ "$index4" \
+ "$index5" \
+ "$debugstr" \
+ "$debugstrmerge" \
+ "$debugstrerr"
+ done
+}
+
+cleanup
+trap cleanup 0
$GDB --batch -nx -iex 'set auto-load no' \
-iex 'set debuginfod enabled off' \
diff --git a/gdb/contrib/shellcheck.sh b/gdb/contrib/shellcheck.sh
index 6417d7a871f..9056206ea5f 100755
--- a/gdb/contrib/shellcheck.sh
+++ b/gdb/contrib/shellcheck.sh
@@ -41,10 +41,6 @@ for f in "$@"; do
# Skip generated files.
continue
;;
- gdb/contrib/gdb-add-index.sh )
- # Skip unclean files.
- continue
- ;;
*)
files=("${files[@]}" "$f")
;;
base-commit: a121bf759aefc18f3be9c5495d23ebe39354810b
--
2.51.0
next reply other threads:[~2026-09-23 7:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-23 7:13 Tom de Vries [this message]
2026-09-23 15:21 ` Keith Seitz
2026-09-23 18:48 ` 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=20260923071343.2887804-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