Consider the following code in configure.ac:

SED_EXTENDED_RE_FLAG='-r'
result=$(echo 'define' | $ac_path_SED -r -e 's/^define/foo/' 2>/dev/null)
if [[ $? -ne 0 ]] ; then
result=$(echo 'define' | $ac_path_SED -r -E 's/^define/foo/' 2>/dev/null)
   if [[ $? -ne 0 ]] ; then
     SED_EXTENDED_RE_FLAG='-E'
   else
AC_MSG_WARN([Don't have SED that understand extended RE's. Some minor compilation issues may fail.])
     SED_EXTENDED_RE_FLAG=''
   fi
fi

Now consider that the second test ought to be [[ $? -eq 0 ]] because we're checking to see if the -E flag works. BUT, the second invocation of sed will never succeed because the -r and the -E flag are mutually exclusive. One exists on one platform and not the other. So the second run of sed really ought to be "-E -e" not "-r -E". (I suspect that someone accidentally changed the wrong option during a copy and paste of the prior invocation when they wrote this code originally.)

Supposing we make all these changes, this still won't work on MacOS because it has ac_path_SED set to /usr/X11/bin/gsed which does not exist. We should use the SED variable rather than ac_path_SED. So when all is sed and done, it should look like this:

SED_EXTENDED_RE_FLAG='-r'
result=$(echo 'define' | $SED -r -e 's/^define/foo/' 2>/dev/null)
if [[ $? -ne 0 ]] ; then
    result=$(echo 'define' | $SED -E -e 's/^define/foo/' 2>/dev/null)
    if [[ $? -eq 0 ]] ; then
        SED_EXTENDED_RE_FLAG='-E'
    else
AC_MSG_WARN([Don't have SED that understand extended RE's. Some minor compilation issues may fail.])
        SED_EXTENDED_RE_FLAG=''
    fi
fi

Thoughts?

Rob

Reply via email to