Bug 20349

Summary: Not (!) not working ?
Product: [Retired] Red Hat Linux Reporter: Need Real Name <adam>
Component: bashAssignee: Bernhard Rosenkraenzer <bero>
Status: CLOSED NOTABUG QA Contact: David Lawrence <dkl>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2000-11-05 02:14:53 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Need Real Name 2000-11-05 02:14:51 UTC
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?

Comment 1 Bernhard Rosenkraenzer 2000-11-05 09:08:31 UTC
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).