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/