[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Finish making zsh Bourne-compatible
From: |
Noah Misch |
Subject: |
Finish making zsh Bourne-compatible |
Date: |
Wed, 23 Jun 2004 21:02:33 -0700 |
User-agent: |
Mutt/1.5.6i |
This patch against Autoconf CVS HEAD adds to the series of commands m4sh
programs use to place zsh in a Bourne-compatible mode. When placed in
sh-compatible mode via ``emulate sh'' or invocation under the name ``sh'', zsh
enables its GLOB_SUBST option, which causes it to make very strange choices
about when to perform quote removal of backslashes. Consider this:
$ cat >quote.sh
a='\\\\\\\\'
b="`echo '\\\\\\\\'`"
c=`echo '\\\\\\\\'`
echo "$a" $a "$b" $b "$c" $c
^D
$ bash quote.sh
\\\\\\\\ \\\\\\\\ \\\\ \\\\ \\\\ \\\\
$ zsh quote.sh quote.sh
\\\\ \\\\ \ \ \ \
$ sh quote.sh # sh is zsh; GLOB_SUBST set implicitly
\\\\\\\\ \\\\ \\\\ \\ \\ \
$ sh -o NO_GLOB_SUBST quote.sh # sh is zsh
\\\\\\\\ \\\\\\\\ \\\\ \\\\ \\\\ \\\\
$ uname -s -r -p -m
SunOS 5.7 sun4u sparc
$ sh quote.sh
\\\\ \\\\ \ \ \ \
Autoconf has been using zsh in the third style on systems with /bin/sh as zsh
(Mac OS X 10.0, 10.1), and this patch effectively makes it use the fourth style.
I observed this behavior while debugging a failure in the libtool test suite on
Mac OS X 10.1. This patch fixes many libtool tests on that platform. Though
libtool was already setting this shell option correctly in some places, certain
declarations (e.g. lt_cv_sys_global_symbol_to_c_name_address) in libtool.m4 were
initialized in the configure script before the first such setopt. Since this
makes all configure.in scripts more portable, I thought it belonged in m4sh, at
the top of every configure script, with the other zsh compatibility settings.
I welcome your feedback. I tested this change on a Fedora Core 1 system and all
Autoconf tests continue to pass. I really cannot run the Autoconf test suite on
Mac OS X with zsh, though. It could take _weeks_. I will post a demonstration
of the improved libtool test suite behavior with a forthcoming patch to
address@hidden, though.
On a related note, I collected enough information on quote removal behaviors in
various shells to add a section documenting them to the the Portable Shell
section of the Autoconf manual. Would that interest folks?
2004-06-23 Noah Misch <address@hidden>
* lib/m4sugar/m4sh.m4 (_AS_BOURNE_COMPATIBLE): If the shell is
zsh, disable GLOB_SUBST to avoid backslash handling problems.
Index: lib/m4sugar/m4sh.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/m4sugar/m4sh.m4,v
retrieving revision 1.115
diff -u -r1.115 m4sh.m4
--- lib/m4sugar/m4sh.m4 3 May 2004 03:49:22 -0000 1.115
+++ lib/m4sugar/m4sh.m4 23 Jun 2004 22:47:29 -0000
@@ -161,6 +161,7 @@
[#] Zsh 3.x and 4.x performs word splitting on ${1+"address@hidden"}, which
# is contrary to our usage. Disable this feature.
alias -g '${1+"address@hidden"}'='"address@hidden"'
+ setopt NO_GLOB_SUBST
elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
set -o posix
fi
- Finish making zsh Bourne-compatible,
Noah Misch <=