bug-bash
[Top][All Lists]
Advanced

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

Re: Question on $@ vs $@$@


From: Robert Elz
Subject: Re: Question on $@ vs $@$@
Date: Wed, 14 Aug 2024 18:23:09 +0700

    Date:        Wed, 14 Aug 2024 11:22:09 +0300
    From:        =?UTF-8?B?T8SfdXo=?= <oguzismailuysal@gmail.com>
    Message-ID:  
<CAH7i3LpeTC4x14wYdEQGhGPFrU2oZsBP1BN=Gdr_dCvNd-oUvg@mail.gmail.com>


  | FWIW, POSIX doesn't pick sides on this; XCU 2.5.2 <

Because different shells have always done different things.
There's nothing special about it being "$@$@" for this,

        X=
        set --

        And then expanding "$X$@" or "$@$X" has the same results
        (or should have) whether that is nothing or "" the shell should
        be consistent at least.

FWIW:

zsh:
0 1<>
1 1<x>
0 1<>
1 1<xx>

bosh:
0 1<>
1 1<x>
0 1<>
1 1<xx>

yash:
0 1<>
1 1<x>
0 1<>
1 1<xx>

mksh:
0 1<>
1 1<x>
0 1<>
1 1<xx>

NetBSD sh
0 1<>
1 1<x>
0 1<>
1 1<xx>

FreeBSD sh:
0 1<>
1 1<x>
0 1<>
1 1<xx>

(and bash as seen earlier).

ksh93:
0 1<>
1 1<x>
1 1<>
1 1<xx>

(and dash as earlier).

If you're ever in a situation where this matters, just write it
as "$@""$@" - when it is like that, everything does it the bash
(et-al) way, which I believe is also what POSIX requires (but
this one is different from the "$X""$@" which must produce ""
as that's what's required of "$X".

kre

ps: set -- a b; echo "$@$@" is also fun, and also correct in all
shells I have to test (3 args produced).





reply via email to

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