This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: gcc question
- To: jbuck at synopsys dot com (Joe Buck)
- Subject: Re: gcc question
- From: Joe Buck <jbuck at synopsys dot COM>
- Date: Thu, 3 Feb 2000 16:11:02 -0800 (PST)
- Cc: martin at loewis dot home dot cs dot tu-berlin dot de (Martin v. Loewis), oliva at lsd dot ic dot unicamp dot br, sklee at synopsys dot com, gcc at gcc dot gnu dot org
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.