From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Kent Gibson <warthog618@gmail.com>
Cc: Bartosz Golaszewski <brgl@bgdev.pl>,
Linus Walleij <linus.walleij@linaro.org>,
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>,
linux-gpio@vger.kernel.org
Subject: Re: [PATCH libgpiod v2 2/4] tools: tests: use "$@" instead of $*
Date: Wed, 29 May 2024 16:08:49 +0300 [thread overview]
Message-ID: <Zlco4cBEWJVrnVU2@smile.fi.intel.com> (raw)
In-Reply-To: <20240527233910.GA3504@rigel>
On Tue, May 28, 2024 at 07:39:10AM +0800, Kent Gibson wrote:
> On Mon, May 27, 2024 at 07:17:37PM +0300, Andy Shevchenko wrote:
> > On Mon, May 27, 2024 at 08:44:20PM +0800, Kent Gibson wrote:
> > > On Mon, May 27, 2024 at 02:02:34PM +0200, Bartosz Golaszewski wrote:
...
> > > > assert_fail() {
> > > > - $* || return 0
> > > > - fail " '$*': command did not fail as expected"
> > > > + "$@" || return 0
> > > > + fail " '$@': command did not fail as expected"
> > > > }
> > >
> > > Ironically, shellcheck doesn't like the '$@' in the fail string[1], so you
> > > should use $* there.
> >
> > But why does it do like this?
>
> Read the link[1].
Okay, this is only for some debug / error messages. Still if one wants to have
clear understanding on what has been passed to some function, $* is not a
correct option. Also note the single quotes, shouldn't that protect from the
arguments loss?
> Because $@ is an array being used to build a string, and that may not
> work the way you expect.
I think it's the opposite, $* works in a way I do not expect :-)
> In this case $* is clearer as that has already
> been concatenated.
...loosing information about which word refers to which argument, yes.
> [1] https://www.shellcheck.net/wiki/SC2145
TL;DR: I consider this is still a bug in shellcheck. But if you rely on the
tool as on the ruleset carved in stone, I will not die. Just a remark to
myself "even honourable tools may also be broken".
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2024-05-29 13:10 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-27 12:02 [PATCH libgpiod v2 0/4] tools: tests: fix a few issues in bash scripts Bartosz Golaszewski
2024-05-27 12:02 ` [PATCH libgpiod v2 1/4] tools: tests: use tabs for indentation consistently Bartosz Golaszewski
2024-05-27 12:02 ` [PATCH libgpiod v2 2/4] tools: tests: use "$@" instead of $* Bartosz Golaszewski
2024-05-27 12:44 ` Kent Gibson
2024-05-27 12:51 ` Bartosz Golaszewski
2024-05-27 12:57 ` Kent Gibson
2024-05-27 13:20 ` Kent Gibson
2024-05-27 15:45 ` Bartosz Golaszewski
2024-05-27 16:17 ` Andy Shevchenko
2024-05-27 23:39 ` Kent Gibson
2024-05-29 13:08 ` Andy Shevchenko [this message]
2024-05-29 13:18 ` Kent Gibson
2024-05-29 13:27 ` Andy Shevchenko
2024-05-29 13:44 ` Kent Gibson
2024-05-29 14:33 ` Andy Shevchenko
2024-05-30 0:22 ` Kent Gibson
2024-05-30 14:14 ` Andy Shevchenko
2024-05-27 16:20 ` Andy Shevchenko
2024-05-27 23:54 ` Kent Gibson
2024-05-29 13:11 ` Andy Shevchenko
2024-05-27 12:02 ` [PATCH libgpiod v2 3/4] tools: tests: remove unneeded ';' in while loops Bartosz Golaszewski
2024-05-27 12:02 ` [PATCH libgpiod v2 4/4] tools: tests: remove dependency on grep Bartosz Golaszewski
2024-05-27 16:16 ` Andy Shevchenko
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=Zlco4cBEWJVrnVU2@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=bartosz.golaszewski@linaro.org \
--cc=brgl@bgdev.pl \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=warthog618@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.