On 5/17/05, Shachar Shemesh <[EMAIL PROTECTED]> wrote: > Hi all, > > I have a bourne shell script that defines a function "dosomething". > Dosomething receives a string, and passes is along to a subshell for > processing (currently by doing sh -c "$cmdline"). > > The problem is that when I do: > dosomething "a\\b" > $cmdline gets: > a\b > (which is ok) > > but the subshell gets: > ab > Which is not. Is there a builtin shell function that quotes special > characters for passing through a context that does dereferencing?
I'm not aware of a Bourne shell function to do this. I also don't see a Bash function to do this (are you prepared to depend on bash-ism?) A simple perl-style solution would be to just quote it yourself through sed, something like: quotedcmdline=`echo $cmdline | sed -e "s:[\$\"\\\']:\\\\&:g"` > > thanks, > Shachar Cheers, --Amos ================================================================To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]