[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bash variable escaping



On Tue, Sep 10, 2013 at 05:13:01PM +0200, Denis Witt wrote:

||  I've a problem with a script. It's a wrapper for a program which uses
||  for example '*' as a parameter. It could also be 'foobar*' and I want
||  the script user to type in the desired parameter via "dialog
||  --inputbox".
||  
||  The parameter is set correctly: "echo ${parameter}" gave me exactly what
||  I expect to see ('*'). Unfortunately when the parameter is passed to the
||  program it looks like this (according to "set +x"): 
||  
||  /usr/bin/salt ''\''*'\''' state.highstate -v test=True -b 10

set -x quotes the parameters that it prints, so what gets passed to your
program is actually

    /usr/bin/salt '*' state.highstate -v test=True -b 10

/usr/bin/salt will be seeing '*' (with those quotes) but not the extra
quotes and backslashes set -x prints for you.

||  How can I avoid that?

Depends on how you did it now, of course. Is dialog quoting the entered
value? If so, look there.

Vincent.
-- 
Vincent Zweije <vincent@zweije.nl>   | "If you're flamed in a group you
<http://www.xs4all.nl/~zweije/>      | don't read, does anybody get burnt?"
[Xhost should be taken out and shot] |            -- Paul Tomblin on a.s.r.

Attachment: signature.asc
Description: Digital signature


Reply to: