init.sh: don't let an ephemeral "*.exe" make us skip all dir entries
authorJim Meyering <meyering@redhat.com>
Sat, 18 Sep 2010 06:33:23 +0000 (08:33 +0200)
committerJim Meyering <meyering@redhat.com>
Sat, 18 Sep 2010 06:48:01 +0000 (08:48 +0200)
Not that it's likely to happen, but if I were to remove from a PATH
directory a file named "*.exe" (yes, starting with an asterisk),
at just the right moment, it would have made init.sh ignore all
remaining .exe-suffixed names in that directory.

* tests/init.sh (find_exe_basenames_): Don't give up on a directory if
a file named "*.exe" is removed between the glob expansion and the
processing of that oddly named file.

ChangeLog
tests/init.sh

index 9f180a0..4caca7c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-09-18  Jim Meyering  <meyering@redhat.com>
+
+       init.sh: don't let an ephemeral "*.exe" make us skip all dir entries
+       * tests/init.sh (find_exe_basenames_): Don't give up on a directory if
+       a file named "*.exe" is removed between the glob expansion and the
+       processing of that oddly named file.
+
 2010-09-17  Eric Blake  <eblake@redhat.com>
 
        mirbsd: add some more support
index d655fbb..20357ce 100644 (file)
@@ -240,9 +240,11 @@ find_exe_basenames_()
   feb_result_=
   feb_sp_=
   for feb_file_ in $feb_dir_/*.exe; do
-    if test "x$feb_file_" = "x$feb_dir_/*.exe" && test ! -f "$feb_file_"; then
-      return 0
-    fi
+    # If there was no *.exe file, or there existed a file named "*.exe" that
+    # was deleted between the above glob expansion and the existence test
+    # below, just skip it.
+    test "x$feb_file_" = "x$feb_dir_/*.exe" && test ! -f "$feb_file_" \
+      && continue
     case $feb_file_ in
       *[!-a-zA-Z/0-9_.+]*) feb_fail_=1; break;;
       *) # Remove leading file name components as well as the .exe suffix.