[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[BUG] With null IFS, ${1+$*}, ${var-$*}, etc. don't generate fields
From: |
Martijn Dekker |
Subject: |
[BUG] With null IFS, ${1+$*}, ${var-$*}, etc. don't generate fields |
Date: |
Sun, 19 Feb 2017 02:35:41 +0100 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 |
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.
Unquoted $* outside of a substitution does this correctly; the bug only
occurs within one.
Test:
bash -c 'IFS=; set "abc" "def ghi" "jkl";
set ${1+$*}; printf "[%s]\\n" "$#" "$@"'
Actual output:
[1]
[abcdef ghijkl]
Expected output (as produced by every other shell):
[3]
[abc]
[def ghi]
[jkl]
Bug confirmed on bash 3.2.57, 4.3.30, 4.4.12.
Bug confirmed *not* present on bash 2.05b.
Thanks,
- M.
- [BUG] With null IFS, ${1+$*}, ${var-$*}, etc. don't generate fields,
Martijn Dekker <=
- Re: [BUG] With null IFS, ${1+$*}, ${var-$*}, etc. don't generate fields, Chet Ramey, 2017/02/19
- Re: [BUG] With null IFS, ${1+$*}, ${var-$*}, etc. don't generate fields, Grisha Levit, 2017/02/24
- Re: [BUG] With null IFS, ${1+$*}, ${var-$*}, etc. don't generate fields, Chet Ramey, 2017/02/24
- Re: [BUG] With null IFS, ${1+$*}, ${var-$*}, etc. don't generate fields, Martijn Dekker, 2017/02/27