[Rd] Suggested modification to shell command

ripley@stats.ox.ac.uk ripley@stats.ox.ac.uk
Fri Jan 10 09:21:02 2003

Why not set R_SHELL to "bash" as in

export R_SHELL=bash

?  That's the intention, and should work (it does for me), whereas your
suggestion does not work here.  I think a variable (COMSPEC) has been set
anyway, so setting this in e.g. .bashrc should be no hardship.

Despite my inability to verify this, I'll make the change in R-devel as at
least the basename() part may come in handy.

On Thu, 9 Jan 2003, Wright, Kevin wrote:

> I'm using R 1.6.1 on Windows 95 with cygwin bash as my shell.
> The 'shell' command tries to determine which shell the user prefers via the
> following steps:
>       shell <- Sys.getenv("R_SHELL")
>       if (!nchar(shell))
>           shell <- Sys.getenv("SHELL")
>       if (!nchar(shell))
>           shell <- Sys.getenv("COMSPEC")
> For me, shell evaluates to "c:/cygwin/bin/bash.exe" .

Not for me, though (under XP).  I think something is strange if under
cygwin you are getting a Windows path with forward slashes.  The current
cygwin bash (for me) sets SHELL to /bin/sh but does not export it, so
COMSPEC is used (and that is not what you want).

> The 'shell' command then tries to determine the proper flag to use:
> if (missing(flag) && any(!is.na(match(c("bash", "tcsh"),
>     shell))))
>     flag <- "-c"
> For anyone who is using MS Windows (with .exe file extensions) or has the
> path name in the SHELL environment variable (as appears to be the cygwin
> default),

I am sure it is not what cygwin does by default, as it does not understand
drives specifed by c:/.

> the following modification to the matching may be more general in
> determining the proper flag to use:
> is.na(pmatch(c("bash","tcsh"),basename(shell)))
> Thank you for considering this suggestion.

Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595