Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Tom de Vries <tdevries@suse.de>, gdb-patches@sourceware.org
Subject: Re: [PATCH 2/2] [gdb] Fix unbound variable in regformats/regdat.sh
Date: Fri, 28 Aug 2026 08:46:35 -0400	[thread overview]
Message-ID: <987c9664-c0ed-4052-be6c-cb80eec17dff@simark.ca> (raw)
In-Reply-To: <20260828120439.3857602-3-tdevries@suse.de>



On 2026-08-28 08:04, Tom de Vries wrote:
> While testing the previous patch, I noticed the following difference:
> ...
> $ sh ./gdb/regformats/regdat.sh \
>       gdb/regformats/rs6000/powerpc-isa205-ppr-dscr-vsx64l.dat \
>       gdbsupport/osabi.def \
>       tmp.txt
> $ ./gdb/regformats/regdat.sh \
>       gdb/regformats/rs6000/powerpc-isa205-ppr-dscr-vsx64l.dat \
>       gdbsupport/osabi.def \
>       tmp.txt
> ./gdb/regformats/regdat.sh: line 33: comment: unbound variable
> ...
> 
> The difference is due to the start of regdat.sh:
> ...
>  #!/bin/sh -u
> ...
> where -u is enabling the unbound variable check.
> 
> In the first variant, this setting is ignored.
> 
> Fix this by using "set -u" instead, making sure that the unbound variable
> check is done for both variants.
> 
> The comment variable is not used in a meaningful way, so fix the unbound
> variable error by removing it.
> 
> Tested in the same way as the preceding patch.

LGTM, thanks.

Approved-By: Simon Marchi <simon.marchi@efficios.com>

> ---
>  gdb/regformats/regdat.sh | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/gdb/regformats/regdat.sh b/gdb/regformats/regdat.sh
> index 01f2dabe459..f93270ba0ca 100755
> --- a/gdb/regformats/regdat.sh
> +++ b/gdb/regformats/regdat.sh
> @@ -1,4 +1,4 @@
> -#!/bin/sh -u
> +#!/bin/sh
>  
>  # Register protocol definitions for GDB, the GNU debugger.
>  # Copyright (C) 2001-2026 Free Software Foundation, Inc.
> @@ -18,6 +18,8 @@
>  # You should have received a copy of the GNU General Public License
>  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>  
> +set -u
> +
>  # Format of the input files
>  read="type entry"
>  
> @@ -28,15 +30,11 @@ do_read ()
>      while read -r line
>      do
>  	if test "${line}" = ""
> -	then
> -	    continue
> -	elif test "${line}" = "#" -a "${comment}" = ""
>  	then
>  	    continue
>  	elif expr "${line}" : "#" > /dev/null
>  	then
> -	    comment="${comment}

Unrelated comment: I'd like if we could standardize on

  if ...; then
  for ... in ...; do
  while ...; do

instead of

  if ...
  then

  for ... in ...
  do

  while ...
  do

I think it's more common, easier to read and takes less unnecessary
lines.

Simon

  reply	other threads:[~2026-08-28 12:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-28 12:04 [PATCH 0/2] [gdb] Two regformats/regdat.sh fixes Tom de Vries
2026-08-28 12:04 ` [PATCH 1/2] [gdb] Make regformats/regdat.sh shellcheck-clean Tom de Vries
2026-08-28 12:43   ` Simon Marchi
2026-08-28 14:40     ` Tom de Vries
2026-08-28 13:34   ` Andreas Schwab
2026-08-28 14:04     ` Tom de Vries
2026-08-28 12:04 ` [PATCH 2/2] [gdb] Fix unbound variable in regformats/regdat.sh Tom de Vries
2026-08-28 12:46   ` Simon Marchi [this message]
2026-08-28 14:19     ` 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=987c9664-c0ed-4052-be6c-cb80eec17dff@simark.ca \
    --to=simark@simark.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=tdevries@suse.de \
    /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