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

38 lines, 17 significant
1
2#### module
3shopt --set ysh:upgrade
4
5module 'main' || return 0
6source $REPO_ROOT/spec/testdata/module/common.ysh
7source $REPO_ROOT/spec/testdata/module/module1.ysh
8## STDOUT:
9common
10module1
11## END
12
13#### is-main
14
15# This sources lib.ysh
16$SH $REPO_ROOT/spec/testdata/module/main.ysh
17
18# Run it directly
19$SH $REPO_ROOT/spec/testdata/module/lib.ysh
20
21## STDOUT:
22lib.ysh is not the main module
23hi from main.ysh
24hi from lib.ysh
25## END
26
27#### is-main with -c and stdin
28
29$SH -c 'echo -c; is-main; echo status=$?'
30
31echo 'echo stdin; is-main; echo status=$?' | $SH
32
33## STDOUT:
34-c
35status=0
36stdin
37status=0
38## END