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

Reply via email to