just-bash 2.5.5 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (292) hide show
  1. package/README.md +3 -3
  2. package/dist/AGENTS.md +3 -3
  3. package/dist/ast/types.d.ts +100 -11
  4. package/dist/bin/chunks/alias-EGIS5LUE.js +7 -0
  5. package/dist/bin/chunks/awk2-GFEJOWML.js +21 -0
  6. package/dist/bin/chunks/bash-PGDTHIM2.js +6 -0
  7. package/dist/bin/chunks/chmod-TYLTHXFR.js +9 -0
  8. package/dist/bin/chunks/chunk-D5WP4CKS.js +3 -0
  9. package/dist/bin/chunks/chunk-FSAGDARS.js +74 -0
  10. package/dist/bin/chunks/chunk-FSZWFMB4.js +16 -0
  11. package/dist/bin/chunks/chunk-IRUD2E3M.js +17 -0
  12. package/dist/bin/chunks/chunk-K5IXNHO5.js +8 -0
  13. package/dist/bin/chunks/chunk-KD3EODLB.js +6 -0
  14. package/dist/bin/{shell/chunks/echo-WSKTON6U.js → chunks/echo-7I42V66Q.js} +2 -2
  15. package/dist/bin/chunks/env-7A4MH7BJ.js +9 -0
  16. package/dist/bin/chunks/expansion-BOR3ELLC.js +2 -0
  17. package/dist/bin/{shell/chunks/find-CBEJ35BR.js → chunks/find-PHDZK64M.js} +1 -1
  18. package/dist/bin/{shell/chunks/grep-IIVQXFNI.js → chunks/grep-VX7MJMVN.js} +2 -2
  19. package/dist/bin/chunks/{head-DYK37Z24.js → head-TJHLLIMR.js} +1 -1
  20. package/dist/bin/{shell/chunks/jq-XXZPU5CA.js → chunks/jq-RGZHJNXC.js} +1 -1
  21. package/dist/bin/chunks/od-KRKGC2U3.js +5 -0
  22. package/dist/bin/chunks/printf-YPXD4CRE.js +15 -0
  23. package/dist/bin/chunks/pwd-L26WH2K4.js +3 -0
  24. package/dist/bin/chunks/python3-JGT65AEB.js +14 -0
  25. package/dist/bin/{shell/chunks/rg-Q4OTJOEF.js → chunks/rg-RSDLLECO.js} +1 -1
  26. package/dist/bin/chunks/rmdir-GOODLY5W.js +14 -0
  27. package/dist/bin/chunks/sed-JPDTWF4W.js +100 -0
  28. package/dist/bin/{shell/chunks/tail-BES27CZT.js → chunks/tail-YAUIERGN.js} +1 -1
  29. package/dist/bin/{shell/chunks/tar-C27YYUAS.js → chunks/tar-LFENC54A.js} +7 -7
  30. package/dist/bin/chunks/time-37F5EBPK.js +14 -0
  31. package/dist/bin/chunks/touch-IBPHJBM3.js +7 -0
  32. package/dist/bin/chunks/wc-SAOHEZYP.js +6 -0
  33. package/dist/bin/chunks/{which-73KOOLC6.js → which-FCDFBOMN.js} +1 -1
  34. package/dist/bin/chunks/whoami-JVLUNKSG.js +3 -0
  35. package/dist/bin/chunks/worker.js +1038 -0
  36. package/dist/bin/{shell/chunks/xan-6K2NGTHM.js → chunks/xan-5HNHTFMB.js} +19 -19
  37. package/dist/bin/chunks/{yq-MF2SNFGL.js → yq-PFV4T2PV.js} +1 -1
  38. package/dist/bin/just-bash.js +659 -135
  39. package/dist/bin/shell/chunks/alias-EGIS5LUE.js +7 -0
  40. package/dist/bin/shell/chunks/awk2-GFEJOWML.js +21 -0
  41. package/dist/bin/shell/chunks/bash-PGDTHIM2.js +6 -0
  42. package/dist/bin/shell/chunks/chmod-TYLTHXFR.js +9 -0
  43. package/dist/bin/shell/chunks/chunk-D5WP4CKS.js +3 -0
  44. package/dist/bin/shell/chunks/chunk-FSAGDARS.js +74 -0
  45. package/dist/bin/shell/chunks/chunk-FSZWFMB4.js +16 -0
  46. package/dist/bin/shell/chunks/chunk-IRUD2E3M.js +17 -0
  47. package/dist/bin/shell/chunks/chunk-K5IXNHO5.js +8 -0
  48. package/dist/bin/shell/chunks/chunk-KD3EODLB.js +6 -0
  49. package/dist/bin/{chunks/echo-WSKTON6U.js → shell/chunks/echo-7I42V66Q.js} +2 -2
  50. package/dist/bin/shell/chunks/env-7A4MH7BJ.js +9 -0
  51. package/dist/bin/shell/chunks/expansion-BOR3ELLC.js +2 -0
  52. package/dist/bin/{chunks/find-CBEJ35BR.js → shell/chunks/find-PHDZK64M.js} +1 -1
  53. package/dist/bin/{chunks/grep-IIVQXFNI.js → shell/chunks/grep-VX7MJMVN.js} +2 -2
  54. package/dist/bin/shell/chunks/{head-DYK37Z24.js → head-TJHLLIMR.js} +1 -1
  55. package/dist/bin/{chunks/jq-XXZPU5CA.js → shell/chunks/jq-RGZHJNXC.js} +1 -1
  56. package/dist/bin/shell/chunks/od-KRKGC2U3.js +5 -0
  57. package/dist/bin/shell/chunks/printf-YPXD4CRE.js +15 -0
  58. package/dist/bin/shell/chunks/pwd-L26WH2K4.js +3 -0
  59. package/dist/bin/shell/chunks/python3-JGT65AEB.js +14 -0
  60. package/dist/bin/{chunks/rg-Q4OTJOEF.js → shell/chunks/rg-RSDLLECO.js} +1 -1
  61. package/dist/bin/shell/chunks/rmdir-GOODLY5W.js +14 -0
  62. package/dist/bin/shell/chunks/sed-JPDTWF4W.js +100 -0
  63. package/dist/bin/{chunks/tail-BES27CZT.js → shell/chunks/tail-YAUIERGN.js} +1 -1
  64. package/dist/bin/{chunks/tar-C27YYUAS.js → shell/chunks/tar-LFENC54A.js} +7 -7
  65. package/dist/bin/shell/chunks/time-37F5EBPK.js +14 -0
  66. package/dist/bin/shell/chunks/touch-IBPHJBM3.js +7 -0
  67. package/dist/bin/shell/chunks/wc-SAOHEZYP.js +6 -0
  68. package/dist/bin/shell/chunks/{which-73KOOLC6.js → which-FCDFBOMN.js} +1 -1
  69. package/dist/bin/shell/chunks/whoami-JVLUNKSG.js +3 -0
  70. package/dist/bin/{chunks/xan-6K2NGTHM.js → shell/chunks/xan-5HNHTFMB.js} +19 -19
  71. package/dist/bin/shell/chunks/{yq-MF2SNFGL.js → yq-PFV4T2PV.js} +1 -1
  72. package/dist/bin/shell/shell.js +664 -140
  73. package/dist/bundle/browser.js +1251 -606
  74. package/dist/bundle/chunks/alias-ATFBB6D2.js +6 -0
  75. package/dist/bundle/chunks/awk2-6FBZTP57.js +20 -0
  76. package/dist/bundle/chunks/bash-OLRNM52U.js +5 -0
  77. package/dist/bundle/chunks/chmod-ODWUR7E6.js +8 -0
  78. package/dist/bundle/chunks/chunk-3AWP5CWK.js +73 -0
  79. package/dist/bundle/chunks/chunk-CXEWLFNE.js +16 -0
  80. package/dist/bundle/chunks/chunk-CZPA5RBA.js +5 -0
  81. package/dist/bundle/chunks/chunk-EEXR5ZDP.js +2 -0
  82. package/dist/bundle/chunks/chunk-HDQ56CKY.js +15 -0
  83. package/dist/bundle/chunks/chunk-PSW6BMXW.js +7 -0
  84. package/dist/bundle/chunks/{echo-VUHWYV6L.js → echo-6S7WE7XB.js} +2 -2
  85. package/dist/bundle/chunks/env-2UI6XINU.js +8 -0
  86. package/dist/bundle/chunks/expansion-RIGCFEMA.js +1 -0
  87. package/dist/bundle/chunks/{find-ACOAWALE.js → find-YGMSVGUV.js} +1 -1
  88. package/dist/bundle/chunks/{grep-ACVE42JK.js → grep-NIC6JNLH.js} +2 -2
  89. package/dist/bundle/chunks/{head-FZ6IQHYW.js → head-SA7P5NJ7.js} +1 -1
  90. package/dist/bundle/chunks/{jq-3YU5HRKE.js → jq-RLRYRPOJ.js} +1 -1
  91. package/dist/bundle/chunks/od-3FPDPLWJ.js +4 -0
  92. package/dist/bundle/chunks/printf-66XGXFCD.js +14 -0
  93. package/dist/bundle/chunks/pwd-S4NVAMC4.js +2 -0
  94. package/dist/bundle/chunks/python3-3OP7EKER.js +13 -0
  95. package/dist/bundle/chunks/{rg-YLZJWCEJ.js → rg-SRMB7L6G.js} +1 -1
  96. package/dist/bundle/chunks/rmdir-XFQE4ZYV.js +13 -0
  97. package/dist/bundle/chunks/sed-IV6HLDXU.js +99 -0
  98. package/dist/bundle/chunks/{tail-PD4RZR6J.js → tail-52LRAWXT.js} +1 -1
  99. package/dist/bundle/chunks/{tar-QWBXMF7K.js → tar-LWIHPMT6.js} +7 -7
  100. package/dist/bundle/chunks/time-UWXBG6CS.js +13 -0
  101. package/dist/bundle/chunks/touch-TDTEBHHI.js +6 -0
  102. package/dist/bundle/chunks/wc-HE5XARI4.js +5 -0
  103. package/dist/bundle/chunks/{which-M5MQ6QXQ.js → which-UBLRBDHN.js} +1 -1
  104. package/dist/bundle/chunks/whoami-YUDAIS32.js +2 -0
  105. package/dist/bundle/chunks/worker.js +1038 -0
  106. package/dist/bundle/chunks/{xan-2R2APJJ4.js → xan-A6VPI4HJ.js} +19 -19
  107. package/dist/bundle/chunks/{yq-KANM4MD2.js → yq-L665QPQU.js} +1 -1
  108. package/dist/bundle/index.js +657 -133
  109. package/dist/commands/awk/ast.d.ts +1 -0
  110. package/dist/commands/awk/interpreter/context.d.ts +14 -0
  111. package/dist/commands/awk/interpreter/interpreter.d.ts +2 -0
  112. package/dist/commands/awk/interpreter/{helpers.d.ts → type-coercion.d.ts} +4 -1
  113. package/dist/commands/awk/parser2-print.d.ts +35 -0
  114. package/dist/commands/awk/parser2.d.ts +42 -34
  115. package/dist/commands/printf/strftime.d.ts +9 -0
  116. package/dist/commands/python3/fs-bridge-handler.d.ts +50 -0
  117. package/dist/commands/python3/protocol.d.ts +138 -0
  118. package/dist/commands/python3/python3.d.ts +11 -0
  119. package/dist/commands/python3/sync-fs-backend.d.ts +59 -0
  120. package/dist/commands/python3/worker.d.ts +16 -0
  121. package/dist/commands/query-engine/builtins/array-builtins.d.ts +20 -0
  122. package/dist/commands/query-engine/builtins/control-builtins.d.ts +18 -0
  123. package/dist/commands/query-engine/builtins/date-builtins.d.ts +15 -0
  124. package/dist/commands/query-engine/builtins/format-builtins.d.ts +11 -0
  125. package/dist/commands/query-engine/builtins/index-builtins.d.ts +16 -0
  126. package/dist/commands/query-engine/builtins/index.d.ts +17 -0
  127. package/dist/commands/query-engine/builtins/math-builtins.d.ts +15 -0
  128. package/dist/commands/query-engine/builtins/navigation-builtins.d.ts +18 -0
  129. package/dist/commands/query-engine/builtins/object-builtins.d.ts +15 -0
  130. package/dist/commands/query-engine/builtins/path-builtins.d.ts +20 -0
  131. package/dist/commands/query-engine/builtins/sql-builtins.d.ts +16 -0
  132. package/dist/commands/query-engine/builtins/string-builtins.d.ts +15 -0
  133. package/dist/commands/query-engine/builtins/type-builtins.d.ts +11 -0
  134. package/dist/commands/query-engine/evaluator.d.ts +10 -2
  135. package/dist/commands/query-engine/parser-types.d.ts +171 -0
  136. package/dist/commands/query-engine/parser.d.ts +2 -132
  137. package/dist/commands/query-engine/path-operations.d.ts +15 -0
  138. package/dist/commands/query-engine/value-operations.d.ts +39 -0
  139. package/dist/commands/registry.d.ts +1 -1
  140. package/dist/commands/rmdir/rmdir.d.ts +2 -0
  141. package/dist/commands/sed/lexer.d.ts +12 -0
  142. package/dist/commands/sed/parser.d.ts +9 -0
  143. package/dist/commands/sed/sed-regex.d.ts +23 -0
  144. package/dist/commands/sed/types.d.ts +13 -1
  145. package/dist/commands/tar/tar-options.d.ts +36 -0
  146. package/dist/commands/time/time.d.ts +25 -0
  147. package/dist/commands/whoami/whoami.d.ts +9 -0
  148. package/dist/commands/xan/moonblade-tokenizer.d.ts +25 -0
  149. package/dist/fs/in-memory-fs/in-memory-fs.d.ts +12 -0
  150. package/dist/fs/interface.d.ts +16 -0
  151. package/dist/fs/mountable-fs/mountable-fs.d.ts +12 -0
  152. package/dist/fs/overlay-fs/overlay-fs.d.ts +13 -1
  153. package/dist/fs/read-write-fs/read-write-fs.d.ts +13 -1
  154. package/dist/interpreter/alias-expansion.d.ts +23 -0
  155. package/dist/interpreter/arithmetic.d.ts +1 -6
  156. package/dist/interpreter/assignment-expansion.d.ts +24 -0
  157. package/dist/interpreter/builtin-dispatch.d.ts +39 -0
  158. package/dist/interpreter/builtins/compgen.d.ts +26 -0
  159. package/dist/interpreter/builtins/complete.d.ts +17 -0
  160. package/dist/interpreter/builtins/compopt.d.ts +28 -0
  161. package/dist/interpreter/builtins/declare-array-parsing.d.ts +14 -0
  162. package/dist/interpreter/builtins/declare-print.d.ts +39 -0
  163. package/dist/interpreter/builtins/declare.d.ts +10 -4
  164. package/dist/interpreter/builtins/dirs.d.ts +29 -0
  165. package/dist/interpreter/builtins/eval.d.ts +1 -1
  166. package/dist/interpreter/builtins/export.d.ts +1 -0
  167. package/dist/interpreter/builtins/getopts.d.ts +18 -0
  168. package/dist/interpreter/builtins/hash.d.ts +19 -0
  169. package/dist/interpreter/builtins/help.d.ts +12 -0
  170. package/dist/interpreter/builtins/index.d.ts +9 -1
  171. package/dist/interpreter/builtins/local.d.ts +1 -1
  172. package/dist/interpreter/builtins/read.d.ts +1 -1
  173. package/dist/interpreter/builtins/set.d.ts +3 -0
  174. package/dist/interpreter/builtins/shift.d.ts +3 -0
  175. package/dist/interpreter/builtins/shopt.d.ts +7 -0
  176. package/dist/interpreter/builtins/unset.d.ts +5 -1
  177. package/dist/interpreter/builtins/variable-assignment.d.ts +66 -0
  178. package/dist/interpreter/command-resolution.d.ts +43 -0
  179. package/dist/interpreter/conditionals.d.ts +1 -1
  180. package/dist/interpreter/errors.d.ts +36 -1
  181. package/dist/interpreter/expansion/analysis.d.ts +15 -17
  182. package/dist/interpreter/expansion/arith-text-expansion.d.ts +20 -0
  183. package/dist/interpreter/expansion/array-pattern-ops.d.ts +21 -0
  184. package/dist/interpreter/expansion/array-prefix-suffix.d.ts +46 -0
  185. package/dist/interpreter/expansion/array-slice-transform.d.ts +36 -0
  186. package/dist/interpreter/expansion/array-word-expansion.d.ts +39 -0
  187. package/dist/interpreter/expansion/command-substitution.d.ts +23 -0
  188. package/dist/interpreter/expansion/glob-escape.d.ts +32 -0
  189. package/dist/interpreter/expansion/indirect-expansion.d.ts +42 -0
  190. package/dist/interpreter/expansion/parameter-ops.d.ts +113 -0
  191. package/dist/interpreter/expansion/pattern-expansion.d.ts +23 -0
  192. package/dist/interpreter/expansion/pattern-removal.d.ts +18 -0
  193. package/dist/interpreter/expansion/pattern.d.ts +2 -1
  194. package/dist/interpreter/expansion/positional-params.d.ts +59 -0
  195. package/dist/interpreter/expansion/prompt.d.ts +39 -0
  196. package/dist/interpreter/expansion/quoting.d.ts +13 -0
  197. package/dist/interpreter/expansion/tilde.d.ts +12 -0
  198. package/dist/interpreter/expansion/unquoted-expansion.d.ts +76 -0
  199. package/dist/interpreter/expansion/variable-attrs.d.ts +19 -0
  200. package/dist/interpreter/expansion/variable.d.ts +10 -1
  201. package/dist/interpreter/expansion/word-glob-expansion.d.ts +33 -0
  202. package/dist/interpreter/expansion/word-split.d.ts +11 -6
  203. package/dist/interpreter/expansion.d.ts +30 -4
  204. package/dist/interpreter/functions.d.ts +1 -1
  205. package/dist/interpreter/helpers/array.d.ts +20 -0
  206. package/dist/interpreter/helpers/ifs.d.ts +66 -5
  207. package/dist/interpreter/helpers/nameref.d.ts +65 -0
  208. package/dist/interpreter/helpers/quoting.d.ts +24 -0
  209. package/dist/interpreter/helpers/readonly.d.ts +28 -4
  210. package/dist/interpreter/helpers/shell-constants.d.ts +25 -0
  211. package/dist/interpreter/helpers/shellopts.d.ts +28 -0
  212. package/dist/interpreter/helpers/string-compare.d.ts +3 -1
  213. package/dist/interpreter/helpers/tilde.d.ts +13 -0
  214. package/dist/interpreter/helpers/variable-tests.d.ts +1 -1
  215. package/dist/interpreter/helpers/word-matching.d.ts +26 -0
  216. package/dist/interpreter/helpers/xtrace.d.ts +18 -0
  217. package/dist/interpreter/interpreter.d.ts +13 -14
  218. package/dist/interpreter/pipeline-execution.d.ts +16 -0
  219. package/dist/interpreter/redirections.d.ts +38 -1
  220. package/dist/interpreter/simple-command-assignments.d.ts +29 -0
  221. package/dist/interpreter/subshell-group.d.ts +32 -0
  222. package/dist/interpreter/type-command.d.ts +37 -0
  223. package/dist/interpreter/types.d.ts +255 -21
  224. package/dist/limits.d.ts +2 -0
  225. package/dist/parser/arithmetic-parser.d.ts +2 -4
  226. package/dist/parser/arithmetic-primaries.d.ts +45 -0
  227. package/dist/parser/compound-parser.d.ts +21 -7
  228. package/dist/parser/expansion-parser.d.ts +7 -1
  229. package/dist/parser/lexer.d.ts +57 -0
  230. package/dist/parser/parser-substitution.d.ts +62 -0
  231. package/dist/parser/parser.d.ts +39 -2
  232. package/dist/parser/types.d.ts +1 -0
  233. package/dist/types.d.ts +17 -0
  234. package/package.json +10 -5
  235. package/dist/bin/chunks/alias-PCMLRCRW.js +0 -7
  236. package/dist/bin/chunks/awk2-D2US2LMM.js +0 -20
  237. package/dist/bin/chunks/bash-UT3MT5UU.js +0 -7
  238. package/dist/bin/chunks/chmod-3DIKREF7.js +0 -9
  239. package/dist/bin/chunks/chunk-ACRTDIBO.js +0 -6
  240. package/dist/bin/chunks/chunk-DV5HL4K2.js +0 -17
  241. package/dist/bin/chunks/chunk-J7BCMQDI.js +0 -16
  242. package/dist/bin/chunks/chunk-NWWB2XRE.js +0 -6
  243. package/dist/bin/chunks/chunk-PM2DS2YW.js +0 -3
  244. package/dist/bin/chunks/env-YLLSNZZN.js +0 -9
  245. package/dist/bin/chunks/od-SLM7SRWU.js +0 -7
  246. package/dist/bin/chunks/printf-HWUQKYUM.js +0 -14
  247. package/dist/bin/chunks/pwd-53KG2MCJ.js +0 -3
  248. package/dist/bin/chunks/sed-5LQMJYRJ.js +0 -80
  249. package/dist/bin/chunks/touch-TSNAXMZ2.js +0 -4
  250. package/dist/bin/chunks/wc-QSBRKIF5.js +0 -6
  251. package/dist/bin/shell/chunks/alias-PCMLRCRW.js +0 -7
  252. package/dist/bin/shell/chunks/awk2-D2US2LMM.js +0 -20
  253. package/dist/bin/shell/chunks/bash-UT3MT5UU.js +0 -7
  254. package/dist/bin/shell/chunks/chmod-3DIKREF7.js +0 -9
  255. package/dist/bin/shell/chunks/chunk-ACRTDIBO.js +0 -6
  256. package/dist/bin/shell/chunks/chunk-DV5HL4K2.js +0 -17
  257. package/dist/bin/shell/chunks/chunk-J7BCMQDI.js +0 -16
  258. package/dist/bin/shell/chunks/chunk-NWWB2XRE.js +0 -6
  259. package/dist/bin/shell/chunks/chunk-PM2DS2YW.js +0 -3
  260. package/dist/bin/shell/chunks/env-YLLSNZZN.js +0 -9
  261. package/dist/bin/shell/chunks/od-SLM7SRWU.js +0 -7
  262. package/dist/bin/shell/chunks/printf-HWUQKYUM.js +0 -14
  263. package/dist/bin/shell/chunks/pwd-53KG2MCJ.js +0 -3
  264. package/dist/bin/shell/chunks/sed-5LQMJYRJ.js +0 -80
  265. package/dist/bin/shell/chunks/touch-TSNAXMZ2.js +0 -4
  266. package/dist/bin/shell/chunks/wc-QSBRKIF5.js +0 -6
  267. package/dist/bundle/chunks/alias-4UGRF4DM.js +0 -6
  268. package/dist/bundle/chunks/awk2-46RTIZKB.js +0 -19
  269. package/dist/bundle/chunks/bash-ZILV3VHA.js +0 -6
  270. package/dist/bundle/chunks/chmod-FBHLEIY6.js +0 -8
  271. package/dist/bundle/chunks/chunk-4JO5BKO4.js +0 -5
  272. package/dist/bundle/chunks/chunk-BOJ3OAZB.js +0 -16
  273. package/dist/bundle/chunks/chunk-CG2HXOFG.js +0 -5
  274. package/dist/bundle/chunks/chunk-NWEGHOXL.js +0 -2
  275. package/dist/bundle/chunks/chunk-W2EKKAIL.js +0 -15
  276. package/dist/bundle/chunks/env-EG5SQSAQ.js +0 -8
  277. package/dist/bundle/chunks/od-ECWXNUB4.js +0 -6
  278. package/dist/bundle/chunks/printf-VG2POOXB.js +0 -13
  279. package/dist/bundle/chunks/pwd-AC4P3JKI.js +0 -2
  280. package/dist/bundle/chunks/sed-ZKODWZ6F.js +0 -79
  281. package/dist/bundle/chunks/touch-MVQSKQKT.js +0 -3
  282. package/dist/bundle/chunks/wc-DFQKWSIZ.js +0 -5
  283. package/dist/interpreter/builtins/variable-helpers.d.ts +0 -30
  284. /package/dist/bin/chunks/{curl-LCMREE7R.js → curl-TH7YRBSA.js} +0 -0
  285. /package/dist/bin/chunks/{file-LNCFDPQZ.js → file-6PCTL3MH.js} +0 -0
  286. /package/dist/bin/shell/chunks/{curl-LCMREE7R.js → curl-TH7YRBSA.js} +0 -0
  287. /package/dist/bin/shell/chunks/{file-LNCFDPQZ.js → file-6PCTL3MH.js} +0 -0
  288. /package/dist/bundle/chunks/{curl-TVZH24MD.js → curl-XLP4VABU.js} +0 -0
  289. /package/dist/bundle/chunks/{file-XPA6O6H2.js → file-NQP3CKRV.js} +0 -0
  290. /package/dist/commands/curl/{utils.d.ts → response-formatting.d.ts} +0 -0
  291. /package/dist/commands/xan/{xan-utils.d.ts → column-selection.d.ts} +0 -0
  292. /package/dist/fs/{utils.d.ts → encoding.d.ts} +0 -0
