+2010-09-07 Eric Blake <eblake@redhat.com>
+
+ getopt: handle POSIXLY_CORRECT set but not exported
+ * m4/getopt.m4 (gl_GETOPT_CHECK_HEADERS): Restore pre-existing
+ export state of POSIXLY_CORRECT, due to bash set -o posix.
+ Reported by Dustin J. Mitchell.
+
2010-09-05 Bruno Haible <bruno@clisp.org>
gnulib-tool: Highlight the changed options.
-# getopt.m4 serial 29
+# getopt.m4 serial 30
dnl Copyright (C) 2002-2006, 2008-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
AC_DEFUN([gl_GETOPT_CHECK_HEADERS],
[
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+ AC_REQUIRE([AC_PROG_AWK]) dnl for awk that supports ENVIRON
dnl Persuade Solaris <unistd.h> to declare optarg, optind, opterr, optopt.
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
# optstring is necessary for programs like m4 that have POSIX-mandated
# semantics for supporting options interspersed with files.
# Also, since getopt_long is a GNU extension, we require optind=0.
- gl_had_POSIXLY_CORRECT=${POSIXLY_CORRECT:+yes}
+ # Bash ties 'set -o posix' to a non-exported POSIXLY_CORRECT;
+ # so take care to revert to the correct (non-)export state.
+dnl GNU Coding Standards currently allow awk but not env; besides, env
+dnl is ambiguous with environment values that contain newlines.
+ gl_awk_probe='BEGIN { for (v in ENVIRON)
+ if (v == "POSIXLY_CORRECT") print "x" }'
+ case ${POSIXLY_CORRECT:+x}`$AWK "$gl_awk_probe" </dev/null` in
+ xx) gl_had_POSIXLY_CORRECT=exported ;;
+ x) gl_had_POSIXLY_CORRECT=yes ;;
+ *) gl_had_POSIXLY_CORRECT= ;;
+ esac
POSIXLY_CORRECT=1
export POSIXLY_CORRECT
AC_RUN_IFELSE(
*) gl_cv_func_getopt_gnu=yes;;
esac
])
- if test "$gl_had_POSIXLY_CORRECT" != yes; then
- AS_UNSET([POSIXLY_CORRECT])
- fi
+ case $gl_had_POSIXLY_CORRECT in
+ exported) ;;
+ yes) AS_UNSET([POSIXLY_CORRECT]); POSIXLY_CORRECT=1 ;;
+ *) AS_UNSET([POSIXLY_CORRECT]) ;;
+ esac
])
if test "$gl_cv_func_getopt_gnu" = "no"; then
gl_replace_getopt=yes