[NTLUG:Discuss] An Oddity (bug) in Redhat 7.1

Kenneth Loafman ken at lt.com
Sun Oct 28 16:15:24 CST 2001


Steve Baker wrote:
> 
> Kenneth Loafman wrote:
> >
> > An interesting bug was found in RH 7.1 shell.  Redirection of both
> > stdout and stderr can be done with either >& or &>, with the first form
> > being predominate in use.  Both are semantically equivalent according to
> > the bash manual.  I've been using >& for years and its embedded in a lot
> > scripts since it works on every other distro.  Not so for Redhat 7.1.
> >
> >   *** &> will redirect both while >& redirects nothing ***
> 
> Eh!?  Which version number does bash return?  2.03 under SuSE Linux seems
> to allow both &> and >& .  I agree with you that >& is correct - but 'Bourne'
> shells typically don't support it - that's a 'csh' shell mechanism.  tcsh (for
> example) allows >& but &> is interpreted thus:
> 
>   echo "Hello World"  &> temp
> 
> ...the shell sees this as a request to run 'echo' in background:
> 
>   echo "Hello World" &
> 
> ...followed by a null command whose stdout is redirected to the file 'temp'.
> It just gives an error for the null command.
> 
> Bourne shell (and hence, I would have thought - 'bash') uses
> 
>     N>
> 
> (Where N is a file descriptor number).
> 
> Hence:
> 
>     2>
> 
> Should redirect stderr.
> 
> There are just *so* many things that are strange under RedHat 7.x

'bash --version' yields:
GNU bash, version 2.04.21(1)-release (i386-redhat-linux-gnu)

...Kenneth



More information about the Discuss mailing list