aboutsummaryrefslogtreecommitdiff
path: root/repo.sh
blob: 7d81867c590db537098d1409a9e8ae3bd9cd7331 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/sh
set -eu

f() {
	set -e
	bad-command
	unreachable
	return 0
}

f && echo 'Executed, but shoult not'

if f; then
	echo 'Also executed, but should not'
fi

f || echo 'Not executed, but should be'

if ! f; then
	echo 'Also not executed, but should be'
fi

set -x
set +e
f
STATUS=$?
set -e
if [ "$STATUS" != 0 ]; then
	echo 'Only one that is executed when it should be'
fi

f
echo 'This is *actually* unreachable'