autoconf-patches
[Top][All Lists]
Advanced

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

Re: install-sh posix compliance


From: Paul Eggert
Subject: Re: install-sh posix compliance
Date: Thu, 27 Jun 2002 00:57:39 -0700 (PDT)

> From: Alexandre Duret-Lutz <address@hidden>
> Date: Wed, 26 Jun 2002 18:44:45 +0200

>  Clint>   if [ -f $src -o -d $src ]
>  Clint> This is not strictly POSIX-conformant.  
> 
> Damn!  Are they removing things between revisions?

No, this conformance issue has been in the standard for a decade.  The
problem is that different versions of the "test" command assign
different priorities to the -o and -a operators, so they're not
portable (and POSIX does not standardize them).  This issue is covered
in the Autoconf manual.

I installed the following patch to the Autoconf sources, to fix this
issue along with some more minor POSIX portability issues that I
noticed at the same time.

2002-06-27  Paul Eggert  <address@hidden>

        * config/install-sh: Quote $src.  Prefer || to test's -o option,
        as per "Limitations of Builtins".
        * tests/atspecific.m4 (AT_CHECK_ENV): Likewise, for && vs test -a.
        * tests/semantics.at (AC_C_BIGENDIAN): Likewise.

        * tests/mktests.sh: Use grep instead of fgrep, as per
        "Limitations of Builtins".  This substitution is safe, since
        the patterns cannot contain grep metacharacters.

Index: config/install-sh
===================================================================
RCS file: /cvsroot/autoconf/autoconf/config/install-sh,v
retrieving revision 1.1
diff -p -u -r1.1 install-sh
--- config/install-sh   22 May 2001 14:43:50 -0000      1.1
+++ config/install-sh   27 Jun 2002 07:45:29 -0000
@@ -128,7 +128,7 @@ else
 # might cause directories to be created, which would be especially bad 
 # if $src (and thus $dsttmp) contains '*'.
 
-       if [ -f $src -o -d $src ]
+       if [ -f "$src" ] || [ -d "$src" ]
        then
                :
        else
Index: tests/atspecific.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/tests/atspecific.m4,v
retrieving revision 1.70
diff -p -u -r1.70 atspecific.m4
--- tests/atspecific.m4 29 May 2002 22:29:26 -0000      1.70
+++ tests/atspecific.m4 27 Jun 2002 07:45:30 -0000
@@ -201,11 +201,11 @@ m4_define([AT_CHECK_CONFIGURE],
 # me tests might exit prematurely when they find a problem, in
 # which case `env-after' is probably missing.  Don't check it then.
 m4_define([AT_CHECK_ENV],
-[if test -f state-env.before -a -f state-env.after; then
+[if test -f state-env.before && test -f state-env.after; then
   mv -f state-env.before expout
   AT_CHECK([cat state-env.after], 0, expout)
 fi
-if test -f state-ls.before -a -f state-ls.after; then
+if test -f state-ls.before && test -f state-ls.after; then
   mv -f state-ls.before expout
   AT_CHECK([cat state-ls.after], 0, expout)
 fi
Index: tests/mktests.sh
===================================================================
RCS file: /cvsroot/autoconf/autoconf/tests/mktests.sh,v
retrieving revision 1.27
diff -p -u -r1.27 mktests.sh
--- tests/mktests.sh    7 Jun 2002 09:50:32 -0000       1.27
+++ tests/mktests.sh    27 Jun 2002 07:45:30 -0000
@@ -233,14 +233,14 @@ MK_EOF
 
     echo "# Modern macros."
     for macro in `cat acdefuns`; do
-      if fgrep "$macro" requires >/dev/null 2>&1; then :; else
+      if grep "$macro" requires >/dev/null 2>&1; then :; else
        echo "AT_CHECK_MACRO([$macro])"
       fi
     done
     echo
     echo "# Obsolete macros."
     for macro in `cat audefuns`; do
-      if fgrep "$macro" requires >/dev/null 2>&1; then :; else
+      if grep "$macro" requires >/dev/null 2>&1; then :; else
        echo "AT_CHECK_AU_MACRO([$macro])"
       fi
     done
@@ -249,7 +249,7 @@ MK_EOF
   # In one atomic step so that if something above fails, the trap
   # preserves the old version of the file.  If there is nothing to
   # check, output /rien du tout/[1].
-  if fgrep AT_CHECK ac$base.tat >/dev/null 2>&1; then
+  if grep AT_CHECK ac$base.tat >/dev/null 2>&1; then
     mv ac$base.tat ac$base.at
   else
     rm -f ac$base.tat ac$base.at
Index: tests/semantics.at
===================================================================
RCS file: /cvsroot/autoconf/autoconf/tests/semantics.at,v
retrieving revision 1.38
diff -p -u -r1.38 semantics.at
--- tests/semantics.at  20 Apr 2002 06:09:02 -0000      1.38
+++ tests/semantics.at  27 Jun 2002 07:45:30 -0000
@@ -353,11 +353,11 @@ _AT_CHECK_AC_MACRO(
   [cross_compiling=yes
    AC_C_BIGENDIAN([ac_endian=big],[ac_endian=little],[ac_endian=unknown])
    ac_prevendian=`cat at-endian`
-   # Chech we have found the same result as in the previous run
+   # Check that we have found the same result as in the previous run
    # or unknown (because the cross-compiling check is allowed to fail;
    # although it might be interesting to suppress this comparison, just
    # to know on which system it fails if it ever does).
-   if test $ac_endian != $ac_prevendian -a $ac_endian != unknown; then
+   if test $ac_endian != $ac_prevendian && test $ac_endian != unknown; then
      AC_MSG_ERROR([unexpected endianness: first run found '$ac_prevendian' but 
second run found '$ac_endian'])
    fi
 ])




reply via email to

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