[removing bug-standards from the CC list]

Paolo Bonzini wrote:
> On 09/07/2010 10:39 PM, Eric Blake wrote:
> >         gl_awk_probe='BEGIN { for (v in ENVIRON)
> >           if (v == "POSIXLY_CORRECT") print "x" }'
> >         case ${POSIXLY_CORRECT:+x}`awk "$gl_awk_probe" </dev/null` in
> >           xx) gl_had_POSIXLY_CORRECT=exported ;;
> >           x)  gl_had_POSIXLY_CORRECT=yes      ;;
> >           *)  gl_had_POSIXLY_CORRECT=         ;;
> >         esac
> 
> Walking all of ENVIRON seems slow.

But it handles an empty exported value correctly:
  export POSIXLY_CORRECT=
has the same semantics as
  export POSIXLY_CORRECT=1

> What about 
> 
>         gl_awk_probe='BEGIN {print !!length(ENVIRON["POSIXLY_CORRECT"])}'
>         case ${POSIXLY_CORRECT:+x}`awk "$gl_awk_probe" </dev/null` in
>           x1) gl_had_POSIXLY_CORRECT=exported ;;
>           x0) gl_had_POSIXLY_CORRECT=yes      ;;
>           *)  gl_had_POSIXLY_CORRECT=         ;;
>         esac
> 
> instead?

It handles an empty exported value as if the variable was not exported.

Bruno

Reply via email to