libcdio-devel
[Top][All Lists]
Advanced

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

[Libcdio-devel] problems with sed test


From: Robert William Fuller
Subject: [Libcdio-devel] problems with sed test
Date: Fri, 26 Oct 2012 12:34:59 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.4) Gecko/20120510 Icedove/10.0.4

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

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