From johnz at vmware.com  Tue Jun 10 15:56:55 2003
From: johnz at vmware.com (John Zedlewski)
Date: Tue Jun 10 23:51:51 2003
Subject: [Rd] Re: [R] early R messages to stdout
In-Reply-To: <Pine.LNX.4.44.0306101149290.13455-100000@gannet.stats>
References: <Pine.LNX.4.44.0306101149290.13455-100000@gannet.stats>
Message-ID: <200306101456.57126.johnz@vmware.com>

On Tuesday 10 June 2003 03:59 am, Prof Brian Ripley wrote:
> No patch was included in the distributed message.  Moved to R-devel, as
> this is not a help question.

Maybe the attachment was stripped by mailman. Hopefully the diff (which is now 
attached inline at the end of this message) will clear up all of these 
questions.
Perhaps the web page http://www.r-project.org/mail.html should be changed 
then? It currently says that r-help is for, among other things: "enhancements 
and patches to the source code and documentation of R"

> By not having R_ConsoleFile set R_WriteConsole is used.
> I don't think you can assume that all users of that code will have a
> stderr.
>

The original code itself makes this assumption. On all non-aqua UNIX systems, 
the code unconditionally sets R_ConsoleFile to stderr. My code simply moves 
up the location of that setting.

> If you find the warnings (*not* errors) annoying, don't misuse R by
> supplying incorrect arguments.  Use e.g. environment variables to pass
> your input.

Why is it a misuse to pass arguments to an R program? Every modern interpreter 
on UNIX systems allows this functionality. If you have an R program that 
requires 4 input variables, it is quite inconvenient to require the user to 
set them all as environment variables. 

Similarly, all UNIX programs are expected to display unexpected error and 
warning messages to stderr and regular output to stdout, so that users can 
redirect them as desired.

Diff follows:

*** R-1.7.0-old/src/unix/system.c	2003-03-11 16:09:47.000000000 -0800
--- R-1.7.0/src/unix/system.c	2003-06-08 19:47:59.000000000 -0700
***************
*** 125,130 ****
--- 125,134 ----
      ptr_R_savehistory = Rstd_savehistory;
      R_timeout_handler = NULL;
      R_timeout_val = 0;
+ #ifndef HAVE_AQUA
+     R_Outputfile = stdout;
+     R_Consolefile = stderr;
+ #endif
  
      R_GlobalContext = NULL; /* Make R_Suicide less messy... */
  
***************
*** 240,252 ****
      R_Interactive = isatty(0);
  #ifdef HAVE_AQUA
      if(useaqua){
!      R_Outputfile = NULL;
!      R_Consolefile = NULL;
      } else { 
! #endif
!     R_Outputfile = stdout;
!     R_Consolefile = stderr;
! #ifdef HAVE_AQUA
      }
  #endif 
  
--- 244,254 ----
      R_Interactive = isatty(0);
  #ifdef HAVE_AQUA
      if(useaqua){
!        R_Outputfile = NULL;
!        R_Consolefile = NULL;
      } else { 
!        R_Outputfile = stdout;
!        R_Consolefile = stderr;
      }
  #endif


[Rd] Re: [R] early R messages to stdout
John Zedlewski