summaryrefslogtreecommitdiffstats
path: root/tests/shopt.tests
blob: c31870cf929e480c4c79257e26a087bd98d9f66e (plain)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# let's try an error message first
shopt -z

# first, set up a known environment
shopt -u cdable_vars
shopt -s cdspell
shopt -u checkhash
shopt -u checkwinsize
shopt -s cmdhist
shopt -u dotglob
shopt -u execfail
shopt -s expand_aliases
shopt -u extglob
shopt -u histreedit
shopt -u histappend
shopt -u histverify
shopt -s hostcomplete
shopt -u huponexit
shopt -s interactive_comments
shopt -u lithist
shopt -u mailwarn
shopt -u nocaseglob
shopt -u nullglob
shopt -s promptvars
shopt -u shift_verbose
shopt -s sourcepath
shopt -u xpg_echo

# Now, start checking the output
builtin printf -- "--\n"
shopt -p	# list 'em all
builtin printf -- "--\n"
# test specific variables
shopt -p huponexit
shopt -p checkwinsize
shopt -p sourcepath

builtin printf -- "--\n"
shopt -s -p
builtin printf -- "--\n"
shopt -u -p
builtin printf -- "--\n"
shopt -u

# Now set up another known environment
set +o allexport
set -o braceexpand
set +o errexit
set -o hashall
set -o histexpand
set +o keyword
set -o monitor
set +o noclobber
set +o noexec
set +o noglob
set +o notify
set +o nounset
set +o onecmd
set +o physical
set -o privileged
set +o verbose
set +o xtrace
set -o history
set +o ignoreeof
set -o interactive-comments
set +o posix
set -o emacs
set +o vi

# list 'em all
builtin printf -- "--\n"
shopt -o -p

builtin printf -- "--\n"
set -o
builtin printf -- "--\n"
set +o

# test specific variables
builtin printf -- "--\n"
shopt -p -o history
shopt -p -o verbose

builtin printf -- "--\n"
shopt -s -p -o
builtin printf -- "--\n"
shopt -u -p -o
builtin printf -- "--\n"
shopt -u -o

# errors
builtin printf -- "--\n"
shopt -p xyz1
shopt -o -p xyz1

${THIS_SH} ./shopt1.sub

# test whether or not temporary variable assignments that manipulate posix
# mode restore the previous state or the default non-posix state
${THIS_SH} -c 'shopt -s expand_aliases ; shopt expand_aliases ; POSIXLY_CORRECT=y true ; shopt expand_aliases'