]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Improve AC_STATE_SAVE.
authorEric Blake <ebb9@byu.net>
Tue, 2 Dec 2008 18:51:44 +0000 (11:51 -0700)
committerEric Blake <ebb9@byu.net>
Thu, 4 Dec 2008 03:22:01 +0000 (20:22 -0700)
* tests/local.at (AC_STATE_SAVE): Avoid ls -1, and use one less
process by hoisting the uniqueness check into sed.
* doc/autoconf.texi (Limitations of Usual Tools) <ls>: Mention
MacOS bug.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
doc/autoconf.texi
tests/local.at

index 7ca53e90ed80ec6a95a4dc35f51118cbd75a4a0a..cd343d811f23a2028f42b6b4fe493223aa3d401d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-12-03  Eric Blake  <ebb9@byu.net>
+
+       Improve AC_STATE_SAVE.
+       * tests/local.at (AC_STATE_SAVE): Avoid ls -1, and use one less
+       process by hoisting the uniqueness check into sed.
+       * doc/autoconf.texi (Limitations of Usual Tools) <ls>: Mention
+       MacOS bug.
+
 2008-12-02  Eric Blake  <ebb9@byu.net>
 
        Avoid MacOS readdir bug in testsuite.
index 1decd4b70659d4b124feb6eec7c324ab1ff91ae4..fe28f392f40e0ba0ce2b9eedc75a49b8ad9c133c 100644 (file)
@@ -16575,6 +16575,16 @@ was equivalent to @samp{sources='*.c not found'} in the absence of
 @samp{.c} files.  This is no longer a practical problem, since current
 @command{ls} implementations send diagnostics to standard error.
 
+The behavior of @command{ls} on a directory that is being concurrently
+modified is not always predictable, because of a data race where cached
+information returned by @code{readdir} does not match the current
+directory state.  In fact, MacOS 10.5 has an intermittent bug where
+@code{readdir}, and thus @command{ls}, sometimes lists a file more than
+once if other files were added or removed from the directory immediately
+prior to the @command{ls} call.  Since @command{ls} already sorts its
+output, the duplicate entries can be avoided by piping the results
+through @code{uniq}.
+
 @anchor{mkdir}
 @item @command{mkdir}
 @c ------------------
index 2ec7bc5a2fd6d3d9cc61a0fe9075f9f586d04385..ba81e7c0c5e5b06e2fd9162c56524cca5d417c75 100644 (file)
@@ -197,11 +197,25 @@ m4_define([AT_CONFIGURE_AC],
 # confirm that no test modifies variables outside the Autoconf namespace or
 # leaves temporary files.  AT_CONFIG_CMP uses the variable dumps to confirm that
 # tests have the same side effects regardless of caching.
-# The sort -u is necessary, since MacOS 10.5 has a bug where readdir can
-# list a file multiple times in a rapidly changing directory.
+#
+# The sed script duplicates uniq functionality (thanks to 'info sed
+# uniq' for the recipe), in order to avoid a MacOS 10.5 bug where
+# readdir can list a file multiple times in a rapidly changing
+# directory, while avoiding yet another fork.
 m4_defun([AC_STATE_SAVE],
 [(set) 2>&1 | sort >state-env.$][1
-ls -1 | sed '/^at-/d;/^state-/d;/^config\./d' | sort -u >state-ls.$][1
+ls | sed '/^at-/d;/^state-/d;/^config\./d
+  h
+  :b
+  $b
+  N
+  /^\(.*\)\n\1$/ {
+    g
+    bb
+  }
+  $b
+  P
+  D' >state-ls.$][1
 ])# AC_STATE_SAVE
 ]])