From pinard at iro.umontreal.ca  Thu Feb 23 00:10:22 2006
From: pinard at iro.umontreal.ca (=?iso-8859-1?Q?Fran=E7ois?= Pinard)
Date: Wed, 22 Feb 2006 18:10:22 -0500
Subject: [Rd] Spurious output white line in R script (PR#8631)
In-Reply-To: <20A69DDC-E571-4DD1-9047-0073F47FA7CF@r-project.org>
References: <20060222184113.A6F1B3F70C@slim.kubism.ku.dk>
	<20A69DDC-E571-4DD1-9047-0073F47FA7CF@r-project.org>
Message-ID: <20060222231022.GA24313@phenix.sram.qc.ca>

[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:

       --slave
              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,


>>#!/bin/sh
>>R --slave --vanilla <<EOF

>>cat("Hello\n")

>>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
>>0000007



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


>Cheers,
>Simon


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



[Rd] Spurious output white line in R script (PR#8631)
=?iso-8859-1?Q?Fran=E7ois?= Pinard