| 1 |
|
| 2 |
|
| 3 |
shopt --set ysh:upgrade
|
| 4 |
|
| 5 |
source-guard 'main' || return 0
|
| 6 |
source $REPO_ROOT/spec/testdata/module/common.ysh
|
| 7 |
source $REPO_ROOT/spec/testdata/module/module1.ysh
|
| 8 |
## STDOUT:
|
| 9 |
common
|
| 10 |
module1
|
| 11 |
## END
|
| 12 |
|
| 13 |
|
| 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:
|
| 22 |
lib.ysh is not the main module
|
| 23 |
hi from main.ysh
|
| 24 |
hi from lib.ysh
|
| 25 |
## END
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
$SH -c 'echo -c; is-main; echo status=$?'
|
| 30 |
|
| 31 |
echo 'echo stdin; is-main; echo status=$?' | $SH
|
| 32 |
|
| 33 |
## STDOUT:
|
| 34 |
-c
|
| 35 |
status=0
|
| 36 |
stdin
|
| 37 |
status=0
|
| 38 |
## END
|