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 21:20:39 +0700

    Date:        Wed, 14 Aug 2024 11:04:08 +0200
    From:        Marc Chantreux <mc@unistra.fr>
    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




reply via email to

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