R_Interactive {was '[Rd] stdout == 'Terminal' or 'File'}

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed May 12 12:16:32 CEST 2004

On Wed, 12 May 2004, Simon Urbanek wrote:

> while the topic is on, something remotely related although the same:
> On May 12, 2004, at 10:04 AM, Prof Brian Ripley wrote:
> > interactive() is as good a test as we have, and I think if a better 
> > test
> > is required in the interactive case, the user should be asked.
> There may be a little problem in the current sources (talking unix for 
> now) - R sets the interactive flag like this:
> system.c at 248:    R_Interactive = isatty(0);
> Unfortunately right after this there comes:
> if (!R_Interactive && SaveAction != SA_SAVE && SaveAction != SA_NOSAVE)
>     R_Suicide("you must specify `--save', `--no-save' or `--vanilla'");
> Now speaking of embedded R - the above leaves (afaik) no way of telling 
> R to use interactive mode before this suicide attempt if stdout is no 
> tty (it doesn't have to if the embedding app provides its own 
> Read/WriteConsole etc.). Any thoughts on this? (btw: aqua uses a hack 
> to circumvent this... whenever aqua needs a hack it may be worth 
> thinking about something more general ;))

Not R per se, but the Unix front-end in Rf_initialize_R, which is a hack
from the terminal-like Unix front-end. As in the comment

    /* On Unix the console is a file; we just use stdio to write on it */

An embedding application can (and probably should) set argv when it calls
Rf_initEmbeddedR, or it can call its own version of Rf_initialize_R (which
is what happens under Windows).

BTW, this is in the process of being broken up (and aqua and gnome 
support moved to Rmain.c) so it is a good time for a better solution.
OTOH, it is not particularly good to break the API of which 
Rf_initialize_R is probably considered part.

I agree with your comment about aqua, but then those of us not using Raqua 
are often unaware of the hacks which have been used.


Brian D. Ripley,                  ripley at 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

More information about the R-devel mailing list