Skip to content
Prev 29497 / 63424 Next

shQuote and cat

On Jul 23, 2008, at 4:46 PM, Vadim Organovich wrote:

            
Well, you input is not right ('\"' is parsed in R into '"') - you have  
to escape the backslash that you want to keep and all is well:

 > x <- 'echo "\\"a\\""'
 > cat(x, '\n')
echo "\"a\""
 > cat(shQuote(x), '\n')
'echo "\"a\""'
 > system(paste("sh -c",shQuote(x,type="sh")))
"a"

Cheers,
Simon