>>>>> Harris A Jaffee <h...@jhu.edu> >>>>> on Thu, 18 Sep 2014 19:32:29 +0200 writes:
(using HTML, please don't ) > The loop that echoes the arguments almost always stops too soon. It > apparently does that to avoid > echoing the "--args" (that had been inserted) when there are no user > arguments. However, when there > are user arguments, the next element of the 'av' array is the last > argument and usually not "--args", > although it can be. > ?Rscript is a little sketchy: > `--verbose' gives details of what `Rscript' is doing. Also passed > on to R. > What is passed to R is correct, but the diagnostic is not: > $ Rscript --verbose /dev/null 1 2 > running > '/path_to_R --slave --no-restore --file=/dev/null --args 1' > Fixed (only tested on Mac): > $ Rscript --verbose /dev/null 1 2 > running > '/Library/Frameworks/R.framework/Versions/3.1/Resources/bin/R --slave > --no-restore --file=/dev/null --args 1 2' You are right about the problem, also reproducible on Linux. You mention a 'fix'. It looks to me that is just - for(i = 1; i < ac-1; i++) fprintf(stderr, " %s", av[i]); + for(i = 1; i < ac; i++) fprintf(stderr, " %s", av[i]); in unix/Rscript.c, right ? BTW: If one use -e 'commandArgs()' instead of /dev/null one sees that Rscript's "lying" about the last argument is not helpful anyway : Rscript --verbose -e 'commandArgs()' running '/usr/local64.sfs/app/R/R-3.1.1-inst/bin/R --slave --no-restore -e commandArgs()' [1] "/usr/local64.sfs/app/R/R-3.1.1-inst/bin/exec/R" [2] "--slave" [3] "--no-restore" [4] "-e" [5] "commandArgs()" [6] "--args" because the '--args' appears anyway and indeed *is* passed to 'R'... A better fix would rather suppress that; but I will commit the above change. Martin Maechler ETH Zurich ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel