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
package/README.md CHANGED
@@ -275,7 +275,7 @@ pnpm shell --no-network
275
275
 
276
276
  ### File Operations
277
277
 
278
- `cat`, `cp`, `file`, `ln`, `ls`, `mkdir`, `mv`, `readlink`, `rm`, `split`, `stat`, `touch`, `tree`
278
+ `cat`, `cp`, `file`, `ln`, `ls`, `mkdir`, `mv`, `readlink`, `rm`, `rmdir`, `split`, `stat`, `touch`, `tree`
279
279
 
280
280
  ### Text Processing
281
281
 
@@ -295,7 +295,7 @@ pnpm shell --no-network
295
295
 
296
296
  ### Shell Utilities
297
297
 
298
- `alias`, `bash`, `chmod`, `clear`, `date`, `expr`, `false`, `help`, `history`, `seq`, `sh`, `sleep`, `timeout`, `true`, `unalias`, `which`
298
+ `alias`, `bash`, `chmod`, `clear`, `date`, `expr`, `false`, `help`, `history`, `seq`, `sh`, `sleep`, `time`, `timeout`, `true`, `unalias`, `which`, `whoami`
299
299
 
300
300
  ### Network Commands
301
301
 
package/dist/AGENTS.md CHANGED
@@ -68,9 +68,9 @@ const result = await bash.exec("cat input.txt | grep pattern");
68
68
 
69
69
  **Data processing**: `jq` (JSON), `sqlite3` (SQLite), `xan` (CSV), `yq` (YAML/XML/TOML/CSV)
70
70
 
71
- **File operations**: `basename`, `chmod`, `cp`, `dirname`, `du`, `file`, `find`, `ln`, `ls`, `mkdir`, `mv`, `od`, `pwd`, `readlink`, `rm`, `split`, `stat`, `touch`, `tree`
71
+ **File operations**: `basename`, `chmod`, `cp`, `dirname`, `du`, `file`, `find`, `ln`, `ls`, `mkdir`, `mv`, `od`, `pwd`, `readlink`, `rm`, `rmdir`, `split`, `stat`, `touch`, `tree`
72
72
 
73
- **Utilities**: `alias`, `base64`, `bash`, `clear`, `curl`, `date`, `diff`, `echo`, `env`, `expr`, `false`, `gzip`, `gunzip`, `help`, `history`, `hostname`, `html-to-markdown`, `md5sum`, `printenv`, `printf`, `seq`, `sh`, `sha1sum`, `sha256sum`, `sleep`, `tar`, `tee`, `timeout`, `true`, `unalias`, `which`, `zcat`
73
+ **Utilities**: `alias`, `base64`, `bash`, `clear`, `curl`, `date`, `diff`, `echo`, `env`, `expr`, `false`, `gzip`, `gunzip`, `help`, `history`, `hostname`, `html-to-markdown`, `md5sum`, `printenv`, `printf`, `seq`, `sh`, `sha1sum`, `sha256sum`, `sleep`, `tar`, `tee`, `time`, `timeout`, `true`, `unalias`, `which`, `whoami`, `zcat`
74
74
 
75
75
  All commands support `--help` for usage details.
76
76
 
@@ -40,6 +40,21 @@ export interface StatementNode extends ASTNode {
40
40
  operators: ("&&" | "||" | ";")[];
41
41
  /** Run in background? */
42
42
  background: boolean;
43
+ /**
44
+ * Deferred syntax error. If set, executing this statement will throw a syntax error.
45
+ * This is used to support bash's incremental parsing behavior where syntax errors
46
+ * on later lines only trigger if/when execution reaches that line.
47
+ * Example: `{ls;\n}` - the } is invalid but with errexit, the script exits before reaching it.
48
+ */
49
+ deferredError?: {
50
+ message: string;
51
+ token: string;
52
+ };
53
+ /**
54
+ * Original source text for verbose mode (set -v).
55
+ * When verbose mode is enabled, this text is printed to stderr before execution.
56
+ */
57
+ sourceText?: string;
43
58
  }
44
59
  /** A pipeline: cmd1 | cmd2 | cmd3 */
