On Friday 8 May 2009, 16:51, Alan McKinnon wrote: > > > 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 > > > > That will output an uncaptured error message if --color is not > > supported. > > which is the desired effect. It causes the if to be false and the grep > options are not enabled (as they are not supported)
It's not the fact that the error message is left free to show on screen that makes the exit status true or false. If the file is sourced from a non-interactive environment, you don't want anything printed (and probably, in this case, neither if it's an interactive session). Capturing stderr does not change the exit status of the pipeline.