bug-bash
[Top][All Lists]
Advanced

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

Re: [BUG] With null IFS, ${1+$*}, ${var-$*}, etc. don't generate fields


From: Chet Ramey
Subject: Re: [BUG] With null IFS, ${1+$*}, ${var-$*}, etc. don't generate fields
Date: Sun, 19 Feb 2017 00:01:01 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.7.1

On 2/18/17 8:35 PM, Martijn Dekker wrote:
> When IFS is null, unquoted $* within an unquoted substitution (e.g.
> ${1+$*} or ${unset_var-$*}) joins the PPs together into one field, as if
> either "$*" or the whole substitution were quoted.
> 
> POSIX says the unquoted substitution is supposed to generate one field
> for each positional parameter, with further field splitting inactive due
> to empty IFS.

It's an interesting question.  I'm ok with looking at the context of the
surrounding brace expansion, though field splitting isn't one of the
expansions Posix lists for the `word'.  The question is how other shells
rationalize differing behavior for differing parameter expansions.  For
instance, ${a#$*} expands $* as if it were not going to undergo field
splitting:

set -- a b
IFS=
x=abc
printf "<%s>\n" ${x#$*}

where, as you note, other expansions such as ${parameter+word} and
${parameter-word} do not.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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