autoconf
[Top][All Lists]
Advanced

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

Re: AS_DIRNAME and expr


From: Akim Demaille
Subject: Re: AS_DIRNAME and expr
Date: 29 Nov 2000 12:29:09 +0100
User-agent: Gnus/5.0807 (Gnus v5.8.7) XEmacs/21.1 (Channel Islands)

| Akim: 

Hi!

| I'm curious as to how you plan to use this information. I got the
| impression that you were suggesting to use something like:
| 
| expr foo : '\(bar\)' \| a : 'a\(\)

Nope, not exactly.  It is true there are two issues being debated, and
the thread is quite confusing.

The first thing I was trying to emphasize is that

expr foo : bar

was proved to be able to return the string 0 (or the empty string),
but it had to be de-correlated from another question:

expr foo : 'bar\(\)'

I was expecting the later to return indeed the empty string.  I'll
have to reread the whole thread, because I don't remember if someone
showed a case where `0' is output.

I can't believe that some expr would answer `0' to

expr foo : 'foo\(\)'

but I'd appreciate if someone could try on her host :)

Finally, what I was suggesting was to use the empty string itself as
fall back, hoping that it would erase the 0.

| but beware that this behaves on different machines:
| solaris$ expr foo : '\(bar\)' \| a : 'a\(\)
| 0

here I was suggesting

expr foo : '\(bar\)' \| ''

and hoped we'd get a empty output instead of 0.

I know that the Autoconf documentation says 

     You can use `|'.  There is one portability problem occuring when
     you `|' together the empty string (or zero) with the empty string.
     For example:

          expr '' \| ''

     GNU/Linux and POSIX.2 return the empty string for this case, but
     traditional Unix returns `0'.  In the latest POSIX draft, the
     specification has been changed to match traditional Unix's behavior
     (which is bizarre, but it's too late to fix this).

     Avoid this portability problem by avoiding the empty string.

but it's not clear to me whether there is a difference between the
empty as a literal or as the result of an evaluation.  In other, what
the documentation says here, is it valid for

expr foo : bar \| bar : foo

I guess it is and you'll get a `0'.

But then, maybe the problem is just very simple: isn't it just the
empty string which evaluates to 0?  I mean, could you try this on your
solaris?

        expr ''

Thanks!

        Akim



reply via email to

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