]> Savannah Git Hosting - gnulib.git/commitdiff
tests: fix 'invalid path dir' error
authorKO Myung-Hun <komh@chollian.net>
Sat, 7 Oct 2017 10:21:07 +0000 (19:21 +0900)
committerBruno Haible <bruno@clisp.org>
Sat, 7 Oct 2017 12:30:13 +0000 (14:30 +0200)
On OS/2, a path separator is ';' not ':'. And ':' is used as a
separator between a drive letter and directory parts.

As a result, an absolute path such as x:/path/to/dir on OS/2 is
treated as an invalid path dir.

* tests/init.sh (PATH_SEPARATOR): Set at startup.
(path_prepend_): '?:*' is also an absolute path. Use $PATH_SEPARATOR
instead of hard coded ':'.

ChangeLog
tests/init.sh

index 74d1d1ec177d85886c08cefae3fe0f75959c25fa..8a225e924d85611aaac533cddeaf484224b347f6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2017-10-07  KO Myung-Hun  <komh@chollian.net>
+
+       test-framework-sh: Fix 'invalid path dir' error.
+       On OS/2, a path separator is ';' not ':'. And ':' is used as a
+       separator between a drive letter and directory parts.
+       As a result, an absolute path such as x:/path/to/dir on OS/2 is
+       treated as an invalid path dir.
+       * tests/init.sh (PATH_SEPARATOR): Set at startup.
+       (path_prepend_): '?:*' is also an absolute path. Use $PATH_SEPARATOR
+       instead of hard coded ':'.
+
 2017-10-07  Bruno Haible  <bruno@clisp.org>
 
        vma-iter: Fix truncated result on Linux (regression from 2017-09-26).
index 0821c572ae71aef4d5dd9913e8470b7b61c5ab25..24fb51219a1c65ad1ef85256e01da3dc3f072ef4 100644 (file)
 
 ME_=`expr "./$0" : '.*/\(.*\)$'`
 
+# Prepare PATH_SEPARATOR.
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  # 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
+
 # We use a trap below for cleanup.  This requires us to go through
 # hoops to get the right exit status transported through the handler.
 # So use 'Exit STATUS' instead of 'exit STATUS' inside of the tests.
@@ -429,13 +442,13 @@ path_prepend_ ()
     path_dir_=$1
     case $path_dir_ in
       '') fail_ "invalid path dir: '$1'";;
-      /*) abs_path_dir_=$path_dir_;;
+      /* | ?:*) abs_path_dir_=$path_dir_;;
       *) abs_path_dir_=$initial_cwd_/$path_dir_;;
     esac
     case $abs_path_dir_ in
-      *:*) fail_ "invalid path dir: '$abs_path_dir_'";;
+      *$PATH_SEPARATOR*) fail_ "invalid path dir: '$abs_path_dir_'";;
     esac
-    PATH="$abs_path_dir_:$PATH"
+    PATH="$abs_path_dir_$PATH_SEPARATOR$PATH"
 
     # Create an alias, FOO, for each FOO.exe in this directory.
     create_exe_shims_ "$abs_path_dir_" \