Denys Vlasenko | b28d4c3 | 2017-07-25 16:29:36 +0200 | [diff] [blame] | 1 | # check invalid options are rejected |
2 | # bash: in posix mode, aborts if non-interactive; using subshell to avoid that | ||||
3 | (unset -) | ||||
4 | echo $? | ||||
5 | (unset -m a b c) | ||||
6 | echo $? | ||||
7 | |||||
8 | # check funky usage | ||||
9 | unset | ||||
10 | echo $? | ||||
11 | |||||
12 | # check normal usage | ||||
13 | echo ___ | ||||
14 | f=f g=g | ||||
15 | echo $? $f $g | ||||
16 | unset f | ||||
17 | echo $? $f $g | ||||
18 | unset g | ||||
19 | echo $? $f $g | ||||
20 | |||||
21 | echo ___ | ||||
22 | f=f g=g | ||||
23 | echo $? $f $g | ||||
24 | unset f g | ||||
25 | echo $? $f $g | ||||
26 | f=f g=g | ||||
27 | echo $? $f $g | ||||
28 | unset -v f g | ||||
29 | echo $? $f $g | ||||
30 | |||||
31 | # check read only vars | ||||
32 | echo ___ | ||||
33 | f=f g=g | ||||
34 | VAR_RO=1 | ||||
35 | readonly VAR_RO | ||||
36 | (unset VAR_RO) | ||||
37 | echo $? $f $g | ||||
38 | # not testing "do variables survive error halfway through unset" since unset aborts | ||||
39 | # unset f VAR_RO g | ||||
40 | #echo $? $f $g |