#!/usr/bin/env mksh ascript=' function expansion { # purpose: compare handling of field splitting/expansion of $* and # $@ in different contexts and in different shells. set a b typeset x typeset IFS=, ################################################# # $* and $@ as command argument echo $* echo "$*" echo $@ echo "$@" ################################################# # in variable assignment plus printing (quoted) x=$*; echo "$x" x="$*"; echo "$x" x=$@; echo "$x" x="$@"; echo "$x" ################################################# # in variable assignment plus printing (unquoted) x=$*; echo $x x="$*"; echo $x x=$@; echo $x x="$@"; echo $x ################################################# # in a here string cat <<< $* cat <<< "$*" cat <<< $@ cat <<< "$@" } expansion ' glue='command echo $* echo "$*" echo $@ echo "$@" x=$*; echo "$x" x="$*"; echo "$x" x=$@; echo "$x" x="$@"; echo "$x" x=$*; echo $x x="$*"; echo $x x=$@; echo $x x="$@"; echo $x cat <<< $* cat <<< "$*" cat <<< $@ cat <<< "$@"' cnt=0 for i in ksh mksh bash zsh; do glue+=$'\n'$i$'\n'$($i <<< "$ascript") ((++cnt)) done print "+++++++++++++++++" print '$1=a, $2=b, IFS=,' print "+++++++++++++++++" print "$glue" | rs -t -e -g3 -z 0 $((1 + cnt))