[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
- Re: Use of $@, (continued)
- Re: Use of $@, Andreas Kusalananda Kähäri, 2023/02/21
- Re: Use of $@, Kerin Millar, 2023/02/21
- Re: Use of $@, Koichi Murase, 2023/02/21
- Re: Use of $@, Christof Warlich, 2023/02/21
- Re: Use of $@, Greg Wooledge, 2023/02/21
- Re: Use of $@,
Kerin Millar <=
- Re: Use of $@, alex xmb ratchev, 2023/02/21
- Re: Use of $@, alex xmb ratchev, 2023/02/21
- Re: Use of $@, Chris F.A. Johnson, 2023/02/21
- Re: Use of $@, alex xmb ratchev, 2023/02/21
- Re: Use of $@, Greg Wooledge, 2023/02/21
- Re: Use of $@, Greg Wooledge, 2023/02/21
- Re: Use of $@, alex xmb ratchev, 2023/02/21
- Re: Use of $@, Kerin Millar, 2023/02/21
- Re: Use of $@, Greg Wooledge, 2023/02/21
- Re: Use of $@, Chet Ramey, 2023/02/21