1 #!/bin/bash
2 #
3 # Test set flags, sh flags.
4
5 ### nounset
6 echo "[$unset]"
7 set -o nounset
8 echo "[$unset]"
9 echo end # never reached
10 # stdout: []
11 # status: 1
12 # OK dash status: 2
13
14 ### -u is nounset
15 echo "[$unset]"
16 set -u
17 echo "[$unset]"
18 echo end # never reached
19 # stdout: []
20 # status: 1
21 # OK dash status: 2
22
23 ### reset option with long flag
24 set -o errexit
25 set +o errexit
26 echo "[$unset]"
27 # stdout: []
28 # status: 0
29
30 ### reset option with short flag
31 set -u
32 set +u
33 echo "[$unset]"
34 # stdout: []
35 # status: 0
36
37 ### sh -c
38 $SH -c 'echo hi'
39 # stdout: hi
40 # status: 0