[Top][All Lists]

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

Re: weird ksh eval behavior

From: Ralf Wildenhues
Subject: Re: weird ksh eval behavior
Date: Fri, 2 Dec 2005 17:13:49 +0100
User-agent: Mutt/1.5.11

* Otto Moerbeek wrote on Thu, Dec 01, 2005 at 11:17:01PM CET:
> On Thu, 1 Dec 2005, Matthias Kilian wrote:
> > On Thu, Dec 01, 2005 at 08:43:31PM +0100, Ralf Wildenhues wrote:
> > > With ash-0.3.8, OpenBSD 3.8 'sh' and 'ksh' PD KSH v5.2.14 99/07/13.2,
> > > 
> > > $ false; eval 'foo=$?'; echo $foo
> > > 0

> > If POSIX mode is enabled by using `set -o posix' or setting
> > POSIXLY_CORRECT, the above command line results in a `1'.

Ah, OK.  We should be trying to set the shell in posix mode anyway.
Now I understand why I never noticed this bug before testing on OpenBSD:
I've always been using pdksh as ksh, not as /bin/sh.  One difference is
that it won't set KSH_VERSION then, thus this snippet expanded from

| # Be Bourne compatible
| if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
|   # ...
| elif test -n "${BASH_VERSION+set}${KSH_VERSION+set}" && (set -o posix) 
>/dev/null 2>&1; then
|   set -o posix
| fi

won't trigger posix mode.  I wonder whether it should try to set posix
mode in any case, or whether we can find out without iff we're dealing
with pdksh without forking?  Suggested patch below.

> I think this is a bug in pdksh. It's a coincidence the posix flag has
> the correct behaviour.

I tend to agree.

Cheers, and thanks,

        * lib/m4sugar/m4sh.m4 (_AS_BOURNE_COMPATIBLE): Try `set -o
        posix' unconditionally, for pdksh in `native sh' emulation.

Index: lib/m4sugar/m4sh.m4
RCS file: /cvsroot/autoconf/autoconf/lib/m4sugar/m4sh.m4,v
retrieving revision 1.151
diff -u -r1.151 m4sh.m4
--- lib/m4sugar/m4sh.m4 6 Sep 2005 15:37:55 -0000       1.151
+++ lib/m4sugar/m4sh.m4 2 Dec 2005 16:04:57 -0000
@@ -169,7 +169,7 @@
   # 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}${KSH_VERSION+set}" && (set -o posix) 
>/dev/null 2>&1; then
+elif (set -o posix) >/dev/null 2>&1; then
   set -o posix
 BIN_SH=xpg4; export BIN_SH # for Tru64

reply via email to

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