scripting problem

Eric "Shubes" plug at shubes.net
Fri Feb 16 14:59:15 MST 2007


Darrin Chandler wrote:
> On Fri, Feb 16, 2007 at 02:41:38PM -0700, Eric Shubes wrote:
>> I wasn't quite clear enough I guess. Since I'm building a variable number of
>> parameters, I can't specify each one separately, and thus cannot use quotes
>> when invoking the command.
>>
>> Using your example, I need to do:
>> argument="this is"
>> scriptname.sh $argument a parm
>> and have it come out the same as your example. I can't put the whole thing
>> in quotes because I have a list of arguments, some containing spaces and
>> some not.
> 
> This can get a little tricky because interpretation can (and does)
> happen at any of several levels. Then, there are different methods of
> quoting.
> 
> echo "foo bar"
> echo 'foo bar'
> echo foo\ bar
> 
> Many times the "\ " quoting is easiest to propagate down levels. So that
> when you really want "foo\ bar" you end up using "foo\\ bar" because the
> first interpretation evals and removes the escape you end up with a bare
> space, which the next evaluation uses to separate args. With the double
> backslash the first eval turns it into a single "\" and the second eval
> will correctly see the escaped space "\ " and pass that through. Am I
> making sense?
> 

That makes sense all right. My problem with this is that I'm not putting in
the spaces myself, they're coming from an external source. I suppose I could
use sed to escape the spaces, but that doesn't feel like the right thing to do.

Thanks, Darrin. I figured you'd like this one!

-- 
-Eric 'shubes'


More information about the PLUG-discuss mailing list