[Rd] Spurious output white line in R script (PR#8631)

François Pinard pinard at iro.umontreal.ca
Thu Feb 23 00:10:22 CET 2006

[Simon Urbanek]

>I don't see the bug here ... you may want to explain how this  behavior 
>conflicts with the documentation.

Oh, sorry.  I merely surmised that R developers were aware of the 
meaning of "--slave" option.  Within the output resulting of command 
"man R", one reads:

              Make R run as quietly as possible

So, I was not expecting R, running with that option activated, to 
"volunteer" white lines. :-)

>If you don't want it, tell R to explicitly terminate in your script,
>e.g. with quit("no",0) - then there will be no new line.

Thanks for this work-around, which solves the problem of the spurious 
white line at end of script.  I did not need arguments on the q() call, 
first because the "no" is already implied through "default" from the 
"--vanilla" option and second because 0 is also the default exit status.

Yet, it sounds reasonable to suggest (or hope) that R interprets an 
end-of-file as meaning that R should cleanly quit.  I naively thought 
that it does this already, from the fact that interactively at least, 
R seems to behave on a Ctrl-D as if q() has been called.

This is either right or wrong using an end-of-file instead of calling 
q().  If it is right to use end-of-file instead of an explicit q() call,
I'm reporting a bug.  If it is wrong to use end-of-file instead of an 
explicit q() call, I'm rather making a suggestion. :-)

If you consider that the user is definitely wrong by not calling q() 
explicitly, and that various unexpected things may then happen, R would 
be friendlier if it produced a diagnostic, hitting an end-of-file while 
expecting a statement.  Interactively, it could even go further, and 
nicely remind the user, at the time the user types Ctrl-D, that calling 
q() is the only proper way for cleanly terminating an R session.

>On Feb 22, 2006, at 1:41 PM, pinard at progiciels-bpi.ca wrote:

>>I noticed that R scripts produce a spurious white line after output.
>>For example, the following shell script,

>>R --slave --vanilla <<EOF



>>when made executable under the name ``hello`` along the search  
>>path, behaves
>>like this:

>>$ hello | od -bc
>>0000000 110 145 154 154 157 012 012
>>           H   e   l   l   o  \n  \n

>>The second newline is not wanted, and I would like if R was not
>>producing it.


François Pinard   http://pinard.progiciels-bpi.ca

More information about the R-devel mailing list