* [PATCH] gdb-add-index.sh: Remove use of non posix 'local'
@ 2021-03-26 17:14 Lancelot SIX
2021-03-26 18:39 ` Simon Marchi
0 siblings, 1 reply; 3+ messages in thread
From: Lancelot SIX @ 2021-03-26 17:14 UTC (permalink / raw)
To: gdb-patches; +Cc: Lancelot SIX
While working on gdb-add-index.sh, it appeared that it uses the non
POSIX 'local' keyword. Instead of using local to allow variable
shadowing, I rename the local one to avoid name conflicts altogether.
gdb/ChangeLog:
* contrib/gdb-add-index.sh: Avoid variable shadowing and get
rid of 'local'.
---
gdb/contrib/gdb-add-index.sh | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/gdb/contrib/gdb-add-index.sh b/gdb/contrib/gdb-add-index.sh
index 48a85136a4c..dfefc507001 100755
--- a/gdb/contrib/gdb-add-index.sh
+++ b/gdb/contrib/gdb-add-index.sh
@@ -73,13 +73,13 @@ fi
set_files ()
{
- local file="$1"
+ fpath="$1"
- index4="${file}.gdb-index"
- index5="${file}.debug_names"
- debugstr="${file}.debug_str"
- debugstrmerge="${file}.debug_str.merge"
- debugstrerr="${file}.debug_str.err"
+ index4="${fpath}.gdb-index"
+ index5="${fpath}.debug_names"
+ debugstr="${fpath}.debug_str"
+ debugstrmerge="${fpath}.debug_str.merge"
+ debugstrerr="${fpath}.debug_str.err"
}
tmp_files=
@@ -112,13 +112,12 @@ status=0
handle_file ()
{
- local file
- file="$1"
+ fpath="$1"
- set_files "$file"
+ set_files "$fpath"
if test -f "$index4" -a -f "$index5"; then
- echo "$myname: Both index types were created for $file" 1>&2
+ echo "$myname: Both index types were created for $fpath" 1>&2
status=1
elif test -f "$index4" -o -f "$index5"; then
if test -f "$index4"; then
@@ -131,7 +130,7 @@ handle_file ()
debugstradd=false
debugstrupdate=false
if test -s "$debugstr"; then
- if ! $OBJCOPY --dump-section .debug_str="$debugstrmerge" "$file" \
+ if ! $OBJCOPY --dump-section .debug_str="$debugstrmerge" "$fpath" \
/dev/null 2>$debugstrerr; then
cat >&2 $debugstrerr
exit 1
@@ -155,11 +154,11 @@ handle_file ()
if $debugstrupdate; then \
echo --update-section .debug_str="$debugstrmerge"; \
fi) \
- "$file" "$file"
+ "$fpath" "$fpath"
status=$?
else
- echo "$myname: No index was created for $file" 1>&2
+ echo "$myname: No index was created for $fpath" 1>&2
echo "$myname: [Was there no debuginfo? Was there already an index?]" \
1>&2
fi
--
2.30.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] gdb-add-index.sh: Remove use of non posix 'local'
2021-03-26 17:14 [PATCH] gdb-add-index.sh: Remove use of non posix 'local' Lancelot SIX
@ 2021-03-26 18:39 ` Simon Marchi
2021-03-26 23:56 ` Lancelot SIX
0 siblings, 1 reply; 3+ messages in thread
From: Simon Marchi @ 2021-03-26 18:39 UTC (permalink / raw)
To: Lancelot SIX, gdb-patches
On 2021-03-26 1:14 p.m., Lancelot SIX via Gdb-patches wrote:
> While working on gdb-add-index.sh, it appeared that it uses the non
> POSIX 'local' keyword. Instead of using local to allow variable
> shadowing, I rename the local one to avoid name conflicts altogether.
Thanks, this is OK. You can also mention in the commit message that it
gets rid of this shellcheck warning:
In gdb-add-index.sh line 63:
local file="$1"
^--------^ SC2039: In POSIX sh, 'local' is undefined.
Simon
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] gdb-add-index.sh: Remove use of non posix 'local'
2021-03-26 18:39 ` Simon Marchi
@ 2021-03-26 23:56 ` Lancelot SIX
0 siblings, 0 replies; 3+ messages in thread
From: Lancelot SIX @ 2021-03-26 23:56 UTC (permalink / raw)
To: Simon Marchi; +Cc: gdb-patches
Le Fri, Mar 26, 2021 at 02:39:52PM -0400, Simon Marchi a écrit :
> On 2021-03-26 1:14 p.m., Lancelot SIX via Gdb-patches wrote:
> > While working on gdb-add-index.sh, it appeared that it uses the non
> > POSIX 'local' keyword. Instead of using local to allow variable
> > shadowing, I rename the local one to avoid name conflicts altogether.
>
> Thanks, this is OK. You can also mention in the commit message that it
> gets rid of this shellcheck warning:
>
>
> In gdb-add-index.sh line 63:
> local file="$1"
> ^--------^ SC2039: In POSIX sh, 'local' is undefined.
>
>
> Simon
I have added this info to the commit message and pushed.
Thanks,
Lancelot.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-03-26 23:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-26 17:14 [PATCH] gdb-add-index.sh: Remove use of non posix 'local' Lancelot SIX
2021-03-26 18:39 ` Simon Marchi
2021-03-26 23:56 ` Lancelot SIX
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).