bug-autoconf
[Top][All Lists]
Advanced

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

[PATCH] Dealing with read-only variables


From: Ludovic Courtès
Subject: [PATCH] Dealing with read-only variables
Date: Fri, 4 Jun 2004 13:43:44 +0200
User-agent: Mutt/1.5.4i [Guile enabled]

Hi,

Some news regarding the `unset' issue with read-only variables when
using SGI's /bin/sh on IRIX 6.5 (see below).  According to their manual
[1], `sh' supports read-only variables through the `readonly' builtin
command and such variables cannot be unset.  From my experience, trying
to unset a read-only variable from within a script just makes it stop.
Also, by default, it seems that the `ENV' variable is read-only.

So I came up with the following workaround: use the `readonly' or
`readonly -p' output and grep it in order to known whether a given
variable is read-only.  Unset it iff it is _not_ read-only (or none of
`readonly VAR', `readonly' and `readonly -p' works).

The attached patch applies to `lib/m4sugar/m4sh.m4' (Autoconf 2.59).  I
did not add an `AS_READONLY_VAR' test to `AS_UNSET' since this is
probably not useful for variables which are only used from within the
script.  I tested it with Bash 2.05, Tru64 5.1's /bin/sh, and HP-UX
11.11's /bin/sh (couldn't test it with IRIX's /bin/sh though).

Side note: Bash 2.05 seems to be buggy in that `ENV' does not show up in
the output of `readonly -p' if one executes `readonly ENV' _after_ it's
been defined (although `ENV' actually is read-only, ie. `unset ENV'
complains).  However, `ENV' does show up in the `readonly -p' output if
it has been defined as `readonly ENV=x'...

Thanks,
Ludovic.

[1] 
http://techpubs.sgi.com/library/tpl/cgi-bin/getdoc.cgi?coll=0650&db=man&fname=/usr/share/catman/u_man/cat1/sh.z&srch=sh

2 days, one hour, one minute, 59 seconds ago, 
Ludovic Courtès wrote:
> Hi,
> 
> I'm forwarding this message here since it may be more relevant to post
> it here.
> 
> Thanks,
> Ludovic.
> 
> -------------------[ Forwarded from Ludovic Courtès ]-------------------
> 
> From: Ludovic Courtès <address@hidden>
> To: address@hidden
> Date: Fri, 28 May 2004 10:30:45 +0200
> Subject: `unset ENV' and `AC_CHECK_LIB' on IRIX
> 
> Hi,
> 
> I got into troubles when running an Autoconf 2.59 generated `configure'
> script on an IRIX64 6.2 machine.
> 
> The first problem I had is that I was unable to run `configure' and
> `config.status' as is.  Both scripts contain the following line:
> 
>   # Work around bugs in pre-3.0 UWIN ksh.
>   $as_unset ENV MAIL MAILPATH
> 
> On IRIX (whose `sh' does support `unset'), this causes the script to
> abort with the following error message:
> 
>   configure[35]: ENV: readonly
> 
> (35 being the number of the line where the `unset' occurs).  Is there a
> way to work around this problem?
> 
> 
> The second problem I had was when checking for function `main' in some
> libraries, like:
> 
>   AC_CHECK_LIB([ACE], [main],
>              [LIBS="-lACE $LIBS"],
>                [AC_MSG_ERROR([Could not find libACE.])])
> 
> (since there are C++ libraries, I cannot check for actual function name
> such as `ACE::init ()' since Autoconf would declare it "as is" which
> won't work).  SGI CC C++ compiler produces an error with a message like:
> 
>   function "main" may not be called or have its address taken
> 
> Compaq's CXX outputs a similar message except that it only considers it
> as a warning.  With SGI CC, this causes `configure' to think that the
> library was not found.  Using `CHECK_LIB' with an empty function name
> doesn't work.  So, again, what would be the best solution to work around
> this problem?
> 
> Thanks,
> Ludovic.
> 
> 
> _______________________________________________
> Autoconf mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/autoconf
> 
> ----------------------[ End of forwarded message ]----------------------
> 
> 

Attachment: m4sh.m4.unset.diff
Description: Text document


reply via email to

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