--- m4sh.m4.orig Fri Jun 4 10:17:11 2004 +++ m4sh.m4 Fri Jun 4 13:22:29 2004 @@ -155,9 +155,19 @@ DUALCASE=1; export DUALCASE # for MKS sh _AS_UNSET_PREPARE +_AS_READONLY_PREPARE # Work around bugs in pre-3.0 UWIN ksh. -$as_unset ENV MAIL MAILPATH +for as_var in ENV MAIL MAILPATH +do + # Before unsetting a variable, check whether it is read-only. + # Trying to unset a read-only variable with SGI's /bin/sh on IRIX 6.5 + # causes the script to stop (and the `ENV' variable typically is + # read-only). + AS_READONLY_VAR([$as_var], [], + [$as_unset $as_var]) +done + PS1='$ ' PS2='> ' PS4='+ ' @@ -289,6 +299,30 @@ fi ]) +# _AS_READONLY_PREPARE +# ----------------- +# Compute $as_readonly depending on whether the `readonly' builtin is +# available. +m4_defun([_AS_READONLY_PREPARE], +[# Check whether `readonly' is available. +# Most shells (bash, IRIX's /bin/sh, HP-UX 11.11's /bin/sh) have +# `readonly -p' list all read-only variables; however, Tru64's /bin/sh +# does not support `-p'. Fortunately, most shells (each one of the +# above shells, although I couldn't check on IRIX) also list all +# readonly variables when no argument is passed to `readonly'. +as_unused_readonly_var=something ; export as_unused_readonly_var +if readonly as_unused_readonly_var >/dev/null 2>&1 ; then + if readonly | grep "as_unused_readonly_var=" >/dev/null 2>&1; then + as_readonly=readonly + elif readonly -p | grep "as_unused_readonly_var=" >/dev/null 2>&1; then + as_readonly="readonly -p" + else + as_readonly=true + fi +else + as_readonly=true +fi +]) # AS_UNSET(VAR, [VALUE-IF-UNSET-NOT-SUPPORTED = `']) # -------------------------------------------------- @@ -298,6 +332,24 @@ [AS_REQUIRE([_AS_UNSET_PREPARE])dnl $as_unset $1 || test "${$1+set}" != set || { $1=$2; export $1; }]) +# AS_READONLY_VAR(VAR, ACTION-IF-READONLY, ACTION-IF-READWRITE) +# ------------------------------------------------------------- +# If read-only variables are supported, check whether VAR is readonly and +# execute ACTION-IF-READONLY if it is, ACTION-IF-READWRITE otherwise. +# Both Tru64's /bin/sh and GNU bash `readonly' builtins list the read-only +# variables when no argument is given. However, IRIX's /bin/sh manual +# does not mention whether if behaves the same way (`readonly -p' does +# list read-only variables though). +m4_defun([AS_READONLY_VAR], +[AS_REQUIRE([_AS_READONLY_PREPARE])dnl +if $as_readonly | grep "$1=" >/dev/null 2>&1 ; then + : + $2 +else + : + $3 +fi +])