man.test 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. #!/bin/bash
  2. # Copyright 2019 makepost <makepost@firemail.cc>
  3. [ -f testing.sh ] && . testing.sh
  4. #testing "name" "command" "result" "infile" "stdin"
  5. mkdir -p banana/man{1,3,5}
  6. # Can't/shouldn't write to /usr/share/man so use -M to change path
  7. MAN="man -M banana"
  8. echo one | bzip2 >banana/man1/numbers.1.bz2
  9. echo three | gzip >banana/man3/numbers.3.gz
  10. echo five > banana/man5/numbers.5
  11. testing "man" "$MAN numbers" " one\n\n" "" ""
  12. testing "man.section" "$MAN numbers.3" " three\n\n" "" ""
  13. testing "section man" "$MAN 5 numbers" " five\n\n" "" ""
  14. testing "/" "$MAN /" "" "" "" # Regression guard for !suf in zopen
  15. cat >banana/man1/toybox.1 <<EOF
  16. .TP
  17. .PD 0
  18. .B \\-F
  19. .TP
  20. .PD
  21. .B \\-\\^\\-foo\\-bar
  22. Does something.
  23. .TP
  24. .PD 0
  25. .B \\-\\-no\\-alias
  26. Has no alias.
  27. EOF
  28. testing "gawk alias" "$MAN toybox" " -F\n --foo-bar Does something.\n\n --no-alias Has no alias.\n\n" "" ""
  29. cat >banana/man1/toybox.1 <<EOF
  30. \\fBsh\\fR-compatible
  31. \\fIKorn\\fP
  32. EOF
  33. testing "bash bold,ita" "$MAN toybox" " sh-compatible Korn\n\n" "" ""
  34. cat >banana/man1/toybox.1 <<EOF
  35. quoted \\(aqstring\\(aq
  36. \\(dqserver\\(dq
  37. Don\\(cq\\&t
  38. EOF
  39. testing "bash,rsync quote" "$MAN toybox" " quoted 'string' \"server\" Don't\n\n" "" ""
  40. echo "\\*(lq\\-\\^\\-\\*(rq" >banana/man1/toybox.1
  41. testing "gawk quote" "$MAN toybox" " \"--\"\n\n" "" ""
  42. cat >banana/man1/toybox.1 <<EOF
  43. .IP \\(bu
  44. [\\fB|\\fP\\(bv\\fB|&\\fP]
  45. EOF
  46. testing "bash symbol" "$MAN toybox" " * [|||&]\n\n" "" ""
  47. cat >banana/man1/toybox.1 <<EOF
  48. \\&\\fBfflush(...)\\fR
  49. \\f(CW$ ssh ...\\fP
  50. EOF
  51. testing "gawk,rsync fancy" "$MAN toybox" " fflush(...) $ ssh ...\n\n" "" ""
  52. cat >banana/man1/toybox.1 <<EOF
  53. "\\eC\\-x\\eC\\-r": re\\-read
  54. must be \\(>= 1
  55. EOF
  56. testing "bash escape" "$MAN toybox" " \"\C-x\C-r\": re-read must be >= 1\n\n" "" ""
  57. echo "\\*(AK language. The \\*(PX standard" >banana/man1/toybox.1
  58. testing "gawk var" "$MAN toybox" " #AK language. The #PX standard\n\n" "" ""
  59. cat >banana/man1/toybox.1 <<EOF
  60. If set to
  61. .BR On ,
  62. (...)
  63. EOF
  64. testing "bash boldpunct" "$MAN toybox" " If set to On, (...)\n\n" "" ""
  65. cat >banana/man1/toybox.1 <<EOF
  66. .IP \\fB\$endif\\fP
  67. (...)
  68. .IP \\fB\$else\\fP
  69. (...)
  70. .IP \\fB\$include\\fP
  71. EOF
  72. testing "bash list" "$MAN toybox" " \$endif (...)\n\n \$else (...)\n\n \$include\n\n" "" ""
  73. cat >banana/man1/toybox.1 <<EOF
  74. asynchronously (in the
  75. .IR background ),
  76. it prints
  77. EOF
  78. testing "bash itapunct" "$MAN toybox" " asynchronously (in the background), it prints\n\n" "" ""
  79. cat >banana/man1/toybox.1 <<EOF
  80. (...)
  81. .B Bash
  82. is
  83. EOF
  84. testing "bash bold" "$MAN toybox" " (...) Bash is\n\n" "" ""
  85. # TODO: Unquote.
  86. cat >banana/man1/toybox.1 <<EOF
  87. .PD 0
  88. .BI \\-f " program-file"
  89. .TP
  90. EOF
  91. testing "gawk boldita" "$MAN toybox" " -f \" program-file\"\n\n" "" ""
  92. cat >banana/man1/toybox.1 <<EOF
  93. same format as
  94. .FN /etc/hosts
  95. (...)
  96. EOF
  97. testing "bash filename" "$MAN toybox" " same format as /etc/hosts (...)\n\n" "" ""
  98. cat >banana/man1/toybox.1 <<EOF
  99. The
  100. .I Internal Field Separator
  101. that is used
  102. EOF
  103. testing "bash ita" "$MAN toybox" " The Internal Field Separator that is used\n\n" "" ""
  104. cat >banana/man1/toybox.1 <<EOF
  105. .if n Copyright (C) 2019
  106. .if t Copyright \\(co 2019
  107. EOF
  108. testing "bash nroff" "$MAN toybox" " Copyright (C) 2019\n\n" "" ""
  109. cat >banana/man1/toybox.1 <<EOF
  110. .EX
  111. #include <stdio.h>
  112. #include <stdlib.h>
  113. .EE
  114. EOF
  115. testing "stat example" "$MAN toybox" "#include <stdio.h>\n#include <stdlib.h>\n\n\n" "" ""
  116. cat >banana/man1/toybox.1 <<EOF
  117. (...)
  118. .PP
  119. (...)
  120. EOF
  121. testing "bash paragraph" "$MAN toybox" " (...)\n\n (...)\n\n" "" ""
  122. # TODO: Find some command I saw that has a different see below.
  123. cat >banana/man1/toybox.1 <<EOF
  124. (see
  125. .SM
  126. .B INVOCATION
  127. below)
  128. EOF
  129. testing "bash small" "$MAN toybox" " (see INVOCATION below)\n\n" "" ""
  130. cat >banana/man1/toybox.1 <<EOF
  131. (...)
  132. .SH "SHELL GRAMMAR"
  133. .SS Simple Commands
  134. .PP
  135. (...)
  136. EOF
  137. testing "bash section" "$MAN toybox" " (...)\n\n\"SHELL GRAMMAR\"\n\nSimple Commands\n\n (...)\n\n" "" ""
  138. echo ".so man1/last.1" >banana/man1/toybox.1
  139. testing "lastb" "$MAN toybox" "See last.1\n\n" "" ""
  140. cat >banana/man1/toybox.1 <<EOF
  141. .TH TOYBOX 1 "Apr 13 2019" "Project Organization" "Document Name"
  142. .PP
  143. .TH "TOYBOX" "1" "04/13/2019" "Toybox 0\\&.8\\&.0" "Toybox Manual"
  144. EOF
  145. testing "gawk,git head" "$MAN toybox" "TOYBOX 1 Apr 13 2019 Project Organization Document Name \n\n TOYBOX 1 04/13/2019 Toybox 0.8.0 Toybox Manual \n\n" "" ""
  146. cat >banana/man1/toybox.1 <<EOF
  147. (...)
  148. .PP
  149. .PD 0
  150. .TP 10
  151. .B \\-c
  152. If the
  153. .B \\-c
  154. option is present
  155. EOF
  156. testing "bash table" "$MAN toybox" " (...)\n\n -c If the -c option is present\n\n" "" ""
  157. cat >banana/man1/toybox.1 <<EOF
  158. .de FN
  159. .sp
  160. .RE
  161. '\" t
  162. EOF
  163. testing "bash,git garbage" "$MAN toybox" "" "" ""
  164. # "bash,git garbage" from above has no content, -k skips it.
  165. bzip2 >banana/man1/numbers.1.bz2 <<EOF
  166. .TH NUMBERS 1 "2019 Apr 28" "Toybox Manual"
  167. .SH NAME
  168. man \- test -k
  169. .SH ANOTHER SECTION
  170. .so noop.1
  171. Skip this text.
  172. EOF
  173. echo "No dash." | gzip >banana/man3/numbers.3.gz
  174. echo .so man1/numbers.1 >banana/man5/numbers.5
  175. testing "-k ." "$MAN -k ." "numbers.1.bz2 - test -k\nnumbers.3.gz - No dash.\nnumbers.5 - See numbers.1\n" "" ""
  176. testing "-k -k" "$MAN -k -k" "numbers.1.bz2 - test -k\n" "" ""
  177. testing "-k d.*h" "$MAN -k 'd.*h'" "numbers.3.gz - No dash.\n" "" ""
  178. testing "-k ers.1" "$MAN -k ers.1" "numbers.1.bz2 - test -k\nnumbers.5 - See numbers.1\n" "" ""
  179. mkdir -p walrus/man1
  180. echo Local development override. | bzip2 >walrus/man1/numbers.1.bz2
  181. testing "-M /dir:/dir0" "man -M walrus:banana numbers" " Local development override.\n\n" "" ""
  182. testing "-M /dir:/dir0 -k ." "man -M walrus:banana -k ." "numbers.1.bz2 - Local development override.\nnumbers.1.bz2 - test -k\nnumbers.3.gz - No dash.\nnumbers.5 - See numbers.1\n" "" ""
  183. testing "-M '' x" "man -M '' numbers 2>&1" "man: no numbers\n" "" ""
  184. testing "-M '' 1 x" "man -M '' 1 numbers 2>&1" "man: section 1 no numbers\n" "" ""
  185. testing "-M '' -k ." "man -M '' -k ." "" "" ""
  186. # TODO: emerge section header newline
  187. # TODO: fdm,man-pages man1p/, .nf, rare tags
  188. rm -rf banana walrus