* [PATCH] [gdb/contrib] Make gdb-add-index.sh shellcheck-clean
@ 2026-09-15 17:14 Tom de Vries
0 siblings, 0 replies; only message in thread
From: Tom de Vries @ 2026-09-15 17:14 UTC (permalink / raw)
To: gdb-patches
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-09-15 17:15 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-15 17:14 [PATCH] [gdb/contrib] Make gdb-add-index.sh shellcheck-clean 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