bug-autoconf
[Top][All Lists]
Advanced

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

Re: IFS clobbering


From: Eric Blake
Subject: Re: IFS clobbering
Date: Wed, 18 Jul 2012 14:58:12 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1

On 07/18/2012 02:23 PM, Andreas Schwab wrote:
> Eric Blake <address@hidden> writes:
> 
>> We need to document this issue if we decide this is important enough to
>> fix in autoconf.  But a patch for this issue seems like a reasonable
>> improvement to me.  Would you like to help write one?
> 
> How about this?
> 
> Andreas.
> 
>>From e45f558825d68ae898153c33c710ac377016fc8d Mon Sep 17 00:00:00 2001
> From: Andreas Schwab <address@hidden>
> Date: Tue, 22 Nov 2011 00:36:46 +0100
> Subject: [PATCH] general: Sanitize IFS in EXIT trap
> 
> IFS may be modified temporarily when the configure script receives a
> signal.  Make sure the EXIT trap uses the standard value.
> 
> * lib/autoconf/general.m4: Sanitize IFS in trap.

I like it, and pushed.  I also tweaked your listing in THANKS, assuming
you prefer a newer email address these days.  I think it's also worth a
mention in the docs, so I'll follow up with:

From 9debc540b081488f92a71d0850736786ec2d92c8 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Wed, 18 Jul 2012 14:53:24 -0600
Subject: [PATCH] doc: mention trap pitfalls

Document why the previous patch was useful.

* doc/autoconf.texi (Limitations of Builtins) <trap>: Mention the
need to be defensive in trap handlers.
---
 doc/autoconf.texi |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 506d966..0dd4898 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -18346,6 +18346,18 @@ Limitations of Builtins
 2
 @end example

+Be aware that a trap can be called from any number of places in your
+script, and therefore the trap handler should not make assumptions about
+shell state.  For some examples, if your script temporarily modifies
address@hidden, then the trap should include an initialization back to its
+typical value of space-tab-newline (autoconf does this for generated
address@hidden files).  Likewise, if your script changes the current
+working directory at some point after the trap is installed, then your
+trap cannot assume which directory it is in, and should begin by
+changing directories to an absolute path if that is important to the
+cleanup efforts (autotest does this for generated @file{testsuite}
+files).
+
 @item @command{true}
 @c -----------------
 @prindex @command{true}
-- 
1.7.10.4



-- 
Eric Blake   address@hidden    +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]