Grouped pipeline clobbering question

2006-03-20 Thread Phillip Susi
I'm a bit confused by the results I'm seeing with a pipeline to a group. I was trying to parse a text file in such a way as the first n lines are passed straight through, and then a sed script is applied to the rest. I thought I could do that with something like this: cat file | ( head --lin

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 2>&1 If an error happens inside the {} block, it lo

Re: trap handler scope wrong?

2006-03-07 Thread Phillip Susi
Chet Ramey wrote: trap "cat $LOG > &3" ERR { foo bar } 3>&1 > /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

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 } 3>&1 > /dev/null Chet Ramey w