bug-autoconf
[Top][All Lists]
Advanced

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

Re: [PATCH] Dealing with read-only variables


From: Paul Eggert
Subject: Re: [PATCH] Dealing with read-only variables
Date: Fri, 04 Jun 2004 13:12:45 -0700
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

Ludovic Courtès <address@hidden> writes:

> From my experience, trying
> to unset a read-only variable from within a script just makes it stop.

Even if it's in a subshell?  What does this do?

if (unset ENV) >/dev/null 2>&1
then echo "can unset ENV"
else echo "cannot unset ENV"
fi

If this prints "cannot unset ENV" I think I'd rather do that than futz
with the "readonly" command.  (E.g. the latest Bash doesn't conform to
POSIX with "readonly -p".)

How about this patch instead?

2004-06-04  Paul Eggert  <address@hidden>

        * lib/m4sugar/m4sh.m4 (_AS_DETECT_BETTER_SHELL): Require
        _AS_UNSET_PREPARE, so that we can use $as_unset directly.
        Don't fail if ENV or BASH_ENV is readonly.
        (AS_SHELL_SANITIZE): Don't fail if ENV, MAIL, MAILPATH, LC_ALL,
        etc. are read only.

Index: lib/m4sugar/m4sh.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/m4sugar/m4sh.m4,v
retrieving revision 1.115
diff -p -u -r1.115 m4sh.m4
--- lib/m4sugar/m4sh.m4 3 May 2004 03:49:22 -0000       1.115
+++ lib/m4sugar/m4sh.m4 4 Jun 2004 20:07:03 -0000
@@ -208,6 +208,7 @@ m4_expand_once([m4_append([_AS_DETECT_SU
 # features.
 m4_defun_once([_AS_DETECT_BETTER_SHELL],
 [m4_wrap([m4_divert_text([M4SH-SANITIZE], [
+AS_REQUIRE([_AS_UNSET_PREPARE])dnl
 if test "x$CONFIG_SHELL" = x; then
   AS_IF([_AS_RUN([_AS_DETECT_REQUIRED_BODY]) 2>/dev/null],
         [as_have_required=yes],
@@ -233,8 +234,9 @@ if test "x$CONFIG_SHELL" = x; then
       done
 
       AS_IF([test "x$CONFIG_SHELL" != x],
-        [AS_UNSET([ENV])
-        AS_UNSET([BASH_ENV])
+        [for as_var in BASH_ENV ENV
+        do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+        done
         export CONFIG_SHELL
         exec "$CONFIG_SHELL" "$as_myself" ${1+"address@hidden"}])
 
@@ -318,7 +320,9 @@ if test ! -f "$as_myself"; then
 fi
 
 # Work around bugs in pre-3.0 UWIN ksh.
-$as_unset ENV MAIL MAILPATH
+for as_var in ENV MAIL MAILPATH
+do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+done
 PS1='$ '
 PS2='> '
 PS4='+ '
@@ -332,7 +336,7 @@ do
   if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
     eval $as_var=C; export $as_var
   else
-    $as_unset $as_var
+    ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
   fi
 done
 




reply via email to

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