Actually, what you posted has two single quotes, so gets 'unexpected EOF' for me, but
Code:
test=`echo $option | sed 's/\\/\\\\/'`
does get 'unterminated'.
The original 'backticks' method is treated differently and the newer way works:
Code:
test=$(echo $option | sed 's/\\/\\\\/')
Near as I can figure, the backtick method is resulting in the backslashes getting 'swallowed', and maybe the slashes being treated by sed as literal - so it's still waiting on a 'special' slash to terminate the substitution.
Code:
~
990>> echo `echo /\\/\\\\/`
//\/
~
991>> echo $(echo /\\/\\\\/)
/\/\\/
In the first, bash is passing to sed what looks like 'substitute nothing with a literal slash and...' whereas the second is 'replace a slash with two'. Now, what bash is passing to sed and what echo is outputting in 990/991 are two different things but I still think that's basically what's going on. Could well be wrong, though. It's not that I'm not willing to help, but I just don't really know.
Just out of curiosity, what was the way around? (If you don't want to say, that's okay. I, too, know the shame of ugly workarounds.
)