]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
doc: mention trap pitfalls
authorEric Blake <eblake@redhat.com>
Wed, 18 Jul 2012 20:53:24 +0000 (14:53 -0600)
committerEric Blake <eblake@redhat.com>
Wed, 18 Jul 2012 20:58:16 +0000 (14:58 -0600)
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

index 506d9667ada62da560955ffa60fdf00c3579291b..927921c4ce3470ee175207fde6b6e2fbaa407bc6 100644 (file)
@@ -18346,6 +18346,18 @@ $ @kbd{bash-2.05b -c 'trap ":; /bin/true" 0; exit 2'; echo $?}
 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
+@env{IFS}, then the trap should include an initialization back to its
+typical value of space-tab-newline (autoconf does this for generated
+@file{configure} 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}