]> git.ipfire.org Git - thirdparty/bash.git/blob - tests/exec6.sub
Imported from ../bash-2.05.tar.gz.
[thirdparty/bash.git] / tests / exec6.sub
1 # builtins with exit status inverted
2
3 ( true )
4 echo $?
5 ( ! true )
6 echo $?
7
8 ( false )
9 echo $?
10 ( ! false )
11 echo $?
12
13 # inverting shouldn't affect exit
14 (exit 42)
15 echo $?
16
17 ( ! exit 42 )
18 echo $?
19
20 # commands requiring an exec with exit status inverted -- broken in bash-2.04
21
22 ( ls > /dev/null 2>&1 )
23 echo $?
24 ( ! ls > /dev/null 2>&1 )
25 echo $?
26
27 touch /tmp/notwrite
28 chmod 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
34 echo $?
35
36 ( ! ls > /tmp/notwrite ) 2>/dev/null
37 echo $?
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
43 echo $?
44
45 (trap 'false' 0 ; ls > /tmp/notwrite ) 2>/dev/null
46 echo $?
47
48 (trap 'true' 0 ; ! ls > /tmp/notwrite ) 2>/dev/null
49 echo $?
50
51 (trap 'true' 0 ; ls > /tmp/notwrite ) 2>/dev/null
52 echo $?
53
54 rm -f /tmp/notwrite