autoconf
[Top][All Lists]
Advanced

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

Re: Recommended way to truncate a shell variable value in autoconf


From: Eric Blake
Subject: Re: Recommended way to truncate a shell variable value in autoconf
Date: Fri, 21 Feb 2014 16:57:28 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0

On 02/21/2014 04:50 PM, Dale Visser wrote:
>> Date: Fri, 21 Feb 2014 15:23:31 -0700
>> From: address@hidden
>> To: address@hidden; address@hidden
>> Subject: Re: Recommended way to truncate a shell variable value in autoconf
>>
>> ...
>> is portable.  Until then, the only portable fallback to this particular
>> problem is the use of 'expr' pattern matching and/or sed scripts.  :(
> 
> I've figured a working alternative using successive calls to `expr STRING : 
> REGEXP`
> 
> But then again I notice in the autoconf docs 
> (https://www.gnu.org/software/autoconf/manual/autoconf.html#Limitations-of-Usual-Tools)
>  this:
> 
> "Don't use length, substr, match and index."
> 
> Since "STRING : REGEXP" does the same thing as "match STRING REGEXP", does 
> that mean I'm out of luck with this approach, too?

'string : regexp' is portable.  'match string regexp' is not.  For
example this use of expr is already present in pretty much any configure
file generated by modern autoconf:

    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'

But if you're trying to modify autoconf proper, I really do think it's
time that we start requiring a shell that supports XSI variable
expansion, rather than forking expr right and left.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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