On 09/07/2010 02:09 PM, Bruno Haible wrote:
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

Maybe the test whether the value of ENVIRON["POSIXLY_CORRECT"] is empty or
non-empty can be moved into the awk script. I'm not very familiar with awk
programming.

Like so:

       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

except that now we're stuck on the issue of finding a portable $AWK that understands ENVIRON.

--
Eric Blake   ebl...@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Reply via email to