[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Is redirecting stdout/stderr in postinst allowed?



Frank Küster wrote:
> Hi,
> 
> the developers' reference says in 6.4:
> 
> | Standard input and output may be redirected (e.g. into pipes) for
> | logging purposes, so don't rely on them being a tty.
> 
> So far, so good. But is it o.k. if the script itself performs
> redirections? For example something like the following in postinst:
> 
> db_get mypackage/someinfo
> 
> VAR=`process $RET | mangle with $WHATEVER`
> 
> exec 3>&1 >> $someconffile
> echo "#added by postinst"
> echo $VAR
> exec >&3
> 
> Of course in this case, a here-document would be sufficient, but not
> generally. 

Generally sure, this is ok. You need to be a little bit careful with
debconf and filehandle swapping later, since it always swaps them around
as follows, and takes over stdin and stdout:

exec 3>&1 1>&2

Since you apparently understand exec file handle switching and I have to
read up on it each time, I'll omit any explinations of what that does.
:-) See /usr/share/debconf/confmodule for more.

-- 
see shy jo

Attachment: pgpv9KKvngqJF.pgp
Description: PGP signature


Reply to: