Skip to content
Prev 19578 / 63424 Next

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

On Thu, 23 Feb 2006, Thomas Lumley wrote:

            
Well, we might not be outputting to a file ... (I did say console), and 
.Last() might well produce output so we need to leave the console in a 
suitable state.  I do think we need a \n unless we can be sure that we are 
currently at the left margin of the console (and I am not sure we can be 
unless we assume all output went through R[E]printf, and even in that 
case we do not currently collect the information).

Consider the script

gannet% cat foo
#!/bin/sh
R --slave --vanilla <<EOF

.Last <- function() cat("goodbye\n")
cat("Hello")
EOF

which produces

gannet% foo.R
Hello
goodbye
gannet%

We do not want

gannet% foo.R
Hellogoodbye
gannet%

or at least, I do not want that.


Beyond that, there must be hundreds or more reference results of test runs 
against which comparisons are made, and this might well affect a lot of 
testing code, although perhaps we could conditionalize on --slave.