[Rd] [patch] Rscript off-by-one error in output

Scott Kostyshak skostysh at princeton.edu
Thu Jul 10 01:26:59 CEST 2014


Rscript eats up the last argument when reporting the command it runs:

$ Rscript --verbose "/tmp/test.R" one two three
running
  '/usr/local/lib/R-devel/lib/R/bin/R --slave --no-restore
--file=/tmp/test.R --args one two'

With the patch below, I get the following:

$ Rscript --verbose "/tmp/test.R" one two three
running
  '/usr/local/lib/R-devel/lib/R/bin/R --slave --no-restore
--file=/tmp/test.R --args one two three'


Index: src/unix/Rscript.c
===================================================================
--- src/unix/Rscript.c  (revision 66100)
+++ src/unix/Rscript.c  (working copy)
@@ -249,7 +249,7 @@
 #endif
     if(verbose) {
  fprintf(stderr, "running\n  '%s", cmd);
- for(i = 1; i < ac-1; i++) fprintf(stderr, " %s", av[i]);
+ for(i = 1; i < ac; i++) fprintf(stderr, " %s", av[i]);
  fprintf(stderr, "'\n\n");
     }
 #ifndef _WIN32


Scott


> sessionInfo()
R Under development (unstable) (2014-07-08 r66100)
Platform: x86_64-unknown-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base


--
Scott Kostyshak
Economics PhD Candidate
Princeton University



More information about the R-devel mailing list