@@ -10,7 +10,9 @@
10
10
  * All functions take a Parser instance as the first argument for shared state access.
11
11
  */
12
12
  import type { ArithExpr, ArithmeticExpressionNode } from "../ast/types.js";
13
+ import { parseArithNumber } from "./arithmetic-primaries.js";
13
14
  import type { Parser } from "./parser.js";
15
+ export { parseArithNumber };
14
16
  /**
15
17
  * Parse an arithmetic expression string into an AST node
16
18
  */
@@ -19,7 +21,3 @@ export declare function parseArithExpr(p: Parser, input: string, pos: number): {
19
21
  expr: ArithExpr;
20
22
  pos: number;
21
23
  };
22
- /**
23
- * Parse a number string with various bases (decimal, hex, octal, base#num)
24
- */
25
- export declare function parseArithNumber(str: string): number;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Helper functions for parsing primary arithmetic expressions
3
+ */
4
+ import type { ArithExpr } from "../ast/types.js";
5
+ import type { Parser } from "./parser.js";
6
+ /**
7
+ * Skip whitespace in arithmetic expression input.
8
+ * Also handles line continuations (backslash followed by newline).
9
+ */
10
+ export declare function skipArithWhitespace(input: string, pos: number): number;
11
+ /**
12
+ * Assignment operators in arithmetic expressions
13
+ */
14
+ export declare const ARITH_ASSIGN_OPS: readonly ["=", "+=", "-=", "*=", "/=", "%=", "<<=", ">>=", "&=", "|=", "^="];
15
+ /**
16
+ * Parse a number string with various bases (decimal, hex, octal, base#num)
17
+ * Returns NaN for invalid numbers.
18
+ */
19
+ export declare function parseArithNumber(str: string): number;
20
+ /**
21
+ * Parse nested arithmetic expression: $((expr))
22
+ */
23
+ export declare function parseNestedArithmetic(parseArithExpr: (p: Parser, input: string, pos: number) => {
24
+ expr: ArithExpr;
25
+ pos: number;
26
+ }, p: Parser, input: string, currentPos: number): {
27
+ expr: ArithExpr;
28
+ pos: number;
29
+ } | null;
30
+ /**
31
+ * Parse ANSI-C quoting: $'...'
32
+ * Returns the numeric value of the string content
33
+ */
34
+ export declare function parseAnsiCQuoting(input: string, currentPos: number): {
35
+ expr: ArithExpr;
36
+ pos: number;
37
+ } | null;
38
+ /**
39
+ * Parse localization quoting: $"..."
40
+ * Returns the numeric value of the string content
41
+ */
42
+ export declare function parseLocalizationQuoting(input: string, currentPos: number): {
43
+ expr: ArithExpr;
44
+ pos: number;
45
+ } | null;
@@ -5,10 +5,24 @@
5
5
  */
