On Monday, December 15 2014, Jakub Jelinek wrote: > I'd be surprised if all versions of grep supported --text option (e.g. POSIX > doesn't mention the -a nor --text options), guess > you'd need to check for that first (early in the script) and add it only if > it works.
Thanks for the review, Jakub. Right, it makes sense to check that indeed. Take a look at the attached patch please. > Also, supposedly the options should come before the regexp and > list of files. Right, fixed. > Why isn't the python version used in your case btw? Because GDB has not yet merged the new Python version into our codebase. I am working on it now, too. -- Sergio GPG key ID: 0x65FC5E36 Please send encrypted e-mail if possible http://sergiodj.net/ diff --git a/contrib/dg-extract-results.sh b/contrib/dg-extract-results.sh index a83c8e8..ebf93bf 100755 --- a/contrib/dg-extract-results.sh +++ b/contrib/dg-extract-results.sh @@ -127,13 +127,20 @@ do done test $ERROR -eq 0 || exit 1 +# Check if grep supports the '--text' option. + +GREP_TEXT_OPT="--text" +if grep --text 2>&1 | grep "unrecognized option" > /dev/null 2>&1 ; then + GREP_TEXT_OPT="" +fi + if [ -z "$TOOL" ]; then # If no tool was specified, all specified summary files must be for # the same tool. - CNT=`grep '=== .* tests ===' $SUM_FILES | $AWK '{ print $3 }' | sort -u | wc -l` + CNT=`grep $GREP_TEXT_OPT '=== .* tests ===' $SUM_FILES | $AWK '{ print $3 }' | sort -u | wc -l` if [ $CNT -eq 1 ]; then - TOOL=`grep '=== .* tests ===' $FIRST_SUM | $AWK '{ print $2 }'` + TOOL=`grep $GREP_TEXT_OPT '=== .* tests ===' $FIRST_SUM | $AWK '{ print $2 }'` else msg "${PROGNAME}: sum files are for multiple tools, specify a tool" msg "" @@ -144,7 +151,7 @@ else # Ignore the specified summary files that are not for this tool. This # should keep the relevant files in the same order. - SUM_FILES=`grep -l "=== $TOOL" $SUM_FILES` + SUM_FILES=`grep $GREP_TEXT_OPT -l "=== $TOOL" $SUM_FILES` if test -z "$SUM_FILES" ; then msg "${PROGNAME}: none of the specified files are results for $TOOL" exit 1 @@ -233,7 +240,7 @@ else VARIANTS="" for VAR in $VARS do - grep "Running target $VAR" $SUM_FILES > /dev/null && VARIANTS="$VARIANTS $VAR" + grep $GREP_TEXT_OPT "Running target $VAR" $SUM_FILES > /dev/null && VARIANTS="$VARIANTS $VAR" done fi