[ale] Partial interpretation in a bash script
Geoffrey
esoteric at 3times25.net
Mon Oct 27 06:07:35 EST 2003
Bjorn Dittmer-Roche wrote:
> $ script \\\\
>
> will put \\ into the variable $@ (or $*, which I think is the same
> thing).
I seem to remember there was a difference in $@ and $* from my early
shell days, but couldn't put my finger on it. I couldn't find a
reference to it. I dug up my old ksh book and did in fact find that
there is a difference, although that difference is not emulated in pdksh.
Here's what I've found to be true for pdksh and bash, by way of an example:
script:
for i in "$*"; do
echo $i
done
echo
for i in "$@"; do
echo $i
done
execute: foo "one two" three
output:
one two three
one two
three
Note, the double quotes around 'one two' cause them to be interpreted by
the script as a single argument when '$*' is used.
This, by the way is not what the real korn ksh does. One of the few
things I've found where pdksh does not mimic the original.
--
Until later, Geoffrey esoteric at 3times25.net
Building secure systems inspite of Microsoft
More information about the Ale
mailing list