On 17 September 2018 at 07:09, Duncan Murdoch wrote: | I would not assume that shell behaviour in Windows and Unix would always | be the same. A better comparison would be to list some other command on | the same system that behaves differently. For example, on MacOS I see | | $ echo 'ls() | > ls()' | ls() | ls() | | | which suggests that what you wrote should be legal, but the form of that | command is different: there's no equivalent of "-e". Maybe someone else | who knows Unix shell behaviour better can comment on whether they'd | expect your Rscript command to work.
When we wrote littler, ie 'r', just before Rscript was added to R itself, the ability to work from standard input just like any other Unix tool does was in fact a design feature. So with littler it works (and you need -p to print as we are silent by default by another design choice) edd@rob:~$ (echo "ls()"; echo "ls()") ls() ls() edd@rob:~$ (echo "ls()"; echo "ls()") | r -p [1] "argv" [1] "argv" edd@rob:~$ argv is a global variable to hold the arguments (as in C). Hence standard things work the way you expect them to: edd@rob:~$ echo "set.seed(123); print(summary(rnorm(1e6)))" | r Min. 1st Qu. Median Mean 3rd Qu. Max. -4.79919 -0.67439 -0.00026 -0.00052 0.67333 4.85077 edd@rob:~$ just like r -e ... would, or R -e do now. It is harder to do this for R and Rscript due to the way they are invoked, setting shell variables and all that before calling into $R_HOME/exec/bin/R. Dirk -- http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel