[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ast-users
Subject:    [ast-users] Re: [bbx-list] Re: old SCO script not working in
From:       rac () tenzing ! org (Roger Cornelius)
Date:       2008-01-28 17:42:44
Message-ID: 20080128224209.GA874 () tenzing ! org
[Download RAW message or body]

Thanks to both you and Glenn for your elucidation.

On 01/25/2008 12:37, David Korn wrote:
> Subject: Re: [ast-users] Re: [bbx-list] Re: old SCO script not working in Suse  Linux
> --------
> 
> > On another, non-ksh related, mailing list, someone wrote:
> > 
> > > <> is a legal operator under SCO's old version of ksh, and also under 
> > > Linux's bash.
> > > 
> > > This runs fine under 5.0.7 and ksh:
> > > 
> > > aa="OK"
> > > 
> > > if [ "$aa" <> "XX" ]
> > >   then
> > >   echo "Was not XX"
> > > fi
> > > 
> > > The echo line displays when run.
> > 
> > This indeed works as he describes, but the case where the two items
> > being tested are equal does not.  I.e.:
> > 
> >     aa="OK"
> > 
> >     if [ "$aa" <> "OK" ]
> >       then
> >       echo "Was not XX"
> >     fi
> > 
> > This still prints "Was not XX".  I don't believe <> was ever valid
> > syntax, so what is really going on here.  Are the <> operators being
> > interpreted as IO redirection?  Why does the shell not generate an error?
> 
> Since
> 	[ "$aa" <> "XX" ]
> is an ordinary command, unlike [[...]], it is parsed with the normal rules.
> Redirection operators can be anywhere on the line so that this is equivalent
> to
> 	[ "$aa" ] <> "XX"
> The <> opens XX for reading and writing.
> 
> This returns true if $aa is not empty and if $aa does not begin with -
> and is not ! in which case it could be an error.
> 
> David Korn
> dgk@research.att.com
> _______________________________________________
> ast-users mailing list
> ast-users@research.att.com
> https://mailman.research.att.com/mailman/listinfo/ast-users
> 

-- 
Roger Cornelius        rac@tenzing.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic