That is unfortunately wrong, though. Whether the script runs as "main" and whether R is in interactive mode are independent properties. I guess most of the time it works, because _usually_ you run the whole script (main()) in non-interactive mode, and source() it in interactive mode, but this is not necessarily always the case, e.g. you might want to source() in non-interactive mode to run some tests, or use the functions of the script in another script, in which cases you don't want to run main().
G. On Sun, Aug 25, 2019 at 11:47 PM Cyclic Group Z_1 <[email protected]> wrote: > > This seems like a nice idiom; I've seen others use > if(!interactive()){ > main() > } > to a similar effect. > > Best, > CG > > On Sunday, August 25, 2019, 01:16:06 AM CDT, Gábor Csárdi > <[email protected]> wrote: > > > This is what I usually put in scripts: > > if (is.null(sys.calls())) { > main() > } > [...] ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
