When running R in 'batch mode', the interactive
flag is set to false, which prevents any sort of user prompts that would interrupt the process in the context of an embedded/batch setting. See:
R -e 'interactive()'
Some holds when using Rscript
. The flag can also manually be set by using the interactivity package. To test, we can try:
R -e 'install.packages("anything")
Assuming no CRAN mirror has been set yet, install.packages
will not show some interactive mirror picker, but instead throw an error and exit.
However, I noticed that the help
or ?
command will still work. For example, the command below will show the help browser, and it does not continue until I press q.
R -e 'help(lm); 1+2'
However, when sending the output to a file, it does not show the interactive prompt and just dumps the complete help document in the output:
R -e 'help(lm); 1+2' > output.txt
I'm a bit confused now about what is really going on when using help
. Why do you get the interactive help browser even when R is running in batch mode? Is this a feature of R
, or from the Debian/Ubuntu front-end? Is there a risk of R
becoming unresponsive when the help
function is called inside i.e. Rserve, RInside, JRI, etc, due to R waiting for using input?
help actually spawns a new process, pager, which is like "less":