6
6
  import { type CaseNode, type CStyleForNode, type ForNode, type GroupNode, type IfNode, type SubshellNode, type UntilNode, type WhileNode } from "../ast/types.js";
7
7
  import type { Parser } from "./parser.js";
8
- export declare function parseIf(p: Parser): IfNode;
9
- export declare function parseFor(p: Parser): ForNode | CStyleForNode;
10
- export declare function parseWhile(p: Parser): WhileNode;
11
- export declare function parseUntil(p: Parser): UntilNode;
12
- export declare function parseCase(p: Parser): CaseNode;
13
- export declare function parseSubshell(p: Parser): SubshellNode | CStyleForNode;
14
- export declare function parseGroup(p: Parser): GroupNode;
8
+ export declare function parseIf(p: Parser, options?: {
9
+ skipRedirections?: boolean;
10
+ }): IfNode;
11
+ export declare function parseFor(p: Parser, options?: {
12
+ skipRedirections?: boolean;
13
+ }): ForNode | CStyleForNode;
14
+ export declare function parseWhile(p: Parser, options?: {
15
+ skipRedirections?: boolean;
16
+ }): WhileNode;
17
+ export declare function parseUntil(p: Parser, options?: {
18
+ skipRedirections?: boolean;
19
+ }): UntilNode;
20
+ export declare function parseCase(p: Parser, options?: {
21
+ skipRedirections?: boolean;
22
+ }): CaseNode;
23
+ export declare function parseSubshell(p: Parser, options?: {
24
+ skipRedirections?: boolean;
25
+ }): SubshellNode | CStyleForNode;
26
+ export declare function parseGroup(p: Parser, options?: {
27
+ skipRedirections?: boolean;
28
+ }): GroupNode;
@@ -7,4 +7,10 @@ import { type WordPart } from "../ast/types.js";
7
7
  import type { Parser } from "./parser.js";
8
8
  export declare function parseWordParts(p: Parser, value: string, quoted?: boolean, singleQuoted?: boolean, isAssignment?: boolean, hereDoc?: boolean,
9
9
  /** When true, single quotes are treated as literal characters, not quote delimiters */
10
- singleQuotesAreLiteral?: boolean): WordPart[];
10
+ singleQuotesAreLiteral?: boolean,
11
+ /** When true, brace expansion is disabled (used in [[ ]] conditionals) */
12
+ noBraceExpansion?: boolean,
13
+ /** When true, all backslash escapes create Escaped nodes (for regex patterns in [[ =~ ]]) */
14
+ regexPattern?: boolean,
15
+ /** When true, \} is treated as escaped } (used in parameter expansion default values) */
16
+ inParameterExpansion?: boolean): WordPart[];
@@ -63,6 +63,7 @@ export declare enum TokenType {
63
63
  NAME = "NAME",// Valid variable name
64
64
  NUMBER = "NUMBER",// For redirections like 2>&1
65
65
  ASSIGNMENT_WORD = "ASSIGNMENT_WORD",// VAR=value
66
+ FD_VARIABLE = "FD_VARIABLE",// {varname} before redirect operator
66
67
  COMMENT = "COMMENT",
67
68
  HEREDOC_CONTENT = "HEREDOC_CONTENT"
68
69
  }
@@ -78,6 +79,14 @@ export interface Token {
78
79
  quoted?: boolean;
79
80
  singleQuoted?: boolean;
80
81
  }
82
+ /**
83
+ * Error thrown when the lexer encounters invalid input
84
+ */
85
+ export declare class LexerError extends Error {
86
+ line: number;
87
+ column: number;
88
+ constructor(message: string, line: number, column: number);
89
+ }
81
90
  /**
82
91
  * Lexer class
83
92
  */
