Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: nosuchprogram 2> /dev/null



On 2010-06-20 13:53:20 -0700, Dave Yost wrote:
> Sun 13:19:36 s3 yost /home/yost/mill/s3/personal/yost/bench
> 1 338 Z% nosuchprogram
> zsh: command not found: nosuchprogram
> Sun 13:20:21 s3 yost /home/yost/mill/s3/personal/yost/bench
> 127 339 Z% nosuchprogram 2> /dev/null
> Sun 13:20:27 s3 yost /home/yost/mill/s3/personal/yost/bench
> 127 340 Z%
> 
> This command intends to redirect the output of nosuchcommand, but
> unintentionally, it is also redirecting the error output from zsh
> itself!
> 
> I think this behavior is wrong.

This behavior is correct and very important to avoid spurious
error messages. For instance, I have in my .zshenv:

export LC_CHARMAP="$(codeset 2> /dev/null || locale charmap)"

and I don't want an error message if "codeset" doesn't exist.

Similarly:

if [[ -z $COLORTERM && \
      ( $TERM == xtermc || `tput colors 2>/dev/null` -ge 1 ) ]] then
  export COLORTERM="$TERM"
fi

One may also want to test the output of:

  some_program --version 2>/dev/null

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)



Messages sorted by: Reverse Date, Date, Thread, Author