This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: gcc question


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]