autoconf-patches
[Top][All Lists]
Advanced

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

Re: [PATCH] Modernize AS_UNSET, take 3


From: Eric Blake
Subject: Re: [PATCH] Modernize AS_UNSET, take 3
Date: Wed, 15 Oct 2008 06:24:40 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.17) Gecko/20080914 Thunderbird/2.0.0.17 Mnenhy/0.7.5.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Paolo Bonzini on 10/15/2008 5:32 AM:
> This addresses all the nits in the previous patch, except one.  I had to
> leave the AS_REQUIRE of _AS_UNSET_PREPARE in AS_INIT, because it defines
> a shell function and so it must go *after* the better-shell search.
> 
> In order to use AS_UNSET([$foo]), which expands to "eval $foo=; unset $foo",
> I had to add an AS_LITERAL_IF.  Nothing special.
> 
> Ok?

Ready to apply, after yet one or two more nits:

> 2008-10-15  Paolo Bonzini  <address@hidden>
> 
>       * lib/m4sugar/m4sh.m4 (_AS_UNSET_PREPARE): Provide $as_unset as an
>       alias for AS_UNSET, for backwards compatibility.
>       (_AS_DETECT_BETTER_SHELL): Set BASH_ENV and ENV to /dev/null in case
>       the shell does not support unset.
>       (_AS_SHELL_SANITIZE): Work around Bash 2.01 bugs.  Unset BASH_ENV.
>       (AS_INIT, _AS_PREPARE, AS_PREPARE): Call it.
>       (AS_UNSET): Assume it is there but it might fail if the variable is
>       not set.  Use it throughout instead of $as_unset.

Per ChangeLog standards, please mention lib/autoconf/general.m4 and
lib/autoconf/programs.m4 by name in this entry.

> -     [for as_var in BASH_ENV ENV
> -     do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
> -     done
> +     [# We cannot yet assume a decent shell, so we have to provide a
> +     # neutralization value for shells without unset; and this also
> +     # works around shells that cannot unset nonexistent variables.
> +     BASH_ENV=/dev/null
> +     ENV=/dev/null
> +     (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV

Nice!  Fewer forks!

> -# Work around bugs in pre-3.0 UWIN ksh.
> -for as_var in ENV MAIL MAILPATH
> -do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
> +# Unset variables that we do not need and cause bugs (e.g. in pre-3.0 UWIN 
> ksh).
> +# But do not cause bugs in bash 2.01; the "|| exit 1" suppresses any
> +# "Segmentation fault" message there.  '((' could trigger a bug in pdksh 
> 5.2.14.
> +for as_var in BASH_ENV ENV MAIL MAILPATH
> +do ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :

But this introduces more forks.  Could we enhance this loop to do
 'eval test x\${$as_var+set} = xset &&'
prior to the subshell, to avoid forks in the common case of (some of) the
variables not being set?

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkj14QgACgkQ84KuGfSFAYA99ACg1/Wd0qFTM1ffLL1TcKrV2trB
PA8An1CE4lBgvGGPV+8f0zdeUZYizMV2
=DO+u
-----END PGP SIGNATURE-----




reply via email to

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