[Rd] Possibly broken system2 env-option

Gábor Csárdi c@@rd|@g@bor @end|ng |rom gm@||@com
Tue Mar 19 11:09:50 CET 2019


On Tue, Mar 19, 2019 at 9:59 AM peter dalgaard <pdalgd using gmail.com> wrote:
[...]
> What you need is something like (NB: single quotes!)
> > system2("sh", env = c("VAR='Hello World'"), args = c("-c 'echo $VAR'"))
> Hello World

Just out of curiosity, do you think it is possible to make this
portable, assuming sh is available? On Windows it gives

> system2("sh", env = c("VAR='Hello World'"), args = c("-c 'echo $VAR'"))
/rtools34/bin/sh: VAR=Hello World: No such file or directory
Warning message:
running command '"sh" VAR='Hello World' -c 'echo $VAR'' had status 127

G.



More information about the R-devel mailing list