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

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

 



On Wed, May 29, 2024 at 04:27:00PM +0300, Andy Shevchenko wrote:
> On Wed, May 29, 2024 at 09:18:47PM +0800, Kent Gibson wrote:
> > On Wed, May 29, 2024 at 04:08:49PM +0300, Andy Shevchenko wrote:
> > > 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?
> >
> > That's right - I was only referring to this particular case where a
> > string is being constructed.  Wasn't that clear?
>
> I meant that if you want to have this knowledge in the debug / error message,
> you will fail with $*, that's why I consider shellcheck is incorrect.
>
> Ex.
>
> I have
>
> 	foo bar "baz bar2"
>
> and I want
>
> 	"ERROR: 'foo bar "baz bar2"' failed"
>
> type of message.
>

Fair point, but $@ doesn't give you that either:

boo() {
	echo "star '$*'"
	echo "hash '$@'"
}

boo foo bar "baz bar2"

gives:

star 'foo bar baz bar2'
hash 'foo bar baz bar2'

Is there any form that gives you the format you want?

Cheers,
Kent.




[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