autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I make a portable test??


From: Eric Siegerman
Subject: Re: How do I make a portable test??
Date: Fri, 14 Feb 2003 19:31:12 -0500
User-agent: Mutt/1.2.5i

On Fri, Feb 14, 2003 at 02:32:42PM -0500, Thomas E. Dickey wrote:
> On Fri, 14 Feb 2003, Andreas Schwab wrote:
> 
> > Eric Siegerman <address@hidden> writes:
> >
> > |>   [ksh doesn't support "=="]
> >
> > Since pdksh supports "==" I'd guess that ksh does too.

Yup.  Sort of.  It's icky.

> I don't see that in the manpage for ksh on Solaris 8.
> (csh implements "==")

They botched the Solaris-8 man page, so you can't find it by
searching for "==".  Fooled me too :-)  ksh(1) and test(1) both
say:
     string = pattern
               True, if string matches pattern.

     string != pattern
               True, if string does not match pattern.

     string1=string2
               True if the strings string1 and string2 are ident-
               ical.

     string1! =string2
               True if the strings string1 and  string2  are  not
               identical.

So *all four* of those synopses are wrong!

But that's ok, they botched the implementation too :-)
"==" doesn't seem to actually work on Solaris-8 ksh.  It behaves
like "=":
    $ test "abc" == "abc"; echo $?
    0
Well, duh.  But:
    $ test "abc" == "a?c"; echo $?
    1
Hmmm.  Maybe they're lying and it's a regexp:
    $ test "abc" == "a.c"; echo $?
    1
Hmmmm again.  Ok, take the man page at its punctuation:
    $ test "abc" = "a?c"; echo $? 
    1
Nope, the man page is wrong; _=_ works as it should.  Phew!
Ok, see if they got it backwards, and despite all logic and
experience, "=" with no spaces is the pattern-match operator:
    $ test "abc"="a?c"; echo $?
    0
Well, maybe.  Or maybe not:
    $ test "abc"="za?c"; echo $?
    0
Yup, the string "abc=za?c" is non-null all right.


So we're all sort-of correct.  It isn't supported -- but it's
supposed to be :-)

--

|  | /\
|-_|/  >   Eric Siegerman, Toronto, Ont.        address@hidden
|  |  /
A distributed system is one on which I cannot get any work done,
because a machine I have never heard of has crashed.
        - Leslie Lamport




reply via email to

[Prev in Thread] Current Thread [Next in Thread]