just-bash 2.5.5 → 2.6.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 (281) hide show
  1. package/README.md +2 -2
  2. package/dist/AGENTS.md +2 -2
  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/{shell/chunks/rg-Q4OTJOEF.js → chunks/rg-RSDLLECO.js} +1 -1
  25. package/dist/bin/chunks/rmdir-GOODLY5W.js +14 -0
  26. package/dist/bin/chunks/sed-JPDTWF4W.js +100 -0
  27. package/dist/bin/{shell/chunks/tail-BES27CZT.js → chunks/tail-YAUIERGN.js} +1 -1
  28. package/dist/bin/{shell/chunks/tar-C27YYUAS.js → chunks/tar-LFENC54A.js} +7 -7
  29. package/dist/bin/chunks/time-37F5EBPK.js +14 -0
  30. package/dist/bin/chunks/touch-IBPHJBM3.js +7 -0
  31. package/dist/bin/chunks/wc-SAOHEZYP.js +6 -0
  32. package/dist/bin/chunks/{which-73KOOLC6.js → which-FCDFBOMN.js} +1 -1
  33. package/dist/bin/chunks/whoami-JVLUNKSG.js +3 -0
  34. package/dist/bin/{shell/chunks/xan-6K2NGTHM.js → chunks/xan-5HNHTFMB.js} +19 -19
  35. package/dist/bin/chunks/{yq-MF2SNFGL.js → yq-PFV4T2PV.js} +1 -1
  36. package/dist/bin/just-bash.js +659 -135
  37. package/dist/bin/shell/chunks/alias-EGIS5LUE.js +7 -0
  38. package/dist/bin/shell/chunks/awk2-GFEJOWML.js +21 -0
  39. package/dist/bin/shell/chunks/bash-PGDTHIM2.js +6 -0
  40. package/dist/bin/shell/chunks/chmod-TYLTHXFR.js +9 -0
  41. package/dist/bin/shell/chunks/chunk-D5WP4CKS.js +3 -0
  42. package/dist/bin/shell/chunks/chunk-FSAGDARS.js +74 -0
  43. package/dist/bin/shell/chunks/chunk-FSZWFMB4.js +16 -0
  44. package/dist/bin/shell/chunks/chunk-IRUD2E3M.js +17 -0
  45. package/dist/bin/shell/chunks/chunk-K5IXNHO5.js +8 -0
  46. package/dist/bin/shell/chunks/chunk-KD3EODLB.js +6 -0
  47. package/dist/bin/{chunks/echo-WSKTON6U.js → shell/chunks/echo-7I42V66Q.js} +2 -2
  48. package/dist/bin/shell/chunks/env-7A4MH7BJ.js +9 -0
  49. package/dist/bin/shell/chunks/expansion-BOR3ELLC.js +2 -0
  50. package/dist/bin/{chunks/find-CBEJ35BR.js → shell/chunks/find-PHDZK64M.js} +1 -1
  51. package/dist/bin/{chunks/grep-IIVQXFNI.js → shell/chunks/grep-VX7MJMVN.js} +2 -2
  52. package/dist/bin/shell/chunks/{head-DYK37Z24.js → head-TJHLLIMR.js} +1 -1
  53. package/dist/bin/{chunks/jq-XXZPU5CA.js → shell/chunks/jq-RGZHJNXC.js} +1 -1
  54. package/dist/bin/shell/chunks/od-KRKGC2U3.js +5 -0
  55. package/dist/bin/shell/chunks/printf-YPXD4CRE.js +15 -0
  56. package/dist/bin/shell/chunks/pwd-L26WH2K4.js +3 -0
  57. package/dist/bin/{chunks/rg-Q4OTJOEF.js → shell/chunks/rg-RSDLLECO.js} +1 -1
  58. package/dist/bin/shell/chunks/rmdir-GOODLY5W.js +14 -0
  59. package/dist/bin/shell/chunks/sed-JPDTWF4W.js +100 -0
  60. package/dist/bin/{chunks/tail-BES27CZT.js → shell/chunks/tail-YAUIERGN.js} +1 -1
  61. package/dist/bin/{chunks/tar-C27YYUAS.js → shell/chunks/tar-LFENC54A.js} +7 -7
  62. package/dist/bin/shell/chunks/time-37F5EBPK.js +14 -0
  63. package/dist/bin/shell/chunks/touch-IBPHJBM3.js +7 -0
  64. package/dist/bin/shell/chunks/wc-SAOHEZYP.js +6 -0
  65. package/dist/bin/shell/chunks/{which-73KOOLC6.js → which-FCDFBOMN.js} +1 -1
  66. package/dist/bin/shell/chunks/whoami-JVLUNKSG.js +3 -0
  67. package/dist/bin/{chunks/xan-6K2NGTHM.js → shell/chunks/xan-5HNHTFMB.js} +19 -19
  68. package/dist/bin/shell/chunks/{yq-MF2SNFGL.js → yq-PFV4T2PV.js} +1 -1
  69. package/dist/bin/shell/shell.js +664 -140
  70. package/dist/bundle/browser.js +1251 -606
  71. package/dist/bundle/chunks/alias-ATFBB6D2.js +6 -0
  72. package/dist/bundle/chunks/awk2-6FBZTP57.js +20 -0
  73. package/dist/bundle/chunks/bash-OLRNM52U.js +5 -0
  74. package/dist/bundle/chunks/chmod-ODWUR7E6.js +8 -0
  75. package/dist/bundle/chunks/chunk-3AWP5CWK.js +73 -0
  76. package/dist/bundle/chunks/chunk-CXEWLFNE.js +16 -0
  77. package/dist/bundle/chunks/chunk-CZPA5RBA.js +5 -0
  78. package/dist/bundle/chunks/chunk-EEXR5ZDP.js +2 -0
  79. package/dist/bundle/chunks/chunk-HDQ56CKY.js +15 -0
  80. package/dist/bundle/chunks/chunk-PSW6BMXW.js +7 -0
  81. package/dist/bundle/chunks/{echo-VUHWYV6L.js → echo-6S7WE7XB.js} +2 -2
  82. package/dist/bundle/chunks/env-2UI6XINU.js +8 -0
  83. package/dist/bundle/chunks/expansion-RIGCFEMA.js +1 -0
  84. package/dist/bundle/chunks/{find-ACOAWALE.js → find-YGMSVGUV.js} +1 -1
  85. package/dist/bundle/chunks/{grep-ACVE42JK.js → grep-NIC6JNLH.js} +2 -2
  86. package/dist/bundle/chunks/{head-FZ6IQHYW.js → head-SA7P5NJ7.js} +1 -1
  87. package/dist/bundle/chunks/{jq-3YU5HRKE.js → jq-RLRYRPOJ.js} +1 -1
  88. package/dist/bundle/chunks/od-3FPDPLWJ.js +4 -0
  89. package/dist/bundle/chunks/printf-66XGXFCD.js +14 -0
  90. package/dist/bundle/chunks/pwd-S4NVAMC4.js +2 -0
  91. package/dist/bundle/chunks/{rg-YLZJWCEJ.js → rg-SRMB7L6G.js} +1 -1
  92. package/dist/bundle/chunks/rmdir-XFQE4ZYV.js +13 -0
  93. package/dist/bundle/chunks/sed-IV6HLDXU.js +99 -0
  94. package/dist/bundle/chunks/{tail-PD4RZR6J.js → tail-52LRAWXT.js} +1 -1
  95. package/dist/bundle/chunks/{tar-QWBXMF7K.js → tar-LWIHPMT6.js} +7 -7
  96. package/dist/bundle/chunks/time-UWXBG6CS.js +13 -0
  97. package/dist/bundle/chunks/touch-TDTEBHHI.js +6 -0
  98. package/dist/bundle/chunks/wc-HE5XARI4.js +5 -0
  99. package/dist/bundle/chunks/{which-M5MQ6QXQ.js → which-UBLRBDHN.js} +1 -1
  100. package/dist/bundle/chunks/whoami-YUDAIS32.js +2 -0
  101. package/dist/bundle/chunks/{xan-2R2APJJ4.js → xan-A6VPI4HJ.js} +19 -19
  102. package/dist/bundle/chunks/{yq-KANM4MD2.js → yq-L665QPQU.js} +1 -1
  103. package/dist/bundle/index.js +657 -133
  104. package/dist/commands/awk/ast.d.ts +1 -0
  105. package/dist/commands/awk/interpreter/context.d.ts +14 -0
  106. package/dist/commands/awk/interpreter/interpreter.d.ts +2 -0
  107. package/dist/commands/awk/interpreter/{helpers.d.ts → type-coercion.d.ts} +4 -1
  108. package/dist/commands/awk/parser2-print.d.ts +35 -0
  109. package/dist/commands/awk/parser2.d.ts +42 -34
  110. package/dist/commands/printf/strftime.d.ts +9 -0
  111. package/dist/commands/query-engine/builtins/array-builtins.d.ts +20 -0
  112. package/dist/commands/query-engine/builtins/control-builtins.d.ts +18 -0
  113. package/dist/commands/query-engine/builtins/date-builtins.d.ts +15 -0
  114. package/dist/commands/query-engine/builtins/format-builtins.d.ts +11 -0
  115. package/dist/commands/query-engine/builtins/index-builtins.d.ts +16 -0
  116. package/dist/commands/query-engine/builtins/index.d.ts +17 -0
  117. package/dist/commands/query-engine/builtins/math-builtins.d.ts +15 -0
  118. package/dist/commands/query-engine/builtins/navigation-builtins.d.ts +18 -0
  119. package/dist/commands/query-engine/builtins/object-builtins.d.ts +15 -0
  120. package/dist/commands/query-engine/builtins/path-builtins.d.ts +20 -0
  121. package/dist/commands/query-engine/builtins/sql-builtins.d.ts +16 -0
  122. package/dist/commands/query-engine/builtins/string-builtins.d.ts +15 -0
  123. package/dist/commands/query-engine/builtins/type-builtins.d.ts +11 -0
  124. package/dist/commands/query-engine/evaluator.d.ts +10 -2
  125. package/dist/commands/query-engine/parser-types.d.ts +171 -0
  126. package/dist/commands/query-engine/parser.d.ts +2 -132
  127. package/dist/commands/query-engine/path-operations.d.ts +15 -0
  128. package/dist/commands/query-engine/value-operations.d.ts +39 -0
  129. package/dist/commands/registry.d.ts +1 -1
  130. package/dist/commands/rmdir/rmdir.d.ts +2 -0
  131. package/dist/commands/sed/lexer.d.ts +12 -0
  132. package/dist/commands/sed/parser.d.ts +9 -0
  133. package/dist/commands/sed/sed-regex.d.ts +23 -0
  134. package/dist/commands/sed/types.d.ts +13 -1
  135. package/dist/commands/tar/tar-options.d.ts +36 -0
  136. package/dist/commands/time/time.d.ts +25 -0
  137. package/dist/commands/whoami/whoami.d.ts +9 -0
  138. package/dist/commands/xan/moonblade-tokenizer.d.ts +25 -0
  139. package/dist/fs/in-memory-fs/in-memory-fs.d.ts +12 -0
  140. package/dist/fs/interface.d.ts +16 -0
  141. package/dist/fs/mountable-fs/mountable-fs.d.ts +12 -0
  142. package/dist/fs/overlay-fs/overlay-fs.d.ts +13 -1
  143. package/dist/fs/read-write-fs/read-write-fs.d.ts +13 -1
  144. package/dist/interpreter/alias-expansion.d.ts +23 -0
  145. package/dist/interpreter/arithmetic.d.ts +1 -6
  146. package/dist/interpreter/assignment-expansion.d.ts +24 -0
  147. package/dist/interpreter/builtin-dispatch.d.ts +39 -0
  148. package/dist/interpreter/builtins/compgen.d.ts +26 -0
  149. package/dist/interpreter/builtins/complete.d.ts +17 -0
  150. package/dist/interpreter/builtins/compopt.d.ts +28 -0
  151. package/dist/interpreter/builtins/declare-array-parsing.d.ts +14 -0
  152. package/dist/interpreter/builtins/declare-print.d.ts +39 -0
  153. package/dist/interpreter/builtins/declare.d.ts +10 -4
  154. package/dist/interpreter/builtins/dirs.d.ts +29 -0
  155. package/dist/interpreter/builtins/eval.d.ts +1 -1
  156. package/dist/interpreter/builtins/export.d.ts +1 -0
  157. package/dist/interpreter/builtins/getopts.d.ts +18 -0
  158. package/dist/interpreter/builtins/hash.d.ts +19 -0
  159. package/dist/interpreter/builtins/help.d.ts +12 -0
  160. package/dist/interpreter/builtins/index.d.ts +9 -1
  161. package/dist/interpreter/builtins/local.d.ts +1 -1
  162. package/dist/interpreter/builtins/read.d.ts +1 -1
  163. package/dist/interpreter/builtins/set.d.ts +3 -0
  164. package/dist/interpreter/builtins/shift.d.ts +3 -0
  165. package/dist/interpreter/builtins/shopt.d.ts +7 -0
  166. package/dist/interpreter/builtins/unset.d.ts +5 -1
  167. package/dist/interpreter/builtins/variable-assignment.d.ts +66 -0
  168. package/dist/interpreter/command-resolution.d.ts +43 -0
  169. package/dist/interpreter/conditionals.d.ts +1 -1
  170. package/dist/interpreter/errors.d.ts +36 -1
  171. package/dist/interpreter/expansion/analysis.d.ts +15 -17
  172. package/dist/interpreter/expansion/arith-text-expansion.d.ts +20 -0
  173. package/dist/interpreter/expansion/array-pattern-ops.d.ts +21 -0
  174. package/dist/interpreter/expansion/array-prefix-suffix.d.ts +46 -0
  175. package/dist/interpreter/expansion/array-slice-transform.d.ts +36 -0
  176. package/dist/interpreter/expansion/array-word-expansion.d.ts +39 -0
  177. package/dist/interpreter/expansion/command-substitution.d.ts +23 -0
  178. package/dist/interpreter/expansion/glob-escape.d.ts +32 -0
  179. package/dist/interpreter/expansion/indirect-expansion.d.ts +42 -0
  180. package/dist/interpreter/expansion/parameter-ops.d.ts +113 -0
  181. package/dist/interpreter/expansion/pattern-expansion.d.ts +23 -0
  182. package/dist/interpreter/expansion/pattern-removal.d.ts +18 -0
  183. package/dist/interpreter/expansion/pattern.d.ts +2 -1
  184. package/dist/interpreter/expansion/positional-params.d.ts +59 -0
  185. package/dist/interpreter/expansion/prompt.d.ts +39 -0
  186. package/dist/interpreter/expansion/quoting.d.ts +13 -0
  187. package/dist/interpreter/expansion/tilde.d.ts +12 -0
  188. package/dist/interpreter/expansion/unquoted-expansion.d.ts +76 -0
  189. package/dist/interpreter/expansion/variable-attrs.d.ts +19 -0
  190. package/dist/interpreter/expansion/variable.d.ts +10 -1
  191. package/dist/interpreter/expansion/word-glob-expansion.d.ts +33 -0
  192. package/dist/interpreter/expansion/word-split.d.ts +11 -6
  193. package/dist/interpreter/expansion.d.ts +30 -4
  194. package/dist/interpreter/functions.d.ts +1 -1
  195. package/dist/interpreter/helpers/array.d.ts +20 -0
  196. package/dist/interpreter/helpers/ifs.d.ts +66 -5
  197. package/dist/interpreter/helpers/nameref.d.ts +65 -0
  198. package/dist/interpreter/helpers/quoting.d.ts +24 -0
  199. package/dist/interpreter/helpers/readonly.d.ts +28 -4
  200. package/dist/interpreter/helpers/shell-constants.d.ts +25 -0
  201. package/dist/interpreter/helpers/shellopts.d.ts +28 -0
  202. package/dist/interpreter/helpers/string-compare.d.ts +3 -1
  203. package/dist/interpreter/helpers/tilde.d.ts +13 -0
  204. package/dist/interpreter/helpers/variable-tests.d.ts +1 -1
  205. package/dist/interpreter/helpers/word-matching.d.ts +26 -0
  206. package/dist/interpreter/helpers/xtrace.d.ts +18 -0
  207. package/dist/interpreter/interpreter.d.ts +13 -14
  208. package/dist/interpreter/pipeline-execution.d.ts +16 -0
  209. package/dist/interpreter/redirections.d.ts +38 -1
  210. package/dist/interpreter/simple-command-assignments.d.ts +29 -0
  211. package/dist/interpreter/subshell-group.d.ts +32 -0
  212. package/dist/interpreter/type-command.d.ts +37 -0
  213. package/dist/interpreter/types.d.ts +255 -21
  214. package/dist/parser/arithmetic-parser.d.ts +2 -4
  215. package/dist/parser/arithmetic-primaries.d.ts +45 -0
  216. package/dist/parser/compound-parser.d.ts +21 -7
  217. package/dist/parser/expansion-parser.d.ts +7 -1
  218. package/dist/parser/lexer.d.ts +57 -0
  219. package/dist/parser/parser-substitution.d.ts +62 -0
  220. package/dist/parser/parser.d.ts +39 -2
  221. package/dist/parser/types.d.ts +1 -0
  222. package/dist/types.d.ts +17 -0
  223. package/package.json +4 -1
  224. package/dist/bin/chunks/alias-PCMLRCRW.js +0 -7
  225. package/dist/bin/chunks/awk2-D2US2LMM.js +0 -20
  226. package/dist/bin/chunks/bash-UT3MT5UU.js +0 -7
  227. package/dist/bin/chunks/chmod-3DIKREF7.js +0 -9
  228. package/dist/bin/chunks/chunk-ACRTDIBO.js +0 -6
  229. package/dist/bin/chunks/chunk-DV5HL4K2.js +0 -17
  230. package/dist/bin/chunks/chunk-J7BCMQDI.js +0 -16
  231. package/dist/bin/chunks/chunk-NWWB2XRE.js +0 -6
  232. package/dist/bin/chunks/chunk-PM2DS2YW.js +0 -3
  233. package/dist/bin/chunks/env-YLLSNZZN.js +0 -9
  234. package/dist/bin/chunks/od-SLM7SRWU.js +0 -7
  235. package/dist/bin/chunks/printf-HWUQKYUM.js +0 -14
  236. package/dist/bin/chunks/pwd-53KG2MCJ.js +0 -3
  237. package/dist/bin/chunks/sed-5LQMJYRJ.js +0 -80
  238. package/dist/bin/chunks/touch-TSNAXMZ2.js +0 -4
  239. package/dist/bin/chunks/wc-QSBRKIF5.js +0 -6
  240. package/dist/bin/shell/chunks/alias-PCMLRCRW.js +0 -7
  241. package/dist/bin/shell/chunks/awk2-D2US2LMM.js +0 -20
  242. package/dist/bin/shell/chunks/bash-UT3MT5UU.js +0 -7
  243. package/dist/bin/shell/chunks/chmod-3DIKREF7.js +0 -9
  244. package/dist/bin/shell/chunks/chunk-ACRTDIBO.js +0 -6
  245. package/dist/bin/shell/chunks/chunk-DV5HL4K2.js +0 -17
  246. package/dist/bin/shell/chunks/chunk-J7BCMQDI.js +0 -16
  247. package/dist/bin/shell/chunks/chunk-NWWB2XRE.js +0 -6
  248. package/dist/bin/shell/chunks/chunk-PM2DS2YW.js +0 -3
  249. package/dist/bin/shell/chunks/env-YLLSNZZN.js +0 -9
  250. package/dist/bin/shell/chunks/od-SLM7SRWU.js +0 -7
  251. package/dist/bin/shell/chunks/printf-HWUQKYUM.js +0 -14
  252. package/dist/bin/shell/chunks/pwd-53KG2MCJ.js +0 -3
  253. package/dist/bin/shell/chunks/sed-5LQMJYRJ.js +0 -80
  254. package/dist/bin/shell/chunks/touch-TSNAXMZ2.js +0 -4
  255. package/dist/bin/shell/chunks/wc-QSBRKIF5.js +0 -6
  256. package/dist/bundle/chunks/alias-4UGRF4DM.js +0 -6
  257. package/dist/bundle/chunks/awk2-46RTIZKB.js +0 -19
  258. package/dist/bundle/chunks/bash-ZILV3VHA.js +0 -6
  259. package/dist/bundle/chunks/chmod-FBHLEIY6.js +0 -8
  260. package/dist/bundle/chunks/chunk-4JO5BKO4.js +0 -5
  261. package/dist/bundle/chunks/chunk-BOJ3OAZB.js +0 -16
  262. package/dist/bundle/chunks/chunk-CG2HXOFG.js +0 -5
  263. package/dist/bundle/chunks/chunk-NWEGHOXL.js +0 -2
  264. package/dist/bundle/chunks/chunk-W2EKKAIL.js +0 -15
  265. package/dist/bundle/chunks/env-EG5SQSAQ.js +0 -8
  266. package/dist/bundle/chunks/od-ECWXNUB4.js +0 -6
  267. package/dist/bundle/chunks/printf-VG2POOXB.js +0 -13
  268. package/dist/bundle/chunks/pwd-AC4P3JKI.js +0 -2
  269. package/dist/bundle/chunks/sed-ZKODWZ6F.js +0 -79
  270. package/dist/bundle/chunks/touch-MVQSKQKT.js +0 -3
  271. package/dist/bundle/chunks/wc-DFQKWSIZ.js +0 -5
  272. package/dist/interpreter/builtins/variable-helpers.d.ts +0 -30
  273. /package/dist/bin/chunks/{curl-LCMREE7R.js → curl-TH7YRBSA.js} +0 -0
  274. /package/dist/bin/chunks/{file-LNCFDPQZ.js → file-6PCTL3MH.js} +0 -0
  275. /package/dist/bin/shell/chunks/{curl-LCMREE7R.js → curl-TH7YRBSA.js} +0 -0
  276. /package/dist/bin/shell/chunks/{file-LNCFDPQZ.js → file-6PCTL3MH.js} +0 -0
  277. /package/dist/bundle/chunks/{curl-TVZH24MD.js → curl-XLP4VABU.js} +0 -0
  278. /package/dist/bundle/chunks/{file-XPA6O6H2.js → file-NQP3CKRV.js} +0 -0
  279. /package/dist/commands/curl/{utils.d.ts → response-formatting.d.ts} +0 -0
  280. /package/dist/commands/xan/{xan-utils.d.ts → column-selection.d.ts} +0 -0
  281. /package/dist/fs/{utils.d.ts → encoding.d.ts} +0 -0
