User enters string: "string
echo $@ | sed '/\"/\\"/g'
At runtime, this becomes:
echo "string | sed '/\"/\\"/g'
The shell now waits since there is no closing quote on the echo. I'm
stumped. Am I on the wrong track, or is this just not possible?
I assume your sed should have an "s" at the front and you don't need to
quote the " so the result would be:
echo $@ | sed 's/"/\\"/g'
I assume your user is calling the script as:
whatever "string
and that's what's hanging. If so, there's nothing you can do about that
within your script since the script won't even be invoked until the user
provides the terminating ". Try it with some non-existent script name
and you'll see what I mean. If the user wants to pass in a ", they'll
need to escape it, e.g.:
whatever \"string
and in that case your script will work.
Ed.