Denys Vlasenko | 9fed83a | 2017-08-29 14:35:58 +0200 | [diff] [blame] | 1 | ( |
| 2 | |
Mike Frysinger | d690f68 | 2009-03-30 06:50:54 +0000 | [diff] [blame] | 3 | # check invalid options are rejected |
Denys Vlasenko | b28d4c3 | 2017-07-25 16:29:36 +0200 | [diff] [blame] | 4 | # bash: in posix mode, aborts if non-interactive |
Mike Frysinger | d690f68 | 2009-03-30 06:50:54 +0000 | [diff] [blame] | 5 | unset - |
| 6 | echo $? |
| 7 | unset -m a b c |
| 8 | echo $? |
| 9 | |
| 10 | # check funky usage |
| 11 | unset |
| 12 | echo $? |
| 13 | |
| 14 | # check normal usage |
| 15 | echo ___ |
| 16 | f=f g=g |
| 17 | echo $? $f $g |
| 18 | unset f |
| 19 | echo $? $f $g |
| 20 | unset g |
| 21 | echo $? $f $g |
| 22 | |
| 23 | echo ___ |
| 24 | f=f g=g |
| 25 | echo $? $f $g |
| 26 | unset f g |
| 27 | echo $? $f $g |
| 28 | f=f g=g |
| 29 | echo $? $f $g |
| 30 | unset -v f g |
| 31 | echo $? $f $g |
| 32 | |
| 33 | # check read only vars |
| 34 | echo ___ |
| 35 | f=f g=g |
Denys Vlasenko | b28d4c3 | 2017-07-25 16:29:36 +0200 | [diff] [blame] | 36 | VAR_RO=1 |
| 37 | readonly VAR_RO |
| 38 | unset VAR_RO |
Mike Frysinger | d690f68 | 2009-03-30 06:50:54 +0000 | [diff] [blame] | 39 | echo $? $f $g |
Denys Vlasenko | b28d4c3 | 2017-07-25 16:29:36 +0200 | [diff] [blame] | 40 | unset f VAR_RO g |
Mike Frysinger | d690f68 | 2009-03-30 06:50:54 +0000 | [diff] [blame] | 41 | echo $? $f $g |
Denys Vlasenko | 9fed83a | 2017-08-29 14:35:58 +0200 | [diff] [blame] | 42 | |
| 43 | ) 2>&1 \ |
| 44 | | sed -e 's/ unrecognized option: / invalid option -- /' \ |
| 45 | -e 's/ illegal option -- / invalid option -- /' \ |