Assaf Gordon wrote:
Trying to isolate it, gives (on that OpenSolaris 5.10 i86pc machine):
===
   $ cat 1.sh
   #!/bin/sh
   test -z "${host_os##os2*}"

   $ ./1.sh
   ./1.sh: bad substitution
===

Just a guess, but perhaps the recent OS/2 patches to gnulib are the source

Thanks for the diagnosis; your guess is correct. Apparently OpenSolaris is still using the old SunOS /bin/sh, which doesn't support parameter substitution with # or % operators, and the test that 'configure' uses for shells (generated by Autoconf) doesn't catch this POSIX incompatibility.

I installed the attached patch into gnulib, which should fix this problem when grep gets the latest gnulib version. Using traditional 'case' is easier to read for this sort of thing anyway.
>From a93faea3bd057b0ef6d2dfdc1a98e24b057a229e Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Sun, 24 Jan 2016 00:28:19 -0800
Subject: [PATCH] closedir, dirfd, opendir: port to OpenSolaris 5.10

* m4/closedir.m4 (gl_FUNC_CLOSEDIR):
* m4/dirfd.m4 (gl_FUNC_DIRFD):
* m4/opendir.m4 (gl_FUNC_OPENDIR):
Don't use ${word##pat} substitution, as it doesn't work in
OpenSolaris 5.10 /bin/sh.  Problem reported by Assaf Gordon in:
http://bugs.gnu.org/22443#11
---
 ChangeLog      | 10 ++++++++++
 m4/closedir.m4 | 11 +++++------
 m4/dirfd.m4    | 14 ++++++--------
 m4/opendir.m4  | 11 +++++------
 4 files changed, 26 insertions(+), 20 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 839c222..2da850c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2016-01-24  Paul Eggert  <egg...@cs.ucla.edu>
+
+	closedir, dirfd, opendir: port to OpenSolaris 5.10
+	* m4/closedir.m4 (gl_FUNC_CLOSEDIR):
+	* m4/dirfd.m4 (gl_FUNC_DIRFD):
+	* m4/opendir.m4 (gl_FUNC_OPENDIR):
+	Don't use ${word##pat} substitution, as it doesn't work in
+	OpenSolaris 5.10 /bin/sh.  Problem reported by Assaf Gordon in:
+	http://bugs.gnu.org/22443#11
+
 2016-01-23  Paul Eggert  <egg...@cs.ucla.edu>
 
 	bootstrap: use American spelling
diff --git a/m4/closedir.m4 b/m4/closedir.m4
index 15a5cc8..e679694 100644
--- a/m4/closedir.m4
+++ b/m4/closedir.m4
@@ -1,4 +1,4 @@
-# closedir.m4 serial 3
+# closedir.m4 serial 4
 dnl Copyright (C) 2011-2016 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -23,9 +23,8 @@ AC_DEFUN([gl_FUNC_CLOSEDIR],
     fi
   ])
   dnl Replace closedir() for supporting the gnulib-defined dirfd() function.
-  if test -z "${host_os##os2*}"; then
-    if test $HAVE_OPENDIR = 1; then
-      REPLACE_OPENDIR=1
-    fi
-  fi
+  case $host_os,$HAVE_OPENDIR in
+    os2,1)
+      REPLACE_OPENDIR=1;;
+  esac
 ])
diff --git a/m4/dirfd.m4 b/m4/dirfd.m4
index 758fed0..1d7cb08 100644
--- a/m4/dirfd.m4
+++ b/m4/dirfd.m4
@@ -1,4 +1,4 @@
-# serial 23   -*- Autoconf -*-
+# serial 24   -*- Autoconf -*-
 
 dnl Find out how to get the file descriptor associated with an open DIR*.
 
@@ -37,15 +37,13 @@ AC_DEFUN([gl_FUNC_DIRFD],
 
   # Use the replacement if we have no function or macro with that name,
   # or if OS/2 kLIBC whose dirfd() does not work.
-  if test $ac_cv_func_dirfd = no && test $gl_cv_func_dirfd_macro = no \
-     || test -z "${host_os##os2*}" ; then
-    if test $ac_cv_have_decl_dirfd = yes; then
-      # If the system declares dirfd already, let's declare rpl_dirfd instead.
+  # Replace only if the system declares dirfd already.
+  case $ac_cv_func_dirfd,$gl_cv_func_dirfd_macro,$host_os,$ac_cv_have_decl_dirfd in
+    no,no,*,yes | *,*,os2*,yes)
       REPLACE_DIRFD=1
       AC_DEFINE([REPLACE_DIRFD], [1],
-        [Define to 1 if gnulib's dirfd() replacement is used.])
-    fi
-  fi
+        [Define to 1 if gnulib's dirfd() replacement is used.]);;
+  esac
 ])
 
 dnl Prerequisites of lib/dirfd.c.
diff --git a/m4/opendir.m4 b/m4/opendir.m4
index 2124f98..ffaa6ae 100644
--- a/m4/opendir.m4
+++ b/m4/opendir.m4
@@ -1,4 +1,4 @@
-# opendir.m4 serial 3
+# opendir.m4 serial 4
 dnl Copyright (C) 2011-2016 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -24,9 +24,8 @@ AC_DEFUN([gl_FUNC_OPENDIR],
   ])
   dnl Replace opendir() on OS/2 kLIBC to support dirfd() function replaced
   dnl by gnulib.
-  if test -z "${host_os##os2*}"; then
-    if test $HAVE_OPENDIR = 1; then
-      REPLACE_OPENDIR=1
-    fi
-  fi
+  case $host_os,$HAVE_OPENDIR in
+    os2*,1)
+      REPLACE_OPENDIR=1;;
+  esac
 ])
-- 
2.5.0

Reply via email to