autoconf-patches
[Top][All Lists]
Advanced

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

Re: [PATCH 2/2] config.status: minimize use of $tmp


From: Eric Blake
Subject: Re: [PATCH 2/2] config.status: minimize use of $tmp
Date: Mon, 30 Aug 2010 10:41:47 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.8) Gecko/20100806 Fedora/3.1.2-1.fc13 Mnenhy/0.8.3 Thunderbird/3.1.2

On 08/27/2010 01:24 PM, Eric Blake wrote:

I like the fact that I can use ${ac_tmp:=$tmp} ;)

  $debug ||
  {
-  tmp=
+  tmp= ac_tmp=
    trap 'exit_status=$?
-  { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; }&&  exit $exit_status
+  { test ! -d "${ac_tmp:=$tmp}" || rm -fr "$ac_tmp"; }&&  exit $exit_status

And then I promptly used it incorrectly. Per what we just documented, we cannot assume that ${a=b} takes effect in the parent shell if we are executing a child command like test, so the rm -fr "$ac_tmp" command would be suspect in some, but not all, shells (although I don't know that I could reliably reproduce the race conditions necessary to expose that bug). So I'm squashing this in, by inspection:

diff --git i/lib/autoconf/status.m4 w/lib/autoconf/status.m4
index c44aed4..07889ae 100644
--- i/lib/autoconf/status.m4
+++ w/lib/autoconf/status.m4
@@ -1626,13 +1626,14 @@ fi
# Note that there is a small window in which the directory will not be cleaned:
 # after its creation but before its name has been assigned to `$tmp'.
 dnl For historical reasons, AS_TMPDIR must continue to place the results
-dnl in $tmp; but we swap to the namespace clean $ac_tmp to avoid issues
+dnl in $tmp; but we swap to the namespace-clean $ac_tmp to avoid issues
 dnl with any CONFIG_COMMANDS playing with the common variable name $tmp.
 $debug ||
 {
   tmp= ac_tmp=
   trap 'exit_status=$?
-  { test ! -d "${ac_tmp:=$tmp}" || rm -fr "$ac_tmp"; } && exit $exit_status
+  : "${ac_tmp:=$tmp}"
+  { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status
 ' 0
   trap 'AS_EXIT([1])' 1 2 13 15
 }


--
Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org



reply via email to

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