From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH v2 2/3] [gdb] Use shfmt on regformats/regdat.sh
Date: Sun, 30 Aug 2026 21:53:14 +0200 [thread overview]
Message-ID: <20260830195315.1497894-3-tdevries@suse.de> (raw)
In-Reply-To: <20260830195315.1497894-1-tdevries@suse.de>
Run shfmt [1] on gdb/regformats/regdat.sh:
...
$ shfmt \
--language-dialect=posix \
--indent=4 \
--func-next-line \
--space-redirects \
--write \
gdb/regformats/regdat.sh
...
followed by emacs whitespace-cleanup (because shfmt doesn't know about mixed
tab/spaces indentation).
Normalizes things like:
...
if true
then
...
to:
...
if true; then
...
as suggested by Simon [2].
Also:
- makes sure statements are on their own line
- removes double empty line
- minor whitespace changes:
- do_read () -> do_read()
- cat <<EOF -> cat << EOF
[1] https://github.com/mvdan/sh
[2] https://sourceware.org/pipermail/gdb-patches/2026-August/229818.html
---
gdb/regformats/regdat.sh | 35 ++++++++++++++---------------------
1 file changed, 14 insertions(+), 21 deletions(-)
diff --git a/gdb/regformats/regdat.sh b/gdb/regformats/regdat.sh
index 2f48c165fc8..6cac186735e 100755
--- a/gdb/regformats/regdat.sh
+++ b/gdb/regformats/regdat.sh
@@ -23,17 +23,14 @@ set -u
# Format of the input files
read="type entry"
-do_read ()
+do_read()
{
type=""
entry=""
- while read -r line
- do
- if test "${line}" = ""
- then
+ while read -r line; do
+ if test "${line}" = ""; then
continue
- elif expr "${line}" : "#" > /dev/null
- then
+ elif expr "${line}" : "#" > /dev/null; then
continue
else
@@ -42,21 +39,20 @@ do_read ()
# Work around this by eliminating ``::'' ....
line="$(echo "${line}" | sed -e 's/::/: :/g' -e 's/::/: :/g')"
- OFS="${IFS}" ; IFS="[:]"
+ OFS="${IFS}"
+ IFS="[:]"
# Word-splitting on read variable is required.
# shellcheck disable=SC2086
- eval read ${read} <<EOF
+ eval read ${read} << EOF
${line}
EOF
IFS="${OFS}"
# .... and then going back through each field and strip out those
# that ended up with just that space character.
- for r in ${read}
- do
+ for r in ${read}; do
eval "rvalue=\$$r"
- if test "${rvalue:-}" = " "
- then
+ if test "${rvalue:-}" = " "; then
eval "$r=''"
fi
done
@@ -64,8 +60,7 @@ EOF
break
fi
done
- if [ -n "${type}" ]
- then
+ if [ -n "${type}" ]; then
true
else
false
@@ -77,9 +72,9 @@ if test ! -r "$1"; then
exit 1
fi
-copyright ()
+copyright()
{
- cat <<EOF
+ cat << EOF
/* *INDENT-OFF* */ /* THIS FILE IS GENERATED */
/* A register protocol for GDB, the GNU debugger.
@@ -105,7 +100,6 @@ copyright ()
EOF
}
-
exec > new-"$3"
copyright "$1"
echo '#include "regdef.h"'
@@ -121,8 +115,7 @@ expedite=x
feature=x
osabi=unknown
exec < "$1"
-while do_read
-do
+while do_read; do
if test "${type}" = "name"; then
name="${entry}"
@@ -194,7 +187,7 @@ echo
osabi_enum=$(grep "${osabi}" "$2" | sed 's/.*(\([^,]\+\),.*/GDB_OSABI_\1/')
-cat <<EOF
+cat << EOF
result->xmltarget = xmltarget_${name};
#endif
--
2.51.0
next prev parent reply other threads:[~2026-08-30 19:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-30 19:53 [PATCH v2 0/3] [gdb] Reformat regformats/regdat.sh Tom de Vries
2026-08-30 19:53 ` [PATCH v2 1/3] [gdb] Re-indent regformats/regdat.sh Tom de Vries
2026-08-31 20:09 ` Simon Marchi
2026-09-01 9:21 ` Tom de Vries
2026-08-30 19:53 ` Tom de Vries [this message]
2026-08-31 20:13 ` [PATCH v2 2/3] [gdb] Use shfmt on regformats/regdat.sh Simon Marchi
2026-09-02 13:21 ` Tom de Vries
2026-08-30 19:53 ` [PATCH v2 3/3] [gdb] Use shfmt --simplify " Tom de Vries
2026-08-31 20:14 ` Simon Marchi
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=20260830195315.1497894-3-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