OILS / spec / ysh-env.test.sh View on Github | oilshell.org

54 lines, 18 significant
1## oils_failures_allowed: 2
2
3#### Can read from ENV Dict
4shopt -s ysh:upgrade
5
6pp test_ (type(ENV))
7
8sh=$[ENV.SH]
9env -i PATH=$[ENV.PATH] ZZ=zz $sh -c 'echo "ZZ is $[ENV.ZZ]"'
10
11## STDOUT:
12(Str) "Dict"
13ZZ is zz
14## END
15
16#### Temp bindings A=a B=b my-command push to ENV dict
17shopt -s ysh:upgrade
18
19_A=a _B=b env | grep '^_' | sort
20
21## STDOUT:
22_A=a
23_B=b
24## END
25
26#### setglobal ENV.PYTHONPATH = 'foo' changes child process state
27shopt -s ysh:upgrade
28
29setglobal ENV.PYTHONPATH = 'foo'
30
31pp test_ (ENV)
32
33#export PYTHONPATH=zz
34
35# execute POSIX shell
36sh -c 'echo pythonpath=$PYTHONPATH'
37
38## STDOUT:
39## END
40
41#### export builtin still works
42shopt -s ysh:upgrade
43
44export PYTHONPATH='foo'
45
46#pp test_ (ENV)
47
48# execute POSIX shell
49sh -c 'echo pythonpath=$PYTHONPATH'
50
51## STDOUT:
52pythonpath=foo
53## END
54