[R] PHP escapeshellcmd() equivalent

Yihui Xie xie at yihui.name
Wed Aug 29 18:48:23 CEST 2012


Well, then I guess there is no such function in base R, but it should
be something like escapeshellcmd = function(x)
gsub('[metacharacters]', '\\\\\\1', x)

Regards,
Yihui
--
Yihui Xie <xieyihui at gmail.com>
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA


On Wed, Aug 29, 2012 at 11:04 AM, Roebuck,Paul L
<proebuck at mdanderson.org> wrote:
> On 8/24/12 9:59 PM, "Yihui Xie" <xie at yihui.name> wrote:
>
>> On Fri, Aug 24, 2012 at 3:17 PM, Roebuck,Paul L <proebuck at mdanderson.org>
>> wrote:
>>> On 8/24/12 2:59 PM, "R. Michael Weylandt" <michael.weylandt at gmail.com>
>>> wrote:
>>>
>>>> On Fri, Aug 24, 2012 at 2:48 PM, Roebuck,Paul <proebuck at mdanderson.org>
>>>> wrote:
>>>>> [Redirected from R-Devel...]
>>>>>
>>>>> Not that I recall running across such, but does R (or CRAN package)
>>>>> provide something equivalent to PHP's escapeshellcmd() function
>>>>> to escape shell job control, wildcards, etc?
>>>>
>>>> I don't know PHP, but what does escapeshellcmd() provide over and
>>>> above what system() / system2() do?
>>>>
>>>
>>> As before, it escapes job control, etc from the command string.
>>> Assuming such existed in R, it would be used something like this:
>>>
>>> R> system(escapeshellcmd(sprintf("somecmd %s", untrustedInput1)))
>>
>> You probably mean shQuote().
>>
>
> No, as that ONLY handles double/single quote agreement
> (equivalent to PHP's escapeshellarg() function).
>




More information about the R-help mailing list