[Top][All Lists]

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

Re: Fix `set -o posix' again

From: Ralf Wildenhues
Subject: Re: Fix `set -o posix' again
Date: Sun, 12 Feb 2006 12:11:15 +0100
User-agent: Mutt/1.5.9i

Hi Paul, Bruce,

* Bruce Korb wrote on Sat, Feb 11, 2006 at 05:11:50PM CET:
> Paul Eggert wrote:
> >
> >How about this idea instead?
> >
> >for i in `(set -o) 2>/dev/null`; do
> >  case $i in
> >  posix) set -o posix;;
> >  esac
> >done
> Clever.

Yes, very nice idea.  Thanks!

> Would it not be easier thus:
> case "`set -o 2>/dev/null`" in

(Side note: the double quotes are not necessary here.)

> *"posix "* ) set -o posix ;;

The format output by `set -o' is unspecified by SUSv3.  So I don't think
one should expect a space after `posix'.  (SUS specifies `set +o'
better, but that is not so portable and it does not have to show unset
flags at all anyway).  I don't think matching just `posix' would hurt,

> esac
> why bother with a loop?  :)

My thought as well.  Both above approach and the following patch work on
the AIX 5.3 system in question, and they also do the right thing on
OpenBSD, and a few other systems' shells.  The patch below is more
efficient for bash.  What do you think?


Index: lib/m4sugar/m4sh.m4
RCS file: /cvsroot/autoconf/autoconf/lib/m4sugar/m4sh.m4,v
retrieving revision 1.156
diff -u -r1.156 m4sh.m4
--- lib/m4sugar/m4sh.m4 21 Jan 2006 09:09:46 -0000      1.156
+++ lib/m4sugar/m4sh.m4 12 Feb 2006 11:01:18 -0000
@@ -169,8 +169,8 @@
   # is contrary to our usage.  Disable this feature.
   alias -g '${1+"address@hidden"}'='"address@hidden"'
   setopt NO_GLOB_SUBST
-elif (set -o posix) >/dev/null 2>&1; then
-  set -o posix
+  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
 BIN_SH=xpg4; export BIN_SH # for Tru64
 DUALCASE=1; export DUALCASE # for MKS sh

reply via email to

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