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
7 echo interactive
8
9 $[ENV.SH] -i --rcfile $[ENV.REPO_ROOT]/spec/testdata/module/this_dir.ysh -c 'echo -c'
10
11 ## STDOUT:
12 hi from this_dir.ysh
13 $_this_dir = REPLACED/oil/spec/testdata/module
14 interactive
15 hi 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
22 echo ${_this_dir:-'not yet'}
23 ## STDOUT:
24 not yet
25 ## END
26
27
28 #### _this_dir in sourced module
29 source $[ENV.REPO_ROOT]/spec/testdata/module/this_dir.ysh
30 ## STDOUT:
31 hi from this_dir.ysh
32 $_this_dir = REPLACED/oil/spec/testdata/module
33 ## END
34
35
36 #### _this_dir not affected by 'cd'
37 cd /tmp
38 source $[ENV.REPO_ROOT]/spec/testdata/module/this_dir.ysh
39 ## STDOUT:
40 hi from this_dir.ysh
41 $_this_dir = REPLACED/oil/spec/testdata/module
42 ## END
43
44 #### _this_dir used with relative path
45 cd $[ENV.REPO_ROOT]
46 source spec/testdata/module/this_dir.ysh
47 ## STDOUT:
48 hi from this_dir.ysh
49 $_this_dir = REPLACED/oil/spec/testdata/module
50 ## END