just-bash 2.5.5 → 2.7.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 (292) hide show
  1. package/README.md +3 -3
  2. package/dist/AGENTS.md +3 -3
  3. package/dist/ast/types.d.ts +100 -11
  4. package/dist/bin/chunks/alias-EGIS5LUE.js +7 -0
  5. package/dist/bin/chunks/awk2-GFEJOWML.js +21 -0
  6. package/dist/bin/chunks/bash-PGDTHIM2.js +6 -0
  7. package/dist/bin/chunks/chmod-TYLTHXFR.js +9 -0
  8. package/dist/bin/chunks/chunk-D5WP4CKS.js +3 -0
  9. package/dist/bin/chunks/chunk-FSAGDARS.js +74 -0
  10. package/dist/bin/chunks/chunk-FSZWFMB4.js +16 -0
  11. package/dist/bin/chunks/chunk-IRUD2E3M.js +17 -0
  12. package/dist/bin/chunks/chunk-K5IXNHO5.js +8 -0
  13. package/dist/bin/chunks/chunk-KD3EODLB.js +6 -0
  14. package/dist/bin/{shell/chunks/echo-WSKTON6U.js → chunks/echo-7I42V66Q.js} +2 -2
  15. package/dist/bin/chunks/env-7A4MH7BJ.js +9 -0
  16. package/dist/bin/chunks/expansion-BOR3ELLC.js +2 -0
  17. package/dist/bin/{shell/chunks/find-CBEJ35BR.js → chunks/find-PHDZK64M.js} +1 -1
  18. package/dist/bin/{shell/chunks/grep-IIVQXFNI.js → chunks/grep-VX7MJMVN.js} +2 -2
  19. package/dist/bin/chunks/{head-DYK37Z24.js → head-TJHLLIMR.js} +1 -1
  20. package/dist/bin/{shell/chunks/jq-XXZPU5CA.js → chunks/jq-RGZHJNXC.js} +1 -1
  21. package/dist/bin/chunks/od-KRKGC2U3.js +5 -0
  22. package/dist/bin/chunks/printf-YPXD4CRE.js +15 -0
  23. package/dist/bin/chunks/pwd-L26WH2K4.js +3 -0
  24. package/dist/bin/chunks/python3-JGT65AEB.js +14 -0
  25. package/dist/bin/{shell/chunks/rg-Q4OTJOEF.js → chunks/rg-RSDLLECO.js} +1 -1
  26. package/dist/bin/chunks/rmdir-GOODLY5W.js +14 -0
  27. package/dist/bin/chunks/sed-JPDTWF4W.js +100 -0
  28. package/dist/bin/{shell/chunks/tail-BES27CZT.js → chunks/tail-YAUIERGN.js} +1 -1
  29. package/dist/bin/{shell/chunks/tar-C27YYUAS.js → chunks/tar-LFENC54A.js} +7 -7
  30. package/dist/bin/chunks/time-37F5EBPK.js +14 -0
  31. package/dist/bin/chunks/touch-IBPHJBM3.js +7 -0
  32. package/dist/bin/chunks/wc-SAOHEZYP.js +6 -0
  33. package/dist/bin/chunks/{which-73KOOLC6.js → which-FCDFBOMN.js} +1 -1
  34. package/dist/bin/chunks/whoami-JVLUNKSG.js +3 -0
  35. package/dist/bin/chunks/worker.js +1038 -0
  36. package/dist/bin/{shell/chunks/xan-6K2NGTHM.js → chunks/xan-5HNHTFMB.js} +19 -19
  37. package/dist/bin/chunks/{yq-MF2SNFGL.js → yq-PFV4T2PV.js} +1 -1
  38. package/dist/bin/just-bash.js +659 -135
  39. package/dist/bin/shell/chunks/alias-EGIS5LUE.js +7 -0
  40. package/dist/bin/shell/chunks/awk2-GFEJOWML.js +21 -0
  41. package/dist/bin/shell/chunks/bash-PGDTHIM2.js +6 -0
  42. package/dist/bin/shell/chunks/chmod-TYLTHXFR.js +9 -0
  43. package/dist/bin/shell/chunks/chunk-D5WP4CKS.js +3 -0
  44. package/dist/bin/shell/chunks/chunk-FSAGDARS.js +74 -0
  45. package/dist/bin/shell/chunks/chunk-FSZWFMB4.js +16 -0
  46. package/dist/bin/shell/chunks/chunk-IRUD2E3M.js +17 -0
  47. package/dist/bin/shell/chunks/chunk-K5IXNHO5.js +8 -0
  48. package/dist/bin/shell/chunks/chunk-KD3EODLB.js +6 -0
  49. package/dist/bin/{chunks/echo-WSKTON6U.js → shell/chunks/echo-7I42V66Q.js} +2 -2
  50. package/dist/bin/shell/chunks/env-7A4MH7BJ.js +9 -0
  51. package/dist/bin/shell/chunks/expansion-BOR3ELLC.js +2 -0
  52. package/dist/bin/{chunks/find-CBEJ35BR.js → shell/chunks/find-PHDZK64M.js} +1 -1
  53. package/dist/bin/{chunks/grep-IIVQXFNI.js → shell/chunks/grep-VX7MJMVN.js} +2 -2
  54. package/dist/bin/shell/chunks/{head-DYK37Z24.js → head-TJHLLIMR.js} +1 -1
  55. package/dist/bin/{chunks/jq-XXZPU5CA.js → shell/chunks/jq-RGZHJNXC.js} +1 -1
  56. package/dist/bin/shell/chunks/od-KRKGC2U3.js +5 -0
  57. package/dist/bin/shell/chunks/printf-YPXD4CRE.js +15 -0
  58. package/dist/bin/shell/chunks/pwd-L26WH2K4.js +3 -0
  59. package/dist/bin/shell/chunks/python3-JGT65AEB.js +14 -0
  60. package/dist/bin/{chunks/rg-Q4OTJOEF.js → shell/chunks/rg-RSDLLECO.js} +1 -1
  61. package/dist/bin/shell/chunks/rmdir-GOODLY5W.js +14 -0
  62. package/dist/bin/shell/chunks/sed-JPDTWF4W.js +100 -0
  63. package/dist/bin/{chunks/tail-BES27CZT.js → shell/chunks/tail-YAUIERGN.js} +1 -1
  64. package/dist/bin/{chunks/tar-C27YYUAS.js → shell/chunks/tar-LFENC54A.js} +7 -7
  65. package/dist/bin/shell/chunks/time-37F5EBPK.js +14 -0
  66. package/dist/bin/shell/chunks/touch-IBPHJBM3.js +7 -0
  67. package/dist/bin/shell/chunks/wc-SAOHEZYP.js +6 -0
  68. package/dist/bin/shell/chunks/{which-73KOOLC6.js → which-FCDFBOMN.js} +1 -1
  69. package/dist/bin/shell/chunks/whoami-JVLUNKSG.js +3 -0
  70. package/dist/bin/{chunks/xan-6K2NGTHM.js → shell/chunks/xan-5HNHTFMB.js} +19 -19
  71. package/dist/bin/shell/chunks/{yq-MF2SNFGL.js → yq-PFV4T2PV.js} +1 -1
  72. package/dist/bin/shell/shell.js +664 -140
  73. package/dist/bundle/browser.js +1251 -606
  74. package/dist/bundle/chunks/alias-ATFBB6D2.js +6 -0
  75. package/dist/bundle/chunks/awk2-6FBZTP57.js +20 -0
  76. package/dist/bundle/chunks/bash-OLRNM52U.js +5 -0
  77. package/dist/bundle/chunks/chmod-ODWUR7E6.js +8 -0
  78. package/dist/bundle/chunks/chunk-3AWP5CWK.js +73 -0
  79. package/dist/bundle/chunks/chunk-CXEWLFNE.js +16 -0
  80. package/dist/bundle/chunks/chunk-CZPA5RBA.js +5 -0
  81. package/dist/bundle/chunks/chunk-EEXR5ZDP.js +2 -0
  82. package/dist/bundle/chunks/chunk-HDQ56CKY.js +15 -0
  83. package/dist/bundle/chunks/chunk-PSW6BMXW.js +7 -0
  84. package/dist/bundle/chunks/{echo-VUHWYV6L.js → echo-6S7WE7XB.js} +2 -2
  85. package/dist/bundle/chunks/env-2UI6XINU.js +8 -0
  86. package/dist/bundle/chunks/expansion-RIGCFEMA.js +1 -0
  87. package/dist/bundle/chunks/{find-ACOAWALE.js → find-YGMSVGUV.js} +1 -1
  88. package/dist/bundle/chunks/{grep-ACVE42JK.js → grep-NIC6JNLH.js} +2 -2
  89. package/dist/bundle/chunks/{head-FZ6IQHYW.js → head-SA7P5NJ7.js} +1 -1
  90. package/dist/bundle/chunks/{jq-3YU5HRKE.js → jq-RLRYRPOJ.js} +1 -1
  91. package/dist/bundle/chunks/od-3FPDPLWJ.js +4 -0
  92. package/dist/bundle/chunks/printf-66XGXFCD.js +14 -0
  93. package/dist/bundle/chunks/pwd-S4NVAMC4.js +2 -0
  94. package/dist/bundle/chunks/python3-3OP7EKER.js +13 -0
  95. package/dist/bundle/chunks/{rg-YLZJWCEJ.js → rg-SRMB7L6G.js} +1 -1
  96. package/dist/bundle/chunks/rmdir-XFQE4ZYV.js +13 -0
  97. package/dist/bundle/chunks/sed-IV6HLDXU.js +99 -0
  98. package/dist/bundle/chunks/{tail-PD4RZR6J.js → tail-52LRAWXT.js} +1 -1
  99. package/dist/bundle/chunks/{tar-QWBXMF7K.js → tar-LWIHPMT6.js} +7 -7
  100. package/dist/bundle/chunks/time-UWXBG6CS.js +13 -0
  101. package/dist/bundle/chunks/touch-TDTEBHHI.js +6 -0
  102. package/dist/bundle/chunks/wc-HE5XARI4.js +5 -0
  103. package/dist/bundle/chunks/{which-M5MQ6QXQ.js → which-UBLRBDHN.js} +1 -1
  104. package/dist/bundle/chunks/whoami-YUDAIS32.js +2 -0
  105. package/dist/bundle/chunks/worker.js +1038 -0
  106. package/dist/bundle/chunks/{xan-2R2APJJ4.js → xan-A6VPI4HJ.js} +19 -19
  107. package/dist/bundle/chunks/{yq-KANM4MD2.js → yq-L665QPQU.js} +1 -1
  108. package/dist/bundle/index.js +657 -133
  109. package/dist/commands/awk/ast.d.ts +1 -0
  110. package/dist/commands/awk/interpreter/context.d.ts +14 -0
  111. package/dist/commands/awk/interpreter/interpreter.d.ts +2 -0
  112. package/dist/commands/awk/interpreter/{helpers.d.ts → type-coercion.d.ts} +4 -1
  113. package/dist/commands/awk/parser2-print.d.ts +35 -0
  114. package/dist/commands/awk/parser2.d.ts +42 -34
  115. package/dist/commands/printf/strftime.d.ts +9 -0
  116. package/dist/commands/python3/fs-bridge-handler.d.ts +50 -0
  117. package/dist/commands/python3/protocol.d.ts +138 -0
  118. package/dist/commands/python3/python3.d.ts +11 -0
  119. package/dist/commands/python3/sync-fs-backend.d.ts +59 -0
  120. package/dist/commands/python3/worker.d.ts +16 -0
  121. package/dist/commands/query-engine/builtins/array-builtins.d.ts +20 -0
  122. package/dist/commands/query-engine/builtins/control-builtins.d.ts +18 -0
  123. package/dist/commands/query-engine/builtins/date-builtins.d.ts +15 -0
  124. package/dist/commands/query-engine/builtins/format-builtins.d.ts +11 -0
  125. package/dist/commands/query-engine/builtins/index-builtins.d.ts +16 -0
  126. package/dist/commands/query-engine/builtins/index.d.ts +17 -0
  127. package/dist/commands/query-engine/builtins/math-builtins.d.ts +15 -0
  128. package/dist/commands/query-engine/builtins/navigation-builtins.d.ts +18 -0
  129. package/dist/commands/query-engine/builtins/object-builtins.d.ts +15 -0
  130. package/dist/commands/query-engine/builtins/path-builtins.d.ts +20 -0
  131. package/dist/commands/query-engine/builtins/sql-builtins.d.ts +16 -0
  132. package/dist/commands/query-engine/builtins/string-builtins.d.ts +15 -0
  133. package/dist/commands/query-engine/builtins/type-builtins.d.ts +11 -0
  134. package/dist/commands/query-engine/evaluator.d.ts +10 -2
  135. package/dist/commands/query-engine/parser-types.d.ts +171 -0
  136. package/dist/commands/query-engine/parser.d.ts +2 -132
  137. package/dist/commands/query-engine/path-operations.d.ts +15 -0
  138. package/dist/commands/query-engine/value-operations.d.ts +39 -0
  139. package/dist/commands/registry.d.ts +1 -1
  140. package/dist/commands/rmdir/rmdir.d.ts +2 -0
  141. package/dist/commands/sed/lexer.d.ts +12 -0
  142. package/dist/commands/sed/parser.d.ts +9 -0
  143. package/dist/commands/sed/sed-regex.d.ts +23 -0
  144. package/dist/commands/sed/types.d.ts +13 -1
  145. package/dist/commands/tar/tar-options.d.ts +36 -0
  146. package/dist/commands/time/time.d.ts +25 -0
  147. package/dist/commands/whoami/whoami.d.ts +9 -0
  148. package/dist/commands/xan/moonblade-tokenizer.d.ts +25 -0
  149. package/dist/fs/in-memory-fs/in-memory-fs.d.ts +12 -0
  150. package/dist/fs/interface.d.ts +16 -0
  151. package/dist/fs/mountable-fs/mountable-fs.d.ts +12 -0
  152. package/dist/fs/overlay-fs/overlay-fs.d.ts +13 -1
  153. package/dist/fs/read-write-fs/read-write-fs.d.ts +13 -1
  154. package/dist/interpreter/alias-expansion.d.ts +23 -0
  155. package/dist/interpreter/arithmetic.d.ts +1 -6
  156. package/dist/interpreter/assignment-expansion.d.ts +24 -0
  157. package/dist/interpreter/builtin-dispatch.d.ts +39 -0
  158. package/dist/interpreter/builtins/compgen.d.ts +26 -0
  159. package/dist/interpreter/builtins/complete.d.ts +17 -0
  160. package/dist/interpreter/builtins/compopt.d.ts +28 -0
  161. package/dist/interpreter/builtins/declare-array-parsing.d.ts +14 -0
  162. package/dist/interpreter/builtins/declare-print.d.ts +39 -0
  163. package/dist/interpreter/builtins/declare.d.ts +10 -4
  164. package/dist/interpreter/builtins/dirs.d.ts +29 -0
  165. package/dist/interpreter/builtins/eval.d.ts +1 -1
  166. package/dist/interpreter/builtins/export.d.ts +1 -0
  167. package/dist/interpreter/builtins/getopts.d.ts +18 -0
  168. package/dist/interpreter/builtins/hash.d.ts +19 -0
  169. package/dist/interpreter/builtins/help.d.ts +12 -0
  170. package/dist/interpreter/builtins/index.d.ts +9 -1
  171. package/dist/interpreter/builtins/local.d.ts +1 -1
  172. package/dist/interpreter/builtins/read.d.ts +1 -1
  173. package/dist/interpreter/builtins/set.d.ts +3 -0
  174. package/dist/interpreter/builtins/shift.d.ts +3 -0
  175. package/dist/interpreter/builtins/shopt.d.ts +7 -0
  176. package/dist/interpreter/builtins/unset.d.ts +5 -1
  177. package/dist/interpreter/builtins/variable-assignment.d.ts +66 -0
  178. package/dist/interpreter/command-resolution.d.ts +43 -0
  179. package/dist/interpreter/conditionals.d.ts +1 -1
  180. package/dist/interpreter/errors.d.ts +36 -1
  181. package/dist/interpreter/expansion/analysis.d.ts +15 -17
  182. package/dist/interpreter/expansion/arith-text-expansion.d.ts +20 -0
  183. package/dist/interpreter/expansion/array-pattern-ops.d.ts +21 -0
  184. package/dist/interpreter/expansion/array-prefix-suffix.d.ts +46 -0
  185. package/dist/interpreter/expansion/array-slice-transform.d.ts +36 -0
  186. package/dist/interpreter/expansion/array-word-expansion.d.ts +39 -0
  187. package/dist/interpreter/expansion/command-substitution.d.ts +23 -0
  188. package/dist/interpreter/expansion/glob-escape.d.ts +32 -0
  189. package/dist/interpreter/expansion/indirect-expansion.d.ts +42 -0
  190. package/dist/interpreter/expansion/parameter-ops.d.ts +113 -0
  191. package/dist/interpreter/expansion/pattern-expansion.d.ts +23 -0
  192. package/dist/interpreter/expansion/pattern-removal.d.ts +18 -0
  193. package/dist/interpreter/expansion/pattern.d.ts +2 -1
  194. package/dist/interpreter/expansion/positional-params.d.ts +59 -0
  195. package/dist/interpreter/expansion/prompt.d.ts +39 -0
  196. package/dist/interpreter/expansion/quoting.d.ts +13 -0
  197. package/dist/interpreter/expansion/tilde.d.ts +12 -0
  198. package/dist/interpreter/expansion/unquoted-expansion.d.ts +76 -0
  199. package/dist/interpreter/expansion/variable-attrs.d.ts +19 -0
  200. package/dist/interpreter/expansion/variable.d.ts +10 -1
  201. package/dist/interpreter/expansion/word-glob-expansion.d.ts +33 -0
  202. package/dist/interpreter/expansion/word-split.d.ts +11 -6
  203. package/dist/interpreter/expansion.d.ts +30 -4
  204. package/dist/interpreter/functions.d.ts +1 -1
  205. package/dist/interpreter/helpers/array.d.ts +20 -0
  206. package/dist/interpreter/helpers/ifs.d.ts +66 -5
  207. package/dist/interpreter/helpers/nameref.d.ts +65 -0
  208. package/dist/interpreter/helpers/quoting.d.ts +24 -0
  209. package/dist/interpreter/helpers/readonly.d.ts +28 -4
  210. package/dist/interpreter/helpers/shell-constants.d.ts +25 -0
  211. package/dist/interpreter/helpers/shellopts.d.ts +28 -0
  212. package/dist/interpreter/helpers/string-compare.d.ts +3 -1
  213. package/dist/interpreter/helpers/tilde.d.ts +13 -0
  214. package/dist/interpreter/helpers/variable-tests.d.ts +1 -1
  215. package/dist/interpreter/helpers/word-matching.d.ts +26 -0
  216. package/dist/interpreter/helpers/xtrace.d.ts +18 -0
  217. package/dist/interpreter/interpreter.d.ts +13 -14
  218. package/dist/interpreter/pipeline-execution.d.ts +16 -0
  219. package/dist/interpreter/redirections.d.ts +38 -1
  220. package/dist/interpreter/simple-command-assignments.d.ts +29 -0
  221. package/dist/interpreter/subshell-group.d.ts +32 -0
  222. package/dist/interpreter/type-command.d.ts +37 -0
  223. package/dist/interpreter/types.d.ts +255 -21
  224. package/dist/limits.d.ts +2 -0
  225. package/dist/parser/arithmetic-parser.d.ts +2 -4
  226. package/dist/parser/arithmetic-primaries.d.ts +45 -0
  227. package/dist/parser/compound-parser.d.ts +21 -7
  228. package/dist/parser/expansion-parser.d.ts +7 -1
  229. package/dist/parser/lexer.d.ts +57 -0
  230. package/dist/parser/parser-substitution.d.ts +62 -0
  231. package/dist/parser/parser.d.ts +39 -2
  232. package/dist/parser/types.d.ts +1 -0
  233. package/dist/types.d.ts +17 -0
  234. package/package.json +10 -5
  235. package/dist/bin/chunks/alias-PCMLRCRW.js +0 -7
  236. package/dist/bin/chunks/awk2-D2US2LMM.js +0 -20
  237. package/dist/bin/chunks/bash-UT3MT5UU.js +0 -7
  238. package/dist/bin/chunks/chmod-3DIKREF7.js +0 -9
  239. package/dist/bin/chunks/chunk-ACRTDIBO.js +0 -6
  240. package/dist/bin/chunks/chunk-DV5HL4K2.js +0 -17
  241. package/dist/bin/chunks/chunk-J7BCMQDI.js +0 -16
  242. package/dist/bin/chunks/chunk-NWWB2XRE.js +0 -6
  243. package/dist/bin/chunks/chunk-PM2DS2YW.js +0 -3
  244. package/dist/bin/chunks/env-YLLSNZZN.js +0 -9
  245. package/dist/bin/chunks/od-SLM7SRWU.js +0 -7
  246. package/dist/bin/chunks/printf-HWUQKYUM.js +0 -14
  247. package/dist/bin/chunks/pwd-53KG2MCJ.js +0 -3
  248. package/dist/bin/chunks/sed-5LQMJYRJ.js +0 -80
  249. package/dist/bin/chunks/touch-TSNAXMZ2.js +0 -4
  250. package/dist/bin/chunks/wc-QSBRKIF5.js +0 -6
  251. package/dist/bin/shell/chunks/alias-PCMLRCRW.js +0 -7
  252. package/dist/bin/shell/chunks/awk2-D2US2LMM.js +0 -20
  253. package/dist/bin/shell/chunks/bash-UT3MT5UU.js +0 -7
  254. package/dist/bin/shell/chunks/chmod-3DIKREF7.js +0 -9
  255. package/dist/bin/shell/chunks/chunk-ACRTDIBO.js +0 -6
  256. package/dist/bin/shell/chunks/chunk-DV5HL4K2.js +0 -17
  257. package/dist/bin/shell/chunks/chunk-J7BCMQDI.js +0 -16
  258. package/dist/bin/shell/chunks/chunk-NWWB2XRE.js +0 -6
  259. package/dist/bin/shell/chunks/chunk-PM2DS2YW.js +0 -3
  260. package/dist/bin/shell/chunks/env-YLLSNZZN.js +0 -9
  261. package/dist/bin/shell/chunks/od-SLM7SRWU.js +0 -7
  262. package/dist/bin/shell/chunks/printf-HWUQKYUM.js +0 -14
  263. package/dist/bin/shell/chunks/pwd-53KG2MCJ.js +0 -3
  264. package/dist/bin/shell/chunks/sed-5LQMJYRJ.js +0 -80
  265. package/dist/bin/shell/chunks/touch-TSNAXMZ2.js +0 -4
  266. package/dist/bin/shell/chunks/wc-QSBRKIF5.js +0 -6
  267. package/dist/bundle/chunks/alias-4UGRF4DM.js +0 -6
  268. package/dist/bundle/chunks/awk2-46RTIZKB.js +0 -19
  269. package/dist/bundle/chunks/bash-ZILV3VHA.js +0 -6
  270. package/dist/bundle/chunks/chmod-FBHLEIY6.js +0 -8
  271. package/dist/bundle/chunks/chunk-4JO5BKO4.js +0 -5
  272. package/dist/bundle/chunks/chunk-BOJ3OAZB.js +0 -16
  273. package/dist/bundle/chunks/chunk-CG2HXOFG.js +0 -5
  274. package/dist/bundle/chunks/chunk-NWEGHOXL.js +0 -2
  275. package/dist/bundle/chunks/chunk-W2EKKAIL.js +0 -15
  276. package/dist/bundle/chunks/env-EG5SQSAQ.js +0 -8
  277. package/dist/bundle/chunks/od-ECWXNUB4.js +0 -6
  278. package/dist/bundle/chunks/printf-VG2POOXB.js +0 -13
  279. package/dist/bundle/chunks/pwd-AC4P3JKI.js +0 -2
  280. package/dist/bundle/chunks/sed-ZKODWZ6F.js +0 -79
  281. package/dist/bundle/chunks/touch-MVQSKQKT.js +0 -3
  282. package/dist/bundle/chunks/wc-DFQKWSIZ.js +0 -5
  283. package/dist/interpreter/builtins/variable-helpers.d.ts +0 -30
  284. /package/dist/bin/chunks/{curl-LCMREE7R.js → curl-TH7YRBSA.js} +0 -0
  285. /package/dist/bin/chunks/{file-LNCFDPQZ.js → file-6PCTL3MH.js} +0 -0
  286. /package/dist/bin/shell/chunks/{curl-LCMREE7R.js → curl-TH7YRBSA.js} +0 -0
  287. /package/dist/bin/shell/chunks/{file-LNCFDPQZ.js → file-6PCTL3MH.js} +0 -0
  288. /package/dist/bundle/chunks/{curl-TVZH24MD.js → curl-XLP4VABU.js} +0 -0
  289. /package/dist/bundle/chunks/{file-XPA6O6H2.js → file-NQP3CKRV.js} +0 -0
  290. /package/dist/commands/curl/{utils.d.ts → response-formatting.d.ts} +0 -0
  291. /package/dist/commands/xan/{xan-utils.d.ts → column-selection.d.ts} +0 -0
  292. /package/dist/fs/{utils.d.ts → encoding.d.ts} +0 -0
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Variable assignment helpers for declare, readonly, local, export builtins.
3
+ */
4
+ import type { ExecResult } from "../../types.js";
5
+ import type { InterpreterContext } from "../types.js";
6
+ /**
7
+ * Result of parsing an assignment argument.
8
+ */
9
+ export interface ParsedAssignment {
10
+ name: string;
11
+ isArray: boolean;
12
+ arrayElements?: string[];
13
+ value?: string;
14
+ /** For array index assignment: a[index]=value */
15
+ arrayIndex?: string;
16
+ }
17
+ /**
18
+ * Parse an assignment argument like "name=value", "name=(a b c)", or "name[index]=value".
19
+ */
20
+ export declare function parseAssignment(arg: string): ParsedAssignment;
21
+ /**
22
+ * Options for setting a variable.
23
+ */
24
+ export interface SetVariableOptions {
25
+ makeReadonly?: boolean;
26
+ checkReadonly?: boolean;
27
+ }
28
+ /**
29
+ * Set a variable from a parsed assignment.
30
+ * Returns an error result if the variable is readonly, otherwise null.
31
+ */
32
+ export declare function setVariable(ctx: InterpreterContext, assignment: ParsedAssignment, options?: SetVariableOptions): Promise<ExecResult | null>;
33
+ /**
34
+ * Mark a variable as being declared at the current call depth.
35
+ * Used for bash-specific unset scoping behavior.
36
+ */
37
+ export declare function markLocalVarDepth(ctx: InterpreterContext, name: string): void;
38
+ /**
39
+ * Get the call depth at which a local variable was declared.
40
+ * Returns undefined if the variable is not a local variable.
41
+ */
42
+ export declare function getLocalVarDepth(ctx: InterpreterContext, name: string): number | undefined;
43
+ /**
44
+ * Clear the local variable depth tracking for a variable.
45
+ * Called when a local variable is cell-unset (dynamic-unset).
46
+ */
47
+ export declare function clearLocalVarDepth(ctx: InterpreterContext, name: string): void;
48
+ /**
49
+ * Push the current value of a variable onto the local var stack.
50
+ * Used for bash's localvar-nest behavior where nested local declarations
51
+ * each create a new cell that can be unset independently.
52
+ */
53
+ export declare function pushLocalVarStack(ctx: InterpreterContext, name: string, currentValue: string | undefined): void;
54
+ /**
55
+ * Pop the top entry from the local var stack for a variable.
56
+ * Returns the saved value and scope index if there was an entry, or undefined if the stack was empty.
57
+ */
58
+ export declare function popLocalVarStack(ctx: InterpreterContext, name: string): {
59
+ value: string | undefined;
60
+ scopeIndex: number;
61
+ } | undefined;
62
+ /**
63
+ * Clear all local var stack entries for a specific scope index.
64
+ * Called when a function returns and its local scope is popped.
65
+ */
66
+ export declare function clearLocalVarStackForScope(ctx: InterpreterContext, scopeIndex: number): void;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Command Resolution
3
+ *
4
+ * Handles PATH-based command resolution and lookup for external commands.
5
+ */
6
+ import type { IFileSystem } from "../fs/interface.js";
7
+ import type { Command, CommandRegistry } from "../types.js";
8
+ import type { InterpreterState } from "./types.js";
9
+ /**
10
+ * Context needed for command resolution
11
+ */
12
+ export interface CommandResolutionContext {
13
+ fs: IFileSystem;
14
+ state: InterpreterState;
15
+ commands: CommandRegistry;
16
+ }
17
+ /**
18
+ * Result type for command resolution
19
+ */
20
+ export type ResolveCommandResult = {
21
+ cmd: Command;
22
+ path: string;
23
+ } | {
24
+ script: true;
25
+ path: string;
26
+ } | {
27
+ error: "not_found" | "permission_denied";
28
+ path?: string;
29
+ } | null;
30
+ /**
31
+ * Resolve a command name to its implementation via PATH lookup.
32
+ * Returns the command and its resolved path, or null if not found.
33
+ *
34
+ * Resolution order:
35
+ * 1. If command contains "/", resolve as a path
36
+ * 2. Search PATH directories for the command file
37
+ * 3. Fall back to registry lookup (for non-InMemoryFs filesystems like OverlayFs)
38
+ */
39
+ export declare function resolveCommand(ctx: CommandResolutionContext, commandName: string, pathOverride?: string): Promise<ResolveCommandResult>;
40
+ /**
41
+ * Find all paths for a command in PATH (for `which -a`).
42
+ */
43
+ export declare function findCommandInPath(ctx: CommandResolutionContext, commandName: string): Promise<string[]>;
@@ -14,4 +14,4 @@ import type { ExecResult } from "../types.js";
14
14
  import type { InterpreterContext } from "./types.js";
