bug-autoconf
[Top][All Lists]
Advanced

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

Re: autoreconf breaks shell functions in configure.ac


From: Eric Blake
Subject: Re: autoreconf breaks shell functions in configure.ac
Date: Mon, 15 Jan 2018 06:30:14 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2

On 01/14/2018 02:23 AM, Mike Frysinger wrote:
> On 13 Jan 2018 21:42, Yuri wrote:
>> I added this function to configure.ac:
>>
>> log2() {
>>    x=0
>>    y=$(($1>>1))
>>    while [ $y -gt 0 ]; do

You need to use additional [] around any literal [] that you want in
your output, and you have also discovered why autoconf prefers that you
use 'test' instead of '['.

By the way, your function is not completely portable - not all /bin/sh
implement $(()) according to POSIX rules yet, and unless you take
special care to enforce that your configure script probes for and uses a
new-enough shell, your configure will be broken on some older platforms.
 See the documentation of AS_VAR_ARITH, as well as the undocumented
_AS_DETECT_REQUIRED in autoconf/lib/m4sugar/m4sh.m4, for more details
about ensuring a new-enough shell can perform $(()) or other POSIX
constructs not portable to ancient /bin/sh.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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