my redhat 7.0 system does this bash-2.04$ if ( /bin/true ) ; then echo ok ;fi ok bash-2.04$ if ( ! /bin/true ) ; then echo ok ;fi ok bash-2.04$ if ( /bin/false ) ; then echo ok ;fi bash-2.04$ if ( ! /bin/false ) ; then echo ok ;fi while my redhat 6.2 and solaris systems do this bash$ if ( /bin/true ) ; then echo ok ;fi ok bash$ if ( ! /bin/true ) ; then echo ok ;fi bash$ if ( /bin/false ) ; then echo ok ;fi bash$ if ( ! /bin/false ) ; then echo ok ;fi ok Maybe this isn't a bug. I figured it's probably me who is confused, because I didn't see an update for this. I mean, if it really is *that* broken then scripts all over the world would be breaking... So what am i doing wrong?
It's not a bug - it's a POSIX compliant change in bash 2.x. ( ) gets a separate process space. The right thing to do is keeping everything in the same space: if /bin/true; then echo ok; fi ok if ! /bin/true; then echo ok; fi if /bin/false; then echo ok; fi if ! /bin/false; then echo ok; fi ok or to use brackets (if [ ! /bin/true ]; then echo ok; fi).