From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH] [gdb/contrib] Make gdb-add-index.sh shellcheck-clean
Date: Tue, 15 Sep 2026 19:14:59 +0200 [thread overview]
Message-ID: <20260915171459.2753844-1-tdevries@suse.de> (raw)
Make gdb-add-index.sh shellcheck-clean:
- drop x in "xa" != "xb" comparison
- eliminate tmp_files and use the args array instead
- drop dwz_file=$(echo $dwz_file) and strip leading spaces using
sed instead
---
gdb/contrib/gdb-add-index.sh | 19 ++++++++++++-------
gdb/contrib/shellcheck.sh | 4 ----
2 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/gdb/contrib/gdb-add-index.sh b/gdb/contrib/gdb-add-index.sh
index 4a30c5c5536..e1a37f2cd4c 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,6 +93,7 @@ if test $# != 1; then
fi
file="$1"
+set --
if test -L "$file"; then
if ! command -v readlink >/dev/null 2>&1; then
@@ -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,24 @@ 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"
+ set -- \
+ "$@" \
+ "$index4" \
+ "$index5" \
+ "$debugstr" \
+ "$debugstrmerge" \
+ "$debugstrerr"
done
-rm -f $tmp_files
+rm -f "$@"
# Ensure intermediate index file is removed when we exit.
-trap "rm -f $tmp_files" 0
+trap 'rm -f "$@"' 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: eec39a2f9250c622d86219cc182c4feaa6b07c50
--
2.51.0
reply other threads:[~2026-09-15 17:15 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260915171459.2753844-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