gcc question

Joe Buck jbuck@synopsys.COM
Thu Feb 3 16:13:00 GMT 2000


At the risk of drifting offtopic, I should correct something I previously
wrote.

> > #! /bin/sh
> > echo $* >/tmp/prog.cmdline
> 
I wrote:
> This is a common shell programming mistake.
> Use of $* breaks if there is a quoted argument that has special characters
> or whitespace.  Use "$@" rather than $*.  Otherwise there's fun with
> things like
> 
> prog '`rm -rf /`'

While my advice to use "$@" rather than $* is correct, command
substitution happens before variable substitution, so /bin/rm wouldn't
be executed by the above command.  The more common problem with use of
$* is when an argument must be passed that contains spaces.


More information about the Gcc mailing list