Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Keith Seitz <keiths@redhat.com>, Sam James <sam@gentoo.org>,
	gdb-patches@sourceware.org
Subject: Re: [PATCH 1/2] gcore: improve shell use
Date: Mon, 31 Mar 2025 14:26:01 -0400	[thread overview]
Message-ID: <ad678123-2d34-42ae-9162-f3de665c3981@simark.ca> (raw)
In-Reply-To: <944054f1-6a59-4115-8340-95d399b931e2@redhat.com>

On 3/29/25 7:42 PM, Keith Seitz wrote:
> Hi,
> 
> On 3/28/25 11:58 AM, Sam James wrote:
>> * Use bash tests, i.e. '[[' and ']]', instead of POSIX '[' and ']' or
>>    'test' which have their own pitfalls, given gcore has a bash shebang already.
>>
>> * Use $() subshell syntax rather than `backticks`.
> 
> Nice. I didn't actually know that '[['/']]' was preferred. I'll have
> to remember that.
> 
>> ---
>>   gdb/gcore-1.in | 22 +++++++++++-----------
>>   1 file changed, 11 insertions(+), 11 deletions(-)
>>
>> diff --git a/gdb/gcore-1.in b/gdb/gcore-1.in
>> index c0979a51db3..edd807b86dc 100644
>> --- a/gdb/gcore-1.in
>> +++ b/gdb/gcore-1.in
>> @@ -139,14 +139,14 @@ if test "x$binary_path" = x. ; then
>>       # The gcore script was not found in ".", which means the script
>>       # was called from somewhere else in $PATH by "sh gcore".
>>       # Extract the correct path now.
>> -    binary_path_from_env=`which "$0"`
>> -    binary_path=`dirname "$binary_path_from_env"`
>> +    binary_path_from_env=$(which "$0")
>> +    binary_path=$(dirname "$binary_path_from_env")
> 
> This uses 'which', and we've (downstream distros) run into issues
> with this and package dependencies. Since this strictly bash,
> can we use "command -v" here instead?

Can you clarify what kind of issues?  Do you mean that `which` may not
be available?

shellcheck points out this:

In gcore line 69:
        OPTARG="${OPTARG#'$OPT'}"
                         ^----^ SC2016 (info): Expressions don't expand in single quotes, use double quotes for that.

I actually can't figure out what this "if" does:

    if [[ "$OPT" = "-" ]]; then
	OPT="${OPTARG%%=*}"
	OPTARG="${OPTARG#'$OPT'}"
	OPTARG="${OPTARG#=}"
    fi

Any idea?

Simon

  reply	other threads:[~2025-03-31 18:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-28 18:58 [PATCH 0/2] shell fixes for gcore, gdb-add-index Sam James
2025-03-28 18:58 ` [PATCH 1/2] gcore: improve shell use Sam James
2025-03-29 23:42   ` Keith Seitz
2025-03-31 18:26     ` Simon Marchi [this message]
2025-03-31 18:44       ` Andreas Schwab
2025-03-31 18:54         ` Simon Marchi
2025-04-02 16:08           ` Keith Seitz
2025-04-01 13:39   ` Tom Tromey
2025-04-02 16:15     ` Simon Marchi
2025-04-02 20:31       ` Tom Tromey
2025-03-28 18:58 ` [PATCH 2/2] gdb-add-index: fix shellcheck warnings Sam James
2025-03-29 23:42   ` Keith Seitz
2025-03-31 18:30     ` 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=ad678123-2d34-42ae-9162-f3de665c3981@simark.ca \
    --to=simark@simark.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=keiths@redhat.com \
    --cc=sam@gentoo.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