[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Question on $@ vs $@$@
From: |
Steffen Nurpmeso |
Subject: |
Re: Question on $@ vs $@$@ |
Date: |
Thu, 15 Aug 2024 20:48:58 +0200 |
User-agent: |
s-nail v14.9.25-599-g5c75a327b2 |
Hello.
Unfortunately i have to add one thing to this thread..
Steffen Nurpmeso wrote in
<20240814200534.Vh3Eu_Md@steffen%sdaoden.eu>:
|Chet Ramey wrote in
| <1bba673e-5ab9-4263-9d88-124854793b4b@case.edu>:
||On 8/13/24 8:45 PM, Steffen Nurpmeso wrote:
||> I include bug-bash even though i think bash is correct, but there
||> lots of people of expertise are listening, so, thus.
||> Sorry for cross-posting, nonetheless.
||> Given this snippet (twox() without argument it is)
||>
||> one() { echo "$# 1<$1>"; }
||> two() { one "$@"; }
||> twox() { one "$@$@"; }
||> two
||> two x
||> twox
||> twox x
| ...
||When, as in this case, the result would be split if the double quotes
||weren't there, $@ within double quotes expands to nothing if there are
||no positional parameters, no matter how many times it appears.
|
|As was shown there is standard wording which makes this case
|explicitly unspecified. Thanks for pointing this out. I should
|have reread the standard first (that particular wording is hard to
|grasp for me).
...
In fact Geoff Clare (who we all deserve thanks, together with Don
Cragun, for continued ISO C compiler support for the BSD socket
interface we all use in at least POSIX environments, it is
undefined anywhere else!, and more) sees this differently:
The standard clearly requires "$@$@" to generate zero fields if
there are no positional parameters. The quoted text "if the
expansion is embedded within a word which contains one or more
other parts that expand to a quoted null string, ..." does not
apply because there are no other parts that expand to a quoted
null string. (The second $@ is not a candidate for being such
a part because "the expansion of '@' shall generate zero
fields".)
If this does not match existing behaviour in some shells, we
could consider making it unspecified, but the first step should
be to alert the maintainers of those shells to the issue and
find out whether they are willing to change their shell to
comply with the standard.
So please any shell maintainer listening here, please feel
alerted.
(P.S.: regarding
> I'd still love to know what the script's intent is.
It will be a test. My MUA does not yet apply word splitting for
unquoted variable expansions, and while going that road, there was
a pitfall.)
--steffen
|
|Der Kragenbaer, The moon bear,
|der holt sich munter he cheerfully and one by one
|einen nach dem anderen runter wa.ks himself off
|(By Robert Gernhardt)
Re: Question on $@ vs $@$@, Robert Elz, 2024/08/14
Re: Question on $@ vs $@$@, Oğuz, 2024/08/14
Re: Question on $@ vs $@$@, Robert Elz, 2024/08/14
Re: Question on $@ vs $@$@, Chet Ramey, 2024/08/14
- Re: Question on $@ vs $@$@, Steffen Nurpmeso, 2024/08/14
- Re: Question on $@ vs $@$@,
Steffen Nurpmeso <=
- Re: Question on $@ vs $@$@, Steffen Nurpmeso, 2024/08/15
- Re: Question on $@ vs $@$@, Robert Elz, 2024/08/16
- Re: Question on $@ vs $@$@, Steffen Nurpmeso, 2024/08/16
- Re: Question on $@ vs $@$@, Steffen Nurpmeso, 2024/08/16
- Re: Question on $@ vs $@$@, Steffen Nurpmeso, 2024/08/22
- Re: Question on $@ vs $@$@, Steffen Nurpmeso, 2024/08/22
- Re: Question on $@ vs $@$@, Greg Wooledge, 2024/08/22
- Re: Question on $@ vs $@$@, Steffen Nurpmeso, 2024/08/23
- Re: Question on $@ vs $@$@, Chet Ramey, 2024/08/26
- Re: Question on $@ vs $@$@, Steffen Nurpmeso, 2024/08/26