15
15
  export declare function evaluateConditional(ctx: InterpreterContext, expr: ConditionalExpressionNode): Promise<boolean>;
16
16
  export declare function evaluateTestArgs(ctx: InterpreterContext, args: string[]): Promise<ExecResult>;
17
- export declare function matchPattern(value: string, pattern: string): boolean;
17
+ export declare function matchPattern(value: string, pattern: string, nocasematch?: boolean, extglob?: boolean): boolean;
@@ -78,7 +78,12 @@ export declare class ExitError extends ControlFlowError {
78
78
  */
79
79
  export declare class ArithmeticError extends ControlFlowError {
80
80
  readonly name = "ArithmeticError";
81
- constructor(message: string, stdout?: string, stderr?: string);
81
+ /**
82
+ * If true, this error should abort script execution (like missing operand after binary operator).
83
+ * If false, the error is recoverable and execution can continue.
84
+ */
85
+ fatal: boolean;
86
+ constructor(message: string, stdout?: string, stderr?: string, fatal?: boolean);
82
87
  }
83
88
  /**
84
89
  * Error thrown for bad substitution errors (e.g., ${#var:1:3}).
@@ -88,6 +93,22 @@ export declare class BadSubstitutionError extends ControlFlowError {
88
93
  readonly name = "BadSubstitutionError";
89
94
  constructor(message: string, stdout?: string, stderr?: string);
90
95
  }
96
+ /**
97
+ * Error thrown when failglob is enabled and a glob pattern has no matches.
98
+ * Returns exit code 1.
99
+ */
100
+ export declare class GlobError extends ControlFlowError {
101
+ readonly name = "GlobError";
102
+ constructor(pattern: string, stdout?: string, stderr?: string);
103
+ }
104
+ /**
105
+ * Error thrown for invalid brace expansions (e.g., mixed case character ranges like {z..A}).
106
+ * Returns exit code 1 (matching bash behavior).
107
+ */
108
+ export declare class BraceExpansionError extends ControlFlowError {
109
+ readonly name = "BraceExpansionError";
110
+ constructor(message: string, stdout?: string, stderr?: string);
111
+ }
91
112
  /**
92
113
  * Error thrown when execution limits are exceeded (recursion depth, command count, loop iterations).
93
114
  * This should ALWAYS be thrown before JavaScript's native RangeError kicks in.
@@ -112,4 +133,18 @@ export declare class SubshellExitError extends ControlFlowError {
112
133
  * These need special handling vs errexit/nounset which terminate execution.
113
134
  */
114
135
  export declare function isScopeExitError(error: unknown): error is BreakError | ContinueError | ReturnError;
136
+ /**
137
+ * Error thrown when a POSIX special builtin fails in POSIX mode.
138
+ * In POSIX mode (set -o posix), errors in special builtins like
139
+ * shift, set, readonly, export, etc. cause the entire script to exit.
140
+ *
141
+ * Per POSIX 2.8.1 - Consequences of Shell Errors:
142
+ * "A special built-in utility causes an interactive or non-interactive shell
143
+ * to exit when an error occurs."
144
+ */
145
+ export declare class PosixFatalError extends ControlFlowError {
146
+ readonly exitCode: number;
147
+ readonly name = "PosixFatalError";
148
+ constructor(exitCode: number, stdout?: string, stderr?: string);
149
+ }
115
150
  export {};
@@ -1,28 +1,24 @@
1
1
  /**
2
2
  * Word Analysis
3
3
  *
4
- * Functions for analyzing word parts to determine:
5
- * - Whether async execution is needed
6
- * - What types of expansions are present
4
+ * Functions for analyzing word parts to determine what types of expansions are present.
7
5
  */
8
- import type { ParameterExpansionPart, WordNode, WordPart } from "../../ast/types.js";
6
+ import type { ParameterExpansionPart, WordPart } from "../../ast/types.js";
9
7
  /**
10
- * Check if a parameter expansion requires async execution
8
+ * Check if a glob pattern string contains variable references ($var or ${var})
9
+ * This is used to detect when IFS splitting should apply to expanded glob patterns.
11
10
  */
12
- export declare function paramExpansionNeedsAsync(part: ParameterExpansionPart): boolean;
11
+ export declare function globPatternHasVarRef(pattern: string): boolean;
13
12
  /**
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
13
+ * Check if a parameter expansion's operation word is entirely quoted (all parts are quoted).
14
+ * This is different from hasQuotedOperationWord which returns true if ANY part is quoted.
15
+ *
16
+ * For word splitting purposes:
17
+ * - ${v:-"AxBxC"} - entirely quoted, should NOT be split
18
+ * - ${v:-x"AxBxC"x} - mixed quoted/unquoted, SHOULD be split (on unquoted parts)
19
+ * - ${v:-AxBxC} - entirely unquoted, SHOULD be split
24
20
  */
25
- export declare function hasQuotedOperationWord(part: ParameterExpansionPart): boolean;
21
+ export declare function isOperationWordEntirelyQuoted(part: ParameterExpansionPart): boolean;
26
22
  /**
27
23
  * Result of analyzing word parts
28
24
  */
@@ -32,6 +28,8 @@ export interface WordPartsAnalysis {
32
28
  hasArrayVar: boolean;
33
29
  hasArrayAtExpansion: boolean;
34
30
  hasParamExpansion: boolean;
31
+ hasVarNamePrefixExpansion: boolean;
32
+ hasIndirection: boolean;
35
33
  }
36
34
  /**
37
35
  * Analyze word parts for expansion behavior
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Arithmetic Text Expansion
3
+ *
4
+ * Functions for expanding variables within arithmetic expression text.
5
+ * This handles the bash behavior where $(( $x * 3 )) with x='1 + 2' should
6
+ * expand to $(( 1 + 2 * 3 )) = 7, not $(( (1+2) * 3 )) = 9.
7
+ */
8
+ import type { InterpreterContext } from "../types.js";
9
+ /**
10
+ * Expand $var patterns in arithmetic expression text for text substitution.
11
+ * Only expands simple $var patterns, not ${...}, $(()), $(), etc.
12
+ */
13
+ export declare function expandDollarVarsInArithText(ctx: InterpreterContext, text: string): Promise<string>;
14
+ /**
15
+ * Expand variable references and command substitutions in an array subscript.
16
+ * e.g., "${array[@]}" -> "1 2 3", "$(echo 1)" -> "1"
17
+ * This is needed for associative array subscripts like assoc["${array[@]}"]
18
+ * where the subscript may contain variable or array expansions.
19
+ */
20
+ export declare function expandSubscriptForAssocArray(ctx: InterpreterContext, subscript: string): Promise<string>;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Array Pattern Operations
3
+ *
4
+ * Handles pattern replacement and pattern removal for array expansions:
5
+ * - "${arr[@]/pattern/replacement}" - pattern replacement
6
+ * - "${arr[@]#pattern}" - prefix removal
7
+ * - "${arr[@]%pattern}" - suffix removal
8
+ */
9
+ import type { WordPart } from "../../ast/types.js";
10
+ import type { InterpreterContext } from "../types.js";
11
+ import type { ArrayExpansionResult, ExpandPartFn, ExpandWordPartsAsyncFn } from "./array-word-expansion.js";
12
+ /**
13
+ * Handle "${arr[@]/pattern/replacement}" and "${arr[*]/pattern/replacement}"
14
+ * Returns null if this handler doesn't apply.
15
+ */
16
+ export declare function handleArrayPatternReplacement(ctx: InterpreterContext, wordParts: WordPart[], expandWordPartsAsync: ExpandWordPartsAsyncFn, expandPart: ExpandPartFn): Promise<ArrayExpansionResult>;
17
+ /**
18
+ * Handle "${arr[@]#pattern}" and "${arr[*]#pattern}" - array pattern removal
19
+ * Returns null if this handler doesn't apply.
20
+ */
21
+ export declare function handleArrayPatternRemoval(ctx: InterpreterContext, wordParts: WordPart[], expandWordPartsAsync: ExpandWordPartsAsyncFn, expandPart: ExpandPartFn): Promise<ArrayExpansionResult>;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Array Expansion with Prefix/Suffix Handlers
3
+ *
4
+ * Handles array expansions that have adjacent text in double quotes:
5
+ * - "${prefix}${arr[@]#pattern}${suffix}" - pattern removal with prefix/suffix
6
+ * - "${prefix}${arr[@]/pattern/replacement}${suffix}" - pattern replacement with prefix/suffix
7
+ * - "${prefix}${arr[@]}${suffix}" - simple array expansion with prefix/suffix
8
+ * - "${arr[@]:-${default[@]}}" - array default/alternative values
9
+ */
10
+ import type { WordPart } from "../../ast/types.js";
11
+ import type { InterpreterContext } from "../types.js";
12
+ /**
13
+ * Result type for array expansion handlers.
14
+ * `null` means the handler doesn't apply to this case.
15
+ */
16
+ export type ArrayExpansionResult = {
17
+ values: string[];
18
+ quoted: boolean;
19
+ } | null;
20
+ /**
21
+ * Type for expandPart function reference
22
+ */
23
+ export type ExpandPartFn = (ctx: InterpreterContext, part: WordPart) => Promise<string>;
24
+ /**
25
+ * Type for expandWordPartsAsync function reference
26
+ */
27
+ export type ExpandWordPartsAsyncFn = (ctx: InterpreterContext, parts: WordPart[]) => Promise<string>;
28
+ /**
29
+ * Handle "${arr[@]:-${default[@]}}", "${arr[@]:+${alt[@]}}", and "${arr[@]:=default}"
30
+ * Also handles "${var:-${default[@]}}" where var is a scalar variable.
31
+ * When the default value contains an array expansion, each element should become a separate word.
32
+ */
33
+ export declare function handleArrayDefaultValue(ctx: InterpreterContext, wordParts: WordPart[]): Promise<ArrayExpansionResult>;
34
+ /**
35
+ * Handle "${prefix}${arr[@]#pattern}${suffix}" and "${prefix}${arr[@]/pat/rep}${suffix}"
36
+ * Array pattern operations with adjacent text in double quotes.
37
+ * Each array element has the pattern applied, then becomes a separate word
38
+ * with prefix joined to first and suffix joined to last.
39
+ */
40
+ export declare function handleArrayPatternWithPrefixSuffix(ctx: InterpreterContext, wordParts: WordPart[], hasArrayAtExpansion: boolean, expandPart: ExpandPartFn, expandWordPartsAsync: ExpandWordPartsAsyncFn): Promise<ArrayExpansionResult>;
41
+ /**
42
+ * Handle "${prefix}${arr[@]}${suffix}" - array expansion with adjacent text in double quotes.
43
+ * Each array element becomes a separate word, with prefix joined to first and suffix joined to last.
44
+ * This is similar to how "$@" works with prefix/suffix.
45
+ */
46
+ export declare function handleArrayWithPrefixSuffix(ctx: InterpreterContext, wordParts: WordPart[], hasArrayAtExpansion: boolean, expandPart: ExpandPartFn): Promise<ArrayExpansionResult>;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Array Slicing and Transform Operations
3
+ *
4
+ * Handles array expansion with slicing and transform operators:
5
+ * - "${arr[@]:offset}" and "${arr[@]:offset:length}" - array slicing
6
+ * - "${arr[@]@a}", "${arr[@]@P}", "${arr[@]@Q}" - transform operations
7
+ */
8
+ import type { WordPart } from "../../ast/types.js";
9
+ import type { InterpreterContext } from "../types.js";
10
+ /**
11
+ * Result type for array expansion handlers.
12
+ * `null` means the handler doesn't apply to this case.
13
+ */
14
+ export type ArrayExpansionResult = {
15
+ values: string[];
16
+ quoted: boolean;
17
+ } | null;
18
+ import type { ArithExpr } from "../../ast/types.js";
19
+ /**
20
+ * Type for evaluateArithmetic function
21
+ */
22
+ export type EvaluateArithmeticFn = (ctx: InterpreterContext, expr: ArithExpr, isExpansionContext?: boolean) => Promise<number>;
23
+ /**
24
+ * Handle "${arr[@]:offset}" and "${arr[@]:offset:length}" - array slicing with multiple return values
25
+ * "${arr[@]:n:m}" returns m elements starting from index n as separate words
26
+ * "${arr[*]:n:m}" returns m elements starting from index n joined with IFS as one word
27
+ */
28
+ export declare function handleArraySlicing(ctx: InterpreterContext, wordParts: WordPart[], evaluateArithmetic: EvaluateArithmeticFn): Promise<ArrayExpansionResult>;
29
+ /**
30
+ * Handle "${arr[@]@a}", "${arr[@]@P}", "${arr[@]@Q}" - array Transform operations
31
+ * "${arr[@]@a}": Return attribute letter for each element (e.g., 'a' for indexed array)
32
+ * "${arr[@]@P}": Return each element's value (prompt expansion, limited implementation)
33
+ * "${arr[@]@Q}": Return each element quoted for shell reuse
34
+ * "${arr[*]@X}": Same as above but joined with IFS as one word
35
+ */
36
+ export declare function handleArrayTransform(ctx: InterpreterContext, wordParts: WordPart[]): ArrayExpansionResult;
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Array Word Expansion Handlers
3
+ *
4
+ * Handles complex array expansion cases in word expansion:
5
+ * - "${arr[@]}" and "${arr[*]}" - array element expansion
6
+ * - "${arr[@]:-default}" - array with defaults
7
+ * - "${arr[@]:offset:length}" - array slicing
8
+ * - "${arr[@]/pattern/replacement}" - pattern replacement
9
+ * - "${arr[@]#pattern}" - pattern removal
10
+ * - "${arr[@]@op}" - transform operations
11
+ */
12
+ import type { WordPart } from "../../ast/types.js";
13
+ import type { InterpreterContext } from "../types.js";
14
+ /**
15
+ * Result type for array expansion handlers.
16
+ * `null` means the handler doesn't apply to this case.
17
+ */
18
+ export type ArrayExpansionResult = {
19
+ values: string[];
20
+ quoted: boolean;
21
+ } | null;
22
+ /**
23
+ * Helper type for expandWordPartsAsync function reference
24
+ */
25
+ export type ExpandWordPartsAsyncFn = (ctx: InterpreterContext, parts: WordPart[]) => Promise<string>;
26
+ /**
27
+ * Helper type for expandPart function reference
28
+ */
29
+ export type ExpandPartFn = (ctx: InterpreterContext, part: WordPart) => Promise<string>;
30
+ /**
31
+ * Handle simple "${arr[@]}" expansion without operations.
32
+ * Returns each array element as a separate word.
33
+ */
34
+ export declare function handleSimpleArrayExpansion(ctx: InterpreterContext, wordParts: WordPart[]): ArrayExpansionResult;
35
+ /**
36
+ * Handle namerefs pointing to array[@] - "${ref}" where ref='arr[@]'
37
+ * When a nameref points to array[@], expanding "$ref" should produce multiple words
38
+ */
39
+ export declare function handleNamerefArrayExpansion(ctx: InterpreterContext, wordParts: WordPart[]): ArrayExpansionResult;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Command Substitution Helpers
3
+ *
4
+ * Helper functions for handling command substitution patterns.
5
+ */
6
+ import type { ScriptNode, WordNode } from "../../ast/types.js";
7
+ /**
8
+ * Check if a command substitution body matches the $(<file) shorthand pattern.
9
+ * This is a special case where $(< file) is equivalent to $(cat file) but reads
10
+ * the file directly without spawning a subprocess.
11
+ *
12
+ * For this to match, the body must consist of:
13
+ * - One statement without operators (no && or ||)
14
+ * - One pipeline with one command
15
+ * - A SimpleCommand with no name, no args, no assignments
16
+ * - Exactly one input redirection (<)
17
+ *
18
+ * Note: The special $(<file) behavior only works when it's the ONLY element
19
+ * in the command substitution. $(< file; cmd) or $(cmd; < file) are NOT special.
20
+ */
21
+ export declare function getFileReadShorthand(body: ScriptNode): {
22
+ target: WordNode;
23
+ } | null;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Glob Helper Functions
3
+ *
4
+ * Functions for handling glob patterns, escaping, and unescaping.
5
+ */
6
+ /**
7
+ * Check if a string contains glob patterns, including extglob when enabled.
8
+ */
9
+ export declare function hasGlobPattern(value: string, extglob: boolean): boolean;
10
+ /**
11
+ * Unescape a glob pattern - convert escaped glob chars to literal chars.
12
+ * For example, [\]_ (escaped pattern) becomes [\\]_ (literal string).
13
+ *
14
+ * This is used when we need to take a pattern that was built with escaped
15
+ * glob characters and convert it back to a literal string (e.g., for
16
+ * no-match fallback when nullglob is off).
17
+ *
18
+ * Note: The input is expected to be a pattern string where backslashes escape
19
+ * the following character. For patterns like "test\\[*" (user input: test\[*)
20
+ * the output is "\\_" (with processed escapes), not [\\]_ (raw pattern).
21
+ */
22
+ export declare function unescapeGlobPattern(pattern: string): string;
23
+ /**
24
+ * Escape glob metacharacters in a string for literal matching.
25
+ * Includes extglob metacharacters: ( ) |
26
+ */
27
+ export declare function escapeGlobChars(str: string): string;
28
+ /**
29
+ * Escape regex metacharacters in a string for literal matching.
30
+ * Used when quoted patterns are used with =~ operator.
31
+ */
32
+ export declare function escapeRegexChars(str: string): string;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Indirect Array Expansion Handlers
3
+ *
4
+ * Handles "${!ref}" style indirect expansions where ref points to an array:
5
+ * - "${!ref}" where ref='arr[@]' or ref='arr[*]'
6
+ * - "${!ref:offset}" and "${!ref:offset:length}" - array slicing via indirection
7
+ * - "${!ref:-default}" and "${!ref:+alternative}" - default/alternative via indirection
8
+ * - "${ref+${!ref}}" - indirect in alternative value
9
+ */
10
+ import type { ParameterExpansionPart, WordPart } from "../../ast/types.js";
11
+ import type { InterpreterContext } from "../types.js";
12
+ /**
13
+ * Result type for indirect expansion handlers.
14
+ * `null` means the handler doesn't apply to this case.
15
+ */
16
+ export type IndirectExpansionResult = {
17
+ values: string[];
18
+ quoted: boolean;
19
+ } | null;
20
+ /**
21
+ * Type for expandParameterAsync function reference
22
+ */
23
+ export type ExpandParameterAsyncFn = (ctx: InterpreterContext, part: ParameterExpansionPart, inDoubleQuotes?: boolean) => Promise<string>;
24
+ /**
25
+ * Type for expandWordPartsAsync function reference
26
+ */
27
+ export type ExpandWordPartsAsyncFn = (ctx: InterpreterContext, parts: WordPart[], inDoubleQuotes?: boolean) => Promise<string>;
28
+ /**
29
+ * Handle "${!ref}" where ref='arr[@]' or ref='arr[*]' - indirect array expansion.
30
+ * This handles all the inner operation cases as well.
31
+ */
32
+ export declare function handleIndirectArrayExpansion(ctx: InterpreterContext, wordParts: WordPart[], hasIndirection: boolean, expandParameterAsync: ExpandParameterAsyncFn, expandWordPartsAsync: ExpandWordPartsAsyncFn): Promise<IndirectExpansionResult>;
33
+ /**
34
+ * Handle ${ref+${!ref}} or ${ref-${!ref}} - indirect in alternative/default value.
35
+ * This handles patterns like: ${hooksSlice+"${!hooksSlice}"} which should preserve element boundaries
36
+ */
37
+ export declare function handleIndirectInAlternative(ctx: InterpreterContext, wordParts: WordPart[]): Promise<IndirectExpansionResult>;
38
+ /**
39
+ * Handle ${!ref+${!ref}} or ${!ref-${!ref}} - indirect with innerOp in alternative/default value.
40
+ * This handles patterns like: ${!hooksSlice+"${!hooksSlice}"} which should preserve element boundaries
41
+ */
42
+ export declare function handleIndirectionWithInnerAlternative(ctx: InterpreterContext, wordParts: WordPart[]): Promise<IndirectExpansionResult>;
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Parameter Operation Handlers
3
+ *
4
+ * Handles individual parameter expansion operations:
5
+ * - DefaultValue, AssignDefault, UseAlternative, ErrorIfUnset
6
+ * - PatternRemoval, PatternReplacement
7
+ * - Length, Substring
8
+ * - CaseModification, Transform
9
+ * - Indirection, ArrayKeys, VarNamePrefix
10
+ */
11
+ import type { CaseModificationOp, ErrorIfUnsetOp, InnerParameterOperation, ParameterExpansionPart, PatternRemovalOp, PatternReplacementOp, SubstringOp, WordNode, WordPart } from "../../ast/types.js";
12
+ import type { InterpreterContext } from "../types.js";
13
+ /**
14
+ * Type for expandWordPartsAsync function reference
15
+ */
16
+ export type ExpandWordPartsAsyncFn = (ctx: InterpreterContext, parts: WordPart[], inDoubleQuotes?: boolean) => Promise<string>;
17
+ /**
18
+ * Type for expandPart function reference
19
+ */
20
+ export type ExpandPartFn = (ctx: InterpreterContext, part: WordPart, inDoubleQuotes?: boolean) => Promise<string>;
21
+ /**
22
+ * Type for self-reference to expandParameterAsync
23
+ */
24
+ export type ExpandParameterAsyncFn = (ctx: InterpreterContext, part: ParameterExpansionPart, inDoubleQuotes?: boolean) => Promise<string>;
25
+ /**
26
+ * Context with computed values used across multiple operation handlers
27
+ */
28
+ export interface ParameterOpContext {
29
+ value: string;
30
+ isUnset: boolean;
31
+ isEmpty: boolean;
32
+ effectiveValue: string;
33
+ inDoubleQuotes: boolean;
34
+ }
35
+ /**
36
+ * Handle DefaultValue operation: ${param:-word}
37
+ */
38
+ export declare function handleDefaultValue(ctx: InterpreterContext, operation: {
39
+ word?: WordNode;
40
+ checkEmpty?: boolean;
41
+ }, opCtx: ParameterOpContext, expandWordPartsAsync: ExpandWordPartsAsyncFn): Promise<string>;
42
+ /**
43
+ * Handle AssignDefault operation: ${param:=word}
44
+ */
45
+ export declare function handleAssignDefault(ctx: InterpreterContext, parameter: string, operation: {
46
+ word?: WordNode;
47
+ checkEmpty?: boolean;
48
+ }, opCtx: ParameterOpContext, expandWordPartsAsync: ExpandWordPartsAsyncFn): Promise<string>;
49
+ /**
50
+ * Handle ErrorIfUnset operation: ${param:?word}
51
+ */
52
+ export declare function handleErrorIfUnset(ctx: InterpreterContext, parameter: string, operation: ErrorIfUnsetOp, opCtx: ParameterOpContext, expandWordPartsAsync: ExpandWordPartsAsyncFn): Promise<string>;
53
+ /**
54
+ * Handle UseAlternative operation: ${param:+word}
55
+ */
56
+ export declare function handleUseAlternative(ctx: InterpreterContext, operation: {
57
+ word?: WordNode;
58
+ checkEmpty?: boolean;
59
+ }, opCtx: ParameterOpContext, expandWordPartsAsync: ExpandWordPartsAsyncFn): Promise<string>;
60
+ /**
61
+ * Handle PatternRemoval operation: ${param#pattern}, ${param%pattern}
62
+ */
63
+ export declare function handlePatternRemoval(ctx: InterpreterContext, value: string, operation: PatternRemovalOp, expandWordPartsAsync: ExpandWordPartsAsyncFn, expandPart: ExpandPartFn): Promise<string>;
64
+ /**
65
+ * Handle PatternReplacement operation: ${param/pattern/replacement}
66
+ */
67
+ export declare function handlePatternReplacement(ctx: InterpreterContext, value: string, operation: PatternReplacementOp, expandWordPartsAsync: ExpandWordPartsAsyncFn, expandPart: ExpandPartFn): Promise<string>;
68
+ /**
69
+ * Handle Length operation: ${#param}
70
+ */
71
+ export declare function handleLength(ctx: InterpreterContext, parameter: string, value: string): string;
72
+ /**
73
+ * Handle Substring operation: ${param:offset:length}
74
+ */
75
+ export declare function handleSubstring(ctx: InterpreterContext, parameter: string, value: string, operation: SubstringOp): Promise<string>;
76
+ /**
77
+ * Handle CaseModification operation: ${param^pattern}, ${param,pattern}
78
+ */
79
+ export declare function handleCaseModification(ctx: InterpreterContext, value: string, operation: CaseModificationOp, expandWordPartsAsync: ExpandWordPartsAsyncFn, expandParameterAsync: ExpandParameterAsyncFn): Promise<string>;
80
+ /**
81
+ * Handle Transform operation: ${param@operator}
82
+ */
83
+ export declare function handleTransform(ctx: InterpreterContext, parameter: string, value: string, isUnset: boolean, operation: {
84
+ operator: string;
85
+ }): string;
86
+ /**
87
+ * Handle Indirection operation: ${!param}
88
+ */
89
+ export declare function handleIndirection(ctx: InterpreterContext, parameter: string, value: string, isUnset: boolean, operation: {
90
+ innerOp?: InnerParameterOperation;
91
+ }, expandParameterAsync: ExpandParameterAsyncFn, inDoubleQuotes?: boolean): Promise<string>;
92
+ /**
93
+ * Handle ArrayKeys operation: ${!arr[@]}, ${!arr[*]}
94
+ */
95
+ export declare function handleArrayKeys(ctx: InterpreterContext, operation: {
96
+ array: string;
97
+ star: boolean;
98
+ }): string;
99
+ /**
100
+ * Handle VarNamePrefix operation: ${!prefix*}, ${!prefix@}
101
+ */
102
+ export declare function handleVarNamePrefix(ctx: InterpreterContext, operation: {
103
+ prefix: string;
104
+ star: boolean;
105
+ }): string;
106
+ /**
107
+ * Compute whether the parameter value is "empty" for expansion purposes.
108
+ * This handles special cases for $*, $@, array[*], and array[@].
109
+ */
110
+ export declare function computeIsEmpty(ctx: InterpreterContext, parameter: string, value: string, inDoubleQuotes: boolean): {
111
+ isEmpty: boolean;
112
+ effectiveValue: string;
113
+ };
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Pattern Expansion
3
+ *
4
+ * Functions for expanding variables within glob/extglob patterns.
5
+ * Handles command substitution, variable expansion, and quoting within patterns.
6
+ */
7
+ import type { InterpreterContext } from "../types.js";
8
+ /**
9
+ * Check if a pattern string contains command substitution $(...)
10
+ */
11
+ export declare function patternHasCommandSubstitution(pattern: string): boolean;
12
+ /**
13
+ * Expand variables within a glob/extglob pattern string.
14
+ * This handles patterns like @($var|$other) where variables need expansion.
15
+ * Also handles quoted strings inside patterns (e.g., @(foo|'bar'|"$baz")).
16
+ * Preserves pattern metacharacters while expanding $var and ${var} references.
17
+ */
18
+ export declare function expandVariablesInPattern(ctx: InterpreterContext, pattern: string): string;
19
+ /**
20
+ * Async version of expandVariablesInPattern that handles command substitutions.
21
+ * This handles patterns like @($var|$(echo foo)) where command substitutions need expansion.
22
+ */
23
+ export declare function expandVariablesInPatternAsync(ctx: InterpreterContext, pattern: string): Promise<string>;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Pattern Removal Helpers
3
+ *
4
+ * Functions for ${var#pattern}, ${var%pattern}, ${!prefix*} etc.
5
+ */
6
+ import type { InterpreterContext } from "../types.js";
7
+ /**
8
+ * Apply pattern removal (prefix or suffix strip) to a single value.
9
+ * Used by both scalar and vectorized array operations.
10
+ */
11
+ export declare function applyPatternRemoval(value: string, regexStr: string, side: "prefix" | "suffix", greedy: boolean): string;
12
+ /**
13
+ * Get variable names that match a given prefix.
14
+ * Used for ${!prefix*} and ${!prefix@} expansions.
15
+ * Handles arrays properly - includes array base names from __length markers,
16
+ * excludes internal storage keys like arr_0, arr__length.
17
+ */
18
+ export declare function getVarNamesWithPrefix(ctx: InterpreterContext, prefix: string): string[];
@@ -18,5 +18,6 @@
18
18
  * Convert a shell glob pattern to a regex string.
19
19
  * @param pattern - The glob pattern (*, ?, [...])
20
20
  * @param greedy - Whether * should be greedy (true for suffix matching, false for prefix)
21
+ * @param extglob - Whether to support extended glob patterns (@(...), *(...), +(...), ?(...), !(...))
21
22
  */
22
- export declare function patternToRegex(pattern: string, greedy: boolean): string;
23
+ export declare function patternToRegex(pattern: string, greedy: boolean, extglob?: boolean): string;