bug-bash
[Top][All Lists]
Advanced

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

Re: Unexpected word splitting on $* when IFS is unset


From: Greg Wooledge
Subject: Re: Unexpected word splitting on $* when IFS is unset
Date: Thu, 22 Jun 2017 07:51:12 -0400
User-agent: Mutt/1.4.2.3i

On Wed, Jun 21, 2017 at 10:30:22PM -0400, Chet Ramey wrote:
> However, not all shells were consistent in their interpretation of the
> Posix rules. For instance, dash, which bills itself as being completely
> Posix conformant, produces 1 for that case (and expands to "ab").  The
> Bourne shell (SVR4.2 version) produces 1 as well, but expands it
> differently ("a b"). Debian's posh produces the same results as the Bourne
> shell. And so on.

Oh, wow.  I didn't realize it was quite this bad.

$ dash
$ set -- a b
$ IFS=
$ args $*
1 args: <ab>
$ args $@
1 args: <ab>
$ args "$*"
1 args: <ab>
$ args "$@"
2 args: <a> <b>

$ ksh
$ set -- a b
$ IFS=
$ args $*
2 args: <a> <b>
$ args $@
2 args: <a> <b>
$ args "$*"
1 args: <ab>
$ args "$@"
2 args: <a> <b>

OK, going forward, I am officially considering any use of unquoted $*
or $@ in a script to be a BUG, an invocation of undefined behavior,
not acceptable, no excuses.



reply via email to

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