From stvjc@channing.harvard.edu  Wed Oct 30 16:30:55 2002
From: stvjc@channing.harvard.edu (Vincent Carey 525-2265)
Date: Wed, 30 Oct 2002 11:30:55 -0500 (EST)
Subject: silent option for library function
In-Reply-To: <Pine.LNX.4.31.0210301601500.5214-100000@gannet.stats>
Message-ID: <Pine.GSO.4.40.0210301112360.5730-100000@falmouth.bwh.harvard.edu>

>
> Don't think so.  From help(sink):
>
>      Normal R output is diverted by the default `type = "output"'. Only
>      prompts and warning/error messages continue to appear on the
>      terminal. These too can diverted by `type = "message"' (see
>      below).
>
> and for example
>
> > sink(file="/dev/null")
> > library(foo)
> Error in firstlib(which.lib.loc, package) :
>         testing
> Error in library(foo) : .First.lib failed
> > sink()
>
> So how are you losing error messages?

The point on error messages was speculation.  I am wrong.

>
>
> BTW, there is no way for library() to control what a user does in his
> .First.lib: he could put up a dialog box agreeing the usage terms.
> Actually, that seems a rather good idea ....

Indeed.  However, one could modify library to divert normal R
output if a silent parameter were supplied.

Thus if i edit library to incorporate a parameter silent=FALSE,
and introduce the lines

if (silent) sink("/dev/null")
on.exit( if (silent) sink() )

at the top of the function body, the command

library(mgcv, silent=TRUE)

has the desired silent behavior.  however, ordinary
output is still diverted after the return from library(...)
in this case!  perhaps I misunderstand
the on.exit behavior.  I would expect that it would 'remove'
the sink set in library and restore ordinary processing.

The behavior noted here is for 1.6.1 of 10-19-2002

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


silent option for library function
Vincent Carey 525-2265