Duncan Murdoch wrote:
> Vadim Organovich wrote:
>> It is precizely a shell command that I am trying to generate. To be
>> specific let's try to have R 'output' the following shell command:
>> 'echo "\"a\""'. This is is a valid command, at least in bash:
>> bash-3.2$ echo "\"a\""
>> "a"
>>
>> Now in R:
>>  
>>> x <- 'echo "\"a\""'
>>> cat(x, '\n')
>>>     
>> echo ""a""
>>  
>>> cat(shQuote(x), '\n')
>>>     
>> "echo \"\"a\"\""
>>
>> Whichever way you do it it is not right. Again I think cat('echo
>> "\"a\""') should be printing *echo "\"a\""* (asterics are not a part
>> of the output)
>>   
try this:

(x = 'echo "\\"a\\""') # or x = 'echo \"\\\"a\\\"\"')
[1] "echo \"\\\"a\\\"\""

cat(x, "\n")
# echo "\"a\""

as desired.  you need to backslash the backslash.

vQ

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to