just-bash 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (329) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +326 -0
  3. package/dist/Bash.d.ts +90 -0
  4. package/dist/ai/index.d.ts +56 -0
  5. package/dist/ast/types.d.ts +518 -0
  6. package/dist/bin/chunks/alias-74DFXE2E.js +7 -0
  7. package/dist/bin/chunks/awk-S63F6IYK.js +15 -0
  8. package/dist/bin/chunks/base64-NC7HTKLZ.js +5 -0
  9. package/dist/bin/chunks/basename-Y7JDBYHN.js +6 -0
  10. package/dist/bin/chunks/bash-TQGTNXAE.js +7 -0
  11. package/dist/bin/chunks/cat-YZXBF5YF.js +6 -0
  12. package/dist/bin/chunks/chmod-3G4LK462.js +9 -0
  13. package/dist/bin/chunks/chunk-26Q3PZQ6.js +2 -0
  14. package/dist/bin/chunks/chunk-4VDEBYW7.js +2 -0
  15. package/dist/bin/chunks/chunk-5KNEBKYN.js +2 -0
  16. package/dist/bin/chunks/chunk-GTNBSMZR.js +23 -0
  17. package/dist/bin/chunks/chunk-J7BCMQDI.js +16 -0
  18. package/dist/bin/chunks/chunk-J7MJV6WO.js +3 -0
  19. package/dist/bin/chunks/chunk-LV662IGP.js +6 -0
  20. package/dist/bin/chunks/chunk-TA7RUHGQ.js +4 -0
  21. package/dist/bin/chunks/clear-GTCFHSB2.js +2 -0
  22. package/dist/bin/chunks/cp-77UY7PGN.js +8 -0
  23. package/dist/bin/chunks/curl-NE7XEWMN.js +26 -0
  24. package/dist/bin/chunks/cut-UYV3FM7R.js +6 -0
  25. package/dist/bin/chunks/date-7NBRXV2Z.js +5 -0
  26. package/dist/bin/chunks/diff-TG2NXCX2.js +19 -0
  27. package/dist/bin/chunks/dirname-VLHP44TU.js +5 -0
  28. package/dist/bin/chunks/du-4FZ7WF2P.js +8 -0
  29. package/dist/bin/chunks/echo-DEUIS5JO.js +4 -0
  30. package/dist/bin/chunks/env-FVITWNHG.js +9 -0
  31. package/dist/bin/chunks/expr-HA2ZNL6S.js +5 -0
  32. package/dist/bin/chunks/find-4B67H4RP.js +11 -0
  33. package/dist/bin/chunks/grep-OVWU4WCZ.js +15 -0
  34. package/dist/bin/chunks/head-VGXR3WWL.js +2 -0
  35. package/dist/bin/chunks/help-5V3MPCYQ.js +16 -0
  36. package/dist/bin/chunks/history-PRQ4B6N2.js +3 -0
  37. package/dist/bin/chunks/html-to-markdown-L4UWMK4S.js +84 -0
  38. package/dist/bin/chunks/jq-EYSXBSCP.js +14 -0
  39. package/dist/bin/chunks/ln-DB7J2W5X.js +10 -0
  40. package/dist/bin/chunks/ls-C4MPAF3H.js +26 -0
  41. package/dist/bin/chunks/mkdir-LWULWDHP.js +7 -0
  42. package/dist/bin/chunks/mv-TDYCNSIQ.js +7 -0
  43. package/dist/bin/chunks/paste-R36J3G4K.js +8 -0
  44. package/dist/bin/chunks/printf-BOFQVMMK.js +15 -0
  45. package/dist/bin/chunks/pwd-X4MWD4JP.js +3 -0
  46. package/dist/bin/chunks/readlink-DPNOQY67.js +7 -0
  47. package/dist/bin/chunks/rm-W6CCBEMG.js +8 -0
  48. package/dist/bin/chunks/sed-7IS44XON.js +48 -0
  49. package/dist/bin/chunks/seq-DGJILX2Q.js +7 -0
  50. package/dist/bin/chunks/sleep-E4DIYGTT.js +10 -0
  51. package/dist/bin/chunks/sort-UJP353TM.js +15 -0
  52. package/dist/bin/chunks/stat-3PHITCPO.js +9 -0
  53. package/dist/bin/chunks/tail-YSVKBQ77.js +2 -0
  54. package/dist/bin/chunks/tee-UU2VS3OM.js +3 -0
  55. package/dist/bin/chunks/timeout-OZVAGW2H.js +12 -0
  56. package/dist/bin/chunks/touch-XCIAYF5I.js +4 -0
  57. package/dist/bin/chunks/tr-2EEKHHO6.js +20 -0
  58. package/dist/bin/chunks/tree-4247W67O.js +12 -0
  59. package/dist/bin/chunks/true-JCX733LK.js +2 -0
  60. package/dist/bin/chunks/uniq-W4HF6YSB.js +5 -0
  61. package/dist/bin/chunks/wc-CNJ3QDRA.js +6 -0
  62. package/dist/bin/chunks/which-HX2NMOP3.js +3 -0
  63. package/dist/bin/chunks/xargs-YNLVLPOF.js +4 -0
  64. package/dist/bin/just-bash.js +188 -0
  65. package/dist/bin/shell/chunks/alias-74DFXE2E.js +7 -0
  66. package/dist/bin/shell/chunks/awk-S63F6IYK.js +15 -0
  67. package/dist/bin/shell/chunks/base64-NC7HTKLZ.js +5 -0
  68. package/dist/bin/shell/chunks/basename-Y7JDBYHN.js +6 -0
  69. package/dist/bin/shell/chunks/bash-TQGTNXAE.js +7 -0
  70. package/dist/bin/shell/chunks/cat-YZXBF5YF.js +6 -0
  71. package/dist/bin/shell/chunks/chmod-3G4LK462.js +9 -0
  72. package/dist/bin/shell/chunks/chunk-26Q3PZQ6.js +2 -0
  73. package/dist/bin/shell/chunks/chunk-4VDEBYW7.js +2 -0
  74. package/dist/bin/shell/chunks/chunk-5KNEBKYN.js +2 -0
  75. package/dist/bin/shell/chunks/chunk-GTNBSMZR.js +23 -0
  76. package/dist/bin/shell/chunks/chunk-J7BCMQDI.js +16 -0
  77. package/dist/bin/shell/chunks/chunk-J7MJV6WO.js +3 -0
  78. package/dist/bin/shell/chunks/chunk-LV662IGP.js +6 -0
  79. package/dist/bin/shell/chunks/chunk-TA7RUHGQ.js +4 -0
  80. package/dist/bin/shell/chunks/clear-GTCFHSB2.js +2 -0
  81. package/dist/bin/shell/chunks/cp-77UY7PGN.js +8 -0
  82. package/dist/bin/shell/chunks/curl-NE7XEWMN.js +26 -0
  83. package/dist/bin/shell/chunks/cut-UYV3FM7R.js +6 -0
  84. package/dist/bin/shell/chunks/date-7NBRXV2Z.js +5 -0
  85. package/dist/bin/shell/chunks/diff-TG2NXCX2.js +19 -0
  86. package/dist/bin/shell/chunks/dirname-VLHP44TU.js +5 -0
  87. package/dist/bin/shell/chunks/du-4FZ7WF2P.js +8 -0
  88. package/dist/bin/shell/chunks/echo-DEUIS5JO.js +4 -0
  89. package/dist/bin/shell/chunks/env-FVITWNHG.js +9 -0
  90. package/dist/bin/shell/chunks/expr-HA2ZNL6S.js +5 -0
  91. package/dist/bin/shell/chunks/find-4B67H4RP.js +11 -0
  92. package/dist/bin/shell/chunks/grep-OVWU4WCZ.js +15 -0
  93. package/dist/bin/shell/chunks/head-VGXR3WWL.js +2 -0
  94. package/dist/bin/shell/chunks/help-5V3MPCYQ.js +16 -0
  95. package/dist/bin/shell/chunks/history-PRQ4B6N2.js +3 -0
  96. package/dist/bin/shell/chunks/html-to-markdown-L4UWMK4S.js +84 -0
  97. package/dist/bin/shell/chunks/jq-EYSXBSCP.js +14 -0
  98. package/dist/bin/shell/chunks/ln-DB7J2W5X.js +10 -0
  99. package/dist/bin/shell/chunks/ls-C4MPAF3H.js +26 -0
  100. package/dist/bin/shell/chunks/mkdir-LWULWDHP.js +7 -0
  101. package/dist/bin/shell/chunks/mv-TDYCNSIQ.js +7 -0
  102. package/dist/bin/shell/chunks/paste-R36J3G4K.js +8 -0
  103. package/dist/bin/shell/chunks/printf-BOFQVMMK.js +15 -0
  104. package/dist/bin/shell/chunks/pwd-X4MWD4JP.js +3 -0
  105. package/dist/bin/shell/chunks/readlink-DPNOQY67.js +7 -0
  106. package/dist/bin/shell/chunks/rm-W6CCBEMG.js +8 -0
  107. package/dist/bin/shell/chunks/sed-7IS44XON.js +48 -0
  108. package/dist/bin/shell/chunks/seq-DGJILX2Q.js +7 -0
  109. package/dist/bin/shell/chunks/sleep-E4DIYGTT.js +10 -0
  110. package/dist/bin/shell/chunks/sort-UJP353TM.js +15 -0
  111. package/dist/bin/shell/chunks/stat-3PHITCPO.js +9 -0
  112. package/dist/bin/shell/chunks/tail-YSVKBQ77.js +2 -0
  113. package/dist/bin/shell/chunks/tee-UU2VS3OM.js +3 -0
  114. package/dist/bin/shell/chunks/timeout-OZVAGW2H.js +12 -0
  115. package/dist/bin/shell/chunks/touch-XCIAYF5I.js +4 -0
  116. package/dist/bin/shell/chunks/tr-2EEKHHO6.js +20 -0
  117. package/dist/bin/shell/chunks/tree-4247W67O.js +12 -0
  118. package/dist/bin/shell/chunks/true-JCX733LK.js +2 -0
  119. package/dist/bin/shell/chunks/uniq-W4HF6YSB.js +5 -0
  120. package/dist/bin/shell/chunks/wc-CNJ3QDRA.js +6 -0
  121. package/dist/bin/shell/chunks/which-HX2NMOP3.js +3 -0
  122. package/dist/bin/shell/chunks/xargs-YNLVLPOF.js +4 -0
  123. package/dist/bin/shell/shell.js +172 -0
  124. package/dist/bundle/ai/index.js +541 -0
  125. package/dist/bundle/chunks/alias-7ZSTROM7.js +6 -0
  126. package/dist/bundle/chunks/awk-V4C3GTJI.js +14 -0
  127. package/dist/bundle/chunks/base64-WATI5PWI.js +4 -0
  128. package/dist/bundle/chunks/basename-SB5JXIY3.js +5 -0
  129. package/dist/bundle/chunks/bash-T4PXVRYX.js +6 -0
  130. package/dist/bundle/chunks/cat-5KESXK2M.js +5 -0
  131. package/dist/bundle/chunks/chmod-VLKWIL3N.js +8 -0
  132. package/dist/bundle/chunks/chunk-3YNHMZ5M.js +2 -0
  133. package/dist/bundle/chunks/chunk-44UOCSGV.js +1 -0
  134. package/dist/bundle/chunks/chunk-74CEPOFO.js +22 -0
  135. package/dist/bundle/chunks/chunk-JYYFSUWP.js +5 -0
  136. package/dist/bundle/chunks/chunk-UJMN5NLH.js +1 -0
  137. package/dist/bundle/chunks/chunk-W2EKKAIL.js +15 -0
  138. package/dist/bundle/chunks/chunk-ZVV5VXYZ.js +3 -0
  139. package/dist/bundle/chunks/clear-ZBD2DMXN.js +1 -0
  140. package/dist/bundle/chunks/cp-BLHAPLQZ.js +7 -0
  141. package/dist/bundle/chunks/curl-PA2MWGKN.js +25 -0
  142. package/dist/bundle/chunks/cut-7RHEYJ7Y.js +5 -0
  143. package/dist/bundle/chunks/date-YOOSNZVA.js +4 -0
  144. package/dist/bundle/chunks/diff-IVJFQANX.js +6 -0
  145. package/dist/bundle/chunks/dirname-Q5HDZLH2.js +4 -0
  146. package/dist/bundle/chunks/du-I5HYAKTQ.js +7 -0
  147. package/dist/bundle/chunks/echo-W2TA2N7Y.js +3 -0
  148. package/dist/bundle/chunks/env-OORA5GFS.js +8 -0
  149. package/dist/bundle/chunks/expr-A4LJAGVP.js +4 -0
  150. package/dist/bundle/chunks/find-K3NO35MZ.js +10 -0
  151. package/dist/bundle/chunks/grep-3D2INI4S.js +14 -0
  152. package/dist/bundle/chunks/head-7H5R4WKO.js +1 -0
  153. package/dist/bundle/chunks/help-SDCRRU2F.js +15 -0
  154. package/dist/bundle/chunks/history-7Z2STZ6Y.js +2 -0
  155. package/dist/bundle/chunks/html-to-markdown-XMBYO6FD.js +4 -0
  156. package/dist/bundle/chunks/jq-7R2XGLLH.js +13 -0
  157. package/dist/bundle/chunks/ln-UTUVIAFP.js +9 -0
  158. package/dist/bundle/chunks/ls-B7C35UDO.js +23 -0
  159. package/dist/bundle/chunks/mkdir-WYI2LJ6H.js +6 -0
  160. package/dist/bundle/chunks/mv-GN23UIZU.js +6 -0
  161. package/dist/bundle/chunks/paste-L4TYPVSP.js +7 -0
  162. package/dist/bundle/chunks/printf-3ZT5XOIZ.js +14 -0
  163. package/dist/bundle/chunks/pwd-ZVX5RTL4.js +2 -0
  164. package/dist/bundle/chunks/readlink-HHC33N5C.js +6 -0
  165. package/dist/bundle/chunks/rm-5X2XSQQ6.js +7 -0
  166. package/dist/bundle/chunks/sed-UZJSXYQZ.js +47 -0
  167. package/dist/bundle/chunks/seq-TFPZQZPJ.js +6 -0
  168. package/dist/bundle/chunks/sleep-QJBQD6VS.js +9 -0
  169. package/dist/bundle/chunks/sort-LHMQWYH2.js +14 -0
  170. package/dist/bundle/chunks/stat-TM5F5YO4.js +8 -0
  171. package/dist/bundle/chunks/tail-BLGGG2VX.js +1 -0
  172. package/dist/bundle/chunks/tee-VCNOG5VI.js +2 -0
  173. package/dist/bundle/chunks/timeout-THAT7IOO.js +11 -0
  174. package/dist/bundle/chunks/touch-Z5XRYFYY.js +3 -0
  175. package/dist/bundle/chunks/tr-UV4V27RJ.js +19 -0
  176. package/dist/bundle/chunks/tree-75UXQ4XJ.js +11 -0
  177. package/dist/bundle/chunks/true-OD7ZXH3O.js +1 -0
  178. package/dist/bundle/chunks/uniq-IIOQKNTS.js +4 -0
  179. package/dist/bundle/chunks/wc-OXLYBRUE.js +5 -0
  180. package/dist/bundle/chunks/which-ONWH3TNF.js +2 -0
  181. package/dist/bundle/chunks/xargs-E5JPQL24.js +3 -0
  182. package/dist/bundle/index.js +141 -0
  183. package/dist/commands/alias/alias.d.ts +3 -0
  184. package/dist/commands/awk/awk.d.ts +2 -0
  185. package/dist/commands/awk/executor.d.ts +3 -0
  186. package/dist/commands/awk/expressions.d.ts +3 -0
  187. package/dist/commands/awk/functions.d.ts +12 -0
  188. package/dist/commands/awk/parser.d.ts +3 -0
  189. package/dist/commands/awk/types.d.ts +44 -0
  190. package/dist/commands/base64/base64.d.ts +5 -0
  191. package/dist/commands/basename/basename.d.ts +2 -0
  192. package/dist/commands/bash/bash.d.ts +3 -0
  193. package/dist/commands/cat/cat.d.ts +2 -0
  194. package/dist/commands/chmod/chmod.d.ts +2 -0
  195. package/dist/commands/clear/clear.d.ts +2 -0
  196. package/dist/commands/cp/cp.d.ts +2 -0
  197. package/dist/commands/curl/curl.d.ts +8 -0
  198. package/dist/commands/curl/form.d.ts +21 -0
  199. package/dist/commands/curl/help.d.ts +9 -0
  200. package/dist/commands/curl/parse.d.ts +9 -0
  201. package/dist/commands/curl/types.d.ts +31 -0
  202. package/dist/commands/curl/utils.d.ts +20 -0
  203. package/dist/commands/cut/cut.d.ts +2 -0
  204. package/dist/commands/date/date.d.ts +5 -0
  205. package/dist/commands/diff/diff.d.ts +5 -0
  206. package/dist/commands/dirname/dirname.d.ts +2 -0
  207. package/dist/commands/du/du.d.ts +2 -0
  208. package/dist/commands/echo/echo.d.ts +2 -0
  209. package/dist/commands/env/env.d.ts +3 -0
  210. package/dist/commands/expr/expr.d.ts +7 -0
  211. package/dist/commands/find/find.d.ts +2 -0
  212. package/dist/commands/find/matcher.d.ts +3 -0
  213. package/dist/commands/find/parser.d.ts +2 -0
  214. package/dist/commands/find/types.d.ts +70 -0
  215. package/dist/commands/grep/grep.d.ts +4 -0
  216. package/dist/commands/head/head-tail-shared.d.ts +38 -0
  217. package/dist/commands/head/head.d.ts +2 -0
  218. package/dist/commands/help/help.d.ts +2 -0
  219. package/dist/commands/help.d.ts +16 -0
  220. package/dist/commands/history/history.d.ts +2 -0
  221. package/dist/commands/html-to-markdown/html-to-markdown.d.ts +7 -0
  222. package/dist/commands/jq/jq.d.ts +14 -0
  223. package/dist/commands/ln/ln.d.ts +2 -0
  224. package/dist/commands/ls/ls.d.ts +2 -0
  225. package/dist/commands/mkdir/mkdir.d.ts +2 -0
  226. package/dist/commands/mv/mv.d.ts +2 -0
  227. package/dist/commands/paste/paste.d.ts +2 -0
  228. package/dist/commands/printf/printf.d.ts +2 -0
  229. package/dist/commands/pwd/pwd.d.ts +2 -0
  230. package/dist/commands/readlink/readlink.d.ts +2 -0
  231. package/dist/commands/registry.d.ts +33 -0
  232. package/dist/commands/rm/rm.d.ts +2 -0
  233. package/dist/commands/sed/executor.d.ts +7 -0
  234. package/dist/commands/sed/parser.d.ts +5 -0
  235. package/dist/commands/sed/sed.d.ts +2 -0
  236. package/dist/commands/sed/types.d.ts +141 -0
  237. package/dist/commands/seq/seq.d.ts +14 -0
  238. package/dist/commands/sleep/sleep.d.ts +2 -0
  239. package/dist/commands/sort/comparator.d.ts +9 -0
  240. package/dist/commands/sort/parser.d.ts +11 -0
  241. package/dist/commands/sort/sort.d.ts +2 -0
  242. package/dist/commands/sort/types.d.ts +18 -0
  243. package/dist/commands/stat/stat.d.ts +2 -0
  244. package/dist/commands/tail/tail.d.ts +2 -0
  245. package/dist/commands/tee/tee.d.ts +2 -0
  246. package/dist/commands/timeout/timeout.d.ts +2 -0
  247. package/dist/commands/touch/touch.d.ts +2 -0
  248. package/dist/commands/tr/tr.d.ts +2 -0
  249. package/dist/commands/tree/tree.d.ts +2 -0
  250. package/dist/commands/true/true.d.ts +3 -0
  251. package/dist/commands/uniq/uniq.d.ts +2 -0
  252. package/dist/commands/wc/wc.d.ts +2 -0
  253. package/dist/commands/which/which.d.ts +2 -0
  254. package/dist/commands/xargs/xargs.d.ts +2 -0
  255. package/dist/fs-interface.d.ts +186 -0
  256. package/dist/fs.d.ts +39 -0
  257. package/dist/index.d.ts +12 -0
  258. package/dist/interpreter/arithmetic.d.ts +29 -0
  259. package/dist/interpreter/builtins/break.d.ts +6 -0
  260. package/dist/interpreter/builtins/cd.d.ts +6 -0
  261. package/dist/interpreter/builtins/continue.d.ts +6 -0
  262. package/dist/interpreter/builtins/declare.d.ts +29 -0
  263. package/dist/interpreter/builtins/eval.d.ts +9 -0
  264. package/dist/interpreter/builtins/exit.d.ts +5 -0
  265. package/dist/interpreter/builtins/export.d.ts +13 -0
  266. package/dist/interpreter/builtins/index.d.ts +36 -0
  267. package/dist/interpreter/builtins/let.d.ts +18 -0
  268. package/dist/interpreter/builtins/local.d.ts +6 -0
  269. package/dist/interpreter/builtins/read.d.ts +6 -0
  270. package/dist/interpreter/builtins/return.d.ts +6 -0
  271. package/dist/interpreter/builtins/set.d.ts +6 -0
  272. package/dist/interpreter/builtins/shift.d.ts +12 -0
  273. package/dist/interpreter/builtins/source.d.ts +6 -0
  274. package/dist/interpreter/builtins/unset.d.ts +12 -0
  275. package/dist/interpreter/builtins/variable-helpers.d.ts +30 -0
  276. package/dist/interpreter/conditionals.d.ts +17 -0
  277. package/dist/interpreter/control-flow.d.ts +21 -0
  278. package/dist/interpreter/errors.d.ts +107 -0
  279. package/dist/interpreter/expansion/analysis.d.ts +39 -0
  280. package/dist/interpreter/expansion/brace-range.d.ts +20 -0
  281. package/dist/interpreter/expansion/pattern.d.ts +22 -0
  282. package/dist/interpreter/expansion/variable.d.ts +27 -0
  283. package/dist/interpreter/expansion/word-split.d.ts +24 -0
  284. package/dist/interpreter/expansion.d.ts +27 -0
  285. package/dist/interpreter/functions.d.ts +12 -0
  286. package/dist/interpreter/helpers/array.d.ts +23 -0
  287. package/dist/interpreter/helpers/condition.d.ts +22 -0
  288. package/dist/interpreter/helpers/errors.d.ts +8 -0
  289. package/dist/interpreter/helpers/file-tests.d.ts +33 -0
  290. package/dist/interpreter/helpers/ifs.d.ts +43 -0
  291. package/dist/interpreter/helpers/loop.d.ts +24 -0
  292. package/dist/interpreter/helpers/numeric-compare.d.ts +13 -0
  293. package/dist/interpreter/helpers/readonly.d.ts +21 -0
  294. package/dist/interpreter/helpers/regex.d.ts +8 -0
  295. package/dist/interpreter/helpers/result.d.ts +54 -0
  296. package/dist/interpreter/helpers/statements.d.ts +20 -0
  297. package/dist/interpreter/helpers/string-compare.d.ts +22 -0
  298. package/dist/interpreter/helpers/string-tests.d.ts +13 -0
  299. package/dist/interpreter/helpers/variable-tests.d.ts +9 -0
  300. package/dist/interpreter/helpers/word-parts.d.ts +22 -0
  301. package/dist/interpreter/index.d.ts +3 -0
  302. package/dist/interpreter/interpreter.d.ts +61 -0
  303. package/dist/interpreter/redirections.d.ts +14 -0
  304. package/dist/interpreter/types.d.ts +68 -0
  305. package/dist/limits.d.ts +26 -0
  306. package/dist/network/allow-list/shared.d.ts +45 -0
  307. package/dist/network/allow-list.d.ts +51 -0
  308. package/dist/network/fetch.d.ts +25 -0
  309. package/dist/network/index.d.ts +7 -0
  310. package/dist/network/types.d.ts +85 -0
  311. package/dist/overlay-fs/OverlayFs.d.ts +87 -0
  312. package/dist/overlay-fs/index.d.ts +1 -0
  313. package/dist/parser/arithmetic-parser.d.ts +25 -0
  314. package/dist/parser/command-parser.d.ts +10 -0
  315. package/dist/parser/compound-parser.d.ts +14 -0
  316. package/dist/parser/conditional-parser.d.ts +8 -0
  317. package/dist/parser/expansion-parser.d.ts +10 -0
  318. package/dist/parser/lexer.d.ts +135 -0
  319. package/dist/parser/parser.d.ts +92 -0
  320. package/dist/parser/types.d.ts +23 -0
  321. package/dist/parser/word-parser.d.ts +33 -0
  322. package/dist/sandbox/Command.d.ts +28 -0
  323. package/dist/sandbox/Sandbox.d.ts +60 -0
  324. package/dist/sandbox/index.d.ts +2 -0
  325. package/dist/types.d.ts +80 -0
  326. package/dist/utils/args.d.ts +55 -0
  327. package/dist/utils/file-reader.d.ts +64 -0
  328. package/dist/utils/glob.d.ts +25 -0
  329. package/package.json +103 -0
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Control Flow Execution
3
+ *
4
+ * Handles control flow constructs:
5
+ * - if/elif/else
6
+ * - for loops
7
+ * - C-style for loops
8
+ * - while loops
9
+ * - until loops
10
+ * - case statements
11
+ * - break/continue
12
+ */
13
+ import type { CaseNode, CStyleForNode, ForNode, IfNode, UntilNode, WhileNode } from "../ast/types.js";
14
+ import type { ExecResult } from "../types.js";
15
+ import type { InterpreterContext } from "./types.js";
16
+ export declare function executeIf(ctx: InterpreterContext, node: IfNode): Promise<ExecResult>;
17
+ export declare function executeFor(ctx: InterpreterContext, node: ForNode): Promise<ExecResult>;
18
+ export declare function executeCStyleFor(ctx: InterpreterContext, node: CStyleForNode): Promise<ExecResult>;
19
+ export declare function executeWhile(ctx: InterpreterContext, node: WhileNode, stdin?: string): Promise<ExecResult>;
20
+ export declare function executeUntil(ctx: InterpreterContext, node: UntilNode): Promise<ExecResult>;
21
+ export declare function executeCase(ctx: InterpreterContext, node: CaseNode): Promise<ExecResult>;
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Control Flow Errors
3
+ *
4
+ * Error classes used to implement shell control flow:
5
+ * - break: Exit loops
6
+ * - continue: Skip to next iteration
7
+ * - return: Exit functions
8
+ * - errexit: Exit on error (set -e)
9
+ * - nounset: Error on unset variables (set -u)
10
+ *
11
+ * All control flow errors carry stdout/stderr to accumulate output
12
+ * as they propagate through the execution stack.
13
+ */
14
+ /**
15
+ * Base class for all control flow errors.
16
+ * Carries stdout/stderr to preserve output during propagation.
17
+ */
18
+ declare abstract class ControlFlowError extends Error {
19
+ stdout: string;
20
+ stderr: string;
21
+ constructor(message: string, stdout?: string, stderr?: string);
22
+ /**
23
+ * Prepend output from the current context before re-throwing.
24
+ */
25
+ prependOutput(stdout: string, stderr: string): void;
26
+ }
27
+ /**
28
+ * Error thrown when break is called to exit loops.
29
+ */
30
+ export declare class BreakError extends ControlFlowError {
31
+ levels: number;
32
+ readonly name = "BreakError";
33
+ constructor(levels?: number, stdout?: string, stderr?: string);
34
+ }
35
+ /**
36
+ * Error thrown when continue is called to skip to next iteration.
37
+ */
38
+ export declare class ContinueError extends ControlFlowError {
39
+ levels: number;
40
+ readonly name = "ContinueError";
41
+ constructor(levels?: number, stdout?: string, stderr?: string);
42
+ }
43
+ /**
44
+ * Error thrown when return is called to exit a function.
45
+ */
46
+ export declare class ReturnError extends ControlFlowError {
47
+ exitCode: number;
48
+ readonly name = "ReturnError";
49
+ constructor(exitCode?: number, stdout?: string, stderr?: string);
50
+ }
51
+ /**
52
+ * Error thrown when set -e (errexit) is enabled and a command fails.
53
+ */
54
+ export declare class ErrexitError extends ControlFlowError {
55
+ readonly exitCode: number;
56
+ readonly name = "ErrexitError";
57
+ constructor(exitCode: number, stdout?: string, stderr?: string);
58
+ }
59
+ /**
60
+ * Error thrown when set -u (nounset) is enabled and an unset variable is referenced.
61
+ */
62
+ export declare class NounsetError extends ControlFlowError {
63
+ varName: string;
64
+ readonly name = "NounsetError";
65
+ constructor(varName: string, stdout?: string);
66
+ }
67
+ /**
68
+ * Error thrown when exit builtin is called to terminate the script.
69
+ */
70
+ export declare class ExitError extends ControlFlowError {
71
+ readonly exitCode: number;
72
+ readonly name = "ExitError";
73
+ constructor(exitCode: number, stdout?: string, stderr?: string);
74
+ }
75
+ /**
76
+ * Error thrown for arithmetic expression errors (e.g., floating point, invalid syntax).
77
+ * Returns exit code 1 instead of 2 (syntax error).
78
+ */
79
+ export declare class ArithmeticError extends ControlFlowError {
80
+ readonly name = "ArithmeticError";
81
+ constructor(message: string, stdout?: string, stderr?: string);
82
+ }
83
+ /**
84
+ * Error thrown for bad substitution errors (e.g., ${#var:1:3}).
85
+ * Returns exit code 1.
86
+ */
87
+ export declare class BadSubstitutionError extends ControlFlowError {
88
+ readonly name = "BadSubstitutionError";
89
+ constructor(message: string, stdout?: string, stderr?: string);
90
+ }
91
+ /**
92
+ * Error thrown when execution limits are exceeded (recursion depth, command count, loop iterations).
93
+ * This should ALWAYS be thrown before JavaScript's native RangeError kicks in.
94
+ * Exit code 126 indicates a limit was exceeded.
95
+ */
96
+ export declare class ExecutionLimitError extends ControlFlowError {
97
+ readonly limitType: "recursion" | "commands" | "iterations";
98
+ readonly name = "ExecutionLimitError";
99
+ static readonly EXIT_CODE = 126;
100
+ constructor(message: string, limitType: "recursion" | "commands" | "iterations", stdout?: string, stderr?: string);
101
+ }
102
+ /**
103
+ * Type guard for errors that exit the current scope (return, break, continue).
104
+ * These need special handling vs errexit/nounset which terminate execution.
105
+ */
106
+ export declare function isScopeExitError(error: unknown): error is BreakError | ContinueError | ReturnError;
107
+ export {};
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Word Analysis
3
+ *
4
+ * Functions for analyzing word parts to determine:
5
+ * - Whether async execution is needed
6
+ * - What types of expansions are present
7
+ */
8
+ import type { ParameterExpansionPart, WordNode, WordPart } from "../../ast/types.js";
9
+ /**
10
+ * Check if a parameter expansion requires async execution
11
+ */
12
+ export declare function paramExpansionNeedsAsync(part: ParameterExpansionPart): boolean;
13
+ /**
14
+ * Check if a word part requires async execution
15
+ */
16
+ export declare function partNeedsAsync(part: WordPart): boolean;
17
+ /**
18
+ * Check if a word requires async execution
19
+ */
20
+ export declare function wordNeedsAsync(word: WordNode): boolean;
21
+ /**
22
+ * Check if a parameter expansion has quoted parts in its operation word
23
+ * e.g., ${v:-"AxBxC"} has a quoted default value
24
+ */
25
+ export declare function hasQuotedOperationWord(part: ParameterExpansionPart): boolean;
26
+ /**
27
+ * Result of analyzing word parts
28
+ */
29
+ export interface WordPartsAnalysis {
30
+ hasQuoted: boolean;
31
+ hasCommandSub: boolean;
32
+ hasArrayVar: boolean;
33
+ hasArrayAtExpansion: boolean;
34
+ hasParamExpansion: boolean;
35
+ }
36
+ /**
37
+ * Analyze word parts for expansion behavior
38
+ */
39
+ export declare function analyzeWordParts(parts: WordPart[]): WordPartsAnalysis;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Brace Range Expansion
3
+ *
4
+ * Handles numeric {1..10} and character {a..z} range expansion.
5
+ * These are pure functions with no external dependencies.
6
+ */
7
+ /**
8
+ * Result of a brace range expansion.
9
+ * Either contains expanded values or a literal fallback for invalid ranges.
10
+ */
11
+ export interface BraceRangeResult {
12
+ expanded: string[] | null;
13
+ literal: string;
14
+ }
15
+ /**
16
+ * Unified brace range expansion helper.
17
+ * Handles both numeric and character ranges, returning either expanded values
18
+ * or a literal string for invalid ranges.
19
+ */
20
+ export declare function expandBraceRange(start: number | string, end: number | string, step: number | undefined, startStr?: string, endStr?: string): BraceRangeResult;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Pattern Matching
3
+ *
4
+ * Converts shell glob patterns to regex equivalents for pattern matching
5
+ * in parameter expansion (${var%pattern}, ${var/pattern/replacement}, etc.)
6
+ * and case statements.
7
+ *
8
+ * ## Error Handling
9
+ *
10
+ * This module follows bash's behavior for invalid patterns:
11
+ * - Invalid character ranges (e.g., `[z-a]`) result in regex compilation failure
12
+ * - Unknown POSIX classes (e.g., `[:foo:]`) produce empty match groups
13
+ * - Unclosed character classes (`[abc`) are treated as literal `[`
14
+ *
15
+ * Callers should wrap regex compilation in try/catch to handle invalid patterns.
16
+ */
17
+ /**
18
+ * Convert a shell glob pattern to a regex string.
19
+ * @param pattern - The glob pattern (*, ?, [...])
20
+ * @param greedy - Whether * should be greedy (true for suffix matching, false for prefix)
21
+ */
22
+ export declare function patternToRegex(pattern: string, greedy: boolean): string;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Variable Access
3
+ *
4
+ * Handles variable value retrieval, including:
5
+ * - Special variables ($?, $$, $#, $@, $*, $0)
6
+ * - Array access (${arr[0]}, ${arr[@]}, ${arr[*]})
7
+ * - Positional parameters ($1, $2, ...)
8
+ * - Regular variables
9
+ */
10
+ import type { InterpreterContext } from "../types.js";
11
+ /**
12
+ * Get all elements of an array stored as arrayName_0, arrayName_1, etc.
13
+ * Returns an array of [index/key, value] tuples, sorted by index/key.
14
+ * For associative arrays, uses string keys.
15
+ */
16
+ export declare function getArrayElements(ctx: InterpreterContext, arrayName: string): Array<[number | string, string]>;
17
+ /**
18
+ * Check if a variable is an array (has elements stored as name_0, name_1, etc.)
19
+ */
20
+ export declare function isArray(ctx: InterpreterContext, name: string): boolean;
21
+ /**
22
+ * Get the value of a variable, optionally checking nounset.
23
+ * @param ctx - The interpreter context
24
+ * @param name - The variable name
25
+ * @param checkNounset - Whether to check for nounset (default true)
26
+ */
27
+ export declare function getVariable(ctx: InterpreterContext, name: string, checkNounset?: boolean, _insideDoubleQuotes?: boolean): string;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Word Splitting
3
+ *
4
+ * IFS-based word splitting for unquoted expansions.
5
+ */
6
+ import type { WordPart } from "../../ast/types.js";
7
+ import type { InterpreterContext } from "../types.js";
8
+ /**
9
+ * Type for the expandPart function that will be injected
10
+ */
11
+ export type ExpandPartFn = (ctx: InterpreterContext, part: WordPart) => Promise<string>;
12
+ /**
13
+ * Smart word splitting that respects expansion boundaries.
14
+ *
15
+ * E.g., with IFS=x: ${v:-AxBxC}x should give "A B Cx" (literal x attaches to last field)
16
+ * E.g., with IFS=x: y${v:-AxBxC}z should give "yA B Cz" (literals attach to first/last fields)
17
+ *
18
+ * @param ctx - Interpreter context
19
+ * @param wordParts - Word parts to expand and split
20
+ * @param _ifsChars - IFS characters (unused, kept for API compatibility)
21
+ * @param ifsPattern - Regex-escaped IFS pattern for splitting
22
+ * @param expandPartFn - Function to expand individual parts (injected to avoid circular deps)
23
+ */
24
+ export declare function smartWordSplit(ctx: InterpreterContext, wordParts: WordPart[], _ifsChars: string, ifsPattern: string, expandPartFn: ExpandPartFn): Promise<string[]>;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Word Expansion
3
+ *
4
+ * Handles shell word expansion including:
5
+ * - Variable expansion ($VAR, ${VAR})
6
+ * - Command substitution $(...)
7
+ * - Arithmetic expansion $((...))
8
+ * - Tilde expansion (~)
9
+ * - Brace expansion {a,b,c}
10
+ * - Glob expansion (*, ?, [...])
11
+ */
12
+ import type { WordNode } from "../ast/types.js";
13
+ import type { InterpreterContext } from "./types.js";
14
+ export { getArrayElements, getVariable } from "./expansion/variable.js";
15
+ /**
16
+ * Check if an entire word is fully quoted
17
+ */
18
+ export declare function isWordFullyQuoted(word: WordNode): boolean;
19
+ /**
20
+ * Escape glob metacharacters in a string for literal matching
21
+ */
22
+ export declare function escapeGlobChars(str: string): string;
23
+ export declare function expandWord(ctx: InterpreterContext, word: WordNode): Promise<string>;
24
+ export declare function expandWordWithGlob(ctx: InterpreterContext, word: WordNode): Promise<{
25
+ values: string[];
26
+ quoted: boolean;
27
+ }>;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Function Handling
3
+ *
4
+ * Handles shell function definition and invocation:
5
+ * - Function definition (adding to function table)
6
+ * - Function calls (with positional parameters and local scopes)
7
+ */
8
+ import type { FunctionDefNode } from "../ast/types.js";
9
+ import type { ExecResult } from "../types.js";
10
+ import type { InterpreterContext } from "./types.js";
11
+ export declare function executeFunctionDef(ctx: InterpreterContext, node: FunctionDefNode): ExecResult;
12
+ export declare function callFunction(ctx: InterpreterContext, func: FunctionDefNode, args: string[]): Promise<ExecResult>;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Array helper functions for the interpreter.
3
+ */
4
+ import type { InterpreterContext } from "../types.js";
5
+ /**
6
+ * Get all indices of an array, sorted in ascending order.
7
+ * Arrays are stored as `name_0`, `name_1`, etc. in the environment.
8
+ */
9
+ export declare function getArrayIndices(ctx: InterpreterContext, arrayName: string): number[];
10
+ /**
11
+ * Clear all elements of an array from the environment.
12
+ */
13
+ export declare function clearArray(ctx: InterpreterContext, arrayName: string): void;
14
+ /**
15
+ * Get all keys of an associative array.
16
+ * For associative arrays, keys are stored as `name_key` where key is a string.
17
+ */
18
+ export declare function getAssocArrayKeys(ctx: InterpreterContext, arrayName: string): string[];
19
+ /**
20
+ * Remove surrounding quotes from a key string.
21
+ * Handles 'key' and "key" → key
22
+ */
23
+ export declare function unquoteKey(key: string): string;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Condition execution helper for the interpreter.
3
+ *
4
+ * Handles executing condition statements with proper inCondition state management.
5
+ * Used by if, while, and until loops.
6
+ */
7
+ import type { StatementNode } from "../../ast/types.js";
8
+ import type { InterpreterContext } from "../types.js";
9
+ export interface ConditionResult {
10
+ stdout: string;
11
+ stderr: string;
12
+ exitCode: number;
13
+ }
14
+ /**
15
+ * Execute condition statements with inCondition flag set.
16
+ * This prevents errexit from triggering during condition evaluation.
17
+ *
18
+ * @param ctx - Interpreter context
19
+ * @param statements - Condition statements to execute
20
+ * @returns Accumulated stdout, stderr, and final exit code
21
+ */
22
+ export declare function executeCondition(ctx: InterpreterContext, statements: StatementNode[]): Promise<ConditionResult>;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Error helper functions for the interpreter.
3
+ */
4
+ /**
5
+ * Extract message from an unknown error value.
6
+ * Handles both Error instances and other thrown values.
7
+ */
8
+ export declare function getErrorMessage(error: unknown): string;
@@ -0,0 +1,33 @@
1
+ import type { InterpreterContext } from "../types.js";
2
+ /**
3
+ * File test operators supported by bash
4
+ * Unary operators that test file properties
5
+ */
6
+ declare const FILE_TEST_OPERATORS: readonly ["-e", "-a", "-f", "-d", "-r", "-w", "-x", "-s", "-L", "-h", "-k", "-g", "-u", "-G", "-O", "-b", "-c", "-p", "-S", "-t", "-N"];
7
+ export type FileTestOperator = (typeof FILE_TEST_OPERATORS)[number];
8
+ export declare function isFileTestOperator(op: string): op is FileTestOperator;
9
+ /**
10
+ * Evaluates a file test operator (-e, -f, -d, etc.) against a path.
11
+ * Returns a boolean result.
12
+ *
13
+ * @param ctx - Interpreter context with filesystem access
14
+ * @param operator - The file test operator (e.g., "-f", "-d", "-e")
15
+ * @param operand - The path to test (will be resolved relative to cwd)
16
+ */
17
+ export declare function evaluateFileTest(ctx: InterpreterContext, operator: string, operand: string): Promise<boolean>;
18
+ /**
19
+ * Binary file test operators for comparing two files
20
+ */
21
+ declare const BINARY_FILE_TEST_OPERATORS: readonly ["-nt", "-ot", "-ef"];
22
+ export type BinaryFileTestOperator = (typeof BINARY_FILE_TEST_OPERATORS)[number];
23
+ export declare function isBinaryFileTestOperator(op: string): op is BinaryFileTestOperator;
24
+ /**
25
+ * Evaluates a binary file test operator (-nt, -ot, -ef) comparing two files.
26
+ *
27
+ * @param ctx - Interpreter context with filesystem access
28
+ * @param operator - The operator (-nt, -ot, -ef)
29
+ * @param left - Left operand (file path)
30
+ * @param right - Right operand (file path)
31
+ */
32
+ export declare function evaluateBinaryFileTest(ctx: InterpreterContext, operator: string, left: string, right: string): Promise<boolean>;
33
+ export {};
@@ -0,0 +1,43 @@
1
+ /**
2
+ * IFS (Internal Field Separator) Handling
3
+ *
4
+ * Centralized utilities for IFS-based word splitting used by:
5
+ * - Word expansion (unquoted variable expansion)
6
+ * - read builtin
7
+ * - ${!prefix*} and ${!arr[*]} expansions
8
+ */
9
+ /**
10
+ * Get the effective IFS value from environment.
11
+ * Returns DEFAULT_IFS if IFS is undefined, or the actual value (including empty string).
12
+ */
13
+ export declare function getIfs(env: Record<string, string>): string;
14
+ /**
15
+ * Check if IFS is set to empty string (disables word splitting).
16
+ */
17
+ export declare function isIfsEmpty(env: Record<string, string>): boolean;
18
+ /**
19
+ * Build a regex-safe pattern from IFS characters for use in character classes.
20
+ * E.g., for IFS=" \t\n", returns " \\t\\n" (escaped for [pattern] use)
21
+ */
22
+ export declare function buildIfsCharClassPattern(ifs: string): string;
23
+ /**
24
+ * Get the first character of IFS (used for joining with $* and ${!prefix*}).
25
+ * Returns space if IFS is undefined, empty string if IFS is empty.
26
+ */
27
+ export declare function getIfsSeparator(env: Record<string, string>): string;
28
+ /**
29
+ * Split a string by IFS, handling leading/trailing IFS properly.
30
+ * Returns words and their start positions in the original string.
31
+ *
32
+ * @param value - String to split
33
+ * @param ifs - IFS characters to split on
34
+ * @returns Object with words array and wordStarts array
35
+ */
36
+ export declare function splitByIfs(value: string, ifs: string): {
37
+ words: string[];
38
+ wordStarts: number[];
39
+ };
40
+ /**
41
+ * Strip trailing IFS characters from a string.
42
+ */
43
+ export declare function stripTrailingIfs(value: string, ifs: string): string;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Loop Error Handling Helpers
3
+ *
4
+ * Consolidates the repeated error handling logic used in all loop constructs
5
+ * (for, c-style for, while, until).
6
+ */
7
+ export type LoopAction = "break" | "continue" | "rethrow" | "error";
8
+ export interface LoopErrorResult {
9
+ action: LoopAction;
10
+ stdout: string;
11
+ stderr: string;
12
+ exitCode?: number;
13
+ error?: unknown;
14
+ }
15
+ /**
16
+ * Handle errors thrown during loop body execution.
17
+ *
18
+ * @param error - The caught error
19
+ * @param stdout - Current accumulated stdout
20
+ * @param stderr - Current accumulated stderr
21
+ * @param loopDepth - Current loop nesting depth from ctx.state.loopDepth
22
+ * @returns Result indicating what action the loop should take
23
+ */
24
+ export declare function handleLoopError(error: unknown, stdout: string, stderr: string, loopDepth: number): LoopErrorResult;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Numeric comparison helper for conditionals.
3
+ * Handles -eq, -ne, -lt, -le, -gt, -ge operators.
4
+ */
5
+ export type NumericOp = "-eq" | "-ne" | "-lt" | "-le" | "-gt" | "-ge";
6
+ /**
7
+ * Check if an operator is a numeric comparison operator.
8
+ */
9
+ export declare function isNumericOp(op: string): op is NumericOp;
10
+ /**
11
+ * Compare two numbers using a numeric comparison operator.
12
+ */
13
+ export declare function compareNumeric(op: NumericOp, left: number, right: number): boolean;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Readonly variable helpers.
3
+ *
4
+ * Consolidates readonly variable logic used in declare, export, local, etc.
5
+ */
6
+ import type { ExecResult } from "../../types.js";
7
+ import type { InterpreterContext } from "../types.js";
8
+ /**
9
+ * Mark a variable as readonly.
10
+ */
11
+ export declare function markReadonly(ctx: InterpreterContext, name: string): void;
12
+ /**
13
+ * Check if a variable is readonly and return an error if so.
14
+ * Returns null if the variable is not readonly (can be modified).
15
+ *
16
+ * @param ctx - Interpreter context
17
+ * @param name - Variable name
18
+ * @param command - Command name for error message (default: "bash")
19
+ * @returns Error result if readonly, null otherwise
20
+ */
21
+ export declare function checkReadonlyError(ctx: InterpreterContext, name: string, command?: string): ExecResult | null;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Regex helper functions for the interpreter.
3
+ */
4
+ /**
5
+ * Escape a string for use as a literal in a regex pattern.
6
+ * All regex special characters are escaped.
7
+ */
8
+ export declare function escapeRegex(str: string): string;
@@ -0,0 +1,54 @@
1
+ /**
2
+ * ExecResult factory functions for cleaner code.
3
+ *
4
+ * These helpers reduce verbosity and improve readability when
5
+ * constructing ExecResult objects throughout the interpreter.
6
+ */
7
+ import type { ExecResult } from "../../types.js";
8
+ /**
9
+ * A successful result with no output.
10
+ * Use this for commands that succeed silently.
11
+ */
12
+ export declare const OK: ExecResult;
13
+ /**
14
+ * Create a successful result with optional stdout.
15
+ *
16
+ * @param stdout - Output to include (default: "")
17
+ * @returns ExecResult with exitCode 0
18
+ */
19
+ export declare function success(stdout?: string): ExecResult;
20
+ /**
21
+ * Create a failure result with stderr message.
22
+ *
23
+ * @param stderr - Error message to include
24
+ * @param exitCode - Exit code (default: 1)
25
+ * @returns ExecResult with the specified exitCode
26
+ */
27
+ export declare function failure(stderr: string, exitCode?: number): ExecResult;
28
+ /**
29
+ * Create a result with all fields specified.
30
+ *
31
+ * @param stdout - Standard output
32
+ * @param stderr - Standard error
33
+ * @param exitCode - Exit code
34
+ * @returns ExecResult with all fields
35
+ */
36
+ export declare function result(stdout: string, stderr: string, exitCode: number): ExecResult;
37
+ /**
38
+ * Convert a boolean test result to an ExecResult.
39
+ * Useful for test/conditional commands where true = exit 0, false = exit 1.
40
+ *
41
+ * @param passed - Boolean test result
42
+ * @returns ExecResult with exitCode 0 if passed, 1 otherwise
43
+ */
44
+ export declare function testResult(passed: boolean): ExecResult;
45
+ /**
46
+ * Throw an ExecutionLimitError for execution limits (recursion, iterations, commands).
47
+ *
48
+ * @param message - Error message describing the limit exceeded
49
+ * @param limitType - Type of limit exceeded
50
+ * @param stdout - Accumulated stdout to include
51
+ * @param stderr - Accumulated stderr to include
52
+ * @throws ExecutionLimitError always
53
+ */
54
+ export declare function throwExecutionLimit(message: string, limitType: "recursion" | "iterations" | "commands", stdout?: string, stderr?: string): never;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Statement execution helpers for the interpreter.
3
+ *
4
+ * Consolidates the common pattern of executing a list of statements
5
+ * and accumulating their output.
6
+ */
7
+ import type { StatementNode } from "../../ast/types.js";
8
+ import type { ExecResult } from "../../types.js";
9
+ import type { InterpreterContext } from "../types.js";
10
+ /**
11
+ * Execute a list of statements and accumulate their output.
12
+ * Handles scope exit errors (break, continue, return) and errexit properly.
13
+ *
14
+ * @param ctx - Interpreter context
15
+ * @param statements - Statements to execute
16
+ * @param initialStdout - Initial stdout to prepend (default "")
17
+ * @param initialStderr - Initial stderr to prepend (default "")
18
+ * @returns Accumulated stdout, stderr, and final exit code
19
+ */
20
+ export declare function executeStatements(ctx: InterpreterContext, statements: StatementNode[], initialStdout?: string, initialStderr?: string): Promise<ExecResult>;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * String comparison helpers for conditionals.
3
+ *
4
+ * Consolidates string comparison logic (=, ==, !=) used in:
5
+ * - [[ ]] conditional expressions (with optional pattern matching)
6
+ * - test/[ ] command (literal comparison only)
7
+ */
8
+ export type StringCompareOp = "=" | "==" | "!=";
9
+ /**
10
+ * Check if an operator is a string comparison operator.
11
+ */
12
+ export declare function isStringCompareOp(op: string): op is StringCompareOp;
13
+ /**
14
+ * Compare two strings using the specified operator.
15
+ *
16
+ * @param op - The comparison operator (=, ==, !=)
17
+ * @param left - Left operand
18
+ * @param right - Right operand
19
+ * @param usePattern - If true, use glob pattern matching for equality (default: false)
20
+ * @returns True if the comparison succeeds
21
+ */
22
+ export declare function compareStrings(op: StringCompareOp, left: string, right: string, usePattern?: boolean): boolean;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * String test helper for conditionals.
3
+ * Handles -z (empty) and -n (non-empty) operators.
4
+ */
5
+ export type StringTestOp = "-z" | "-n";
6
+ /**
7
+ * Check if an operator is a string test operator.
8
+ */
9
+ export declare function isStringTestOp(op: string): op is StringTestOp;
10
+ /**
11
+ * Evaluate a string test operator.
12
+ */
13
+ export declare function evaluateStringTest(op: StringTestOp, value: string): boolean;
@@ -0,0 +1,9 @@
1
+ import type { InterpreterContext } from "../types.js";
2
+ /**
3
+ * Evaluates the -v (variable is set) test.
4
+ * Handles both simple variables and array element access with negative indices.
5
+ *
6
+ * @param ctx - Interpreter context with environment variables
7
+ * @param operand - The variable name to test, may include array subscript (e.g., "arr[0]", "arr[-1]")
8
+ */
9
+ export declare function evaluateVariableTest(ctx: InterpreterContext, operand: string): boolean;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Word Part Helper Functions
3
+ *
4
+ * Provides common operations on WordPart types to eliminate duplication
5
+ * across expansion.ts and word-parser.ts.
6
+ */
7
+ import type { WordPart } from "../../ast/types.js";
8
+ /**
9
+ * Get the literal string value from a word part.
10
+ * Returns the value for Literal, SingleQuoted, and Escaped parts.
11
+ * Returns null for complex parts that require expansion.
12
+ */
13
+ export declare function getLiteralValue(part: WordPart): string | null;
14
+ /**
15
+ * Check if a word part is "quoted" - meaning glob characters should be treated literally.
16
+ * A part is quoted if it is:
17
+ * - SingleQuoted
18
+ * - Escaped
19
+ * - DoubleQuoted (entirely quoted)
20
+ * - Literal with empty value (doesn't affect quoting)
21
+ */
22
+ export declare function isQuotedPart(part: WordPart): boolean;