L A Walsh <[email protected]> writes:
> It would be nice to have a expansion that preserves arg boundaries
> but that expands to nothing when there are 0 parameters
> (because whatever gets called still sees "" as a parameter)
Fiddling a bit, I found this is a nice way to show how "$@" (or any
other construction) affects the parameters given a to command.
$ function show { ( set -x ; echo "$@" >/dev/null ) }
$ show a
+ echo a
$ show a b
+ echo a b
$ show ''
+ echo ''
$ show a ''
+ echo a ''
$ show
+ echo
$
What makes it particularly effective is that "set -x" shows the sequence
of arguments unambiguously. (Hmmm, I could have used ":" instead of
"echo".)
And the manual page does make this clear if you read the entire
description:
When there are no positional parameters, "$@" and $@ expand to
nothing (i.e., they are removed).
Dale