silent option for library function

Vincent Carey 525-2265
Wed, 30 Oct 2002 11:30:55 -0500 (EST)

> 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
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: