[ovs-dev] [PATCH 1/2] autoconf: Don't die on grep error.
jesse at nicira.com
Wed Nov 3 01:02:41 UTC 2010
On Tue, Nov 2, 2010 at 5:05 PM, Ben Pfaff <blp at nicira.com> wrote:
> On Tue, Nov 02, 2010 at 04:53:09PM -0700, Jesse Gross wrote:
>> The most likely cause of an error when grepping for a compatibility
>> string is that the file doesn't exist. Since this can be a valid
>> result when files are added in later versions, we shouldn't kill
>> the build. Instead, note that the file doesn't exist but otherwise
>> treat it as if the string was not found.
> It's good to tolerate a missing file, but wouldn't it be better to do so
> by checking for it beforehand with "test -r", instead of assuming that
> any error from "grep" means a missing file?
Probably. I changed it to this:
Author: Jesse Gross <jesse at nicira.com>
Date: Tue Nov 2 16:00:16 2010 -0700
autoconf: Tolerate missing file when grepping.
Currently we die when grepping for compatibility strings if the
file does not exist. Since this can be a valid situation when
files are added in later versions, we shouldn't kill the build.
Instead, note that the file doesn't exist but otherwise treat it
as if the string was not found.
diff --git a/acinclude.m4 b/acinclude.m4
index f1322fa..0af7fd0 100644
@@ -108,21 +108,26 @@ dnl
dnl Greps FILE for REGEX. If it matches, runs IF-MATCH, otherwise IF-NO-MATCH.
AC_MSG_CHECKING([whether $2 matches in $1])
- grep '$2' $1 >/dev/null 2>&1
- case $status in
- AC_MSG_ERROR([grep exited with status $status])
+ if test -f $1; then
+ grep '$2' $1 >/dev/null 2>&1
+ case $status in
+ AC_MSG_ERROR([grep exited with status $status])
+ AC_MSG_RESULT([file not found])
More information about the dev