45
60
  export interface PipelineNode extends ASTNode {
@@ -47,6 +62,16 @@ export interface PipelineNode extends ASTNode {
47
62
  commands: CommandNode[];
48
63
  /** Negate exit status with ! */
49
64
  negated: boolean;
65
+ /** Time the pipeline with 'time' keyword */
66
+ timed?: boolean;
67
+ /** Use POSIX format for time output (-p flag) */
68
+ timePosix?: boolean;
69
+ /**
70
+ * For each pipe in the pipeline, whether it's |& (pipe stderr too).
71
+ * pipeStderr[i] indicates if command[i]'s stderr should be piped to command[i+1]'s stdin.
72
+ * Length is commands.length - 1.
73
+ */
74
+ pipeStderr?: boolean[];
50
75
  }
51
76
  /** Union of all command types */
52
77
  export type CommandNode = SimpleCommandNode | CompoundCommandNode | FunctionDefNode;
@@ -144,6 +169,7 @@ export interface ConditionalCommandNode extends ASTNode {
144
169
  type: "ConditionalCommand";
145
170
  expression: ConditionalExpressionNode;
146
171
  redirections: RedirectionNode[];
172
+ line?: number;
147
173
  }
148
174
  /** Function definition */
149
175
  export interface FunctionDefNode extends ASTNode {
@@ -151,6 +177,8 @@ export interface FunctionDefNode extends ASTNode {
151
177
  name: string;
152
178
  body: CompoundCommandNode;
153
179
  redirections: RedirectionNode[];
180
+ /** Source file where the function was defined (for BASH_SOURCE tracking) */
181
+ sourceFile?: string;
154
182
  }
155
183
  /** Variable assignment: VAR=value or VAR+=value */
156
184
  export interface AssignmentNode extends ASTNode {
@@ -167,6 +195,11 @@ export interface RedirectionNode extends ASTNode {
167
195
  type: "Redirection";
168
196
  /** File descriptor (default depends on operator) */
169
197
  fd: number | null;
198
+ /**
199
+ * Variable name for automatic FD allocation ({varname}>file syntax).
200
+ * When set, bash allocates an FD >= 10 and stores the number in this variable.
201
+ */
202
+ fdVariable?: string;
170
203
  operator: RedirectionOperator;
171
204
  target: WordNode | HereDocNode;
172
205
  }
@@ -218,11 +251,19 @@ export interface ParameterExpansionPart extends ASTNode {
218
251
  /** Expansion operation */
219
252
  operation: ParameterOperation | null;
220
253
  }
221
- export type ParameterOperation = DefaultValueOp | AssignDefaultOp | ErrorIfUnsetOp | UseAlternativeOp | LengthOp | LengthSliceErrorOp | SubstringOp | PatternRemovalOp | PatternReplacementOp | CaseModificationOp | TransformOp | IndirectionOp | ArrayKeysOp | VarNamePrefixOp;
254
+ /** Operations that can be used as inner operations for indirection (${!ref-default}) */
255
+ export type InnerParameterOperation = DefaultValueOp | AssignDefaultOp | ErrorIfUnsetOp | UseAlternativeOp | LengthOp | LengthSliceErrorOp | BadSubstitutionOp | SubstringOp | PatternRemovalOp | PatternReplacementOp | CaseModificationOp | TransformOp;
256
+ export type ParameterOperation = InnerParameterOperation | IndirectionOp | ArrayKeysOp | VarNamePrefixOp;
222
257
  /** ${#VAR:...} - invalid syntax, length cannot have substring */
223
258
  export interface LengthSliceErrorOp {
224
259
  type: "LengthSliceError";
225
260
  }
261
+ /** Bad substitution - parsed but errors at runtime (e.g., ${(x)foo} zsh syntax) */
262
+ export interface BadSubstitutionOp {
263
+ type: "BadSubstitution";
264
+ /** The raw text that caused the error (for error message) */
265
+ text: string;
266
+ }
226
267
  /** ${VAR:-default} or ${VAR-default} */
227
268
  export interface DefaultValueOp {
228
269
  type: "DefaultValue";
@@ -288,12 +329,14 @@ export interface CaseModificationOp {
288
329
  /** ${var@Q}, ${var@P}, etc. - parameter transformation */
289
330
  export interface TransformOp {
290
331
  type: "Transform";
291
- /** Q=quote, P=prompt, a=attributes, A=assignment, E=escape, K=keys */
292
- operator: "Q" | "P" | "a" | "A" | "E" | "K";
332
+ /** Q=quote, P=prompt, a=attributes, A=assignment, E=escape, K=keys, k=keys(alt), u=ucfirst, U=uppercase, L=lowercase */
333
+ operator: "Q" | "P" | "a" | "A" | "E" | "K" | "k" | "u" | "U" | "L";
293
334
  }
294
- /** ${!VAR} - indirect expansion */
335
+ /** ${!VAR} - indirect expansion, optionally combined with another operation like ${!ref-default} */
295
336
  export interface IndirectionOp {
296
337
  type: "Indirection";
338
+ /** Additional operation to apply after indirection (e.g., ${!ref-default}) */
339
+ innerOp?: InnerParameterOperation;
297
340
  }
298
341
  /** ${!arr[@]} or ${!arr[*]} - array keys/indices */
299
342
  export interface ArrayKeysOp {
@@ -327,8 +370,10 @@ export interface ArithmeticExpansionPart extends ASTNode {
327
370
  export interface ArithmeticExpressionNode extends ASTNode {
328
371
  type: "ArithmeticExpression";
329
372
  expression: ArithExpr;
373
+ /** Original expression text before parsing, used for re-parsing after variable expansion */
374
+ originalText?: string;
330
375
  }
331
- export type ArithExpr = ArithNumberNode | ArithVariableNode | ArithBinaryNode | ArithUnaryNode | ArithTernaryNode | ArithAssignmentNode | ArithGroupNode | ArithNestedNode | ArithCommandSubstNode | ArithBracedExpansionNode | ArithArrayElementNode | ArithDynamicBaseNode | ArithDynamicNumberNode | ArithConcatNode | ArithDoubleSubscriptNode | ArithNumberSubscriptNode;
376
+ export type ArithExpr = ArithNumberNode | ArithVariableNode | ArithSpecialVarNode | ArithBinaryNode | ArithUnaryNode | ArithTernaryNode | ArithAssignmentNode | ArithDynamicAssignmentNode | ArithDynamicElementNode | ArithGroupNode | ArithNestedNode | ArithCommandSubstNode | ArithBracedExpansionNode | ArithArrayElementNode | ArithDynamicBaseNode | ArithDynamicNumberNode | ArithConcatNode | ArithDoubleSubscriptNode | ArithNumberSubscriptNode | ArithSyntaxErrorNode | ArithSingleQuoteNode;
332
377
  export interface ArithBracedExpansionNode extends ASTNode {
333
378
  type: "ArithBracedExpansion";
334
379
  content: string;
@@ -370,6 +415,22 @@ export interface ArithNumberSubscriptNode extends ASTNode {
370
415
  number: string;
371
416
  errorToken: string;
372
417
  }
418
+ /** Syntax error in arithmetic expression - evaluated to error at runtime */
419
+ export interface ArithSyntaxErrorNode extends ASTNode {
420
+ type: "ArithSyntaxError";
421
+ errorToken: string;
422
+ message: string;
423
+ }
424
+ /**
425
+ * Single-quoted string in arithmetic expression.
426
+ * In $(()) expansion context, this causes an error.
427
+ * In (()) command context, this is evaluated as a number.
428
+ */
429
+ export interface ArithSingleQuoteNode extends ASTNode {
430
+ type: "ArithSingleQuote";
431
+ content: string;
432
+ value: number;
433
+ }
373
434
  export interface ArithNumberNode extends ASTNode {
374
435
  type: "ArithNumber";
375
436
  value: number;
@@ -377,6 +438,13 @@ export interface ArithNumberNode extends ASTNode {
377
438
  export interface ArithVariableNode extends ASTNode {
378
439
  type: "ArithVariable";
379
440
  name: string;
441
+ /** True if the variable was written with $ prefix (e.g., $x vs x) */
442
+ hasDollarPrefix?: boolean;
443
+ }
444
+ /** Special variable node: $*, $@, $#, $?, $-, $!, $$ */
445
+ export interface ArithSpecialVarNode extends ASTNode {
446
+ type: "ArithSpecialVar";
447
+ name: string;
380
448
  }
381
449
  export interface ArithBinaryNode extends ASTNode {
382
450
  type: "ArithBinary";
@@ -408,6 +476,24 @@ export interface ArithAssignmentNode extends ASTNode {
408
476
  stringKey?: string;
409
477
  value: ArithExpr;
410
478
  }
479
+ /** Dynamic assignment where variable name is built from concatenation: x$foo = 42 or x$foo[5] = 42 */
480
+ export interface ArithDynamicAssignmentNode extends ASTNode {
481
+ type: "ArithDynamicAssignment";
482
+ operator: ArithAssignmentOperator;
483
+ /** The target expression (ArithConcat) that evaluates to the variable name */
484
+ target: ArithExpr;
485
+ /** For array element assignment: the subscript expression */
486
+ subscript?: ArithExpr;
487
+ value: ArithExpr;
488
+ }
489
+ /** Dynamic array element where array name is built from concatenation: x$foo[5] */
490
+ export interface ArithDynamicElementNode extends ASTNode {
491
+ type: "ArithDynamicElement";
492
+ /** The expression (ArithConcat) that evaluates to the array name */
493
+ nameExpr: ArithExpr;
494
+ /** The subscript expression */
495
+ subscript: ArithExpr;
496
+ }
411
497
  export interface ArithGroupNode extends ASTNode {
412
498
  type: "ArithGroup";
413
499
  expression: ArithExpr;
@@ -492,8 +578,11 @@ export interface CondWordNode extends ASTNode {
492
578
  }
493
579
  export declare const AST: {
494
580
  script(statements: StatementNode[]): ScriptNode;
495
- statement(pipelines: PipelineNode[], operators?: ("&&" | "||" | ";")[], background?: boolean): StatementNode;
496
- pipeline(commands: CommandNode[], negated?: boolean): PipelineNode;
581
+ statement(pipelines: PipelineNode[], operators?: ("&&" | "||" | ";")[], background?: boolean, deferredError?: {
582
+ message: string;
583
+ token: string;
584
+ }, sourceText?: string): StatementNode;
585
+ pipeline(commands: CommandNode[], negated?: boolean, timed?: boolean, timePosix?: boolean, pipeStderr?: boolean[]): PipelineNode;
497
586
  simpleCommand(name: WordNode | null, args?: WordNode[], assignments?: AssignmentNode[], redirections?: RedirectionNode[]): SimpleCommandNode;
498
587
  word(parts: WordPart[]): WordNode;
499
588
  literal(value: string): LiteralPart;
@@ -504,7 +593,7 @@ export declare const AST: {
504
593
  commandSubstitution(body: ScriptNode, legacy?: boolean): CommandSubstitutionPart;
505
594
  arithmeticExpansion(expression: ArithmeticExpressionNode): ArithmeticExpansionPart;
506
595
  assignment(name: string, value: WordNode | null, append?: boolean, array?: WordNode[] | null): AssignmentNode;
507
- redirection(operator: RedirectionOperator, target: WordNode | HereDocNode, fd?: number | null): RedirectionNode;
596
+ redirection(operator: RedirectionOperator, target: WordNode | HereDocNode, fd?: number | null, fdVariable?: string): RedirectionNode;
508
597
  hereDoc(delimiter: string, content: WordNode, stripTabs?: boolean, quoted?: boolean): HereDocNode;
509
598
  ifNode(clauses: IfClause[], elseBody?: StatementNode[] | null, redirections?: RedirectionNode[]): IfNode;
510
599
  forNode(variable: string, words: WordNode[] | null, body: StatementNode[], redirections?: RedirectionNode[]): ForNode;
@@ -514,7 +603,7 @@ export declare const AST: {
514
603
  caseItem(patterns: WordNode[], body: StatementNode[], terminator?: ";;" | ";&" | ";;&"): CaseItemNode;
515
604
  subshell(body: StatementNode[], redirections?: RedirectionNode[]): SubshellNode;
516
605
  group(body: StatementNode[], redirections?: RedirectionNode[]): GroupNode;
517
- functionDef(name: string, body: CompoundCommandNode, redirections?: RedirectionNode[]): FunctionDefNode;
518
- conditionalCommand(expression: ConditionalExpressionNode, redirections?: RedirectionNode[]): ConditionalCommandNode;
519
- arithmeticCommand(expression: ArithmeticExpressionNode, redirections?: RedirectionNode[]): ArithmeticCommandNode;
606
+ functionDef(name: string, body: CompoundCommandNode, redirections?: RedirectionNode[], sourceFile?: string): FunctionDefNode;
607
+ conditionalCommand(expression: ConditionalExpressionNode, redirections?: RedirectionNode[], line?: number): ConditionalCommandNode;
608
+ arithmeticCommand(expression: ArithmeticExpressionNode, redirections?: RedirectionNode[], line?: number): ArithmeticCommandNode;
520
609
  };
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ import{a as r,b as d}from"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";var u={name:"alias",summary:"define or display aliases",usage:"alias [name[=value] ...]",options:[" --help display this help and exit"]},o="BASH_ALIAS_",m={name:"alias",async execute(e,a){if(d(e))return r(u);if(e.length===0){let t="";for(let[i,s]of Object.entries(a.env))if(i.startsWith(o)){let n=i.slice(o.length);t+=`alias ${n}='${s}'
3
+ `}return{stdout:t,stderr:"",exitCode:0}}let l=e[0]==="--"?e.slice(1):e;for(let t of l){let i=t.indexOf("=");if(i===-1){let s=o+t;return a.env[s]?{stdout:`alias ${t}='${a.env[s]}'
4
+ `,stderr:"",exitCode:0}:{stdout:"",stderr:`alias: ${t}: not found
5
+ `,exitCode:1}}else{let s=t.slice(0,i),n=t.slice(i+1);(n.startsWith("'")&&n.endsWith("'")||n.startsWith('"')&&n.endsWith('"'))&&(n=n.slice(1,-1)),a.env[o+s]=n}}return{stdout:"",stderr:"",exitCode:0}}},c={name:"unalias",async execute(e,a){if(d(e))return r({name:"unalias",summary:"remove alias definitions",usage:"unalias name [name ...]",options:["-a remove all aliases"," --help display this help and exit"]});if(e.length===0)return{stdout:"",stderr:`unalias: usage: unalias [-a] name [name ...]
6
+ `,exitCode:1};if(e[0]==="-a"){for(let s of Object.keys(a.env))s.startsWith(o)&&delete a.env[s];return{stdout:"",stderr:"",exitCode:0}}let l=e[0]==="--"?e.slice(1):e,t=!1,i="";for(let s of l){let n=o+s;a.env[n]?delete a.env[n]:(i+=`unalias: ${s}: not found
7
+ `,t=!0)}return{stdout:"",stderr:i,exitCode:t?1:0}}};export{m as aliasCommand,c as unaliasCommand};
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env node
2
+ import{k as C}from"./chunk-K5IXNHO5.js";import{a as te,b as ne,c as X}from"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";function K(e={}){let{fieldSep:t=/\s+/,maxIterations:n=1e4,maxRecursionDepth:i=100,fs:a,cwd:s,exec:o}=e;return{FS:" ",OFS:" ",ORS:`
3
+ `,OFMT:"%.6g",NR:0,NF:0,FNR:0,FILENAME:"",RSTART:0,RLENGTH:-1,SUBSEP:"",fields:[],line:"",vars:{},arrays:{},arrayAliases:new Map,ARGC:0,ARGV:{},ENVIRON:{},functions:new Map,fieldSep:t,maxIterations:n,maxRecursionDepth:i,currentRecursionDepth:0,exitCode:0,shouldExit:!1,shouldNext:!1,shouldNextFile:!1,loopBreak:!1,loopContinue:!1,hasReturn:!1,inEndBlock:!1,output:"",openedFiles:new Set,fs:a,cwd:s,exec:o}}function re(e,t,n){switch(n){case"+":return e+t;case"-":return e-t;case"*":return e*t;case"/":return t!==0?e/t:0;case"%":return t!==0?e%t:0;case"^":case"**":return e**t;default:return 0}}function k(e){if(typeof e=="number")return e;let t=parseFloat(e);return Number.isNaN(t)?0:t}function m(e){return typeof e=="string"?e:(Number.isInteger(e),String(e))}async function G(e,t){if(e.type==="regex")return e.pattern;let n=m(await t.evalExpr(e));return n.startsWith("/")&&n.endsWith("/")&&(n=n.slice(1,-1)),n}async function se(e,t){return e?e.type==="variable"?e.name:e.type==="field"?`$${Math.floor(k(await t.evalExpr(e.index)))}`:"$0":"$0"}function ae(e,t){if(e==="$0")return t.line;if(e.startsWith("$")){let n=parseInt(e.slice(1),10)-1;return t.fields[n]||""}return m(t.vars[e]??"")}function oe(e,t,n){if(e==="$0")n.line=t,n.fields=n.FS===" "?t.trim().split(/\s+/).filter(Boolean):t.split(n.fieldSep),n.NF=n.fields.length;else if(e.startsWith("$")){let i=parseInt(e.slice(1),10)-1;for(;n.fields.length<=i;)n.fields.push("");n.fields[i]=t,n.NF=n.fields.length,n.line=n.fields.join(n.OFS)}else n.vars[e]=t}async function ge(e,t,n){return e.length===0?t.line.length:m(await n.evalExpr(e[0])).length}async function ke(e,t,n){if(e.length<2)return"";let i=m(await n.evalExpr(e[0])),a=Math.floor(k(await n.evalExpr(e[1])))-1;if(e.length>=3){let s=Math.floor(k(await n.evalExpr(e[2])));return i.substr(Math.max(0,a),s)}return i.substr(Math.max(0,a))}async function Ce(e,t,n){if(e.length<2)return 0;let i=m(await n.evalExpr(e[0])),a=m(await n.evalExpr(e[1])),s=i.indexOf(a);return s===-1?0:s+1}async function Le(e,t,n){if(e.length<2)return 0;let i=m(await n.evalExpr(e[0])),a=e[1];if(a.type!=="variable")return 0;let s=a.name,o=t.FS;if(e.length>=3){let h=e[2];if(h.type==="regex")o=new RegExp(h.pattern);else{let N=m(await n.evalExpr(h));o=N===" "?/\s+/:N}}else t.FS===" "&&(o=/\s+/);let l=i.split(o);t.arrays[s]={};for(let h=0;h<l.length;h++)t.arrays[s][String(h+1)]=l[h];return l.length}async function be(e,t,n){if(e.length<2)return 0;let i=await G(e[0],n),a=m(await n.evalExpr(e[1])),s=await se(e[2],n),o=ae(s,t);try{let l=new RegExp(i),h=o.replace(l,ce(a)),N=h!==o?1:0;return oe(s,h,t),N}catch{return 0}}async function Oe(e,t,n){if(e.length<2)return 0;let i=await G(e[0],n),a=m(await n.evalExpr(e[1])),s=await se(e[2],n),o=ae(s,t);try{let l=new RegExp(i,"g"),h=o.match(l),N=h?h.length:0,v=o.replace(l,ce(a));return oe(s,v,t),N}catch{return 0}}function ce(e){return t=>{let n="",i=0;for(;i<e.length;)if(e[i]==="\\"&&i+1<e.length){let a=e[i+1];a==="&"?(n+="&",i+=2):a==="\\"?(n+="\\",i+=2):(n+=e[i+1],i+=2)}else e[i]==="&"?(n+=t,i++):(n+=e[i],i++);return n}}async function Pe(e,t,n){if(e.length<2)return t.RSTART=0,t.RLENGTH=-1,0;let i=m(await n.evalExpr(e[0])),a=await G(e[1],n);try{let o=new RegExp(a).exec(i);if(o)return t.RSTART=o.index+1,t.RLENGTH=o[0].length,t.RSTART}catch{}return t.RSTART=0,t.RLENGTH=-1,0}async function Me(e,t,n){if(e.length<3)return"";let i=await G(e[0],n),a=m(await n.evalExpr(e[1])),s=m(await n.evalExpr(e[2])),o=e.length>=4?m(await n.evalExpr(e[3])):t.line;try{let l=s.toLowerCase()==="g",h=l?0:parseInt(s,10)||1;if(l){let N=new RegExp(i,"g");return o.replace(N,(v,...R)=>ie(a,v,R.slice(0,-2)))}else{let N=0,v=new RegExp(i,"g");return o.replace(v,(R,...I)=>(N++,N===h?ie(a,R,I.slice(0,-2)):R))}}catch{return o}}function ie(e,t,n){let i="",a=0;for(;a<e.length;)if(e[a]==="\\"&&a+1<e.length){let s=e[a+1];if(s==="&")i+="&",a+=2;else if(s==="0")i+=t,a+=2;else if(s>="1"&&s<="9"){let o=parseInt(s,10)-1;i+=n[o]||"",a+=2}else s==="n"?(i+=`
4
+ `,a+=2):s==="t"?(i+=" ",a+=2):(i+=s,a+=2)}else e[a]==="&"?(i+=t,a++):(i+=e[a],a++);return i}async function Te(e,t,n){return e.length===0?"":m(await n.evalExpr(e[0])).toLowerCase()}async function Fe(e,t,n){return e.length===0?"":m(await n.evalExpr(e[0])).toUpperCase()}async function _e(e,t,n){if(e.length===0)return"";let i=m(await n.evalExpr(e[0])),a=[];for(let s=1;s<e.length;s++)a.push(await n.evalExpr(e[s]));return D(i,a)}async function Ge(e,t,n){return e.length===0?0:Math.floor(k(await n.evalExpr(e[0])))}async function De(e,t,n){return e.length===0?0:Math.sqrt(k(await n.evalExpr(e[0])))}async function xe(e,t,n){return e.length===0?0:Math.sin(k(await n.evalExpr(e[0])))}async function Ue(e,t,n){return e.length===0?0:Math.cos(k(await n.evalExpr(e[0])))}async function Be(e,t,n){let i=e.length>0?k(await n.evalExpr(e[0])):0,a=e.length>1?k(await n.evalExpr(e[1])):0;return Math.atan2(i,a)}async function He(e,t,n){return e.length===0?0:Math.log(k(await n.evalExpr(e[0])))}async function $e(e,t,n){return e.length===0?1:Math.exp(k(await n.evalExpr(e[0])))}function We(e,t,n){return t.random?t.random():Math.random()}async function Ve(e,t,n){let i=e.length>0?k(await n.evalExpr(e[0])):Date.now();return t.vars._srand_seed=i,i}function Xe(e,t){return()=>{throw new Error(`${e}() is not supported - ${t}`)}}function Q(e){return()=>{throw new Error(`function '${e}()' is not implemented`)}}function D(e,t){let n=0,i="",a=0;for(;a<e.length;)if(e[a]==="%"&&a+1<e.length){let s=a+1,o="",l="",h="",N,v=s;for(;s<e.length&&/\d/.test(e[s]);)s++;s>v&&e[s]==="$"?(N=parseInt(e.substring(v,s),10)-1,s++):s=v;let R=()=>{if(s<e.length){if(s+1<e.length&&(e[s]==="h"&&e[s+1]==="h"||e[s]==="l"&&e[s+1]==="l")){s+=2;return}/[lzjh]/.test(e[s])&&s++}};for(;s<e.length&&/[-+ #0]/.test(e[s]);)o+=e[s++];if(e[s]==="*"){let c=t[n++],p=c!==void 0?Math.floor(Number(c)):0;p<0?(o+="-",l=String(-p)):l=String(p),s++}else for(;s<e.length&&/\d/.test(e[s]);)l+=e[s++];if(e[s]===".")if(s++,e[s]==="*"){let c=t[n++];h=String(c!==void 0?Math.floor(Number(c)):0),s++}else for(;s<e.length&&/\d/.test(e[s]);)h+=e[s++];R();let I=e[s],w=t[N!==void 0?N:n];switch(I){case"s":{let c=w!==void 0?String(w):"";if(h&&(c=c.substring(0,parseInt(h,10))),l){let p=parseInt(l,10);o.includes("-")?c=c.padEnd(p):c=c.padStart(p)}i+=c,N===void 0&&n++;break}case"d":case"i":{let c=w!==void 0?Math.floor(Number(w)):0;Number.isNaN(c)&&(c=0);let p=c<0,E=Math.abs(c).toString();if(h){let L=parseInt(h,10);E=E.padStart(L,"0")}let d="";p?d="-":o.includes("+")?d="+":o.includes(" ")&&(d=" ");let y=d+E;if(l){let L=parseInt(l,10);o.includes("-")?y=y.padEnd(L):o.includes("0")&&!h?y=d+E.padStart(L-d.length,"0"):y=y.padStart(L)}i+=y,N===void 0&&n++;break}case"f":{let c=w!==void 0?Number(w):0;Number.isNaN(c)&&(c=0);let p=h?parseInt(h,10):6,E=c.toFixed(p);if(l){let d=parseInt(l,10);o.includes("-")?E=E.padEnd(d):E=E.padStart(d)}i+=E,N===void 0&&n++;break}case"e":case"E":{let c=w!==void 0?Number(w):0;Number.isNaN(c)&&(c=0);let p=h?parseInt(h,10):6,E=c.toExponential(p);if(I==="E"&&(E=E.toUpperCase()),l){let d=parseInt(l,10);o.includes("-")?E=E.padEnd(d):E=E.padStart(d)}i+=E,N===void 0&&n++;break}case"g":case"G":{let c=w!==void 0?Number(w):0;Number.isNaN(c)&&(c=0);let p=h?parseInt(h,10):6,E=c!==0?Math.floor(Math.log10(Math.abs(c))):0,d;if(c===0?d="0":E<-4||E>=p?(d=c.toExponential(p-1),I==="G"&&(d=d.toUpperCase())):d=c.toPrecision(p),d.includes(".")&&(d=d.replace(/\.?0+$/,"").replace(/\.?0+e/,"e")),d.includes("e")&&(d=d.replace(/\.?0+e/,"e")),l){let y=parseInt(l,10);o.includes("-")?d=d.padEnd(y):d=d.padStart(y)}i+=d,N===void 0&&n++;break}case"x":case"X":{let c=w!==void 0?Math.floor(Number(w)):0;Number.isNaN(c)&&(c=0);let p=Math.abs(c).toString(16);if(I==="X"&&(p=p.toUpperCase()),h){let y=parseInt(h,10);p=p.padStart(y,"0")}let E=c<0?"-":"",d=E+p;if(l){let y=parseInt(l,10);o.includes("-")?d=d.padEnd(y):o.includes("0")&&!h?d=E+p.padStart(y-E.length,"0"):d=d.padStart(y)}i+=d,N===void 0&&n++;break}case"o":{let c=w!==void 0?Math.floor(Number(w)):0;Number.isNaN(c)&&(c=0);let p=Math.abs(c).toString(8);if(h){let y=parseInt(h,10);p=p.padStart(y,"0")}let E=c<0?"-":"",d=E+p;if(l){let y=parseInt(l,10);o.includes("-")?d=d.padEnd(y):o.includes("0")&&!h?d=E+p.padStart(y-E.length,"0"):d=d.padStart(y)}i+=d,N===void 0&&n++;break}case"c":{typeof w=="number"?i+=String.fromCharCode(w):i+=String(w??"").charAt(0)||"",N===void 0&&n++;break}case"%":i+="%";break;default:i+=e.substring(a,s+1)}a=s+1}else if(e[a]==="\\"&&a+1<e.length){let s=e[a+1];switch(s){case"n":i+=`
5
+ `;break;case"t":i+=" ";break;case"r":i+="\r";break;case"\\":i+="\\";break;default:i+=s}a+=2}else i+=e[a++];return i}var le={length:ge,substr:ke,index:Ce,split:Le,sub:be,gsub:Oe,match:Pe,gensub:Me,tolower:Te,toupper:Fe,sprintf:_e,int:Ge,sqrt:De,sin:xe,cos:Ue,atan2:Be,log:He,exp:$e,rand:We,srand:Ve,system:Xe("system","shell execution not allowed in sandboxed environment"),close:()=>0,fflush:()=>0,systime:Q("systime"),mktime:Q("mktime"),strftime:Q("strftime")};function g(e){return typeof e=="number"?e!==0:!(e===""||e==="0")}function A(e){if(typeof e=="number")return e;let t=parseFloat(e);return Number.isNaN(t)?0:t}function S(e){return typeof e=="string"?e:(Number.isInteger(e),String(e))}function j(e){if(typeof e=="number")return!0;let t=String(e).trim();return t===""?!1:!Number.isNaN(Number(t))}function T(e,t){try{return new RegExp(e).test(t)}catch{return!1}}function ue(e,t){return t===""?[]:e.FS===" "?t.trim().split(/\s+/).filter(Boolean):t.split(e.fieldSep)}function x(e,t){return t===0?e.line:t<0||t>e.fields.length?"":e.fields[t-1]??""}function q(e,t,n){if(t===0)e.line=S(n),e.fields=ue(e,e.line),e.NF=e.fields.length;else if(t>0){for(;e.fields.length<t;)e.fields.push("");e.fields[t-1]=S(n),e.NF=e.fields.length,e.line=e.fields.join(e.OFS)}}function O(e,t){e.line=t,e.fields=ue(e,t),e.NF=e.fields.length}function he(e,t){if(e.FS=t,t===" ")e.fieldSep=/\s+/;else try{e.fieldSep=new RegExp(t)}catch{e.fieldSep=new RegExp(t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))}}function U(e,t){switch(t){case"FS":return e.FS;case"OFS":return e.OFS;case"ORS":return e.ORS;case"OFMT":return e.OFMT;case"NR":return e.NR;case"NF":return e.NF;case"FNR":return e.FNR;case"FILENAME":return e.FILENAME;case"RSTART":return e.RSTART;case"RLENGTH":return e.RLENGTH;case"SUBSEP":return e.SUBSEP;case"ARGC":return e.ARGC}return e.vars[t]??""}function P(e,t,n){switch(t){case"FS":he(e,S(n));return;case"OFS":e.OFS=S(n);return;case"ORS":e.ORS=S(n);return;case"OFMT":e.OFMT=S(n);return;case"NR":e.NR=Math.floor(A(n));return;case"NF":{let i=Math.floor(A(n));if(i<e.NF)e.fields=e.fields.slice(0,i),e.line=e.fields.join(e.OFS);else if(i>e.NF){for(;e.fields.length<i;)e.fields.push("");e.line=e.fields.join(e.OFS)}e.NF=i;return}case"FNR":e.FNR=Math.floor(A(n));return;case"FILENAME":e.FILENAME=S(n);return;case"RSTART":e.RSTART=Math.floor(A(n));return;case"RLENGTH":e.RLENGTH=Math.floor(A(n));return;case"SUBSEP":e.SUBSEP=S(n);return}e.vars[t]=n}function F(e,t){let n=t,i=new Set,a=e.arrayAliases.get(n);for(;a!==void 0&&!i.has(n);)i.add(n),n=a,a=e.arrayAliases.get(n);return n}function B(e,t,n){if(t==="ARGV")return e.ARGV[n]??"";if(t==="ENVIRON")return e.ENVIRON[n]??"";let i=F(e,t);return e.arrays[i]?.[n]??""}function z(e,t,n,i){let a=F(e,t);e.arrays[a]||(e.arrays[a]={}),e.arrays[a][n]=i}function pe(e,t,n){if(t==="ARGV")return e.ARGV[n]!==void 0;if(t==="ENVIRON")return e.ENVIRON[n]!==void 0;let i=F(e,t);return e.arrays[i]?.[n]!==void 0}function fe(e,t,n){let i=F(e,t);e.arrays[i]&&delete e.arrays[i][n]}function de(e,t){let n=F(e,t);delete e.arrays[n]}var J=null;function Ee(e){J=e}async function f(e,t){switch(t.type){case"number":return t.value;case"string":return t.value;case"regex":return T(t.pattern,e.line)?1:0;case"field":return Ke(e,t);case"variable":return U(e,t.name);case"array_access":return Qe(e,t);case"binary":return je(e,t);case"unary":return Je(e,t);case"ternary":return g(await f(e,t.condition))?await f(e,t.consequent):await f(e,t.alternate);case"call":return Ze(e,t.name,t.args);case"assignment":return et(e,t);case"pre_increment":return tt(e,t.operand);case"pre_decrement":return nt(e,t.operand);case"post_increment":return rt(e,t.operand);case"post_decrement":return it(e,t.operand);case"in":return st(e,t.key,t.array);case"getline":return at(e,t.variable,t.file,t.command);case"tuple":return lt(e,t.elements);default:return""}}async function Ke(e,t){let n=Math.floor(A(await f(e,t.index)));return x(e,n)}async function Qe(e,t){let n=S(await f(e,t.key));return B(e,t.array,n)}async function je(e,t){let n=t.operator;if(n==="||")return g(await f(e,t.left))||g(await f(e,t.right))?1:0;if(n==="&&")return g(await f(e,t.left))&&g(await f(e,t.right))?1:0;if(n==="~"){let l=await f(e,t.left),h=t.right.type==="regex"?t.right.pattern:S(await f(e,t.right));try{return new RegExp(h).test(S(l))?1:0}catch{return 0}}if(n==="!~"){let l=await f(e,t.left),h=t.right.type==="regex"?t.right.pattern:S(await f(e,t.right));try{return new RegExp(h).test(S(l))?0:1}catch{return 1}}let i=await f(e,t.left),a=await f(e,t.right);if(n===" ")return S(i)+S(a);if(qe(n))return ze(i,a,n);let s=A(i),o=A(a);return re(s,o,n)}function qe(e){return["<","<=",">",">=","==","!="].includes(e)}function ze(e,t,n){let i=j(e),a=j(t);if(i&&a){let l=A(e),h=A(t);switch(n){case"<":return l<h?1:0;case"<=":return l<=h?1:0;case">":return l>h?1:0;case">=":return l>=h?1:0;case"==":return l===h?1:0;case"!=":return l!==h?1:0}}let s=S(e),o=S(t);switch(n){case"<":return s<o?1:0;case"<=":return s<=o?1:0;case">":return s>o?1:0;case">=":return s>=o?1:0;case"==":return s===o?1:0;case"!=":return s!==o?1:0}return 0}async function Je(e,t){let n=await f(e,t.operand);switch(t.operator){case"!":return g(n)?0:1;case"-":return-A(n);case"+":return+A(n);default:return n}}async function Ze(e,t,n){let i=le[t];if(i)return i(n,e,{evalExpr:s=>f(e,s)});let a=e.functions.get(t);return a?Ye(e,a,n):""}async function Ye(e,t,n){if(e.currentRecursionDepth++,e.currentRecursionDepth>e.maxRecursionDepth)throw e.currentRecursionDepth--,new C(`awk: recursion depth exceeded maximum (${e.maxRecursionDepth})`,"recursion",e.output);let i={};for(let o of t.params)i[o]=e.vars[o];let a=[];for(let o=0;o<t.params.length;o++){let l=t.params[o];if(o<n.length){let h=n[o];h.type==="variable"&&(e.arrayAliases.set(l,h.name),a.push(l));let N=await f(e,h);e.vars[l]=N}else e.vars[l]=""}e.hasReturn=!1,e.returnValue=void 0,J&&await J(e,t.body.statements);let s=e.returnValue??"";for(let o of t.params)i[o]!==void 0?e.vars[o]=i[o]:delete e.vars[o];for(let o of a)e.arrayAliases.delete(o);return e.hasReturn=!1,e.returnValue=void 0,e.currentRecursionDepth--,s}async function et(e,t){let n=await f(e,t.value),i=t.target,a=t.operator,s;if(a==="=")s=n;else{let o;if(i.type==="field"){let N=Math.floor(A(await f(e,i.index)));o=x(e,N)}else if(i.type==="variable")o=U(e,i.name);else{let N=S(await f(e,i.key));o=B(e,i.array,N)}let l=A(o),h=A(n);switch(a){case"+=":s=l+h;break;case"-=":s=l-h;break;case"*=":s=l*h;break;case"/=":s=h!==0?l/h:0;break;case"%=":s=h!==0?l%h:0;break;case"^=":s=l**h;break;default:s=n}}if(i.type==="field"){let o=Math.floor(A(await f(e,i.index)));q(e,o,s)}else if(i.type==="variable")P(e,i.name,s);else{let o=S(await f(e,i.key));z(e,i.array,o,s)}return s}async function H(e,t,n,i){let a;if(t.type==="field"){let s=Math.floor(A(await f(e,t.index)));a=A(x(e,s)),q(e,s,a+n)}else if(t.type==="variable")a=A(U(e,t.name)),P(e,t.name,a+n);else{let s=S(await f(e,t.key));a=A(B(e,t.array,s)),z(e,t.array,s,a+n)}return i?a+n:a}async function tt(e,t){return H(e,t,1,!0)}async function nt(e,t){return H(e,t,-1,!0)}async function rt(e,t){return H(e,t,1,!1)}async function it(e,t){return H(e,t,-1,!1)}async function st(e,t,n){let i;if(t.type==="tuple"){let a=[];for(let s of t.elements)a.push(S(await f(e,s)));i=a.join(e.SUBSEP)}else i=S(await f(e,t));return pe(e,n,i)?1:0}async function at(e,t,n,i){if(i)return ot(e,t,i);if(n)return ct(e,t,n);if(!e.lines||e.lineIndex===void 0)return-1;let a=e.lineIndex+1;if(a>=e.lines.length)return 0;let s=e.lines[a];return t?P(e,t,s):O(e,s),e.NR++,e.lineIndex=a,1}async function ot(e,t,n){if(!e.exec)return-1;let i=S(await f(e,n)),a=`__cmd_${i}`,s=`__cmdi_${i}`,o,l;if(e.vars[a]===void 0)try{o=(await e.exec(i)).stdout.split(`
6
+ `),o.length>0&&o[o.length-1]===""&&o.pop(),e.vars[a]=JSON.stringify(o),e.vars[s]=-1,l=-1}catch{return-1}else o=JSON.parse(e.vars[a]),l=e.vars[s];let h=l+1;if(h>=o.length)return 0;let N=o[h];return e.vars[s]=h,t?P(e,t,N):O(e,N),1}async function ct(e,t,n){if(!e.fs||!e.cwd)return-1;let i=S(await f(e,n));if(i==="/dev/null")return 0;let a=e.fs.resolvePath(e.cwd,i),s=`__fc_${a}`,o=`__fi_${a}`,l,h;if(e.vars[s]===void 0)try{l=(await e.fs.readFile(a)).split(`
7
+ `),l.length>0&&l[l.length-1]===""&&l.pop(),e.vars[s]=JSON.stringify(l),e.vars[o]=-1,h=-1}catch{return-1}else l=JSON.parse(e.vars[s]),h=e.vars[o];let N=h+1;if(N>=l.length)return 0;let v=l[N];return e.vars[o]=N,t?P(e,t,v):O(e,v),1}async function lt(e,t){if(t.length===0)return"";for(let n=0;n<t.length-1;n++)await f(e,t[n]);return f(e,t[t.length-1])}Ee(M);async function M(e,t){for(let n of t)if(await b(e,n),ut(e))break}function ut(e){return e.shouldExit||e.shouldNext||e.shouldNextFile||e.loopBreak||e.loopContinue||e.hasReturn}async function b(e,t){switch(t.type){case"block":await M(e,t.statements);break;case"expr_stmt":await f(e,t.expression);break;case"print":await ht(e,t.args,t.output);break;case"printf":await pt(e,t.format,t.args,t.output);break;case"if":await ft(e,t);break;case"while":await dt(e,t);break;case"do_while":await Et(e,t);break;case"for":await Nt(e,t);break;case"for_in":await St(e,t);break;case"break":e.loopBreak=!0;break;case"continue":e.loopContinue=!0;break;case"next":e.shouldNext=!0;break;case"nextfile":e.shouldNextFile=!0;break;case"exit":e.shouldExit=!0,e.exitCode=t.code?Math.floor(A(await f(e,t.code))):0;break;case"return":e.hasReturn=!0,e.returnValue=t.value?await f(e,t.value):"";break;case"delete":await yt(e,t.target);break}}async function ht(e,t,n){let i=[];for(let s of t){let o=await f(e,s);typeof o=="number"?Number.isInteger(o)&&Math.abs(o)<Number.MAX_SAFE_INTEGER?i.push(String(o)):i.push(D(e.OFMT,[o])):i.push(S(o))}let a=i.join(e.OFS)+e.ORS;n?await Ne(e,n.redirect,n.file,a):e.output+=a}async function pt(e,t,n,i){let a=S(await f(e,t)),s=[];for(let l of n)s.push(await f(e,l));let o=D(a,s);i?await Ne(e,i.redirect,i.file,o):e.output+=o}async function Ne(e,t,n,i){if(!e.fs||!e.cwd){e.output+=i;return}let a=S(await f(e,n)),s=e.fs.resolvePath(e.cwd,a);t===">"?e.openedFiles.has(s)?await e.fs.appendFile(s,i):(await e.fs.writeFile(s,i),e.openedFiles.add(s)):(e.openedFiles.has(s)||e.openedFiles.add(s),await e.fs.appendFile(s,i))}async function ft(e,t){g(await f(e,t.condition))?await b(e,t.consequent):t.alternate&&await b(e,t.alternate)}async function dt(e,t){let n=0;for(;g(await f(e,t.condition));){if(n++,n>e.maxIterations)throw new C(`awk: while loop exceeded maximum iterations (${e.maxIterations})`,"iterations",e.output);if(e.loopContinue=!1,await b(e,t.body),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break}}async function Et(e,t){let n=0;do{if(n++,n>e.maxIterations)throw new C(`awk: do-while loop exceeded maximum iterations (${e.maxIterations})`,"iterations",e.output);if(e.loopContinue=!1,await b(e,t.body),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break}while(g(await f(e,t.condition)))}async function Nt(e,t){t.init&&await f(e,t.init);let n=0;for(;!t.condition||g(await f(e,t.condition));){if(n++,n>e.maxIterations)throw new C(`awk: for loop exceeded maximum iterations (${e.maxIterations})`,"iterations",e.output);if(e.loopContinue=!1,await b(e,t.body),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break;t.update&&await f(e,t.update)}}async function St(e,t){let n=e.arrays[t.array];if(n)for(let i of Object.keys(n)){if(e.vars[t.variable]=i,e.loopContinue=!1,await b(e,t.body),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break}}async function yt(e,t){if(t.type==="array_access"){let n=S(await f(e,t.key));fe(e,t.array,n)}else t.type==="variable"&&de(e,t.name)}var _=class{ctx;program=null;rangeStates=[];constructor(t){this.ctx=t}execute(t){this.program=t,this.ctx.output="";for(let n of t.functions)this.ctx.functions.set(n.name,n);this.rangeStates=t.rules.map(()=>!1)}async executeBegin(){if(this.program){for(let t of this.program.rules)if(t.pattern?.type==="begin"&&(await M(this.ctx,t.action.statements),this.ctx.shouldExit))break}}async executeLine(t){if(!(!this.program||this.ctx.shouldExit)){O(this.ctx,t),this.ctx.NR++,this.ctx.FNR++,this.ctx.shouldNext=!1;for(let n=0;n<this.program.rules.length&&!(this.ctx.shouldExit||this.ctx.shouldNext||this.ctx.shouldNextFile);n++){let i=this.program.rules[n];i.pattern?.type==="begin"||i.pattern?.type==="end"||await this.matchesRule(i,n)&&await M(this.ctx,i.action.statements)}}}async executeEnd(){if(this.program&&!this.ctx.inEndBlock){this.ctx.inEndBlock=!0,this.ctx.shouldExit=!1;for(let t of this.program.rules)if(t.pattern?.type==="end"&&(await M(this.ctx,t.action.statements),this.ctx.shouldExit))break;this.ctx.inEndBlock=!1}}getOutput(){return this.ctx.output}getExitCode(){return this.ctx.exitCode}getContext(){return this.ctx}async matchesRule(t,n){let i=t.pattern;if(!i)return!0;switch(i.type){case"begin":case"end":return!1;case"regex_pattern":return T(i.pattern,this.ctx.line);case"expr_pattern":return g(await f(this.ctx,i.expression));case"range":{let a=await this.matchPattern(i.start),s=await this.matchPattern(i.end);return this.rangeStates[n]?(s&&(this.rangeStates[n]=!1),!0):a?(this.rangeStates[n]=!0,s&&(this.rangeStates[n]=!1),!0):!1}default:return!1}}async matchPattern(t){switch(t.type){case"regex_pattern":return T(t.pattern,this.ctx.line);case"expr_pattern":return g(await f(this.ctx,t.expression));default:return!1}}};var r;(function(e){e.NUMBER="NUMBER",e.STRING="STRING",e.REGEX="REGEX",e.IDENT="IDENT",e.BEGIN="BEGIN",e.END="END",e.IF="IF",e.ELSE="ELSE",e.WHILE="WHILE",e.DO="DO",e.FOR="FOR",e.IN="IN",e.BREAK="BREAK",e.CONTINUE="CONTINUE",e.NEXT="NEXT",e.NEXTFILE="NEXTFILE",e.EXIT="EXIT",e.RETURN="RETURN",e.DELETE="DELETE",e.FUNCTION="FUNCTION",e.PRINT="PRINT",e.PRINTF="PRINTF",e.GETLINE="GETLINE",e.PLUS="PLUS",e.MINUS="MINUS",e.STAR="STAR",e.SLASH="SLASH",e.PERCENT="PERCENT",e.CARET="CARET",e.EQ="EQ",e.NE="NE",e.LT="LT",e.GT="GT",e.LE="LE",e.GE="GE",e.MATCH="MATCH",e.NOT_MATCH="NOT_MATCH",e.AND="AND",e.OR="OR",e.NOT="NOT",e.ASSIGN="ASSIGN",e.PLUS_ASSIGN="PLUS_ASSIGN",e.MINUS_ASSIGN="MINUS_ASSIGN",e.STAR_ASSIGN="STAR_ASSIGN",e.SLASH_ASSIGN="SLASH_ASSIGN",e.PERCENT_ASSIGN="PERCENT_ASSIGN",e.CARET_ASSIGN="CARET_ASSIGN",e.INCREMENT="INCREMENT",e.DECREMENT="DECREMENT",e.QUESTION="QUESTION",e.COLON="COLON",e.COMMA="COMMA",e.SEMICOLON="SEMICOLON",e.NEWLINE="NEWLINE",e.LPAREN="LPAREN",e.RPAREN="RPAREN",e.LBRACE="LBRACE",e.RBRACE="RBRACE",e.LBRACKET="LBRACKET",e.RBRACKET="RBRACKET",e.DOLLAR="DOLLAR",e.APPEND="APPEND",e.PIPE="PIPE",e.EOF="EOF"})(r||(r={}));var Rt={BEGIN:r.BEGIN,END:r.END,if:r.IF,else:r.ELSE,while:r.WHILE,do:r.DO,for:r.FOR,in:r.IN,break:r.BREAK,continue:r.CONTINUE,next:r.NEXT,nextfile:r.NEXTFILE,exit:r.EXIT,return:r.RETURN,delete:r.DELETE,function:r.FUNCTION,print:r.PRINT,printf:r.PRINTF,getline:r.GETLINE};function At(e){return e.replace(/\[\[:space:\]\]/g,"[ \\t\\n\\r\\f\\v]").replace(/\[\[:blank:\]\]/g,"[ \\t]").replace(/\[\[:alpha:\]\]/g,"[a-zA-Z]").replace(/\[\[:digit:\]\]/g,"[0-9]").replace(/\[\[:alnum:\]\]/g,"[a-zA-Z0-9]").replace(/\[\[:upper:\]\]/g,"[A-Z]").replace(/\[\[:lower:\]\]/g,"[a-z]").replace(/\[\[:punct:\]\]/g,"[!\"#$%&'()*+,\\-./:;<=>?@\\[\\]\\\\^_`{|}~]").replace(/\[\[:xdigit:\]\]/g,"[0-9A-Fa-f]").replace(/\[\[:graph:\]\]/g,"[!-~]").replace(/\[\[:print:\]\]/g,"[ -~]").replace(/\[\[:cntrl:\]\]/g,"[\\x00-\\x1f\\x7f]")}var $=class{input;pos=0;line=1;column=1;lastTokenType=null;constructor(t){this.input=t}tokenize(){let t=[];for(;this.pos<this.input.length;){let n=this.nextToken();n&&(t.push(n),this.lastTokenType=n.type)}return t.push(this.makeToken(r.EOF,"")),t}makeToken(t,n){return{type:t,value:n,line:this.line,column:this.column}}peek(t=0){return this.input[this.pos+t]||""}advance(){let t=this.input[this.pos++]||"";return t===`
8
+ `?(this.line++,this.column=1):this.column++,t}skipWhitespace(){for(;this.pos<this.input.length;){let t=this.peek();if(t===" "||t===" "||t==="\r")this.advance();else if(t==="\\")if(this.peek(1)===`
9
+ `)this.advance(),this.advance();else break;else if(t==="#")for(;this.pos<this.input.length&&this.peek()!==`
10
+ `;)this.advance();else break}}nextToken(){if(this.skipWhitespace(),this.pos>=this.input.length)return null;let t=this.line,n=this.column,i=this.peek();return i===`
11
+ `?(this.advance(),{type:r.NEWLINE,value:`
12
+ `,line:t,column:n}):i==='"'?this.readString():i==="/"&&this.canBeRegex()?this.readRegex():this.isDigit(i)||i==="."&&this.isDigit(this.peek(1))?this.readNumber():this.isAlpha(i)||i==="_"?this.readIdentifier():this.readOperator()}canBeRegex(){return new Set([null,r.NEWLINE,r.SEMICOLON,r.LBRACE,r.RBRACE,r.LPAREN,r.LBRACKET,r.COMMA,r.ASSIGN,r.PLUS_ASSIGN,r.MINUS_ASSIGN,r.STAR_ASSIGN,r.SLASH_ASSIGN,r.PERCENT_ASSIGN,r.CARET_ASSIGN,r.AND,r.OR,r.NOT,r.MATCH,r.NOT_MATCH,r.QUESTION,r.COLON,r.LT,r.GT,r.LE,r.GE,r.EQ,r.NE,r.PLUS,r.MINUS,r.STAR,r.PERCENT,r.CARET,r.PRINT,r.PRINTF,r.IF,r.WHILE,r.DO,r.FOR,r.RETURN]).has(this.lastTokenType)}readString(){let t=this.line,n=this.column;this.advance();let i="";for(;this.pos<this.input.length&&this.peek()!=='"';)if(this.peek()==="\\"){this.advance();let a=this.advance();switch(a){case"n":i+=`
13
+ `;break;case"t":i+=" ";break;case"r":i+="\r";break;case"f":i+="\f";break;case"b":i+="\b";break;case"v":i+="\v";break;case"a":i+="\x07";break;case"\\":i+="\\";break;case'"':i+='"';break;case"/":i+="/";break;case"x":{let s="";for(;s.length<2&&/[0-9a-fA-F]/.test(this.peek());)s+=this.advance();s.length>0?i+=String.fromCharCode(parseInt(s,16)):i+="x";break}default:if(/[0-7]/.test(a)){let s=a;for(;s.length<3&&/[0-7]/.test(this.peek());)s+=this.advance();i+=String.fromCharCode(parseInt(s,8))}else i+=a}}else i+=this.advance();return this.peek()==='"'&&this.advance(),{type:r.STRING,value:i,line:t,column:n}}readRegex(){let t=this.line,n=this.column;this.advance();let i="";for(;this.pos<this.input.length&&this.peek()!=="/";)if(this.peek()==="\\")i+=this.advance(),this.pos<this.input.length&&(i+=this.advance());else{if(this.peek()===`
14
+ `)break;i+=this.advance()}return this.peek()==="/"&&this.advance(),i=At(i),{type:r.REGEX,value:i,line:t,column:n}}readNumber(){let t=this.line,n=this.column,i="";for(;this.isDigit(this.peek());)i+=this.advance();if(this.peek()==="."&&this.isDigit(this.peek(1)))for(i+=this.advance();this.isDigit(this.peek());)i+=this.advance();if(this.peek()==="e"||this.peek()==="E")for(i+=this.advance(),(this.peek()==="+"||this.peek()==="-")&&(i+=this.advance());this.isDigit(this.peek());)i+=this.advance();return{type:r.NUMBER,value:parseFloat(i),line:t,column:n}}readIdentifier(){let t=this.line,n=this.column,i="";for(;this.isAlphaNumeric(this.peek())||this.peek()==="_";)i+=this.advance();let a=Rt[i];return a?{type:a,value:i,line:t,column:n}:{type:r.IDENT,value:i,line:t,column:n}}readOperator(){let t=this.line,n=this.column,i=this.advance(),a=this.peek();switch(i){case"+":return a==="+"?(this.advance(),{type:r.INCREMENT,value:"++",line:t,column:n}):a==="="?(this.advance(),{type:r.PLUS_ASSIGN,value:"+=",line:t,column:n}):{type:r.PLUS,value:"+",line:t,column:n};case"-":return a==="-"?(this.advance(),{type:r.DECREMENT,value:"--",line:t,column:n}):a==="="?(this.advance(),{type:r.MINUS_ASSIGN,value:"-=",line:t,column:n}):{type:r.MINUS,value:"-",line:t,column:n};case"*":return a==="*"?(this.advance(),{type:r.CARET,value:"**",line:t,column:n}):a==="="?(this.advance(),{type:r.STAR_ASSIGN,value:"*=",line:t,column:n}):{type:r.STAR,value:"*",line:t,column:n};case"/":return a==="="?(this.advance(),{type:r.SLASH_ASSIGN,value:"/=",line:t,column:n}):{type:r.SLASH,value:"/",line:t,column:n};case"%":return a==="="?(this.advance(),{type:r.PERCENT_ASSIGN,value:"%=",line:t,column:n}):{type:r.PERCENT,value:"%",line:t,column:n};case"^":return a==="="?(this.advance(),{type:r.CARET_ASSIGN,value:"^=",line:t,column:n}):{type:r.CARET,value:"^",line:t,column:n};case"=":return a==="="?(this.advance(),{type:r.EQ,value:"==",line:t,column:n}):{type:r.ASSIGN,value:"=",line:t,column:n};case"!":return a==="="?(this.advance(),{type:r.NE,value:"!=",line:t,column:n}):a==="~"?(this.advance(),{type:r.NOT_MATCH,value:"!~",line:t,column:n}):{type:r.NOT,value:"!",line:t,column:n};case"<":return a==="="?(this.advance(),{type:r.LE,value:"<=",line:t,column:n}):{type:r.LT,value:"<",line:t,column:n};case">":return a==="="?(this.advance(),{type:r.GE,value:">=",line:t,column:n}):a===">"?(this.advance(),{type:r.APPEND,value:">>",line:t,column:n}):{type:r.GT,value:">",line:t,column:n};case"&":return a==="&"?(this.advance(),{type:r.AND,value:"&&",line:t,column:n}):{type:r.IDENT,value:"&",line:t,column:n};case"|":return a==="|"?(this.advance(),{type:r.OR,value:"||",line:t,column:n}):{type:r.PIPE,value:"|",line:t,column:n};case"~":return{type:r.MATCH,value:"~",line:t,column:n};case"?":return{type:r.QUESTION,value:"?",line:t,column:n};case":":return{type:r.COLON,value:":",line:t,column:n};case",":return{type:r.COMMA,value:",",line:t,column:n};case";":return{type:r.SEMICOLON,value:";",line:t,column:n};case"(":return{type:r.LPAREN,value:"(",line:t,column:n};case")":return{type:r.RPAREN,value:")",line:t,column:n};case"{":return{type:r.LBRACE,value:"{",line:t,column:n};case"}":return{type:r.RBRACE,value:"}",line:t,column:n};case"[":return{type:r.LBRACKET,value:"[",line:t,column:n};case"]":return{type:r.RBRACKET,value:"]",line:t,column:n};case"$":return{type:r.DOLLAR,value:"$",line:t,column:n};default:return{type:r.IDENT,value:i,line:t,column:n}}}isDigit(t){return t>="0"&&t<="9"}isAlpha(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"}isAlphaNumeric(t){return this.isDigit(t)||this.isAlpha(t)}};var u={LPAREN:"LPAREN",RPAREN:"RPAREN",QUESTION:"QUESTION",NEWLINE:"NEWLINE",SEMICOLON:"SEMICOLON",RBRACE:"RBRACE",COMMA:"COMMA",PIPE:"PIPE",GT:"GT",APPEND:"APPEND",AND:"AND",OR:"OR",ASSIGN:"ASSIGN",PLUS_ASSIGN:"PLUS_ASSIGN",MINUS_ASSIGN:"MINUS_ASSIGN",STAR_ASSIGN:"STAR_ASSIGN",SLASH_ASSIGN:"SLASH_ASSIGN",PERCENT_ASSIGN:"PERCENT_ASSIGN",CARET_ASSIGN:"CARET_ASSIGN",RBRACKET:"RBRACKET",COLON:"COLON",IN:"IN",PRINT:"PRINT",PRINTF:"PRINTF",IDENT:"IDENT",LT:"LT",LE:"LE",GE:"GE",EQ:"EQ",NE:"NE",MATCH:"MATCH",NOT_MATCH:"NOT_MATCH",NUMBER:"NUMBER",STRING:"STRING",DOLLAR:"DOLLAR",NOT:"NOT",MINUS:"MINUS",PLUS:"PLUS",INCREMENT:"INCREMENT",DECREMENT:"DECREMENT"};function Ie(e){e.expect(u.PRINT);let t=[];if(e.check(u.NEWLINE)||e.check(u.SEMICOLON)||e.check(u.RBRACE)||e.check(u.PIPE)||e.check(u.GT)||e.check(u.APPEND))t.push({type:"field",index:{type:"number",value:0}});else for(t.push(W(e));e.check(u.COMMA);)e.advance(),t.push(W(e));let n;return e.check(u.GT)?(e.advance(),n={redirect:">",file:e.parsePrimary()}):e.check(u.APPEND)&&(e.advance(),n={redirect:">>",file:e.parsePrimary()}),{type:"print",args:t,output:n}}function W(e){return It(e)?Z(e,!0):Z(e,!1)}function Z(e,t){let n=t?e.parseTernary():wt(e);if(e.match(u.ASSIGN,u.PLUS_ASSIGN,u.MINUS_ASSIGN,u.STAR_ASSIGN,u.SLASH_ASSIGN,u.PERCENT_ASSIGN,u.CARET_ASSIGN)){let i=e.advance(),a=Z(e,t);if(n.type!=="variable"&&n.type!=="field"&&n.type!=="array_access")throw new Error("Invalid assignment target");return{type:"assignment",operator:{"=":"=","+=":"+=","-=":"-=","*=":"*=","/=":"/=","%=":"%=","^=":"^="}[i.value],target:n,value:a}}return n}function It(e){let t=0,n=e.pos;for(;n<e.tokens.length;){let i=e.tokens[n];if(i.type===u.LPAREN&&t++,i.type===u.RPAREN&&t--,i.type===u.QUESTION&&t===0)return!0;if(i.type===u.NEWLINE||i.type===u.SEMICOLON||i.type===u.RBRACE||i.type===u.COMMA||i.type===u.PIPE)return!1;n++}return!1}function wt(e){let t=Se(e);for(;e.check(u.OR);){e.advance();let n=Se(e);t={type:"binary",operator:"||",left:t,right:n}}return t}function Se(e){let t=ye(e);for(;e.check(u.AND);){e.advance();let n=ye(e);t={type:"binary",operator:"&&",left:t,right:n}}return t}function ye(e){let t=mt(e);if(e.check(u.IN)){e.advance();let n=String(e.expect(u.IDENT).value);return{type:"in",key:t,array:n}}return t}function mt(e){let t=Re(e);for(;vt(e)&&!gt(e);){let n=Re(e);t={type:"binary",operator:" ",left:t,right:n}}return t}function Re(e){let t=Ae(e);for(;e.match(u.MATCH,u.NOT_MATCH);){let n=e.advance().type===u.MATCH?"~":"!~",i=Ae(e);t={type:"binary",operator:n,left:t,right:i}}return t}function Ae(e){let t=e.parseAddSub();for(;e.match(u.LT,u.LE,u.GE,u.EQ,u.NE);){let n=e.advance(),i=e.parseAddSub();t={type:"binary",operator:{"<":"<","<=":"<=",">=":">=","==":"==","!=":"!="}[n.value],left:t,right:i}}return t}function vt(e){return e.match(u.NUMBER,u.STRING,u.IDENT,u.DOLLAR,u.LPAREN,u.NOT,u.MINUS,u.PLUS,u.INCREMENT,u.DECREMENT)}function gt(e){return e.match(u.AND,u.OR,u.QUESTION,u.ASSIGN,u.PLUS_ASSIGN,u.MINUS_ASSIGN,u.STAR_ASSIGN,u.SLASH_ASSIGN,u.PERCENT_ASSIGN,u.CARET_ASSIGN,u.COMMA,u.SEMICOLON,u.NEWLINE,u.RBRACE,u.RPAREN,u.RBRACKET,u.COLON,u.PIPE,u.APPEND,u.GT,u.IN)}function we(e){e.expect(u.PRINTF);let t=e.check(u.LPAREN);t&&(e.advance(),e.skipNewlines());let n=t?e.parseExpression():W(e),i=[];for(;e.check(u.COMMA);)e.advance(),t&&e.skipNewlines(),i.push(t?e.parseExpression():W(e));t&&(e.skipNewlines(),e.expect(u.RPAREN));let a;return e.check(u.GT)?(e.advance(),a={redirect:">",file:e.parsePrimary()}):e.check(u.APPEND)&&(e.advance(),a={redirect:">>",file:e.parsePrimary()}),{type:"printf",format:n,args:i,output:a}}var V=class{tokens=[];pos=0;parse(t){let n=new $(t);return this.tokens=n.tokenize(),this.pos=0,this.parseProgram()}setPos(t){this.pos=t}current(){return this.tokens[this.pos]||{type:r.EOF,value:"",line:0,column:0}}advance(){let t=this.current();return this.pos<this.tokens.length&&this.pos++,t}match(...t){return t.includes(this.current().type)}check(t){return this.current().type===t}expect(t,n){if(!this.check(t)){let i=this.current();throw new Error(n||`Expected ${t}, got ${i.type} at line ${i.line}:${i.column}`)}return this.advance()}skipNewlines(){for(;this.check(r.NEWLINE);)this.advance()}skipTerminators(){for(;this.check(r.NEWLINE)||this.check(r.SEMICOLON);)this.advance()}parseProgram(){let t=[],n=[];for(this.skipNewlines();!this.check(r.EOF)&&(this.skipNewlines(),!this.check(r.EOF));)this.check(r.FUNCTION)?t.push(this.parseFunction()):n.push(this.parseRule()),this.skipTerminators();return{functions:t,rules:n}}parseFunction(){this.expect(r.FUNCTION);let t=this.expect(r.IDENT).value;this.expect(r.LPAREN);let n=[];if(!this.check(r.RPAREN))for(n.push(this.expect(r.IDENT).value);this.check(r.COMMA);)this.advance(),n.push(this.expect(r.IDENT).value);this.expect(r.RPAREN),this.skipNewlines();let i=this.parseBlock();return{name:t,params:n,body:i}}parseRule(){let t;if(this.check(r.BEGIN))this.advance(),t={type:"begin"};else if(this.check(r.END))this.advance(),t={type:"end"};else if(this.check(r.LBRACE))t=void 0;else if(this.check(r.REGEX)){let i=this.advance();if(this.check(r.AND)||this.check(r.OR)){let a={type:"binary",operator:"~",left:{type:"field",index:{type:"number",value:0}},right:{type:"regex",pattern:i.value}};t={type:"expr_pattern",expression:this.parseLogicalOrRest(a)}}else{let a={type:"regex_pattern",pattern:i.value};if(this.check(r.COMMA)){this.advance();let s;this.check(r.REGEX)?s={type:"regex_pattern",pattern:this.advance().value}:s={type:"expr_pattern",expression:this.parseExpression()},t={type:"range",start:a,end:s}}else t=a}}else{let a={type:"expr_pattern",expression:this.parseExpression()};if(this.check(r.COMMA)){this.advance();let s;this.check(r.REGEX)?s={type:"regex_pattern",pattern:this.advance().value}:s={type:"expr_pattern",expression:this.parseExpression()},t={type:"range",start:a,end:s}}else t=a}this.skipNewlines();let n;return this.check(r.LBRACE)?n=this.parseBlock():n={type:"block",statements:[{type:"print",args:[{type:"field",index:{type:"number",value:0}}]}]},{pattern:t,action:n}}parseBlock(){this.expect(r.LBRACE),this.skipNewlines();let t=[];for(;!this.check(r.RBRACE)&&!this.check(r.EOF);)t.push(this.parseStatement()),this.skipTerminators();return this.expect(r.RBRACE),{type:"block",statements:t}}parseStatement(){if(this.check(r.SEMICOLON)||this.check(r.NEWLINE))return this.advance(),{type:"block",statements:[]};if(this.check(r.LBRACE))return this.parseBlock();if(this.check(r.IF))return this.parseIf();if(this.check(r.WHILE))return this.parseWhile();if(this.check(r.DO))return this.parseDoWhile();if(this.check(r.FOR))return this.parseFor();if(this.check(r.BREAK))return this.advance(),{type:"break"};if(this.check(r.CONTINUE))return this.advance(),{type:"continue"};if(this.check(r.NEXT))return this.advance(),{type:"next"};if(this.check(r.NEXTFILE))return this.advance(),{type:"nextfile"};if(this.check(r.EXIT)){this.advance();let n;return!this.check(r.NEWLINE)&&!this.check(r.SEMICOLON)&&!this.check(r.RBRACE)&&!this.check(r.EOF)&&(n=this.parseExpression()),{type:"exit",code:n}}if(this.check(r.RETURN)){this.advance();let n;return!this.check(r.NEWLINE)&&!this.check(r.SEMICOLON)&&!this.check(r.RBRACE)&&!this.check(r.EOF)&&(n=this.parseExpression()),{type:"return",value:n}}if(this.check(r.DELETE)){this.advance();let n=this.parsePrimary();if(n.type!=="array_access"&&n.type!=="variable")throw new Error("delete requires array element or array");return{type:"delete",target:n}}return this.check(r.PRINT)?Ie(this):this.check(r.PRINTF)?we(this):{type:"expr_stmt",expression:this.parseExpression()}}parseIf(){this.expect(r.IF),this.expect(r.LPAREN);let t=this.parseExpression();this.expect(r.RPAREN),this.skipNewlines();let n=this.parseStatement();this.skipTerminators();let i;return this.check(r.ELSE)&&(this.advance(),this.skipNewlines(),i=this.parseStatement()),{type:"if",condition:t,consequent:n,alternate:i}}parseWhile(){this.expect(r.WHILE),this.expect(r.LPAREN);let t=this.parseExpression();this.expect(r.RPAREN),this.skipNewlines();let n=this.parseStatement();return{type:"while",condition:t,body:n}}parseDoWhile(){this.expect(r.DO),this.skipNewlines();let t=this.parseStatement();this.skipNewlines(),this.expect(r.WHILE),this.expect(r.LPAREN);let n=this.parseExpression();return this.expect(r.RPAREN),{type:"do_while",body:t,condition:n}}parseFor(){if(this.expect(r.FOR),this.expect(r.LPAREN),this.check(r.IDENT)){let s=this.advance();if(this.check(r.IN)){this.advance();let o=this.expect(r.IDENT).value;this.expect(r.RPAREN),this.skipNewlines();let l=this.parseStatement();return{type:"for_in",variable:s.value,array:o,body:l}}this.pos--}let t;this.check(r.SEMICOLON)||(t=this.parseExpression()),this.expect(r.SEMICOLON);let n;this.check(r.SEMICOLON)||(n=this.parseExpression()),this.expect(r.SEMICOLON);let i;this.check(r.RPAREN)||(i=this.parseExpression()),this.expect(r.RPAREN),this.skipNewlines();let a=this.parseStatement();return{type:"for",init:t,condition:n,update:i,body:a}}parseExpression(){return this.parseAssignment()}parseAssignment(){let t=this.parseTernary();if(this.match(r.ASSIGN,r.PLUS_ASSIGN,r.MINUS_ASSIGN,r.STAR_ASSIGN,r.SLASH_ASSIGN,r.PERCENT_ASSIGN,r.CARET_ASSIGN)){let n=this.advance(),i=this.parseAssignment();if(t.type!=="variable"&&t.type!=="field"&&t.type!=="array_access")throw new Error("Invalid assignment target");return{type:"assignment",operator:{"=":"=","+=":"+=","-=":"-=","*=":"*=","/=":"/=","%=":"%=","^=":"^="}[n.value],target:t,value:i}}return t}parseTernary(){let t=this.parsePipeGetline();if(this.check(r.QUESTION)){this.advance();let n=this.parseExpression();this.expect(r.COLON);let i=this.parseExpression();t={type:"ternary",condition:t,consequent:n,alternate:i}}return t}parsePipeGetline(){let t=this.parseOr();if(this.check(r.PIPE)){if(this.advance(),!this.check(r.GETLINE))throw new Error("Expected 'getline' after '|' in expression context");this.advance();let n;return this.check(r.IDENT)&&(n=this.advance().value),{type:"getline",command:t,variable:n}}return t}parseOr(){let t=this.parseAnd();for(;this.check(r.OR);){this.advance();let n=this.parseAnd();t={type:"binary",operator:"||",left:t,right:n}}return t}parseLogicalOrRest(t){for(t=this.parseLogicalAndRest(t);this.check(r.OR);){this.advance();let n=this.parseAnd();t={type:"binary",operator:"||",left:t,right:n}}return t}parseLogicalAndRest(t){for(;this.check(r.AND);){this.advance();let n=this.parseIn();t={type:"binary",operator:"&&",left:t,right:n}}return t}parseAnd(){let t=this.parseIn();for(;this.check(r.AND);){this.advance();let n=this.parseIn();t={type:"binary",operator:"&&",left:t,right:n}}return t}parseIn(){let t=this.parseConcatenation();if(this.check(r.IN)){this.advance();let n=this.expect(r.IDENT).value;return{type:"in",key:t,array:n}}return t}parseConcatenation(){let t=this.parseMatch();for(;this.canStartExpression()&&!this.isConcatTerminator();){let n=this.parseMatch();t={type:"binary",operator:" ",left:t,right:n}}return t}parseMatch(){let t=this.parseComparison();for(;this.match(r.MATCH,r.NOT_MATCH);){let n=this.advance().type===r.MATCH?"~":"!~",i=this.parseComparison();t={type:"binary",operator:n,left:t,right:i}}return t}parseComparison(){let t=this.parseAddSub();for(;this.match(r.LT,r.LE,r.GT,r.GE,r.EQ,r.NE);){let n=this.advance(),i=this.parseAddSub();t={type:"binary",operator:{"<":"<","<=":"<=",">":">",">=":">=","==":"==","!=":"!="}[n.value],left:t,right:i}}return t}canStartExpression(){return this.match(r.NUMBER,r.STRING,r.IDENT,r.DOLLAR,r.LPAREN,r.NOT,r.MINUS,r.PLUS,r.INCREMENT,r.DECREMENT)}isConcatTerminator(){return this.match(r.AND,r.OR,r.QUESTION,r.ASSIGN,r.PLUS_ASSIGN,r.MINUS_ASSIGN,r.STAR_ASSIGN,r.SLASH_ASSIGN,r.PERCENT_ASSIGN,r.CARET_ASSIGN,r.COMMA,r.SEMICOLON,r.NEWLINE,r.RBRACE,r.RPAREN,r.RBRACKET,r.COLON,r.PIPE,r.APPEND,r.IN)}parseAddSub(){let t=this.parseMulDiv();for(;this.match(r.PLUS,r.MINUS);){let n=this.advance().value,i=this.parseMulDiv();t={type:"binary",operator:n,left:t,right:i}}return t}parseMulDiv(){let t=this.parseUnary();for(;this.match(r.STAR,r.SLASH,r.PERCENT);){let n=this.advance(),i=this.parseUnary();t={type:"binary",operator:{"*":"*","/":"/","%":"%"}[n.value],left:t,right:i}}return t}parseUnary(){if(this.check(r.INCREMENT)){this.advance();let t=this.parseUnary();return t.type!=="variable"&&t.type!=="field"&&t.type!=="array_access"?{type:"unary",operator:"+",operand:{type:"unary",operator:"+",operand:t}}:{type:"pre_increment",operand:t}}if(this.check(r.DECREMENT)){this.advance();let t=this.parseUnary();return t.type!=="variable"&&t.type!=="field"&&t.type!=="array_access"?{type:"unary",operator:"-",operand:{type:"unary",operator:"-",operand:t}}:{type:"pre_decrement",operand:t}}if(this.match(r.NOT,r.MINUS,r.PLUS)){let t=this.advance().value,n=this.parseUnary();return{type:"unary",operator:t,operand:n}}return this.parsePower()}parsePower(){let t=this.parsePostfix();if(this.check(r.CARET)){this.advance();let n=this.parsePower();t={type:"binary",operator:"^",left:t,right:n}}return t}parsePostfix(){let t=this.parsePrimary();if(this.check(r.INCREMENT)){if(this.advance(),t.type!=="variable"&&t.type!=="field"&&t.type!=="array_access")throw new Error("Invalid increment operand");return{type:"post_increment",operand:t}}if(this.check(r.DECREMENT)){if(this.advance(),t.type!=="variable"&&t.type!=="field"&&t.type!=="array_access")throw new Error("Invalid decrement operand");return{type:"post_decrement",operand:t}}return t}parseFieldIndex(){if(this.check(r.INCREMENT)){this.advance();let t=this.parseFieldIndex();return t.type!=="variable"&&t.type!=="field"&&t.type!=="array_access"?{type:"unary",operator:"+",operand:{type:"unary",operator:"+",operand:t}}:{type:"pre_increment",operand:t}}if(this.check(r.DECREMENT)){this.advance();let t=this.parseFieldIndex();return t.type!=="variable"&&t.type!=="field"&&t.type!=="array_access"?{type:"unary",operator:"-",operand:{type:"unary",operator:"-",operand:t}}:{type:"pre_decrement",operand:t}}if(this.match(r.NOT,r.MINUS,r.PLUS)){let t=this.advance().value,n=this.parseFieldIndex();return{type:"unary",operator:t,operand:n}}return this.parseFieldIndexPower()}parseFieldIndexPower(){let t=this.parseFieldIndexPrimary();if(this.check(r.CARET)){this.advance();let n=this.parseFieldIndexPower();t={type:"binary",operator:"^",left:t,right:n}}return t}parseFieldIndexPrimary(){if(this.check(r.NUMBER))return{type:"number",value:this.advance().value};if(this.check(r.STRING))return{type:"string",value:this.advance().value};if(this.check(r.DOLLAR))return this.advance(),{type:"field",index:this.parseFieldIndex()};if(this.check(r.LPAREN)){this.advance();let t=this.parseExpression();return this.expect(r.RPAREN),t}if(this.check(r.IDENT)){let t=this.advance().value;if(this.check(r.LPAREN)){this.advance();let n=[];if(!this.check(r.RPAREN))for(n.push(this.parseExpression());this.check(r.COMMA);)this.advance(),n.push(this.parseExpression());return this.expect(r.RPAREN),{type:"call",name:t,args:n}}if(this.check(r.LBRACKET)){this.advance();let n=this.parseExpression();if(this.check(r.COMMA)){let i=[n];for(;this.check(r.COMMA);)this.advance(),i.push(this.parseExpression());this.expect(r.RBRACKET);let a=i.reduce((s,o)=>({type:"binary",operator:" ",left:{type:"binary",operator:" ",left:s,right:{type:"variable",name:"SUBSEP"}},right:o}));return{type:"array_access",array:t,key:a}}return this.expect(r.RBRACKET),{type:"array_access",array:t,key:n}}return{type:"variable",name:t}}throw new Error(`Unexpected token in field index: ${this.current().type} at line ${this.current().line}:${this.current().column}`)}parsePrimary(){if(this.check(r.NUMBER))return{type:"number",value:this.advance().value};if(this.check(r.STRING))return{type:"string",value:this.advance().value};if(this.check(r.REGEX))return{type:"regex",pattern:this.advance().value};if(this.check(r.DOLLAR))return this.advance(),{type:"field",index:this.parseFieldIndex()};if(this.check(r.LPAREN)){this.advance();let t=this.parseExpression();if(this.check(r.COMMA)){let n=[t];for(;this.check(r.COMMA);)this.advance(),n.push(this.parseExpression());return this.expect(r.RPAREN),{type:"tuple",elements:n}}return this.expect(r.RPAREN),t}if(this.check(r.GETLINE)){this.advance();let t,n;return this.check(r.IDENT)&&(t=this.advance().value),this.check(r.LT)&&(this.advance(),n=this.parsePrimary()),{type:"getline",variable:t,file:n}}if(this.check(r.IDENT)){let t=this.advance().value;if(this.check(r.LPAREN)){this.advance();let n=[];if(this.skipNewlines(),!this.check(r.RPAREN))for(n.push(this.parseExpression());this.check(r.COMMA);)this.advance(),this.skipNewlines(),n.push(this.parseExpression());return this.skipNewlines(),this.expect(r.RPAREN),{type:"call",name:t,args:n}}if(this.check(r.LBRACKET)){this.advance();let n=[this.parseExpression()];for(;this.check(r.COMMA);)this.advance(),n.push(this.parseExpression());this.expect(r.RBRACKET);let i;if(n.length===1)i=n[0];else{i=n[0];for(let a=1;a<n.length;a++)i={type:"binary",operator:" ",left:{type:"binary",operator:" ",left:i,right:{type:"variable",name:"SUBSEP"}},right:n[a]}}return{type:"array_access",array:t,key:i}}return{type:"variable",name:t}}throw new Error(`Unexpected token: ${this.current().type} at line ${this.current().line}:${this.current().column}`)}};var kt={name:"awk",summary:"pattern scanning and text processing language",usage:"awk [OPTIONS] 'PROGRAM' [FILE...]",options:["-F FS use FS as field separator","-v VAR=VAL assign VAL to variable VAR"," --help display this help and exit"]},fn={name:"awk",async execute(e,t){if(ne(e))return te(kt);let n=/\s+/,i=" ",a={},s=0;for(let c=0;c<e.length;c++){let p=e[c];if(p==="-F"&&c+1<e.length)i=Y(e[++c]),n=me(i),s=c+1;else if(p.startsWith("-F"))i=Y(p.slice(2)),n=me(i),s=c+1;else if(p==="-v"&&c+1<e.length){let E=e[++c],d=E.indexOf("=");if(d>0){let y=E.slice(0,d),L=Y(E.slice(d+1));a[y]=L}s=c+1}else{if(p.startsWith("--"))return X("awk",p);if(p.startsWith("-")&&p.length>1){let E=p[1];if(E!=="F"&&E!=="v")return X("awk",`-${E}`);s=c+1}else if(!p.startsWith("-")){s=c;break}}}if(s>=e.length)return{stdout:"",stderr:`awk: missing program
15
+ `,exitCode:1};let o=e[s],l=e.slice(s+1),h=new V,N;try{N=h.parse(o)}catch(c){return{stdout:"",stderr:`awk: ${c instanceof Error?c.message:String(c)}
16
+ `,exitCode:1}}let v={readFile:t.fs.readFile.bind(t.fs),writeFile:t.fs.writeFile.bind(t.fs),appendFile:async(c,p)=>{try{let E=await t.fs.readFile(c);await t.fs.writeFile(c,E+p)}catch{await t.fs.writeFile(c,p)}},resolvePath:t.fs.resolvePath.bind(t.fs)},R=K({fieldSep:n,maxIterations:t.limits?.maxAwkIterations,fs:v,cwd:t.cwd,exec:t.exec?c=>t.exec(c,{cwd:t.cwd}):void 0});R.FS=i,R.vars={...a},R.ARGC=l.length+1,R.ARGV={0:"awk"};for(let c=0;c<l.length;c++)R.ARGV[String(c+1)]=l[c];R.ENVIRON={...t.env};let I=new _(R);I.execute(N);let ee=N.rules.some(c=>c.pattern?.type!=="begin"&&c.pattern?.type!=="end"),w=N.rules.some(c=>c.pattern?.type==="end");try{if(await I.executeBegin(),R.shouldExit)return await I.executeEnd(),{stdout:I.getOutput(),stderr:"",exitCode:I.getExitCode()};if(!ee&&!w)return{stdout:I.getOutput(),stderr:"",exitCode:I.getExitCode()};let c=[];if(l.length>0)for(let p of l)try{let E=t.fs.resolvePath(t.cwd,p),y=(await t.fs.readFile(E)).split(`
17
+ `);y.length>0&&y[y.length-1]===""&&y.pop(),c.push({filename:p,lines:y})}catch{return{stdout:"",stderr:`awk: ${p}: No such file or directory
18
+ `,exitCode:1}}else{let p=t.stdin.split(`
19
+ `);p.length>0&&p[p.length-1]===""&&p.pop(),c.push({filename:"",lines:p})}for(let p of c){for(R.FILENAME=p.filename,R.FNR=0,R.lines=p.lines,R.lineIndex=-1,R.shouldNextFile=!1;R.lineIndex<p.lines.length-1&&(R.lineIndex++,await I.executeLine(p.lines[R.lineIndex]),!(R.shouldExit||R.shouldNextFile)););if(R.shouldExit)break}return await I.executeEnd(),{stdout:I.getOutput(),stderr:"",exitCode:I.getExitCode()}}catch(c){let p=c instanceof Error?c.message:String(c),E=c instanceof C?C.EXIT_CODE:2;return{stdout:I.getOutput(),stderr:`awk: ${p}
20
+ `,exitCode:E}}}};function Y(e){return e.replace(/\\t/g," ").replace(/\\n/g,`
21
+ `).replace(/\\r/g,"\r").replace(/\\b/g,"\b").replace(/\\f/g,"\f").replace(/\\a/g,"\x07").replace(/\\v/g,"\v").replace(/\\\\/g,"\\")}function me(e){if(e===" ")return/\s+/;if(/[[\](){}.*+?^$|\\]/.test(e))try{return new RegExp(e)}catch{return new RegExp(ve(e))}return new RegExp(ve(e))}function ve(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}export{fn as awkCommand2};
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ import{a as h,b as d}from"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";var l={name:"bash",summary:"execute shell commands or scripts",usage:"bash [OPTIONS] [SCRIPT_FILE] [ARGUMENTS...]",options:["-c COMMAND execute COMMAND string"," --help display this help and exit"],notes:["Without -c, reads and executes commands from SCRIPT_FILE.","Arguments are passed as $1, $2, etc. to the script.",'$0 is set to the script name (or "bash" with -c).']},f={name:"bash",async execute(e,t){if(d(e))return h(l);if(e[0]==="-c"&&e.length>=2){let r=e[1],s=e[2]||"bash",c=e.slice(3);return i(r,s,c,t)}if(e.length===0)return t.stdin?.trim()?i(t.stdin,"bash",[],t):{stdout:"",stderr:"",exitCode:0};let n=e[0],o=e.slice(1);try{let r=t.fs.resolvePath(t.cwd,n),s=await t.fs.readFile(r);return i(s,n,o,t)}catch{return{stdout:"",stderr:`bash: ${n}: No such file or directory
3
+ `,exitCode:127}}}},p={name:"sh",async execute(e,t){if(d(e))return h({...l,name:"sh",summary:"execute shell commands or scripts (POSIX shell)"});if(e[0]==="-c"&&e.length>=2){let r=e[1],s=e[2]||"sh",c=e.slice(3);return i(r,s,c,t)}if(e.length===0)return t.stdin?.trim()?i(t.stdin,"sh",[],t):{stdout:"",stderr:"",exitCode:0};let n=e[0],o=e.slice(1);try{let r=t.fs.resolvePath(t.cwd,n),s=await t.fs.readFile(r);return i(s,n,o,t)}catch{return{stdout:"",stderr:`sh: ${n}: No such file or directory
4
+ `,exitCode:127}}}};async function i(e,t,n,o){if(!o.exec)return{stdout:"",stderr:`bash: internal error: exec function not available
5
+ `,exitCode:1};let r={...o.exportedEnv||{},0:t,"#":String(n.length),"@":n.join(" "),"*":n.join(" ")};n.forEach((a,u)=>{r[String(u+1)]=a});let s=e;if(s.startsWith("#!")){let a=s.indexOf(`
6
+ `);a!==-1&&(s=s.slice(a+1))}return await o.exec(s,{env:r,cwd:o.cwd})}export{f as bashCommand,p as shCommand};
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ import{a as g,b as $}from"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";var C={name:"chmod",summary:"change file mode bits",usage:"chmod [OPTIONS] MODE FILE...",options:["-R change files recursively","-v output a diagnostic for every file processed"," --help display this help and exit"]},R={name:"chmod",async execute(s,a){if($(s))return g(C);if(s.length<2)return{stdout:"",stderr:`chmod: missing operand
3
+ `,exitCode:1};let e=!1,c=!1,o=0;for(;o<s.length&&s[o].startsWith("-");){let t=s[o];if(t==="-R"||t==="--recursive")e=!0,o++;else if(t==="-v"||t==="--verbose")c=!0,o++;else if(t==="--"){o++;break}else{if(/^[+-]?[rwxugo]+/.test(t)||/^\d+$/.test(t))break;if(/^-[Rv]+$/.test(t)){t.includes("R")&&(e=!0),t.includes("v")&&(c=!0),o++;continue}return{stdout:"",stderr:`chmod: invalid option -- '${t.slice(1)}'
4
+ `,exitCode:1}}}if(s.length-o<2)return{stdout:"",stderr:`chmod: missing operand
5
+ `,exitCode:1};let n=s[o],d=s.slice(o+1),r=/^[0-7]+$/.test(n),i;if(r)i=parseInt(n,8);else try{p(n,420)}catch{return{stdout:"",stderr:`chmod: invalid mode: '${n}'
6
+ `,exitCode:1}}let f="",l="",u=!1;for(let t of d){let h=a.fs.resolvePath(a.cwd,t);try{let m;if(r&&i!==void 0)m=i;else{let w=await a.fs.stat(h);m=p(n,w.mode)}if(await a.fs.chmod(h,m),c&&(f+=`mode of '${t}' changed to ${m.toString(8).padStart(4,"0")}
7
+ `),e&&(await a.fs.stat(h)).isDirectory){let y=await v(a,h,r?i:void 0,r?void 0:n,c);f+=y}}catch{l+=`chmod: cannot access '${t}': No such file or directory
8
+ `,u=!0}}return{stdout:f,stderr:l,exitCode:u?1:0}}};async function v(s,a,e,c,o){let n="",d=await s.fs.readdir(a);for(let r of d){let i=a==="/"?`/${r}`:`${a}/${r}`,f;if(e!==void 0)f=e;else if(c!==void 0){let u=await s.fs.stat(i);f=p(c,u.mode)}else f=420;await s.fs.chmod(i,f),o&&(n+=`mode of '${i}' changed to ${f.toString(8).padStart(4,"0")}
9
+ `),(await s.fs.stat(i)).isDirectory&&(n+=await v(s,i,e,c,o))}return n}function p(s,a=420){if(/^[0-7]+$/.test(s))return parseInt(s,8);let e=a&4095,c=s.split(",");for(let o of c){let n=o.match(/^([ugoa]*)([+\-=])([rwxXst]*)$/);if(!n)throw new Error(`Invalid mode: ${s}`);let d=n[1]||"a",r=n[2],i=n[3];(d==="a"||d==="")&&(d="ugo");let f=0;i.includes("r")&&(f|=4),i.includes("w")&&(f|=2),(i.includes("x")||i.includes("X"))&&(f|=1);let l=0;i.includes("s")&&(d.includes("u")&&(l|=2048),d.includes("g")&&(l|=1024)),i.includes("t")&&(l|=512);for(let u of d){let t=0;u==="u"?t=6:u==="g"?t=3:u==="o"&&(t=0);let h=f<<t;r==="+"?e|=h:r==="-"?e&=~h:r==="="&&(e&=~(7<<t),e|=h)}r==="+"?e|=l:r==="-"?e&=~l:r==="="&&(i.includes("s")&&(d.includes("u")&&(e&=-2049,e|=l&2048),d.includes("g")&&(e&=-1025,e|=l&1024)),i.includes("t")&&(e&=-513,e|=l&512))}return e}export{R as chmodCommand};
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ function i(t,l,e){let c=t;e>=0&&c.length>e&&(c=c.slice(0,e));let n=Math.abs(l);return n>c.length&&(l<0?c=c.padEnd(n," "):c=c.padStart(n," ")),c}function h(t,l){let e=l,c=0,n=-1,a=!1;for(e<t.length&&t[e]==="-"&&(a=!0,e++);e<t.length&&/\d/.test(t[e]);)c=c*10+parseInt(t[e],10),e++;if(e<t.length&&t[e]===".")for(e++,n=0;e<t.length&&/\d/.test(t[e]);)n=n*10+parseInt(t[e],10),e++;return a&&c>0&&(c=-c),[c,n,e-l]}function r(t){let l="",e=0;for(;e<t.length;)if(t[e]==="\\"&&e+1<t.length)switch(t[e+1]){case"n":l+=`
3
+ `,e+=2;break;case"t":l+=" ",e+=2;break;case"r":l+="\r",e+=2;break;case"\\":l+="\\",e+=2;break;case"a":l+="\x07",e+=2;break;case"b":l+="\b",e+=2;break;case"f":l+="\f",e+=2;break;case"v":l+="\v",e+=2;break;case"e":case"E":l+="\x1B",e+=2;break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":{let n="",a=e+1;for(;a<t.length&&a<e+4&&/[0-7]/.test(t[a]);)n+=t[a],a++;l+=String.fromCharCode(parseInt(n,8)),e=a;break}case"x":{let n=[],a=e;for(;a+3<t.length&&t[a]==="\\"&&t[a+1]==="x"&&/[0-9a-fA-F]{2}/.test(t.slice(a+2,a+4));)n.push(parseInt(t.slice(a+2,a+4),16)),a+=4;if(n.length>0){try{let s=new TextDecoder("utf-8",{fatal:!0});l+=s.decode(new Uint8Array(n))}catch{for(let s of n)l+=String.fromCharCode(s)}e=a}else l+=t[e],e++;break}case"u":{let n="",a=e+2;for(;a<t.length&&a<e+6&&/[0-9a-fA-F]/.test(t[a]);)n+=t[a],a++;n?(l+=String.fromCodePoint(parseInt(n,16)),e=a):(l+="\\u",e+=2);break}case"U":{let n="",a=e+2;for(;a<t.length&&a<e+10&&/[0-9a-fA-F]/.test(t[a]);)n+=t[a],a++;n?(l+=String.fromCodePoint(parseInt(n,16)),e=a):(l+="\\U",e+=2);break}default:l+=t[e],e++}else l+=t[e],e++;return l}export{i as a,h as b,r as c};