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