Op 20-06-17 om 02:13 schreef Kevin Brodsky:
> When IFS is unset, unquoted $* undergoes word splitting as if IFS=' ',
> and not the expected IFS=$' \t\n'.
Possibly related are the following two issues:
1. When IFS is unset, assignments of unquoted ${var-$*}, ${var+$*}, etc.
to a variable removes leading and trailing spaces from $* (but not tabs
or newlines). (Modernish ID: BUG_PP_03B)
This issue exists on bash 4.3, 4.4 and current git.
Test script:
set " abc " " def ghi " "jkl "
unset -v IFS var
var=${var-$*}/${var-$*}
printf '[%s]\n' "$var"
Actual output:
[abc def ghi jkl/abc def ghi jkl]
Expected output:
[ abc def ghi jkl / abc def ghi jkl ]
2. When IFS is unset, conditional assignments of unquoted $* to a
variable within a parameter substitution, e.g. ${var=$*} or ${var:=$*},
removes leading and trailing spaces (but not tabs or newlines).
(Modernish ID: BUG_PP_04A)
This issue exists on all bash versions from current git down to at least
2.05b.
set " abc " " def ghi " "jkl "
unset -v IFS var
: ${var:=$*/$*/${var-$*}}
printf '[%s]\n' "$var"
Actual output:
[abc def ghi jkl / abc def ghi jkl /abc def ghi jkl]
Expected output:
[ abc def ghi jkl / abc def ghi jkl / abc def ghi jkl ]
Thanks,
- Martijn