autoconf
[Top][All Lists]
Advanced

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

Re: AS_DIRNAME and expr


From: Paul Eggert
Subject: Re: AS_DIRNAME and expr
Date: Thu, 9 Nov 2000 15:04:00 -0800 (PST)

> From: David Morgan <address@hidden>
> Date: Thu, 09 Nov 2000 08:12:01 -0800

> > | > expr 'a' : '\(b\)' && echo failure
> > |
> > | Gives:
> > | 0
> > 
> > Result is wrong, $? right.

> Wrong explanation - no characters match so the output of 0 is correct
> (At least I think so)

The POSIX standard says:

   Usually, the matching operator shall return a string representing
   the number of characters matched ('0' on failure). Alternatively,
   if the pattern contains at least one regular expression
   subexpression "[\(...\)]", the string corresponding to "\1" shall
   be returned.

This leaves it ambiguous as to what expr 'a' : '\(b\)' should return.
One could easily argue that it should be '0'.  But in practice,
GNU/Linux and Solaris expr both return the empty string, under the
theory that the operation is returning a string.

However, autoconf's use of expr in AS_DIRNAME should be OK either way,
so I don't see why this matters to autoconf.

> > Man!  Did I miss something?  David, could you double check this is
> > right?  Paul, what do you think about this?

Sorry, I've lost context.  Why is this a problem?  If expr exits with
nonzero status, then AS_DIRNAME will fall back on sed, right?


By the way, In reviewing the latest AS_DIRNAME I see a quoting
problem.  AS_DIRNAME_SED shell-quotes its argument, but
AS_DIRNAME_EXPR doesn't.  This needs to be handled consistently.

Also, in looking at the callers of AS_DIRNAME, I see that some callers
quote their arguments, but some don't.  This also needs to get fixed.

I don't know what the desired quoting convention is, so I'll leave it
to you to fix the problem.



reply via email to

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