Re: Quoting Problems for Shell Script

From: Michael Tosch (eedmit_at_NO.eed.SPAM.ericsson.PLS.se)
Date: 01/21/05


Date: Fri, 21 Jan 2005 19:07:25 +0100

Tony George wrote:
> Hi,
>
> I'm having some problems figuring out quoting for a Bourne shell script on
> Solaris 8. It's a pretty basic script and I'm probably missing something
> obvious:
>
> ---
> #!/bin/sh
>
> cmd="make $@"
>
> $cmd
> ---
>
> I want to pass the script the following options: testscript
> "DEBUGFLAGS=-DTEST1 -DTEST2"
>
> It has problems with the second parameter (i.e. -DTEST2). The whole
> DEBUGFLAGS parameter is not getting sucked in whole. If I just put the make
> command straight in the script instead of calling it from a variable,
> everything is fine. However, I would like to have the actual command in the
> variable so that I can use it in other parts of the script (e.g. logging
> info, etc...).
>
> Here are the options I've already tried with no success:
>
> testscript \"DEBUGFLAGS=-DTEST1 -DTEST2\"
>
> testscript DEBUGFLAGS=\"-DTEST1 -DTEST2\"
> testscript \'DEBUGFLAGS=-DTEST1 -DTEST2\'
>
> Any help would be greatly appreciated! My apologies if this has already
> been answered recently (I couldn't find it in the FAQ).
>
> TG
>
>

You are the 3rd now with the same solution, see previous postings:

cmd='make "$@"'
eval "$cmd"

But why not simply

cmd='make'
$cmd "$@"

-- 
Michael Tosch @ hp : com