summaryrefslogtreecommitdiff
path: root/eclass/tests/estack_eshopts.sh
blob: 28346c65ec13cf98bd4261f2d002197d9498ccd2 (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
#!/bin/bash
# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

source tests-common.sh

inherit estack

test-it() {
	local s0 s1 s2

	tbegin "push/pop '$*'"
	s0=$(shopt -p)
	t eshopts_push $*
	s1=$(shopt -p)
	t eshopts_pop
	s2=$(shopt -p)
	[[ ${s0} == "${s2}" ]] && \
	[[ ${s1} == *"shopt $*"* ]]
	tend $?
}

# should handle bug #395025
for arg in nullglob dotglob extglob ; do
	for flag in s u ; do
		test-it -${flag} ${arg}
	done
done

# test 'set' options
set -f
tbegin "set +f"
s0=$-
t eshopts_push +f
s1=$-
t eshopts_pop
s2=$-
[[ ${s0} == "${s2}" ]] &&
[[ ${s1} != *f* ]]
tend $?

set +f
tbegin "set -f"
s0=$-
t eshopts_push -f
s1=$-
t eshopts_pop
s2=$-
[[ ${s0} == "${s2}" ]] &&
[[ ${s1} == *f* ]]
tend $?

tbegin "multi push/pop"
s0=$(shopt -p)
t eshopts_push -s dotglob
t eshopts_push -u dotglob
t eshopts_push -s extglob
t eshopts_push -u dotglob
t eshopts_push -s dotglob
t eshopts_pop
t eshopts_pop
t eshopts_pop
t eshopts_pop
t eshopts_pop
s1=$(shopt -p)
[[ ${s0} == "${s1}" ]]
tend $?

texit