1# builtins with exit status inverted 2 3( true ) 4echo $? 5( ! true ) 6echo $? 7 8( false ) 9echo $? 10( ! false ) 11echo $? 12 13# inverting shouldn't affect exit 14(exit 42) 15echo $? 16 17( ! exit 42 ) 18echo $? 19 20# commands requiring an exec with exit status inverted -- broken in bash-2.04 21 22( ls > /dev/null 2>&1 ) 23echo $? 24( ! ls > /dev/null 2>&1 ) 25echo $? 26 27touch /tmp/notwrite 28chmod 400 /tmp/notwrite 29 30# make sure redirection failures in commands whose exit status is inverted 31# are handled correctly 32 33( ls > /tmp/notwrite ) 2>/dev/null 34echo $? 35 36( ! ls > /tmp/notwrite ) 2>/dev/null 37echo $? 38 39# now add exit traps, true and false for commands with and without exit 40# status inversion 41 42(trap 'false' 0 ; ! ls > /tmp/notwrite ) 2>/dev/null 43echo $? 44 45(trap 'false' 0 ; ls > /tmp/notwrite ) 2>/dev/null 46echo $? 47 48(trap 'true' 0 ; ! ls > /tmp/notwrite ) 2>/dev/null 49echo $? 50 51(trap 'true' 0 ; ls > /tmp/notwrite ) 2>/dev/null 52echo $? 53 54rm -f /tmp/notwrite 55