@@ -88,6 +97,7 @@ export declare class Lexer {
88
97
  private column;
89
98
  private tokens;
90
99
  private pendingHeredocs;
100
+ private dparenDepth;
91
101
  constructor(input: string);
92
102
  /**
93
103
  * Tokenize the entire input
@@ -95,6 +105,13 @@ export declare class Lexer {
95
105
  tokenize(): Token[];
96
106
  private skipWhitespace;
97
107
  private nextToken;
108
+ /**
109
+ * Look ahead from position after (( to determine if this is nested subshells
110
+ * like ((cmd) || (cmd2)) rather than arithmetic like ((1+2)).
111
+ *
112
+ * Returns true if it looks like nested subshells (command invocation).
113
+ */
114
+ private looksLikeNestedSubshells;
98
115
  private makeToken;
99
116
  private readComment;
100
117
  private readWord;
@@ -132,4 +149,44 @@ export declare class Lexer {
132
149
  * This is used when {} contains something but it's not a valid brace expansion.
133
150
  */
134
151
  private scanLiteralBraceWord;
152
+ /**
153
+ * Scan an extglob pattern starting at the opening parenthesis.
154
+ * Extglob patterns are: @(...), *(...), +(...), ?(...), !(...)
155
+ * The operator (@, *, +, ?, !) is already consumed; we start at the (.
156
+ * Returns the content including parentheses, or null if not a valid extglob.
157
+ */
158
+ private scanExtglobPattern;
159
+ /**
160
+ * Scan for FD variable syntax: {varname} immediately followed by a redirect operator.
161
+ * This is the bash 4.1+ feature where {fd}>file allocates an FD and stores it in variable.
162
+ * Returns the variable name and end position if found, null otherwise.
163
+ *
164
+ * Valid patterns:
165
+ * - {varname}>file, {varname}>>file, {varname}>|file
166
+ * - {varname}<file, {varname}<<word, {varname}<<<word
167
+ * - {varname}<>file
168
+ * - {varname}>&N, {varname}<&N
169
+ * - {varname}>&-, {varname}<&- (close FD)
170
+ */
171
+ private scanFdVariable;
172
+ /**
173
+ * Scan ahead from a $(( position to determine if it should be treated as
174
+ * $( ( subshell ) ) instead of $(( arithmetic )).
175
+ * This handles cases like:
176
+ * echo $(( echo 1
177
+ * echo 2
178
+ * ) )
179
+ * which should be a command substitution containing a subshell, not arithmetic.
180
+ *
181
+ * @param startPos - position at the second ( (i.e., at input[startPos] === "(")
182
+ * @returns true if this is a subshell (closes with ) )), false if arithmetic (closes with )))
183
+ */
184
+ private dollarDparenIsSubshell;
185
+ /**
186
+ * Scan ahead from a (( position to determine if it closes with ) ) (nested subshells)
187
+ * or )) (arithmetic). We need to track paren depth and quotes to find the matching close.
188
+ * @param startPos - position after the (( (i.e., at the first char of content)
189
+ * @returns true if it closes with ) ) (space between parens), false otherwise
190
+ */
191
+ private dparenClosesWithSpacedParens;
135
192
  }
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Command and Arithmetic Substitution Parsing Helpers
3
+ *
4
+ * Contains pure string analysis functions and substitution parsing utilities
5
+ * extracted from the main parser.
6
+ */
7
+ import { type CommandSubstitutionPart, type ScriptNode } from "../ast/types.js";
8
+ /**
9
+ * Type for a parser factory function that creates new parser instances.
10
+ * Used to avoid circular dependencies.
11
+ */
12
+ export type ParserFactory = () => {
13
+ parse(input: string): ScriptNode;
14
+ };
15
+ /**
16
+ * Type for an error reporting function.
17
+ */
18
+ export type ErrorFn = (message: string) => never;
19
+ /**
20
+ * Check if $(( at position `start` in `value` is a command substitution with nested
21
+ * subshell rather than arithmetic expansion. This uses similar logic to the lexer's
22
+ * dparenClosesWithSpacedParens but operates on a string within a word/expansion.
23
+ *
24
+ * The key heuristics are:
25
+ * 1. If it closes with `) )` (separated by whitespace or content), it's a subshell
26
+ * 2. If at depth 1 we see `||`, `&&`, or single `|`, it's a command context
27
+ * 3. If it closes with `))`, it's arithmetic
28
+ *
29
+ * @param value The string containing the expansion
30
+ * @param start Position of the `$` in `$((` (so `$((` is at start..start+2)
31
+ * @returns true if this should be parsed as command substitution, false for arithmetic
32
+ */
33
+ export declare function isDollarDparenSubshell(value: string, start: number): boolean;
34
+ /**
35
+ * Parse a command substitution starting at the given position.
36
+ * Handles $(...) syntax with proper depth tracking for nested substitutions.
37
+ *
38
+ * @param value The string containing the substitution
39
+ * @param start Position of the `$` in `$(`
40
+ * @param createParser Factory function to create a new parser instance
41
+ * @param error Error reporting function
42
+ * @returns The parsed command substitution part and the ending index
43
+ */
44
+ export declare function parseCommandSubstitutionFromString(value: string, start: number, createParser: ParserFactory, error: ErrorFn): {
45
+ part: CommandSubstitutionPart;
46
+ endIndex: number;
47
+ };
48
+ /**
49
+ * Parse a backtick command substitution starting at the given position.
50
+ * Handles `...` syntax with proper escape processing.
51
+ *
52
+ * @param value The string containing the substitution
53
+ * @param start Position of the opening backtick
54
+ * @param inDoubleQuotes Whether the backtick is inside double quotes
55
+ * @param createParser Factory function to create a new parser instance
56
+ * @param error Error reporting function
57
+ * @returns The parsed command substitution part and the ending index
58
+ */
59
+ export declare function parseBacktickSubstitutionFromString(value: string, start: number, inDoubleQuotes: boolean, createParser: ParserFactory, error: ErrorFn): {
60
+ part: CommandSubstitutionPart;
61
+ endIndex: number;
62
+ };
@@ -24,6 +24,12 @@ export declare class Parser {
24
24
  private pos;
25
25
  private pendingHeredocs;
26
26
  private parseIterations;
27
+ private _input;
28
+ /**
29
+ * Get the raw input string being parsed.
30
+ * Used by conditional-parser for extracting exact whitespace in regex patterns.
31
+ */
32
+ getInput(): string;
27
33
  /**
28
34
  * Check parse iteration limit to prevent infinite loops
29
35
  */
@@ -55,15 +61,41 @@ export declare class Parser {
55
61
  private isCommandStart;
56
62
  private parseScript;
57
63
  /**
58
- * Check for unexpected tokens that can't appear at statement start
64
+ * Check for unexpected tokens that can't appear at statement start.
65
+ * Returns a deferred error statement for tokens that should cause errors
66
+ * at execution time rather than parse time (to match bash's incremental behavior).
59
67
  */
60
68
  private checkUnexpectedToken;
61
69
  parseStatement(): StatementNode | null;
62
70
  private parsePipeline;
63
71
  private parseCommand;
72
+ /**
73
+ * Scan ahead from current DPAREN_START to determine if it closes with ) )
74
+ * (two separate RPAREN tokens) or )) (DPAREN_END token).
75
+ * Returns true if it closes with ) ) (nested subshells case).
76
+ */
77
+ private dparenClosesWithSpacedParens;
78
+ /**
79
+ * Parse (( ... ) ) as nested subshells when we know it closes with ) ).
80
+ * We've already determined via dparenClosesWithSpacedParens() that this
81
+ * DPAREN_START should be treated as two LPAREN tokens.
82
+ */
83
+ private parseNestedSubshellsFromDparen;
64
84
  isWord(): boolean;
65
85
  parseWord(): WordNode;
66
- parseWordFromString(value: string, quoted?: boolean, singleQuoted?: boolean, isAssignment?: boolean, hereDoc?: boolean): WordNode;
86
+ /**
87
+ * Parse a word without brace expansion (for [[ ]] conditionals).
88
+ * In bash, brace expansion does not occur inside [[ ]].
89
+ */
90
+ parseWordNoBraceExpansion(): WordNode;
91
+ /**
92
+ * Parse a word for regex patterns (in [[ =~ ]]).
93
+ * All escaped characters create Escaped nodes so the backslash is preserved
94
+ * for the regex engine. For example, \$ creates Escaped("$") which becomes \$
95
+ * in the final regex pattern.
96
+ */
97
+ parseWordForRegex(): WordNode;
98
+ parseWordFromString(value: string, quoted?: boolean, singleQuoted?: boolean, isAssignment?: boolean, hereDoc?: boolean, noBraceExpansion?: boolean, regexPattern?: boolean): WordNode;
67
99
  parseCommandSubstitution(value: string, start: number): {
68
100
  part: CommandSubstitutionPart;
69
101
  endIndex: number;
@@ -74,6 +106,11 @@ export declare class Parser {
74
106
  part: CommandSubstitutionPart;
75
107
  endIndex: number;
76
108
  };
109
+ /**
110
+ * Check if $(( at position `start` in `value` is a command substitution with nested
111
+ * subshell rather than arithmetic expansion.
112
+ */
113
+ isDollarDparenSubshell(value: string, start: number): boolean;
77
114
  parseArithmeticExpansion(value: string, start: number): {
78
115
  part: ArithmeticExpansionPart;
79
116
  endIndex: number;
@@ -9,6 +9,7 @@ export declare const MAX_TOKENS = 100000;
9
9
  export declare const MAX_PARSE_ITERATIONS = 1000000;
10
10
  export declare const REDIRECTION_TOKENS: Set<TokenType>;
11
11
  export declare const REDIRECTION_AFTER_NUMBER: Set<TokenType>;
12
+ export declare const REDIRECTION_AFTER_FD_VARIABLE: Set<TokenType>;
12
13
  export interface ParseError {
13
14
  message: string;
14
15
  line: number;
package/dist/types.d.ts CHANGED
@@ -63,6 +63,12 @@ export interface CommandContext {
63
63
  cwd: string;
64
64
  /** Environment variables */
65
65
  env: Record<string, string>;
66
+ /**
67
+ * Exported environment variables only.
68
+ * Used by commands like printenv and env that should only show exported vars.
69
+ * In bash, only exported variables are passed to child processes.
70
+ */
71
+ exportedEnv?: Record<string, string>;
66
72
  /** Standard input content */
67
73
  stdin: string;
68
74
  /**
@@ -100,6 +106,17 @@ export interface CommandContext {
100
106
  * Useful for testing with mock clocks.
101
107
  */
102
108
  sleep?: (ms: number) => Promise<void>;
109
+ /**
110
+ * File descriptors map for here-docs and process substitution.
111
+ * Maps FD numbers to their content (e.g., 3 -> "content from 3<<EOF").
112
+ * Note: FD 0 content is in `stdin`, but may also appear here for consistency.
113
+ */
114
+ fileDescriptors?: Map<number, string>;
115
+ /**
116
+ * Whether xpg_echo shopt is enabled.
117
+ * When true, echo interprets backslash escapes by default (like echo -e).
118
+ */
119
+ xpgEcho?: boolean;
103
120
  }
104
121
  export interface Command {
105
122
  name: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "just-bash",
3
- "version": "2.5.5",
3
+ "version": "2.7.0",
4
4
  "description": "A simulated bash environment with virtual filesystem",
5
5
  "repository": {
6
6
  "type": "git",
@@ -57,6 +57,7 @@
57
57
  "@types/sprintf-js": "^1.1.4",
58
58
  "@types/sql.js": "^1.4.9",
59
59
  "@types/turndown": "^5.0.6",
60
+ "@vitest/coverage-v8": "^4.0.18",
60
61
  "esbuild": "^0.27.2",
61
62
  "knip": "^5.41.1",
62
63
  "typescript": "^5.9.3",
@@ -72,6 +73,7 @@
72
73
  "minimatch": "^10.1.1",
73
74
  "modern-tar": "^0.7.3",
74
75
  "papaparse": "^5.5.3",
76
+ "pyodide": "^0.27.0",
75
77
  "smol-toml": "^1.6.0",
76
78
  "sprintf-js": "^1.1.3",
77
79
  "sql.js": "^1.13.0",
@@ -83,12 +85,13 @@
83
85
  },
84
86
  "packageManager": "pnpm@8.15.9+sha512.499434c9d8fdd1a2794ebf4552b3b25c0a633abcee5bb15e7b5de90f32f47b513aca98cd5cfd001c31f0db454bc3804edccd578501e4ca293a6816166bbd9f81",
85
87
  "scripts": {
86
- "build": "rm -rf dist && tsc && pnpm build:lib && pnpm build:browser && pnpm build:cli && pnpm build:shell && pnpm build:clean && sed '1,/^-->/d' AGENTS.npm.md > dist/AGENTS.md",
88
+ "build": "rm -rf dist && tsc && pnpm build:lib && pnpm build:browser && pnpm build:cli && pnpm build:shell && pnpm build:worker && pnpm build:clean && sed '1,/^-->/d' AGENTS.npm.md > dist/AGENTS.md",
87
89
  "build:clean": "find dist -name '*.test.js' -delete && find dist -name '*.test.d.ts' -delete",
88
- "build:lib": "esbuild dist/index.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bundle --chunk-names=chunks/[name]-[hash] --external:diff --external:minimatch --external:sprintf-js --external:turndown --external:sql.js --external:@mongodb-js/zstd --external:node-liblzma --external:compressjs",
90
+ "build:worker": "esbuild src/commands/python3/worker.ts --bundle --platform=node --format=esm --outfile=src/commands/python3/worker.js --external:pyodide && cp src/commands/python3/worker.js dist/commands/python3/worker.js && mkdir -p dist/bin/chunks && cp src/commands/python3/worker.js dist/bin/chunks/worker.js && mkdir -p dist/bundle/chunks && cp src/commands/python3/worker.js dist/bundle/chunks/worker.js",
91
+ "build:lib": "esbuild dist/index.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bundle --chunk-names=chunks/[name]-[hash] --external:diff --external:minimatch --external:sprintf-js --external:turndown --external:sql.js --external:pyodide --external:@mongodb-js/zstd --external:node-liblzma --external:compressjs",
89
92
  "build:browser": "esbuild dist/browser.js --bundle --platform=browser --format=esm --minify --outfile=dist/bundle/browser.js --external:diff --external:minimatch --external:sprintf-js --external:turndown --external:node:* --external:@mongodb-js/zstd --external:node-liblzma --external:compressjs --define:__BROWSER__=true",
90
- "build:cli": "esbuild dist/cli/just-bash.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bin --entry-names=[name] --chunk-names=chunks/[name]-[hash] --banner:js='#!/usr/bin/env node' --external:sql.js --external:@mongodb-js/zstd --external:node-liblzma --external:compressjs",
91
- "build:shell": "esbuild dist/cli/shell.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bin/shell --entry-names=[name] --chunk-names=chunks/[name]-[hash] --banner:js='#!/usr/bin/env node' --external:sql.js --external:@mongodb-js/zstd --external:node-liblzma --external:compressjs",
93
+ "build:cli": "esbuild dist/cli/just-bash.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bin --entry-names=[name] --chunk-names=chunks/[name]-[hash] --banner:js='#!/usr/bin/env node' --external:sql.js --external:pyodide --external:@mongodb-js/zstd --external:node-liblzma --external:compressjs",
94
+ "build:shell": "esbuild dist/cli/shell.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bin/shell --entry-names=[name] --chunk-names=chunks/[name]-[hash] --banner:js='#!/usr/bin/env node' --external:sql.js --external:pyodide --external:@mongodb-js/zstd --external:node-liblzma --external:compressjs",
92
95
  "validate": "pnpm lint && pnpm knip && pnpm typecheck && pnpm build && pnpm test:run && pnpm test:dist",
93
96
  "typecheck": "tsc --noEmit",
94
97
  "lint": "biome check .",
@@ -100,6 +103,8 @@
100
103
  "test:unit": "vitest run --config vitest.unit.config.ts",
101
104
  "test:comparison": "vitest run --config vitest.comparison.config.ts",
102
105
  "test:comparison:record": "RECORD_FIXTURES=1 vitest run --config vitest.comparison.config.ts",
106
+ "test:coverage": "vitest run --coverage",
107
+ "test:coverage:unit": "vitest run --config vitest.unit.config.ts --coverage",
103
108
  "shell": "npx tsx src/cli/shell.ts",
104
109
  "dev:exec": "npx tsx src/cli/exec.ts"
105
110
  }
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env node
2
- import{a as l,b as r}from"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";var d={name:"alias",summary:"define or display aliases",usage:"alias [name[=value] ...]",options:[" --help display this help and exit"]},o="BASH_ALIAS_",f={name:"alias",async execute(i,n){if(r(i))return l(d);if(i.length===0){let e="";for(let[a,t]of Object.entries(n.env))if(a.startsWith(o)){let s=a.slice(o.length);e+=`alias ${s}='${t}'
3
- `}return{stdout:e,stderr:"",exitCode:0}}for(let e of i){let a=e.indexOf("=");if(a===-1){let t=o+e;return n.env[t]?{stdout:`alias ${e}='${n.env[t]}'
4
- `,stderr:"",exitCode:0}:{stdout:"",stderr:`alias: ${e}: not found
5
- `,exitCode:1}}else{let t=e.slice(0,a),s=e.slice(a+1);(s.startsWith("'")&&s.endsWith("'")||s.startsWith('"')&&s.endsWith('"'))&&(s=s.slice(1,-1)),n.env[o+t]=s}}return{stdout:"",stderr:"",exitCode:0}}},m={name:"unalias",async execute(i,n){if(r(i))return l({name:"unalias",summary:"remove alias definitions",usage:"unalias name [name ...]",options:["-a remove all aliases"," --help display this help and exit"]});if(i.length===0)return{stdout:"",stderr:`unalias: usage: unalias [-a] name [name ...]
6
- `,exitCode:1};if(i[0]==="-a"){for(let t of Object.keys(n.env))t.startsWith(o)&&delete n.env[t];return{stdout:"",stderr:"",exitCode:0}}let e=!1,a="";for(let t of i){let s=o+t;n.env[s]?delete n.env[s]:(a+=`unalias: ${t}: not found
7
- `,e=!0)}return{stdout:"",stderr:a,exitCode:e?1:0}}};export{f as aliasCommand,m as unaliasCommand};
@@ -1,20 +0,0 @@
1
- #!/usr/bin/env node
2
- import{i as g}from"./chunk-NWWB2XRE.js";import{a as K,b as Q,c as U}from"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";function x(e={}){let{fieldSep:t=/\s+/,maxIterations:r=1e4,maxRecursionDepth:n=100,fs:a,cwd:s}=e;return{FS:" ",OFS:" ",ORS:`
3
- `,NR:0,NF:0,FNR:0,FILENAME:"",RSTART:0,RLENGTH:-1,SUBSEP:"",fields:[],line:"",vars:{},arrays:{},ARGC:0,ARGV:{},functions:new Map,fieldSep:t,maxIterations:r,maxRecursionDepth:n,currentRecursionDepth:0,exitCode:0,shouldExit:!1,shouldNext:!1,shouldNextFile:!1,loopBreak:!1,loopContinue:!1,hasReturn:!1,output:"",openedFiles:new Set,fs:a,cwd:s}}function j(e,t,r){switch(r){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 A(e){if(typeof e=="number")return e;let t=parseFloat(e);return Number.isNaN(t)?0:t}function w(e){return typeof e=="string"?e:(Number.isInteger(e),String(e))}async function ce(e,t,r){return e.length===0?t.line.length:w(await r.evalExpr(e[0])).length}async function he(e,t,r){if(e.length<2)return"";let n=w(await r.evalExpr(e[0])),a=Math.floor(A(await r.evalExpr(e[1])))-1;if(e.length>=3){let s=Math.floor(A(await r.evalExpr(e[2])));return n.substr(Math.max(0,a),s)}return n.substr(Math.max(0,a))}async function ue(e,t,r){if(e.length<2)return 0;let n=w(await r.evalExpr(e[0])),a=w(await r.evalExpr(e[1])),s=n.indexOf(a);return s===-1?0:s+1}async function pe(e,t,r){if(e.length<2)return 0;let n=w(await r.evalExpr(e[0])),a=e[1];if(a.type!=="variable")return 0;let s=a.name,o=t.FS;if(e.length>=3){let u=w(await r.evalExpr(e[2]));o=u===" "?/\s+/:u}else t.FS===" "&&(o=/\s+/);let l=n.split(o);t.arrays[s]={};for(let u=0;u<l.length;u++)t.arrays[s][String(u+1)]=l[u];return l.length}async function fe(e,t,r){if(e.length<2)return 0;let n;e[0].type==="regex"?n=e[0].pattern:(n=w(await r.evalExpr(e[0])),n.startsWith("/")&&n.endsWith("/")&&(n=n.slice(1,-1)));let a=w(await r.evalExpr(e[1])),s="$0";if(e.length>=3){let l=e[2];l.type==="variable"?s=l.name:l.type==="field"&&(s=`$${Math.floor(A(await r.evalExpr(l.index)))}`)}let o;if(s==="$0")o=t.line;else if(s.startsWith("$")){let l=parseInt(s.slice(1),10)-1;o=t.fields[l]||""}else o=w(t.vars[s]??"");try{let l=new RegExp(n),u=o.replace(l,z(a)),m=u!==o?1:0;if(s==="$0")t.line=u,t.fields=t.FS===" "?u.trim().split(/\s+/).filter(Boolean):u.split(t.fieldSep),t.NF=t.fields.length;else if(s.startsWith("$")){let N=parseInt(s.slice(1),10)-1;for(;t.fields.length<=N;)t.fields.push("");t.fields[N]=u,t.NF=t.fields.length,t.line=t.fields.join(t.OFS)}else t.vars[s]=u;return m}catch{return 0}}async function de(e,t,r){if(e.length<2)return 0;let n;e[0].type==="regex"?n=e[0].pattern:(n=w(await r.evalExpr(e[0])),n.startsWith("/")&&n.endsWith("/")&&(n=n.slice(1,-1)));let a=w(await r.evalExpr(e[1])),s="$0";if(e.length>=3){let l=e[2];l.type==="variable"?s=l.name:l.type==="field"&&(s=`$${Math.floor(A(await r.evalExpr(l.index)))}`)}let o;if(s==="$0")o=t.line;else if(s.startsWith("$")){let l=parseInt(s.slice(1),10)-1;o=t.fields[l]||""}else o=w(t.vars[s]??"");try{let l=new RegExp(n,"g"),u=o.match(l),m=u?u.length:0,N=o.replace(l,z(a));if(s==="$0")t.line=N,t.fields=t.FS===" "?N.trim().split(/\s+/).filter(Boolean):N.split(t.fieldSep),t.NF=t.fields.length;else if(s.startsWith("$")){let c=parseInt(s.slice(1),10)-1;for(;t.fields.length<=c;)t.fields.push("");t.fields[c]=N,t.NF=t.fields.length,t.line=t.fields.join(t.OFS)}else t.vars[s]=N;return m}catch{return 0}}function z(e){return t=>{let r="",n=0;for(;n<e.length;)if(e[n]==="\\"&&n+1<e.length){let a=e[n+1];a==="&"?(r+="&",n+=2):a==="\\"?(r+="\\",n+=2):(r+=e[n+1],n+=2)}else e[n]==="&"?(r+=t,n++):(r+=e[n],n++);return r}}async function Ee(e,t,r){if(e.length<2)return t.RSTART=0,t.RLENGTH=-1,0;let n=w(await r.evalExpr(e[0])),a;e[1].type==="regex"?a=e[1].pattern:(a=w(await r.evalExpr(e[1])),a.startsWith("/")&&a.endsWith("/")&&(a=a.slice(1,-1)));try{let o=new RegExp(a).exec(n);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 Ne(e,t,r){if(e.length<3)return"";let n;e[0].type==="regex"?n=e[0].pattern:(n=w(await r.evalExpr(e[0])),n.startsWith("/")&&n.endsWith("/")&&(n=n.slice(1,-1)));let a=w(await r.evalExpr(e[1])),s=w(await r.evalExpr(e[2])),o=e.length>=4?w(await r.evalExpr(e[3])):t.line;try{let l=s.toLowerCase()==="g",u=l?0:parseInt(s,10)||1;if(l){let m=new RegExp(n,"g");return o.replace(m,(N,...c)=>q(a,N,c.slice(0,-2)))}else{let m=0,N=new RegExp(n,"g");return o.replace(N,(c,...d)=>(m++,m===u?q(a,c,d.slice(0,-2)):c))}}catch{return o}}function q(e,t,r){let n="",a=0;for(;a<e.length;)if(e[a]==="\\"&&a+1<e.length){let s=e[a+1];if(s==="&")n+="&",a+=2;else if(s==="0")n+=t,a+=2;else if(s>="1"&&s<="9"){let o=parseInt(s,10)-1;n+=r[o]||"",a+=2}else s==="n"?(n+=`
4
- `,a+=2):s==="t"?(n+=" ",a+=2):(n+=s,a+=2)}else e[a]==="&"?(n+=t,a++):(n+=e[a],a++);return n}async function ye(e,t,r){return e.length===0?"":w(await r.evalExpr(e[0])).toLowerCase()}async function me(e,t,r){return e.length===0?"":w(await r.evalExpr(e[0])).toUpperCase()}async function we(e,t,r){if(e.length===0)return"";let n=w(await r.evalExpr(e[0])),a=[];for(let s=1;s<e.length;s++)a.push(await r.evalExpr(e[s]));return W(n,a)}async function Re(e,t,r){return e.length===0?0:Math.floor(A(await r.evalExpr(e[0])))}async function Se(e,t,r){return e.length===0?0:Math.sqrt(A(await r.evalExpr(e[0])))}async function Ae(e,t,r){return e.length===0?0:Math.sin(A(await r.evalExpr(e[0])))}async function ge(e,t,r){return e.length===0?0:Math.cos(A(await r.evalExpr(e[0])))}async function ve(e,t,r){let n=e.length>0?A(await r.evalExpr(e[0])):0,a=e.length>1?A(await r.evalExpr(e[1])):0;return Math.atan2(n,a)}async function ke(e,t,r){return e.length===0?0:Math.log(A(await r.evalExpr(e[0])))}async function Ie(e,t,r){return e.length===0?1:Math.exp(A(await r.evalExpr(e[0])))}function Ce(e,t,r){return t.random?t.random():Math.random()}async function be(e,t,r){let n=e.length>0?A(await r.evalExpr(e[0])):Date.now();return t.vars._srand_seed=n,n}function H(e,t){return()=>{throw new Error(`${e}() is not supported - ${t}`)}}function $(e){return()=>{throw new Error(`function '${e}()' is not implemented`)}}function W(e,t){let r=0,n="",a=0;for(;a<e.length;)if(e[a]==="%"&&a+1<e.length){let s=a+1,o="",l="",u="";for(;s<e.length&&/[-+ #0]/.test(e[s]);)o+=e[s++];for(;s<e.length&&/\d/.test(e[s]);)l+=e[s++];if(e[s]===".")for(s++;s<e.length&&/\d/.test(e[s]);)u+=e[s++];let m=e[s],N=t[r];switch(m){case"s":{let c=N!==void 0?String(N):"";if(u&&(c=c.substring(0,parseInt(u,10))),l){let d=parseInt(l,10);o.includes("-")?c=c.padEnd(d):c=c.padStart(d)}n+=c,r++;break}case"d":case"i":{let c=N!==void 0?Math.floor(Number(N)):0;Number.isNaN(c)&&(c=0);let d=String(c);if(l){let h=parseInt(l,10);if(o.includes("-"))d=d.padEnd(h);else if(o.includes("0")&&!o.includes("-")){let f=c<0?"-":"";d=f+Math.abs(c).toString().padStart(h-f.length,"0")}else d=d.padStart(h)}n+=d,r++;break}case"f":{let c=N!==void 0?Number(N):0;Number.isNaN(c)&&(c=0);let d=u?parseInt(u,10):6,h=c.toFixed(d);if(l){let f=parseInt(l,10);o.includes("-")?h=h.padEnd(f):h=h.padStart(f)}n+=h,r++;break}case"e":case"E":{let c=N!==void 0?Number(N):0;Number.isNaN(c)&&(c=0);let d=u?parseInt(u,10):6,h=c.toExponential(d);if(m==="E"&&(h=h.toUpperCase()),l){let f=parseInt(l,10);o.includes("-")?h=h.padEnd(f):h=h.padStart(f)}n+=h,r++;break}case"g":case"G":{let c=N!==void 0?Number(N):0;Number.isNaN(c)&&(c=0);let d=u?parseInt(u,10):6,h=c!==0?Math.floor(Math.log10(Math.abs(c))):0,f;if(c===0?f="0":h<-4||h>=d?(f=c.toExponential(d-1),m==="G"&&(f=f.toUpperCase())):f=c.toPrecision(d),f=f.replace(/\.?0+$/,"").replace(/\.?0+e/,"e"),l){let R=parseInt(l,10);o.includes("-")?f=f.padEnd(R):f=f.padStart(R)}n+=f,r++;break}case"x":case"X":{let c=N!==void 0?Math.floor(Number(N)):0;Number.isNaN(c)&&(c=0);let d=Math.abs(c).toString(16);if(m==="X"&&(d=d.toUpperCase()),l){let h=parseInt(l,10);o.includes("0")?d=d.padStart(h,"0"):o.includes("-")?d=d.padEnd(h):d=d.padStart(h)}n+=c<0?`-${d}`:d,r++;break}case"o":{let c=N!==void 0?Math.floor(Number(N)):0;Number.isNaN(c)&&(c=0);let d=Math.abs(c).toString(8);if(l){let h=parseInt(l,10);o.includes("0")?d=d.padStart(h,"0"):o.includes("-")?d=d.padEnd(h):d=d.padStart(h)}n+=c<0?`-${d}`:d,r++;break}case"c":{typeof N=="number"?n+=String.fromCharCode(N):n+=String(N??"").charAt(0)||"",r++;break}case"%":n+="%";break;default:n+=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":n+=`
5
- `;break;case"t":n+=" ";break;case"r":n+="\r";break;case"\\":n+="\\";break;default:n+=s}a+=2}else n+=e[a++];return n}var Z={length:ce,substr:he,index:ue,split:pe,sub:fe,gsub:de,match:Ee,gensub:Ne,tolower:ye,toupper:me,sprintf:we,int:Re,sqrt:Se,sin:Ae,cos:ge,atan2:ve,log:ke,exp:Ie,rand:Ce,srand:be,system:H("system","shell execution not allowed in sandboxed environment"),close:H("close","file operations not allowed"),fflush:H("fflush","file operations not allowed"),systime:$("systime"),mktime:$("mktime"),strftime:$("strftime")};function S(e){return typeof e=="number"?e!==0:e!==""}function E(e){if(typeof e=="number")return e;let t=parseFloat(e);return Number.isNaN(t)?0:t}function y(e){return typeof e=="string"?e:(Number.isInteger(e),String(e))}function X(e){if(typeof e=="number")return!0;let t=String(e).trim();return t===""?!1:!Number.isNaN(Number(t))}function F(e,t){try{return new RegExp(e).test(t)}catch{return!1}}function J(e,t){return e.FS===" "?t.trim().split(/\s+/).filter(Boolean):t.split(e.fieldSep)}function I(e,t){return t===0?e.line:t<0||t>e.fields.length?"":e.fields[t-1]??""}function O(e,t,r){if(t===0)e.line=y(r),e.fields=J(e,e.line),e.NF=e.fields.length;else if(t>0){for(;e.fields.length<t;)e.fields.push("");e.fields[t-1]=y(r),e.NF=e.fields.length,e.line=e.fields.join(e.OFS)}}function T(e,t){e.line=t,e.fields=J(e,t),e.NF=e.fields.length}function Y(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 C(e,t){switch(t){case"FS":return e.FS;case"OFS":return e.OFS;case"ORS":return e.ORS;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 v(e,t,r){switch(t){case"FS":Y(e,y(r));return;case"OFS":e.OFS=y(r);return;case"ORS":e.ORS=y(r);return;case"NR":e.NR=Math.floor(E(r));return;case"NF":{let n=Math.floor(E(r));if(n<e.NF)e.fields=e.fields.slice(0,n),e.line=e.fields.join(e.OFS);else if(n>e.NF){for(;e.fields.length<n;)e.fields.push("");e.line=e.fields.join(e.OFS)}e.NF=n;return}case"FNR":e.FNR=Math.floor(E(r));return;case"FILENAME":e.FILENAME=y(r);return;case"RSTART":e.RSTART=Math.floor(E(r));return;case"RLENGTH":e.RLENGTH=Math.floor(E(r));return;case"SUBSEP":e.SUBSEP=y(r);return}e.vars[t]=r}function b(e,t,r){return t==="ARGV"?e.ARGV[r]??"":e.arrays[t]?.[r]??""}function P(e,t,r,n){e.arrays[t]||(e.arrays[t]={}),e.arrays[t][r]=n}function ee(e,t,r){return t==="ARGV"?e.ARGV[r]!==void 0:e.arrays[t]?.[r]!==void 0}function te(e,t,r){e.arrays[t]&&delete e.arrays[t][r]}function re(e,t){delete e.arrays[t]}var V=null;function ie(e){V=e}async function p(e,t){switch(t.type){case"number":return t.value;case"string":return t.value;case"regex":return F(t.pattern,e.line)?1:0;case"field":return Le(e,t);case"variable":return C(e,t.name);case"array_access":return Oe(e,t);case"binary":return Pe(e,t);case"unary":return Te(e,t);case"ternary":return S(await p(e,t.condition))?p(e,t.consequent):p(e,t.alternate);case"call":return _e(e,t.name,t.args);case"assignment":return De(e,t);case"pre_increment":return Be(e,t.operand);case"pre_decrement":return Ue(e,t.operand);case"post_increment":return xe(e,t.operand);case"post_decrement":return He(e,t.operand);case"in":return $e(e,t.key,t.array);case"getline":return We(e,t.variable,t.file);case"tuple":return Ve(e,t.elements);default:return""}}async function Le(e,t){let r=Math.floor(E(await p(e,t.index)));return I(e,r)}async function Oe(e,t){let r=y(await p(e,t.key));return b(e,t.array,r)}async function Pe(e,t){let r=t.operator;if(r==="||")return S(await p(e,t.left))||S(await p(e,t.right))?1:0;if(r==="&&")return S(await p(e,t.left))&&S(await p(e,t.right))?1:0;if(r==="~"){let l=await p(e,t.left),u=t.right.type==="regex"?t.right.pattern:y(await p(e,t.right));try{return new RegExp(u).test(y(l))?1:0}catch{return 0}}if(r==="!~"){let l=await p(e,t.left),u=t.right.type==="regex"?t.right.pattern:y(await p(e,t.right));try{return new RegExp(u).test(y(l))?0:1}catch{return 1}}let n=await p(e,t.left),a=await p(e,t.right);if(r===" ")return y(n)+y(a);if(Me(r))return Fe(n,a,r);let s=E(n),o=E(a);return j(s,o,r)}function Me(e){return["<","<=",">",">=","==","!="].includes(e)}function Fe(e,t,r){let n=X(e),a=X(t);if(n&&a){let l=E(e),u=E(t);switch(r){case"<":return l<u?1:0;case"<=":return l<=u?1:0;case">":return l>u?1:0;case">=":return l>=u?1:0;case"==":return l===u?1:0;case"!=":return l!==u?1:0}}let s=y(e),o=y(t);switch(r){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 Te(e,t){let r=await p(e,t.operand);switch(t.operator){case"!":return S(r)?0:1;case"-":return-E(r);case"+":return+E(r);default:return r}}async function _e(e,t,r){let n=Z[t];if(n)return n(r,e,{evalExpr:s=>p(e,s)});let a=e.functions.get(t);return a?Ge(e,a,r):""}async function Ge(e,t,r){if(e.currentRecursionDepth++,e.currentRecursionDepth>e.maxRecursionDepth)throw e.currentRecursionDepth--,new g(`awk: recursion depth exceeded maximum (${e.maxRecursionDepth})`,"recursion",e.output);let n={};for(let s of t.params)n[s]=e.vars[s];for(let s=0;s<t.params.length;s++){let o=t.params[s],l=s<r.length?await p(e,r[s]):"";e.vars[o]=l}e.hasReturn=!1,e.returnValue=void 0,V&&await V(e,t.body.statements);let a=e.returnValue??"";for(let s of t.params)n[s]!==void 0?e.vars[s]=n[s]:delete e.vars[s];return e.hasReturn=!1,e.returnValue=void 0,e.currentRecursionDepth--,a}async function De(e,t){let r=await p(e,t.value),n=t.target,a=t.operator,s;if(a==="=")s=r;else{let o;if(n.type==="field"){let m=Math.floor(E(await p(e,n.index)));o=I(e,m)}else if(n.type==="variable")o=C(e,n.name);else{let m=y(await p(e,n.key));o=b(e,n.array,m)}let l=E(o),u=E(r);switch(a){case"+=":s=l+u;break;case"-=":s=l-u;break;case"*=":s=l*u;break;case"/=":s=u!==0?l/u:0;break;case"%=":s=u!==0?l%u:0;break;case"^=":s=l**u;break;default:s=r}}if(n.type==="field"){let o=Math.floor(E(await p(e,n.index)));O(e,o,s)}else if(n.type==="variable")v(e,n.name,s);else{let o=y(await p(e,n.key));P(e,n.array,o,s)}return s}async function Be(e,t){let r;if(t.type==="field"){let n=Math.floor(E(await p(e,t.index)));r=E(I(e,n))+1,O(e,n,r)}else if(t.type==="variable")r=E(C(e,t.name))+1,v(e,t.name,r);else{let n=y(await p(e,t.key));r=E(b(e,t.array,n))+1,P(e,t.array,n,r)}return r}async function Ue(e,t){let r;if(t.type==="field"){let n=Math.floor(E(await p(e,t.index)));r=E(I(e,n))-1,O(e,n,r)}else if(t.type==="variable")r=E(C(e,t.name))-1,v(e,t.name,r);else{let n=y(await p(e,t.key));r=E(b(e,t.array,n))-1,P(e,t.array,n,r)}return r}async function xe(e,t){let r;if(t.type==="field"){let n=Math.floor(E(await p(e,t.index)));r=E(I(e,n)),O(e,n,r+1)}else if(t.type==="variable")r=E(C(e,t.name)),v(e,t.name,r+1);else{let n=y(await p(e,t.key));r=E(b(e,t.array,n)),P(e,t.array,n,r+1)}return r}async function He(e,t){let r;if(t.type==="field"){let n=Math.floor(E(await p(e,t.index)));r=E(I(e,n)),O(e,n,r-1)}else if(t.type==="variable")r=E(C(e,t.name)),v(e,t.name,r-1);else{let n=y(await p(e,t.key));r=E(b(e,t.array,n)),P(e,t.array,n,r-1)}return r}async function $e(e,t,r){let n;if(t.type==="tuple"){let a=[];for(let s of t.elements)a.push(y(await p(e,s)));n=a.join(e.SUBSEP)}else n=y(await p(e,t));return ee(e,r,n)?1:0}async function We(e,t,r){if(r)return Xe(e,t,r);if(!e.lines||e.lineIndex===void 0)return-1;let n=e.lineIndex+1;if(n>=e.lines.length)return 0;let a=e.lines[n];return t?v(e,t,a):T(e,a),e.NR++,e.lineIndex=n,1}async function Xe(e,t,r){if(!e.fs||!e.cwd)return-1;let n=y(await p(e,r)),a=e.fs.resolvePath(e.cwd,n),s=`__fc_${a}`,o=`__fi_${a}`,l,u;if(e.vars[s]===void 0)try{l=(await e.fs.readFile(a)).split(`
6
- `),l.length>0&&l[l.length-1]===""&&l.pop(),e.vars[s]=JSON.stringify(l),e.vars[o]=-1,u=-1}catch{return-1}else l=JSON.parse(e.vars[s]),u=e.vars[o];let m=u+1;if(m>=l.length)return 0;let N=l[m];return e.vars[o]=m,t?v(e,t,N):T(e,N),1}async function Ve(e,t){if(t.length===0)return"";for(let r=0;r<t.length-1;r++)await p(e,t[r]);return p(e,t[t.length-1])}ie(M);async function M(e,t){for(let r of t)if(await L(e,r),Ke(e))break}function Ke(e){return e.shouldExit||e.shouldNext||e.shouldNextFile||e.loopBreak||e.loopContinue||e.hasReturn}async function L(e,t){switch(t.type){case"block":await M(e,t.statements);break;case"expr_stmt":await p(e,t.expression);break;case"print":await Qe(e,t.args,t.output);break;case"printf":await je(e,t.format,t.args,t.output);break;case"if":await qe(e,t);break;case"while":await ze(e,t);break;case"do_while":await Ze(e,t);break;case"for":await Je(e,t);break;case"for_in":await Ye(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(E(await p(e,t.code))):0;break;case"return":e.hasReturn=!0,e.returnValue=t.value?await p(e,t.value):"";break;case"delete":await et(e,t.target);break}}async function Qe(e,t,r){let n=[];for(let s of t)n.push(y(await p(e,s)));let a=n.join(e.OFS)+e.ORS;r?await ne(e,r.redirect,r.file,a):e.output+=a}async function je(e,t,r,n){let a=y(await p(e,t)),s=[];for(let l of r)s.push(await p(e,l));let o=W(a,s);n?await ne(e,n.redirect,n.file,o):e.output+=o}async function ne(e,t,r,n){if(!e.fs||!e.cwd){e.output+=n;return}let a=y(await p(e,r)),s=e.fs.resolvePath(e.cwd,a);t===">"?e.openedFiles.has(s)?await e.fs.appendFile(s,n):(await e.fs.writeFile(s,n),e.openedFiles.add(s)):(e.openedFiles.has(s)||e.openedFiles.add(s),await e.fs.appendFile(s,n))}async function qe(e,t){S(await p(e,t.condition))?await L(e,t.consequent):t.alternate&&await L(e,t.alternate)}async function ze(e,t){let r=0;for(;S(await p(e,t.condition));){if(r++,r>e.maxIterations)throw new g(`awk: while loop exceeded maximum iterations (${e.maxIterations})`,"iterations",e.output);if(e.loopContinue=!1,await L(e,t.body),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break}}async function Ze(e,t){let r=0;do{if(r++,r>e.maxIterations)throw new g(`awk: do-while loop exceeded maximum iterations (${e.maxIterations})`,"iterations",e.output);if(e.loopContinue=!1,await L(e,t.body),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break}while(S(await p(e,t.condition)))}async function Je(e,t){t.init&&await p(e,t.init);let r=0;for(;!t.condition||S(await p(e,t.condition));){if(r++,r>e.maxIterations)throw new g(`awk: for loop exceeded maximum iterations (${e.maxIterations})`,"iterations",e.output);if(e.loopContinue=!1,await L(e,t.body),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break;t.update&&await p(e,t.update)}}async function Ye(e,t){let r=e.arrays[t.array];if(r)for(let n of Object.keys(r)){if(e.vars[t.variable]=n,e.loopContinue=!1,await L(e,t.body),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break}}async function et(e,t){if(t.type==="array_access"){let r=y(await p(e,t.key));te(e,t.array,r)}else t.type==="variable"&&re(e,t.name)}var _=class{ctx;program=null;rangeStates=[];constructor(t){this.ctx=t}execute(t){this.program=t,this.ctx.output="";for(let r of t.functions)this.ctx.functions.set(r.name,r);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)){T(this.ctx,t),this.ctx.NR++,this.ctx.FNR++,this.ctx.shouldNext=!1;for(let r=0;r<this.program.rules.length&&!(this.ctx.shouldExit||this.ctx.shouldNext||this.ctx.shouldNextFile);r++){let n=this.program.rules[r];n.pattern?.type==="begin"||n.pattern?.type==="end"||await this.matchesRule(n,r)&&await M(this.ctx,n.action.statements)}}}async executeEnd(){if(!(!this.program||this.ctx.shouldExit)){for(let t of this.program.rules)if(t.pattern?.type==="end"&&(await M(this.ctx,t.action.statements),this.ctx.shouldExit))break}}getOutput(){return this.ctx.output}getExitCode(){return this.ctx.exitCode}getContext(){return this.ctx}async matchesRule(t,r){let n=t.pattern;if(!n)return!0;switch(n.type){case"begin":case"end":return!1;case"regex_pattern":return F(n.pattern,this.ctx.line);case"expr_pattern":return S(await p(this.ctx,n.expression));case"range":{let a=await this.matchPattern(n.start),s=await this.matchPattern(n.end);return this.rangeStates[r]?(s&&(this.rangeStates[r]=!1),!0):a?(this.rangeStates[r]=!0,s&&(this.rangeStates[r]=!1),!0):!1}default:return!1}}async matchPattern(t){switch(t.type){case"regex_pattern":return F(t.pattern,this.ctx.line);case"expr_pattern":return S(await p(this.ctx,t.expression));default:return!1}}};var i;(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"})(i||(i={}));var tt={BEGIN:i.BEGIN,END:i.END,if:i.IF,else:i.ELSE,while:i.WHILE,do:i.DO,for:i.FOR,in:i.IN,break:i.BREAK,continue:i.CONTINUE,next:i.NEXT,nextfile:i.NEXTFILE,exit:i.EXIT,return:i.RETURN,delete:i.DELETE,function:i.FUNCTION,print:i.PRINT,printf:i.PRINTF,getline:i.GETLINE};function rt(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 D=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 r=this.nextToken();r&&(t.push(r),this.lastTokenType=r.type)}return t.push(this.makeToken(i.EOF,"")),t}makeToken(t,r){return{type:t,value:r,line:this.line,column:this.column}}peek(t=0){return this.input[this.pos+t]||""}advance(){let t=this.input[this.pos++]||"";return t===`
7
- `?(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)===`
8
- `)this.advance(),this.advance();else break;else if(t==="#")for(;this.pos<this.input.length&&this.peek()!==`
9
- `;)this.advance();else break}}nextToken(){if(this.skipWhitespace(),this.pos>=this.input.length)return null;let t=this.line,r=this.column,n=this.peek();return n===`
10
- `?(this.advance(),{type:i.NEWLINE,value:`
11
- `,line:t,column:r}):n==='"'?this.readString():n==="/"&&this.canBeRegex()?this.readRegex():this.isDigit(n)||n==="."&&this.isDigit(this.peek(1))?this.readNumber():this.isAlpha(n)||n==="_"?this.readIdentifier():this.readOperator()}canBeRegex(){return new Set([null,i.NEWLINE,i.SEMICOLON,i.LBRACE,i.RBRACE,i.LPAREN,i.LBRACKET,i.COMMA,i.ASSIGN,i.PLUS_ASSIGN,i.MINUS_ASSIGN,i.STAR_ASSIGN,i.SLASH_ASSIGN,i.PERCENT_ASSIGN,i.CARET_ASSIGN,i.AND,i.OR,i.NOT,i.MATCH,i.NOT_MATCH,i.QUESTION,i.COLON,i.LT,i.GT,i.LE,i.GE,i.EQ,i.NE,i.PLUS,i.MINUS,i.STAR,i.PERCENT,i.CARET,i.PRINT,i.PRINTF,i.IF,i.WHILE,i.DO,i.FOR,i.RETURN]).has(this.lastTokenType)}readString(){let t=this.line,r=this.column;this.advance();let n="";for(;this.pos<this.input.length&&this.peek()!=='"';)if(this.peek()==="\\"){this.advance();let a=this.advance();switch(a){case"n":n+=`
12
- `;break;case"t":n+=" ";break;case"r":n+="\r";break;case"\\":n+="\\";break;case'"':n+='"';break;case"/":n+="/";break;default:n+=a}}else n+=this.advance();return this.peek()==='"'&&this.advance(),{type:i.STRING,value:n,line:t,column:r}}readRegex(){let t=this.line,r=this.column;this.advance();let n="";for(;this.pos<this.input.length&&this.peek()!=="/";)if(this.peek()==="\\")n+=this.advance(),this.pos<this.input.length&&(n+=this.advance());else{if(this.peek()===`
13
- `)break;n+=this.advance()}return this.peek()==="/"&&this.advance(),n=rt(n),{type:i.REGEX,value:n,line:t,column:r}}readNumber(){let t=this.line,r=this.column,n="";for(;this.isDigit(this.peek());)n+=this.advance();if(this.peek()==="."&&this.isDigit(this.peek(1)))for(n+=this.advance();this.isDigit(this.peek());)n+=this.advance();if(this.peek()==="e"||this.peek()==="E")for(n+=this.advance(),(this.peek()==="+"||this.peek()==="-")&&(n+=this.advance());this.isDigit(this.peek());)n+=this.advance();return{type:i.NUMBER,value:parseFloat(n),line:t,column:r}}readIdentifier(){let t=this.line,r=this.column,n="";for(;this.isAlphaNumeric(this.peek())||this.peek()==="_";)n+=this.advance();let a=tt[n];return a?{type:a,value:n,line:t,column:r}:{type:i.IDENT,value:n,line:t,column:r}}readOperator(){let t=this.line,r=this.column,n=this.advance(),a=this.peek();switch(n){case"+":return a==="+"?(this.advance(),{type:i.INCREMENT,value:"++",line:t,column:r}):a==="="?(this.advance(),{type:i.PLUS_ASSIGN,value:"+=",line:t,column:r}):{type:i.PLUS,value:"+",line:t,column:r};case"-":return a==="-"?(this.advance(),{type:i.DECREMENT,value:"--",line:t,column:r}):a==="="?(this.advance(),{type:i.MINUS_ASSIGN,value:"-=",line:t,column:r}):{type:i.MINUS,value:"-",line:t,column:r};case"*":return a==="*"?(this.advance(),{type:i.CARET,value:"**",line:t,column:r}):a==="="?(this.advance(),{type:i.STAR_ASSIGN,value:"*=",line:t,column:r}):{type:i.STAR,value:"*",line:t,column:r};case"/":return a==="="?(this.advance(),{type:i.SLASH_ASSIGN,value:"/=",line:t,column:r}):{type:i.SLASH,value:"/",line:t,column:r};case"%":return a==="="?(this.advance(),{type:i.PERCENT_ASSIGN,value:"%=",line:t,column:r}):{type:i.PERCENT,value:"%",line:t,column:r};case"^":return a==="="?(this.advance(),{type:i.CARET_ASSIGN,value:"^=",line:t,column:r}):{type:i.CARET,value:"^",line:t,column:r};case"=":return a==="="?(this.advance(),{type:i.EQ,value:"==",line:t,column:r}):{type:i.ASSIGN,value:"=",line:t,column:r};case"!":return a==="="?(this.advance(),{type:i.NE,value:"!=",line:t,column:r}):a==="~"?(this.advance(),{type:i.NOT_MATCH,value:"!~",line:t,column:r}):{type:i.NOT,value:"!",line:t,column:r};case"<":return a==="="?(this.advance(),{type:i.LE,value:"<=",line:t,column:r}):{type:i.LT,value:"<",line:t,column:r};case">":return a==="="?(this.advance(),{type:i.GE,value:">=",line:t,column:r}):a===">"?(this.advance(),{type:i.APPEND,value:">>",line:t,column:r}):{type:i.GT,value:">",line:t,column:r};case"&":return a==="&"?(this.advance(),{type:i.AND,value:"&&",line:t,column:r}):{type:i.IDENT,value:"&",line:t,column:r};case"|":return a==="|"?(this.advance(),{type:i.OR,value:"||",line:t,column:r}):{type:i.PIPE,value:"|",line:t,column:r};case"~":return{type:i.MATCH,value:"~",line:t,column:r};case"?":return{type:i.QUESTION,value:"?",line:t,column:r};case":":return{type:i.COLON,value:":",line:t,column:r};case",":return{type:i.COMMA,value:",",line:t,column:r};case";":return{type:i.SEMICOLON,value:";",line:t,column:r};case"(":return{type:i.LPAREN,value:"(",line:t,column:r};case")":return{type:i.RPAREN,value:")",line:t,column:r};case"{":return{type:i.LBRACE,value:"{",line:t,column:r};case"}":return{type:i.RBRACE,value:"}",line:t,column:r};case"[":return{type:i.LBRACKET,value:"[",line:t,column:r};case"]":return{type:i.RBRACKET,value:"]",line:t,column:r};case"$":return{type:i.DOLLAR,value:"$",line:t,column:r};default:return{type:i.IDENT,value:n,line:t,column:r}}}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 B=class{tokens=[];pos=0;parse(t){let r=new D(t);return this.tokens=r.tokenize(),this.pos=0,this.parseProgram()}current(){return this.tokens[this.pos]||{type:i.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,r){if(!this.check(t)){let n=this.current();throw new Error(r||`Expected ${t}, got ${n.type} at line ${n.line}:${n.column}`)}return this.advance()}skipNewlines(){for(;this.check(i.NEWLINE);)this.advance()}skipTerminators(){for(;this.check(i.NEWLINE)||this.check(i.SEMICOLON);)this.advance()}parseProgram(){let t=[],r=[];for(this.skipNewlines();!this.check(i.EOF)&&(this.skipNewlines(),!this.check(i.EOF));)this.check(i.FUNCTION)?t.push(this.parseFunction()):r.push(this.parseRule()),this.skipTerminators();return{functions:t,rules:r}}parseFunction(){this.expect(i.FUNCTION);let t=this.expect(i.IDENT).value;this.expect(i.LPAREN);let r=[];if(!this.check(i.RPAREN))for(r.push(this.expect(i.IDENT).value);this.check(i.COMMA);)this.advance(),r.push(this.expect(i.IDENT).value);this.expect(i.RPAREN),this.skipNewlines();let n=this.parseBlock();return{name:t,params:r,body:n}}parseRule(){let t;if(this.check(i.BEGIN))this.advance(),t={type:"begin"};else if(this.check(i.END))this.advance(),t={type:"end"};else if(this.check(i.LBRACE))t=void 0;else if(this.check(i.REGEX)){let n=this.advance();if(this.check(i.AND)||this.check(i.OR)){let a={type:"binary",operator:"~",left:{type:"field",index:{type:"number",value:0}},right:{type:"regex",pattern:n.value}};t={type:"expr_pattern",expression:this.parseLogicalOrRest(a)}}else{let a={type:"regex_pattern",pattern:n.value};if(this.check(i.COMMA)){this.advance();let s;this.check(i.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(i.COMMA)){this.advance();let s;this.check(i.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 r;return this.check(i.LBRACE)?r=this.parseBlock():r={type:"block",statements:[{type:"print",args:[{type:"field",index:{type:"number",value:0}}]}]},{pattern:t,action:r}}parseBlock(){this.expect(i.LBRACE),this.skipNewlines();let t=[];for(;!this.check(i.RBRACE)&&!this.check(i.EOF);)t.push(this.parseStatement()),this.skipTerminators();return this.expect(i.RBRACE),{type:"block",statements:t}}parseStatement(){if(this.check(i.LBRACE))return this.parseBlock();if(this.check(i.IF))return this.parseIf();if(this.check(i.WHILE))return this.parseWhile();if(this.check(i.DO))return this.parseDoWhile();if(this.check(i.FOR))return this.parseFor();if(this.check(i.BREAK))return this.advance(),{type:"break"};if(this.check(i.CONTINUE))return this.advance(),{type:"continue"};if(this.check(i.NEXT))return this.advance(),{type:"next"};if(this.check(i.NEXTFILE))return this.advance(),{type:"nextfile"};if(this.check(i.EXIT)){this.advance();let r;return!this.check(i.NEWLINE)&&!this.check(i.SEMICOLON)&&!this.check(i.RBRACE)&&!this.check(i.EOF)&&(r=this.parseExpression()),{type:"exit",code:r}}if(this.check(i.RETURN)){this.advance();let r;return!this.check(i.NEWLINE)&&!this.check(i.SEMICOLON)&&!this.check(i.RBRACE)&&!this.check(i.EOF)&&(r=this.parseExpression()),{type:"return",value:r}}if(this.check(i.DELETE)){this.advance();let r=this.parsePrimary();if(r.type!=="array_access"&&r.type!=="variable")throw new Error("delete requires array element or array");return{type:"delete",target:r}}return this.check(i.PRINT)?this.parsePrint():this.check(i.PRINTF)?this.parsePrintf():{type:"expr_stmt",expression:this.parseExpression()}}parseIf(){this.expect(i.IF),this.expect(i.LPAREN);let t=this.parseExpression();this.expect(i.RPAREN),this.skipNewlines();let r=this.parseStatement();this.skipTerminators();let n;return this.check(i.ELSE)&&(this.advance(),this.skipNewlines(),n=this.parseStatement()),{type:"if",condition:t,consequent:r,alternate:n}}parseWhile(){this.expect(i.WHILE),this.expect(i.LPAREN);let t=this.parseExpression();this.expect(i.RPAREN),this.skipNewlines();let r=this.parseStatement();return{type:"while",condition:t,body:r}}parseDoWhile(){this.expect(i.DO),this.skipNewlines();let t=this.parseStatement();this.skipNewlines(),this.expect(i.WHILE),this.expect(i.LPAREN);let r=this.parseExpression();return this.expect(i.RPAREN),{type:"do_while",body:t,condition:r}}parseFor(){if(this.expect(i.FOR),this.expect(i.LPAREN),this.check(i.IDENT)){let s=this.advance();if(this.check(i.IN)){this.advance();let o=this.expect(i.IDENT).value;this.expect(i.RPAREN),this.skipNewlines();let l=this.parseStatement();return{type:"for_in",variable:s.value,array:o,body:l}}this.pos--}let t;this.check(i.SEMICOLON)||(t=this.parseExpression()),this.expect(i.SEMICOLON);let r;this.check(i.SEMICOLON)||(r=this.parseExpression()),this.expect(i.SEMICOLON);let n;this.check(i.RPAREN)||(n=this.parseExpression()),this.expect(i.RPAREN),this.skipNewlines();let a=this.parseStatement();return{type:"for",init:t,condition:r,update:n,body:a}}parsePrint(){this.expect(i.PRINT);let t=[];if(this.check(i.NEWLINE)||this.check(i.SEMICOLON)||this.check(i.RBRACE)||this.check(i.PIPE)||this.check(i.GT)||this.check(i.APPEND))t.push({type:"field",index:{type:"number",value:0}});else for(t.push(this.parsePrintArg());this.check(i.COMMA);)this.advance(),t.push(this.parsePrintArg());let r;return this.check(i.GT)?(this.advance(),r={redirect:">",file:this.parsePrimary()}):this.check(i.APPEND)&&(this.advance(),r={redirect:">>",file:this.parsePrimary()}),{type:"print",args:t,output:r}}parsePrintArg(){return this.lookAheadForTernary()?this.parseTernary():this.parsePrintOr()}lookAheadForTernary(){let t=0,r=this.pos;for(;r<this.tokens.length;){let n=this.tokens[r];if(n.type===i.LPAREN&&t++,n.type===i.RPAREN&&t--,n.type===i.QUESTION&&t===0)return!0;if(n.type===i.NEWLINE||n.type===i.SEMICOLON||n.type===i.RBRACE||n.type===i.COMMA||n.type===i.PIPE)return!1;r++}return!1}parsePrintOr(){let t=this.parsePrintAnd();for(;this.check(i.OR);){this.advance();let r=this.parsePrintAnd();t={type:"binary",operator:"||",left:t,right:r}}return t}parsePrintAnd(){let t=this.parsePrintIn();for(;this.check(i.AND);){this.advance();let r=this.parsePrintIn();t={type:"binary",operator:"&&",left:t,right:r}}return t}parsePrintIn(){let t=this.parsePrintMatch();if(this.check(i.IN)){this.advance();let r=String(this.expect(i.IDENT).value);return{type:"in",key:t,array:r}}return t}parsePrintMatch(){let t=this.parsePrintComparison();for(;this.match(i.MATCH,i.NOT_MATCH);){let r=this.advance().type===i.MATCH?"~":"!~",n=this.parsePrintComparison();t={type:"binary",operator:r,left:t,right:n}}return t}parsePrintComparison(){let t=this.parseConcatenation();for(;this.match(i.LT,i.LE,i.GE,i.EQ,i.NE);){let r=this.advance(),n=this.parseConcatenation();t={type:"binary",operator:{"<":"<","<=":"<=",">=":">=","==":"==","!=":"!="}[r.value],left:t,right:n}}return t}parsePrintf(){this.expect(i.PRINTF);let t=this.parsePrintArg(),r=[];for(;this.check(i.COMMA);)this.advance(),r.push(this.parsePrintArg());let n;return this.check(i.GT)?(this.advance(),n={redirect:">",file:this.parsePrimary()}):this.check(i.APPEND)&&(this.advance(),n={redirect:">>",file:this.parsePrimary()}),{type:"printf",format:t,args:r,output:n}}parseExpression(){return this.parseAssignment()}parseAssignment(){let t=this.parseTernary();if(this.match(i.ASSIGN,i.PLUS_ASSIGN,i.MINUS_ASSIGN,i.STAR_ASSIGN,i.SLASH_ASSIGN,i.PERCENT_ASSIGN,i.CARET_ASSIGN)){let r=this.advance(),n=this.parseAssignment();if(t.type!=="variable"&&t.type!=="field"&&t.type!=="array_access")throw new Error("Invalid assignment target");return{type:"assignment",operator:{"=":"=","+=":"+=","-=":"-=","*=":"*=","/=":"/=","%=":"%=","^=":"^="}[r.value],target:t,value:n}}return t}parseTernary(){let t=this.parseOr();if(this.check(i.QUESTION)){this.advance();let r=this.parseExpression();this.expect(i.COLON);let n=this.parseExpression();t={type:"ternary",condition:t,consequent:r,alternate:n}}return t}parseOr(){let t=this.parseAnd();for(;this.check(i.OR);){this.advance();let r=this.parseAnd();t={type:"binary",operator:"||",left:t,right:r}}return t}parseLogicalOrRest(t){for(t=this.parseLogicalAndRest(t);this.check(i.OR);){this.advance();let r=this.parseAnd();t={type:"binary",operator:"||",left:t,right:r}}return t}parseLogicalAndRest(t){for(;this.check(i.AND);){this.advance();let r=this.parseIn();t={type:"binary",operator:"&&",left:t,right:r}}return t}parseAnd(){let t=this.parseIn();for(;this.check(i.AND);){this.advance();let r=this.parseIn();t={type:"binary",operator:"&&",left:t,right:r}}return t}parseIn(){let t=this.parseMatch();if(this.check(i.IN)){this.advance();let r=this.expect(i.IDENT).value;return{type:"in",key:t,array:r}}return t}parseMatch(){let t=this.parseComparison();for(;this.match(i.MATCH,i.NOT_MATCH);){let r=this.advance().type===i.MATCH?"~":"!~",n=this.parseComparison();t={type:"binary",operator:r,left:t,right:n}}return t}parseComparison(){let t=this.parseConcatenation();for(;this.match(i.LT,i.LE,i.GT,i.GE,i.EQ,i.NE);){let r=this.advance(),n=this.parseConcatenation();t={type:"binary",operator:{"<":"<","<=":"<=",">":">",">=":">=","==":"==","!=":"!="}[r.value],left:t,right:n}}return t}parseConcatenation(){let t=this.parseAddSub();for(;this.canStartExpression()&&!this.isComparisonOrHigherOp();){let r=this.parseAddSub();t={type:"binary",operator:" ",left:t,right:r}}return t}canStartExpression(){return this.match(i.NUMBER,i.STRING,i.IDENT,i.DOLLAR,i.LPAREN,i.NOT,i.MINUS,i.PLUS,i.INCREMENT,i.DECREMENT)}isComparisonOrHigherOp(){return this.match(i.LT,i.LE,i.GT,i.GE,i.EQ,i.NE,i.AND,i.OR,i.QUESTION,i.MATCH,i.NOT_MATCH,i.ASSIGN,i.PLUS_ASSIGN,i.MINUS_ASSIGN,i.STAR_ASSIGN,i.SLASH_ASSIGN,i.PERCENT_ASSIGN,i.CARET_ASSIGN,i.COMMA,i.SEMICOLON,i.NEWLINE,i.RBRACE,i.RPAREN,i.RBRACKET,i.COLON,i.PIPE,i.APPEND,i.IN)}parseAddSub(){let t=this.parseMulDiv();for(;this.match(i.PLUS,i.MINUS);){let r=this.advance().value,n=this.parseMulDiv();t={type:"binary",operator:r,left:t,right:n}}return t}parseMulDiv(){let t=this.parseUnary();for(;this.match(i.STAR,i.SLASH,i.PERCENT);){let r=this.advance(),n=this.parseUnary();t={type:"binary",operator:{"*":"*","/":"/","%":"%"}[r.value],left:t,right:n}}return t}parseUnary(){if(this.check(i.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(i.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(i.NOT,i.MINUS,i.PLUS)){let t=this.advance().value,r=this.parseUnary();return{type:"unary",operator:t,operand:r}}return this.parsePower()}parsePower(){let t=this.parsePostfix();if(this.check(i.CARET)){this.advance();let r=this.parsePower();t={type:"binary",operator:"^",left:t,right:r}}return t}parsePostfix(){let t=this.parsePrimary();if(this.check(i.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(i.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}parsePrimary(){if(this.check(i.NUMBER))return{type:"number",value:this.advance().value};if(this.check(i.STRING))return{type:"string",value:this.advance().value};if(this.check(i.REGEX))return{type:"regex",pattern:this.advance().value};if(this.check(i.DOLLAR))return this.advance(),{type:"field",index:this.parsePrimary()};if(this.check(i.LPAREN)){this.advance();let t=this.parseExpression();if(this.check(i.COMMA)){let r=[t];for(;this.check(i.COMMA);)this.advance(),r.push(this.parseExpression());return this.expect(i.RPAREN),{type:"tuple",elements:r}}return this.expect(i.RPAREN),t}if(this.check(i.GETLINE)){this.advance();let t,r;return this.check(i.IDENT)&&(t=this.advance().value),this.check(i.LT)&&(this.advance(),r=this.parsePrimary()),{type:"getline",variable:t,file:r}}if(this.check(i.IDENT)){let t=this.advance().value;if(this.check(i.LPAREN)){this.advance();let r=[];if(!this.check(i.RPAREN))for(r.push(this.parseExpression());this.check(i.COMMA);)this.advance(),r.push(this.parseExpression());return this.expect(i.RPAREN),{type:"call",name:t,args:r}}if(this.check(i.LBRACKET)){this.advance();let r=[this.parseExpression()];for(;this.check(i.COMMA);)this.advance(),r.push(this.parseExpression());this.expect(i.RBRACKET);let n;if(r.length===1)n=r[0];else{n=r[0];for(let a=1;a<r.length;a++)n={type:"binary",operator:" ",left:{type:"binary",operator:" ",left:n,right:{type:"variable",name:"SUBSEP"}},right:r[a]}}return{type:"array_access",array:t,key:n}}return{type:"variable",name:t}}throw new Error(`Unexpected token: ${this.current().type} at line ${this.current().line}:${this.current().column}`)}};var it={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"]},Ht={name:"awk",async execute(e,t){if(Q(e))return K(it);let r=/\s+/,n=" ",a={},s=0;for(let h=0;h<e.length;h++){let f=e[h];if(f==="-F"&&h+1<e.length)n=se(e[++h]),r=ae(n),s=h+1;else if(f.startsWith("-F"))n=se(f.slice(2)),r=ae(n),s=h+1;else if(f==="-v"&&h+1<e.length){let R=e[++h],G=R.indexOf("=");if(G>0){let k=R.slice(0,G),oe=R.slice(G+1);a[k]=oe}s=h+1}else{if(f.startsWith("--"))return U("awk",f);if(f.startsWith("-")&&f.length>1){let R=f[1];if(R!=="F"&&R!=="v")return U("awk",`-${R}`);s=h+1}else if(!f.startsWith("-")){s=h;break}}}if(s>=e.length)return{stdout:"",stderr:`awk: missing program
14
- `,exitCode:1};let o=e[s],l=e.slice(s+1),u=new B,m;try{m=u.parse(o)}catch(h){return{stdout:"",stderr:`awk: ${h instanceof Error?h.message:String(h)}
15
- `,exitCode:1}}let N={readFile:t.fs.readFile.bind(t.fs),writeFile:t.fs.writeFile.bind(t.fs),appendFile:async(h,f)=>{try{let R=await t.fs.readFile(h);await t.fs.writeFile(h,R+f)}catch{await t.fs.writeFile(h,f)}},resolvePath:t.fs.resolvePath.bind(t.fs)},c=x({fieldSep:r,maxIterations:t.limits?.maxAwkIterations,fs:N,cwd:t.cwd});c.FS=n,c.vars={...a},c.ARGC=l.length+1,c.ARGV={0:"awk"};for(let h=0;h<l.length;h++)c.ARGV[String(h+1)]=l[h];let d=new _(c);d.execute(m);try{if(await d.executeBegin(),c.shouldExit)return{stdout:d.getOutput(),stderr:"",exitCode:d.getExitCode()};let h=[];if(l.length>0)for(let f of l)try{let R=t.fs.resolvePath(t.cwd,f),k=(await t.fs.readFile(R)).split(`
16
- `);k.length>0&&k[k.length-1]===""&&k.pop(),h.push({filename:f,lines:k})}catch{return{stdout:"",stderr:`awk: ${f}: No such file or directory
17
- `,exitCode:1}}else{let f=t.stdin.split(`
18
- `);f.length>0&&f[f.length-1]===""&&f.pop(),h.push({filename:"",lines:f})}for(let f of h){for(c.FILENAME=f.filename,c.FNR=0,c.lines=f.lines,c.lineIndex=-1,c.shouldNextFile=!1;c.lineIndex<f.lines.length-1&&(c.lineIndex++,await d.executeLine(f.lines[c.lineIndex]),!(c.shouldExit||c.shouldNextFile)););if(c.shouldExit)break}return c.shouldExit||await d.executeEnd(),{stdout:d.getOutput(),stderr:"",exitCode:d.getExitCode()}}catch(h){let f=h instanceof Error?h.message:String(h),R=h instanceof g?g.EXIT_CODE:2;return{stdout:d.getOutput(),stderr:`awk: ${f}
19
- `,exitCode:R}}}};function se(e){return e.replace(/\\t/g," ").replace(/\\n/g,`
20
- `).replace(/\\r/g,"\r").replace(/\\\\/g,"\\")}function ae(e){if(e===" ")return/\s+/;if(/[[\](){}.*+?^$|\\]/.test(e))try{return new RegExp(e)}catch{return new RegExp(le(e))}return new RegExp(le(e))}function le(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}export{Ht as awkCommand2};
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env node
2
- import{a as l,b as d}from"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";var m={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).']},b={name:"bash",async execute(t,e){if(d(t))return l(m);if(t[0]==="-c"&&t.length>=2){let o=t[1],s=t[2]||"bash",i=t.slice(3);return h(o,s,i,e)}if(t.length===0)return{stdout:"",stderr:"",exitCode:0};let n=t[0],c=t.slice(1);try{let o=e.fs.resolvePath(e.cwd,n),s=await e.fs.readFile(o);return h(s,n,c,e)}catch{return{stdout:"",stderr:`bash: ${n}: No such file or directory
3
- `,exitCode:127}}}},w={name:"sh",async execute(t,e){if(d(t))return l({...m,name:"sh",summary:"execute shell commands or scripts (POSIX shell)"});if(t[0]==="-c"&&t.length>=2){let o=t[1],s=t[2]||"sh",i=t.slice(3);return h(o,s,i,e)}if(t.length===0)return{stdout:"",stderr:"",exitCode:0};let n=t[0],c=t.slice(1);try{let o=e.fs.resolvePath(e.cwd,n),s=await e.fs.readFile(o);return h(s,n,c,e)}catch{return{stdout:"",stderr:`sh: ${n}: No such file or directory
4
- `,exitCode:127}}}};async function h(t,e,n,c){if(!c.exec)return{stdout:"",stderr:`bash: internal error: exec function not available
5
- `,exitCode:1};let o={0:e,"#":String(n.length),"@":n.join(" "),"*":n.join(" ")};n.forEach((r,a)=>{o[String(a+1)]=r});let s=t;if(s.startsWith("#!")){let r=s.indexOf(`
6
- `);r!==-1&&(s=s.slice(r+1))}let i=s.split(`
7
- `),u=[];for(let r of i){let a=r.trim();a&&!a.startsWith("#")&&u.push(a)}let f=u.join("; ");return await c.exec(f,{env:o,cwd:c.cwd})}export{b as bashCommand,w as shCommand};
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env node
2
- import{a as h,b as m}from"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";var v={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"]},C={name:"chmod",async execute(o,s){if(m(o))return h(v);if(o.length<2)return{stdout:"",stderr:`chmod: missing operand
3
- `,exitCode:1};let r=!1,n=!1,e=0;for(;e<o.length&&o[e].startsWith("-");){let t=o[e];if(t==="-R"||t==="--recursive")r=!0,e++;else if(t==="-v"||t==="--verbose")n=!0,e++;else if(t==="--"){e++;break}else{if(/^[+-]?[rwxugo]+/.test(t)||/^\d+$/.test(t))break;if(/^-[Rv]+$/.test(t)){t.includes("R")&&(r=!0),t.includes("v")&&(n=!0),e++;continue}return{stdout:"",stderr:`chmod: invalid option -- '${t.slice(1)}'
4
- `,exitCode:1}}}if(o.length-e<2)return{stdout:"",stderr:`chmod: missing operand
5
- `,exitCode:1};let a=o[e],f=o.slice(e+1),i;try{i=$(a)}catch{return{stdout:"",stderr:`chmod: invalid mode: '${a}'
6
- `,exitCode:1}}let c="",d="",l=!1;for(let t of f){let u=s.fs.resolvePath(s.cwd,t);try{if(await s.fs.chmod(u,i),n&&(c+=`mode of '${t}' changed to ${i.toString(8).padStart(4,"0")}
7
- `),r&&(await s.fs.stat(u)).isDirectory){let w=await p(s,u,i,n);c+=w}}catch{d+=`chmod: cannot access '${t}': No such file or directory
8
- `,l=!0}}return{stdout:c,stderr:d,exitCode:l?1:0}}};async function p(o,s,r,n){let e="",a=await o.fs.readdir(s);for(let f of a){let i=s==="/"?`/${f}`:`${s}/${f}`;await o.fs.chmod(i,r),n&&(e+=`mode of '${i}' changed to ${r.toString(8).padStart(4,"0")}
9
- `),(await o.fs.stat(i)).isDirectory&&(e+=await p(o,i,r,n))}return e}function $(o){if(/^[0-7]+$/.test(o))return parseInt(o,8);let s=420,r=o.split(",");for(let n of r){let e=n.match(/^([ugoa]*)([+\-=])([rwxXst]*)$/);if(!e)throw new Error(`Invalid mode: ${o}`);let a=e[1]||"a",f=e[2],i=e[3];(a==="a"||a==="")&&(a="ugo");let c=0;i.includes("r")&&(c|=4),i.includes("w")&&(c|=2),(i.includes("x")||i.includes("X"))&&(c|=1);for(let d of a){let l=0;d==="u"?l=6:d==="g"?l=3:d==="o"&&(l=0);let t=c<<l;f==="+"?s|=t:f==="-"?s&=~t:f==="="&&(s&=~(7<<l),s|=t)}}return s}export{C as chmodCommand};