forked from gentoo/gentoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
estack_evar.sh
executable file
·99 lines (88 loc) · 1.38 KB
/
estack_evar.sh
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
#!/bin/bash
# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
source tests-common.sh
inherit estack
tbegin "simple push/pop"
VAR=1
evar_push VAR
pu=$?
VAR=2
evar_pop
po=$?
[[ ${pu}${po}${VAR} == "001" ]]
tend $?
tbegin "unset push/pop"
unset VAR
evar_push VAR
pu=$?
VAR=2
evar_pop
po=$?
[[ ${pu}${po}${VAR+set} == "00" ]]
tend $?
tbegin "empty push/pop"
VAR=
evar_push VAR
pu=$?
VAR=2
evar_pop
po=$?
[[ ${pu}${po}${VAR+set}${VAR} == "00set" ]]
tend $?
tbegin "export push/pop"
export VAR=exported
evar_push VAR
pu=$?
VAR=2
evar_pop
po=$?
var=$(bash -c 'echo ${VAR}')
[[ ${pu}${po}${var} == "00exported" ]]
tend $?
tbegin "unexport push/pop"
unset VAR
VAR=not-exported
evar_push VAR
pu=$?
VAR=2
evar_pop
po=$?
var=$(bash -c 'echo ${VAR+set}')
[[ ${pu}${po}${VAR}${var} == "00not-exported" ]]
tend $?
tbegin "multi push/pop"
A=a B=b C=c
evar_push A B C
pu=$?
A=A B=B C=C
evar_pop 1
po1=$?
[[ ${A}${B}${C} == "ABc" ]]
po2=$?
evar_pop 2
po3=$?
var=$(bash -c 'echo ${VAR+set}')
[[ ${pu}${po1}${po2}${po3}${A}${B}${C} == "0000abc" ]]
tend $?
tbegin "simple push_set/pop"
VAR=1
evar_push_set VAR 2
pu=$?
[[ ${VAR} == "2" ]]
po1=$?
evar_pop
po2=$?
[[ ${pu}${po1}${po2}${VAR} == "0001" ]]
tend $?
tbegin "unset push_set/pop"
VAR=1
evar_push_set VAR
pu=$?
[[ ${VAR+set} != "set" ]]
po1=$?
evar_pop
po2=$?
[[ ${pu}${po1}${po2}${VAR} == "0001" ]]
tend $?
texit