Hi Alan, Am Freitag, 8. Mai 2009 schrieb Alan McKinnon: > > Some greps (like BSD one) might not support '--color' option, so "echo > > hello|grep --color=auto l" will return error code, skipping if clause, > > and won't break grep operation by adding an unsupported option.
is this really right? The result of if echo hello|grep --Acolor=auto l >/dev/null 2>&1; then echo hallo; fi is nothing. So the if clause is false although I pieped STDERR to /dev/null. > except that STDERR is combined with STDOUT and sent to /dev/null so the > script will never get it, the if is always true and the entire check is > redundant. Better would be > > if echo hello|grep --color=auto l >/dev/null ; then grep writes to STDERR if an error is occured. The result of if echo hello|grep --Acolor=auto l >/dev/null ; then echo hallo; fi is: grep: Unbekannte Option »--Acolor=auto« Aufruf: grep [OPTION]... MUSTER [DATEI]... »grep --help« gibt Ihnen mehr Informationen. Best regard Christian