Re: Question on $@ vs $@$@

Robert Elz <[email protected]>
Newsgroups org.kernel.vger.dash
Message-ID <[email protected]>
    Date:        Wed, 14 Aug 2024 11:04:08 +0200
    From:        Marc Chantreux <[email protected]>
    Message-ID:  <ZrxzCOnZv-HffFuB@prometheus>

  | I'm really currious: do you see another one ?

The case he was asking about is when $# is 0 (no positional params set)
and whether "$@$@" should result in "" (1 arg) or nothing (0 args).

Upon rereading POSIX, while I am sure that the intent would be to
make that unspecified, just as "$@$X" is, when X is unset or null,
but I'm not convinced that the wording actually does.

As was quoted from POSIX (this time from the new standard, though I
believe this is unchanged, it remains XCU 2.5.2 (the '@' expansion descr)):

    however, if the expansion is embedded within a word which contains one
    or more other parts that expand to a quoted null string, these null
    string(s) shall still produce an empty field,

which I am not sure actually applies in the relevant case, as neither $@
expansion produced a quoted null string, they both produce nothing (when
there are no parameters, which is the only time this is relevant).

So, I am not sure that this exception is relevant, and if it isn't, then
the exception to the exception

    except that if the other parts are all within the same double-quotes
    as the '@', it is unspecified whether the result is zero fields
    or one empty field.

cannot apply either.   That would mean that perhaps "$@$@" might be
specified to produce nothing.   However, as ksh93 makes "" from this
expansion, and so probably ksh88 might have done as well (I don't have
a ksh88 to test it) and as the standard was originally based upon ksh88
if a clarification were added, it would probably be to change the
wording (somehow) so the "$@$@" case is also explicitly unspecified.

kre
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.