From: Robert Klemme Date: 2010-01-17T01:50:09+09:00 Subject: Re: How to know if $stderr is reopened to /dev/null On 01/16/2010 01:01 AM, Iñaki Baz Castillo wrote: > El Sábado, 16 de Enero de 2010, Seebs escribió: >> On 2010-01-15, Iñaki Baz Castillo wrote: >>> Hi, how could I know if $stderr has been redirected to /dev/null? >> You couldn't. >> >> Consider a wrapper: >> >> exec 5>/dev/null >> ruby foo.rb 2>&5 >> >> Or for that matter, a file "/home/ibc/nulldev" which happens to be >> a character special device using the same driver as /dev/null. >> >> ... Note that this assumes that what you care about is "$stderr is >> being thrown away", not the exact path by which it's being done. > > Thanks for the clarification. However it's enough for me using $stderr.tty?. > This is, I just care when $stederr is not pointing to a terminal. Note though, that this also includes cases where stderr is redirected to a pipe. robert@fussel:~$ ruby19 -e 'p $stderr.tty?' true robert@fussel:~$ ruby19 -e 'p $stderr.tty?' 2>&1 | cat false robert@fussel:~$ Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/