[ale] $* equivalent with quotes.
Danny Cox
danscox at mindspring.com
Mon May 7 20:13:33 EDT 2007
On Sun, 2007-05-06 at 15:03 -0400, Geoffrey wrote:
> David Corbin wrote:
> > Is there bash equivalent to $*, but where each argument is quoted (I think I
> > need single quotes, but having an option would be nice). It seems like it's
> > really necessary to right complex/robust shell scripts without a lot of
> > repetition.
>
> I recall that $@ will list the args, but I don't recall the differences
> between that and $*.
You almost always want $@, at least in my experience. But you also
need to quote it, like this:
for FILE in "$@"
do
foo "$FILE"
done
That will iterate across each file name even if it contains spaces. The
"$*" version will split "words" at the spaces, and that's almost
certainly NOT what you want.
HTH!
--
kernel, n.: A part of an operating system that preserves the
medieval traditions of sorcery and black art.
Danny
More information about the Ale
mailing list