trap handler scope wrong?

2006-03-10 Thread Phillip Susi
I ran into something weird the other day, but I'm not sure if it's a bug or not since I'm a bit new to bash shell scripting. Basically I have a script that has structure like this: set -e trap cat $LOGFILE ERR { foo bar baz } $LOGFILE 21 If an error happens inside the {} block, it looks

Re: trap handler scope wrong?

2006-03-07 Thread Phillip Susi
Chet Ramey wrote: trap cat $LOG 3 ERR { foo bar } 31 /dev/null That's about right, but you need 3 in the trap command. I did have 3 in the trap command, see? I'm a bit worried though about hard coding the fd 3. Is there a way to get the next available fd number and save it in a

Re: trap handler scope wrong?

2006-03-05 Thread Phillip Susi
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 } 31 /dev/null Chet Ramey wrote: