This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Make dg-extract-results.sh explicitly treat .{sum,log} files as text
- From: Sergio Durigan Junior <sergiodj at redhat dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Pedro Alves <palves at redhat dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 16 Dec 2014 11:37:59 -0500
- Subject: Re: [PATCH] Make dg-extract-results.sh explicitly treat .{sum,log} files as text
- Authentication-results: sourceware.org; auth=none
- References: <1418683023-26087-1-git-send-email-sergiodj at redhat dot com> <20141215224608 dot GX1667 at tucnak dot redhat dot com> <87lhm85xhy dot fsf at redhat dot com> <548FFD21 dot 1030703 at redhat dot com> <20141216100232 dot GY1667 at tucnak dot redhat dot com>
On Tuesday, December 16 2014, Jakub Jelinek wrote:
> On Tue, Dec 16, 2014 at 09:36:33AM +0000, Pedro Alves wrote:
>> 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
>
> Even better include some non-text bytes around the foo string in the input you feed to grep.
> Also, perhaps better would be to use a GREP variable, initialized to
> GREP=grep
> or
> GREP="grep --text"
> and just invoke $GREP.
Hm, right. Thank you Pedro and Jakub for the comments. I will work on
another version of the patch.
--
Sergio
GPG key ID: 0x65FC5E36
Please send encrypted e-mail if possible
http://sergiodj.net/