This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Make dg-extract-results.sh explicitly treat .{sum,log} files as text


On 12/15/2014 11:00 PM, Sergio Durigan Junior wrote:
> +# 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
> +

That assumes all greps output "unrecognized option" on
unrecognized options.  I don't think that can be counted on being
portable?  ISTM reversing the logic of the test would be better.
IOW, test that --text actually works.  Something like this perhaps:

# If grep supports the '--text' option, use it.
GREP_TEXT_OPT=""
if echo foo | grep --text foo > /dev/null 2>&1 ; then
  GREP_TEXT_OPT="--text"
fi

Thanks,
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]