[Rd] --interactive and -f/-e

Mick Jordan mick.jordan at oracle.com
Wed Apr 29 03:11:54 CEST 2015


I was surprised by this:

R --interactive -e 'interactive()'

bash-3.2$ R -q -e 'interactive()' --interactive
 > interactive()
[1] FALSE
 >

as the command options document says that --interactive should force 
interactive=TRUE:

" When *R* is run in a terminal (via |Rterm.exe| on Windows), it assumes 
that it is interactive if ‘stdin’ is connected to a (pseudo-)terminal 
and not if ‘stdin’ is redirected to a file or pipe. Command-line options 
--interactive (Unix) and --ess (Windows, |Rterm.exe|) override the 
default assumption"

But the code in system.c does this:

R_Interactive = R_Interactive && (force_interactive || isatty(0));

R_Interactive is set to FALSE in the -e/-f processing, and 
force_interactive is set to TRUE in the --interactive processing, so 
there is no way that it can ever override -e/-f. It seems that 
--interactive can only have an effect for something like a pipe. Is this 
actually the expected behavior?

Mick Jordan




	[[alternative HTML version deleted]]



More information about the R-devel mailing list