[nhc-bugs] Building nhc98 on Windows 2000
C.Reinke
C.Reinke@ukc.ac.uk
Thu, 04 Apr 2002 16:52:36 +0100
> > > ?? you seem to assume that the redirection affects the executing
> > > shell itself, whereas, IMO, it only affects the command. so, if
> > > the shell can't find the command, no redirection, and the shell
> > > reports the error as usual, no?
> >
> > There seems to be a difference between bash and sh - the former behaves
> > as I would like, the latter as you describe.
>
> Under sh, something like
>
> if (basename >/dev/null 2>&1); then echo foo; fi
>
> will hide the shell's stderr.
okay, I admit, I had to check;-)
but for sh, the above will not hide the shell's stderr, only the
condition's stderr, if that condition is found and executed
(reassociating the redirection with the whole helps, though):
> sh
$ if (fullname >/dev/null 2>&1); then echo hi; fi
fullname: not found
$ if (fullname 2>>/dev/null); then echo hi; fi
fullname: not found
$ if fullname ; then echo hi ; fi 2>>/dev/null
$
whereas, as Malcolm pointed out, bash differs from sh here..:-(
> bash
bash-2.04$ if (fullname >/dev/null 2>&1); then echo hi; fi
bash-2.04$ if (fullname 2>>/dev/null); then echo hi; fi
bash-2.04$ if fullname ; then echo hi ; fi 2>>/dev/null
bash-2.04$ if fullname; then echo hi; fi
bash: fullname: command not found
bash-2.04$
Claus