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

124 lines, 58 significant
1## our_shell: ysh
2
3#### help topic not found
4
5help zz
6
7## status: 1
8## STDOUT:
9## END
10
11#### help topics that are embedded
12
13help > help.txt
14echo no args $?
15echo
16
17for topic in help oils-usage {osh,ysh}-usage {osh,ysh}-chapters; do
18 help $topic | fgrep -o "~~~ $topic"
19 echo $topic $?
20 echo
21done
22
23## STDOUT:
24no args 0
25
26~~~ help
27help 0
28
29~~~ oils-usage
30oils-usage 0
31
32~~~ osh-usage
33osh-usage 0
34
35~~~ ysh-usage
36ysh-usage 0
37
38~~~ osh-chapters
39osh-chapters 0
40
41~~~ ysh-chapters
42ysh-chapters 0
43
44## END
45
46#### help topics that print URLs
47
48help command-sub | grep -o chap-word-lang.html
49echo status=$?
50
51help read | grep -o chap-builtin-cmd.html
52echo status=$?
53
54## STDOUT:
55chap-word-lang.html
56status=0
57chap-builtin-cmd.html
58status=0
59## END
60
61#### help shows 'ysh-chapters' topic
62
63# shows ~~~ instead of ANSI text
64help | grep ysh-chapters
65
66echo status=$?
67
68## STDOUT:
69~~~ ysh-chapters ~~~
70status=0
71## END
72
73#### help List/append, runes, etc.
74
75shopt --set ysh:upgrade
76
77proc assert-lines {
78 var num_lines = $(@ARGV | wc -l)
79 #echo "lines = $num_lines"
80 if (num_lines < 2) {
81 error "only got $num_lines lines"
82 }
83}
84
85assert-lines help List/append
86echo status=$?
87
88assert-lines help cmd/append
89echo status=$?
90
91assert-lines help runes
92echo status=$?
93
94## STDOUT:
95status=0
96status=0
97status=0
98## END
99
100
101#### help oils-err-12 (case insensitive)
102
103# note that the topics are lower-casedo
104
105help oils-err-12 | grep -o 'catalog.html#oils-err-12'
106echo status=$?
107
108help OILS-ERR-12 | grep -o 'catalog.html#oils-err-12'
109echo status=$?
110
111# these are bad
112
113# help oils-err-zz
114# echo status=$?
115
116# help OILS-ERR-zz
117# echo status=$?
118
119## STDOUT:
120catalog.html#oils-err-12
121status=0
122catalog.html#oils-err-12
123status=0
124## END