1
2 #### module
3 shopt --set ysh:upgrade
4
5 module '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 #### 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:
22 lib.ysh is not the main module
23 hi from main.ysh
24 hi from lib.ysh
25 ## END
26
27 #### is-main with -c and stdin
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
39
40 #### runproc
41 shopt --set parse_proc
42
43 f() {
44 write -- f "$@"
45 }
46 proc p {
47 write -- p "$@"
48 }
49 runproc f 1 2
50 echo status=$?
51
52 runproc p 3 4
53 echo status=$?
54
55 runproc invalid 5 6
56 echo status=$?
57
58 runproc
59 echo status=$?
60
61 ## STDOUT:
62 f
63 1
64 2
65 status=0
66 p
67 3
68 4
69 status=0
70 status=1
71 status=2
72 ## END
73
74 #### runproc typed args
75 shopt --set parse_brace parse_proc
76
77 proc p {
78 echo hi
79 }
80
81 # The block is ignored for now
82 runproc p {
83 echo myblock
84 }
85 ## STDOUT:
86 hi
87 ## END
88