zsh-workers
 help / color / mirror / code / Atom feed
* nosuchprogram 2> /dev/null
@ 2010-06-20 20:53 Dave Yost
  2010-06-21 13:02 ` Vincent Lefevre
  0 siblings, 1 reply; 2+ messages in thread
From: Dave Yost @ 2010-06-20 20:53 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 957 bytes --]

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. I expected this:

Sun 13:19:36 s3 yost /home/yost/mill/s3/personal/yost/bench
1 338 Z% nosuchprogram 2> /dev/null
zsh: command not found: nosuchprogram
Sun 13:20:21 s3 yost /home/yost/mill/s3/personal/yost/bench
127 339 Z%

sh and bash act the same way.

This behavior is no doubt over 30 years old, so it would have to be 
changed under control of an option. I think there should be such an 
option.

Couldn't find anything about this anywhere within a reasonable amount 
of time searching.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: nosuchprogram 2> /dev/null
  2010-06-20 20:53 nosuchprogram 2> /dev/null Dave Yost
@ 2010-06-21 13:02 ` Vincent Lefevre
  0 siblings, 0 replies; 2+ messages in thread
From: Vincent Lefevre @ 2010-06-21 13:02 UTC (permalink / raw)
  To: zsh-workers

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@vinc17.net> - 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)


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-06-21 13:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-20 20:53 nosuchprogram 2> /dev/null Dave Yost
2010-06-21 13:02 ` Vincent Lefevre

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).