]> git.ipfire.org Git - thirdparty/bash.git/blame - tests/exec6.sub
Bash-5.2 patch 26: fix typo when specifying readline's custom color prefix
[thirdparty/bash.git] / tests / exec6.sub
CommitLineData
8868edaf
CR
1# This program is free software: you can redistribute it and/or modify
2# it under the terms of the GNU General Public License as published by
3# the Free Software Foundation, either version 3 of the License, or
4# (at your option) any later version.
5#
6# This program is distributed in the hope that it will be useful,
7# but WITHOUT ANY WARRANTY; without even the implied warranty of
8# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9# GNU General Public License for more details.
10#
11# You should have received a copy of the GNU General Public License
12# along with this program. If not, see <http://www.gnu.org/licenses/>.
13#
28ef6c31
JA
14# builtins with exit status inverted
15
16( true )
17echo $?
18( ! true )
19echo $?
20
21( false )
22echo $?
23( ! false )
24echo $?
25
26# inverting shouldn't affect exit
27(exit 42)
28echo $?
29
30( ! exit 42 )
31echo $?
32
33# commands requiring an exec with exit status inverted -- broken in bash-2.04
34
35( ls > /dev/null 2>&1 )
36echo $?
37( ! ls > /dev/null 2>&1 )
38echo $?
39
40touch /tmp/notwrite
41chmod 400 /tmp/notwrite
42
43# make sure redirection failures in commands whose exit status is inverted
44# are handled correctly
45
46( ls > /tmp/notwrite ) 2>/dev/null
47echo $?
48
49( ! ls > /tmp/notwrite ) 2>/dev/null
50echo $?
51
52# now add exit traps, true and false for commands with and without exit
53# status inversion
54
55(trap 'false' 0 ; ! ls > /tmp/notwrite ) 2>/dev/null
56echo $?
57
58(trap 'false' 0 ; ls > /tmp/notwrite ) 2>/dev/null
59echo $?
60
61(trap 'true' 0 ; ! ls > /tmp/notwrite ) 2>/dev/null
62echo $?
63
64(trap 'true' 0 ; ls > /tmp/notwrite ) 2>/dev/null
65echo $?
66
67rm -f /tmp/notwrite