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

50 lines, 22 significant
1## our_shell: ysh
2
3#### _this_dir in main and oshrc
4
5$[ENV.SH] $[ENV.REPO_ROOT]/spec/testdata/module/this_dir.ysh
6
7echo interactive
8
9$[ENV.SH] -i --rcfile $[ENV.REPO_ROOT]/spec/testdata/module/this_dir.ysh -c 'echo -c'
10
11## STDOUT:
12hi from this_dir.ysh
13$_this_dir = REPLACED/oil/spec/testdata/module
14interactive
15hi from this_dir.ysh
16$_this_dir = REPLACED/oil/spec/testdata/module
17-c
18## END
19
20#### _this_dir not set on stdin
21
22echo ${_this_dir:-'not yet'}
23## STDOUT:
24not yet
25## END
26
27
28#### _this_dir in sourced module
29source $[ENV.REPO_ROOT]/spec/testdata/module/this_dir.ysh
30## STDOUT:
31hi from this_dir.ysh
32$_this_dir = REPLACED/oil/spec/testdata/module
33## END
34
35
36#### _this_dir not affected by 'cd'
37cd /tmp
38source $[ENV.REPO_ROOT]/spec/testdata/module/this_dir.ysh
39## STDOUT:
40hi from this_dir.ysh
41$_this_dir = REPLACED/oil/spec/testdata/module
42## END
43
44#### _this_dir used with relative path
45cd $[ENV.REPO_ROOT]
46source spec/testdata/module/this_dir.ysh
47## STDOUT:
48hi from this_dir.ysh
49$_this_dir = REPLACED/oil/spec/testdata/module
50## END