I've written several simple command line tools in ruby to display 
standard reports.  These are all placed in the PATH, so that they can 
be executed like this:

jobstatus.rb -j1233

to show the status for job 1233 (I'm using the getoptlong library.)  
The default output is in fixed width, ASCII character built tables 
(e.g., | for vertical line, - for horizontal line, and + for corners).  
I'd like to be able to automatically sense when the output is being 
piped to somewhere else, so that I can automatically make the report 
switch to a tab delimited format a la the mysql command line client.  
This, for example, allows for much easier use of command line tools 
such as cut, uniq, sort, etc.

I've tried trapping signal 13 (SIGPIPE) and this doesn't work.  In 
fact, I've tried trapping every signal from 0 to 64; 26 throws an 
error, 0 executes on exit (of course), but none of them seem to 
register for any kind of pipe; viz., '<', '>', and '|' all fail to pass 
a signal to the ruby program.

Am I doing something wrong here, or am I going about this entirely the 
wrong way?

Best,

Dave
-------------------------------------------------------
David King Landrith
   (w) 617.227.4469x213
   (h) 617.696.7133

One useless man is a disgrace, two
are called a law firm, and three or more
become a congress   -- John Adams
-------------------------------------------------------
public key available upon request