Re: [PATCH libgpiod v2 2/4] tools: tests: use "$@" instead of $*

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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].

Because $@ is an array being used to build a string, and that may not
work the way you expect.  In this case $* is clearer as that has already
been concatenated.

Cheers,
Kent.

[1] https://www.shellcheck.net/wiki/SC2145






[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux