On 2/28/11 6:45 AM, Andres Perera wrote:
> for i in bash mksh; do
> echo $i:
> $i <<'!'
> set 'a b' 'c d'
> quoted="$@"
> unquoted=$@
> echo "$quoted"
> echo "$unquoted"
> !
> done
>
> here bash treats unquoted $@ on rhs differently, expanding it like $*:
>
> bash:
> a b c d
> a b c d
> mksh:
> a b c d
> a b c d
>
> persists after turning on posix-compat mode:
>
> bash -o posix -c 'set "a b" "c d"; unquoted=$@; echo "$unquoted"'
> a b c d
>
>
> the shell is treating $@ and "$@" like special tokens in assignments,
> which is wrong
Thanks for the report. The shell is inappropriately splitting the
unquoted $@ when it appeared on the rhs of an assignment statement. This
will certainly be fixed for the next version, and may appear as a
patch to bash-4.2.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU [email protected] http://cnswww.cns.cwru.edu/~chet/