1 |
## oils_failures_allowed: 3
|
2 |
|
3 |
|
4 |
shopt -s ysh:upgrade
|
5 |
|
6 |
pp test_ (type(ENV))
|
7 |
#pp test_ (ENV)
|
8 |
|
9 |
# Set by the spec test harness
|
10 |
|
11 |
if (ENV.SH ~~ '*osh') {
|
12 |
echo ok
|
13 |
}
|
14 |
|
15 |
#echo SH=$[ENV.SH]
|
16 |
|
17 |
## STDOUT:
|
18 |
(Str) "Dict"
|
19 |
ok
|
20 |
## END
|
21 |
|
22 |
|
23 |
|
24 |
osh=$SH # this file is run by OSH
|
25 |
|
26 |
case $osh in
|
27 |
*osh)
|
28 |
echo 'OSH ok'
|
29 |
;;
|
30 |
esac
|
31 |
|
32 |
var ysh = osh.replace('osh', 'ysh')
|
33 |
|
34 |
# NOT exported
|
35 |
$ysh -c 'echo sh=$[getVar("SH")]'
|
36 |
|
37 |
## STDOUT:
|
38 |
OSH ok
|
39 |
sh=null
|
40 |
## END
|
41 |
|
42 |
|
43 |
shopt -s ysh:upgrade
|
44 |
|
45 |
_A=a _B=b env | grep '^_' | sort
|
46 |
|
47 |
## STDOUT:
|
48 |
_A=a
|
49 |
_B=b
|
50 |
## END
|
51 |
|
52 |
|
53 |
shopt -s ysh:upgrade
|
54 |
|
55 |
setglobal ENV.PYTHONPATH = 'foo'
|
56 |
|
57 |
#pp test_ (ENV)
|
58 |
#export PYTHONPATH=zz
|
59 |
|
60 |
# execute POSIX shell
|
61 |
sh -c 'echo pythonpath=$PYTHONPATH'
|
62 |
|
63 |
## STDOUT:
|
64 |
pythonpath=foo
|
65 |
## END
|
66 |
|
67 |
|
68 |
shopt -s ysh:all
|
69 |
|
70 |
setglobal ENV.ZZ = 'setglobal'
|
71 |
|
72 |
# execute POSIX shell
|
73 |
sh -c 'echo ZZ=$ZZ'
|
74 |
|
75 |
export ZZ='export' # fails
|
76 |
|
77 |
sh -c 'echo ZZ=$ZZ' # not reached
|
78 |
|
79 |
## status: 1
|
80 |
## STDOUT:
|
81 |
ZZ=setglobal
|
82 |
## END
|
83 |
|
84 |
|
85 |
shopt -s ysh:upgrade
|
86 |
|
87 |
export ZZ='export' # fails
|
88 |
|
89 |
sh -c 'echo ZZ=$ZZ' # not reached
|
90 |
|
91 |
setglobal ENV.ZZ = 'setglobal' # this takes precedence
|
92 |
|
93 |
# execute POSIX shell
|
94 |
sh -c 'echo ZZ=$ZZ'
|
95 |
|
96 |
## STDOUT:
|
97 |
ZZ=export
|
98 |
ZZ=setglobal
|
99 |
## END
|
100 |
|
101 |
|
102 |
|
103 |
shopt -s ysh:upgrade
|
104 |
|
105 |
setglobal ENV.PS4 = '%%% '
|
106 |
|
107 |
$[ENV.SH] -c 'set -x; echo 1; echo 2'
|
108 |
|
109 |
## STDOUT:
|
110 |
TODO
|
111 |
## END
|
112 |
|
113 |
|
114 |
|
115 |
shopt -s ysh:upgrade
|
116 |
|
117 |
setglobal ENV.PS4 = '%%% '
|
118 |
|
119 |
use $[ENV.REPO_ROOT]/spec/testdata/module2/env.ysh
|
120 |
|
121 |
## STDOUT:
|
122 |
env.ysh
|
123 |
OSH ok
|
124 |
## END
|
125 |
|
126 |
|
127 |
|
128 |
|
129 |
HOME=zz-osh
|
130 |
echo ~/src
|
131 |
|
132 |
shopt --set ysh:upgrade
|
133 |
|
134 |
setvar ENV.HOME = 'ysh-zz'
|
135 |
|
136 |
# TODO: this should consult ENV.HOME
|
137 |
echo ~/src
|
138 |
|
139 |
# not set by spec test framework
|
140 |
#echo $[ENV.HOME]
|
141 |
|
142 |
## STDOUT:
|
143 |
zz-osh/src
|
144 |
ysh-zz/src
|
145 |
## END
|
146 |
|
147 |
|
148 |
|
149 |
shopt --set ysh:upgrade
|
150 |
|
151 |
#export ZZ=zzz
|
152 |
setglobal ENV.ZZ = 'zz'
|
153 |
|
154 |
env sh -c 'echo child ZZ=$ZZ'
|
155 |
|
156 |
exec env sh -c 'echo exec ZZ=$ZZ'
|
157 |
|
158 |
## STDOUT:
|
159 |
child ZZ=zz
|
160 |
exec ZZ=zz
|
161 |
## END
|