@@ -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;
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Positional Parameter Expansion Handlers
3
+ *
4
+ * Handles $@ and $* expansion with various operations:
5
+ * - "${@:offset}" and "${*:offset}" - slicing
6
+ * - "${@/pattern/replacement}" - pattern replacement
7
+ * - "${@#pattern}" - pattern removal (strip)
8
+ * - "$@" and "$*" with adjacent text
9
+ */
10
+ import type { WordPart } from "../../ast/types.js";
11
+ import type { InterpreterContext } from "../types.js";
12
+ /**
13
+ * Result type for positional parameter expansion handlers.
14
+ * `null` means the handler doesn't apply to this case.
15
+ */
16
+ export type PositionalExpansionResult = {
17
+ values: string[];
18
+ quoted: boolean;
19
+ } | null;
20
+ import type { ArithExpr } from "../../ast/types.js";
21
+ /**
22
+ * Type for evaluateArithmetic function
23
+ */
24
+ export type EvaluateArithmeticFn = (ctx: InterpreterContext, expr: ArithExpr, isExpansionContext?: boolean) => Promise<number>;
25
+ /**
26
+ * Type for expandPart function
27
+ */
28
+ export type ExpandPartFn = (ctx: InterpreterContext, part: WordPart) => Promise<string>;
29
+ /**
30
+ * Type for expandWordPartsAsync function
31
+ */
32
+ export type ExpandWordPartsAsyncFn = (ctx: InterpreterContext, parts: WordPart[]) => Promise<string>;
33
+ /**
34
+ * Handle "${@:offset}" and "${*:offset}" with Substring operations inside double quotes
35
+ * "${@:offset}": Each sliced positional parameter becomes a separate word
36
+ * "${*:offset}": All sliced params joined with IFS as ONE word
37
+ */
38
+ export declare function handlePositionalSlicing(ctx: InterpreterContext, wordParts: WordPart[], evaluateArithmetic: EvaluateArithmeticFn, expandPart: ExpandPartFn): Promise<PositionalExpansionResult>;
39
+ /**
40
+ * Handle "${@/pattern/replacement}" and "${* /pattern/replacement}" with PatternReplacement inside double quotes
41
+ * "${@/pattern/replacement}": Each positional parameter has pattern replaced, each becomes a separate word
42
+ * "${* /pattern/replacement}": All params joined with IFS, pattern replaced, becomes ONE word
43
+ */
44
+ export declare function handlePositionalPatternReplacement(ctx: InterpreterContext, wordParts: WordPart[], expandPart: ExpandPartFn, expandWordPartsAsync: ExpandWordPartsAsyncFn): Promise<PositionalExpansionResult>;
45
+ /**
46
+ * Handle "${@#pattern}" and "${*#pattern}" - positional parameter pattern removal (strip)
47
+ * "${@#pattern}": Remove shortest matching prefix from each parameter, each becomes a separate word
48
+ * "${@##pattern}": Remove longest matching prefix from each parameter
49
+ * "${@%pattern}": Remove shortest matching suffix from each parameter
50
+ * "${@%%pattern}": Remove longest matching suffix from each parameter
51
+ */
52
+ export declare function handlePositionalPatternRemoval(ctx: InterpreterContext, wordParts: WordPart[], expandPart: ExpandPartFn, expandWordPartsAsync: ExpandWordPartsAsyncFn): Promise<PositionalExpansionResult>;
53
+ /**
54
+ * Handle "$@" and "$*" with adjacent text inside double quotes, e.g., "-$@-"
55
+ * "$@": Each positional parameter becomes a separate word, with prefix joined to first
56
+ * and suffix joined to last. If no params, produces nothing (or just prefix+suffix if present)
57
+ * "$*": All params joined with IFS as ONE word. If no params, produces one empty word.
58
+ */
59
+ export declare function handleSimplePositionalExpansion(ctx: InterpreterContext, wordParts: WordPart[], expandPart: ExpandPartFn): Promise<PositionalExpansionResult>;
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Prompt expansion
3
+ *
4
+ * Handles prompt escape sequences for ${var@P} transformation and PS1/PS2/PS3/PS4.
5
+ */
6
+ import type { InterpreterContext } from "../types.js";
7
+ /**
8
+ * Expand prompt escape sequences (${var@P} transformation)
9
+ * Interprets backslash escapes used in PS1, PS2, PS3, PS4 prompt strings.
10
+ *
11
+ * Supported escapes:
12
+ * - \a - bell (ASCII 07)
13
+ * - \e - escape (ASCII 033)
14
+ * - \n - newline
15
+ * - \r - carriage return
16
+ * - \\ - literal backslash
17
+ * - \$ - $ for regular user, # for root (always $ here)
18
+ * - \[ and \] - non-printing sequence delimiters (removed)
19
+ * - \u - username
20
+ * - \h - short hostname (up to first .)
21
+ * - \H - full hostname
22
+ * - \w - current working directory
23
+ * - \W - basename of current working directory
24
+ * - \d - date (Weekday Month Day format)
25
+ * - \t - time HH:MM:SS (24-hour)
26
+ * - \T - time HH:MM:SS (12-hour)
27
+ * - \@ - time HH:MM AM/PM (12-hour)
28
+ * - \A - time HH:MM (24-hour)
29
+ * - \D{format} - strftime format
30
+ * - \s - shell name
31
+ * - \v - bash version (major.minor)
32
+ * - \V - bash version (major.minor.patch)
33
+ * - \j - number of jobs
34
+ * - \l - terminal device basename
35
+ * - \# - command number
36
+ * - \! - history number
37
+ * - \NNN - octal character code
38
+ */
39
+ export declare function expandPrompt(ctx: InterpreterContext, value: string): string;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Quoting helpers for word expansion
3
+ *
4
+ * Handles quoting values for shell reuse (${var@Q} transformation).
5
+ */
6
+ /**
7
+ * Quote a value for safe reuse as shell input (${var@Q} transformation)
8
+ * Uses single quotes with proper escaping for special characters.
9
+ * Follows bash's quoting behavior:
10
+ * - Simple strings without quotes: 'value'
11
+ * - Strings with single quotes or control characters: $'value' with \' escaping
12
+ */
13
+ export declare function quoteValue(value: string): string;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Tilde Expansion
3
+ *
4
+ * Functions for handling tilde (~) expansion in word expansion.
5
+ */
6
+ import type { InterpreterContext } from "../types.js";
7
+ /**
8
+ * Apply tilde expansion to a string.
9
+ * Used after brace expansion to handle cases like ~{/src,root} -> ~/src ~root -> /home/user/src /root
10
+ * Only expands ~ at the start of the string followed by / or end of string.
11
+ */
12
+ export declare function applyTildeExpansion(ctx: InterpreterContext, value: string): string;
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Unquoted Expansion Handlers
3
+ *
4
+ * Handles unquoted positional parameter and array expansions:
5
+ * - Unquoted $@ and $* (with and without prefix/suffix)
6
+ * - Unquoted ${arr[@]} and ${arr[*]}
7
+ * - Unquoted ${@:offset} and ${*:offset} slicing
8
+ * - Unquoted ${@#pattern} and ${*#pattern} pattern removal
9
+ * - Unquoted ${arr[@]/pattern/replacement} pattern replacement
10
+ * - Unquoted ${arr[@]#pattern} pattern removal
11
+ * - Unquoted ${!prefix@} and ${!prefix*} variable name prefix expansion
12
+ * - Unquoted ${!arr[@]} and ${!arr[*]} array keys expansion
13
+ */
14
+ import type { ArithExpr, WordPart } from "../../ast/types.js";
15
+ import type { InterpreterContext } from "../types.js";
16
+ /**
17
+ * Result type for unquoted expansion handlers.
18
+ * `null` means the handler doesn't apply to this case.
19
+ */
20
+ export type UnquotedExpansionResult = {
21
+ values: string[];
22
+ quoted: boolean;
23
+ } | null;
24
+ /**
25
+ * Type for expandPart function reference
26
+ */
27
+ export type ExpandPartFn = (ctx: InterpreterContext, part: WordPart) => Promise<string>;
28
+ /**
29
+ * Type for expandWordPartsAsync function reference
30
+ */
31
+ export type ExpandWordPartsAsyncFn = (ctx: InterpreterContext, parts: WordPart[]) => Promise<string>;
32
+ /**
33
+ * Type for evaluateArithmetic function
34
+ */
35
+ export type EvaluateArithmeticFn = (ctx: InterpreterContext, expr: ArithExpr, isExpansionContext?: boolean) => Promise<number>;
36
+ /**
37
+ * Handle unquoted ${array[@]/pattern/replacement} - apply to each element
38
+ * This handles ${array[@]/#/prefix} (prepend) and ${array[@]/%/suffix} (append)
39
+ */
40
+ export declare function handleUnquotedArrayPatternReplacement(ctx: InterpreterContext, wordParts: WordPart[], expandWordPartsAsync: ExpandWordPartsAsyncFn, expandPart: ExpandPartFn): Promise<UnquotedExpansionResult>;
41
+ /**
42
+ * Handle unquoted ${array[@]#pattern} - apply pattern removal to each element
43
+ * This handles ${array[@]#pattern} (strip shortest prefix), ${array[@]##pattern} (strip longest prefix)
44
+ * ${array[@]%pattern} (strip shortest suffix), ${array[@]%%pattern} (strip longest suffix)
45
+ */
46
+ export declare function handleUnquotedArrayPatternRemoval(ctx: InterpreterContext, wordParts: WordPart[], expandWordPartsAsync: ExpandWordPartsAsyncFn, expandPart: ExpandPartFn): Promise<UnquotedExpansionResult>;
47
+ /**
48
+ * Handle unquoted ${@#pattern} and ${*#pattern} - apply pattern removal to each positional parameter
49
+ * This handles ${@#pattern} (strip shortest prefix), ${@##pattern} (strip longest prefix)
50
+ * ${@%pattern} (strip shortest suffix), ${@%%pattern} (strip longest suffix)
51
+ */
52
+ export declare function handleUnquotedPositionalPatternRemoval(ctx: InterpreterContext, wordParts: WordPart[], expandWordPartsAsync: ExpandWordPartsAsyncFn, expandPart: ExpandPartFn): Promise<UnquotedExpansionResult>;
53
+ /**
54
+ * Handle unquoted ${@:offset} and ${*:offset} (with potential prefix/suffix)
55
+ */
56
+ export declare function handleUnquotedPositionalSlicing(ctx: InterpreterContext, wordParts: WordPart[], evaluateArithmetic: EvaluateArithmeticFn, expandPart: ExpandPartFn): Promise<UnquotedExpansionResult>;
57
+ /**
58
+ * Handle unquoted $@ and $* (simple, without operations)
59
+ */
60
+ export declare function handleUnquotedSimplePositional(ctx: InterpreterContext, wordParts: WordPart[]): Promise<UnquotedExpansionResult>;
61
+ /**
62
+ * Handle unquoted ${arr[@]} and ${arr[*]} (without operations)
63
+ */
64
+ export declare function handleUnquotedSimpleArray(ctx: InterpreterContext, wordParts: WordPart[]): Promise<UnquotedExpansionResult>;
65
+ /**
66
+ * Handle unquoted ${!prefix@} and ${!prefix*} (variable name prefix expansion)
67
+ */
68
+ export declare function handleUnquotedVarNamePrefix(ctx: InterpreterContext, wordParts: WordPart[]): UnquotedExpansionResult;
69
+ /**
70
+ * Handle unquoted ${!arr[@]} and ${!arr[*]} (array keys/indices expansion)
71
+ */
72
+ export declare function handleUnquotedArrayKeys(ctx: InterpreterContext, wordParts: WordPart[]): UnquotedExpansionResult;
73
+ /**
74
+ * Handle unquoted $@ or $* with prefix/suffix (e.g., =$@= or =$*=)
75
+ */
76
+ export declare function handleUnquotedPositionalWithPrefixSuffix(ctx: InterpreterContext, wordParts: WordPart[], expandPart: ExpandPartFn): Promise<UnquotedExpansionResult>;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Variable Attributes
3
+ *
4
+ * Functions for getting variable attributes (${var@a} transformation).
5
+ */
6
+ import type { InterpreterContext } from "../types.js";
7
+ /**
8
+ * Get the attributes of a variable for ${var@a} transformation.
9
+ * Returns a string with attribute flags (e.g., "ar" for readonly array).
10
+ *
11
+ * Attribute flags (in order):
12
+ * - a: indexed array
13
+ * - A: associative array
14
+ * - i: integer
15
+ * - n: nameref
16
+ * - r: readonly
17
+ * - x: exported
18
+ */
19
+ export declare function getVariableAttributes(ctx: InterpreterContext, name: string): string;