[R-SIG-Mac] Shell used within system()

Marc Girondot marc_grt at yahoo.fr
Sun Jul 6 08:02:38 CEST 2014


Hi,

I try to automatize some commands normally used in terminal that I would 
like to run in R.

However, the same command xxx in terminal and in system("xxx") does not 
produce the same result.

It seems related to the shell used and the variables of the shell.

For example, in terminal:
Marc-Girondot-MBA:Chlorophyle marc$ echo $PATH
/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/usr/local/ncl-6.2.0/bin:/opt/local/bin:/opt/local/sbin:/Library/Frameworks/GDAL.framework/Programs:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/texbin

whereas in R:
 > system("echo $PATH")
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/texbin:/opt/local/bin

The shell used in terminal is
Marc-Girondot-MBA:Chlorophyle marc$ echo $SHELL
/bin/bash
Marc-Girondot-MBA:Chlorophyle marc$ echo $0
-bash

whereas in R, it is sh:
 > system("echo $0")
sh

And this sh does not read my configuration files. I have tried to 
modifiy the ~/.profile or ~/.login but system("echo $PATH") does not change.

My question is then:
is it possible to change the default shell used by system ? I have tried:
system("/bin/bash\necho $0\necho $PATH")

but R becomes unresponsive...

or where is the configuration file for sh run by R ?

Thanks a lot

Marc



More information about the R-SIG-Mac mailing list