Subject: Re: redirection within sh-like shells
To: None <tech-userlevel@netbsd.org>
From: David Laight <david@l8s.co.uk>
List: tech-userlevel
Date: 08/15/2002 16:17:59
On Thu, Aug 15, 2002 at 05:00:21PM +0200, Aymeric Vincent wrote:
> Jan Schaumann <jschauma@netbsd.org> writes:
>
> > Klaus Heinz <k.heinz.aug.zwei@onlinehome.de> wrote:
> >
> > > $ sh
> > > $ bla >/dev/null 2>&1
> > > bla: not found
> >
> > Given my understanding of shells and redirection, I can not comprehend
> > why 'sh' does _not_ print the error to /dev/null. It has been
> > instructed to do so.
>
> Actually, the shell has been instructed to redirect the output of the
> "bla" command to /dev/null. Not its own output.
>
> So it seems semantically correct to me.
The pertintent section of xcu is:
http://www.opengroup.org/onlinepubs/007904975/utilities/xcu_chap02.html#tag_02_09_01_01
Command search and execution:
...
ii. If the search is unsuccessful, the command shall fail with
an exit status of 127 and the shell shall write an error message.
Note that the command fails first, the error is written after.
Also the redirections are done 'in the execution environment of the command'.
David
--
David Laight: david@l8s.co.uk