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: [pushed] [gdb] Make po/gdbtext shellcheck-clean
Date: Fri, 28 Aug 2026 10:38:29 +0200	[thread overview]
Message-ID: <20260828083829.3189700-1-tdevries@suse.de> (raw)

Make po/gdbtext shellcheck-clean.

First:
- add missing quotes in a few places
- do "find *" -> "find -- *"

Then, restructure the code into two functions, leaving just:
...
find_files "$@" \
    | run_xgettext "$@"
...
and fix:
...
In gdb/po/gdbtext line 38:
    ${__directories} \
    ^--------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
...
by eliminating the variable and using "set --" [1] instead.

Tested on x86_64-linux by running make po/gdb.pot and comparing po/gdb.pot
with and without the patch.

Also add an entry in gdb/.gitattributes to ensure whitespace errors are detected.

[1] https://www.shellcheck.net/wiki/SC2086
---
 gdb/.gitattributes        |  1 +
 gdb/contrib/shellcheck.sh |  1 -
 gdb/po/gdbtext            | 77 +++++++++++++++++++++++++--------------
 3 files changed, 51 insertions(+), 28 deletions(-)

diff --git a/gdb/.gitattributes b/gdb/.gitattributes
index f176977e7aa..9cb0318dca8 100644
--- a/gdb/.gitattributes
+++ b/gdb/.gitattributes
@@ -20,6 +20,7 @@ aclocal.m4  -whitespace
 
 *.[ly]	whitespace=space-before-tab,indent-with-non-tab,trailing-space
 *.def	whitespace=space-before-tab,indent-with-non-tab,trailing-space
+po/gdbtext  whitespace=space-before-tab,indent-with-non-tab,trailing-space
 
 # Imported files.
 exc_request.defs -whitespace
diff --git a/gdb/contrib/shellcheck.sh b/gdb/contrib/shellcheck.sh
index 64a6b8b6b22..f7f7bf9efbf 100755
--- a/gdb/contrib/shellcheck.sh
+++ b/gdb/contrib/shellcheck.sh
@@ -47,7 +47,6 @@ for f in "$@"; do
 	    | gdb/contrib/gdb-add-index.sh \
 	    | gdb/gdb_buildall.sh \
 	    | gdb/gdb_mbuild.sh \
-	    | gdb/po/gdbtext \
 	    | gdb/regformats/regdat.sh \
 	    | gdb/testsuite/lib/pdtrace.in)
 	    # Skip unclean files.
diff --git a/gdb/po/gdbtext b/gdb/po/gdbtext
index 37cd6dd3ae9..152a0dba0c4 100755
--- a/gdb/po/gdbtext
+++ b/gdb/po/gdbtext
@@ -9,31 +9,54 @@ fi
 xgettext=$1 ; shift
 package=$1 ; shift
 
-for d in "$@"
-do
-  __directories="$__directories --directory=$d"
-done
+find_files ()
+{
+    for d in "$@"; do
+	(
+	    cd "$d"
+	    find -- * \
+		 -name '*-stub.c' -prune -o \
+		 -name 'testsuite' -prune -o \
+		 -name 'init.c' -prune -o \
+		 -name '*.[hc]' -print -o \
+		 -name '*.cc' -print
+	)
+    done
+}
 
-for d in "$@"
-do
-  (
-      cd $d
-      find * \
-	  -name '*-stub.c' -prune -o \
-	  -name 'testsuite' -prune -o \
-	  -name 'init.c' -prune -o \
-	  -name '*.[hc]' -print -o \
-	  -name '*.cc' -print
-  )
-done | ${xgettext} \
-    --default-domain=${package} \
-    --copyright-holder="Free Software Foundation, Inc." \
-    --add-comments \
-    --files-from=- \
-    --force-po \
-    --debug \
-    --language=c++ \
-    --keyword=_ \
-    --keyword=N_ \
-    ${__directories} \
-    -o po/${package}.pot
+run_xgettext ()
+{
+    # Transform:
+    #   "$@" == "arg1" "arg2" ...
+    # into:
+    #   "$@" == "--directory=arg1" "--directory=arg2" ...
+    first=true
+    for d in "$@"; do
+	if $first; then
+	    # Clear "$@", before we start appending to it.
+	    set --
+	    first=false
+	fi
+
+	# Append to "$@".
+	set -- \
+	    "$@" \
+	    --directory="$d"
+    done
+
+    ${xgettext} \
+	--default-domain="${package}" \
+	--copyright-holder="Free Software Foundation, Inc." \
+	--add-comments \
+	--files-from=- \
+	--force-po \
+	--debug \
+	--language=c++ \
+	--keyword=_ \
+	--keyword=N_ \
+	"$@" \
+	-o po/"${package}".pot
+}
+
+find_files "$@" \
+    | run_xgettext "$@"

base-commit: c562e4ffa94c50ee974200a7457e435cec411a43
-- 
2.51.0


                 reply	other threads:[~2026-08-28  8:39 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=20260828083829.3189700-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