bug-standards
[Top][All Lists]
Advanced

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

Re: POSIXLY_CORRECT not correctly unset in getopt.m4?


From: Eric Blake
Subject: Re: POSIXLY_CORRECT not correctly unset in getopt.m4?
Date: Tue, 07 Sep 2010 14:13:49 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.8) Gecko/20100806 Fedora/3.1.2-1.fc13 Mnenhy/0.8.3 Thunderbird/3.1.2

On 09/07/2010 02:09 PM, Bruno Haible wrote:
   $ env | grep POSIXLY_CORRECT
   POSIXLY_CORRECT=1
   $ echo ${POSIXLY_CORRECT+set}

Any other ideas for portable ways of detecting whether a shell variable
is currently local-only or exported?

'printenv' does not exist on Solaris.

But 'awk' is among the list of portable programs. This should work:

   if test `awk 'BEGIN { print ENVIRON["POSIXLY_CORRECT"] }'<  /dev/null | wc 
-c` = 1; then
     : # POSIXLY_CORRECT is not exported
   else
     : # POSIXLY_CORRECT is exported
   fi

Thanks for the tip! With that, I can come up with a more concise awk script, given that hint, and awk is already on the GCS approved list. (Still, it would be nice to add env.) POSIX guarantees that awk supplies ENVIRON; are we assuming that this is reasonable portable to all the old-and-crusty vendor implementations out there, since the autoconf manual doesn't state otherwise?

--
Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org



reply via email to

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