OK, here is the whole snippet and what it appears to be doing. I still
don't know how:
quoted_args () {
for arg in "$@"; do
esc=`echo "$arg" | sed "s/'/'\\\\\\\\''/g"`
printf " '%s'" "$esc"
done
printf ' ;\n'
}
cmd () {
quoted_args "$@"
}
Then you can something like this:
cmd echo this is crazy
and it outputs this:
'echo' 'this' 'is' 'crazy' ;
Another script takes this output and then does the actual echo (or
whatever command it is you use). Useful for what we are doing, but I'm
still baffled by the sed command. Can anyone explain further?
Thanks,
Bryan
On Tue, 2003-06-17 at 14:43, Bryan Murdock wrote:
> I'm looking at some shell scripts a co-worker wrote and there is a line
> that looks like this:
>
> esc=`echo "$arg" | sed "s/'/'\\\\\\\\''/g"`
>
> I can't figure out why any regular expression would need that many
> backslashes. Can any of you?
>
> Thanks,
>
> Bryan
>
>
> ____________________
> BYU Unix Users Group
> http://uug.byu.edu/
> ___________________________________________________________________
> List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list
____________________
BYU Unix Users Group
http://uug.byu.edu/
___________________________________________________________________
List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list