bug-bash
[Top][All Lists]
Advanced

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

Re: trap handler scope wrong?


From: Phillip Susi
Subject: Re: trap handler scope wrong?
Date: Sun, 05 Mar 2006 17:12:50 -0500
User-agent: Mail/News 1.5 (X11/20060213)

Does redirecting to /dev/tty work if the original stdout of the shell was NOT a tty? This script runs as a cron job so it has no tty.
Also is there a better way to save the original stdout and switch back to it 
than this:

trap "cat $LOG > &3" ERR
{
 foo
 bar
} 3>&1 > /dev/null


Chet Ramey wrote:

The ERR trap is handled in the context in which the shell is currently
running.  If you want to display the log file on the terminal when the
ERR trap is run, you can either save the original stdout and make the
trap command (the `cat $LOGFILE') redirect its stdout there, or you can
redirect the trap command's standard output directly to /dev/tty.

Chet





reply via email to

[Prev in Thread] Current Thread [Next in Thread]