help-bash
[Top][All Lists]
Advanced

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

Re: Use of $@


From: Kerin Millar
Subject: Re: Use of $@
Date: Tue, 21 Feb 2023 12:50:33 +0000

On Tue, 21 Feb 2023 07:39:37 -0500
Greg Wooledge <greg@wooledge.org> wrote:

> On Tue, Feb 21, 2023 at 01:34:37PM +0100, Christof Warlich wrote:
> > $ index() { local e="$1"; shift; for i in "${!@}"; do [[ ${!i} != $e ]]
> > || { echo $i; break; }; done; }
> > $ LANG=C index "xx yy" "${myarray[@]}"
> > bash: a bc xx yy z: invalid variable name
> > 
> > Can anyone spot what's wrong?
> 
> I don't know what "${!@}" does, but clearly it doesn't do what you
> thought:
> 
> unicorn:~$ set -- a bc; printf '<%s>\n' "${!@}"
> bash: a bc: invalid variable name
> 
> It looks like it has no use whatsoever, given that it bombs out on
> arbitrary inputs.
> 

It's yet another instance in which bash elects to join the parameters by the 
space character. In this case, the resulting word is treated as a name 
reference. Useless indeed.

-- 
Kerin Millar



reply via email to

[Prev in Thread] Current Thread [Next in Thread]