bug-gnulib
[Top][All Lists]
Advanced

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

Re: [PATCH] Set PATH_SEPARATOR the same way autoconf does.


From: Bruno Haible
Subject: Re: [PATCH] Set PATH_SEPARATOR the same way autoconf does.
Date: Sat, 4 Sep 2010 11:14:01 +0200
User-agent: KMail/1.9.9

Hi Stefano,

> A mostly cosmetic patch.

Please, next time, explain why the way autoconf does it is better than the way
gnulib-tool does it. I can see two reasons, but they are not obvious without
comments:
  - It works around a problem with the Korn shell, see
    <http://lists.gnu.org/archive/html/bug-autoconf/2007-06/msg00009.html>
    and 
<http://www.gnu.org/software/autoconf/manual/html_node/Special-Shell-Variables.html>
  - It does not need a temporary directory.

So, I'm applying your patch, with comments added and with line breaking done
before binary operators, not after binary operators (like in C). Thanks for
the suggestion and patch.

Also, I'm applying the same change to the files
  build-aux/relocatable.sh.in
  m4/lib-ld.m4
  m4/progtest.m4


diff --git a/gnulib-tool b/gnulib-tool
index b606ad6..8168408 100755
--- a/gnulib-tool
+++ b/gnulib-tool
@@ -372,15 +372,14 @@ func_gnulib_dir ()
       # explicit canonicalization command when $PATH contains no empty fields.
       self_abspathname=
       if test "${PATH_SEPARATOR+set}" != set; then
-        func_tmpdir
-        { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh
-        chmod +x "$tmp"/conf.sh
-        if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then
-          PATH_SEPARATOR=';'
-        else
-          PATH_SEPARATOR=:
-        fi
-        rm -rf "$tmp"
+        # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
+        # contains only /bin. Note that ksh looks also at the FPATH variable,
+        # so we have to set that as well for the test.
+        PATH_SEPARATOR=:
+        (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
+          && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
+                 || PATH_SEPARATOR=';'
+             }
       fi
       if test "$PATH_SEPARATOR" = ";"; then
         # On Windows, programs are searched in "." before $PATH.
diff --git a/posix-modules b/posix-modules
index 46de93d..b93b283 100755
--- a/posix-modules
+++ b/posix-modules
@@ -115,15 +115,14 @@ func_gnulib_dir ()
       # explicit canonicalization command when $PATH contains no empty fields.
       self_abspathname=
       if test "${PATH_SEPARATOR+set}" != set; then
-        func_tmpdir
-        { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh
-        chmod +x "$tmp"/conf.sh
-        if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then
-          PATH_SEPARATOR=';'
-        else
-          PATH_SEPARATOR=:
-        fi
-        rm -rf "$tmp"
+        # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
+        # contains only /bin. Note that ksh looks also at the FPATH variable,
+        # so we have to set that as well for the test.
+        PATH_SEPARATOR=:
+        (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
+          && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
+                 || PATH_SEPARATOR=';'
+             }
       fi
       if test "$PATH_SEPARATOR" = ";"; then
         # On Windows, programs are searched in "." before $PATH.



reply via email to

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