just-binary 3.2.5 → 3.3.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 (1049) hide show
  1. package/README.md +1 -1
  2. package/dist/Bash.d.ts +56 -1
  3. package/dist/bin/chunks/alias-MILMQPGR.js +2 -0
  4. package/dist/bin/chunks/awk2-FB5MXVFV.js +2 -0
  5. package/dist/bin/chunks/base64-NGAPXZAM.js +2 -0
  6. package/dist/bin/chunks/basename-ZFBDKUVW.js +2 -0
  7. package/dist/bin/chunks/bash-FQY3C37R.js +2 -0
  8. package/dist/bin/chunks/cat-UO3ZDQHP.js +2 -0
  9. package/dist/bin/chunks/chmod-GYXHDITN.js +2 -0
  10. package/dist/bin/chunks/chunk-2FWUPGJH.js +6 -0
  11. package/dist/bin/chunks/chunk-2JQKBSIH.js +14 -0
  12. package/dist/bin/chunks/chunk-2MX7URRE.js +10 -0
  13. package/dist/bin/chunks/chunk-3G7ONQFJ.js +11 -0
  14. package/dist/bin/chunks/chunk-3KKXX5QY.js +13 -0
  15. package/dist/bin/chunks/chunk-3SWITKTS.js +7 -0
  16. package/dist/bin/chunks/chunk-3V7N5SEN.js +9 -0
  17. package/dist/bin/chunks/chunk-45S6IACR.js +3 -0
  18. package/dist/bin/chunks/chunk-4PDI7A54.js +20 -0
  19. package/dist/bin/chunks/chunk-532RLOPK.js +14 -0
  20. package/dist/bin/chunks/chunk-5B4HIQFQ.js +7 -0
  21. package/dist/bin/chunks/chunk-5CTS5L3T.js +18 -0
  22. package/dist/bin/chunks/chunk-5RANCCE2.js +6 -0
  23. package/dist/bin/chunks/chunk-63FHXCEF.js +4 -0
  24. package/dist/bin/chunks/chunk-64ICY43M.js +8 -0
  25. package/dist/bin/chunks/chunk-6MJ6NBIG.js +8 -0
  26. package/dist/bin/chunks/chunk-6N6IRP6G.js +6 -0
  27. package/dist/bin/chunks/chunk-6VQWCKYE.js +2 -0
  28. package/dist/bin/chunks/chunk-6WKRPHAZ.js +36 -0
  29. package/dist/bin/chunks/chunk-73X3QWRT.js +80 -0
  30. package/dist/bin/chunks/chunk-7FCHB2LT.js +14 -0
  31. package/dist/bin/chunks/chunk-7FGPQVVJ.js +12 -0
  32. package/dist/bin/chunks/chunk-7FUCLMNU.js +7 -0
  33. package/dist/bin/chunks/chunk-7LGOLTRR.js +5 -0
  34. package/dist/bin/chunks/chunk-7POGKC42.js +11 -0
  35. package/dist/bin/chunks/chunk-A257OMG4.js +2 -0
  36. package/dist/bin/chunks/chunk-BH4O34VZ.js +26 -0
  37. package/dist/bin/chunks/chunk-BTCJZ7OY.js +10 -0
  38. package/dist/bin/chunks/chunk-CEU7KGBV.js +24 -0
  39. package/dist/bin/chunks/chunk-COM2NIBS.js +3 -0
  40. package/dist/bin/chunks/chunk-CXEBUGVP.js +7 -0
  41. package/dist/bin/chunks/chunk-CY4RP66Q.js +21 -0
  42. package/dist/bin/chunks/chunk-DM55Q4EM.js +5 -0
  43. package/dist/bin/chunks/chunk-DUBCYODB.js +11 -0
  44. package/dist/bin/chunks/chunk-DUPNDZ3H.js +6 -0
  45. package/dist/bin/chunks/chunk-EKD22SYR.js +23 -0
  46. package/dist/bin/chunks/chunk-EOMAF5KQ.js +6 -0
  47. package/dist/bin/chunks/chunk-EQOXJHK3.js +2 -0
  48. package/dist/bin/chunks/chunk-EYZ62W3A.js +8 -0
  49. package/dist/bin/chunks/chunk-FHWRQZ3L.js +9 -0
  50. package/dist/bin/chunks/chunk-FUPQF256.js +10 -0
  51. package/dist/bin/chunks/chunk-GNVKOWAD.js +7 -0
  52. package/dist/bin/chunks/chunk-GZGWA6JM.js +3 -0
  53. package/dist/bin/chunks/chunk-HMHPYX5K.js +9 -0
  54. package/dist/bin/chunks/chunk-IA7QY73Z.js +9 -0
  55. package/dist/bin/chunks/chunk-J7ARATA6.js +4 -0
  56. package/dist/bin/chunks/chunk-JGKR7YR7.js +2 -0
  57. package/dist/bin/chunks/chunk-JILAHEMU.js +2 -0
  58. package/dist/bin/chunks/chunk-JKVUWQVK.js +12 -0
  59. package/dist/bin/chunks/chunk-JVUFZWPW.js +3 -0
  60. package/dist/bin/chunks/chunk-JYZZJOWW.js +2 -0
  61. package/dist/bin/chunks/chunk-KSXVXC3N.js +2 -0
  62. package/dist/bin/chunks/chunk-KTGY5SRV.js +2 -0
  63. package/dist/bin/chunks/chunk-KTZIEG4R.js +13 -0
  64. package/dist/bin/chunks/chunk-LNAXROAQ.js +5 -0
  65. package/dist/bin/chunks/chunk-LV3CC7SU.js +7 -0
  66. package/dist/bin/chunks/chunk-LVWII44I.js +23 -0
  67. package/dist/bin/chunks/chunk-LZC6DGAO.js +8 -0
  68. package/dist/bin/chunks/chunk-M3JG3HYB.js +14 -0
  69. package/dist/bin/chunks/chunk-MJODCFGH.js +140 -0
  70. package/dist/bin/chunks/chunk-MJTA3OJF.js +7 -0
  71. package/dist/bin/chunks/chunk-OF45CXLB.js +2 -0
  72. package/dist/bin/chunks/chunk-PAD6GYRH.js +5 -0
  73. package/dist/bin/chunks/chunk-PJ7H3LY6.js +8 -0
  74. package/dist/bin/chunks/chunk-QD4WQ5KK.js +17 -0
  75. package/dist/bin/chunks/chunk-R2BBWDS3.js +2 -0
  76. package/dist/bin/chunks/chunk-SIDKYUUQ.js +7 -0
  77. package/dist/bin/chunks/chunk-TDOAJ4YU.js +3 -0
  78. package/dist/bin/chunks/chunk-U34CFKX2.js +13 -0
  79. package/dist/bin/chunks/chunk-U7TJRQHK.js +16 -0
  80. package/dist/bin/chunks/chunk-UIRJNX5Z.js +2 -0
  81. package/dist/bin/chunks/chunk-UKL6PNC2.js +63 -0
  82. package/dist/bin/chunks/chunk-UN3P7MOR.js +16 -0
  83. package/dist/bin/chunks/chunk-UQKQCSRP.js +16 -0
  84. package/dist/bin/chunks/chunk-UYAEZFQS.js +100 -0
  85. package/dist/bin/chunks/chunk-V7OGIT4K.js +3 -0
  86. package/dist/bin/chunks/chunk-VK4UPKZF.js +3 -0
  87. package/dist/bin/chunks/chunk-VUUGFF6A.js +9 -0
  88. package/dist/bin/chunks/chunk-WATFCWHB.js +12 -0
  89. package/dist/bin/chunks/chunk-WIJCOCAS.js +9 -0
  90. package/dist/bin/chunks/chunk-XSCMU2VT.js +19 -0
  91. package/dist/bin/chunks/chunk-XWJ3KFMY.js +287 -0
  92. package/dist/bin/chunks/chunk-Y6NUYQQX.js +84 -0
  93. package/dist/bin/chunks/chunk-YLIFZDMR.js +9 -0
  94. package/dist/bin/chunks/chunk-YQFW27YU.js +33 -0
  95. package/dist/bin/chunks/chunk-YXVJUBRG.js +5 -0
  96. package/dist/bin/chunks/chunk-Z6BNZUNQ.js +32 -0
  97. package/dist/bin/chunks/chunk-ZLGIFJBA.js +5 -0
  98. package/dist/bin/chunks/clear-FZZM6QD2.js +2 -0
  99. package/dist/bin/chunks/column-UCIEGSHJ.js +2 -0
  100. package/dist/bin/chunks/comm-WKYJTISA.js +2 -0
  101. package/dist/bin/chunks/cp-YSXTOMBS.js +2 -0
  102. package/dist/bin/chunks/curl-YFYJ2XNC.js +26 -0
  103. package/dist/bin/chunks/cut-2MSOLU4C.js +2 -0
  104. package/dist/bin/chunks/date-5LA42436.js +2 -0
  105. package/dist/bin/chunks/diff-4PEKV4XS.js +2 -0
  106. package/dist/bin/chunks/dirname-XXQNLCA4.js +2 -0
  107. package/dist/bin/chunks/du-IKBAW7PG.js +2 -0
  108. package/dist/bin/chunks/echo-DHVSEP57.js +2 -0
  109. package/dist/bin/chunks/env-A43LGO53.js +2 -0
  110. package/dist/bin/chunks/expand-L4NT2YFK.js +2 -0
  111. package/dist/bin/chunks/expansion-IB7ZIBIF.js +2 -0
  112. package/dist/bin/chunks/expr-BGBONRHV.js +2 -0
  113. package/dist/bin/chunks/file-DZRWWDPH.js +2 -0
  114. package/dist/bin/chunks/find-B6JV4QSG.js +2 -0
  115. package/dist/bin/chunks/flag-coverage-FTS7XXHM.js +2 -0
  116. package/dist/bin/chunks/fold-OVU7UR2E.js +2 -0
  117. package/dist/bin/chunks/grep-RG26XCUN.js +2 -0
  118. package/dist/bin/chunks/gzip-XZZL25AV.js +2 -0
  119. package/dist/bin/chunks/head-HT46A7YT.js +2 -0
  120. package/dist/bin/chunks/help-AOETY73Q.js +2 -0
  121. package/dist/bin/chunks/history-WO6CMWMT.js +2 -0
  122. package/dist/bin/chunks/hostname-4O6NEPL2.js +2 -0
  123. package/dist/bin/chunks/html-to-markdown-34LV4LFQ.js +2 -0
  124. package/dist/bin/chunks/join-6M3ARIFB.js +2 -0
  125. package/dist/bin/chunks/jq-HP7VLWBL.js +2 -0
  126. package/dist/bin/chunks/ln-2OLFXJYU.js +2 -0
  127. package/dist/bin/chunks/ls-LBW3TTPI.js +2 -0
  128. package/dist/bin/chunks/md5sum-GAWU76ZU.js +2 -0
  129. package/dist/bin/chunks/mkdir-UUOVKGHS.js +2 -0
  130. package/dist/bin/chunks/mv-7VY5OVAU.js +2 -0
  131. package/dist/bin/chunks/nl-34JIXDXD.js +2 -0
  132. package/dist/bin/chunks/od-IGVFBAFH.js +2 -0
  133. package/dist/bin/chunks/paste-Q23K6FU7.js +2 -0
  134. package/dist/bin/chunks/printf-CVEJOTYB.js +2 -0
  135. package/dist/bin/chunks/pwd-6OLMY3MQ.js +2 -0
  136. package/dist/bin/chunks/python3-VZL5HRHR.js +14 -0
  137. package/dist/bin/chunks/readlink-T4CDCG4Z.js +2 -0
  138. package/dist/bin/chunks/rev-O3PQMT23.js +2 -0
  139. package/dist/bin/chunks/rg-PQP4HTR3.js +2 -0
  140. package/dist/bin/chunks/rm-UMIY7ESO.js +2 -0
  141. package/dist/bin/chunks/rmdir-NJCSEPRP.js +2 -0
  142. package/dist/bin/chunks/sed-BZW7POX3.js +2 -0
  143. package/dist/bin/chunks/seq-3FRPQG5E.js +2 -0
  144. package/dist/bin/chunks/sha1sum-AOZWHFTU.js +2 -0
  145. package/dist/bin/chunks/sha256sum-EXJTAPU4.js +2 -0
  146. package/dist/bin/chunks/sleep-HDMKKRCV.js +2 -0
  147. package/dist/bin/chunks/sort-TO3IPXI2.js +2 -0
  148. package/dist/bin/chunks/split-JXCUP73P.js +2 -0
  149. package/dist/bin/chunks/sqlite3-K7LHCU76.js +2 -0
  150. package/dist/bin/chunks/stat-J5TUE4U5.js +2 -0
  151. package/dist/bin/chunks/strings-TDUSHGAB.js +2 -0
  152. package/dist/bin/chunks/tac-QXOHN3J4.js +2 -0
  153. package/dist/bin/chunks/tail-LOVA3SKT.js +2 -0
  154. package/dist/bin/chunks/tar-BAKR5OJO.js +2 -0
  155. package/dist/bin/chunks/tee-SREYEKO6.js +2 -0
  156. package/dist/bin/chunks/time-GS6SIFPK.js +2 -0
  157. package/dist/bin/chunks/timeout-XBYZ5LW5.js +2 -0
  158. package/dist/bin/chunks/touch-4ZSEFYEW.js +2 -0
  159. package/dist/bin/chunks/tr-ARR7JBLN.js +2 -0
  160. package/dist/bin/chunks/tree-7Y7H64VI.js +2 -0
  161. package/dist/bin/chunks/true-CKHNKYAT.js +2 -0
  162. package/dist/bin/chunks/unexpand-B4WHWJHL.js +2 -0
  163. package/dist/bin/chunks/uniq-I2KNCRR6.js +2 -0
  164. package/dist/bin/chunks/wc-TDIG4RIU.js +2 -0
  165. package/dist/bin/chunks/which-QMZ276XE.js +2 -0
  166. package/dist/bin/chunks/whoami-XYB47VCX.js +2 -0
  167. package/dist/bin/chunks/xan-STBKXZ5W.js +2 -0
  168. package/dist/bin/chunks/xan-view-BIT4WIPP.js +2 -0
  169. package/dist/bin/chunks/xargs-6K57XYD6.js +2 -0
  170. package/dist/bin/chunks/yes-7ZGUE2PX.js +2 -0
  171. package/dist/bin/chunks/yq-ZHYSTGN3.js +2 -0
  172. package/dist/bin/just-bash.js +320 -303
  173. package/dist/bin/shell/chunks/alias-MILMQPGR.js +2 -0
  174. package/dist/bin/shell/chunks/awk2-FB5MXVFV.js +2 -0
  175. package/dist/bin/shell/chunks/base64-NGAPXZAM.js +2 -0
  176. package/dist/bin/shell/chunks/basename-ZFBDKUVW.js +2 -0
  177. package/dist/bin/shell/chunks/bash-FQY3C37R.js +2 -0
  178. package/dist/bin/shell/chunks/cat-UO3ZDQHP.js +2 -0
  179. package/dist/bin/shell/chunks/chmod-GYXHDITN.js +2 -0
  180. package/dist/bin/shell/chunks/chunk-2FWUPGJH.js +6 -0
  181. package/dist/bin/shell/chunks/chunk-2JQKBSIH.js +14 -0
  182. package/dist/bin/shell/chunks/chunk-2MX7URRE.js +10 -0
  183. package/dist/bin/shell/chunks/chunk-3G7ONQFJ.js +11 -0
  184. package/dist/bin/shell/chunks/chunk-3KKXX5QY.js +13 -0
  185. package/dist/bin/shell/chunks/chunk-3SWITKTS.js +7 -0
  186. package/dist/bin/shell/chunks/chunk-3V7N5SEN.js +9 -0
  187. package/dist/bin/shell/chunks/chunk-45S6IACR.js +3 -0
  188. package/dist/bin/shell/chunks/chunk-4PDI7A54.js +20 -0
  189. package/dist/bin/shell/chunks/chunk-532RLOPK.js +14 -0
  190. package/dist/bin/shell/chunks/chunk-5B4HIQFQ.js +7 -0
  191. package/dist/bin/shell/chunks/chunk-5CTS5L3T.js +18 -0
  192. package/dist/bin/shell/chunks/chunk-5RANCCE2.js +6 -0
  193. package/dist/bin/shell/chunks/chunk-63FHXCEF.js +4 -0
  194. package/dist/bin/shell/chunks/chunk-64ICY43M.js +8 -0
  195. package/dist/bin/shell/chunks/chunk-6MJ6NBIG.js +8 -0
  196. package/dist/bin/shell/chunks/chunk-6N6IRP6G.js +6 -0
  197. package/dist/bin/shell/chunks/chunk-6VQWCKYE.js +2 -0
  198. package/dist/bin/shell/chunks/chunk-6WKRPHAZ.js +36 -0
  199. package/dist/bin/shell/chunks/chunk-73X3QWRT.js +80 -0
  200. package/dist/bin/shell/chunks/chunk-7FCHB2LT.js +14 -0
  201. package/dist/bin/shell/chunks/chunk-7FGPQVVJ.js +12 -0
  202. package/dist/bin/shell/chunks/chunk-7FUCLMNU.js +7 -0
  203. package/dist/bin/shell/chunks/chunk-7LGOLTRR.js +5 -0
  204. package/dist/bin/shell/chunks/chunk-7POGKC42.js +11 -0
  205. package/dist/bin/shell/chunks/chunk-A257OMG4.js +2 -0
  206. package/dist/bin/shell/chunks/chunk-BH4O34VZ.js +26 -0
  207. package/dist/bin/shell/chunks/chunk-BTCJZ7OY.js +10 -0
  208. package/dist/bin/shell/chunks/chunk-CEU7KGBV.js +24 -0
  209. package/dist/bin/shell/chunks/chunk-COM2NIBS.js +3 -0
  210. package/dist/bin/shell/chunks/chunk-CXEBUGVP.js +7 -0
  211. package/dist/bin/shell/chunks/chunk-CY4RP66Q.js +21 -0
  212. package/dist/bin/shell/chunks/chunk-DM55Q4EM.js +5 -0
  213. package/dist/bin/shell/chunks/chunk-DUBCYODB.js +11 -0
  214. package/dist/bin/shell/chunks/chunk-DUPNDZ3H.js +6 -0
  215. package/dist/bin/shell/chunks/chunk-EKD22SYR.js +23 -0
  216. package/dist/bin/shell/chunks/chunk-EOMAF5KQ.js +6 -0
  217. package/dist/bin/shell/chunks/chunk-EQOXJHK3.js +2 -0
  218. package/dist/bin/shell/chunks/chunk-EYZ62W3A.js +8 -0
  219. package/dist/bin/shell/chunks/chunk-FHWRQZ3L.js +9 -0
  220. package/dist/bin/shell/chunks/chunk-FUPQF256.js +10 -0
  221. package/dist/bin/shell/chunks/chunk-GNVKOWAD.js +7 -0
  222. package/dist/bin/shell/chunks/chunk-GZGWA6JM.js +3 -0
  223. package/dist/bin/shell/chunks/chunk-HMHPYX5K.js +9 -0
  224. package/dist/bin/shell/chunks/chunk-IA7QY73Z.js +9 -0
  225. package/dist/bin/shell/chunks/chunk-J7ARATA6.js +4 -0
  226. package/dist/bin/shell/chunks/chunk-JGKR7YR7.js +2 -0
  227. package/dist/bin/shell/chunks/chunk-JILAHEMU.js +2 -0
  228. package/dist/bin/shell/chunks/chunk-JKVUWQVK.js +12 -0
  229. package/dist/bin/shell/chunks/chunk-JVUFZWPW.js +3 -0
  230. package/dist/bin/shell/chunks/chunk-JYZZJOWW.js +2 -0
  231. package/dist/bin/shell/chunks/chunk-KSXVXC3N.js +2 -0
  232. package/dist/bin/shell/chunks/chunk-KTGY5SRV.js +2 -0
  233. package/dist/bin/shell/chunks/chunk-KTZIEG4R.js +13 -0
  234. package/dist/bin/shell/chunks/chunk-LNAXROAQ.js +5 -0
  235. package/dist/bin/shell/chunks/chunk-LV3CC7SU.js +7 -0
  236. package/dist/bin/shell/chunks/chunk-LVWII44I.js +23 -0
  237. package/dist/bin/shell/chunks/chunk-LZC6DGAO.js +8 -0
  238. package/dist/bin/shell/chunks/chunk-M3JG3HYB.js +14 -0
  239. package/dist/bin/shell/chunks/chunk-MJODCFGH.js +140 -0
  240. package/dist/bin/shell/chunks/chunk-MJTA3OJF.js +7 -0
  241. package/dist/bin/shell/chunks/chunk-OF45CXLB.js +2 -0
  242. package/dist/bin/shell/chunks/chunk-PAD6GYRH.js +5 -0
  243. package/dist/bin/shell/chunks/chunk-PJ7H3LY6.js +8 -0
  244. package/dist/bin/shell/chunks/chunk-QD4WQ5KK.js +17 -0
  245. package/dist/bin/shell/chunks/chunk-R2BBWDS3.js +2 -0
  246. package/dist/bin/shell/chunks/chunk-SIDKYUUQ.js +7 -0
  247. package/dist/bin/shell/chunks/chunk-TDOAJ4YU.js +3 -0
  248. package/dist/bin/shell/chunks/chunk-U34CFKX2.js +13 -0
  249. package/dist/bin/shell/chunks/chunk-U7TJRQHK.js +16 -0
  250. package/dist/bin/shell/chunks/chunk-UIRJNX5Z.js +2 -0
  251. package/dist/bin/shell/chunks/chunk-UKL6PNC2.js +63 -0
  252. package/dist/bin/shell/chunks/chunk-UN3P7MOR.js +16 -0
  253. package/dist/bin/shell/chunks/chunk-UQKQCSRP.js +16 -0
  254. package/dist/bin/shell/chunks/chunk-UYAEZFQS.js +100 -0
  255. package/dist/bin/shell/chunks/chunk-V7OGIT4K.js +3 -0
  256. package/dist/bin/shell/chunks/chunk-VK4UPKZF.js +3 -0
  257. package/dist/bin/shell/chunks/chunk-VUUGFF6A.js +9 -0
  258. package/dist/bin/shell/chunks/chunk-WATFCWHB.js +12 -0
  259. package/dist/bin/shell/chunks/chunk-WIJCOCAS.js +9 -0
  260. package/dist/bin/shell/chunks/chunk-XSCMU2VT.js +19 -0
  261. package/dist/bin/shell/chunks/chunk-XWJ3KFMY.js +287 -0
  262. package/dist/bin/shell/chunks/chunk-Y6NUYQQX.js +84 -0
  263. package/dist/bin/shell/chunks/chunk-YLIFZDMR.js +9 -0
  264. package/dist/bin/shell/chunks/chunk-YQFW27YU.js +33 -0
  265. package/dist/bin/shell/chunks/chunk-YXVJUBRG.js +5 -0
  266. package/dist/bin/shell/chunks/chunk-Z6BNZUNQ.js +32 -0
  267. package/dist/bin/shell/chunks/chunk-ZLGIFJBA.js +5 -0
  268. package/dist/bin/shell/chunks/clear-FZZM6QD2.js +2 -0
  269. package/dist/bin/shell/chunks/column-UCIEGSHJ.js +2 -0
  270. package/dist/bin/shell/chunks/comm-WKYJTISA.js +2 -0
  271. package/dist/bin/shell/chunks/cp-YSXTOMBS.js +2 -0
  272. package/dist/bin/shell/chunks/curl-YFYJ2XNC.js +26 -0
  273. package/dist/bin/shell/chunks/cut-2MSOLU4C.js +2 -0
  274. package/dist/bin/shell/chunks/date-5LA42436.js +2 -0
  275. package/dist/bin/shell/chunks/diff-4PEKV4XS.js +2 -0
  276. package/dist/bin/shell/chunks/dirname-XXQNLCA4.js +2 -0
  277. package/dist/bin/shell/chunks/du-IKBAW7PG.js +2 -0
  278. package/dist/bin/shell/chunks/echo-DHVSEP57.js +2 -0
  279. package/dist/bin/shell/chunks/env-A43LGO53.js +2 -0
  280. package/dist/bin/shell/chunks/expand-L4NT2YFK.js +2 -0
  281. package/dist/bin/shell/chunks/expansion-IB7ZIBIF.js +2 -0
  282. package/dist/bin/shell/chunks/expr-BGBONRHV.js +2 -0
  283. package/dist/bin/shell/chunks/file-DZRWWDPH.js +2 -0
  284. package/dist/bin/shell/chunks/find-B6JV4QSG.js +2 -0
  285. package/dist/bin/shell/chunks/flag-coverage-FTS7XXHM.js +2 -0
  286. package/dist/bin/shell/chunks/fold-OVU7UR2E.js +2 -0
  287. package/dist/bin/shell/chunks/grep-RG26XCUN.js +2 -0
  288. package/dist/bin/shell/chunks/gzip-XZZL25AV.js +2 -0
  289. package/dist/bin/shell/chunks/head-HT46A7YT.js +2 -0
  290. package/dist/bin/shell/chunks/help-AOETY73Q.js +2 -0
  291. package/dist/bin/shell/chunks/history-WO6CMWMT.js +2 -0
  292. package/dist/bin/shell/chunks/hostname-4O6NEPL2.js +2 -0
  293. package/dist/bin/shell/chunks/html-to-markdown-34LV4LFQ.js +2 -0
  294. package/dist/bin/shell/chunks/join-6M3ARIFB.js +2 -0
  295. package/dist/bin/shell/chunks/jq-HP7VLWBL.js +2 -0
  296. package/dist/bin/shell/chunks/ln-2OLFXJYU.js +2 -0
  297. package/dist/bin/shell/chunks/ls-LBW3TTPI.js +2 -0
  298. package/dist/bin/shell/chunks/md5sum-GAWU76ZU.js +2 -0
  299. package/dist/bin/shell/chunks/mkdir-UUOVKGHS.js +2 -0
  300. package/dist/bin/shell/chunks/mv-7VY5OVAU.js +2 -0
  301. package/dist/bin/shell/chunks/nl-34JIXDXD.js +2 -0
  302. package/dist/bin/shell/chunks/od-IGVFBAFH.js +2 -0
  303. package/dist/bin/shell/chunks/paste-Q23K6FU7.js +2 -0
  304. package/dist/bin/shell/chunks/printf-CVEJOTYB.js +2 -0
  305. package/dist/bin/shell/chunks/pwd-6OLMY3MQ.js +2 -0
  306. package/dist/bin/shell/chunks/python3-VZL5HRHR.js +14 -0
  307. package/dist/bin/shell/chunks/readlink-T4CDCG4Z.js +2 -0
  308. package/dist/bin/shell/chunks/rev-O3PQMT23.js +2 -0
  309. package/dist/bin/shell/chunks/rg-PQP4HTR3.js +2 -0
  310. package/dist/bin/shell/chunks/rm-UMIY7ESO.js +2 -0
  311. package/dist/bin/shell/chunks/rmdir-NJCSEPRP.js +2 -0
  312. package/dist/bin/shell/chunks/sed-BZW7POX3.js +2 -0
  313. package/dist/bin/shell/chunks/seq-3FRPQG5E.js +2 -0
  314. package/dist/bin/shell/chunks/sha1sum-AOZWHFTU.js +2 -0
  315. package/dist/bin/shell/chunks/sha256sum-EXJTAPU4.js +2 -0
  316. package/dist/bin/shell/chunks/sleep-HDMKKRCV.js +2 -0
  317. package/dist/bin/shell/chunks/sort-TO3IPXI2.js +2 -0
  318. package/dist/bin/shell/chunks/split-JXCUP73P.js +2 -0
  319. package/dist/bin/shell/chunks/sqlite3-K7LHCU76.js +2 -0
  320. package/dist/bin/shell/chunks/stat-J5TUE4U5.js +2 -0
  321. package/dist/bin/shell/chunks/strings-TDUSHGAB.js +2 -0
  322. package/dist/bin/shell/chunks/tac-QXOHN3J4.js +2 -0
  323. package/dist/bin/shell/chunks/tail-LOVA3SKT.js +2 -0
  324. package/dist/bin/shell/chunks/tar-BAKR5OJO.js +2 -0
  325. package/dist/bin/shell/chunks/tee-SREYEKO6.js +2 -0
  326. package/dist/bin/shell/chunks/time-GS6SIFPK.js +2 -0
  327. package/dist/bin/shell/chunks/timeout-XBYZ5LW5.js +2 -0
  328. package/dist/bin/shell/chunks/touch-4ZSEFYEW.js +2 -0
  329. package/dist/bin/shell/chunks/tr-ARR7JBLN.js +2 -0
  330. package/dist/bin/shell/chunks/tree-7Y7H64VI.js +2 -0
  331. package/dist/bin/shell/chunks/true-CKHNKYAT.js +2 -0
  332. package/dist/bin/shell/chunks/unexpand-B4WHWJHL.js +2 -0
  333. package/dist/bin/shell/chunks/uniq-I2KNCRR6.js +2 -0
  334. package/dist/bin/shell/chunks/wc-TDIG4RIU.js +2 -0
  335. package/dist/bin/shell/chunks/which-QMZ276XE.js +2 -0
  336. package/dist/bin/shell/chunks/whoami-XYB47VCX.js +2 -0
  337. package/dist/bin/shell/chunks/xan-STBKXZ5W.js +2 -0
  338. package/dist/bin/shell/chunks/xan-view-BIT4WIPP.js +2 -0
  339. package/dist/bin/shell/chunks/xargs-6K57XYD6.js +2 -0
  340. package/dist/bin/shell/chunks/yes-7ZGUE2PX.js +2 -0
  341. package/dist/bin/shell/chunks/yq-ZHYSTGN3.js +2 -0
  342. package/dist/bin/shell/shell.js +325 -308
  343. package/dist/browser.d.ts +4 -0
  344. package/dist/bundle/browser.js +859 -841
  345. package/dist/bundle/chunks/alias-CIPN5HGG.js +1 -0
  346. package/dist/bundle/chunks/awk2-RAKURI6M.js +1 -0
  347. package/dist/bundle/chunks/base64-4GSA7KNI.js +1 -0
  348. package/dist/bundle/chunks/basename-Q7SIX77Q.js +1 -0
  349. package/dist/bundle/chunks/bash-HKSQMKKV.js +1 -0
  350. package/dist/bundle/chunks/cat-L3YELBYM.js +1 -0
  351. package/dist/bundle/chunks/chmod-IJMA7OGQ.js +1 -0
  352. package/dist/bundle/chunks/chunk-23R5HQHH.js +22 -0
  353. package/dist/bundle/chunks/chunk-2C5744E3.js +16 -0
  354. package/dist/bundle/chunks/chunk-2UAAXNHX.js +1 -0
  355. package/dist/bundle/chunks/chunk-3JEPB2CL.js +10 -0
  356. package/dist/bundle/chunks/chunk-4NRX5HFD.js +2 -0
  357. package/dist/bundle/chunks/chunk-5JHQRYUS.js +5 -0
  358. package/dist/bundle/chunks/chunk-6B44NYQO.js +8 -0
  359. package/dist/bundle/chunks/chunk-6D5UCV65.js +23 -0
  360. package/dist/bundle/chunks/chunk-6TAOLIZ7.js +13 -0
  361. package/dist/bundle/chunks/chunk-734O2UB7.js +9 -0
  362. package/dist/bundle/chunks/chunk-7B7AWU7X.js +2 -0
  363. package/dist/bundle/chunks/chunk-7KFBK6FW.js +1 -0
  364. package/dist/bundle/chunks/chunk-7ROHLV74.js +31 -0
  365. package/dist/bundle/chunks/chunk-7SQ2RTI2.js +139 -0
  366. package/dist/bundle/chunks/chunk-7UPROJVF.js +4 -0
  367. package/dist/bundle/chunks/chunk-7Z65ZFBM.js +10 -0
  368. package/dist/bundle/chunks/chunk-A5FEGJHF.js +4 -0
  369. package/dist/bundle/chunks/chunk-AAVEDJ2B.js +4 -0
  370. package/dist/bundle/chunks/chunk-AFEP7ZTB.js +4 -0
  371. package/dist/bundle/chunks/chunk-ALZ5CSTK.js +9 -0
  372. package/dist/bundle/chunks/chunk-ANMMLK7G.js +2 -0
  373. package/dist/bundle/chunks/chunk-AXMBAF6A.js +5 -0
  374. package/dist/bundle/chunks/chunk-BX5K34KY.js +1 -0
  375. package/dist/bundle/chunks/chunk-BZXBFTL2.js +4 -0
  376. package/dist/bundle/chunks/chunk-C4UC4TPC.js +8 -0
  377. package/dist/bundle/chunks/chunk-CNBBFQPC.js +1 -0
  378. package/dist/bundle/chunks/chunk-CVM2MFM3.js +2 -0
  379. package/dist/bundle/chunks/chunk-DL5GRV7N.js +5 -0
  380. package/dist/bundle/chunks/chunk-DS5ORKKQ.js +3 -0
  381. package/dist/bundle/chunks/chunk-ESLB4XKL.js +15 -0
  382. package/dist/bundle/chunks/chunk-FPJIAK37.js +8 -0
  383. package/dist/bundle/chunks/chunk-GBVVD7OP.js +12 -0
  384. package/dist/bundle/chunks/chunk-GJQGDOOO.js +8 -0
  385. package/dist/bundle/chunks/chunk-GZRZD5YF.js +4 -0
  386. package/dist/bundle/chunks/chunk-HDHI347R.js +6 -0
  387. package/dist/bundle/chunks/chunk-HKMBFRTV.js +2 -0
  388. package/dist/bundle/chunks/chunk-HMRLLHZE.js +7 -0
  389. package/dist/bundle/chunks/chunk-HVMFTOQY.js +1 -0
  390. package/dist/bundle/chunks/chunk-IVTIGXSE.js +11 -0
  391. package/dist/bundle/chunks/chunk-IXPY5PYY.js +13 -0
  392. package/dist/bundle/chunks/chunk-J2BTXVXN.js +6 -0
  393. package/dist/bundle/chunks/chunk-J2GAF4HH.js +15 -0
  394. package/dist/bundle/chunks/chunk-JJXSCNTG.js +5 -0
  395. package/dist/bundle/chunks/chunk-JZLKE4XX.js +23 -0
  396. package/dist/bundle/chunks/chunk-KL7SL7ES.js +1 -0
  397. package/dist/bundle/chunks/chunk-KLSVVM53.js +6 -0
  398. package/dist/bundle/chunks/chunk-KMDWD5I5.js +8 -0
  399. package/dist/bundle/chunks/chunk-KMFEA7OG.js +2 -0
  400. package/dist/bundle/chunks/chunk-KXZALX7Z.js +7 -0
  401. package/dist/bundle/chunks/chunk-MQY52TBM.js +7 -0
  402. package/dist/bundle/chunks/chunk-N552BMHP.js +1 -0
  403. package/dist/bundle/chunks/chunk-NCNBSBGV.js +286 -0
  404. package/dist/bundle/chunks/chunk-OBYDR4XV.js +4 -0
  405. package/dist/bundle/chunks/chunk-OGUNWUEY.js +17 -0
  406. package/dist/bundle/chunks/chunk-ORNEVHL4.js +99 -0
  407. package/dist/bundle/chunks/chunk-P3THD7GM.js +6 -0
  408. package/dist/bundle/chunks/chunk-PEEBONF2.js +2 -0
  409. package/dist/bundle/chunks/chunk-PMGKXEU7.js +13 -0
  410. package/dist/bundle/chunks/chunk-PVCFRKJJ.js +13 -0
  411. package/dist/bundle/chunks/chunk-QFO6LPNQ.js +7 -0
  412. package/dist/bundle/chunks/chunk-QMUDG3KU.js +12 -0
  413. package/dist/bundle/chunks/chunk-QWZOR6OX.js +5 -0
  414. package/dist/bundle/chunks/chunk-R42D4RK2.js +15 -0
  415. package/dist/bundle/chunks/chunk-S6UKQQAB.js +79 -0
  416. package/dist/bundle/chunks/chunk-SRQ7BXVR.js +1 -0
  417. package/dist/bundle/chunks/chunk-SXA5BV42.js +20 -0
  418. package/dist/bundle/chunks/chunk-TL7ILCBE.js +6 -0
  419. package/dist/bundle/chunks/chunk-TMW4OG4N.js +6 -0
  420. package/dist/bundle/chunks/chunk-UPLN3OMW.js +11 -0
  421. package/dist/bundle/chunks/chunk-UPUUONKD.js +6 -0
  422. package/dist/bundle/chunks/chunk-USPQ6LOW.js +10 -0
  423. package/dist/bundle/chunks/chunk-UY2R54E5.js +8 -0
  424. package/dist/bundle/chunks/chunk-V6WGFVZA.js +6 -0
  425. package/dist/bundle/chunks/chunk-VAEB4OUK.js +1 -0
  426. package/dist/bundle/chunks/chunk-VEE747JZ.js +6 -0
  427. package/dist/bundle/chunks/chunk-WBPZNWSY.js +35 -0
  428. package/dist/bundle/chunks/chunk-WPPIJX5K.js +22 -0
  429. package/dist/bundle/chunks/chunk-X7M472ST.js +32 -0
  430. package/dist/bundle/chunks/chunk-XAYT3L2B.js +1 -0
  431. package/dist/bundle/chunks/chunk-XCI3COKM.js +12 -0
  432. package/dist/bundle/chunks/chunk-XDY76TEA.js +19 -0
  433. package/dist/bundle/chunks/chunk-XEKBP4I4.js +62 -0
  434. package/dist/bundle/chunks/chunk-XGMYS2QC.js +3 -0
  435. package/dist/bundle/chunks/chunk-YIIBJSJS.js +11 -0
  436. package/dist/bundle/chunks/chunk-YMPJSDL2.js +7 -0
  437. package/dist/bundle/chunks/chunk-YU2FN4NA.js +8 -0
  438. package/dist/bundle/chunks/chunk-YZSDCIXP.js +9 -0
  439. package/dist/bundle/chunks/chunk-ZLBJV2VD.js +1 -0
  440. package/dist/bundle/chunks/clear-J6WBUIX6.js +1 -0
  441. package/dist/bundle/chunks/column-N7MHP5SX.js +1 -0
  442. package/dist/bundle/chunks/comm-X7VETT2U.js +1 -0
  443. package/dist/bundle/chunks/cp-73PGBEPL.js +1 -0
  444. package/dist/bundle/chunks/curl-MGBYKD7U.js +25 -0
  445. package/dist/bundle/chunks/cut-7I6UA67F.js +1 -0
  446. package/dist/bundle/chunks/date-MOZRIQXR.js +1 -0
  447. package/dist/bundle/chunks/diff-O5NFSBS5.js +1 -0
  448. package/dist/bundle/chunks/dirname-2TM4IG7K.js +1 -0
  449. package/dist/bundle/chunks/du-KTUJVIGD.js +1 -0
  450. package/dist/bundle/chunks/echo-PC3TVS6B.js +1 -0
  451. package/dist/bundle/chunks/env-MFQH47JH.js +1 -0
  452. package/dist/bundle/chunks/expand-OYPZZOZC.js +1 -0
  453. package/dist/bundle/chunks/expansion-QM4WQBBG.js +1 -0
  454. package/dist/bundle/chunks/expr-4PIUWNB7.js +1 -0
  455. package/dist/bundle/chunks/file-DZRW6GNH.js +1 -0
  456. package/dist/bundle/chunks/find-DESNHKKS.js +1 -0
  457. package/dist/bundle/chunks/flag-coverage-QMBN7WOW.js +1 -0
  458. package/dist/bundle/chunks/fold-5VRJN4CL.js +1 -0
  459. package/dist/bundle/chunks/grep-7RC5DPOS.js +1 -0
  460. package/dist/bundle/chunks/gzip-WH2JWAWT.js +1 -0
  461. package/dist/bundle/chunks/head-EFRLGDOE.js +1 -0
  462. package/dist/bundle/chunks/help-3XYFOR43.js +1 -0
  463. package/dist/bundle/chunks/history-J3C24VIU.js +1 -0
  464. package/dist/bundle/chunks/hostname-D54LLZ5I.js +1 -0
  465. package/dist/bundle/chunks/html-to-markdown-TFBDHAZZ.js +1 -0
  466. package/dist/bundle/chunks/join-36QXZEGR.js +1 -0
  467. package/dist/bundle/chunks/jq-5KN27BBY.js +1 -0
  468. package/dist/bundle/chunks/ln-SHI7B5FY.js +1 -0
  469. package/dist/bundle/chunks/ls-7JNJXADY.js +1 -0
  470. package/dist/bundle/chunks/md5sum-J7XPNTQZ.js +1 -0
  471. package/dist/bundle/chunks/mkdir-NM4BUUUC.js +1 -0
  472. package/dist/bundle/chunks/mv-VDGF4VTT.js +1 -0
  473. package/dist/bundle/chunks/nl-PD7BPFUB.js +1 -0
  474. package/dist/bundle/chunks/od-D6RO3GJE.js +1 -0
  475. package/dist/bundle/chunks/paste-HD4NKO4X.js +1 -0
  476. package/dist/bundle/chunks/printf-6XMXHDAE.js +1 -0
  477. package/dist/bundle/chunks/pwd-KKLARPNT.js +1 -0
  478. package/dist/bundle/chunks/python3-KPG6SQQV.js +13 -0
  479. package/dist/bundle/chunks/readlink-6XCFQQJH.js +1 -0
  480. package/dist/bundle/chunks/rev-NJ2ZPNAT.js +1 -0
  481. package/dist/bundle/chunks/rg-NIW2Q5SV.js +1 -0
  482. package/dist/bundle/chunks/rm-7ERREV4V.js +1 -0
  483. package/dist/bundle/chunks/rmdir-Z4ZRV32S.js +1 -0
  484. package/dist/bundle/chunks/sed-VLSHT4XR.js +1 -0
  485. package/dist/bundle/chunks/seq-RCBD3IYO.js +1 -0
  486. package/dist/bundle/chunks/sha1sum-RMRQ75AE.js +1 -0
  487. package/dist/bundle/chunks/sha256sum-TGW5BMJR.js +1 -0
  488. package/dist/bundle/chunks/sleep-SAQIXUFW.js +1 -0
  489. package/dist/bundle/chunks/sort-KCG2A34N.js +1 -0
  490. package/dist/bundle/chunks/split-EVSSQ6VR.js +1 -0
  491. package/dist/bundle/chunks/sqlite3-M6BXLMYI.js +1 -0
  492. package/dist/bundle/chunks/stat-Z22X56GM.js +1 -0
  493. package/dist/bundle/chunks/strings-EKWOLUFJ.js +1 -0
  494. package/dist/bundle/chunks/tac-RSIVIUEI.js +1 -0
  495. package/dist/bundle/chunks/tail-TULUAGKH.js +1 -0
  496. package/dist/bundle/chunks/tar-KQPQPRTZ.js +1 -0
  497. package/dist/bundle/chunks/tee-DPV6AVMH.js +1 -0
  498. package/dist/bundle/chunks/time-RXWT5RNC.js +1 -0
  499. package/dist/bundle/chunks/timeout-YRSN3MWF.js +1 -0
  500. package/dist/bundle/chunks/touch-PC42E2OS.js +1 -0
  501. package/dist/bundle/chunks/tr-F7JZV44S.js +1 -0
  502. package/dist/bundle/chunks/tree-SVRMFKLQ.js +1 -0
  503. package/dist/bundle/chunks/true-T4XKISHJ.js +1 -0
  504. package/dist/bundle/chunks/unexpand-KAIAW5TX.js +1 -0
  505. package/dist/bundle/chunks/uniq-7HD4DCMD.js +1 -0
  506. package/dist/bundle/chunks/wc-U424DF7O.js +1 -0
  507. package/dist/bundle/chunks/which-OY73BBGP.js +1 -0
  508. package/dist/bundle/chunks/whoami-KUZQQOVR.js +1 -0
  509. package/dist/bundle/chunks/xan-N66EXZFT.js +1 -0
  510. package/dist/bundle/chunks/xan-view-RLM3746X.js +1 -0
  511. package/dist/bundle/chunks/xargs-SWPLSROG.js +1 -0
  512. package/dist/bundle/chunks/yes-5BWAW2VY.js +1 -0
  513. package/dist/bundle/chunks/yq-URX6MHLP.js +1 -0
  514. package/dist/bundle/index.js +313 -296
  515. package/dist/index.d.ts +4 -0
  516. package/dist/interpreter/builtins/break.d.ts +1 -1
  517. package/dist/interpreter/builtins/continue.d.ts +1 -1
  518. package/dist/interpreter/builtins/exit.d.ts +1 -1
  519. package/dist/interpreter/builtins/index.d.ts +3 -0
  520. package/dist/interpreter/builtins/jobs.d.ts +5 -0
  521. package/dist/interpreter/builtins/kill.d.ts +3 -0
  522. package/dist/interpreter/builtins/set.d.ts +1 -1
  523. package/dist/interpreter/builtins/shift.d.ts +1 -1
  524. package/dist/interpreter/builtins/wait.d.ts +3 -0
  525. package/dist/interpreter/errors.d.ts +45 -26
  526. package/dist/interpreter/functions.d.ts +1 -1
  527. package/dist/interpreter/helpers/condition.d.ts +1 -1
  528. package/dist/interpreter/helpers/loop.d.ts +1 -6
  529. package/dist/interpreter/helpers/readonly.d.ts +1 -1
  530. package/dist/interpreter/helpers/result.d.ts +1 -1
  531. package/dist/interpreter/helpers/statements.d.ts +2 -5
  532. package/dist/interpreter/index.d.ts +1 -1
  533. package/dist/interpreter/interpreter.d.ts +12 -2
  534. package/dist/interpreter/output-channels.d.ts +50 -0
  535. package/dist/interpreter/redirect-channels.d.ts +34 -0
  536. package/dist/interpreter/redirections.d.ts +22 -27
  537. package/dist/interpreter/types.d.ts +20 -6
  538. package/dist/limits.d.ts +2 -0
  539. package/dist/process/process-table.d.ts +92 -0
  540. package/dist/sandbox/Command.d.ts +15 -2
  541. package/dist/sandbox/Sandbox.d.ts +5 -0
  542. package/dist/types.d.ts +13 -1
  543. package/dist/utils/abort.d.ts +12 -0
  544. package/dist/utils/stream.d.ts +5 -0
  545. package/package.json +2 -1
  546. package/dist/bin/chunks/alias-VEEWI66Q.js +0 -2
  547. package/dist/bin/chunks/awk2-LEBSBFO3.js +0 -2
  548. package/dist/bin/chunks/base64-Q2G4GF6R.js +0 -2
  549. package/dist/bin/chunks/basename-TNVKQHP5.js +0 -2
  550. package/dist/bin/chunks/bash-E26LCUON.js +0 -2
  551. package/dist/bin/chunks/cat-6WUYWK6Q.js +0 -2
  552. package/dist/bin/chunks/chmod-YHG2ADMJ.js +0 -2
  553. package/dist/bin/chunks/chunk-25DBXZPM.js +0 -100
  554. package/dist/bin/chunks/chunk-272ZYGP4.js +0 -8
  555. package/dist/bin/chunks/chunk-2KW5JZDM.js +0 -2
  556. package/dist/bin/chunks/chunk-33EFJFXL.js +0 -10
  557. package/dist/bin/chunks/chunk-3CCRFBBL.js +0 -23
  558. package/dist/bin/chunks/chunk-3OP7VRO7.js +0 -6
  559. package/dist/bin/chunks/chunk-3PIWDQZL.js +0 -19
  560. package/dist/bin/chunks/chunk-4C26CCJR.js +0 -4
  561. package/dist/bin/chunks/chunk-4G37X3GZ.js +0 -14
  562. package/dist/bin/chunks/chunk-4KTWLZ5A.js +0 -8
  563. package/dist/bin/chunks/chunk-55N7NX6G.js +0 -9
  564. package/dist/bin/chunks/chunk-5OQOWWIB.js +0 -7
  565. package/dist/bin/chunks/chunk-5WAR3CU3.js +0 -3
  566. package/dist/bin/chunks/chunk-63VB22X2.js +0 -33
  567. package/dist/bin/chunks/chunk-6KVPD5H7.js +0 -13
  568. package/dist/bin/chunks/chunk-6OVV6A5W.js +0 -3
  569. package/dist/bin/chunks/chunk-6PU2WD4P.js +0 -7
  570. package/dist/bin/chunks/chunk-7ICAP454.js +0 -12
  571. package/dist/bin/chunks/chunk-7QKMCOGE.js +0 -16
  572. package/dist/bin/chunks/chunk-7SXBGUE4.js +0 -3
  573. package/dist/bin/chunks/chunk-7VQY35S5.js +0 -8
  574. package/dist/bin/chunks/chunk-7VVTANT2.js +0 -7
  575. package/dist/bin/chunks/chunk-7XV5FI5D.js +0 -8
  576. package/dist/bin/chunks/chunk-7Y5TZ5CE.js +0 -6
  577. package/dist/bin/chunks/chunk-A2V4EW6Y.js +0 -10
  578. package/dist/bin/chunks/chunk-ACV764YE.js +0 -5
  579. package/dist/bin/chunks/chunk-AJBYK52Q.js +0 -36
  580. package/dist/bin/chunks/chunk-BCE7PDXY.js +0 -32
  581. package/dist/bin/chunks/chunk-BVWBX3A2.js +0 -9
  582. package/dist/bin/chunks/chunk-COBNN6FR.js +0 -11
  583. package/dist/bin/chunks/chunk-CVXSPZVY.js +0 -2
  584. package/dist/bin/chunks/chunk-CX7XUPMH.js +0 -13
  585. package/dist/bin/chunks/chunk-D2V2UKR2.js +0 -12
  586. package/dist/bin/chunks/chunk-DD4R5YY7.js +0 -7
  587. package/dist/bin/chunks/chunk-DN7JDLUW.js +0 -26
  588. package/dist/bin/chunks/chunk-DVODFXEH.js +0 -5
  589. package/dist/bin/chunks/chunk-EC57ABPL.js +0 -9
  590. package/dist/bin/chunks/chunk-F7RPLNVE.js +0 -11
  591. package/dist/bin/chunks/chunk-FEA5SLRN.js +0 -6
  592. package/dist/bin/chunks/chunk-FJTEZ7ZL.js +0 -9
  593. package/dist/bin/chunks/chunk-FO6UO5LY.js +0 -12
  594. package/dist/bin/chunks/chunk-FYKWQWLG.js +0 -9
  595. package/dist/bin/chunks/chunk-GETENI3B.js +0 -18
  596. package/dist/bin/chunks/chunk-GTLVINNE.js +0 -4
  597. package/dist/bin/chunks/chunk-H7WPPRUD.js +0 -2
  598. package/dist/bin/chunks/chunk-HHBZ7ZEV.js +0 -5
  599. package/dist/bin/chunks/chunk-IGPJA6SA.js +0 -17
  600. package/dist/bin/chunks/chunk-J7REVEWS.js +0 -14
  601. package/dist/bin/chunks/chunk-JHKFD4EI.js +0 -24
  602. package/dist/bin/chunks/chunk-JUQT3ZM5.js +0 -23
  603. package/dist/bin/chunks/chunk-LXRRE42A.js +0 -5
  604. package/dist/bin/chunks/chunk-LYTEJIUW.js +0 -14
  605. package/dist/bin/chunks/chunk-MFXVUOM3.js +0 -2
  606. package/dist/bin/chunks/chunk-N3IFSXB3.js +0 -8
  607. package/dist/bin/chunks/chunk-NHZGQ3Y7.js +0 -84
  608. package/dist/bin/chunks/chunk-NIBKZJZM.js +0 -3
  609. package/dist/bin/chunks/chunk-NJTMAMPV.js +0 -3
  610. package/dist/bin/chunks/chunk-NQSOOEX5.js +0 -20
  611. package/dist/bin/chunks/chunk-NVK6GU4P.js +0 -3
  612. package/dist/bin/chunks/chunk-O4WYCXT4.js +0 -2
  613. package/dist/bin/chunks/chunk-OJGWI2DA.js +0 -63
  614. package/dist/bin/chunks/chunk-OXIM6UEO.js +0 -11
  615. package/dist/bin/chunks/chunk-PLF6WISW.js +0 -10
  616. package/dist/bin/chunks/chunk-PVAWMOD4.js +0 -8
  617. package/dist/bin/chunks/chunk-PXK4KVSW.js +0 -73
  618. package/dist/bin/chunks/chunk-Q2EFJFW4.js +0 -2
  619. package/dist/bin/chunks/chunk-Q5UK2Q5U.js +0 -2
  620. package/dist/bin/chunks/chunk-Q7XQB3YI.js +0 -7
  621. package/dist/bin/chunks/chunk-RXYSXOZE.js +0 -287
  622. package/dist/bin/chunks/chunk-SUC7ET2R.js +0 -14
  623. package/dist/bin/chunks/chunk-SXGBKAL5.js +0 -16
  624. package/dist/bin/chunks/chunk-T26GDTOU.js +0 -3
  625. package/dist/bin/chunks/chunk-T67GIEZU.js +0 -2
  626. package/dist/bin/chunks/chunk-TC7RJRFD.js +0 -16
  627. package/dist/bin/chunks/chunk-TWWOPYOU.js +0 -5
  628. package/dist/bin/chunks/chunk-UDJ6HRS4.js +0 -9
  629. package/dist/bin/chunks/chunk-UQXDPK2T.js +0 -7
  630. package/dist/bin/chunks/chunk-UREODEQQ.js +0 -21
  631. package/dist/bin/chunks/chunk-VDS4FNGM.js +0 -7
  632. package/dist/bin/chunks/chunk-VKE6V3ZO.js +0 -7
  633. package/dist/bin/chunks/chunk-VTQCQCQO.js +0 -140
  634. package/dist/bin/chunks/chunk-W4YU2U3A.js +0 -13
  635. package/dist/bin/chunks/chunk-X4GHJ5JH.js +0 -6
  636. package/dist/bin/chunks/chunk-XBI3O5AF.js +0 -9
  637. package/dist/bin/chunks/chunk-XNMKTUHV.js +0 -6
  638. package/dist/bin/chunks/chunk-ZTU6ENBH.js +0 -2
  639. package/dist/bin/chunks/chunk-ZVROZHDE.js +0 -5
  640. package/dist/bin/chunks/clear-Z6NC6SU4.js +0 -2
  641. package/dist/bin/chunks/column-UMVTEOKJ.js +0 -2
  642. package/dist/bin/chunks/comm-Q4W6PSZ3.js +0 -2
  643. package/dist/bin/chunks/cp-CAN7P3HK.js +0 -2
  644. package/dist/bin/chunks/curl-3PDMZXZI.js +0 -26
  645. package/dist/bin/chunks/cut-BQM2BHFI.js +0 -2
  646. package/dist/bin/chunks/date-XUF36E35.js +0 -2
  647. package/dist/bin/chunks/diff-7GMSJUJG.js +0 -2
  648. package/dist/bin/chunks/dirname-F7P24OLR.js +0 -2
  649. package/dist/bin/chunks/du-HDXNSQIT.js +0 -2
  650. package/dist/bin/chunks/echo-53OGHYIZ.js +0 -2
  651. package/dist/bin/chunks/env-N4LYWUJ6.js +0 -2
  652. package/dist/bin/chunks/expand-535WDY3S.js +0 -2
  653. package/dist/bin/chunks/expansion-GOJYNUQR.js +0 -2
  654. package/dist/bin/chunks/expr-Q7K5RKW2.js +0 -2
  655. package/dist/bin/chunks/file-XMHYEYO5.js +0 -2
  656. package/dist/bin/chunks/find-SJAABILU.js +0 -2
  657. package/dist/bin/chunks/flag-coverage-TBMB7M2N.js +0 -2
  658. package/dist/bin/chunks/fold-MAXEXDKA.js +0 -2
  659. package/dist/bin/chunks/grep-NXW3ZS2T.js +0 -2
  660. package/dist/bin/chunks/gzip-4TZR4OHX.js +0 -2
  661. package/dist/bin/chunks/head-BCMKSPGP.js +0 -2
  662. package/dist/bin/chunks/help-27WXVVW7.js +0 -2
  663. package/dist/bin/chunks/history-T6LTHEYW.js +0 -2
  664. package/dist/bin/chunks/hostname-QJD6DLJM.js +0 -2
  665. package/dist/bin/chunks/html-to-markdown-V7M7ZTGL.js +0 -2
  666. package/dist/bin/chunks/join-PWZ5VYJD.js +0 -2
  667. package/dist/bin/chunks/jq-XOCFM26Q.js +0 -2
  668. package/dist/bin/chunks/ln-X4VQOGPC.js +0 -2
  669. package/dist/bin/chunks/ls-O4UJCH3R.js +0 -2
  670. package/dist/bin/chunks/md5sum-2TRYEYPO.js +0 -2
  671. package/dist/bin/chunks/mkdir-Z65Y7YPB.js +0 -2
  672. package/dist/bin/chunks/mv-UULWKEXQ.js +0 -2
  673. package/dist/bin/chunks/nl-SIHFBFWW.js +0 -2
  674. package/dist/bin/chunks/od-YQTILXPI.js +0 -2
  675. package/dist/bin/chunks/paste-JA7SPT5I.js +0 -2
  676. package/dist/bin/chunks/printf-U3BAFNQW.js +0 -2
  677. package/dist/bin/chunks/pwd-JNTHRUS7.js +0 -2
  678. package/dist/bin/chunks/python3-BQAB3G6R.js +0 -14
  679. package/dist/bin/chunks/readlink-KGURBO5B.js +0 -2
  680. package/dist/bin/chunks/rev-TGHAXMHE.js +0 -2
  681. package/dist/bin/chunks/rg-PCNNZYUZ.js +0 -2
  682. package/dist/bin/chunks/rm-6BNEQYJH.js +0 -2
  683. package/dist/bin/chunks/rmdir-7PTJOZ3J.js +0 -2
  684. package/dist/bin/chunks/sed-IBSHYX2R.js +0 -2
  685. package/dist/bin/chunks/seq-WPCW5LYK.js +0 -2
  686. package/dist/bin/chunks/sha1sum-LHZ223LR.js +0 -2
  687. package/dist/bin/chunks/sha256sum-BFG6UGEY.js +0 -2
  688. package/dist/bin/chunks/sleep-HI2AX63U.js +0 -2
  689. package/dist/bin/chunks/sort-KLSRAA3S.js +0 -2
  690. package/dist/bin/chunks/split-OXHHEEHV.js +0 -2
  691. package/dist/bin/chunks/sqlite3-AKDJPDT5.js +0 -2
  692. package/dist/bin/chunks/stat-T6DAFOAE.js +0 -2
  693. package/dist/bin/chunks/strings-4AJIU4EW.js +0 -2
  694. package/dist/bin/chunks/tac-4GAH3XJY.js +0 -2
  695. package/dist/bin/chunks/tail-G2U2PW6H.js +0 -2
  696. package/dist/bin/chunks/tar-FYLHDP55.js +0 -2
  697. package/dist/bin/chunks/tee-T572YIXT.js +0 -2
  698. package/dist/bin/chunks/time-XSLSFXAR.js +0 -2
  699. package/dist/bin/chunks/timeout-ZPMBHNEN.js +0 -2
  700. package/dist/bin/chunks/touch-PKHKB4B2.js +0 -2
  701. package/dist/bin/chunks/tr-T7NEIDU6.js +0 -2
  702. package/dist/bin/chunks/tree-K2GININJ.js +0 -2
  703. package/dist/bin/chunks/true-JKHT73F3.js +0 -2
  704. package/dist/bin/chunks/unexpand-OAFTIEDP.js +0 -2
  705. package/dist/bin/chunks/uniq-2HGY5ABO.js +0 -2
  706. package/dist/bin/chunks/wc-ZTIOZ2H6.js +0 -2
  707. package/dist/bin/chunks/which-AHZHM3GH.js +0 -2
  708. package/dist/bin/chunks/whoami-IM7KVJBM.js +0 -2
  709. package/dist/bin/chunks/xan-EEBMX2PC.js +0 -2
  710. package/dist/bin/chunks/xan-view-Z7GM75UK.js +0 -2
  711. package/dist/bin/chunks/xargs-QPWVMTQK.js +0 -2
  712. package/dist/bin/chunks/yes-CK5F4N34.js +0 -2
  713. package/dist/bin/chunks/yq-R26WXE6W.js +0 -2
  714. package/dist/bin/shell/chunks/alias-VEEWI66Q.js +0 -2
  715. package/dist/bin/shell/chunks/awk2-LEBSBFO3.js +0 -2
  716. package/dist/bin/shell/chunks/base64-Q2G4GF6R.js +0 -2
  717. package/dist/bin/shell/chunks/basename-TNVKQHP5.js +0 -2
  718. package/dist/bin/shell/chunks/bash-E26LCUON.js +0 -2
  719. package/dist/bin/shell/chunks/cat-6WUYWK6Q.js +0 -2
  720. package/dist/bin/shell/chunks/chmod-YHG2ADMJ.js +0 -2
  721. package/dist/bin/shell/chunks/chunk-25DBXZPM.js +0 -100
  722. package/dist/bin/shell/chunks/chunk-272ZYGP4.js +0 -8
  723. package/dist/bin/shell/chunks/chunk-2KW5JZDM.js +0 -2
  724. package/dist/bin/shell/chunks/chunk-33EFJFXL.js +0 -10
  725. package/dist/bin/shell/chunks/chunk-3CCRFBBL.js +0 -23
  726. package/dist/bin/shell/chunks/chunk-3OP7VRO7.js +0 -6
  727. package/dist/bin/shell/chunks/chunk-3PIWDQZL.js +0 -19
  728. package/dist/bin/shell/chunks/chunk-4C26CCJR.js +0 -4
  729. package/dist/bin/shell/chunks/chunk-4G37X3GZ.js +0 -14
  730. package/dist/bin/shell/chunks/chunk-4KTWLZ5A.js +0 -8
  731. package/dist/bin/shell/chunks/chunk-55N7NX6G.js +0 -9
  732. package/dist/bin/shell/chunks/chunk-5OQOWWIB.js +0 -7
  733. package/dist/bin/shell/chunks/chunk-5WAR3CU3.js +0 -3
  734. package/dist/bin/shell/chunks/chunk-63VB22X2.js +0 -33
  735. package/dist/bin/shell/chunks/chunk-6KVPD5H7.js +0 -13
  736. package/dist/bin/shell/chunks/chunk-6OVV6A5W.js +0 -3
  737. package/dist/bin/shell/chunks/chunk-6PU2WD4P.js +0 -7
  738. package/dist/bin/shell/chunks/chunk-7ICAP454.js +0 -12
  739. package/dist/bin/shell/chunks/chunk-7QKMCOGE.js +0 -16
  740. package/dist/bin/shell/chunks/chunk-7SXBGUE4.js +0 -3
  741. package/dist/bin/shell/chunks/chunk-7VQY35S5.js +0 -8
  742. package/dist/bin/shell/chunks/chunk-7VVTANT2.js +0 -7
  743. package/dist/bin/shell/chunks/chunk-7XV5FI5D.js +0 -8
  744. package/dist/bin/shell/chunks/chunk-7Y5TZ5CE.js +0 -6
  745. package/dist/bin/shell/chunks/chunk-A2V4EW6Y.js +0 -10
  746. package/dist/bin/shell/chunks/chunk-ACV764YE.js +0 -5
  747. package/dist/bin/shell/chunks/chunk-AJBYK52Q.js +0 -36
  748. package/dist/bin/shell/chunks/chunk-BCE7PDXY.js +0 -32
  749. package/dist/bin/shell/chunks/chunk-BVWBX3A2.js +0 -9
  750. package/dist/bin/shell/chunks/chunk-COBNN6FR.js +0 -11
  751. package/dist/bin/shell/chunks/chunk-CVXSPZVY.js +0 -2
  752. package/dist/bin/shell/chunks/chunk-CX7XUPMH.js +0 -13
  753. package/dist/bin/shell/chunks/chunk-D2V2UKR2.js +0 -12
  754. package/dist/bin/shell/chunks/chunk-DD4R5YY7.js +0 -7
  755. package/dist/bin/shell/chunks/chunk-DN7JDLUW.js +0 -26
  756. package/dist/bin/shell/chunks/chunk-DVODFXEH.js +0 -5
  757. package/dist/bin/shell/chunks/chunk-EC57ABPL.js +0 -9
  758. package/dist/bin/shell/chunks/chunk-F7RPLNVE.js +0 -11
  759. package/dist/bin/shell/chunks/chunk-FEA5SLRN.js +0 -6
  760. package/dist/bin/shell/chunks/chunk-FJTEZ7ZL.js +0 -9
  761. package/dist/bin/shell/chunks/chunk-FO6UO5LY.js +0 -12
  762. package/dist/bin/shell/chunks/chunk-FYKWQWLG.js +0 -9
  763. package/dist/bin/shell/chunks/chunk-GETENI3B.js +0 -18
  764. package/dist/bin/shell/chunks/chunk-GTLVINNE.js +0 -4
  765. package/dist/bin/shell/chunks/chunk-H7WPPRUD.js +0 -2
  766. package/dist/bin/shell/chunks/chunk-HHBZ7ZEV.js +0 -5
  767. package/dist/bin/shell/chunks/chunk-IGPJA6SA.js +0 -17
  768. package/dist/bin/shell/chunks/chunk-J7REVEWS.js +0 -14
  769. package/dist/bin/shell/chunks/chunk-JHKFD4EI.js +0 -24
  770. package/dist/bin/shell/chunks/chunk-JUQT3ZM5.js +0 -23
  771. package/dist/bin/shell/chunks/chunk-LXRRE42A.js +0 -5
  772. package/dist/bin/shell/chunks/chunk-LYTEJIUW.js +0 -14
  773. package/dist/bin/shell/chunks/chunk-MFXVUOM3.js +0 -2
  774. package/dist/bin/shell/chunks/chunk-N3IFSXB3.js +0 -8
  775. package/dist/bin/shell/chunks/chunk-NHZGQ3Y7.js +0 -84
  776. package/dist/bin/shell/chunks/chunk-NIBKZJZM.js +0 -3
  777. package/dist/bin/shell/chunks/chunk-NJTMAMPV.js +0 -3
  778. package/dist/bin/shell/chunks/chunk-NQSOOEX5.js +0 -20
  779. package/dist/bin/shell/chunks/chunk-NVK6GU4P.js +0 -3
  780. package/dist/bin/shell/chunks/chunk-O4WYCXT4.js +0 -2
  781. package/dist/bin/shell/chunks/chunk-OJGWI2DA.js +0 -63
  782. package/dist/bin/shell/chunks/chunk-OXIM6UEO.js +0 -11
  783. package/dist/bin/shell/chunks/chunk-PLF6WISW.js +0 -10
  784. package/dist/bin/shell/chunks/chunk-PVAWMOD4.js +0 -8
  785. package/dist/bin/shell/chunks/chunk-PXK4KVSW.js +0 -73
  786. package/dist/bin/shell/chunks/chunk-Q2EFJFW4.js +0 -2
  787. package/dist/bin/shell/chunks/chunk-Q5UK2Q5U.js +0 -2
  788. package/dist/bin/shell/chunks/chunk-Q7XQB3YI.js +0 -7
  789. package/dist/bin/shell/chunks/chunk-RXYSXOZE.js +0 -287
  790. package/dist/bin/shell/chunks/chunk-SUC7ET2R.js +0 -14
  791. package/dist/bin/shell/chunks/chunk-SXGBKAL5.js +0 -16
  792. package/dist/bin/shell/chunks/chunk-T26GDTOU.js +0 -3
  793. package/dist/bin/shell/chunks/chunk-T67GIEZU.js +0 -2
  794. package/dist/bin/shell/chunks/chunk-TC7RJRFD.js +0 -16
  795. package/dist/bin/shell/chunks/chunk-TWWOPYOU.js +0 -5
  796. package/dist/bin/shell/chunks/chunk-UDJ6HRS4.js +0 -9
  797. package/dist/bin/shell/chunks/chunk-UQXDPK2T.js +0 -7
  798. package/dist/bin/shell/chunks/chunk-UREODEQQ.js +0 -21
  799. package/dist/bin/shell/chunks/chunk-VDS4FNGM.js +0 -7
  800. package/dist/bin/shell/chunks/chunk-VKE6V3ZO.js +0 -7
  801. package/dist/bin/shell/chunks/chunk-VTQCQCQO.js +0 -140
  802. package/dist/bin/shell/chunks/chunk-W4YU2U3A.js +0 -13
  803. package/dist/bin/shell/chunks/chunk-X4GHJ5JH.js +0 -6
  804. package/dist/bin/shell/chunks/chunk-XBI3O5AF.js +0 -9
  805. package/dist/bin/shell/chunks/chunk-XNMKTUHV.js +0 -6
  806. package/dist/bin/shell/chunks/chunk-ZTU6ENBH.js +0 -2
  807. package/dist/bin/shell/chunks/chunk-ZVROZHDE.js +0 -5
  808. package/dist/bin/shell/chunks/clear-Z6NC6SU4.js +0 -2
  809. package/dist/bin/shell/chunks/column-UMVTEOKJ.js +0 -2
  810. package/dist/bin/shell/chunks/comm-Q4W6PSZ3.js +0 -2
  811. package/dist/bin/shell/chunks/cp-CAN7P3HK.js +0 -2
  812. package/dist/bin/shell/chunks/curl-3PDMZXZI.js +0 -26
  813. package/dist/bin/shell/chunks/cut-BQM2BHFI.js +0 -2
  814. package/dist/bin/shell/chunks/date-XUF36E35.js +0 -2
  815. package/dist/bin/shell/chunks/diff-7GMSJUJG.js +0 -2
  816. package/dist/bin/shell/chunks/dirname-F7P24OLR.js +0 -2
  817. package/dist/bin/shell/chunks/du-HDXNSQIT.js +0 -2
  818. package/dist/bin/shell/chunks/echo-53OGHYIZ.js +0 -2
  819. package/dist/bin/shell/chunks/env-N4LYWUJ6.js +0 -2
  820. package/dist/bin/shell/chunks/expand-535WDY3S.js +0 -2
  821. package/dist/bin/shell/chunks/expansion-GOJYNUQR.js +0 -2
  822. package/dist/bin/shell/chunks/expr-Q7K5RKW2.js +0 -2
  823. package/dist/bin/shell/chunks/file-XMHYEYO5.js +0 -2
  824. package/dist/bin/shell/chunks/find-SJAABILU.js +0 -2
  825. package/dist/bin/shell/chunks/flag-coverage-TBMB7M2N.js +0 -2
  826. package/dist/bin/shell/chunks/fold-MAXEXDKA.js +0 -2
  827. package/dist/bin/shell/chunks/grep-NXW3ZS2T.js +0 -2
  828. package/dist/bin/shell/chunks/gzip-4TZR4OHX.js +0 -2
  829. package/dist/bin/shell/chunks/head-BCMKSPGP.js +0 -2
  830. package/dist/bin/shell/chunks/help-27WXVVW7.js +0 -2
  831. package/dist/bin/shell/chunks/history-T6LTHEYW.js +0 -2
  832. package/dist/bin/shell/chunks/hostname-QJD6DLJM.js +0 -2
  833. package/dist/bin/shell/chunks/html-to-markdown-V7M7ZTGL.js +0 -2
  834. package/dist/bin/shell/chunks/join-PWZ5VYJD.js +0 -2
  835. package/dist/bin/shell/chunks/jq-XOCFM26Q.js +0 -2
  836. package/dist/bin/shell/chunks/ln-X4VQOGPC.js +0 -2
  837. package/dist/bin/shell/chunks/ls-O4UJCH3R.js +0 -2
  838. package/dist/bin/shell/chunks/md5sum-2TRYEYPO.js +0 -2
  839. package/dist/bin/shell/chunks/mkdir-Z65Y7YPB.js +0 -2
  840. package/dist/bin/shell/chunks/mv-UULWKEXQ.js +0 -2
  841. package/dist/bin/shell/chunks/nl-SIHFBFWW.js +0 -2
  842. package/dist/bin/shell/chunks/od-YQTILXPI.js +0 -2
  843. package/dist/bin/shell/chunks/paste-JA7SPT5I.js +0 -2
  844. package/dist/bin/shell/chunks/printf-U3BAFNQW.js +0 -2
  845. package/dist/bin/shell/chunks/pwd-JNTHRUS7.js +0 -2
  846. package/dist/bin/shell/chunks/python3-BQAB3G6R.js +0 -14
  847. package/dist/bin/shell/chunks/readlink-KGURBO5B.js +0 -2
  848. package/dist/bin/shell/chunks/rev-TGHAXMHE.js +0 -2
  849. package/dist/bin/shell/chunks/rg-PCNNZYUZ.js +0 -2
  850. package/dist/bin/shell/chunks/rm-6BNEQYJH.js +0 -2
  851. package/dist/bin/shell/chunks/rmdir-7PTJOZ3J.js +0 -2
  852. package/dist/bin/shell/chunks/sed-IBSHYX2R.js +0 -2
  853. package/dist/bin/shell/chunks/seq-WPCW5LYK.js +0 -2
  854. package/dist/bin/shell/chunks/sha1sum-LHZ223LR.js +0 -2
  855. package/dist/bin/shell/chunks/sha256sum-BFG6UGEY.js +0 -2
  856. package/dist/bin/shell/chunks/sleep-HI2AX63U.js +0 -2
  857. package/dist/bin/shell/chunks/sort-KLSRAA3S.js +0 -2
  858. package/dist/bin/shell/chunks/split-OXHHEEHV.js +0 -2
  859. package/dist/bin/shell/chunks/sqlite3-AKDJPDT5.js +0 -2
  860. package/dist/bin/shell/chunks/stat-T6DAFOAE.js +0 -2
  861. package/dist/bin/shell/chunks/strings-4AJIU4EW.js +0 -2
  862. package/dist/bin/shell/chunks/tac-4GAH3XJY.js +0 -2
  863. package/dist/bin/shell/chunks/tail-G2U2PW6H.js +0 -2
  864. package/dist/bin/shell/chunks/tar-FYLHDP55.js +0 -2
  865. package/dist/bin/shell/chunks/tee-T572YIXT.js +0 -2
  866. package/dist/bin/shell/chunks/time-XSLSFXAR.js +0 -2
  867. package/dist/bin/shell/chunks/timeout-ZPMBHNEN.js +0 -2
  868. package/dist/bin/shell/chunks/touch-PKHKB4B2.js +0 -2
  869. package/dist/bin/shell/chunks/tr-T7NEIDU6.js +0 -2
  870. package/dist/bin/shell/chunks/tree-K2GININJ.js +0 -2
  871. package/dist/bin/shell/chunks/true-JKHT73F3.js +0 -2
  872. package/dist/bin/shell/chunks/unexpand-OAFTIEDP.js +0 -2
  873. package/dist/bin/shell/chunks/uniq-2HGY5ABO.js +0 -2
  874. package/dist/bin/shell/chunks/wc-ZTIOZ2H6.js +0 -2
  875. package/dist/bin/shell/chunks/which-AHZHM3GH.js +0 -2
  876. package/dist/bin/shell/chunks/whoami-IM7KVJBM.js +0 -2
  877. package/dist/bin/shell/chunks/xan-EEBMX2PC.js +0 -2
  878. package/dist/bin/shell/chunks/xan-view-Z7GM75UK.js +0 -2
  879. package/dist/bin/shell/chunks/xargs-QPWVMTQK.js +0 -2
  880. package/dist/bin/shell/chunks/yes-CK5F4N34.js +0 -2
  881. package/dist/bin/shell/chunks/yq-R26WXE6W.js +0 -2
  882. package/dist/bundle/chunks/alias-PFS6JBTL.js +0 -1
  883. package/dist/bundle/chunks/awk2-HG7QFRRO.js +0 -1
  884. package/dist/bundle/chunks/base64-UOYRM4DO.js +0 -1
  885. package/dist/bundle/chunks/basename-PRS2OP6R.js +0 -1
  886. package/dist/bundle/chunks/bash-UQXFZUPD.js +0 -1
  887. package/dist/bundle/chunks/cat-VI6AVTST.js +0 -1
  888. package/dist/bundle/chunks/chmod-5F3XJPPG.js +0 -1
  889. package/dist/bundle/chunks/chunk-2ERMTDAT.js +0 -1
  890. package/dist/bundle/chunks/chunk-2KW7BHBP.js +0 -5
  891. package/dist/bundle/chunks/chunk-2LC6GLRD.js +0 -10
  892. package/dist/bundle/chunks/chunk-2MWUJW7E.js +0 -13
  893. package/dist/bundle/chunks/chunk-2U6EPFDM.js +0 -4
  894. package/dist/bundle/chunks/chunk-4ECLUXYK.js +0 -5
  895. package/dist/bundle/chunks/chunk-4JZXWCPG.js +0 -2
  896. package/dist/bundle/chunks/chunk-4R3AYXSH.js +0 -6
  897. package/dist/bundle/chunks/chunk-4RPVMPGO.js +0 -4
  898. package/dist/bundle/chunks/chunk-4UNYQEQN.js +0 -6
  899. package/dist/bundle/chunks/chunk-525AJ4MJ.js +0 -9
  900. package/dist/bundle/chunks/chunk-54Z5HIDC.js +0 -7
  901. package/dist/bundle/chunks/chunk-5GE72EGR.js +0 -11
  902. package/dist/bundle/chunks/chunk-5HZ5BSXK.js +0 -1
  903. package/dist/bundle/chunks/chunk-5IUZJGTB.js +0 -99
  904. package/dist/bundle/chunks/chunk-5WPVRWBN.js +0 -12
  905. package/dist/bundle/chunks/chunk-63X77WZM.js +0 -15
  906. package/dist/bundle/chunks/chunk-6BNDUHW7.js +0 -72
  907. package/dist/bundle/chunks/chunk-6V3KZ3UR.js +0 -9
  908. package/dist/bundle/chunks/chunk-77R5SWIQ.js +0 -10
  909. package/dist/bundle/chunks/chunk-A6JH2Z2E.js +0 -7
  910. package/dist/bundle/chunks/chunk-AFZSOIRR.js +0 -1
  911. package/dist/bundle/chunks/chunk-AYQHTCJ6.js +0 -6
  912. package/dist/bundle/chunks/chunk-BJQSDFGC.js +0 -139
  913. package/dist/bundle/chunks/chunk-BOWOEGYM.js +0 -7
  914. package/dist/bundle/chunks/chunk-BXM5UMV3.js +0 -13
  915. package/dist/bundle/chunks/chunk-CDJANZJX.js +0 -5
  916. package/dist/bundle/chunks/chunk-CWN6Z4S3.js +0 -22
  917. package/dist/bundle/chunks/chunk-DGBRICQ7.js +0 -3
  918. package/dist/bundle/chunks/chunk-DGCTBS7B.js +0 -13
  919. package/dist/bundle/chunks/chunk-EBRN7NWX.js +0 -8
  920. package/dist/bundle/chunks/chunk-EHXIMSVW.js +0 -15
  921. package/dist/bundle/chunks/chunk-F2PTB6MB.js +0 -5
  922. package/dist/bundle/chunks/chunk-FTXRTVTE.js +0 -4
  923. package/dist/bundle/chunks/chunk-GNLJZOAK.js +0 -4
  924. package/dist/bundle/chunks/chunk-HACWJFGU.js +0 -1
  925. package/dist/bundle/chunks/chunk-HH6GYTGE.js +0 -13
  926. package/dist/bundle/chunks/chunk-HHGXJW4R.js +0 -6
  927. package/dist/bundle/chunks/chunk-HKR53LNA.js +0 -2
  928. package/dist/bundle/chunks/chunk-HZSJHPS7.js +0 -1
  929. package/dist/bundle/chunks/chunk-I3XSMOC3.js +0 -12
  930. package/dist/bundle/chunks/chunk-IYJXP33F.js +0 -1
  931. package/dist/bundle/chunks/chunk-JKPRCVTG.js +0 -6
  932. package/dist/bundle/chunks/chunk-K5ZCP6UY.js +0 -62
  933. package/dist/bundle/chunks/chunk-KMP3F7WZ.js +0 -17
  934. package/dist/bundle/chunks/chunk-KNKWEAIB.js +0 -4
  935. package/dist/bundle/chunks/chunk-KNU7V7YY.js +0 -8
  936. package/dist/bundle/chunks/chunk-KY5NMRVZ.js +0 -4
  937. package/dist/bundle/chunks/chunk-LHCQ2NLV.js +0 -6
  938. package/dist/bundle/chunks/chunk-M732FP7L.js +0 -2
  939. package/dist/bundle/chunks/chunk-MWKKYA7N.js +0 -19
  940. package/dist/bundle/chunks/chunk-MXTZUALD.js +0 -8
  941. package/dist/bundle/chunks/chunk-N52SZCYB.js +0 -2
  942. package/dist/bundle/chunks/chunk-N5W4XZNS.js +0 -32
  943. package/dist/bundle/chunks/chunk-NFM234IX.js +0 -23
  944. package/dist/bundle/chunks/chunk-NMWKV3TE.js +0 -9
  945. package/dist/bundle/chunks/chunk-O3BQP2BR.js +0 -7
  946. package/dist/bundle/chunks/chunk-ODBLLQG2.js +0 -35
  947. package/dist/bundle/chunks/chunk-OQWK6IJW.js +0 -1
  948. package/dist/bundle/chunks/chunk-OR2BZKU5.js +0 -31
  949. package/dist/bundle/chunks/chunk-OSYWE22E.js +0 -6
  950. package/dist/bundle/chunks/chunk-PJV5BSDQ.js +0 -8
  951. package/dist/bundle/chunks/chunk-PUYKMBEQ.js +0 -3
  952. package/dist/bundle/chunks/chunk-PXCZA2UF.js +0 -2
  953. package/dist/bundle/chunks/chunk-QDJ7TVPH.js +0 -2
  954. package/dist/bundle/chunks/chunk-QIE3SEPQ.js +0 -12
  955. package/dist/bundle/chunks/chunk-QIKTQFYF.js +0 -22
  956. package/dist/bundle/chunks/chunk-RDRBPOO3.js +0 -4
  957. package/dist/bundle/chunks/chunk-RO3SVOT2.js +0 -16
  958. package/dist/bundle/chunks/chunk-RQ7EV7AC.js +0 -7
  959. package/dist/bundle/chunks/chunk-RTIOH4X2.js +0 -1
  960. package/dist/bundle/chunks/chunk-RX22KJ4J.js +0 -10
  961. package/dist/bundle/chunks/chunk-SMDXZHIL.js +0 -8
  962. package/dist/bundle/chunks/chunk-SVBJBJ5T.js +0 -6
  963. package/dist/bundle/chunks/chunk-SYMUCSH2.js +0 -5
  964. package/dist/bundle/chunks/chunk-TPMG4TM3.js +0 -286
  965. package/dist/bundle/chunks/chunk-TYRM7VD4.js +0 -8
  966. package/dist/bundle/chunks/chunk-UL3YZMPQ.js +0 -8
  967. package/dist/bundle/chunks/chunk-V2LCHTLH.js +0 -15
  968. package/dist/bundle/chunks/chunk-V2U6WR7A.js +0 -11
  969. package/dist/bundle/chunks/chunk-WLD7KZYW.js +0 -6
  970. package/dist/bundle/chunks/chunk-WTU2M6ZH.js +0 -1
  971. package/dist/bundle/chunks/chunk-XG2PXUNT.js +0 -7
  972. package/dist/bundle/chunks/chunk-XREOVOVJ.js +0 -20
  973. package/dist/bundle/chunks/chunk-Y33UPDYF.js +0 -23
  974. package/dist/bundle/chunks/chunk-ZMLEPT2B.js +0 -2
  975. package/dist/bundle/chunks/chunk-ZVA3RKAH.js +0 -11
  976. package/dist/bundle/chunks/clear-AQF5Q2LP.js +0 -1
  977. package/dist/bundle/chunks/column-DTV4DT7Z.js +0 -1
  978. package/dist/bundle/chunks/comm-XNF4ZFIQ.js +0 -1
  979. package/dist/bundle/chunks/cp-O5R6UUTB.js +0 -1
  980. package/dist/bundle/chunks/curl-YF5UPZSP.js +0 -25
  981. package/dist/bundle/chunks/cut-A6AD4XLN.js +0 -1
  982. package/dist/bundle/chunks/date-5DATBXSY.js +0 -1
  983. package/dist/bundle/chunks/diff-4RUNUODF.js +0 -1
  984. package/dist/bundle/chunks/dirname-UXBVN4ZU.js +0 -1
  985. package/dist/bundle/chunks/du-URMOHN4N.js +0 -1
  986. package/dist/bundle/chunks/echo-BU4WS5NB.js +0 -1
  987. package/dist/bundle/chunks/env-PRCSFHFD.js +0 -1
  988. package/dist/bundle/chunks/expand-RSU7HJNU.js +0 -1
  989. package/dist/bundle/chunks/expansion-TBT2U5OQ.js +0 -1
  990. package/dist/bundle/chunks/expr-WHQ3N3VC.js +0 -1
  991. package/dist/bundle/chunks/file-OCSDEMRX.js +0 -1
  992. package/dist/bundle/chunks/find-KQBG3YXR.js +0 -1
  993. package/dist/bundle/chunks/flag-coverage-ZFQWXDD4.js +0 -1
  994. package/dist/bundle/chunks/fold-4XHCZTIH.js +0 -1
  995. package/dist/bundle/chunks/grep-MTDYJMIU.js +0 -1
  996. package/dist/bundle/chunks/gzip-JISR2QXU.js +0 -1
  997. package/dist/bundle/chunks/head-25BYUDHC.js +0 -1
  998. package/dist/bundle/chunks/help-A3QG3UR4.js +0 -1
  999. package/dist/bundle/chunks/history-GTNR2KMK.js +0 -1
  1000. package/dist/bundle/chunks/hostname-4YOTMKM4.js +0 -1
  1001. package/dist/bundle/chunks/html-to-markdown-3JPCPF2J.js +0 -1
  1002. package/dist/bundle/chunks/join-KEFNDBL6.js +0 -1
  1003. package/dist/bundle/chunks/jq-EBNRPZT5.js +0 -1
  1004. package/dist/bundle/chunks/ln-TBYICXCX.js +0 -1
  1005. package/dist/bundle/chunks/ls-C7B2SA5A.js +0 -1
  1006. package/dist/bundle/chunks/md5sum-2VY2ODII.js +0 -1
  1007. package/dist/bundle/chunks/mkdir-ZLWSOZZZ.js +0 -1
  1008. package/dist/bundle/chunks/mv-VA4VIZE2.js +0 -1
  1009. package/dist/bundle/chunks/nl-VNFLBUHM.js +0 -1
  1010. package/dist/bundle/chunks/od-3KUUCW5I.js +0 -1
  1011. package/dist/bundle/chunks/paste-5WOFHNWA.js +0 -1
  1012. package/dist/bundle/chunks/printf-U3U7M7RB.js +0 -1
  1013. package/dist/bundle/chunks/pwd-QYQ4FLB5.js +0 -1
  1014. package/dist/bundle/chunks/python3-NDB2XLKG.js +0 -13
  1015. package/dist/bundle/chunks/readlink-B3Y2BKAH.js +0 -1
  1016. package/dist/bundle/chunks/rev-ROSGTRA6.js +0 -1
  1017. package/dist/bundle/chunks/rg-F5QIE3YM.js +0 -1
  1018. package/dist/bundle/chunks/rm-7JBDYEU5.js +0 -1
  1019. package/dist/bundle/chunks/rmdir-A2RQAESC.js +0 -1
  1020. package/dist/bundle/chunks/sed-T3Z6L6KJ.js +0 -1
  1021. package/dist/bundle/chunks/seq-JDQVNKUK.js +0 -1
  1022. package/dist/bundle/chunks/sha1sum-DQ6NXZL5.js +0 -1
  1023. package/dist/bundle/chunks/sha256sum-OHTALYKZ.js +0 -1
  1024. package/dist/bundle/chunks/sleep-T43AU6EO.js +0 -1
  1025. package/dist/bundle/chunks/sort-NBGMSGSP.js +0 -1
  1026. package/dist/bundle/chunks/split-KHHBFS6N.js +0 -1
  1027. package/dist/bundle/chunks/sqlite3-XSQIVKH7.js +0 -1
  1028. package/dist/bundle/chunks/stat-LL77MZ57.js +0 -1
  1029. package/dist/bundle/chunks/strings-UEBU67ZB.js +0 -1
  1030. package/dist/bundle/chunks/tac-GPG772JP.js +0 -1
  1031. package/dist/bundle/chunks/tail-Z2TRGEQE.js +0 -1
  1032. package/dist/bundle/chunks/tar-3BUIIPMD.js +0 -1
  1033. package/dist/bundle/chunks/tee-ZZKDAZU6.js +0 -1
  1034. package/dist/bundle/chunks/time-66YFGDFJ.js +0 -1
  1035. package/dist/bundle/chunks/timeout-QN47GEC7.js +0 -1
  1036. package/dist/bundle/chunks/touch-BOVDTDEU.js +0 -1
  1037. package/dist/bundle/chunks/tr-LEOUNZSP.js +0 -1
  1038. package/dist/bundle/chunks/tree-OLQFL5TR.js +0 -1
  1039. package/dist/bundle/chunks/true-3GSKFWKO.js +0 -1
  1040. package/dist/bundle/chunks/unexpand-AV4WTA4X.js +0 -1
  1041. package/dist/bundle/chunks/uniq-RBOLK7C3.js +0 -1
  1042. package/dist/bundle/chunks/wc-VYPMUZSO.js +0 -1
  1043. package/dist/bundle/chunks/which-6QROVGQN.js +0 -1
  1044. package/dist/bundle/chunks/whoami-NJ6ZQ54Y.js +0 -1
  1045. package/dist/bundle/chunks/xan-IVSICJOO.js +0 -1
  1046. package/dist/bundle/chunks/xan-view-JIIHMXCO.js +0 -1
  1047. package/dist/bundle/chunks/xargs-QQG6OLB3.js +0 -1
  1048. package/dist/bundle/chunks/yes-JBIBIE7V.js +0 -1
  1049. package/dist/bundle/chunks/yq-RIVAIAQ2.js +0 -1
@@ -1,157 +1,148 @@
1
- import{A as Ss,C as zr,D as Wr,E as ge,F as Ze,G as ae,H as xe,I as Ft,J as Vr,K as V,L as Br,M as jr,N as Ie,O as $s,P as Lt,Q as tt,R as K,a as Nr,b as gs,c as Tr,d as Or,e as Rt,f as ne,g as Z,h as Te,i as ce,j as Oe,k as je,l as ws,m as Mt,n as Dr,o as vs,p as Ir,q as ye,r as Le,s as Rr,t as Mr,u as bs,v as Es,w as De,x as Fr,y as Lr,z as Ce}from"./chunks/chunk-6BNDUHW7.js";import{a as xr}from"./chunks/chunk-MIFIRXNI.js";import{a as Be,b as _e}from"./chunks/chunk-UBLR5ACC.js";import{a as bt}from"./chunks/chunk-XYWNAVNS.js";import{a as Ee,b as Se,c as me,d as Ae,e as _r,f as Y,g as qe,h as Ot,i as Dt,j as Cr,k as de,l as Ve,m as It,n as ke}from"./chunks/chunk-O3BQP2BR.js";import"./chunks/chunk-NUFRM6SI.js";import{a as Fe}from"./chunks/chunk-44UOCSGV.js";import{a as et,b as w,c as se,d as he,e as C,f as H,g as Ge,h as O,i as Tt,j as ys,k as ki,l as _i,m as Ci}from"./chunks/chunk-2ERMTDAT.js";import{a as vt,g as F,h as B,i as j,j as Ar,k as Je,l as T,m as g,n as kr}from"./chunks/chunk-DEQBZDPB.js";var Xe=[{name:"echo",load:async()=>(await import("./chunks/echo-BU4WS5NB.js")).echoCommand},{name:"cat",load:async()=>(await import("./chunks/cat-VI6AVTST.js")).catCommand},{name:"printf",load:async()=>(await import("./chunks/printf-U3U7M7RB.js")).printfCommand},{name:"ls",load:async()=>(await import("./chunks/ls-C7B2SA5A.js")).lsCommand},{name:"mkdir",load:async()=>(await import("./chunks/mkdir-ZLWSOZZZ.js")).mkdirCommand},{name:"rmdir",load:async()=>(await import("./chunks/rmdir-A2RQAESC.js")).rmdirCommand},{name:"touch",load:async()=>(await import("./chunks/touch-BOVDTDEU.js")).touchCommand},{name:"rm",load:async()=>(await import("./chunks/rm-7JBDYEU5.js")).rmCommand},{name:"cp",load:async()=>(await import("./chunks/cp-O5R6UUTB.js")).cpCommand},{name:"mv",load:async()=>(await import("./chunks/mv-VA4VIZE2.js")).mvCommand},{name:"ln",load:async()=>(await import("./chunks/ln-TBYICXCX.js")).lnCommand},{name:"chmod",load:async()=>(await import("./chunks/chmod-5F3XJPPG.js")).chmodCommand},{name:"pwd",load:async()=>(await import("./chunks/pwd-QYQ4FLB5.js")).pwdCommand},{name:"readlink",load:async()=>(await import("./chunks/readlink-B3Y2BKAH.js")).readlinkCommand},{name:"head",load:async()=>(await import("./chunks/head-25BYUDHC.js")).headCommand},{name:"tail",load:async()=>(await import("./chunks/tail-Z2TRGEQE.js")).tailCommand},{name:"wc",load:async()=>(await import("./chunks/wc-VYPMUZSO.js")).wcCommand},{name:"stat",load:async()=>(await import("./chunks/stat-LL77MZ57.js")).statCommand},{name:"grep",load:async()=>(await import("./chunks/grep-MTDYJMIU.js")).grepCommand},{name:"fgrep",load:async()=>(await import("./chunks/grep-MTDYJMIU.js")).fgrepCommand},{name:"egrep",load:async()=>(await import("./chunks/grep-MTDYJMIU.js")).egrepCommand},{name:"rg",load:async()=>(await import("./chunks/rg-F5QIE3YM.js")).rgCommand},{name:"sed",load:async()=>(await import("./chunks/sed-T3Z6L6KJ.js")).sedCommand},{name:"awk",load:async()=>(await import("./chunks/awk2-HG7QFRRO.js")).awkCommand2},{name:"sort",load:async()=>(await import("./chunks/sort-NBGMSGSP.js")).sortCommand},{name:"uniq",load:async()=>(await import("./chunks/uniq-RBOLK7C3.js")).uniqCommand},{name:"comm",load:async()=>(await import("./chunks/comm-XNF4ZFIQ.js")).commCommand},{name:"cut",load:async()=>(await import("./chunks/cut-A6AD4XLN.js")).cutCommand},{name:"paste",load:async()=>(await import("./chunks/paste-5WOFHNWA.js")).pasteCommand},{name:"tr",load:async()=>(await import("./chunks/tr-LEOUNZSP.js")).trCommand},{name:"rev",load:async()=>(await import("./chunks/rev-ROSGTRA6.js")).rev},{name:"nl",load:async()=>(await import("./chunks/nl-VNFLBUHM.js")).nl},{name:"fold",load:async()=>(await import("./chunks/fold-4XHCZTIH.js")).fold},{name:"expand",load:async()=>(await import("./chunks/expand-RSU7HJNU.js")).expand},{name:"unexpand",load:async()=>(await import("./chunks/unexpand-AV4WTA4X.js")).unexpand},{name:"strings",load:async()=>(await import("./chunks/strings-UEBU67ZB.js")).strings},{name:"split",load:async()=>(await import("./chunks/split-KHHBFS6N.js")).split},{name:"column",load:async()=>(await import("./chunks/column-DTV4DT7Z.js")).column},{name:"join",load:async()=>(await import("./chunks/join-KEFNDBL6.js")).join},{name:"tee",load:async()=>(await import("./chunks/tee-ZZKDAZU6.js")).teeCommand},{name:"find",load:async()=>(await import("./chunks/find-KQBG3YXR.js")).findCommand},{name:"basename",load:async()=>(await import("./chunks/basename-PRS2OP6R.js")).basenameCommand},{name:"dirname",load:async()=>(await import("./chunks/dirname-UXBVN4ZU.js")).dirnameCommand},{name:"tree",load:async()=>(await import("./chunks/tree-OLQFL5TR.js")).treeCommand},{name:"du",load:async()=>(await import("./chunks/du-URMOHN4N.js")).duCommand},{name:"env",load:async()=>(await import("./chunks/env-PRCSFHFD.js")).envCommand},{name:"printenv",load:async()=>(await import("./chunks/env-PRCSFHFD.js")).printenvCommand},{name:"alias",load:async()=>(await import("./chunks/alias-PFS6JBTL.js")).aliasCommand},{name:"unalias",load:async()=>(await import("./chunks/alias-PFS6JBTL.js")).unaliasCommand},{name:"history",load:async()=>(await import("./chunks/history-GTNR2KMK.js")).historyCommand},{name:"xargs",load:async()=>(await import("./chunks/xargs-QQG6OLB3.js")).xargsCommand},{name:"true",load:async()=>(await import("./chunks/true-3GSKFWKO.js")).trueCommand},{name:"false",load:async()=>(await import("./chunks/true-3GSKFWKO.js")).falseCommand},{name:"clear",load:async()=>(await import("./chunks/clear-AQF5Q2LP.js")).clearCommand},{name:"yes",load:async()=>(await import("./chunks/yes-JBIBIE7V.js")).yesCommand},{name:"bash",load:async()=>(await import("./chunks/bash-UQXFZUPD.js")).bashCommand},{name:"sh",load:async()=>(await import("./chunks/bash-UQXFZUPD.js")).shCommand},{name:"jq",load:async()=>(await import("./chunks/jq-EBNRPZT5.js")).jqCommand},{name:"base64",load:async()=>(await import("./chunks/base64-UOYRM4DO.js")).base64Command},{name:"diff",load:async()=>(await import("./chunks/diff-4RUNUODF.js")).diffCommand},{name:"date",load:async()=>(await import("./chunks/date-5DATBXSY.js")).dateCommand},{name:"sleep",load:async()=>(await import("./chunks/sleep-T43AU6EO.js")).sleepCommand},{name:"timeout",load:async()=>(await import("./chunks/timeout-QN47GEC7.js")).timeoutCommand},{name:"time",load:async()=>(await import("./chunks/time-66YFGDFJ.js")).timeCommand},{name:"seq",load:async()=>(await import("./chunks/seq-JDQVNKUK.js")).seqCommand},{name:"expr",load:async()=>(await import("./chunks/expr-WHQ3N3VC.js")).exprCommand},{name:"md5sum",load:async()=>(await import("./chunks/md5sum-2VY2ODII.js")).md5sumCommand},{name:"sha1sum",load:async()=>(await import("./chunks/sha1sum-DQ6NXZL5.js")).sha1sumCommand},{name:"sha256sum",load:async()=>(await import("./chunks/sha256sum-OHTALYKZ.js")).sha256sumCommand},{name:"file",load:async()=>(await import("./chunks/file-OCSDEMRX.js")).fileCommand},{name:"html-to-markdown",load:async()=>(await import("./chunks/html-to-markdown-3JPCPF2J.js")).htmlToMarkdownCommand},{name:"help",load:async()=>(await import("./chunks/help-A3QG3UR4.js")).helpCommand},{name:"which",load:async()=>(await import("./chunks/which-6QROVGQN.js")).whichCommand},{name:"tac",load:async()=>(await import("./chunks/tac-GPG772JP.js")).tac},{name:"hostname",load:async()=>(await import("./chunks/hostname-4YOTMKM4.js")).hostname},{name:"whoami",load:async()=>(await import("./chunks/whoami-NJ6ZQ54Y.js")).whoami},{name:"od",load:async()=>(await import("./chunks/od-3KUUCW5I.js")).od},{name:"gzip",load:async()=>(await import("./chunks/gzip-JISR2QXU.js")).gzipCommand},{name:"gunzip",load:async()=>(await import("./chunks/gzip-JISR2QXU.js")).gunzipCommand},{name:"zcat",load:async()=>(await import("./chunks/gzip-JISR2QXU.js")).zcatCommand}];(typeof __BROWSER__>"u"||!__BROWSER__)&&(Xe.push({name:"tar",load:async()=>(await import("./chunks/tar-3BUIIPMD.js")).tarCommand}),Xe.push({name:"yq",load:async()=>(await import("./chunks/yq-RIVAIAQ2.js")).yqCommand}),Xe.push({name:"xan",load:async()=>(await import("./chunks/xan-IVSICJOO.js")).xanCommand}),Xe.push({name:"sqlite3",load:async()=>(await import("./chunks/sqlite3-XSQIVKH7.js")).sqlite3Command}));var zt=[];(typeof __BROWSER__>"u"||!__BROWSER__)&&(zt.push({name:"python3",load:async()=>(await import("./chunks/python3-NDB2XLKG.js")).python3Command}),zt.push({name:"python",load:async()=>(await import("./chunks/python3-NDB2XLKG.js")).pythonCommand}));var Hr=[{name:"curl",load:async()=>(await import("./chunks/curl-YF5UPZSP.js")).curlCommand}],Ur=new Map;function Ps(e){return{name:e.name,async execute(t,s){let r=Ur.get(e.name);if(r||(r=await e.load(),Ur.set(e.name,r)),s.coverage&&(typeof __BROWSER__>"u"||!__BROWSER__)){let{emitFlagCoverage:n}=await import("./chunks/flag-coverage-ZFQWXDD4.js"),{decodeArgs:i}=await import("./chunks/bytes-JUNATFIO.js");n(s.coverage,e.name,i(t))}return r.execute(t,s)}}}function xi(){return Xe.map(e=>e.name)}function Ni(){return Hr.map(e=>e.name)}function Gr(e){return(e?Xe.filter(s=>e.includes(s.name)):Xe).map(Ps)}function qr(){return Hr.map(Ps)}function Ti(){return zt.map(e=>e.name)}function Zr(){return zt.map(Ps)}function Xr(e){return"load"in e&&typeof e.load=="function"}function Oi(e,t){return{name:e,async execute(s,r){let n={...r,env:kr(r.env)},i=await t(Je(s),n);return typeof i.stdout=="string"?{stdout:C(i.stdout),stderr:C(i.stderr),exitCode:i.exitCode}:i}}}function Yr(e){let t=null;return{name:e.name,async execute(s,r){return t||(t=await e.load()),t.execute(s,r)}}}var Di=new TextEncoder;function Ii(e){return typeof e=="object"&&e!==null&&typeof e.getReader=="function"}function Ri(e,t){if(e instanceof Uint8Array)return e;if(t==="base64")return Uint8Array.from(atob(e),s=>s.charCodeAt(0));if(t==="hex"){let s=new Uint8Array(e.length/2);for(let r=0;r<e.length;r+=2)s[r/2]=parseInt(e.slice(r,r+2),16);return s}if(t==="binary"||t==="latin1"){if(e.length<=65536)return Uint8Array.from(e,n=>n.charCodeAt(0));let r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r}return Di.encode(e)}function Qr(e){if(e.length===0)return[];if(e.length<=et)return[e];let t=[];for(let s=0;s<e.length;s+=et)t.push(e.subarray(s,Math.min(s+et,e.length)));return t}function st(e,t){let s=Ri(e,t);return{chunks:Qr(s),size:s.length}}async function ze(e,t){if(Ii(e)){let s=[],r=0;for await(let n of ys(e))if(n.length<=et)s.push(n),r+=n.length;else for(let i of Qr(n))s.push(i),r+=i.length;return{chunks:s,size:r}}return st(e,t)}function Wt(e,t){if(t==="base64")return btoa(xr(Kr(e)));if(t==="hex"){let n="";for(let i of e)for(let o=0;o<i.length;o++)n+=i[o].toString(16).padStart(2,"0");return n}if(t==="binary"||t==="latin1"){if(typeof Buffer<"u")return Buffer.from(Kr(e)).toString(t);let n=65536,i="";for(let o of e)if(o.length<=n)i+=String.fromCharCode(...o);else for(let a=0;a<o.length;a+=n){let l=o.subarray(a,a+n);i+=String.fromCharCode(...l)}return i}let s=new TextDecoder,r="";for(let n of e)n.length>0&&(r+=s.decode(n,{stream:!0}));return r+=s.decode(),r}function Kr(e){let t=0;for(let n of e)t+=n.length;if(t===0)return new Uint8Array(0);if(e.length===1)return e[0];let s=new Uint8Array(t),r=0;for(let n of e)s.set(n,r),r+=n.length;return s}function $e(e){if(e!=null)return typeof e=="string"?e:e.encoding??void 0}function rt(e,t){if(!Number.isFinite(e)||!Number.isInteger(e)||e<0)throw new Error(`EINVAL: invalid offset (must be a non-negative integer): ${e}`);if(!Number.isFinite(t)||!Number.isInteger(t)||t<0)throw new Error(`EINVAL: invalid length (must be a non-negative integer): ${t}`)}function Vt(e,t,s,r){if(s>=t||r===0)return new Uint8Array(0);let n=Math.min(s+r,t),i=n-s,o=new Uint8Array(i),a=0,l=0;for(let u of e){if(a>=i)break;let c=l+u.length;if(c>s&&l<n){let f=Math.max(0,s-l),h=Math.min(u.length,n-l),d=u.subarray(f,h);o.set(d,a),a+=d.length}l=c}return o}function Mi(e){return typeof e=="object"&&e!==null&&!(e instanceof Uint8Array)&&!(e instanceof ReadableStream)&&"content"in e}function ie(e,t){if(e.includes("\0"))throw new Error(`ENOENT: path contains null byte, ${t} '${e}'`)}var We=class{data=new Map;constructor(t){if(this.data.set("/",{type:"directory",mode:493,mtime:new Date}),t)for(let[s,r]of Object.entries(t))if(Mi(r)){if(r.content instanceof ReadableStream)throw new Error("InMemoryFs: streams not supported in InitialFiles; use writeFile() after construction");this.writeFileSync(s,r.content,void 0,{mode:r.mode,mtime:r.mtime})}else{if(r instanceof ReadableStream)throw new Error("InMemoryFs: streams not supported in InitialFiles; use writeFile() after construction");this.writeFileSync(s,r)}}normalizePath(t){if(!t||t==="/")return"/";let s=t.endsWith("/")&&t!=="/"?t.slice(0,-1):t;s.startsWith("/")||(s=`/${s}`);let r=s.split("/").filter(i=>i&&i!=="."),n=[];for(let i of r)i===".."?n.pop():n.push(i);return`/${n.join("/")}`||"/"}dirname(t){let s=this.normalizePath(t);if(s==="/")return"/";let r=s.lastIndexOf("/");return r===0?"/":s.slice(0,r)}ensureParentDirs(t){let s=this.dirname(t);s!=="/"&&(this.data.has(s)||(this.ensureParentDirs(s),this.data.set(s,{type:"directory",mode:493,mtime:new Date})))}writeFileSync(t,s,r,n){ie(t,"write");let i=this.normalizePath(t);this.ensureParentDirs(i);let o=$e(r),{chunks:a,size:l}=st(s,o);this.data.set(i,{type:"file",chunks:a,size:l,mode:n?.mode??420,mtime:n?.mtime??new Date})}async readFile(t){ie(t,"open");let s=this.resolvePathWithSymlinks(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, open '${t}'`);if(r.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);return he(r.chunks)}async readRange(t,s,r){rt(s,r),ie(t,"open");let n=this.resolvePathWithSymlinks(t),i=this.data.get(n);if(!i)throw new Error(`ENOENT: no such file or directory, open '${t}'`);if(i.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);return Vt(i.chunks,i.size,s,r)}async readFileText(t,s){ie(t,"open");let r=this.resolvePathWithSymlinks(t),n=this.data.get(r);if(!n)throw new Error(`ENOENT: no such file or directory, open '${t}'`);if(n.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);let i=$e(s);return Wt(n.chunks,i)}async writeFile(t,s,r){ie(t,"write");let n=this.normalizePath(t);this.ensureParentDirs(n);let i=$e(r),{chunks:o,size:a}=await ze(s,i);this.data.set(n,{type:"file",chunks:o,size:a,mode:420,mtime:new Date})}async appendFile(t,s,r){ie(t,"append");let n=this.normalizePath(t),i=this.data.get(n);if(i&&i.type==="directory")throw new Error(`EISDIR: illegal operation on a directory, write '${t}'`);let o=$e(r),{chunks:a,size:l}=await ze(s,o);i?.type==="file"?this.data.set(n,{type:"file",chunks:[...i.chunks,...a],size:i.size+l,mode:i.mode,mtime:new Date}):(this.ensureParentDirs(n),this.data.set(n,{type:"file",chunks:a,size:l,mode:420,mtime:new Date}))}async exists(t){if(t.includes("\0"))return!1;try{let s=this.resolvePathWithSymlinks(t);return this.data.has(s)}catch{return!1}}async stat(t){ie(t,"stat");let s=this.resolvePathWithSymlinks(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, stat '${t}'`);let n=0;return r.type==="file"&&(n=r.size),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:n,mtime:r.mtime||new Date}}async lstat(t){ie(t,"lstat");let s=this.resolveIntermediateSymlinks(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, lstat '${t}'`);if(r.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:r.mode,size:r.target.length,mtime:r.mtime||new Date};let n=0;return r.type==="file"&&(n=r.size),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:n,mtime:r.mtime||new Date}}resolveSymlink(t,s){if(s.startsWith("/"))return this.normalizePath(s);let r=this.dirname(t);return this.normalizePath(r==="/"?`/${s}`:`${r}/${s}`)}resolveIntermediateSymlinks(t){let s=this.normalizePath(t);if(s==="/")return"/";let r=s.slice(1).split("/");if(r.length<=1)return s;let n="",i=new Set;for(let o=0;o<r.length-1;o++){let a=r[o];n=`${n}/${a}`;let l=this.data.get(n),u=0,c=40;for(;l&&l.type==="symlink"&&u<c;){if(i.has(n))throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`);i.add(n),n=this.resolveSymlink(n,l.target),l=this.data.get(n),u++}if(u>=c)throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`)}return`${n}/${r[r.length-1]}`}resolvePathWithSymlinks(t){let s=this.normalizePath(t);if(s==="/")return"/";let r=s.slice(1).split("/"),n="",i=new Set;for(let o of r){n=`${n}/${o}`;let a=this.data.get(n),l=0,u=40;for(;a&&a.type==="symlink"&&l<u;){if(i.has(n))throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`);i.add(n),n=this.resolveSymlink(n,a.target),a=this.data.get(n),l++}if(l>=u)throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`)}return n}async mkdir(t,s){this.mkdirSync(t,s)}mkdirSync(t,s){ie(t,"mkdir");let r=this.normalizePath(t);if(this.data.has(r)){if(this.data.get(r)?.type==="file")throw new Error(`EEXIST: file already exists, mkdir '${t}'`);if(!s?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${t}'`);return}let n=this.dirname(r);if(n!=="/"&&!this.data.has(n))if(s?.recursive)this.mkdirSync(n,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${t}'`);this.data.set(r,{type:"directory",mode:493,mtime:new Date})}async readdir(t){return(await this.readdirWithFileTypes(t)).map(r=>r.name)}async readdirWithFileTypes(t){ie(t,"scandir");let s=this.normalizePath(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);let n=new Set;for(;r&&r.type==="symlink";){if(n.has(s))throw new Error(`ELOOP: too many levels of symbolic links, scandir '${t}'`);n.add(s),s=this.resolveSymlink(s,r.target),r=this.data.get(s)}if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);if(r.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${t}'`);let i=s==="/"?"/":`${s}/`,o=new Map;for(let[a,l]of this.data.entries())if(a!==s&&a.startsWith(i)){let u=a.slice(i.length),c=u.split("/")[0];c&&!u.includes("/",c.length)&&!o.has(c)&&o.set(c,{name:c,isFile:l.type==="file",isDirectory:l.type==="directory",isSymbolicLink:l.type==="symlink"})}return Array.from(o.values()).sort((a,l)=>a.name<l.name?-1:a.name>l.name?1:0)}async rm(t,s){ie(t,"rm");let r=this.normalizePath(t),n=this.data.get(r);if(!n){if(s?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${t}'`)}if(n.type==="directory"){let i=await this.readdir(r);if(i.length>0){if(!s?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${t}'`);for(let o of i){let a=r==="/"?`/${o}`:`${r}/${o}`;await this.rm(a,s)}}}this.data.delete(r)}async cp(t,s,r){ie(t,"cp"),ie(s,"cp");let n=this.normalizePath(t),i=this.normalizePath(s),o=this.data.get(n);if(!o)throw new Error(`ENOENT: no such file or directory, cp '${t}'`);if(o.type==="file")this.ensureParentDirs(i),this.data.set(i,{type:"file",chunks:[...o.chunks],size:o.size,mode:o.mode,mtime:o.mtime});else if(o.type==="directory"){if(!r?.recursive)throw new Error(`EISDIR: is a directory, cp '${t}'`);await this.mkdir(i,{recursive:!0});let a=await this.readdir(n);for(let l of a){let u=n==="/"?`/${l}`:`${n}/${l}`,c=i==="/"?`/${l}`:`${i}/${l}`;await this.cp(u,c,r)}}}async mv(t,s){await this.cp(t,s,{recursive:!0}),await this.rm(t,{recursive:!0})}getAllPaths(){return Array.from(this.data.keys())}resolvePath(t,s){if(s.startsWith("/"))return this.normalizePath(s);let r=t==="/"?`/${s}`:`${t}/${s}`;return this.normalizePath(r)}async chmod(t,s){ie(t,"chmod");let r=this.normalizePath(t),n=this.data.get(r);if(!n)throw new Error(`ENOENT: no such file or directory, chmod '${t}'`);n.mode=s}async symlink(t,s){ie(s,"symlink");let r=this.normalizePath(s);if(this.data.has(r))throw new Error(`EEXIST: file already exists, symlink '${s}'`);this.ensureParentDirs(r),this.data.set(r,{type:"symlink",target:t,mode:511,mtime:new Date})}async link(t,s){ie(t,"link"),ie(s,"link");let r=this.normalizePath(t),n=this.normalizePath(s),i=this.data.get(r);if(!i)throw new Error(`ENOENT: no such file or directory, link '${t}'`);if(i.type!=="file")throw new Error(`EPERM: operation not permitted, link '${t}'`);if(this.data.has(n))throw new Error(`EEXIST: file already exists, link '${s}'`);this.ensureParentDirs(n),this.data.set(n,{type:"file",chunks:[...i.chunks],size:i.size,mode:i.mode,mtime:i.mtime})}async readlink(t){ie(t,"readlink");let s=this.normalizePath(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, readlink '${t}'`);if(r.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${t}'`);return r.target}async realpath(t){ie(t,"realpath");let s=this.resolvePathWithSymlinks(t);if(!this.data.has(s))throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);return s}async utimes(t,s,r){ie(t,"utimes");let n=this.normalizePath(t),i=this.resolvePathWithSymlinks(n),o=this.data.get(i);if(!o)throw new Error(`ENOENT: no such file or directory, utimes '${t}'`);o.mtime=r}};function Fi(e){let t=e;return typeof t.mkdirSync=="function"&&typeof t.writeFileSync=="function"}function Li(e,t){e.mkdirSync("/bin",{recursive:!0}),e.mkdirSync("/usr/bin",{recursive:!0}),t&&(e.mkdirSync("/home/user",{recursive:!0}),e.mkdirSync("/tmp",{recursive:!0}))}function zi(e){e.mkdirSync("/dev",{recursive:!0}),e.writeFileSync("/dev/null",""),e.writeFileSync("/dev/zero",new Uint8Array(0)),e.writeFileSync("/dev/stdin",""),e.writeFileSync("/dev/stdout",""),e.writeFileSync("/dev/stderr","")}function Wi(e){e.mkdirSync("/proc/self/fd",{recursive:!0}),e.writeFileSync("/proc/version",`${Nr}
1
+ import{$ as An,A as qs,B as rs,C as yn,D as Zs,E as gn,F as Ee,G as qe,H as wn,I as vn,J as Xs,K as Js,L as ze,M as bn,N as En,O as Ie,P as Ks,R as Sn,S as $n,T as Se,U as ot,V as de,W as Re,X as ns,Y as Pn,Z as z,_ as Cn,a as hn,aa as je,b as Us,ba as kn,c as pn,ca as xn,d as mn,da as pt,e as ts,ea as ee,f as ce,g as X,h as Fe,i as ss,j as it,k as Gs,l as Hs,m as We,n as Lt,o as Ft,p as G,q as _e,r as K,s as Wt,t as Y,u as te,v as Qe,w as se,x as me,y as Ve,z as et}from"./chunks/chunk-S6UKQQAB.js";import{a as Mt}from"./chunks/chunk-VAEB4OUK.js";import{a as dn}from"./chunks/chunk-MIFIRXNI.js";import{a as Ye,b as xe}from"./chunks/chunk-UBLR5ACC.js";import{a as Rt}from"./chunks/chunk-XYWNAVNS.js";import{a as Ce,b as Ae,c as ve,d as ke,e as cn,f as q,g as nt,h as It,i as Qt,j as un,k as ae,l as fn,m as pe,n as Ke,o as Ge,p as es,q as be}from"./chunks/chunk-BX5K34KY.js";import"./chunks/chunk-NUFRM6SI.js";import{a as He}from"./chunks/chunk-44UOCSGV.js";import{a as dt,b as S,d as fe,e as ht,f as V,g as re,h as Yt,i as rt,j as fo,k as Bs,l as ho,m as po,n as mo}from"./chunks/chunk-KL7SL7ES.js";import{a as Dt,g as R,h as W,i as B,j as an,k as ft,l as T,m as g,n as ln}from"./chunks/chunk-DEQBZDPB.js";var at=[{name:"echo",load:async()=>(await import("./chunks/echo-PC3TVS6B.js")).echoCommand},{name:"cat",load:async()=>(await import("./chunks/cat-L3YELBYM.js")).catCommand},{name:"printf",load:async()=>(await import("./chunks/printf-6XMXHDAE.js")).printfCommand},{name:"ls",load:async()=>(await import("./chunks/ls-7JNJXADY.js")).lsCommand},{name:"mkdir",load:async()=>(await import("./chunks/mkdir-NM4BUUUC.js")).mkdirCommand},{name:"rmdir",load:async()=>(await import("./chunks/rmdir-Z4ZRV32S.js")).rmdirCommand},{name:"touch",load:async()=>(await import("./chunks/touch-PC42E2OS.js")).touchCommand},{name:"rm",load:async()=>(await import("./chunks/rm-7ERREV4V.js")).rmCommand},{name:"cp",load:async()=>(await import("./chunks/cp-73PGBEPL.js")).cpCommand},{name:"mv",load:async()=>(await import("./chunks/mv-VDGF4VTT.js")).mvCommand},{name:"ln",load:async()=>(await import("./chunks/ln-SHI7B5FY.js")).lnCommand},{name:"chmod",load:async()=>(await import("./chunks/chmod-IJMA7OGQ.js")).chmodCommand},{name:"pwd",load:async()=>(await import("./chunks/pwd-KKLARPNT.js")).pwdCommand},{name:"readlink",load:async()=>(await import("./chunks/readlink-6XCFQQJH.js")).readlinkCommand},{name:"head",load:async()=>(await import("./chunks/head-EFRLGDOE.js")).headCommand},{name:"tail",load:async()=>(await import("./chunks/tail-TULUAGKH.js")).tailCommand},{name:"wc",load:async()=>(await import("./chunks/wc-U424DF7O.js")).wcCommand},{name:"stat",load:async()=>(await import("./chunks/stat-Z22X56GM.js")).statCommand},{name:"grep",load:async()=>(await import("./chunks/grep-7RC5DPOS.js")).grepCommand},{name:"fgrep",load:async()=>(await import("./chunks/grep-7RC5DPOS.js")).fgrepCommand},{name:"egrep",load:async()=>(await import("./chunks/grep-7RC5DPOS.js")).egrepCommand},{name:"rg",load:async()=>(await import("./chunks/rg-NIW2Q5SV.js")).rgCommand},{name:"sed",load:async()=>(await import("./chunks/sed-VLSHT4XR.js")).sedCommand},{name:"awk",load:async()=>(await import("./chunks/awk2-RAKURI6M.js")).awkCommand2},{name:"sort",load:async()=>(await import("./chunks/sort-KCG2A34N.js")).sortCommand},{name:"uniq",load:async()=>(await import("./chunks/uniq-7HD4DCMD.js")).uniqCommand},{name:"comm",load:async()=>(await import("./chunks/comm-X7VETT2U.js")).commCommand},{name:"cut",load:async()=>(await import("./chunks/cut-7I6UA67F.js")).cutCommand},{name:"paste",load:async()=>(await import("./chunks/paste-HD4NKO4X.js")).pasteCommand},{name:"tr",load:async()=>(await import("./chunks/tr-F7JZV44S.js")).trCommand},{name:"rev",load:async()=>(await import("./chunks/rev-NJ2ZPNAT.js")).rev},{name:"nl",load:async()=>(await import("./chunks/nl-PD7BPFUB.js")).nl},{name:"fold",load:async()=>(await import("./chunks/fold-5VRJN4CL.js")).fold},{name:"expand",load:async()=>(await import("./chunks/expand-OYPZZOZC.js")).expand},{name:"unexpand",load:async()=>(await import("./chunks/unexpand-KAIAW5TX.js")).unexpand},{name:"strings",load:async()=>(await import("./chunks/strings-EKWOLUFJ.js")).strings},{name:"split",load:async()=>(await import("./chunks/split-EVSSQ6VR.js")).split},{name:"column",load:async()=>(await import("./chunks/column-N7MHP5SX.js")).column},{name:"join",load:async()=>(await import("./chunks/join-36QXZEGR.js")).join},{name:"tee",load:async()=>(await import("./chunks/tee-DPV6AVMH.js")).teeCommand},{name:"find",load:async()=>(await import("./chunks/find-DESNHKKS.js")).findCommand},{name:"basename",load:async()=>(await import("./chunks/basename-Q7SIX77Q.js")).basenameCommand},{name:"dirname",load:async()=>(await import("./chunks/dirname-2TM4IG7K.js")).dirnameCommand},{name:"tree",load:async()=>(await import("./chunks/tree-SVRMFKLQ.js")).treeCommand},{name:"du",load:async()=>(await import("./chunks/du-KTUJVIGD.js")).duCommand},{name:"env",load:async()=>(await import("./chunks/env-MFQH47JH.js")).envCommand},{name:"printenv",load:async()=>(await import("./chunks/env-MFQH47JH.js")).printenvCommand},{name:"alias",load:async()=>(await import("./chunks/alias-CIPN5HGG.js")).aliasCommand},{name:"unalias",load:async()=>(await import("./chunks/alias-CIPN5HGG.js")).unaliasCommand},{name:"history",load:async()=>(await import("./chunks/history-J3C24VIU.js")).historyCommand},{name:"xargs",load:async()=>(await import("./chunks/xargs-SWPLSROG.js")).xargsCommand},{name:"true",load:async()=>(await import("./chunks/true-T4XKISHJ.js")).trueCommand},{name:"false",load:async()=>(await import("./chunks/true-T4XKISHJ.js")).falseCommand},{name:"clear",load:async()=>(await import("./chunks/clear-J6WBUIX6.js")).clearCommand},{name:"yes",load:async()=>(await import("./chunks/yes-5BWAW2VY.js")).yesCommand},{name:"bash",load:async()=>(await import("./chunks/bash-HKSQMKKV.js")).bashCommand},{name:"sh",load:async()=>(await import("./chunks/bash-HKSQMKKV.js")).shCommand},{name:"jq",load:async()=>(await import("./chunks/jq-5KN27BBY.js")).jqCommand},{name:"base64",load:async()=>(await import("./chunks/base64-4GSA7KNI.js")).base64Command},{name:"diff",load:async()=>(await import("./chunks/diff-O5NFSBS5.js")).diffCommand},{name:"date",load:async()=>(await import("./chunks/date-MOZRIQXR.js")).dateCommand},{name:"sleep",load:async()=>(await import("./chunks/sleep-SAQIXUFW.js")).sleepCommand},{name:"timeout",load:async()=>(await import("./chunks/timeout-YRSN3MWF.js")).timeoutCommand},{name:"time",load:async()=>(await import("./chunks/time-RXWT5RNC.js")).timeCommand},{name:"seq",load:async()=>(await import("./chunks/seq-RCBD3IYO.js")).seqCommand},{name:"expr",load:async()=>(await import("./chunks/expr-4PIUWNB7.js")).exprCommand},{name:"md5sum",load:async()=>(await import("./chunks/md5sum-J7XPNTQZ.js")).md5sumCommand},{name:"sha1sum",load:async()=>(await import("./chunks/sha1sum-RMRQ75AE.js")).sha1sumCommand},{name:"sha256sum",load:async()=>(await import("./chunks/sha256sum-TGW5BMJR.js")).sha256sumCommand},{name:"file",load:async()=>(await import("./chunks/file-DZRW6GNH.js")).fileCommand},{name:"html-to-markdown",load:async()=>(await import("./chunks/html-to-markdown-TFBDHAZZ.js")).htmlToMarkdownCommand},{name:"help",load:async()=>(await import("./chunks/help-3XYFOR43.js")).helpCommand},{name:"which",load:async()=>(await import("./chunks/which-OY73BBGP.js")).whichCommand},{name:"tac",load:async()=>(await import("./chunks/tac-RSIVIUEI.js")).tac},{name:"hostname",load:async()=>(await import("./chunks/hostname-D54LLZ5I.js")).hostname},{name:"whoami",load:async()=>(await import("./chunks/whoami-KUZQQOVR.js")).whoami},{name:"od",load:async()=>(await import("./chunks/od-D6RO3GJE.js")).od},{name:"gzip",load:async()=>(await import("./chunks/gzip-WH2JWAWT.js")).gzipCommand},{name:"gunzip",load:async()=>(await import("./chunks/gzip-WH2JWAWT.js")).gunzipCommand},{name:"zcat",load:async()=>(await import("./chunks/gzip-WH2JWAWT.js")).zcatCommand}];(typeof __BROWSER__>"u"||!__BROWSER__)&&(at.push({name:"tar",load:async()=>(await import("./chunks/tar-KQPQPRTZ.js")).tarCommand}),at.push({name:"yq",load:async()=>(await import("./chunks/yq-URX6MHLP.js")).yqCommand}),at.push({name:"xan",load:async()=>(await import("./chunks/xan-N66EXZFT.js")).xanCommand}),at.push({name:"sqlite3",load:async()=>(await import("./chunks/sqlite3-M6BXLMYI.js")).sqlite3Command}));var is=[];(typeof __BROWSER__>"u"||!__BROWSER__)&&(is.push({name:"python3",load:async()=>(await import("./chunks/python3-KPG6SQQV.js")).python3Command}),is.push({name:"python",load:async()=>(await import("./chunks/python3-KPG6SQQV.js")).pythonCommand}));var Tn=[{name:"curl",load:async()=>(await import("./chunks/curl-MGBYKD7U.js")).curlCommand}],_n=new Map;function Ys(e){return{name:e.name,async execute(t,s){let r=_n.get(e.name);if(r||(r=await e.load(),_n.set(e.name,r)),s.coverage&&(typeof __BROWSER__>"u"||!__BROWSER__)){let{emitFlagCoverage:n}=await import("./chunks/flag-coverage-QMBN7WOW.js"),{decodeArgs:i}=await import("./chunks/bytes-JUNATFIO.js");n(s.coverage,e.name,i(t))}return r.execute(t,s)}}}function yo(){return at.map(e=>e.name)}function go(){return Tn.map(e=>e.name)}function Nn(e){return(e?at.filter(s=>e.includes(s.name)):at).map(Ys)}function On(){return Tn.map(Ys)}function wo(){return is.map(e=>e.name)}function Dn(){return is.map(Ys)}function In(e){return"load"in e&&typeof e.load=="function"}function vo(e,t){return{name:e,async execute(s,r){let n={...r,env:ln(r.env)},i=await t(ft(s),n);return typeof i.stdout=="string"?{stdout:V(i.stdout),stderr:V(i.stderr),exitCode:i.exitCode}:i}}}function Rn(e){let t=null;return{name:e.name,async execute(s,r){return t||(t=await e.load()),t.execute(s,r)}}}var bo=new TextEncoder;function Eo(e){return typeof e=="object"&&e!==null&&typeof e.getReader=="function"}function So(e,t){if(e instanceof Uint8Array)return e;if(t==="base64")return Uint8Array.from(atob(e),s=>s.charCodeAt(0));if(t==="hex"){let s=new Uint8Array(e.length/2);for(let r=0;r<e.length;r+=2)s[r/2]=parseInt(e.slice(r,r+2),16);return s}if(t==="binary"||t==="latin1"){if(e.length<=65536)return Uint8Array.from(e,n=>n.charCodeAt(0));let r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r}return bo.encode(e)}function Ln(e){if(e.length===0)return[];if(e.length<=dt)return[e];let t=[];for(let s=0;s<e.length;s+=dt)t.push(e.subarray(s,Math.min(s+dt,e.length)));return t}function mt(e,t){let s=So(e,t);return{chunks:Ln(s),size:s.length}}async function Ze(e,t){if(Eo(e)){let s=[],r=0;for await(let n of Bs(e))if(n.length<=dt)s.push(n),r+=n.length;else for(let i of Ln(n))s.push(i),r+=i.length;return{chunks:s,size:r}}return mt(e,t)}function os(e,t){if(t==="base64")return btoa(dn(Mn(e)));if(t==="hex"){let n="";for(let i of e)for(let a=0;a<i.length;a++)n+=i[a].toString(16).padStart(2,"0");return n}if(t==="binary"||t==="latin1"){if(typeof Buffer<"u")return Buffer.from(Mn(e)).toString(t);let n=65536,i="";for(let a of e)if(a.length<=n)i+=String.fromCharCode(...a);else for(let o=0;o<a.length;o+=n){let l=a.subarray(o,o+n);i+=String.fromCharCode(...l)}return i}let s=new TextDecoder,r="";for(let n of e)n.length>0&&(r+=s.decode(n,{stream:!0}));return r+=s.decode(),r}function Mn(e){let t=0;for(let n of e)t+=n.length;if(t===0)return new Uint8Array(0);if(e.length===1)return e[0];let s=new Uint8Array(t),r=0;for(let n of e)s.set(n,r),r+=n.length;return s}function Te(e){if(e!=null)return typeof e=="string"?e:e.encoding??void 0}function yt(e,t){if(!Number.isFinite(e)||!Number.isInteger(e)||e<0)throw new Error(`EINVAL: invalid offset (must be a non-negative integer): ${e}`);if(!Number.isFinite(t)||!Number.isInteger(t)||t<0)throw new Error(`EINVAL: invalid length (must be a non-negative integer): ${t}`)}function as(e,t,s,r){if(s>=t||r===0)return new Uint8Array(0);let n=Math.min(s+r,t),i=n-s,a=new Uint8Array(i),o=0,l=0;for(let u of e){if(o>=i)break;let c=l+u.length;if(c>s&&l<n){let f=Math.max(0,s-l),d=Math.min(u.length,n-l),p=u.subarray(f,d);a.set(p,o),o+=p.length}l=c}return a}function $o(e){return typeof e=="object"&&e!==null&&!(e instanceof Uint8Array)&&!(e instanceof ReadableStream)&&"content"in e}function ue(e,t){if(e.includes("\0"))throw new Error(`ENOENT: path contains null byte, ${t} '${e}'`)}var Xe=class{data=new Map;constructor(t){if(this.data.set("/",{type:"directory",mode:493,mtime:new Date}),t)for(let[s,r]of Object.entries(t))if($o(r)){if(r.content instanceof ReadableStream)throw new Error("InMemoryFs: streams not supported in InitialFiles; use writeFile() after construction");this.writeFileSync(s,r.content,void 0,{mode:r.mode,mtime:r.mtime})}else{if(r instanceof ReadableStream)throw new Error("InMemoryFs: streams not supported in InitialFiles; use writeFile() after construction");this.writeFileSync(s,r)}}normalizePath(t){if(!t||t==="/")return"/";let s=t.endsWith("/")&&t!=="/"?t.slice(0,-1):t;s.startsWith("/")||(s=`/${s}`);let r=s.split("/").filter(i=>i&&i!=="."),n=[];for(let i of r)i===".."?n.pop():n.push(i);return`/${n.join("/")}`||"/"}dirname(t){let s=this.normalizePath(t);if(s==="/")return"/";let r=s.lastIndexOf("/");return r===0?"/":s.slice(0,r)}ensureParentDirs(t){let s=this.dirname(t);s!=="/"&&(this.data.has(s)||(this.ensureParentDirs(s),this.data.set(s,{type:"directory",mode:493,mtime:new Date})))}writeFileSync(t,s,r,n){ue(t,"write");let i=this.normalizePath(t);this.ensureParentDirs(i);let a=Te(r),{chunks:o,size:l}=mt(s,a);this.data.set(i,{type:"file",chunks:o,size:l,mode:n?.mode??420,mtime:n?.mtime??new Date})}async readFile(t){ue(t,"open");let s=this.resolvePathWithSymlinks(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, open '${t}'`);if(r.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);return ht(r.chunks)}async readRange(t,s,r){yt(s,r),ue(t,"open");let n=this.resolvePathWithSymlinks(t),i=this.data.get(n);if(!i)throw new Error(`ENOENT: no such file or directory, open '${t}'`);if(i.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);return as(i.chunks,i.size,s,r)}async readFileText(t,s){ue(t,"open");let r=this.resolvePathWithSymlinks(t),n=this.data.get(r);if(!n)throw new Error(`ENOENT: no such file or directory, open '${t}'`);if(n.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);let i=Te(s);return os(n.chunks,i)}async writeFile(t,s,r){ue(t,"write");let n=this.normalizePath(t);this.ensureParentDirs(n);let i=Te(r),{chunks:a,size:o}=await Ze(s,i);this.data.set(n,{type:"file",chunks:a,size:o,mode:420,mtime:new Date})}async appendFile(t,s,r){ue(t,"append");let n=this.normalizePath(t),i=this.data.get(n);if(i&&i.type==="directory")throw new Error(`EISDIR: illegal operation on a directory, write '${t}'`);let a=Te(r),{chunks:o,size:l}=await Ze(s,a);i?.type==="file"?this.data.set(n,{type:"file",chunks:[...i.chunks,...o],size:i.size+l,mode:i.mode,mtime:new Date}):(this.ensureParentDirs(n),this.data.set(n,{type:"file",chunks:o,size:l,mode:420,mtime:new Date}))}async exists(t){if(t.includes("\0"))return!1;try{let s=this.resolvePathWithSymlinks(t);return this.data.has(s)}catch{return!1}}async stat(t){ue(t,"stat");let s=this.resolvePathWithSymlinks(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, stat '${t}'`);let n=0;return r.type==="file"&&(n=r.size),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:n,mtime:r.mtime||new Date}}async lstat(t){ue(t,"lstat");let s=this.resolveIntermediateSymlinks(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, lstat '${t}'`);if(r.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:r.mode,size:r.target.length,mtime:r.mtime||new Date};let n=0;return r.type==="file"&&(n=r.size),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:n,mtime:r.mtime||new Date}}resolveSymlink(t,s){if(s.startsWith("/"))return this.normalizePath(s);let r=this.dirname(t);return this.normalizePath(r==="/"?`/${s}`:`${r}/${s}`)}resolveIntermediateSymlinks(t){let s=this.normalizePath(t);if(s==="/")return"/";let r=s.slice(1).split("/");if(r.length<=1)return s;let n="",i=new Set;for(let a=0;a<r.length-1;a++){let o=r[a];n=`${n}/${o}`;let l=this.data.get(n),u=0,c=40;for(;l&&l.type==="symlink"&&u<c;){if(i.has(n))throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`);i.add(n),n=this.resolveSymlink(n,l.target),l=this.data.get(n),u++}if(u>=c)throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`)}return`${n}/${r[r.length-1]}`}resolvePathWithSymlinks(t){let s=this.normalizePath(t);if(s==="/")return"/";let r=s.slice(1).split("/"),n="",i=new Set;for(let a of r){n=`${n}/${a}`;let o=this.data.get(n),l=0,u=40;for(;o&&o.type==="symlink"&&l<u;){if(i.has(n))throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`);i.add(n),n=this.resolveSymlink(n,o.target),o=this.data.get(n),l++}if(l>=u)throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`)}return n}async mkdir(t,s){this.mkdirSync(t,s)}mkdirSync(t,s){ue(t,"mkdir");let r=this.normalizePath(t);if(this.data.has(r)){if(this.data.get(r)?.type==="file")throw new Error(`EEXIST: file already exists, mkdir '${t}'`);if(!s?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${t}'`);return}let n=this.dirname(r);if(n!=="/"&&!this.data.has(n))if(s?.recursive)this.mkdirSync(n,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${t}'`);this.data.set(r,{type:"directory",mode:493,mtime:new Date})}async readdir(t){return(await this.readdirWithFileTypes(t)).map(r=>r.name)}async readdirWithFileTypes(t){ue(t,"scandir");let s=this.normalizePath(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);let n=new Set;for(;r&&r.type==="symlink";){if(n.has(s))throw new Error(`ELOOP: too many levels of symbolic links, scandir '${t}'`);n.add(s),s=this.resolveSymlink(s,r.target),r=this.data.get(s)}if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);if(r.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${t}'`);let i=s==="/"?"/":`${s}/`,a=new Map;for(let[o,l]of this.data.entries())if(o!==s&&o.startsWith(i)){let u=o.slice(i.length),c=u.split("/")[0];c&&!u.includes("/",c.length)&&!a.has(c)&&a.set(c,{name:c,isFile:l.type==="file",isDirectory:l.type==="directory",isSymbolicLink:l.type==="symlink"})}return Array.from(a.values()).sort((o,l)=>o.name<l.name?-1:o.name>l.name?1:0)}async rm(t,s){ue(t,"rm");let r=this.normalizePath(t),n=this.data.get(r);if(!n){if(s?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${t}'`)}if(n.type==="directory"){let i=await this.readdir(r);if(i.length>0){if(!s?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${t}'`);for(let a of i){let o=r==="/"?`/${a}`:`${r}/${a}`;await this.rm(o,s)}}}this.data.delete(r)}async cp(t,s,r){ue(t,"cp"),ue(s,"cp");let n=this.normalizePath(t),i=this.normalizePath(s),a=this.data.get(n);if(!a)throw new Error(`ENOENT: no such file or directory, cp '${t}'`);if(a.type==="file")this.ensureParentDirs(i),this.data.set(i,{type:"file",chunks:[...a.chunks],size:a.size,mode:a.mode,mtime:a.mtime});else if(a.type==="directory"){if(!r?.recursive)throw new Error(`EISDIR: is a directory, cp '${t}'`);await this.mkdir(i,{recursive:!0});let o=await this.readdir(n);for(let l of o){let u=n==="/"?`/${l}`:`${n}/${l}`,c=i==="/"?`/${l}`:`${i}/${l}`;await this.cp(u,c,r)}}}async mv(t,s){await this.cp(t,s,{recursive:!0}),await this.rm(t,{recursive:!0})}getAllPaths(){return Array.from(this.data.keys())}resolvePath(t,s){if(s.startsWith("/"))return this.normalizePath(s);let r=t==="/"?`/${s}`:`${t}/${s}`;return this.normalizePath(r)}async chmod(t,s){ue(t,"chmod");let r=this.normalizePath(t),n=this.data.get(r);if(!n)throw new Error(`ENOENT: no such file or directory, chmod '${t}'`);n.mode=s}async symlink(t,s){ue(s,"symlink");let r=this.normalizePath(s);if(this.data.has(r))throw new Error(`EEXIST: file already exists, symlink '${s}'`);this.ensureParentDirs(r),this.data.set(r,{type:"symlink",target:t,mode:511,mtime:new Date})}async link(t,s){ue(t,"link"),ue(s,"link");let r=this.normalizePath(t),n=this.normalizePath(s),i=this.data.get(r);if(!i)throw new Error(`ENOENT: no such file or directory, link '${t}'`);if(i.type!=="file")throw new Error(`EPERM: operation not permitted, link '${t}'`);if(this.data.has(n))throw new Error(`EEXIST: file already exists, link '${s}'`);this.ensureParentDirs(n),this.data.set(n,{type:"file",chunks:[...i.chunks],size:i.size,mode:i.mode,mtime:i.mtime})}async readlink(t){ue(t,"readlink");let s=this.normalizePath(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, readlink '${t}'`);if(r.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${t}'`);return r.target}async realpath(t){ue(t,"realpath");let s=this.resolvePathWithSymlinks(t);if(!this.data.has(s))throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);return s}async utimes(t,s,r){ue(t,"utimes");let n=this.normalizePath(t),i=this.resolvePathWithSymlinks(n),a=this.data.get(i);if(!a)throw new Error(`ENOENT: no such file or directory, utimes '${t}'`);a.mtime=r}};function Po(e){let t=e;return typeof t.mkdirSync=="function"&&typeof t.writeFileSync=="function"}function Co(e,t){e.mkdirSync("/bin",{recursive:!0}),e.mkdirSync("/usr/bin",{recursive:!0}),t&&(e.mkdirSync("/home/user",{recursive:!0}),e.mkdirSync("/tmp",{recursive:!0}))}function Ao(e){e.mkdirSync("/dev",{recursive:!0}),e.writeFileSync("/dev/null",""),e.writeFileSync("/dev/zero",new Uint8Array(0)),e.writeFileSync("/dev/stdin",""),e.writeFileSync("/dev/stdout",""),e.writeFileSync("/dev/stderr","")}function ko(e){e.mkdirSync("/proc/self/fd",{recursive:!0}),e.writeFileSync("/proc/version",`${hn}
2
2
  `),e.writeFileSync("/proc/self/exe","/bin/bash"),e.writeFileSync("/proc/self/cmdline","bash\0"),e.writeFileSync("/proc/self/comm",`bash
3
- `),e.writeFileSync("/proc/self/status",Tr()),e.writeFileSync("/proc/self/fd/0","/dev/stdin"),e.writeFileSync("/proc/self/fd/1","/dev/stdout"),e.writeFileSync("/proc/self/fd/2","/dev/stderr")}function Jr(e,t){Fi(e)&&(Li(e,t),zi(e),Wi(e))}var Vi=["allexport","errexit","noglob","noclobber","noexec","nounset","pipefail","posix","verbose","xtrace"],Bi=["braceexpand","hashall","interactive-comments"];function As(e){let t=[],s=[...Bi.map(r=>({name:r,enabled:!0})),...Vi.map(r=>({name:r,enabled:e[r]}))].sort((r,n)=>r.name.localeCompare(n.name));for(let r of s)r.enabled&&t.push(r.name);return t.join(":")}function nt(e){g(e.state.env,"SHELLOPTS",As(e.state.options))}var ji=["dotglob","expand_aliases","extglob","failglob","globskipdots","globstar","lastpipe","nocaseglob","nocasematch","nullglob","xpg_echo"];function ks(e){let t=[];for(let s of ji)e[s]&&t.push(s);return t.join(":")}function _s(e){g(e.state.env,"BASHOPTS",ks(e.state.shoptOptions))}var Ui="BASH_ALIAS_";function en(e){return e.parts.length!==1?!1:e.parts[0].type==="Literal"}function tn(e){if(e.parts.length!==1)return null;let t=e.parts[0];return t.type==="Literal"?t.value:null}function sn(e,t){let s=e.env.get(`${Ui}${t}`);return s!==void 0?j(s):void 0}function Cs(e,t,s){if(!t.name||!en(t.name))return t;let r=tn(t.name);if(!r)return t;let n=sn(e,r);if(!n||s.has(r))return t;try{s.add(r);let i=new Z,o=n,a=n.endsWith(" ");if(!a)for(let f of t.args){let h=nn(f);o+=` ${h}`}let l;try{l=i.parse(o)}catch(f){if(f instanceof Rt)throw f;return t}if(l.statements.length!==1||l.statements[0].pipelines.length!==1||l.statements[0].pipelines[0].commands.length!==1)return rn(t,n);let u=l.statements[0].pipelines[0].commands[0];if(u.type!=="SimpleCommand")return rn(t,n);let c={...u,assignments:[...t.assignments,...u.assignments],redirections:[...u.redirections,...t.redirections],line:t.line};if(a&&t.args.length>0&&(c={...c,args:[...c.args,...t.args]},c.args.length>0)){let f=c.args[0];if(en(f)){let h=tn(f);if(h&&sn(e,h)){let d={type:"SimpleCommand",name:f,args:c.args.slice(1),assignments:[],redirections:[]},m=Cs(e,d,s);m!==d&&(c={...c,name:m.name,args:[...m.args]})}}}return c}catch(i){throw s.delete(r),i}}function rn(e,t){let s=t;for(let o of e.args){let a=nn(o);s+=` ${a}`}let r=new Z,n=r.parseWordFromString("eval",!1,!1),i=r.parseWordFromString(`'${s.replace(/'/g,"'\\''")}'`,!1,!1);return{type:"SimpleCommand",name:n,args:[i],assignments:e.assignments,redirections:e.redirections,line:e.line}}function nn(e){let t="";for(let s of e.parts)switch(s.type){case"Literal":t+=s.value.replace(/([\s"'$`\\*?[\]{}()<>|&;#!])/g,"\\$1");break;case"SingleQuoted":t+=`'${s.value}'`;break;case"DoubleQuoted":t+=`"${s.parts.map(r=>r.type==="Literal"?r.value:`$${r.type}`).join("")}"`;break;case"ParameterExpansion":t+=`\${${s.parameter}}`;break;case"CommandSubstitution":t+="$(...)";break;case"ArithmeticExpansion":t+=`$((${s.expression}))`;break;case"Glob":t+=s.pattern;break;default:break}return t}async function on(e,t){let s=t.parts.map(c=>c.type==="Literal"?c.value:"\0").join(""),r=s.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\(/);if(!r||!s.endsWith(")"))return null;let n=r[1],i=[],o=!1,a="",l=!1;for(let c of t.parts)if(c.type==="Literal"){let f=c.value;if(!o){let h=f.indexOf("=(");h!==-1&&(o=!0,f=f.slice(h+2))}if(o){f.endsWith(")")&&(f=f.slice(0,-1));let h=f.split(/(\s+)/);for(let d of h)/^\s+$/.test(d)?(a||l)&&(i.push(a),a="",l=!1):d&&(a+=d)}}else if(o)if(c.type==="BraceExpansion")if(/^\[.+\]=/.test(a))a+=Mt({type:"Word",parts:[c]});else{(a||l)&&(i.push(a),a="",l=!1);let h=await Ie(e,{type:"Word",parts:[c]});i.push(...h.values)}else{(c.type==="SingleQuoted"||c.type==="DoubleQuoted"||c.type==="Escaped")&&(l=!0);let f=await V(e,{type:"Word",parts:[c]});a+=f}(a||l)&&i.push(a);let u=i.map(c=>/^\[.+\]=/.test(c)?c:c===""?"''":/[\s"'\\$`!*?[\]{}|&;<>()]/.test(c)&&!c.startsWith("'")&&!c.startsWith('"')?`'${c.replace(/'/g,"'\\''")}'`:c);return`${n}=(${u.join(" ")})`}async function an(e,t){let s=-1,r=-1,n=!1;for(let p=0;p<t.parts.length;p++){let v=t.parts[p];if(v.type==="Literal"){let y=v.value.indexOf("+=");if(y!==-1){let A=v.value.slice(0,y);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(A)){s=p,r=y,n=!0;break}if(/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(A)){s=p,r=y,n=!0;break}}let S=v.value.indexOf("=");if(S!==-1&&(S===0||v.value[S-1]!=="+")){let A=v.value.slice(0,S);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(A)||/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(A)){s=p,r=S;break}}}}if(s===-1)return null;let i=t.parts.slice(0,s),o=t.parts[s];if(o.type!=="Literal")return null;let a=n?2:1,l=o.value.slice(0,r),u=o.value.slice(r+a),c=t.parts.slice(s+1),f="";for(let p of i)f+=await V(e,{type:"Word",parts:[p]});f+=l;let h={type:"Word",parts:u!==""?[{type:"Literal",value:u},...c]:c},d=h.parts.length>0?await V(e,h):"";return`${f}${n?"+=":"="}${d}`}var Hi=["tar","yq","xan","sqlite3","python3","python"];function ln(e){return Hi.includes(e)}function U(){return{stdout:w(),stderr:w(),exitCode:0}}var it={get stdout(){return w()},get stderr(){return w()},exitCode:0};function Pe(e=w()){return{stdout:e,stderr:w(),exitCode:0}}function X(e){return{stdout:C(e),stderr:w(),exitCode:0}}function k(e,t=1){return{stdout:w(),stderr:C(e),exitCode:t}}function R(e,t,s){return{stdout:e instanceof Uint8Array?se(e):e,stderr:t instanceof Uint8Array?se(t):t,exitCode:s}}function re(e){return{stdout:w(),stderr:w(),exitCode:e?0:1}}function Ne(e,t,s,r){let n=s===void 0?w():s instanceof Uint8Array?se(s):s,i=r===void 0?void 0:r instanceof Uint8Array?se(r):r;throw new de(e,t,n,i)}function xs(e,t){if(e.state.loopDepth===0){if(e.state.parentHasLoopContext)throw new Ve;return U()}if(t.length>1)throw new Y(1,w(),C(`bash: break: too many arguments
4
- `));let s=1;if(t.length>0){let r=Number.parseInt(t[0],10);if(Number.isNaN(r)||r<1)throw new Y(128,w(),C(`bash: break: ${t[0]}: numeric argument required
5
- `));s=r}throw new Ee(s)}async function Ns(e,t){let s,r=!1,n=!1,i=0;for(;i<t.length;)if(t[i]==="--"){i++;break}else if(t[i]==="-L")n=!1,i++;else if(t[i]==="-P")n=!0,i++;else if(t[i].startsWith("-")&&t[i]!=="-")i++;else break;let o=t.slice(i);if(o.length===0?s=T(e.state.env,"HOME","/"):o[0]==="~"?s=T(e.state.env,"HOME","/"):o[0]==="-"?(s=e.state.previousDir,r=!0):s=o[0],!s.startsWith("/")&&!s.startsWith("./")&&!s.startsWith("../")&&s!=="."&&s!==".."){let f=e.state.env.get("CDPATH");if(f){let h=j(f??F).split(":").filter(d=>d);for(let d of h){let m=d.startsWith("/")?`${d}/${s}`:`${e.state.cwd}/${d}/${s}`;try{if((await e.fs.stat(m)).isDirectory){s=m,r=!0;break}}catch{}}}}let l=(s.startsWith("/")?s:`${e.state.cwd}/${s}`).split("/").filter(f=>f&&f!=="."),u="";for(let f of l)if(f==="..")u=u.split("/").slice(0,-1).join("/")||"/";else{u=u?`${u}/${f}`:`/${f}`;try{if(!(await e.fs.stat(u)).isDirectory)return k(`bash: cd: ${s}: Not a directory
6
- `)}catch{return k(`bash: cd: ${s}: No such file or directory
7
- `)}}let c=u||"/";if(n)try{c=await e.fs.realpath(c)}catch{}return e.state.previousDir=e.state.cwd,e.state.cwd=c,g(e.state.env,"PWD",e.state.cwd),g(e.state.env,"OLDPWD",e.state.previousDir),r?X(`${c}
8
- `):Pe()}function Ts(e,t){return e.fs.resolvePath(e.state.cwd,t)}var Gi=["-e","-a","-f","-d","-r","-w","-x","-s","-L","-h","-k","-g","-u","-G","-O","-b","-c","-p","-S","-t","-N"];function Bt(e){return Gi.includes(e)}async function jt(e,t,s){let r=Ts(e,s);switch(t){case"-e":case"-a":return e.fs.exists(r);case"-f":return await e.fs.exists(r)?(await e.fs.stat(r)).isFile:!1;case"-d":return await e.fs.exists(r)?(await e.fs.stat(r)).isDirectory:!1;case"-r":return await e.fs.exists(r)?((await e.fs.stat(r)).mode&256)!==0:!1;case"-w":return await e.fs.exists(r)?((await e.fs.stat(r)).mode&128)!==0:!1;case"-x":return await e.fs.exists(r)?((await e.fs.stat(r)).mode&64)!==0:!1;case"-s":return await e.fs.exists(r)?(await e.fs.stat(r)).size>0:!1;case"-L":case"-h":try{return(await e.fs.lstat(r)).isSymbolicLink}catch{return!1}case"-k":return await e.fs.exists(r)?((await e.fs.stat(r)).mode&512)!==0:!1;case"-g":return await e.fs.exists(r)?((await e.fs.stat(r)).mode&1024)!==0:!1;case"-u":return await e.fs.exists(r)?((await e.fs.stat(r)).mode&2048)!==0:!1;case"-G":case"-O":return e.fs.exists(r);case"-b":return!1;case"-c":return["/dev/null","/dev/zero","/dev/random","/dev/urandom","/dev/tty","/dev/stdin","/dev/stdout","/dev/stderr"].some(i=>r===i||r.endsWith(i));case"-p":return!1;case"-S":return!1;case"-t":return!1;case"-N":return e.fs.exists(r);default:return!1}}var qi=["-nt","-ot","-ef"];function Ut(e){return qi.includes(e)}async function Ht(e,t,s,r){let n=Ts(e,s),i=Ts(e,r);switch(t){case"-nt":try{let o=await e.fs.stat(n),a=await e.fs.stat(i);return o.mtime>a.mtime}catch{return!1}case"-ot":try{let o=await e.fs.stat(n),a=await e.fs.stat(i);return o.mtime<a.mtime}catch{return!1}case"-ef":try{if(!await e.fs.exists(n)||!await e.fs.exists(i))return!1;let o=e.fs.resolvePath(e.state.cwd,n),a=e.fs.resolvePath(e.state.cwd,i);return o===a}catch{return!1}default:return!1}}var Zi=new Set(["-eq","-ne","-lt","-le","-gt","-ge"]);function Gt(e){return Zi.has(e)}function qt(e,t,s){switch(e){case"-eq":return t===s;case"-ne":return t!==s;case"-lt":return t<s;case"-le":return t<=s;case"-gt":return t>s;case"-ge":return t>=s}}function Et(e){return e==="="||e==="=="||e==="!="}function Zt(e,t,s,r=!1,n=!1,i=!1){if(r){let a=ot(t,s,n,i);return e==="!="?!a:a}if(n){let a=t.toLowerCase()===s.toLowerCase();return e==="!="?!a:a}let o=t===s;return e==="!="?!o:o}var Xi=new Set(["-z","-n"]);function Xt(e){return Xi.has(e)}function Yt(e,t){switch(e){case"-z":return t==="";case"-n":return t!==""}}async function Kt(e,t){let s=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(s){let r=s[1],n=s[2];if(e.state.associativeArrays?.has(r)){let a=n;return(a.startsWith("'")&&a.endsWith("'")||a.startsWith('"')&&a.endsWith('"'))&&(a=a.slice(1,-1)),a=a.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)/g,(l,u)=>T(e.state.env,u)),e.state.env.has(`${r}_${a}`)}let o;try{let a=new Z,l=ne(a,n);o=await K(e,l.expression)}catch{if(/^-?\d+$/.test(n))o=Number.parseInt(n,10);else{let a=T(e.state.env,n);o=a?Number.parseInt(a,10):0}}if(o<0){let a=ce(e,r),l=e.state.currentLine;if(a.length===0)return e.state.expansionStderr=(e.state.expansionStderr||"")+`bash: line ${l}: ${r}: bad array subscript
9
- `,!1;if(o=Math.max(...a)+1+o,o<0)return e.state.expansionStderr=(e.state.expansionStderr||"")+`bash: line ${l}: ${r}: bad array subscript
10
- `,!1}return e.state.env.has(`${r}_${o}`)}return e.state.env.has(t)?!0:e.state.associativeArrays?.has(t)?je(e,t).length>0:ce(e,t).length>0}async function Ue(e,t){switch(t.type){case"CondBinary":{let s=await V(e,t.left),r=t.right.parts.length>0&&t.right.parts.every(i=>i.type==="SingleQuoted"||i.type==="DoubleQuoted"||i.type==="Escaped"&&t.operator!=="=~"),n;if(t.operator==="=~")if(r){let i=await V(e,t.right);n=Wr(i)}else n=await Br(e,t.right);else Et(t.operator)&&!r?n=await jr(e,t.right):n=await V(e,t.right);if(Et(t.operator)){let i=e.state.shoptOptions.nocasematch;return Zt(t.operator,s,n,!r,i,!0)}if(Gt(t.operator))return qt(t.operator,await un(e,s),await un(e,n));if(Ut(t.operator))return Ht(e,t.operator,s,n);switch(t.operator){case"=~":try{let i=e.state.shoptOptions.nocasematch,o=Ji(n),l=bt(o,i?"i":"").match(s);if(Oe(e,"BASH_REMATCH"),l)for(let u=0;u<l.length;u++)g(e.state.env,`BASH_REMATCH_${u}`,l[u]||"");return l!==null}catch{throw new Error("syntax error in regular expression")}case"<":return s<n;case">":return s>n;default:return!1}}case"CondUnary":{let s=await V(e,t.operand);return Bt(t.operator)?jt(e,t.operator,s):Xt(t.operator)?Yt(t.operator,s):t.operator==="-v"?await Kt(e,s):t.operator==="-o"?Ds(e,s):!1}case"CondNot":return e.state.shoptOptions.extglob&&t.operand.type==="CondGroup"&&t.operand.expression.type==="CondWord"?`!(${await V(e,t.operand.expression.word)})`!=="":!await Ue(e,t.operand);case"CondAnd":return await Ue(e,t.left)?await Ue(e,t.right):!1;case"CondOr":return await Ue(e,t.left)?!0:await Ue(e,t.right);case"CondGroup":return await Ue(e,t.expression);case"CondWord":return await V(e,t.word)!=="";default:return!1}}async function St(e,t){if(t.length===0)return R(F,F,1);if(t.length===1)return re(!!t[0]);if(t.length===2){let r=t[0],n=t[1];return r==="("?k(`test: '(' without matching ')'
11
- `,2):Bt(r)?re(await jt(e,r,n)):Xt(r)?re(Yt(r,n)):r==="!"?re(!n):r==="-v"?re(await Kt(e,n)):r==="-o"?re(Ds(e,n)):r==="="||r==="=="||r==="!="||r==="<"||r===">"||r==="-eq"||r==="-ne"||r==="-lt"||r==="-le"||r==="-gt"||r==="-ge"||r==="-nt"||r==="-ot"||r==="-ef"?k(`test: ${r}: unary operator expected
12
- `,2):R(F,F,1)}if(t.length===3){let r=t[0],n=t[1],i=t[2];if(Et(n))return re(Zt(n,r,i));if(Gt(n)){let o=Qt(r),a=Qt(i);return!o.valid||!a.valid?R(F,F,2):re(qt(n,o.value,a.value))}if(Ut(n))return re(await Ht(e,n,r,i));switch(n){case"-a":return re(r!==""&&i!=="");case"-o":return re(r!==""||i!=="");case">":return re(r>i);case"<":return re(r<i)}if(r==="!"){let o=await St(e,[n,i]);return R(F,o.stderr,o.exitCode===0?1:o.exitCode===1?0:o.exitCode)}if(r==="("&&i===")")return re(n!=="")}if(t.length===4){if(t[0]==="!"){let r=await St(e,t.slice(1));return R(F,r.stderr,r.exitCode===0?1:r.exitCode===1?0:r.exitCode)}if(t[0]==="("&&t[3]===")")return St(e,[t[1],t[2]])}let s=await dn(e,t,0);return s.pos<t.length?k(`test: too many arguments
13
- `,2):re(s.value)}async function dn(e,t,s){return Yi(e,t,s)}async function Yi(e,t,s){let{value:r,pos:n}=await cn(e,t,s);for(;t[n]==="-o";){let i=await cn(e,t,n+1);r=r||i.value,n=i.pos}return{value:r,pos:n}}async function cn(e,t,s){let{value:r,pos:n}=await Os(e,t,s);for(;t[n]==="-a";){let i=await Os(e,t,n+1);r=r&&i.value,n=i.pos}return{value:r,pos:n}}async function Os(e,t,s){if(t[s]==="!"){let{value:r,pos:n}=await Os(e,t,s+1);return{value:!r,pos:n}}return Ki(e,t,s)}async function Ki(e,t,s){let r=t[s];if(r==="("){let{value:i,pos:o}=await dn(e,t,s+1);return{value:i,pos:t[o]===")"?o+1:o}}let n=t[s+1];if(Et(n)){let i=r,o=t[s+2]??"";return{value:Zt(n,i,o),pos:s+3}}if(Gt(n)){let i=Qt(r),o=Qt(t[s+2]??"0");return!i.valid||!o.valid?{value:!1,pos:s+3}:{value:qt(n,i.value,o.value),pos:s+3}}if(Ut(n)){let i=r,o=t[s+2]??"";return{value:await Ht(e,n,i,o),pos:s+3}}if(Bt(r)){let i=t[s+1]??"";return{value:await jt(e,r,i),pos:s+2}}if(Xt(r)){let i=t[s+1]??"";return{value:Yt(r,i),pos:s+2}}if(r==="-v"){let i=t[s+1]??"";return{value:await Kt(e,i),pos:s+2}}if(r==="-o"){let i=t[s+1]??"";return{value:Ds(e,i),pos:s+2}}return{value:r!==void 0&&r!=="",pos:s+1}}function ot(e,t,s=!1,r=!1){let n=`^${hn(t,r)}$`;return bt(n,s?"is":"s").test(e)}function hn(e,t){let s="";for(let r=0;r<e.length;r++){let n=e[r];if(t&&(n==="@"||n==="*"||n==="+"||n==="?"||n==="!")&&r+1<e.length&&e[r+1]==="("){let i=pn(e,r+1);if(i!==-1){let o=e.slice(r+2,i),a=mn(o),l=a.map(c=>hn(c,t)),u=l.length>0?l.join("|"):"(?:)";if(n==="@")s+=`(?:${u})`;else if(n==="*")s+=`(?:${u})*`;else if(n==="+")s+=`(?:${u})+`;else if(n==="?")s+=`(?:${u})?`;else if(n==="!")if(i<e.length-1){let f=a.map(d=>yn(d,t));if(f.every(d=>d!==null)&&f.every(d=>d===f[0])&&f[0]!==null){let d=f[0];if(d===0)s+="(?:.+)";else{let m=[];d>0&&m.push(`.{0,${d-1}}`),m.push(`.{${d+1},}`),m.push(`(?!(?:${u})).{${d}}`),s+=`(?:${m.join("|")})`}}else s+=`(?:(?!(?:${u})).)*?`}else s+=`(?!(?:${u})$).*`;r=i;continue}}if(n==="\\")if(r+1<e.length){let i=e[r+1];/[\\^$.|+(){}[\]*?]/.test(i)?s+=`\\${i}`:s+=i,r++}else s+="\\\\";else if(n==="*")s+=".*";else if(n==="?")s+=".";else if(n==="["){let i=e.indexOf("]",r+1);i!==-1?(s+=e.slice(r,i+1),r=i):s+="\\["}else/[\\^$.|+(){}]/.test(n)?s+=`\\${n}`:s+=n}return s}function pn(e,t){let s=1,r=t+1;for(;r<e.length&&s>0;){let n=e[r];if(n==="\\"){r+=2;continue}if(n==="(")s++;else if(n===")"&&(s--,s===0))return r;r++}return-1}function mn(e){let t=[],s="",r=0,n=0;for(;n<e.length;){let i=e[n];if(i==="\\"){s+=i,n+1<e.length?(s+=e[n+1],n+=2):n++;continue}i==="("?(r++,s+=i):i===")"?(r--,s+=i):i==="|"&&r===0?(t.push(s),s=""):s+=i,n++}return t.push(s),t}function yn(e,t){let s=0,r=0;for(;r<e.length;){let n=e[r];if(t&&(n==="@"||n==="*"||n==="+"||n==="?"||n==="!")&&r+1<e.length&&e[r+1]==="("){let i=pn(e,r+1);if(i!==-1){if(n==="@"){let o=e.slice(r+2,i),l=mn(o).map(u=>yn(u,t));if(l.every(u=>u!==null)&&l.every(u=>u===l[0])){s+=l[0],r=i+1;continue}return null}return null}}if(n==="*")return null;if(n==="?"){s+=1,r++;continue}if(n==="["){let i=e.indexOf("]",r+1);if(i!==-1){s+=1,r=i+1;continue}s+=1,r++;continue}if(n==="\\"){s+=1,r+=2;continue}s+=1,r++}return s}function Ds(e,t){let r=new Map([["errexit",()=>e.state.options.errexit===!0],["nounset",()=>e.state.options.nounset===!0],["pipefail",()=>e.state.options.pipefail===!0],["xtrace",()=>e.state.options.xtrace===!0],["e",()=>e.state.options.errexit===!0],["u",()=>e.state.options.nounset===!0],["x",()=>e.state.options.xtrace===!0]]).get(t);return r?r():!1}async function un(e,t){if(t=t.trim(),t==="")return 0;if(/^[+-]?(\d+#[a-zA-Z0-9@_]+|0[xX][0-9a-fA-F]+|0[0-7]+|\d+)$/.test(t))return fn(t);try{let s=new Z,r=ne(s,t);return await K(e,r.expression)}catch{return fn(t)}}function Qi(e,t){let s=0;for(let r of e){let n;if(r>="0"&&r<="9")n=r.charCodeAt(0)-48;else if(r>="a"&&r<="z")n=r.charCodeAt(0)-97+10;else if(r>="A"&&r<="Z")n=r.charCodeAt(0)-65+36;else if(r==="@")n=62;else if(r==="_")n=63;else return Number.NaN;if(n>=t)return Number.NaN;s=s*t+n}return s}function fn(e){if(e=e.trim(),e==="")return 0;let t=!1;e.startsWith("-")?(t=!0,e=e.slice(1)):e.startsWith("+")&&(e=e.slice(1));let s,r=e.match(/^(\d+)#([a-zA-Z0-9@_]+)$/);if(r){let n=Number.parseInt(r[1],10);n>=2&&n<=64?s=Qi(r[2],n):s=0}else/^0[xX][0-9a-fA-F]+$/.test(e)?s=Number.parseInt(e,16):/^0[0-7]+$/.test(e)?s=Number.parseInt(e,8):s=Number.parseInt(e,10);return Number.isNaN(s)&&(s=0),t?-s:s}function Qt(e){if(e=e.trim(),e==="")return{value:0,valid:!0};let t=!1;if(e.startsWith("-")?(t=!0,e=e.slice(1)):e.startsWith("+")&&(e=e.slice(1)),!/^\d+$/.test(e))return{value:0,valid:!1};let s=Number.parseInt(e,10);return Number.isNaN(s)?{value:0,valid:!1}:{value:t?-s:s,valid:!0}}function Ji(e){let t="",s=0;for(;s<e.length;)if(e[s]==="\\"&&s+1<e.length)t+=e[s]+e[s+1],s+=2;else if(e[s]==="["){let r=eo(e,s);t+=r.converted,s=r.endIndex}else t+=e[s],s++;return t}function eo(e,t){let s=t+1,r="[";s<e.length&&(e[s]==="^"||e[s]==="!")&&(r+="^",s++);let n=!1;s<e.length&&e[s]==="]"&&(n=!0,s++);let i=!1;s<e.length&&e[s]==="["&&s+1<e.length&&e[s+1]!==":"&&(i=!0,s++);let o="",a=!1;for(;s<e.length;){let l=e[s];if(l==="]"){a=!0,s++;break}if(l==="["&&s+1<e.length&&e[s+1]===":"){let u=e.indexOf(":]",s+2);if(u!==-1){let c=e.slice(s+2,u);o+=to(c),s=u+2;continue}}if(l==="["&&s+1<e.length){let u=e[s+1];if(u==="."||u==="="){let c=`${u}]`,f=e.indexOf(c,s+2);if(f!==-1){let h=e.slice(s+2,f);o+=h,s=f+2;continue}}}if(l==="\\"&&s+1<e.length){o+=l+e[s+1],s+=2;continue}o+=l,s++}return a?(n&&(r+="\\]"),i&&(r+="\\["),r+=o,r+="]",{converted:r,endIndex:s}):{converted:"\\[",endIndex:t+1}}function to(e){return new Map([["alnum","a-zA-Z0-9"],["alpha","a-zA-Z"],["ascii","\\x00-\\x7F"],["blank"," \\t"],["cntrl","\\x00-\\x1F\\x7F"],["digit","0-9"],["graph","!-~"],["lower","a-z"],["print"," -~"],["punct","!-/:-@\\[-`{-~"],["space"," \\t\\n\\r\\f\\v"],["upper","A-Z"],["word","a-zA-Z0-9_"],["xdigit","0-9A-Fa-f"]]).get(e)??""}function Re(e){let t=[],s="",r=!1,n=!1,i=!1,o=!1;for(let a of e){if(i){s+=a,i=!1,o=!0;continue}if(a==="\\"){i=!0;continue}if(a==="'"&&!n){r||(o=!0),r=!r;continue}if(a==='"'&&!r){n||(o=!0),n=!n;continue}if((a===" "||a===" "||a===`
14
- `)&&!r&&!n){o&&(t.push(s),s="",o=!1);continue}s+=a,o=!0}return o&&t.push(s),t}function Jt(e){let t=[],s=0;for(;s<e.length;){for(;s<e.length&&/\s/.test(e[s]);)s++;if(s>=e.length)break;if(e[s]!=="["){s++;continue}s++;let r="";if(e[s]==="'"||e[s]==='"'){let i=e[s];for(s++;s<e.length&&e[s]!==i;)r+=e[s],s++;e[s]===i&&s++}else for(;s<e.length&&e[s]!=="]"&&e[s]!=="=";)r+=e[s],s++;for(;s<e.length&&e[s]!=="]";)s++;if(e[s]==="]"&&s++,e[s]!=="=")continue;s++;let n="";if(e[s]==="'"||e[s]==='"'){let i=e[s];for(s++;s<e.length&&e[s]!==i;)e[s]==="\\"&&s+1<e.length&&s++,n+=e[s],s++;e[s]===i&&s++}else for(;s<e.length&&!/\s/.test(e[s]);)n+=e[s],s++;t.push([r,n])}return t}function gn(e){let t=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(t)return{name:t[1],isArray:!0,arrayElements:Re(t[2])};let s=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([^\]]+)\]=(.*)$/s);if(s)return{name:s[1],isArray:!1,arrayIndex:s[2],value:s[3]};if(e.includes("=")){let r=e.indexOf("=");return{name:e.slice(0,r),isArray:!1,value:e.slice(r+1)}}return{name:e,isArray:!1}}async function so(e,t){try{let s=new Z,r=ne(s,t);return await K(e,r.expression)}catch{let s=parseInt(t,10);return Number.isNaN(s)?0:s}}async function wn(e,t,s={}){let{name:r,isArray:n,arrayElements:i,value:o,arrayIndex:a}=t,{makeReadonly:l=!1,checkReadonly:u=!0}=s;if(u){let c=ae(e,r);if(c)return c}if(n&&i){for(let c=0;c<i.length;c++)g(e.state.env,`${r}_${c}`,i[c]);g(e.state.env,`${r}__length`,String(i.length))}else if(a!==void 0&&o!==void 0){let c=await so(e,a);g(e.state.env,`${r}_${c}`,o);let f=parseInt(T(e.state.env,`${r}__length`,"0"),10);c>=f&&g(e.state.env,`${r}__length`,String(c+1))}else o!==void 0&&g(e.state.env,r,o);return l&&ge(e,r),null}function He(e,t){e.state.localVarDepth=e.state.localVarDepth||new Map,e.state.localVarDepth.set(t,e.state.callDepth)}function at(e,t){return e.state.localVarDepth?.get(t)}function es(e,t){e.state.localVarDepth?.delete(t)}function vn(e,t,s){e.state.localVarStack=e.state.localVarStack||new Map;let r=e.state.localVarStack.get(t)||[];r.push({value:s,scopeIndex:e.state.localScopes.length-1}),e.state.localVarStack.set(t,r)}function ts(e,t){let s=e.state.localVarStack?.get(t);if(!(!s||s.length===0))return s.pop()}function bn(e,t){if(e.state.localVarStack)for(let[s,r]of e.state.localVarStack.entries()){for(;r.length>0&&r[r.length-1].scopeIndex===t;)r.pop();r.length===0&&e.state.localVarStack.delete(s)}}var Is=new Set([":",".","break","continue","eval","exec","exit","export","readonly","return","set","shift","trap","unset"]);function En(e){return Is.has(e)}var Rs=new Set(["if","then","else","elif","fi","case","esac","for","select","while","until","do","done","in","function","{","}","time","[[","]]","!"]),lt=new Set([":","true","false","cd","export","unset","exit","local","set","break","continue","return","eval","shift","getopts","compgen","complete","compopt","pushd","popd","dirs","source",".","read","mapfile","readarray","declare","typeset","readonly","let","command","shopt","exec","test","[","echo","printf","pwd","alias","unalias","type","hash","ulimit","umask","trap","times","wait","kill","jobs","fg","bg","disown","suspend","fc","history","help","enable","builtin","caller"]);async function Ye(e,t,s,r){try{if((await e.fs.stat(t)).isDirectory)return`bash: ${s}: Is a directory
3
+ `),e.writeFileSync("/proc/self/status",pn()),e.writeFileSync("/proc/self/fd/0","/dev/stdin"),e.writeFileSync("/proc/self/fd/1","/dev/stdout"),e.writeFileSync("/proc/self/fd/2","/dev/stderr")}function Fn(e,t){Po(e)&&(Co(e,t),Ao(e),ko(e))}var xo=["allexport","errexit","noglob","noclobber","noexec","nounset","pipefail","posix","verbose","xtrace"],_o=["braceexpand","hashall","interactive-comments"];function Qs(e){let t=[],s=[..._o.map(r=>({name:r,enabled:!0})),...xo.map(r=>({name:r,enabled:e[r]}))].sort((r,n)=>r.name.localeCompare(n.name));for(let r of s)r.enabled&&t.push(r.name);return t.join(":")}function gt(e){g(e.state.env,"SHELLOPTS",Qs(e.state.options))}var To=["dotglob","expand_aliases","extglob","failglob","globskipdots","globstar","lastpipe","nocaseglob","nocasematch","nullglob","xpg_echo"];function er(e){let t=[];for(let s of To)e[s]&&t.push(s);return t.join(":")}function tr(e){g(e.state.env,"BASHOPTS",er(e.state.shoptOptions))}var No="BASH_ALIAS_";function Wn(e){return e.parts.length!==1?!1:e.parts[0].type==="Literal"}function Vn(e){if(e.parts.length!==1)return null;let t=e.parts[0];return t.type==="Literal"?t.value:null}function zn(e,t){let s=e.env.get(`${No}${t}`);return s!==void 0?B(s):void 0}function sr(e,t,s){if(!t.name||!Wn(t.name))return t;let r=Vn(t.name);if(!r)return t;let n=zn(e,r);if(!n||s.has(r))return t;try{s.add(r);let i=new X,a=n,o=n.endsWith(" ");if(!o)for(let f of t.args){let d=Bn(f);a+=` ${d}`}let l;try{l=i.parse(a)}catch(f){if(f instanceof ts)throw f;return t}if(l.statements.length!==1||l.statements[0].pipelines.length!==1||l.statements[0].pipelines[0].commands.length!==1)return jn(t,n);let u=l.statements[0].pipelines[0].commands[0];if(u.type!=="SimpleCommand")return jn(t,n);let c={...u,assignments:[...t.assignments,...u.assignments],redirections:[...u.redirections,...t.redirections],line:t.line};if(o&&t.args.length>0&&(c={...c,args:[...c.args,...t.args]},c.args.length>0)){let f=c.args[0];if(Wn(f)){let d=Vn(f);if(d&&zn(e,d)){let p={type:"SimpleCommand",name:f,args:c.args.slice(1),assignments:[],redirections:[]},m=sr(e,p,s);m!==p&&(c={...c,name:m.name,args:[...m.args]})}}}return c}catch(i){throw s.delete(r),i}}function jn(e,t){let s=t;for(let a of e.args){let o=Bn(a);s+=` ${o}`}let r=new X,n=r.parseWordFromString("eval",!1,!1),i=r.parseWordFromString(`'${s.replace(/'/g,"'\\''")}'`,!1,!1);return{type:"SimpleCommand",name:n,args:[i],assignments:e.assignments,redirections:e.redirections,line:e.line}}function Bn(e){let t="";for(let s of e.parts)switch(s.type){case"Literal":t+=s.value.replace(/([\s"'$`\\*?[\]{}()<>|&;#!])/g,"\\$1");break;case"SingleQuoted":t+=`'${s.value}'`;break;case"DoubleQuoted":t+=`"${s.parts.map(r=>r.type==="Literal"?r.value:`$${r.type}`).join("")}"`;break;case"ParameterExpansion":t+=`\${${s.parameter}}`;break;case"CommandSubstitution":t+="$(...)";break;case"ArithmeticExpansion":t+=`$((${s.expression}))`;break;case"Glob":t+=s.pattern;break;default:break}return t}async function Un(e,t){let s=t.parts.map(c=>c.type==="Literal"?c.value:"\0").join(""),r=s.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\(/);if(!r||!s.endsWith(")"))return null;let n=r[1],i=[],a=!1,o="",l=!1;for(let c of t.parts)if(c.type==="Literal"){let f=c.value;if(!a){let d=f.indexOf("=(");d!==-1&&(a=!0,f=f.slice(d+2))}if(a){f.endsWith(")")&&(f=f.slice(0,-1));let d=f.split(/(\s+)/);for(let p of d)/^\s+$/.test(p)?(o||l)&&(i.push(o),o="",l=!1):p&&(o+=p)}}else if(a)if(c.type==="BraceExpansion")if(/^\[.+\]=/.test(o))o+=rs({type:"Word",parts:[c]});else{(o||l)&&(i.push(o),o="",l=!1);let d=await je(e,{type:"Word",parts:[c]});i.push(...d.values)}else{(c.type==="SingleQuoted"||c.type==="DoubleQuoted"||c.type==="Escaped")&&(l=!0);let f=await z(e,{type:"Word",parts:[c]});o+=f}(o||l)&&i.push(o);let u=i.map(c=>/^\[.+\]=/.test(c)?c:c===""?"''":/[\s"'\\$`!*?[\]{}|&;<>()]/.test(c)&&!c.startsWith("'")&&!c.startsWith('"')?`'${c.replace(/'/g,"'\\''")}'`:c);return`${n}=(${u.join(" ")})`}async function Gn(e,t){let s=-1,r=-1,n=!1;for(let h=0;h<t.parts.length;h++){let b=t.parts[h];if(b.type==="Literal"){let E=b.value.indexOf("+=");if(E!==-1){let y=b.value.slice(0,E);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(y)){s=h,r=E,n=!0;break}if(/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(y)){s=h,r=E,n=!0;break}}let $=b.value.indexOf("=");if($!==-1&&($===0||b.value[$-1]!=="+")){let y=b.value.slice(0,$);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(y)||/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(y)){s=h,r=$;break}}}}if(s===-1)return null;let i=t.parts.slice(0,s),a=t.parts[s];if(a.type!=="Literal")return null;let o=n?2:1,l=a.value.slice(0,r),u=a.value.slice(r+o),c=t.parts.slice(s+1),f="";for(let h of i)f+=await z(e,{type:"Word",parts:[h]});f+=l;let d={type:"Word",parts:u!==""?[{type:"Literal",value:u},...c]:c},p=d.parts.length>0?await z(e,d):"";return`${f}${n?"+=":"="}${p}`}var Oo=["tar","yq","xan","sqlite3","python3","python"];function Hn(e){return Oo.includes(e)}function U(){return{stdout:S(),stderr:S(),exitCode:0}}var wt={get stdout(){return S()},get stderr(){return S()},exitCode:0};function Ne(e=S()){return{stdout:e,stderr:S(),exitCode:0}}function H(e){return{stdout:V(e),stderr:S(),exitCode:0}}function P(e,t=1){return{stdout:S(),stderr:V(e),exitCode:t}}function F(e,t,s){return{stdout:e instanceof Uint8Array?fe(e):e,stderr:t instanceof Uint8Array?fe(t):t,exitCode:s}}function le(e){return{stdout:S(),stderr:S(),exitCode:e?0:1}}function Me(e,t){throw new ae(e,t)}async function rr(e,t){if(e.state.loopDepth===0){if(e.state.parentHasLoopContext)throw new Ge;return U()}if(t.length>1)throw await G(e,2,`bash: break: too many arguments
4
+ `,!0),new q(1);let s=1;if(t.length>0){let r=Number.parseInt(t[0],10);if(Number.isNaN(r)||r<1)throw await G(e,2,`bash: break: ${t[0]}: numeric argument required
5
+ `,!0),new q(128);s=r}throw new Ce(s)}async function nr(e,t){let s,r=!1,n=!1,i=0;for(;i<t.length;)if(t[i]==="--"){i++;break}else if(t[i]==="-L")n=!1,i++;else if(t[i]==="-P")n=!0,i++;else if(t[i].startsWith("-")&&t[i]!=="-")i++;else break;let a=t.slice(i);if(a.length===0?s=T(e.state.env,"HOME","/"):a[0]==="~"?s=T(e.state.env,"HOME","/"):a[0]==="-"?(s=e.state.previousDir,r=!0):s=a[0],!s.startsWith("/")&&!s.startsWith("./")&&!s.startsWith("../")&&s!=="."&&s!==".."){let f=e.state.env.get("CDPATH");if(f){let d=B(f??R).split(":").filter(p=>p);for(let p of d){let m=p.startsWith("/")?`${p}/${s}`:`${e.state.cwd}/${p}/${s}`;try{if((await e.fs.stat(m)).isDirectory){s=m,r=!0;break}}catch{}}}}let l=(s.startsWith("/")?s:`${e.state.cwd}/${s}`).split("/").filter(f=>f&&f!=="."),u="";for(let f of l)if(f==="..")u=u.split("/").slice(0,-1).join("/")||"/";else{u=u?`${u}/${f}`:`/${f}`;try{if(!(await e.fs.stat(u)).isDirectory)return P(`bash: cd: ${s}: Not a directory
6
+ `)}catch{return P(`bash: cd: ${s}: No such file or directory
7
+ `)}}let c=u||"/";if(n)try{c=await e.fs.realpath(c)}catch{}return e.state.previousDir=e.state.cwd,e.state.cwd=c,g(e.state.env,"PWD",e.state.cwd),g(e.state.env,"OLDPWD",e.state.previousDir),r?H(`${c}
8
+ `):Ne()}function ir(e,t){return e.fs.resolvePath(e.state.cwd,t)}var Do=["-e","-a","-f","-d","-r","-w","-x","-s","-L","-h","-k","-g","-u","-G","-O","-b","-c","-p","-S","-t","-N"];function ls(e){return Do.includes(e)}async function cs(e,t,s){let r=ir(e,s);switch(t){case"-e":case"-a":return e.fs.exists(r);case"-f":return await e.fs.exists(r)?(await e.fs.stat(r)).isFile:!1;case"-d":return await e.fs.exists(r)?(await e.fs.stat(r)).isDirectory:!1;case"-r":return await e.fs.exists(r)?((await e.fs.stat(r)).mode&256)!==0:!1;case"-w":return await e.fs.exists(r)?((await e.fs.stat(r)).mode&128)!==0:!1;case"-x":return await e.fs.exists(r)?((await e.fs.stat(r)).mode&64)!==0:!1;case"-s":return await e.fs.exists(r)?(await e.fs.stat(r)).size>0:!1;case"-L":case"-h":try{return(await e.fs.lstat(r)).isSymbolicLink}catch{return!1}case"-k":return await e.fs.exists(r)?((await e.fs.stat(r)).mode&512)!==0:!1;case"-g":return await e.fs.exists(r)?((await e.fs.stat(r)).mode&1024)!==0:!1;case"-u":return await e.fs.exists(r)?((await e.fs.stat(r)).mode&2048)!==0:!1;case"-G":case"-O":return e.fs.exists(r);case"-b":return!1;case"-c":return["/dev/null","/dev/zero","/dev/random","/dev/urandom","/dev/tty","/dev/stdin","/dev/stdout","/dev/stderr"].some(i=>r===i||r.endsWith(i));case"-p":return!1;case"-S":return!1;case"-t":return!1;case"-N":return e.fs.exists(r);default:return!1}}var Io=["-nt","-ot","-ef"];function us(e){return Io.includes(e)}async function fs(e,t,s,r){let n=ir(e,s),i=ir(e,r);switch(t){case"-nt":try{let a=await e.fs.stat(n),o=await e.fs.stat(i);return a.mtime>o.mtime}catch{return!1}case"-ot":try{let a=await e.fs.stat(n),o=await e.fs.stat(i);return a.mtime<o.mtime}catch{return!1}case"-ef":try{if(!await e.fs.exists(n)||!await e.fs.exists(i))return!1;let a=e.fs.resolvePath(e.state.cwd,n),o=e.fs.resolvePath(e.state.cwd,i);return a===o}catch{return!1}default:return!1}}var Ro=new Set(["-eq","-ne","-lt","-le","-gt","-ge"]);function ds(e){return Ro.has(e)}function hs(e,t,s){switch(e){case"-eq":return t===s;case"-ne":return t!==s;case"-lt":return t<s;case"-le":return t<=s;case"-gt":return t>s;case"-ge":return t>=s}}function Vt(e){return e==="="||e==="=="||e==="!="}function ps(e,t,s,r=!1,n=!1,i=!1){if(r){let o=vt(t,s,n,i);return e==="!="?!o:o}if(n){let o=t.toLowerCase()===s.toLowerCase();return e==="!="?!o:o}let a=t===s;return e==="!="?!a:a}var Mo=new Set(["-z","-n"]);function ms(e){return Mo.has(e)}function ys(e,t){switch(e){case"-z":return t==="";case"-n":return t!==""}}async function gs(e,t){let s=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(s){let r=s[1],n=s[2];if(e.state.associativeArrays?.has(r)){let o=n;return(o.startsWith("'")&&o.endsWith("'")||o.startsWith('"')&&o.endsWith('"'))&&(o=o.slice(1,-1)),o=o.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)/g,(l,u)=>T(e.state.env,u)),e.state.env.has(`${r}_${o}`)}let a;try{let o=new X,l=ce(o,n);a=await ee(e,l.expression)}catch{if(/^-?\d+$/.test(n))a=Number.parseInt(n,10);else{let o=T(e.state.env,n);a=o?Number.parseInt(o,10):0}}if(a<0){let o=me(e,r),l=e.state.currentLine;if(o.length===0)return await G(e,2,`bash: line ${l}: ${r}: bad array subscript
9
+ `),!1;if(a=Math.max(...o)+1+a,a<0)return await G(e,2,`bash: line ${l}: ${r}: bad array subscript
10
+ `),!1}return e.state.env.has(`${r}_${a}`)}return e.state.env.has(t)?!0:e.state.associativeArrays?.has(t)?et(e,t).length>0:me(e,t).length>0}async function tt(e,t){switch(t.type){case"CondBinary":{let s=await z(e,t.left),r=t.right.parts.length>0&&t.right.parts.every(i=>i.type==="SingleQuoted"||i.type==="DoubleQuoted"||i.type==="Escaped"&&t.operator!=="=~"),n;if(t.operator==="=~")if(r){let i=await z(e,t.right);n=$n(i)}else n=await Cn(e,t.right);else Vt(t.operator)&&!r?n=await An(e,t.right):n=await z(e,t.right);if(Vt(t.operator)){let i=e.state.shoptOptions.nocasematch;return ps(t.operator,s,n,!r,i,!0)}if(ds(t.operator))return hs(t.operator,await Zn(e,s),await Zn(e,n));if(us(t.operator))return fs(e,t.operator,s,n);switch(t.operator){case"=~":try{let i=e.state.shoptOptions.nocasematch,a=Vo(n),l=Rt(a,i?"i":"").match(s);if(Ve(e,"BASH_REMATCH"),l)for(let u=0;u<l.length;u++)g(e.state.env,`BASH_REMATCH_${u}`,l[u]||"");return l!==null}catch{throw new Error("syntax error in regular expression")}case"<":return s<n;case">":return s>n;default:return!1}}case"CondUnary":{let s=await z(e,t.operand);return ls(t.operator)?cs(e,t.operator,s):ms(t.operator)?ys(t.operator,s):t.operator==="-v"?await gs(e,s):t.operator==="-o"?ar(e,s):!1}case"CondNot":return e.state.shoptOptions.extglob&&t.operand.type==="CondGroup"&&t.operand.expression.type==="CondWord"?`!(${await z(e,t.operand.expression.word)})`!=="":!await tt(e,t.operand);case"CondAnd":return await tt(e,t.left)?await tt(e,t.right):!1;case"CondOr":return await tt(e,t.left)?!0:await tt(e,t.right);case"CondGroup":return await tt(e,t.expression);case"CondWord":return await z(e,t.word)!=="";default:return!1}}async function zt(e,t){if(t.length===0)return F(R,R,1);if(t.length===1)return le(!!t[0]);if(t.length===2){let r=t[0],n=t[1];return r==="("?P(`test: '(' without matching ')'
11
+ `,2):ls(r)?le(await cs(e,r,n)):ms(r)?le(ys(r,n)):r==="!"?le(!n):r==="-v"?le(await gs(e,n)):r==="-o"?le(ar(e,n)):r==="="||r==="=="||r==="!="||r==="<"||r===">"||r==="-eq"||r==="-ne"||r==="-lt"||r==="-le"||r==="-gt"||r==="-ge"||r==="-nt"||r==="-ot"||r==="-ef"?P(`test: ${r}: unary operator expected
12
+ `,2):F(R,R,1)}if(t.length===3){let r=t[0],n=t[1],i=t[2];if(Vt(n))return le(ps(n,r,i));if(ds(n)){let a=ws(r),o=ws(i);return!a.valid||!o.valid?F(R,R,2):le(hs(n,a.value,o.value))}if(us(n))return le(await fs(e,n,r,i));switch(n){case"-a":return le(r!==""&&i!=="");case"-o":return le(r!==""||i!=="");case">":return le(r>i);case"<":return le(r<i)}if(r==="!"){let a=await zt(e,[n,i]);return F(R,a.stderr,a.exitCode===0?1:a.exitCode===1?0:a.exitCode)}if(r==="("&&i===")")return le(n!=="")}if(t.length===4){if(t[0]==="!"){let r=await zt(e,t.slice(1));return F(R,r.stderr,r.exitCode===0?1:r.exitCode===1?0:r.exitCode)}if(t[0]==="("&&t[3]===")")return zt(e,[t[1],t[2]])}let s=await Jn(e,t,0);return s.pos<t.length?P(`test: too many arguments
13
+ `,2):le(s.value)}async function Jn(e,t,s){return Lo(e,t,s)}async function Lo(e,t,s){let{value:r,pos:n}=await qn(e,t,s);for(;t[n]==="-o";){let i=await qn(e,t,n+1);r=r||i.value,n=i.pos}return{value:r,pos:n}}async function qn(e,t,s){let{value:r,pos:n}=await or(e,t,s);for(;t[n]==="-a";){let i=await or(e,t,n+1);r=r&&i.value,n=i.pos}return{value:r,pos:n}}async function or(e,t,s){if(t[s]==="!"){let{value:r,pos:n}=await or(e,t,s+1);return{value:!r,pos:n}}return Fo(e,t,s)}async function Fo(e,t,s){let r=t[s];if(r==="("){let{value:i,pos:a}=await Jn(e,t,s+1);return{value:i,pos:t[a]===")"?a+1:a}}let n=t[s+1];if(Vt(n)){let i=r,a=t[s+2]??"";return{value:ps(n,i,a),pos:s+3}}if(ds(n)){let i=ws(r),a=ws(t[s+2]??"0");return!i.valid||!a.valid?{value:!1,pos:s+3}:{value:hs(n,i.value,a.value),pos:s+3}}if(us(n)){let i=r,a=t[s+2]??"";return{value:await fs(e,n,i,a),pos:s+3}}if(ls(r)){let i=t[s+1]??"";return{value:await cs(e,r,i),pos:s+2}}if(ms(r)){let i=t[s+1]??"";return{value:ys(r,i),pos:s+2}}if(r==="-v"){let i=t[s+1]??"";return{value:await gs(e,i),pos:s+2}}if(r==="-o"){let i=t[s+1]??"";return{value:ar(e,i),pos:s+2}}return{value:r!==void 0&&r!=="",pos:s+1}}function vt(e,t,s=!1,r=!1){let n=`^${Kn(t,r)}$`;return Rt(n,s?"is":"s").test(e)}function Kn(e,t){let s="";for(let r=0;r<e.length;r++){let n=e[r];if(t&&(n==="@"||n==="*"||n==="+"||n==="?"||n==="!")&&r+1<e.length&&e[r+1]==="("){let i=Yn(e,r+1);if(i!==-1){let a=e.slice(r+2,i),o=Qn(a),l=o.map(c=>Kn(c,t)),u=l.length>0?l.join("|"):"(?:)";if(n==="@")s+=`(?:${u})`;else if(n==="*")s+=`(?:${u})*`;else if(n==="+")s+=`(?:${u})+`;else if(n==="?")s+=`(?:${u})?`;else if(n==="!")if(i<e.length-1){let f=o.map(p=>ei(p,t));if(f.every(p=>p!==null)&&f.every(p=>p===f[0])&&f[0]!==null){let p=f[0];if(p===0)s+="(?:.+)";else{let m=[];p>0&&m.push(`.{0,${p-1}}`),m.push(`.{${p+1},}`),m.push(`(?!(?:${u})).{${p}}`),s+=`(?:${m.join("|")})`}}else s+=`(?:(?!(?:${u})).)*?`}else s+=`(?!(?:${u})$).*`;r=i;continue}}if(n==="\\")if(r+1<e.length){let i=e[r+1];/[\\^$.|+(){}[\]*?]/.test(i)?s+=`\\${i}`:s+=i,r++}else s+="\\\\";else if(n==="*")s+=".*";else if(n==="?")s+=".";else if(n==="["){let i=e.indexOf("]",r+1);i!==-1?(s+=e.slice(r,i+1),r=i):s+="\\["}else/[\\^$.|+(){}]/.test(n)?s+=`\\${n}`:s+=n}return s}function Yn(e,t){let s=1,r=t+1;for(;r<e.length&&s>0;){let n=e[r];if(n==="\\"){r+=2;continue}if(n==="(")s++;else if(n===")"&&(s--,s===0))return r;r++}return-1}function Qn(e){let t=[],s="",r=0,n=0;for(;n<e.length;){let i=e[n];if(i==="\\"){s+=i,n+1<e.length?(s+=e[n+1],n+=2):n++;continue}i==="("?(r++,s+=i):i===")"?(r--,s+=i):i==="|"&&r===0?(t.push(s),s=""):s+=i,n++}return t.push(s),t}function ei(e,t){let s=0,r=0;for(;r<e.length;){let n=e[r];if(t&&(n==="@"||n==="*"||n==="+"||n==="?"||n==="!")&&r+1<e.length&&e[r+1]==="("){let i=Yn(e,r+1);if(i!==-1){if(n==="@"){let a=e.slice(r+2,i),l=Qn(a).map(u=>ei(u,t));if(l.every(u=>u!==null)&&l.every(u=>u===l[0])){s+=l[0],r=i+1;continue}return null}return null}}if(n==="*")return null;if(n==="?"){s+=1,r++;continue}if(n==="["){let i=e.indexOf("]",r+1);if(i!==-1){s+=1,r=i+1;continue}s+=1,r++;continue}if(n==="\\"){s+=1,r+=2;continue}s+=1,r++}return s}function ar(e,t){let r=new Map([["errexit",()=>e.state.options.errexit===!0],["nounset",()=>e.state.options.nounset===!0],["pipefail",()=>e.state.options.pipefail===!0],["xtrace",()=>e.state.options.xtrace===!0],["e",()=>e.state.options.errexit===!0],["u",()=>e.state.options.nounset===!0],["x",()=>e.state.options.xtrace===!0]]).get(t);return r?r():!1}async function Zn(e,t){if(t=t.trim(),t==="")return 0;if(/^[+-]?(\d+#[a-zA-Z0-9@_]+|0[xX][0-9a-fA-F]+|0[0-7]+|\d+)$/.test(t))return Xn(t);try{let s=new X,r=ce(s,t);return await ee(e,r.expression)}catch{return Xn(t)}}function Wo(e,t){let s=0;for(let r of e){let n;if(r>="0"&&r<="9")n=r.charCodeAt(0)-48;else if(r>="a"&&r<="z")n=r.charCodeAt(0)-97+10;else if(r>="A"&&r<="Z")n=r.charCodeAt(0)-65+36;else if(r==="@")n=62;else if(r==="_")n=63;else return Number.NaN;if(n>=t)return Number.NaN;s=s*t+n}return s}function Xn(e){if(e=e.trim(),e==="")return 0;let t=!1;e.startsWith("-")?(t=!0,e=e.slice(1)):e.startsWith("+")&&(e=e.slice(1));let s,r=e.match(/^(\d+)#([a-zA-Z0-9@_]+)$/);if(r){let n=Number.parseInt(r[1],10);n>=2&&n<=64?s=Wo(r[2],n):s=0}else/^0[xX][0-9a-fA-F]+$/.test(e)?s=Number.parseInt(e,16):/^0[0-7]+$/.test(e)?s=Number.parseInt(e,8):s=Number.parseInt(e,10);return Number.isNaN(s)&&(s=0),t?-s:s}function ws(e){if(e=e.trim(),e==="")return{value:0,valid:!0};let t=!1;if(e.startsWith("-")?(t=!0,e=e.slice(1)):e.startsWith("+")&&(e=e.slice(1)),!/^\d+$/.test(e))return{value:0,valid:!1};let s=Number.parseInt(e,10);return Number.isNaN(s)?{value:0,valid:!1}:{value:t?-s:s,valid:!0}}function Vo(e){let t="",s=0;for(;s<e.length;)if(e[s]==="\\"&&s+1<e.length)t+=e[s]+e[s+1],s+=2;else if(e[s]==="["){let r=zo(e,s);t+=r.converted,s=r.endIndex}else t+=e[s],s++;return t}function zo(e,t){let s=t+1,r="[";s<e.length&&(e[s]==="^"||e[s]==="!")&&(r+="^",s++);let n=!1;s<e.length&&e[s]==="]"&&(n=!0,s++);let i=!1;s<e.length&&e[s]==="["&&s+1<e.length&&e[s+1]!==":"&&(i=!0,s++);let a="",o=!1;for(;s<e.length;){let l=e[s];if(l==="]"){o=!0,s++;break}if(l==="["&&s+1<e.length&&e[s+1]===":"){let u=e.indexOf(":]",s+2);if(u!==-1){let c=e.slice(s+2,u);a+=jo(c),s=u+2;continue}}if(l==="["&&s+1<e.length){let u=e[s+1];if(u==="."||u==="="){let c=`${u}]`,f=e.indexOf(c,s+2);if(f!==-1){let d=e.slice(s+2,f);a+=d,s=f+2;continue}}}if(l==="\\"&&s+1<e.length){a+=l+e[s+1],s+=2;continue}a+=l,s++}return o?(n&&(r+="\\]"),i&&(r+="\\["),r+=a,r+="]",{converted:r,endIndex:s}):{converted:"\\[",endIndex:t+1}}function jo(e){return new Map([["alnum","a-zA-Z0-9"],["alpha","a-zA-Z"],["ascii","\\x00-\\x7F"],["blank"," \\t"],["cntrl","\\x00-\\x1F\\x7F"],["digit","0-9"],["graph","!-~"],["lower","a-z"],["print"," -~"],["punct","!-/:-@\\[-`{-~"],["space"," \\t\\n\\r\\f\\v"],["upper","A-Z"],["word","a-zA-Z0-9_"],["xdigit","0-9A-Fa-f"]]).get(e)??""}function Be(e){let t=[],s="",r=!1,n=!1,i=!1,a=!1;for(let o of e){if(i){s+=o,i=!1,a=!0;continue}if(o==="\\"){i=!0;continue}if(o==="'"&&!n){r||(a=!0),r=!r;continue}if(o==='"'&&!r){n||(a=!0),n=!n;continue}if((o===" "||o===" "||o===`
14
+ `)&&!r&&!n){a&&(t.push(s),s="",a=!1);continue}s+=o,a=!0}return a&&t.push(s),t}function vs(e){let t=[],s=0;for(;s<e.length;){for(;s<e.length&&/\s/.test(e[s]);)s++;if(s>=e.length)break;if(e[s]!=="["){s++;continue}s++;let r="";if(e[s]==="'"||e[s]==='"'){let i=e[s];for(s++;s<e.length&&e[s]!==i;)r+=e[s],s++;e[s]===i&&s++}else for(;s<e.length&&e[s]!=="]"&&e[s]!=="=";)r+=e[s],s++;for(;s<e.length&&e[s]!=="]";)s++;if(e[s]==="]"&&s++,e[s]!=="=")continue;s++;let n="";if(e[s]==="'"||e[s]==='"'){let i=e[s];for(s++;s<e.length&&e[s]!==i;)e[s]==="\\"&&s+1<e.length&&s++,n+=e[s],s++;e[s]===i&&s++}else for(;s<e.length&&!/\s/.test(e[s]);)n+=e[s],s++;t.push([r,n])}return t}function ti(e){let t=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(t)return{name:t[1],isArray:!0,arrayElements:Be(t[2])};let s=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([^\]]+)\]=(.*)$/s);if(s)return{name:s[1],isArray:!1,arrayIndex:s[2],value:s[3]};if(e.includes("=")){let r=e.indexOf("=");return{name:e.slice(0,r),isArray:!1,value:e.slice(r+1)}}return{name:e,isArray:!1}}async function Bo(e,t){try{let s=new X,r=ce(s,t);return await ee(e,r.expression)}catch{let s=parseInt(t,10);return Number.isNaN(s)?0:s}}async function si(e,t,s={}){let{name:r,isArray:n,arrayElements:i,value:a,arrayIndex:o}=t,{makeReadonly:l=!1,checkReadonly:u=!0}=s;if(u){let c=await de(e,r);if(c)return c}if(n&&i){for(let c=0;c<i.length;c++)g(e.state.env,`${r}_${c}`,i[c]);g(e.state.env,`${r}__length`,String(i.length))}else if(o!==void 0&&a!==void 0){let c=await Bo(e,o);g(e.state.env,`${r}_${c}`,a);let f=parseInt(T(e.state.env,`${r}__length`,"0"),10);c>=f&&g(e.state.env,`${r}__length`,String(c+1))}else a!==void 0&&g(e.state.env,r,a);return l&&Se(e,r),null}function st(e,t){e.state.localVarDepth=e.state.localVarDepth||new Map,e.state.localVarDepth.set(t,e.state.callDepth)}function bt(e,t){return e.state.localVarDepth?.get(t)}function bs(e,t){e.state.localVarDepth?.delete(t)}function ri(e,t,s){e.state.localVarStack=e.state.localVarStack||new Map;let r=e.state.localVarStack.get(t)||[];r.push({value:s,scopeIndex:e.state.localScopes.length-1}),e.state.localVarStack.set(t,r)}function Es(e,t){let s=e.state.localVarStack?.get(t);if(!(!s||s.length===0))return s.pop()}function ni(e,t){if(e.state.localVarStack)for(let[s,r]of e.state.localVarStack.entries()){for(;r.length>0&&r[r.length-1].scopeIndex===t;)r.pop();r.length===0&&e.state.localVarStack.delete(s)}}var lr=new Set([":",".","break","continue","eval","exec","exit","export","readonly","return","set","shift","trap","unset"]);function ii(e){return lr.has(e)}var cr=new Set(["if","then","else","elif","fi","case","esac","for","select","while","until","do","done","in","function","{","}","time","[[","]]","!"]),Je=new Set([":","true","false","cd","export","unset","exit","local","set","break","continue","return","eval","shift","getopts","compgen","complete","compopt","pushd","popd","dirs","source",".","read","mapfile","readarray","declare","typeset","readonly","let","command","shopt","exec","test","[","echo","printf","pwd","alias","unalias","type","hash","ulimit","umask","trap","times","wait","kill","jobs","fg","bg","disown","suspend","fc","history","help","enable","builtin","caller"]);function jt(e,t){if(e.parts.length!==1)return!1;let s=e.parts[0];return s.type!=="Literal"?!1:t.includes(s.value)}function Ss(e){if(!e.startsWith("__rw__:"))return null;let t=e.slice(7),s=t.indexOf(":");if(s===-1)return null;let r=Number.parseInt(t.slice(0,s),10);if(Number.isNaN(r)||r<0)return null;let n=s+1,i=t.slice(n,n+r),a=n+r+1,o=t.slice(a),l=o.indexOf(":");if(l===-1)return null;let u=Number.parseInt(o.slice(0,l),10);if(Number.isNaN(u)||u<0)return null;let c=o.slice(l+1);return{path:i,position:u,content:c}}async function oi(e,t,s,r){try{if((await e.fs.stat(t)).isDirectory)return`bash: ${s}: Is a directory
15
15
  `;if(r.checkNoclobber&&e.state.options.noclobber&&!r.isClobber&&s!=="/dev/null")return`bash: ${s}: cannot overwrite existing file
16
- `}catch{}return null}function ro(e){if(!e.startsWith("__rw__:"))return null;let t=e.slice(7),s=t.indexOf(":");if(s===-1)return null;let r=Number.parseInt(t.slice(0,s),10);if(Number.isNaN(r)||r<0)return null;let n=s+1,i=t.slice(n,n+r),o=n+r+1,a=t.slice(o),l=a.indexOf(":");if(l===-1)return null;let u=Number.parseInt(a.slice(0,l),10);if(Number.isNaN(u)||u<0)return null;let c=a.slice(l+1);return{path:i,position:u,content:c}}async function Sn(e,t){let s=new Map;for(let r=0;r<t.length;r++){let n=t[r];if(n.target.type==="HereDoc")continue;if(n.operator===">&"||n.operator==="<&"){if($s(e,n.target))return{targets:s,error:`bash: $@: ambiguous redirect
17
- `};s.set(r,await V(e,n.target))}else{let o=await Lt(e,n.target);if("error"in o)return{targets:s,error:o.error};s.set(r,o.target)}}return{targets:s}}function no(e){e.state.nextFd===void 0&&(e.state.nextFd=10);let t=e.state.nextFd;return e.state.nextFd++,t}async function ss(e,t){for(let s of t){if(!s.fdVariable)continue;if(e.state.fileDescriptors||(e.state.fileDescriptors=new Map),(s.operator===">&"||s.operator==="<&")&&s.target.type==="Word"&&await V(e,s.target)==="-"){if(e.state.env.has(s.fdVariable)){let i=Number.parseInt(T(e.state.env,s.fdVariable),10);Number.isNaN(i)||e.state.fileDescriptors.delete(i)}continue}let r=no(e);if(g(e.state.env,s.fdVariable,String(r)),s.target.type==="Word"){let n=await V(e,s.target);if(s.operator===">&"||s.operator==="<&"){let i=Number.parseInt(n,10);if(!Number.isNaN(i)){let o=e.state.fileDescriptors.get(i);o!==void 0&&e.state.fileDescriptors.set(r,o);continue}}if(s.operator===">"||s.operator===">>"||s.operator===">|"||s.operator==="&>"||s.operator==="&>>"){let i=e.fs.resolvePath(e.state.cwd,n);(s.operator===">"||s.operator===">|"||s.operator==="&>")&&await e.fs.writeFile(i,""),e.state.fileDescriptors.set(r,`__file__:${i}`)}else if(s.operator==="<<<")e.state.fileDescriptors.set(r,`${n}
18
- `);else if(s.operator==="<"||s.operator==="<>")try{let i=e.fs.resolvePath(e.state.cwd,n),o=await e.fs.readFileText(i);e.state.fileDescriptors.set(r,o)}catch{return R(w(),C(`bash: ${n}: No such file or directory
19
- `),1)}}}return null}async function Me(e,t){for(let s of t){if(s.target.type==="HereDoc")continue;let r=s.operator===">&";if(s.operator!==">"&&s.operator!==">|"&&s.operator!=="&>"&&!r)continue;let n;if(r){if(n=await V(e,s.target),n==="-"||!Number.isNaN(Number.parseInt(n,10))||s.fd!=null)continue}else{let a=await Lt(e,s.target);if("error"in a)return R(w(),C(a.error),1);n=a.target}let i=e.fs.resolvePath(e.state.cwd,n),o=s.operator===">|";if(i.includes("\0"))return R(w(),C(`bash: ${n}: No such file or directory
20
- `),1);try{let a=await e.fs.stat(i);if(a.isDirectory)return R(w(),C(`bash: ${n}: Is a directory
21
- `),1);if(e.state.options.noclobber&&!o&&!a.isDirectory&&n!=="/dev/null")return R(w(),C(`bash: ${n}: cannot overwrite existing file
22
- `),1)}catch{}if(n!=="/dev/null"&&n!=="/dev/stdout"&&n!=="/dev/stderr"&&n!=="/dev/full"&&await e.fs.writeFile(i,""),n==="/dev/full")return R(w(),C(`bash: /dev/full: No space left on device
23
- `),1)}return null}async function Q(e,t,s,r){let n=t.stdout,i=t.stderr,o=t.exitCode;for(let u=0;u<s.length;u++){let c=s[u];if(c.target.type==="HereDoc")continue;let f,h=r?.get(u);if(h!==void 0)f=h;else if(c.operator===">&"||c.operator==="<&"){if($s(e,c.target)){i=O(i,C(`bash: $@: ambiguous redirect
24
- `)),o=1,n=w();continue}f=await V(e,c.target)}else{let m=await Lt(e,c.target);if("error"in m){i=O(i,C(m.error)),o=1,n=w();continue}f=m.target}if(!c.fdVariable){if(f.includes("\0")){i=O(i,C(`bash: ${f.replace(/\0/g,"")}: No such file or directory
25
- `)),o=1,n=w();continue}switch(c.operator){case">":case">|":{let d=c.fd??1,m=c.operator===">|";if(d===1){if(f==="/dev/stdout")break;if(f==="/dev/stderr"){i=O(i,n),n=w();break}if(f==="/dev/full"){i=O(i,C(`bash: echo: write error: No space left on device
26
- `)),o=1,n=w();break}let p=e.fs.resolvePath(e.state.cwd,f),v=await Ye(e,p,f,{checkNoclobber:!0,isClobber:m});if(v){i=O(i,C(v)),o=1,n=w();break}await e.fs.writeFile(p,n),n=w()}else if(d===2){if(f==="/dev/stderr")break;if(f==="/dev/stdout"){n=O(n,i),i=w();break}if(f==="/dev/full"){i=O(i,C(`bash: echo: write error: No space left on device
27
- `)),o=1;break}if(f==="/dev/null")i=w();else{let p=e.fs.resolvePath(e.state.cwd,f),v=await Ye(e,p,f,{checkNoclobber:!0,isClobber:m});if(v){i=O(i,C(v)),o=1;break}await e.fs.writeFile(p,i),i=w()}}break}case">>":{let d=c.fd??1;if(d===1){if(f==="/dev/stdout")break;if(f==="/dev/stderr"){i=O(i,n),n=w();break}if(f==="/dev/full"){i=O(i,C(`bash: echo: write error: No space left on device
28
- `)),o=1,n=w();break}let m=e.fs.resolvePath(e.state.cwd,f),p=await Ye(e,m,f,{});if(p){i=O(i,C(p)),o=1,n=w();break}await e.fs.appendFile(m,n),n=w()}else if(d===2){if(f==="/dev/stderr")break;if(f==="/dev/stdout"){n=O(n,i),i=w();break}if(f==="/dev/full"){i=O(i,C(`bash: echo: write error: No space left on device
29
- `)),o=1;break}let m=e.fs.resolvePath(e.state.cwd,f),p=await Ye(e,m,f,{});if(p){i=O(i,C(p)),o=1;break}await e.fs.appendFile(m,i),i=w()}break}case">&":case"<&":{let d=c.fd??1;if(f==="-")break;if(f.endsWith("-")){let m=f.slice(0,-1),p=Number.parseInt(m,10);if(!Number.isNaN(p)){let v=e.state.fileDescriptors?.get(p);v!==void 0?(e.state.fileDescriptors||(e.state.fileDescriptors=new Map),e.state.fileDescriptors.set(d,v),p>=3&&e.state.fileDescriptors?.delete(p)):p===1||p===2?(e.state.fileDescriptors||(e.state.fileDescriptors=new Map),e.state.fileDescriptors.set(d,`__dupout__:${p}`)):p===0?(e.state.fileDescriptors||(e.state.fileDescriptors=new Map),e.state.fileDescriptors.set(d,`__dupin__:${p}`)):p>=3&&(i=O(i,C(`bash: ${p}: Bad file descriptor
30
- `)),o=1)}break}if(f==="2"||f==="&2")d===1&&(i=O(i,n),n=w());else if(f==="1"||f==="&1")d===2?(n=O(n,i),i=w()):(n=O(n,i),i=w());else{let m=Number.parseInt(f,10);if(Number.isNaN(m)){if(c.operator===">&"){let p=e.fs.resolvePath(e.state.cwd,f),v=await Ye(e,p,f,{checkNoclobber:!0});if(v){i=C(v),o=1,n=w();break}if(c.fd==null){let y=await H(n),S=await H(i);await e.fs.writeFile(p,y),await e.fs.appendFile(p,S),n=w(),i=w()}else d===1?(await e.fs.writeFile(p,n),n=w()):d===2&&(await e.fs.writeFile(p,i),i=w())}}else{let p=e.state.fileDescriptors?.get(m);if(p?.startsWith("__file__:")){let v=p.slice(9);d===1?(await e.fs.appendFile(v,n),n=w()):d===2&&(await e.fs.appendFile(v,i),i=w())}else if(p?.startsWith("__rw__:")){let v=ro(p);v&&(d===1?(await e.fs.appendFile(v.path,n),n=w()):d===2&&(await e.fs.appendFile(v.path,i),i=w()))}else if(p?.startsWith("__dupout__:")){let v=Number.parseInt(p.slice(11),10);if(v!==1)if(v===2)d===1&&(i=O(i,n),n=w());else{let y=e.state.fileDescriptors?.get(v);if(y?.startsWith("__file__:")){let S=y.slice(9);d===1?(await e.fs.appendFile(S,n),n=w()):d===2&&(await e.fs.appendFile(S,i),i=w())}}}else p?.startsWith("__dupin__:")?(i=O(i,C(`bash: ${m}: Bad file descriptor
31
- `)),o=1,n=w()):m>=3&&(i=O(i,C(`bash: ${m}: Bad file descriptor
32
- `)),o=1,n=w())}}break}case"&>":{if(f==="/dev/full"){i=C(`bash: echo: write error: No space left on device
33
- `),o=1,n=w();break}let d=e.fs.resolvePath(e.state.cwd,f),m=await Ye(e,d,f,{checkNoclobber:!0});if(m){i=C(m),o=1,n=w();break}let p=await H(n),v=await H(i);await e.fs.writeFile(d,p),await e.fs.appendFile(d,v),n=w(),i=w();break}case"&>>":{if(f==="/dev/full"){i=C(`bash: echo: write error: No space left on device
34
- `),o=1,n=w();break}let d=e.fs.resolvePath(e.state.cwd,f),m=await Ye(e,d,f,{});if(m){i=C(m),o=1,n=w();break}await e.fs.appendFile(d,n),await e.fs.appendFile(d,i),n=w(),i=w();break}}}}let a=e.state.fileDescriptors?.get(1);if(a){if(a==="__dupout__:2")i=O(i,n),n=w();else if(a.startsWith("__file__:")){let u=a.slice(9);await e.fs.appendFile(u,n),n=w()}else if(a.startsWith("__file_append__:")){let u=a.slice(16);await e.fs.appendFile(u,n),n=w()}}let l=e.state.fileDescriptors?.get(2);if(l){if(l==="__dupout__:1")n=O(n,i),i=w();else if(l.startsWith("__file__:")){let u=l.slice(9);await e.fs.appendFile(u,i),i=w()}else if(l.startsWith("__file_append__:")){let u=l.slice(16);await e.fs.appendFile(u,i),i=w()}}return R(n,i,o)}function $n(e,t){if(e.state.options.posix&&Is.has(t.name)){let r=`bash: line ${e.state.currentLine}: \`${t.name}': is a special builtin
35
- `;throw new Y(2,w(),C(r))}let s={...t,sourceFile:t.sourceFile??e.state.currentSource??"main"};return e.state.functions.set(t.name,s),U()}async function io(e,t){let s=w(),r=!1;for(let n of t)if((n.operator==="<<"||n.operator==="<<-")&&n.target.type==="HereDoc"){let i=n.target,o=await V(e,i.content);i.stripTabs&&(o=o.split(`
16
+ `}catch{}return null}async function $s(e,t){if(t.target.type==="HereDoc")throw new Error("Here-document targets are not words");return t.operator===">&"||t.operator==="<&"?kn(e,t.target)?{error:`bash: $@: ambiguous redirect
17
+ `}:{target:await z(e,t.target)}:xn(e,t.target)}function ur(e){return e.includes("\0")?`bash: ${e.replace(/\0/g,"")}: No such file or directory
18
+ `:null}function Ue(e){return`bash: ${e}: Bad file descriptor
19
+ `}function fr(e,t=()=>!1){for(e.state.nextFd===void 0&&(e.state.nextFd=10);t(e.state.nextFd);)e.state.nextFd++;return e.state.nextFd++}async function Et(e,t,s){for(let r of t){if(!r.fdVariable)continue;e.state.fileDescriptors||(e.state.fileDescriptors=new Map);let n;if((r.operator===">&"||r.operator==="<&")&&r.target.type==="Word"&&(n=await z(e,r.target),n==="-")){if(e.state.env.has(r.fdVariable)){let a=Number.parseInt(T(e.state.env,r.fdVariable),10);Number.isNaN(a)||e.state.fileDescriptors.delete(a)}continue}let i=fr(e,s);if(g(e.state.env,r.fdVariable,String(i)),r.target.type==="Word"){let a=n??await z(e,r.target);if(r.operator===">&"||r.operator==="<&"){let o=Number.parseInt(a,10);if(!Number.isNaN(o)){let l=e.state.fileDescriptors.get(o);if(l!==void 0)e.state.fileDescriptors.set(i,l);else return F(S(),V(Ue(o)),1);continue}}if(r.operator===">"||r.operator===">>"||r.operator===">|"||r.operator==="&>"||r.operator==="&>>"){let o=e.fs.resolvePath(e.state.cwd,a);(r.operator===">"||r.operator===">|"||r.operator==="&>")&&await e.fs.writeFile(o,""),e.state.fileDescriptors.set(i,`__file__:${o}`)}else if(r.operator==="<<<")e.state.fileDescriptors.set(i,`${a}
20
+ `);else if(r.operator==="<"||r.operator==="<>")try{let o=e.fs.resolvePath(e.state.cwd,a),l=await e.fs.readFileText(o);e.state.fileDescriptors.set(i,l)}catch{return F(S(),V(`bash: ${a}: No such file or directory
21
+ `),1)}}}return null}var Uo={write(){}},Go={write(){let e=new Error(`bash: echo: write error: No space left on device
22
+ `);return e.code="ENOSPC",Promise.reject(e)}};function Ho(e){return e.target.type==="HereDoc"||e.operator==="<"||e.operator==="<>"||e.operator==="<<<"||e.operator==="<<"||e.operator==="<<-"}function dr(e,t){return{...e,target:{type:"Word",parts:[{type:"Literal",value:t}]}}}function Cs(e,t){let s=Promise.resolve();return{write(r){let n=s.then(()=>e.fs.appendFile(t,r));return s=n.catch(()=>{}),n}}}function li(e,t,s,r=new Set){let n=t.bindings.get(s),i=n?.sink;if(i)return i;if(r.has(s))return;r.add(s);let a=n?.descriptor,o;if(a?.startsWith("__file__:"))o=Cs(e,a.slice(9));else if(a?.startsWith("__file_append__:"))o=Cs(e,a.slice(16));else if(a?.startsWith("__rw__:")){let l=Ss(a);l&&(o=Cs(e,l.path))}else if(a?.startsWith("__dupout__:")){let l=Number.parseInt(a.slice(11),10);Number.isNaN(l)||(o=li(e,t,l,r))}return o&&t.bindings.set(s,{...n,sink:o}),o}async function ai(e,t,s,r,n=!1){if(s==="/dev/null")return{sink:Uo,descriptor:"__file__:/dev/null"};if(s==="/dev/full")return{sink:Go,descriptor:"__file__:/dev/full"};if(s==="/dev/stdout"||s==="/dev/stderr"){let o=s==="/dev/stdout"?1:2,l=t.bindings.get(o),u=l?.sink;return u?{sink:u,descriptor:l.descriptor??`__dupout__:${o}`}:{error:Ue(o)}}let i=e.fs.resolvePath(e.state.cwd,s),a=await oi(e,i,s,{checkNoclobber:r==="truncate",isClobber:n});return a?{error:a}:(r==="truncate"?await e.fs.writeFile(i,""):await e.fs.appendFile(i,new Uint8Array),{sink:Cs(e,i),descriptor:r==="append"?`__file_append__:${i}`:`__file__:${i}`})}function lt(e,t,s){e.state.fileDescriptors||(e.state.fileDescriptors=new Map),e.state.fileDescriptors.set(t,s)}function qo(e,t){return e.bindings.get(t)?.descriptor??`__dupout__:${t}`}function hr(e,t,s,r,n){if(!(!n&&!t.fdVariable)){if(t.fdVariable&&r.startsWith("__file_append__:")){lt(e,s,`__file__:${r.slice(16)}`);return}lt(e,s,r)}}function Ps(e,t,s,r,n,i=!0){let a=e.state.fileDescriptors?.get(s),o=n?.startsWith("__file_append__:")?`__file__:${n.slice(16)}`:n;(r||t.fdVariable)&&i&&a!==void 0&&a===o&&e.state.fileDescriptors?.delete(s)}function Oe(e,t,s){return{channels:e,legacyRedirections:t,error:P(s)}}async function De(e,t,s,r={}){let n={bindings:new Map(t.bindings),parent:t,overrides:new Set};for(let[o,l]of e.state.fileDescriptors??[]){let u=n.bindings.get(o);u?.descriptor===void 0&&n.bindings.set(o,{...u,descriptor:l})}let i=[],a=r.persistent===!0;for(let o of s){let l;if(o.operator==="<&"&&o.target.type==="Word"){let E=await $s(e,o);if("error"in E)return Oe(n,i,E.error);l=E.target;let $=l.startsWith("&")?l.slice(1):l,y=/^\d+-?$/.test($);if(l!=="-"&&!y)return Oe(n,i,`bash: ${l}: ambiguous redirect
23
+ `);if(!o.fdVariable&&(o.fd??0)===0){i.push(dr(o,l));continue}}if(o.operator==="<"&&!o.fdVariable&&o.target.type==="Word"){let E=await $s(e,o);if("error"in E)return Oe(n,i,E.error);let $=ur(E.target);if($)return Oe(n,i,$);try{let y=e.fs.resolvePath(e.state.cwd,E.target);await e.fs.readFile(y)}catch{return Oe(n,i,`bash: ${E.target}: No such file or directory
24
+ `)}i.push(dr(o,E.target));continue}if(Ho(o)){if(o.fdVariable&&o.target.type==="Word"){let E=await Et(e,[o],v=>Hs(n,v));if(E)return{channels:n,legacyRedirections:i,error:E};let $=Number.parseInt(T(e.state.env,o.fdVariable),10),y=e.state.fileDescriptors?.get($);if(!Number.isNaN($)&&y!==void 0){let v=n.bindings.get($);n.bindings.set($,{...v,descriptor:y})}}else i.push(o);continue}let u;if(l!==void 0)u=l;else{let E=await $s(e,o);if("error"in E)return Oe(n,i,E.error);u=E.target}let c=ur(u);if(c)return Oe(n,i,c);if((o.operator===">&"||o.operator==="<&")&&u==="-"&&o.fdVariable){if(e.state.env.has(o.fdVariable)){let E=Number.parseInt(T(e.state.env,o.fdVariable),10);if(!Number.isNaN(E)){let $=n.bindings.get(E)?.descriptor,y=Ft(n,E);Ps(e,o,E,a,$,y)}}continue}let f=o.fdVariable?fr(e,E=>Hs(n,E)):o.fd??(o.operator==="<&"?0:1);if(o.fdVariable&&g(e.state.env,o.fdVariable,String(f)),!Number.isInteger(f)||f<0)return Oe(n,i,Ue(f));if(o.operator===">"||o.operator===">|"||o.operator===">>"||o.operator==="&>"||o.operator==="&>>"){let E=o.operator===">>"||o.operator==="&>>",$=await ai(e,n,u,E?"append":"truncate",o.operator===">|");if("error"in $)return Oe(n,i,$.error);o.operator==="&>"||o.operator==="&>>"?(n.bindings.set(1,{sink:$.sink,descriptor:$.descriptor}),n.bindings.set(2,{sink:$.sink,descriptor:$.descriptor}),n.overrides?.add(1),n.overrides?.add(2),a&&(lt(e,1,$.descriptor),lt(e,2,$.descriptor))):(o.fdVariable?Lt(n,f,$.sink,$.descriptor):(n.bindings.set(f,{sink:$.sink,descriptor:$.descriptor}),n.overrides?.add(f)),hr(e,o,f,$.descriptor,a));continue}if(o.operator!==">&"&&o.operator!=="<&"){i.push(o);continue}if(u==="-"){let E=n.bindings.get(f)?.descriptor;n.overrides?.add(f),n.bindings.set(f,{descriptor:ss}),Ps(e,o,f,a,E);continue}let d=u.endsWith("-"),p=d?u.slice(0,-1):u,m=p.startsWith("&")?p.slice(1):p,h=/^\d+$/.test(m)?Number.parseInt(m,10):Number.NaN;if(!Number.isNaN(h)){let E=li(e,n,h);if(!E){let y=n.bindings.get(h)?.descriptor;if(y===ss)return Oe(n,i,Ue(h));if(o.operator==="<&"&&o.fdVariable&&y!==void 0){if(n.bindings.set(f,{descriptor:y}),lt(e,f,y),d){let v=Ft(n,h);Ps(e,o,h,a,y,v)}continue}if(o.operator==="<&"&&!o.fdVariable){i.push(dr(o,u));continue}return Oe(n,i,Ue(h))}let $=qo(n,h);if(o.fdVariable?Lt(n,f,E,$):n.bindings.set(f,{sink:E,descriptor:$}),hr(e,o,f,$,a),d){let y=!0;o.fdVariable?y=Ft(n,h):(n.overrides?.add(h),n.bindings.set(h,{descriptor:ss}),r.persistMovedSource&&n.parent&&(y=Ft(n.parent,h))),Ps(e,o,h,a||r.persistMovedSource===!0,$,y)}o.fdVariable||n.overrides?.add(f);continue}if(o.operator==="<&")return Oe(n,i,`bash: ${u}: ambiguous redirect
25
+ `);let b=await ai(e,n,u,"truncate");if("error"in b)return Oe(n,i,b.error);o.fd==null&&!o.fdVariable?(n.bindings.set(1,{sink:b.sink,descriptor:b.descriptor}),n.bindings.set(2,{sink:b.sink,descriptor:b.descriptor}),n.overrides?.add(1),n.overrides?.add(2),a&&(lt(e,1,b.descriptor),lt(e,2,b.descriptor))):(o.fdVariable?Lt(n,f,b.sink,b.descriptor):(n.bindings.set(f,{sink:b.sink,descriptor:b.descriptor}),n.overrides?.add(f)),hr(e,o,f,b.descriptor,a))}return{channels:n,legacyRedirections:i}}async function ci(e,t){let s=e.outputChannels,r=await De(e,s,t,{persistent:!0});if(r.error)return r;for(let n of r.channels.overrides??[]){let i=r.channels.bindings.get(n);i?.descriptor!==void 0&&Lt(s,n,i.sink,i.descriptor)}return{...r,channels:s}}async function ui(e,t){if(e.state.options.posix&&lr.has(t.name)){let r=`bash: line ${e.state.currentLine}: \`${t.name}': is a special builtin
26
+ `;throw await G(e,2,r,!0),new q(2)}let s={...t,sourceFile:t.sourceFile??e.state.currentSource??"main"};return e.state.functions.set(t.name,s),U()}async function Zo(e,t){let s=S(),r=!1;for(let n of t)if(!n.fdVariable){if((n.operator==="<<"||n.operator==="<<-")&&n.target.type==="HereDoc"){let i=n.target,a=await z(e,i.content);i.stripTabs&&(a=a.split(`
36
27
  `).map(l=>l.replace(/^\t+/,"")).join(`
37
- `)),(n.fd??0)===0&&(s=C(o),r=!0)}else if(n.operator==="<<<"&&n.target.type==="Word")s=C(`${await V(e,n.target)}
38
- `),r=!0;else if(n.operator==="<"&&n.target.type==="Word"){let i=await V(e,n.target),o=e.fs.resolvePath(e.state.cwd,i);try{s=await e.fs.readFile(o),r=!0}catch{}}return s}async function rs(e,t,s,r=w(),n){e.state.callDepth++,e.state.callDepth>e.limits.maxCallDepth&&(e.state.callDepth--,Ne(`${t.name}: maximum recursion depth (${e.limits.maxCallDepth}) exceeded, increase executionLimits.maxCallDepth`,"recursion")),e.state.funcNameStack||(e.state.funcNameStack=[]),e.state.callLineStack||(e.state.callLineStack=[]),e.state.sourceStack||(e.state.sourceStack=[]),e.state.funcNameStack.unshift(t.name),e.state.callLineStack.unshift(n??e.state.currentLine),e.state.sourceStack.unshift(t.sourceFile??"main"),e.state.localScopes.push(new Map),e.state.localExportedVars||(e.state.localExportedVars=[]),e.state.localExportedVars.push(new Set);let i=new Map;for(let u=0;u<s.length;u++)i.set(String(u+1),T(e.state.env,String(u+1))),g(e.state.env,String(u+1),s[u]);i.set("@",T(e.state.env,"@")),i.set("#",T(e.state.env,"#")),g(e.state.env,"@",s.join(" ")),g(e.state.env,"#",String(s.length));let o=()=>{let u=e.state.localScopes.length-1,c=e.state.localScopes.pop();if(c)for(let[f,h]of c)h===void 0?e.state.env.delete(f):e.state.env.set(f,h);if(bn(e,u),e.state.fullyUnsetLocals)for(let[f,h]of e.state.fullyUnsetLocals.entries())h===u&&e.state.fullyUnsetLocals.delete(f);if(e.state.localExportedVars&&e.state.localExportedVars.length>0){let f=e.state.localExportedVars.pop();if(f)for(let h of f)e.state.exportedVars?.delete(h)}for(let[f,h]of i)h===void 0?e.state.env.delete(f):g(e.state.env,f,h);e.state.funcNameStack?.shift(),e.state.callLineStack?.shift(),e.state.sourceStack?.shift(),e.state.callDepth--},{targets:a,error:l}=await Sn(e,t.redirections);if(l)return o(),R(w(),C(l),1);try{let u=await H(r),c;u.length>0?c=se(u):c=await io(e,t.redirections);let f=await e.executeCommand(t.body,c);return o(),Q(e,f,t.redirections,a)}catch(u){if(o(),u instanceof me){let c=R(u.stdout,u.stderr,u.exitCode);return Q(e,c,t.redirections,a)}throw u}}var An=["!","[[","]]","case","do","done","elif","else","esac","fi","for","function","if","in","then","time","until","while","{","}"],Fs=[".",":","[","alias","bg","bind","break","builtin","caller","cd","command","compgen","complete","compopt","continue","declare","dirs","disown","echo","enable","eval","exec","exit","export","false","fc","fg","getopts","hash","help","history","jobs","kill","let","local","logout","mapfile","popd","printf","pushd","pwd","read","readarray","readonly","return","set","shift","shopt","source","suspend","test","times","trap","true","type","typeset","ulimit","umask","unalias","unset","wait"],oo=["autocd","assoc_expand_once","cdable_vars","cdspell","checkhash","checkjobs","checkwinsize","cmdhist","compat31","compat32","compat40","compat41","compat42","compat43","compat44","complete_fullquote","direxpand","dirspell","dotglob","execfail","expand_aliases","extdebug","extglob","extquote","failglob","force_fignore","globasciiranges","globstar","gnu_errfmt","histappend","histreedit","histverify","hostcomplete","huponexit","inherit_errexit","interactive_comments","lastpipe","lithist","localvar_inherit","localvar_unset","login_shell","mailwarn","no_empty_cmd_completion","nocaseglob","nocasematch","nullglob","progcomp","progcomp_alias","promptvars","restricted_shell","shift_verbose","sourcepath","xpg_echo"],ao=Fs;async function Ls(e,t){let s=[],r=null,n="",i="",o=null,a=!1,l=!1,u=!1,c=null,f=null,h=null,d=[],m=["alias","arrayvar","binding","builtin","command","directory","disabled","enabled","export","file","function","group","helptopic","hostname","job","keyword","running","service","setopt","shopt","signal","stopped","user","variable"];for(let b=0;b<t.length;b++){let _=t[b];if(_==="-v")s.push("variable");else if(_==="-e")s.push("export");else if(_==="-f")s.push("file");else if(_==="-d")s.push("directory");else if(_==="-k")s.push("keyword");else if(_==="-A"){if(b++,b>=t.length)return k(`compgen: -A: option requires an argument
39
- `,2);let M=t[b];if(!m.includes(M))return k(`compgen: ${M}: invalid action name
40
- `,2);s.push(M)}else if(_==="-W"){if(b++,b>=t.length)return k(`compgen: -W: option requires an argument
41
- `,2);r=t[b]}else if(_==="-P"){if(b++,b>=t.length)return k(`compgen: -P: option requires an argument
42
- `,2);n=t[b]}else if(_==="-S"){if(b++,b>=t.length)return k(`compgen: -S: option requires an argument
43
- `,2);i=t[b]}else if(_==="-o"){if(b++,b>=t.length)return k(`compgen: -o: option requires an argument
44
- `,2);let M=t[b];if(M==="plusdirs")a=!0;else if(M==="dirnames")l=!0;else if(M==="default")u=!0;else if(!(M==="filenames"||M==="nospace"||M==="bashdefault"||M==="noquote"))return k(`compgen: ${M}: invalid option name
45
- `,2)}else if(_==="-F"){if(b++,b>=t.length)return k(`compgen: -F: option requires an argument
46
- `,2);f=t[b]}else if(_==="-C"){if(b++,b>=t.length)return k(`compgen: -C: option requires an argument
47
- `,2);h=t[b]}else if(_==="-X"){if(b++,b>=t.length)return k(`compgen: -X: option requires an argument
48
- `,2);c=t[b]}else if(_==="-G"){if(b++,b>=t.length)return k(`compgen: -G: option requires an argument
49
- `,2)}else if(_==="--"){d.push(...t.slice(b+1));break}else _.startsWith("-")||d.push(_)}o=d[0]??null;let p=[];if(l){let b=await Ms(e,o);p.push(...b)}if(u){let b=await Pn(e,o);p.push(...b)}for(let b of s)if(b==="variable"){let _=lo(e,o);p.push(..._)}else if(b==="export"){let _=co(e,o);p.push(..._)}else if(b==="function"){let _=uo(e,o);p.push(..._)}else if(b==="builtin"){let _=fo(o);p.push(..._)}else if(b==="keyword"){let _=ho(o);p.push(..._)}else if(b==="alias"){let _=po(e,o);p.push(..._)}else if(b==="shopt"){let _=mo(o);p.push(..._)}else if(b==="helptopic"){let _=yo(o);p.push(..._)}else if(b==="directory"){let _=await Ms(e,o);p.push(..._)}else if(b==="file"){let _=await Pn(e,o);p.push(..._)}else if(b==="user"){let _=go(o);p.push(..._)}else if(b==="command"){let _=await wo(e,o);p.push(..._)}if(r!==null)try{let b=await vo(e,r),_=bo(e,b);for(let M of _)(o===null||M.startsWith(o))&&p.push(M)}catch{return R(F,F,1)}if(a){let b=await Ms(e,o);for(let _ of b)p.includes(_)||p.push(_)}let v="";if(f!==null){let b=e.state.functions.get(f);if(b){let _=new Map;_.set("COMP_WORDS__length",T(e.state.env,"COMP_WORDS__length")),g(e.state.env,"COMP_WORDS__length","0"),_.set("COMP_CWORD",T(e.state.env,"COMP_CWORD")),g(e.state.env,"COMP_CWORD","-1"),_.set("COMP_LINE",T(e.state.env,"COMP_LINE")),g(e.state.env,"COMP_LINE",""),_.set("COMP_POINT",T(e.state.env,"COMP_POINT")),g(e.state.env,"COMP_POINT","0");let M=new Map;for(let P of e.state.env.keys())(P==="COMPREPLY"||P.startsWith("COMPREPLY_")||P==="COMPREPLY__length")&&(M.set(P,T(e.state.env,P)),e.state.env.delete(P));let $=["compgen",d[0]??"",""];try{let P=await rs(e,b,$,w());if(P.exitCode!==0)return ct(e,_),ct(e,M),R(F,P.stderr,1);v=j(await H(P.stdout));let N=Eo(e);p.push(...N)}catch{return ct(e,_),ct(e,M),R(F,F,1)}ct(e,_),ct(e,M)}}if(h!==null)try{let b=Te(h),_=await e.executeScript(b);if(_.exitCode!==0)return R(F,_.stderr,_.exitCode);let M=await H(_.stdout);if(M.length>0){let $=j(M).split(`
50
- `);for(let P of $)P.length>0&&p.push(P)}}catch(b){if(b.name==="ParseException")return k(`compgen: -C: ${b.message}
51
- `,2);throw b}let y=p;if(c!==null){let b=c.startsWith("!"),_=b?c.slice(1):c;y=p.filter(M=>{let $=ot(M,_,!1,!0);return b?$:!$})}if(y.length===0&&o!==null)return R(B(v),F,1);let S=y.map(b=>`${n}${b}${i}`).join(`
52
- `),A=v+(S?`${S}
53
- `:"");return X(A)}function lo(e,t){let s=new Set;for(let n of e.state.env.keys()){if(n.includes("_")&&/^[a-zA-Z_][a-zA-Z0-9_]*_\d+$/.test(n)||n.endsWith("__length"))continue;let i=n.split("_")[0];/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)?s.add(n):i&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i)&&e.state.env.has(`${i}__length`)&&s.add(i)}let r=Array.from(s);return t!==null&&(r=r.filter(n=>n.startsWith(t))),r.sort()}function co(e,t){let s=e.state.exportedVars??new Set,r=Array.from(s);return t!==null&&(r=r.filter(n=>n.startsWith(t))),r=r.filter(n=>n.includes("_")&&/^[a-zA-Z_][a-zA-Z0-9_]*_\d+$/.test(n)||n.endsWith("__length")?!1:e.state.env.has(n)),r.sort()}function uo(e,t){let s=Array.from(e.state.functions.keys());return t!==null&&(s=s.filter(r=>r.startsWith(t))),s.sort()}function fo(e){let t=[...Fs];return e!==null&&(t=t.filter(s=>s.startsWith(e))),t.sort()}function ho(e){let t=[...An];return e!==null&&(t=t.filter(s=>s.startsWith(e))),t.sort()}function po(e,t){let s=[];for(let n of e.state.env.keys())if(n.startsWith("BASH_ALIAS_")){let i=n.slice(11);s.push(i)}let r=s;return t!==null&&(r=r.filter(n=>n.startsWith(t))),r.sort()}function mo(e){let t=[...oo];return e!==null&&(t=t.filter(s=>s.startsWith(e))),t.sort()}function yo(e){let t=[...ao];return e!==null&&(t=t.filter(s=>s.startsWith(e))),t.sort()}async function Ms(e,t){let s=[];try{let r=e.state.cwd,n=t??"";if(t){let o=t.lastIndexOf("/");if(o!==-1){let a=t.slice(0,o)||"/";n=t.slice(o+1),a.startsWith("/")?r=a:r=`${e.state.cwd}/${a}`}}let i=await e.fs.readdir(r);for(let o of i){let a=`${r}/${o}`;try{if((await e.fs.stat(a)).isDirectory&&(!n||o.startsWith(n)))if(t?.includes("/")){let u=t.lastIndexOf("/"),c=t.slice(0,u+1);s.push(c+o)}else s.push(o)}catch{}}}catch{}return s.sort()}async function Pn(e,t){let s=[];try{let r=e.state.cwd,n=t??"";if(t){let o=t.lastIndexOf("/");if(o!==-1){let a=t.slice(0,o)||"/";n=t.slice(o+1),a.startsWith("/")?r=a:r=`${e.state.cwd}/${a}`}}let i=await e.fs.readdir(r);for(let o of i)if(!n||o.startsWith(n))if(t?.includes("/")){let a=t.lastIndexOf("/"),l=t.slice(0,a+1);s.push(l+o)}else s.push(o)}catch{}return s.sort()}function go(e){return["root","nobody"]}async function wo(e,t){let s=new Set;for(let i of Fs)s.add(i);for(let i of e.state.functions.keys())s.add(i);for(let i of e.state.env.keys())i.startsWith("BASH_ALIAS_")&&s.add(i.slice(11));for(let i of An)s.add(i);let r=T(e.state.env,"PATH","/usr/bin:/bin");for(let i of r.split(":"))if(i)try{let o=await e.fs.readdir(i);for(let a of o)s.add(a)}catch{}let n=Array.from(s);return t!==null&&(n=n.filter(i=>i.startsWith(t))),n.sort()}async function vo(e,t){let r=new Z().parseWordFromString(t,!1,!1);return await V(e,r)}function bo(e,t){let s=T(e.state.env,"IFS",`
54
- `);if(s.length===0)return[t];let r=new Set(s.split("")),n=[],i="",o=0;for(;o<t.length;){let a=t[o];if(a==="\\"&&o+1<t.length){let l=t[o+1];i+=l,o+=2}else r.has(a)?(i.length>0&&(n.push(i),i=""),o++):(i+=a,o++)}return i.length>0&&n.push(i),n}function ct(e,t){for(let[s,r]of t)r===void 0?e.state.env.delete(s):g(e.state.env,s,r)}function Eo(e){let t=[];if(e.state.env.get("COMPREPLY__length")!==void 0){let n=Ce(e,"COMPREPLY");for(let[,i]of n)t.push(i)}else e.state.env.has("COMPREPLY")&&t.push(T(e.state.env,"COMPREPLY"));return t}var So=["bashdefault","default","dirnames","filenames","noquote","nosort","nospace","plusdirs"];function Ws(e,t){e.state.completionSpecs||(e.state.completionSpecs=new Map);let s=!1,r=!1,n=!1,i,o,a,l=[],u=[],c=[];for(let f=0;f<t.length;f++){let h=t[f];if(h==="-p")s=!0;else if(h==="-r")r=!0;else if(h==="-D")n=!0;else if(h==="-W"){if(f++,f>=t.length)return k(`complete: -W: option requires an argument
55
- `,2);i=t[f]}else if(h==="-F"){if(f++,f>=t.length)return k(`complete: -F: option requires an argument
56
- `,2);o=t[f]}else if(h==="-o"){if(f++,f>=t.length)return k(`complete: -o: option requires an argument
57
- `,2);let d=t[f];if(!So.includes(d))return k(`complete: ${d}: invalid option name
58
- `,2);l.push(d)}else if(h==="-A"){if(f++,f>=t.length)return k(`complete: -A: option requires an argument
59
- `,2);u.push(t[f])}else if(h==="-C"){if(f++,f>=t.length)return k(`complete: -C: option requires an argument
60
- `,2);a=t[f]}else if(h==="-G"){if(f++,f>=t.length)return k(`complete: -G: option requires an argument
61
- `,2)}else if(h==="-P"){if(f++,f>=t.length)return k(`complete: -P: option requires an argument
62
- `,2)}else if(h==="-S"){if(f++,f>=t.length)return k(`complete: -S: option requires an argument
63
- `,2)}else if(h==="-X"){if(f++,f>=t.length)return k(`complete: -X: option requires an argument
64
- `,2)}else if(h==="--"){c.push(...t.slice(f+1));break}else h.startsWith("-")||c.push(h)}if(r){if(c.length===0)return e.state.completionSpecs.clear(),Pe();for(let f of c)e.state.completionSpecs.delete(f);return Pe()}if(s)return c.length===0?zs(e):zs(e,c);if(t.length===0||c.length===0&&!i&&!o&&!a&&l.length===0&&u.length===0&&!n)return zs(e);if(o&&c.length===0&&!n)return k(`complete: -F: option requires a command name
65
- `,2);if(n){let f={isDefault:!0};return i!==void 0&&(f.wordlist=i),o!==void 0&&(f.function=o),a!==void 0&&(f.command=a),l.length>0&&(f.options=l),u.length>0&&(f.actions=u),e.state.completionSpecs.set("__default__",f),Pe()}for(let f of c){let h=Object.create(null);i!==void 0&&(h.wordlist=i),o!==void 0&&(h.function=o),a!==void 0&&(h.command=a),l.length>0&&(h.options=l),u.length>0&&(h.actions=u),e.state.completionSpecs.set(f,h)}return Pe()}function zs(e,t){let s=e.state.completionSpecs;if(!s||s.size===0){if(t&&t.length>0){let i="";for(let o of t)i+=`complete: ${o}: no completion specification
66
- `;return R(F,B(i),1)}return Pe()}let r=[],n=t||Array.from(s.keys());for(let i of n){if(i==="__default__")continue;let o=s.get(i);if(!o){if(t)return R(B(r.join(`
28
+ `)),(n.fd??0)===0&&(s=V(a),r=!0)}else if(n.operator==="<<<"&&n.target.type==="Word")s=V(`${await z(e,n.target)}
29
+ `),r=!0;else if(n.operator==="<"&&n.target.type==="Word"){let i=await z(e,n.target),a=e.fs.resolvePath(e.state.cwd,i);try{s=await e.fs.readFile(a),r=!0}catch{}}}return s}async function As(e,t,s,r=S(),n){e.state.callDepth++,e.state.callDepth>e.limits.maxCallDepth&&(e.state.callDepth--,Me(`${t.name}: maximum recursion depth (${e.limits.maxCallDepth}) exceeded, increase executionLimits.maxCallDepth`,"recursion")),e.state.funcNameStack||(e.state.funcNameStack=[]),e.state.callLineStack||(e.state.callLineStack=[]),e.state.sourceStack||(e.state.sourceStack=[]),e.state.funcNameStack.unshift(t.name),e.state.callLineStack.unshift(n??e.state.currentLine),e.state.sourceStack.unshift(t.sourceFile??"main"),e.state.localScopes.push(new Map),e.state.localExportedVars||(e.state.localExportedVars=[]),e.state.localExportedVars.push(new Set);let i=new Map;for(let o=0;o<s.length;o++)i.set(String(o+1),T(e.state.env,String(o+1))),g(e.state.env,String(o+1),s[o]);i.set("@",T(e.state.env,"@")),i.set("#",T(e.state.env,"#")),g(e.state.env,"@",s.join(" ")),g(e.state.env,"#",String(s.length));let a=()=>{let o=e.state.localScopes.length-1,l=e.state.localScopes.pop();if(l)for(let[u,c]of l)c===void 0?e.state.env.delete(u):e.state.env.set(u,c);if(ni(e,o),e.state.fullyUnsetLocals)for(let[u,c]of e.state.fullyUnsetLocals.entries())c===o&&e.state.fullyUnsetLocals.delete(u);if(e.state.localExportedVars&&e.state.localExportedVars.length>0){let u=e.state.localExportedVars.pop();if(u)for(let c of u)e.state.exportedVars?.delete(c)}for(let[u,c]of i)c===void 0?e.state.env.delete(u):g(e.state.env,u,c);e.state.funcNameStack?.shift(),e.state.callLineStack?.shift(),e.state.sourceStack?.shift(),e.state.callDepth--};try{let o=await De(e,e.outputChannels,t.redirections);return o.error?await K(e,o.channels,()=>se(e,()=>Promise.resolve(o.error))):await K(e,o.channels,async()=>{try{let l=await Et(e,o.legacyRedirections);if(l)return await se(e,()=>Promise.resolve(l));let u=await re(r),c=u.length>0?fe(u):await Zo(e,o.legacyRedirections),f=await e.executeCommand(t.body,c);return await se(e,()=>Promise.resolve(f))}catch(l){let{writeFailure:u}=await Qe(e,l);if(u)return u;if(l instanceof ve)return F(S(),S(),l.exitCode);throw l}})}catch(o){throw await te(e,o),o}finally{a()}}var di=["!","[[","]]","case","do","done","elif","else","esac","fi","for","function","if","in","then","time","until","while","{","}"],mr=[".",":","[","alias","bg","bind","break","builtin","caller","cd","command","compgen","complete","compopt","continue","declare","dirs","disown","echo","enable","eval","exec","exit","export","false","fc","fg","getopts","hash","help","history","jobs","kill","let","local","logout","mapfile","popd","printf","pushd","pwd","read","readarray","readonly","return","set","shift","shopt","source","suspend","test","times","trap","true","type","typeset","ulimit","umask","unalias","unset","wait"],Xo=["autocd","assoc_expand_once","cdable_vars","cdspell","checkhash","checkjobs","checkwinsize","cmdhist","compat31","compat32","compat40","compat41","compat42","compat43","compat44","complete_fullquote","direxpand","dirspell","dotglob","execfail","expand_aliases","extdebug","extglob","extquote","failglob","force_fignore","globasciiranges","globstar","gnu_errfmt","histappend","histreedit","histverify","hostcomplete","huponexit","inherit_errexit","interactive_comments","lastpipe","lithist","localvar_inherit","localvar_unset","login_shell","mailwarn","no_empty_cmd_completion","nocaseglob","nocasematch","nullglob","progcomp","progcomp_alias","promptvars","restricted_shell","shift_verbose","sourcepath","xpg_echo"],Jo=mr;async function yr(e,t){let s=[],r=null,n="",i="",a=null,o=!1,l=!1,u=!1,c=null,f=null,d=null,p=[],m=["alias","arrayvar","binding","builtin","command","directory","disabled","enabled","export","file","function","group","helptopic","hostname","job","keyword","running","service","setopt","shopt","signal","stopped","user","variable"];for(let v=0;v<t.length;v++){let C=t[v];if(C==="-v")s.push("variable");else if(C==="-e")s.push("export");else if(C==="-f")s.push("file");else if(C==="-d")s.push("directory");else if(C==="-k")s.push("keyword");else if(C==="-A"){if(v++,v>=t.length)return P(`compgen: -A: option requires an argument
30
+ `,2);let N=t[v];if(!m.includes(N))return P(`compgen: ${N}: invalid action name
31
+ `,2);s.push(N)}else if(C==="-W"){if(v++,v>=t.length)return P(`compgen: -W: option requires an argument
32
+ `,2);r=t[v]}else if(C==="-P"){if(v++,v>=t.length)return P(`compgen: -P: option requires an argument
33
+ `,2);n=t[v]}else if(C==="-S"){if(v++,v>=t.length)return P(`compgen: -S: option requires an argument
34
+ `,2);i=t[v]}else if(C==="-o"){if(v++,v>=t.length)return P(`compgen: -o: option requires an argument
35
+ `,2);let N=t[v];if(N==="plusdirs")o=!0;else if(N==="dirnames")l=!0;else if(N==="default")u=!0;else if(!(N==="filenames"||N==="nospace"||N==="bashdefault"||N==="noquote"))return P(`compgen: ${N}: invalid option name
36
+ `,2)}else if(C==="-F"){if(v++,v>=t.length)return P(`compgen: -F: option requires an argument
37
+ `,2);f=t[v]}else if(C==="-C"){if(v++,v>=t.length)return P(`compgen: -C: option requires an argument
38
+ `,2);d=t[v]}else if(C==="-X"){if(v++,v>=t.length)return P(`compgen: -X: option requires an argument
39
+ `,2);c=t[v]}else if(C==="-G"){if(v++,v>=t.length)return P(`compgen: -G: option requires an argument
40
+ `,2)}else if(C==="--"){p.push(...t.slice(v+1));break}else C.startsWith("-")||p.push(C)}a=p[0]??null;let h=[];if(l){let v=await pr(e,a);h.push(...v)}if(u){let v=await fi(e,a);h.push(...v)}for(let v of s)if(v==="variable"){let C=Ko(e,a);h.push(...C)}else if(v==="export"){let C=Yo(e,a);h.push(...C)}else if(v==="function"){let C=Qo(e,a);h.push(...C)}else if(v==="builtin"){let C=ea(a);h.push(...C)}else if(v==="keyword"){let C=ta(a);h.push(...C)}else if(v==="alias"){let C=sa(e,a);h.push(...C)}else if(v==="shopt"){let C=ra(a);h.push(...C)}else if(v==="helptopic"){let C=na(a);h.push(...C)}else if(v==="directory"){let C=await pr(e,a);h.push(...C)}else if(v==="file"){let C=await fi(e,a);h.push(...C)}else if(v==="user"){let C=ia(a);h.push(...C)}else if(v==="command"){let C=await oa(e,a);h.push(...C)}if(r!==null)try{let v=await aa(e,r),C=la(e,v);for(let N of C)(a===null||N.startsWith(a))&&h.push(N)}catch{return F(R,R,1)}if(o){let v=await pr(e,a);for(let C of v)h.includes(C)||h.push(C)}let b="";if(f!==null){let v=e.state.functions.get(f);if(v){let C=new Map;C.set("COMP_WORDS__length",T(e.state.env,"COMP_WORDS__length")),g(e.state.env,"COMP_WORDS__length","0"),C.set("COMP_CWORD",T(e.state.env,"COMP_CWORD")),g(e.state.env,"COMP_CWORD","-1"),C.set("COMP_LINE",T(e.state.env,"COMP_LINE")),g(e.state.env,"COMP_LINE",""),C.set("COMP_POINT",T(e.state.env,"COMP_POINT")),g(e.state.env,"COMP_POINT","0");let N=new Map;for(let k of e.state.env.keys())(k==="COMPREPLY"||k.startsWith("COMPREPLY_")||k==="COMPREPLY__length")&&(N.set(k,T(e.state.env,k)),e.state.env.delete(k));let I=["compgen",p[0]??"",""];try{let k=_e(),A=_e(),O=await K(e,{bindings:new Map([[1,{sink:k}],[2,{sink:A}]])},()=>As(e,v,I,S()));if(await Wt(e,O.stderr,A),O.exitCode!==0)return St(e,C),St(e,N),F(R,A.stream(),1);await Wt(e,O.stdout,k),b=B(await re(k.stream()));let M=ca(e);h.push(...M)}catch{return St(e,C),St(e,N),F(R,R,1)}St(e,C),St(e,N)}}if(d!==null)try{let v=Fe(d),C=_e(),N=_e(),I=await K(e,{bindings:new Map([[1,{sink:C}],[2,{sink:N}]])},()=>e.executeScript(v));if(await Wt(e,I.stderr,N),I.exitCode!==0)return F(R,N.stream(),I.exitCode);await Wt(e,I.stdout,C);let k=await re(C.stream());if(k.length>0){let A=B(k).split(`
41
+ `);for(let O of A)O.length>0&&h.push(O)}}catch(v){if(v.name==="ParseException")return P(`compgen: -C: ${v.message}
42
+ `,2);throw v}let E=h;if(c!==null){let v=c.startsWith("!"),C=v?c.slice(1):c;E=h.filter(N=>{let I=vt(N,C,!1,!0);return v?I:!I})}if(E.length===0&&a!==null)return F(W(b),R,1);let $=E.map(v=>`${n}${v}${i}`).join(`
43
+ `),y=b+($?`${$}
44
+ `:"");return H(y)}function Ko(e,t){let s=new Set;for(let n of e.state.env.keys()){if(n.includes("_")&&/^[a-zA-Z_][a-zA-Z0-9_]*_\d+$/.test(n)||n.endsWith("__length"))continue;let i=n.split("_")[0];/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)?s.add(n):i&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i)&&e.state.env.has(`${i}__length`)&&s.add(i)}let r=Array.from(s);return t!==null&&(r=r.filter(n=>n.startsWith(t))),r.sort()}function Yo(e,t){let s=e.state.exportedVars??new Set,r=Array.from(s);return t!==null&&(r=r.filter(n=>n.startsWith(t))),r=r.filter(n=>n.includes("_")&&/^[a-zA-Z_][a-zA-Z0-9_]*_\d+$/.test(n)||n.endsWith("__length")?!1:e.state.env.has(n)),r.sort()}function Qo(e,t){let s=Array.from(e.state.functions.keys());return t!==null&&(s=s.filter(r=>r.startsWith(t))),s.sort()}function ea(e){let t=[...mr];return e!==null&&(t=t.filter(s=>s.startsWith(e))),t.sort()}function ta(e){let t=[...di];return e!==null&&(t=t.filter(s=>s.startsWith(e))),t.sort()}function sa(e,t){let s=[];for(let n of e.state.env.keys())if(n.startsWith("BASH_ALIAS_")){let i=n.slice(11);s.push(i)}let r=s;return t!==null&&(r=r.filter(n=>n.startsWith(t))),r.sort()}function ra(e){let t=[...Xo];return e!==null&&(t=t.filter(s=>s.startsWith(e))),t.sort()}function na(e){let t=[...Jo];return e!==null&&(t=t.filter(s=>s.startsWith(e))),t.sort()}async function pr(e,t){let s=[];try{let r=e.state.cwd,n=t??"";if(t){let a=t.lastIndexOf("/");if(a!==-1){let o=t.slice(0,a)||"/";n=t.slice(a+1),o.startsWith("/")?r=o:r=`${e.state.cwd}/${o}`}}let i=await e.fs.readdir(r);for(let a of i){let o=`${r}/${a}`;try{if((await e.fs.stat(o)).isDirectory&&(!n||a.startsWith(n)))if(t?.includes("/")){let u=t.lastIndexOf("/"),c=t.slice(0,u+1);s.push(c+a)}else s.push(a)}catch{}}}catch{}return s.sort()}async function fi(e,t){let s=[];try{let r=e.state.cwd,n=t??"";if(t){let a=t.lastIndexOf("/");if(a!==-1){let o=t.slice(0,a)||"/";n=t.slice(a+1),o.startsWith("/")?r=o:r=`${e.state.cwd}/${o}`}}let i=await e.fs.readdir(r);for(let a of i)if(!n||a.startsWith(n))if(t?.includes("/")){let o=t.lastIndexOf("/"),l=t.slice(0,o+1);s.push(l+a)}else s.push(a)}catch{}return s.sort()}function ia(e){return["root","nobody"]}async function oa(e,t){let s=new Set;for(let i of mr)s.add(i);for(let i of e.state.functions.keys())s.add(i);for(let i of e.state.env.keys())i.startsWith("BASH_ALIAS_")&&s.add(i.slice(11));for(let i of di)s.add(i);let r=T(e.state.env,"PATH","/usr/bin:/bin");for(let i of r.split(":"))if(i)try{let a=await e.fs.readdir(i);for(let o of a)s.add(o)}catch{}let n=Array.from(s);return t!==null&&(n=n.filter(i=>i.startsWith(t))),n.sort()}async function aa(e,t){let r=new X().parseWordFromString(t,!1,!1);return await z(e,r)}function la(e,t){let s=T(e.state.env,"IFS",`
45
+ `);if(s.length===0)return[t];let r=new Set(s.split("")),n=[],i="",a=0;for(;a<t.length;){let o=t[a];if(o==="\\"&&a+1<t.length){let l=t[a+1];i+=l,a+=2}else r.has(o)?(i.length>0&&(n.push(i),i=""),a++):(i+=o,a++)}return i.length>0&&n.push(i),n}function St(e,t){for(let[s,r]of t)r===void 0?e.state.env.delete(s):g(e.state.env,s,r)}function ca(e){let t=[];if(e.state.env.get("COMPREPLY__length")!==void 0){let n=Ie(e,"COMPREPLY");for(let[,i]of n)t.push(i)}else e.state.env.has("COMPREPLY")&&t.push(T(e.state.env,"COMPREPLY"));return t}var ua=["bashdefault","default","dirnames","filenames","noquote","nosort","nospace","plusdirs"];function wr(e,t){e.state.completionSpecs||(e.state.completionSpecs=new Map);let s=!1,r=!1,n=!1,i,a,o,l=[],u=[],c=[];for(let f=0;f<t.length;f++){let d=t[f];if(d==="-p")s=!0;else if(d==="-r")r=!0;else if(d==="-D")n=!0;else if(d==="-W"){if(f++,f>=t.length)return P(`complete: -W: option requires an argument
46
+ `,2);i=t[f]}else if(d==="-F"){if(f++,f>=t.length)return P(`complete: -F: option requires an argument
47
+ `,2);a=t[f]}else if(d==="-o"){if(f++,f>=t.length)return P(`complete: -o: option requires an argument
48
+ `,2);let p=t[f];if(!ua.includes(p))return P(`complete: ${p}: invalid option name
49
+ `,2);l.push(p)}else if(d==="-A"){if(f++,f>=t.length)return P(`complete: -A: option requires an argument
50
+ `,2);u.push(t[f])}else if(d==="-C"){if(f++,f>=t.length)return P(`complete: -C: option requires an argument
51
+ `,2);o=t[f]}else if(d==="-G"){if(f++,f>=t.length)return P(`complete: -G: option requires an argument
52
+ `,2)}else if(d==="-P"){if(f++,f>=t.length)return P(`complete: -P: option requires an argument
53
+ `,2)}else if(d==="-S"){if(f++,f>=t.length)return P(`complete: -S: option requires an argument
54
+ `,2)}else if(d==="-X"){if(f++,f>=t.length)return P(`complete: -X: option requires an argument
55
+ `,2)}else if(d==="--"){c.push(...t.slice(f+1));break}else d.startsWith("-")||c.push(d)}if(r){if(c.length===0)return e.state.completionSpecs.clear(),Ne();for(let f of c)e.state.completionSpecs.delete(f);return Ne()}if(s)return c.length===0?gr(e):gr(e,c);if(t.length===0||c.length===0&&!i&&!a&&!o&&l.length===0&&u.length===0&&!n)return gr(e);if(a&&c.length===0&&!n)return P(`complete: -F: option requires a command name
56
+ `,2);if(n){let f={isDefault:!0};return i!==void 0&&(f.wordlist=i),a!==void 0&&(f.function=a),o!==void 0&&(f.command=o),l.length>0&&(f.options=l),u.length>0&&(f.actions=u),e.state.completionSpecs.set("__default__",f),Ne()}for(let f of c){let d=Object.create(null);i!==void 0&&(d.wordlist=i),a!==void 0&&(d.function=a),o!==void 0&&(d.command=o),l.length>0&&(d.options=l),u.length>0&&(d.actions=u),e.state.completionSpecs.set(f,d)}return Ne()}function gr(e,t){let s=e.state.completionSpecs;if(!s||s.size===0){if(t&&t.length>0){let i="";for(let a of t)i+=`complete: ${a}: no completion specification
57
+ `;return F(R,W(i),1)}return Ne()}let r=[],n=t||Array.from(s.keys());for(let i of n){if(i==="__default__")continue;let a=s.get(i);if(!a){if(t)return F(W(r.join(`
67
58
  `)+(r.length>0?`
68
- `:"")),B(`complete: ${i}: no completion specification
69
- `),1);continue}let a="complete";if(o.options)for(let l of o.options)a+=` -o ${l}`;if(o.actions)for(let l of o.actions)a+=` -A ${l}`;o.wordlist!==void 0&&(o.wordlist.includes(" ")||o.wordlist.includes("'")?a+=` -W '${o.wordlist}'`:a+=` -W ${o.wordlist}`),o.function!==void 0&&(a+=` -F ${o.function}`),o.isDefault&&(a+=" -D"),a+=` ${i}`,r.push(a)}return r.length===0?Pe():X(`${r.join(`
59
+ `:"")),W(`complete: ${i}: no completion specification
60
+ `),1);continue}let o="complete";if(a.options)for(let l of a.options)o+=` -o ${l}`;if(a.actions)for(let l of a.actions)o+=` -A ${l}`;a.wordlist!==void 0&&(a.wordlist.includes(" ")||a.wordlist.includes("'")?o+=` -W '${a.wordlist}'`:o+=` -W ${a.wordlist}`),a.function!==void 0&&(o+=` -F ${a.function}`),a.isDefault&&(o+=" -D"),o+=` ${i}`,r.push(o)}return r.length===0?Ne():H(`${r.join(`
70
61
  `)}
71
- `)}var kn=["bashdefault","default","dirnames","filenames","noquote","nosort","nospace","plusdirs"];function Vs(e,t){e.state.completionSpecs||(e.state.completionSpecs=new Map);let s=!1,r=!1,n=[],i=[],o=[];for(let a=0;a<t.length;a++){let l=t[a];if(l==="-D")s=!0;else if(l==="-E")r=!0;else if(l==="-o"){if(a++,a>=t.length)return k(`compopt: -o: option requires an argument
72
- `,2);let u=t[a];if(!kn.includes(u))return k(`compopt: ${u}: invalid option name
73
- `,2);n.push(u)}else if(l==="+o"){if(a++,a>=t.length)return k(`compopt: +o: option requires an argument
74
- `,2);let u=t[a];if(!kn.includes(u))return k(`compopt: ${u}: invalid option name
75
- `,2);i.push(u)}else if(l==="--"){o.push(...t.slice(a+1));break}else!l.startsWith("-")&&!l.startsWith("+")&&o.push(l)}if(s){let a=e.state.completionSpecs.get("__default__")??{isDefault:!0},l=new Set(a.options??[]);for(let u of n)l.add(u);for(let u of i)l.delete(u);return a.options=l.size>0?Array.from(l):void 0,e.state.completionSpecs.set("__default__",a),Pe()}if(r){let a=e.state.completionSpecs.get("__empty__")??{},l=new Set(a.options??[]);for(let u of n)l.add(u);for(let u of i)l.delete(u);return a.options=l.size>0?Array.from(l):void 0,e.state.completionSpecs.set("__empty__",a),Pe()}if(o.length>0){for(let a of o){let l=e.state.completionSpecs.get(a)??{},u=new Set(l.options??[]);for(let c of n)u.add(c);for(let c of i)u.delete(c);l.options=u.size>0?Array.from(u):void 0,e.state.completionSpecs.set(a,l)}return Pe()}return k(`compopt: not currently executing completion function
76
- `,1)}function Bs(e,t){if(e.state.loopDepth===0){if(e.state.parentHasLoopContext)throw new Ve;return U()}if(t.length>1)throw new Y(1,w(),C(`bash: continue: too many arguments
77
- `));let s=1;if(t.length>0){let r=Number.parseInt(t[0],10);if(Number.isNaN(r)||r<1)throw new Y(1,w(),C(`bash: continue: ${t[0]}: numeric argument required
78
- `));s=r}throw new Se(s)}function J(e,t){let s=T(e.state.env,"HOME","/home/user");return t.split(":").map(i=>i==="~"?s:i==="~root"?"/root":i.startsWith("~/")?s+i.slice(1):i.startsWith("~root/")?`/root${i.slice(5)}`:i).join(":")}function js(e){for(let t=0;t<e.length;t++){let s=e.charCodeAt(t);if(s<32||s===127)return!0}return!1}function Us(e){let t="$'";for(let s=0;s<e.length;s++){let r=e[s],n=e.charCodeAt(s);n===7?t+="\\a":n===8?t+="\\b":n===9?t+="\\t":n===10?t+="\\n":n===11?t+="\\v":n===12?t+="\\f":n===13?t+="\\r":n===27?t+="\\e":n===39?t+="\\'":n===92?t+="\\\\":n<32||n===127?t+=`\\${n.toString(8).padStart(3,"0")}`:t+=r}return t+="'",t}function ns(e){return js(e)?Us(e):/^[a-zA-Z0-9_/.:\-@%+,=]*$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}function Ke(e){return js(e)?Us(e):`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function Hs(e){return js(e)?Us(e):`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function _n(e,t){let s="";return e.state.integerVars?.has(t)&&(s+="i"),e.state.lowercaseVars?.has(t)&&(s+="l"),ye(e,t)&&(s+="n"),e.state.readonlyVars?.has(t)&&(s+="r"),e.state.uppercaseVars?.has(t)&&(s+="u"),e.state.exportedVars?.has(t)&&(s+="x"),s===""?"--":`-${s}`}function Gs(e){return e===""?"''":/[\s'\\]/.test(e)?`'${e.replace(/'/g,"'\\''")}'`:e}function Cn(e,t){let s="",r="",n=!1;for(let i of t){let o=_n(e,i);if(e.state.associativeArrays?.has(i)){let u=je(e,i);if(u.length===0)s+=`declare -A ${i}=()
79
- `;else{let c=u.map(f=>{let h=T(e.state.env,`${i}_${f}`,""),d=Gs(h);return`['${f}']=${d}`});s+=`declare -A ${i}=(${c.join(" ")})
80
- `}continue}let l=ce(e,i);if(l.length>0){let u=l.map(c=>{let f=T(e.state.env,`${i}_${c}`,"");return`[${c}]=${Ke(f)}`});s+=`declare -a ${i}=(${u.join(" ")})
62
+ `)}var hi=["bashdefault","default","dirnames","filenames","noquote","nosort","nospace","plusdirs"];function vr(e,t){e.state.completionSpecs||(e.state.completionSpecs=new Map);let s=!1,r=!1,n=[],i=[],a=[];for(let o=0;o<t.length;o++){let l=t[o];if(l==="-D")s=!0;else if(l==="-E")r=!0;else if(l==="-o"){if(o++,o>=t.length)return P(`compopt: -o: option requires an argument
63
+ `,2);let u=t[o];if(!hi.includes(u))return P(`compopt: ${u}: invalid option name
64
+ `,2);n.push(u)}else if(l==="+o"){if(o++,o>=t.length)return P(`compopt: +o: option requires an argument
65
+ `,2);let u=t[o];if(!hi.includes(u))return P(`compopt: ${u}: invalid option name
66
+ `,2);i.push(u)}else if(l==="--"){a.push(...t.slice(o+1));break}else!l.startsWith("-")&&!l.startsWith("+")&&a.push(l)}if(s){let o=e.state.completionSpecs.get("__default__")??{isDefault:!0},l=new Set(o.options??[]);for(let u of n)l.add(u);for(let u of i)l.delete(u);return o.options=l.size>0?Array.from(l):void 0,e.state.completionSpecs.set("__default__",o),Ne()}if(r){let o=e.state.completionSpecs.get("__empty__")??{},l=new Set(o.options??[]);for(let u of n)l.add(u);for(let u of i)l.delete(u);return o.options=l.size>0?Array.from(l):void 0,e.state.completionSpecs.set("__empty__",o),Ne()}if(a.length>0){for(let o of a){let l=e.state.completionSpecs.get(o)??{},u=new Set(l.options??[]);for(let c of n)u.add(c);for(let c of i)u.delete(c);l.options=u.size>0?Array.from(u):void 0,e.state.completionSpecs.set(o,l)}return Ne()}return P(`compopt: not currently executing completion function
67
+ `,1)}async function br(e,t){if(e.state.loopDepth===0){if(e.state.parentHasLoopContext)throw new Ge;return U()}if(t.length>1)throw await G(e,2,`bash: continue: too many arguments
68
+ `,!0),new q(1);let s=1;if(t.length>0){let r=Number.parseInt(t[0],10);if(Number.isNaN(r)||r<1)throw await G(e,2,`bash: continue: ${t[0]}: numeric argument required
69
+ `,!0),new q(1);s=r}throw new Ae(s)}function ne(e,t){let s=T(e.state.env,"HOME","/home/user");return t.split(":").map(i=>i==="~"?s:i==="~root"?"/root":i.startsWith("~/")?s+i.slice(1):i.startsWith("~root/")?`/root${i.slice(5)}`:i).join(":")}function Er(e){for(let t=0;t<e.length;t++){let s=e.charCodeAt(t);if(s<32||s===127)return!0}return!1}function Sr(e){let t="$'";for(let s=0;s<e.length;s++){let r=e[s],n=e.charCodeAt(s);n===7?t+="\\a":n===8?t+="\\b":n===9?t+="\\t":n===10?t+="\\n":n===11?t+="\\v":n===12?t+="\\f":n===13?t+="\\r":n===27?t+="\\e":n===39?t+="\\'":n===92?t+="\\\\":n<32||n===127?t+=`\\${n.toString(8).padStart(3,"0")}`:t+=r}return t+="'",t}function ks(e){return Er(e)?Sr(e):/^[a-zA-Z0-9_/.:\-@%+,=]*$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}function ct(e){return Er(e)?Sr(e):`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function $r(e){return Er(e)?Sr(e):`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function pi(e,t){let s="";return e.state.integerVars?.has(t)&&(s+="i"),e.state.lowercaseVars?.has(t)&&(s+="l"),Ee(e,t)&&(s+="n"),e.state.readonlyVars?.has(t)&&(s+="r"),e.state.uppercaseVars?.has(t)&&(s+="u"),e.state.exportedVars?.has(t)&&(s+="x"),s===""?"--":`-${s}`}function Pr(e){return e===""?"''":/[\s'\\]/.test(e)?`'${e.replace(/'/g,"'\\''")}'`:e}function mi(e,t){let s="",r="",n=!1;for(let i of t){let a=pi(e,i);if(e.state.associativeArrays?.has(i)){let u=et(e,i);if(u.length===0)s+=`declare -A ${i}=()
70
+ `;else{let c=u.map(f=>{let d=T(e.state.env,`${i}_${f}`,""),p=Pr(d);return`['${f}']=${p}`});s+=`declare -A ${i}=(${c.join(" ")})
71
+ `}continue}let l=me(e,i);if(l.length>0){let u=l.map(c=>{let f=T(e.state.env,`${i}_${c}`,"");return`[${c}]=${ct(f)}`});s+=`declare -a ${i}=(${u.join(" ")})
81
72
  `;continue}if(e.state.env.has(`${i}__length`)){s+=`declare -a ${i}=()
82
- `;continue}if(e.state.env.has(i)){let u=T(e.state.env,i);s+=`declare ${o} ${i}=${Hs(u)}
83
- `}else{let u=e.state.declaredVars?.has(i),c=e.state.localVarDepth?.has(i);u||c?s+=`declare ${o} ${i}
73
+ `;continue}if(e.state.env.has(i)){let u=T(e.state.env,i);s+=`declare ${a} ${i}=${$r(u)}
74
+ `}else{let u=e.state.declaredVars?.has(i),c=e.state.localVarDepth?.has(i);u||c?s+=`declare ${a} ${i}
84
75
  `:(r+=`bash: declare: ${i}: not found
85
- `,n=!0)}}return R(B(s),B(r),n?1:0)}function xn(e,t){let{filterExport:s,filterReadonly:r,filterNameref:n,filterIndexedArray:i,filterAssocArray:o}=t,a=s||r||n||i||o,l="",u=new Set;for(let f of e.state.env.keys()){if(f.startsWith("BASH_"))continue;if(f.endsWith("__length")){let d=f.slice(0,-8);u.add(d);continue}let h=f.lastIndexOf("_");if(h>0){let d=f.slice(0,h),m=f.slice(h+1);if(/^\d+$/.test(m)||e.state.associativeArrays?.has(d)){u.add(d);continue}}u.add(f)}if(e.state.localVarDepth)for(let f of e.state.localVarDepth.keys())u.add(f);if(e.state.associativeArrays)for(let f of e.state.associativeArrays)u.add(f);let c=Array.from(u).sort();for(let f of c){let h=_n(e,f),d=e.state.associativeArrays?.has(f),m=ce(e,f),p=!d&&(m.length>0||e.state.env.has(`${f}__length`));if(!(a&&(o&&!d||i&&!p||s&&!e.state.exportedVars?.has(f)||r&&!e.state.readonlyVars?.has(f)||n&&!ye(e,f)))){if(d){let v=je(e,f);if(v.length===0)l+=`declare -A ${f}=()
86
- `;else{let y=v.map(S=>{let A=T(e.state.env,`${f}_${S}`,""),b=Gs(A);return`['${S}']=${b}`});l+=`declare -A ${f}=(${y.join(" ")})
87
- `}continue}if(m.length>0){let v=m.map(y=>{let S=T(e.state.env,`${f}_${y}`,"");return`[${y}]=${Ke(S)}`});l+=`declare -a ${f}=(${v.join(" ")})
76
+ `,n=!0)}}return F(W(s),W(r),n?1:0)}function yi(e,t){let{filterExport:s,filterReadonly:r,filterNameref:n,filterIndexedArray:i,filterAssocArray:a}=t,o=s||r||n||i||a,l="",u=new Set;for(let f of e.state.env.keys()){if(f.startsWith("BASH_"))continue;if(f.endsWith("__length")){let p=f.slice(0,-8);u.add(p);continue}let d=f.lastIndexOf("_");if(d>0){let p=f.slice(0,d),m=f.slice(d+1);if(/^\d+$/.test(m)||e.state.associativeArrays?.has(p)){u.add(p);continue}}u.add(f)}if(e.state.localVarDepth)for(let f of e.state.localVarDepth.keys())u.add(f);if(e.state.associativeArrays)for(let f of e.state.associativeArrays)u.add(f);let c=Array.from(u).sort();for(let f of c){let d=pi(e,f),p=e.state.associativeArrays?.has(f),m=me(e,f),h=!p&&(m.length>0||e.state.env.has(`${f}__length`));if(!(o&&(a&&!p||i&&!h||s&&!e.state.exportedVars?.has(f)||r&&!e.state.readonlyVars?.has(f)||n&&!Ee(e,f)))){if(p){let b=et(e,f);if(b.length===0)l+=`declare -A ${f}=()
77
+ `;else{let E=b.map($=>{let y=T(e.state.env,`${f}_${$}`,""),v=Pr(y);return`['${$}']=${v}`});l+=`declare -A ${f}=(${E.join(" ")})
78
+ `}continue}if(m.length>0){let b=m.map(E=>{let $=T(e.state.env,`${f}_${E}`,"");return`[${E}]=${ct($)}`});l+=`declare -a ${f}=(${b.join(" ")})
88
79
  `;continue}if(e.state.env.has(`${f}__length`)){l+=`declare -a ${f}=()
89
- `;continue}if(e.state.env.has(f)){let v=T(e.state.env,f);l+=`declare ${h} ${f}=${Hs(v)}
90
- `}}}return X(l)}function Nn(e){let t="",s=Array.from(e.state.associativeArrays??[]).sort();for(let r of s){let n=je(e,r);if(n.length===0)t+=`declare -A ${r}=()
91
- `;else{let i=n.map(o=>{let a=T(e.state.env,`${r}_${o}`,""),l=Gs(a);return`['${o}']=${l}`});t+=`declare -A ${r}=(${i.join(" ")})
92
- `}}return X(t)}function Tn(e){let t="",s=new Set;for(let n of e.state.env.keys()){if(n.startsWith("BASH_"))continue;if(n.endsWith("__length")){let o=n.slice(0,-8);e.state.associativeArrays?.has(o)||s.add(o);continue}let i=n.lastIndexOf("_");if(i>0){let o=n.slice(0,i),a=n.slice(i+1);/^\d+$/.test(a)&&(e.state.associativeArrays?.has(o)||s.add(o))}}let r=Array.from(s).sort();for(let n of r){let i=ce(e,n);if(i.length===0)t+=`declare -a ${n}=()
93
- `;else{let o=i.map(a=>{let l=T(e.state.env,`${n}_${a}`,"");return`[${a}]=${Ke(l)}`});t+=`declare -a ${n}=(${o.join(" ")})
94
- `}}return X(t)}function On(e){let t="",s=new Set;for(let n of e.state.env.keys()){if(n.startsWith("BASH_"))continue;if(n.endsWith("__length")){let o=n.slice(0,-8);s.add(o);continue}let i=n.lastIndexOf("_");if(i>0){let o=n.slice(0,i),a=n.slice(i+1);if(/^\d+$/.test(a)||e.state.associativeArrays?.has(o)){s.add(o);continue}}s.add(n)}let r=Array.from(s).sort();for(let n of r)e.state.associativeArrays?.has(n)||ce(e,n).length>0||e.state.env.has(`${n}__length`)||e.state.env.has(n)&&(t+=`${n}=${ns(T(e.state.env,n))}
95
- `);return X(t)}function qs(e,t){e.state.integerVars??=new Set,e.state.integerVars.add(t)}function $t(e,t){return e.state.integerVars?.has(t)??!1}function Zs(e,t){e.state.lowercaseVars??=new Set,e.state.lowercaseVars.add(t),e.state.uppercaseVars?.delete(t)}function $o(e,t){return e.state.lowercaseVars?.has(t)??!1}function Xs(e,t){e.state.uppercaseVars??=new Set,e.state.uppercaseVars.add(t),e.state.lowercaseVars?.delete(t)}function Po(e,t){return e.state.uppercaseVars?.has(t)??!1}function ut(e,t,s){return $o(e,t)?s.toLowerCase():Po(e,t)?s.toUpperCase():s}async function Dn(e,t){try{let s=new Z,r=ne(s,t),n=await K(e,r.expression);return String(n)}catch{return"0"}}function Ao(e){let t=e.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);if(!t)return null;let s=t[0],r=s.length;if(e[r]!=="[")return null;let n=0,i=r+1;for(;r<e.length;r++)if(e[r]==="[")n++;else if(e[r]==="]"&&(n--,n===0))break;if(n!==0)return null;let o=e.slice(i,r);if(r++,e[r]!=="=")return null;r++;let a=e.slice(r);return{name:s,indexExpr:o,value:a}}async function Ys(e,t){let s=!1,r=!1,n=!1,i=!1,o=!1,a=!1,l=!1,u=!1,c=!1,f=!1,h=!1,d=!1,m=!1,p=!1,v=!1,y=[];for(let N=0;N<t.length;N++){let x=t[N];if(x==="-a")s=!0;else if(x==="-A")r=!0;else if(x==="-r")n=!0;else if(x==="-x")i=!0;else if(x==="-p")o=!0;else if(x==="-n")a=!0;else if(x==="+n")l=!0;else if(x==="+a")u=!0;else if(x==="+x")c=!0;else if(x==="--"){y.push(...t.slice(N+1));break}else if(x.startsWith("+")){for(let z of x.slice(1))if(z==="n")l=!0;else if(z==="a")u=!0;else if(z==="x")c=!0;else if(z!=="r"){if(z!=="i"){if(!(z==="f"||z==="F"))return R(F,B(`bash: typeset: +${z}: invalid option
96
- `),2)}}}else if(x==="-i")f=!0;else if(x==="-l")h=!0;else if(x==="-u")d=!0;else if(x==="-f")m=!0;else if(x==="-F")p=!0;else if(x==="-g")v=!0;else if(x.startsWith("-"))for(let z of x.slice(1))if(z==="a")s=!0;else if(z==="A")r=!0;else if(z==="r")n=!0;else if(z==="x")i=!0;else if(z==="p")o=!0;else if(z==="n")a=!0;else if(z==="i")f=!0;else if(z==="l")h=!0;else if(z==="u")d=!0;else if(z==="f")m=!0;else if(z==="F")p=!0;else if(z==="g")v=!0;else return R(F,B(`bash: typeset: -${z}: invalid option
97
- `),2);else y.push(x)}let A=e.state.localScopes.length>0&&!v,b=N=>{if(!A)return;let x=e.state.localScopes[e.state.localScopes.length-1];x.has(N)||x.set(N,e.state.env.get(N))},_=N=>{if(!A)return;let x=e.state.localScopes[e.state.localScopes.length-1];x.has(N)||x.set(N,e.state.env.get(N));let z=`${N}_`;for(let D of e.state.env.keys())D.startsWith(z)&&!D.includes("__")&&(x.has(D)||x.set(D,e.state.env.get(D)));let I=`${N}__length`;e.state.env.has(I)&&!x.has(I)&&x.set(I,e.state.env.get(I))},M=N=>{A&&He(e,N)};if(p){if(y.length===0){let z=Array.from(e.state.functions.keys()).sort(),I="";for(let D of z)I+=`declare -f ${D}
98
- `;return X(I)}let N=!0,x="";for(let z of y)e.state.functions.has(z)?x+=`${z}
99
- `:N=!1;return R(B(x),F,N?0:1)}if(m){if(y.length===0){let x="",z=Array.from(e.state.functions.keys()).sort();for(let I of z)x+=`${I} ()
80
+ `;continue}if(e.state.env.has(f)){let b=T(e.state.env,f);l+=`declare ${d} ${f}=${$r(b)}
81
+ `}}}return H(l)}function gi(e){let t="",s=Array.from(e.state.associativeArrays??[]).sort();for(let r of s){let n=et(e,r);if(n.length===0)t+=`declare -A ${r}=()
82
+ `;else{let i=n.map(a=>{let o=T(e.state.env,`${r}_${a}`,""),l=Pr(o);return`['${a}']=${l}`});t+=`declare -A ${r}=(${i.join(" ")})
83
+ `}}return H(t)}function wi(e){let t="",s=new Set;for(let n of e.state.env.keys()){if(n.startsWith("BASH_"))continue;if(n.endsWith("__length")){let a=n.slice(0,-8);e.state.associativeArrays?.has(a)||s.add(a);continue}let i=n.lastIndexOf("_");if(i>0){let a=n.slice(0,i),o=n.slice(i+1);/^\d+$/.test(o)&&(e.state.associativeArrays?.has(a)||s.add(a))}}let r=Array.from(s).sort();for(let n of r){let i=me(e,n);if(i.length===0)t+=`declare -a ${n}=()
84
+ `;else{let a=i.map(o=>{let l=T(e.state.env,`${n}_${o}`,"");return`[${o}]=${ct(l)}`});t+=`declare -a ${n}=(${a.join(" ")})
85
+ `}}return H(t)}function vi(e){let t="",s=new Set;for(let n of e.state.env.keys()){if(n.startsWith("BASH_"))continue;if(n.endsWith("__length")){let a=n.slice(0,-8);s.add(a);continue}let i=n.lastIndexOf("_");if(i>0){let a=n.slice(0,i),o=n.slice(i+1);if(/^\d+$/.test(o)||e.state.associativeArrays?.has(a)){s.add(a);continue}}s.add(n)}let r=Array.from(s).sort();for(let n of r)e.state.associativeArrays?.has(n)||me(e,n).length>0||e.state.env.has(`${n}__length`)||e.state.env.has(n)&&(t+=`${n}=${ks(T(e.state.env,n))}
86
+ `);return H(t)}function Cr(e,t){e.state.integerVars??=new Set,e.state.integerVars.add(t)}function Bt(e,t){return e.state.integerVars?.has(t)??!1}function Ar(e,t){e.state.lowercaseVars??=new Set,e.state.lowercaseVars.add(t),e.state.uppercaseVars?.delete(t)}function fa(e,t){return e.state.lowercaseVars?.has(t)??!1}function kr(e,t){e.state.uppercaseVars??=new Set,e.state.uppercaseVars.add(t),e.state.lowercaseVars?.delete(t)}function da(e,t){return e.state.uppercaseVars?.has(t)??!1}function $t(e,t,s){return fa(e,t)?s.toLowerCase():da(e,t)?s.toUpperCase():s}async function bi(e,t){try{let s=new X,r=ce(s,t),n=await ee(e,r.expression);return String(n)}catch{return"0"}}function ha(e){let t=e.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);if(!t)return null;let s=t[0],r=s.length;if(e[r]!=="[")return null;let n=0,i=r+1;for(;r<e.length;r++)if(e[r]==="[")n++;else if(e[r]==="]"&&(n--,n===0))break;if(n!==0)return null;let a=e.slice(i,r);if(r++,e[r]!=="=")return null;r++;let o=e.slice(r);return{name:s,indexExpr:a,value:o}}async function xr(e,t){let s=!1,r=!1,n=!1,i=!1,a=!1,o=!1,l=!1,u=!1,c=!1,f=!1,d=!1,p=!1,m=!1,h=!1,b=!1,E=[];for(let A=0;A<t.length;A++){let O=t[A];if(O==="-a")s=!0;else if(O==="-A")r=!0;else if(O==="-r")n=!0;else if(O==="-x")i=!0;else if(O==="-p")a=!0;else if(O==="-n")o=!0;else if(O==="+n")l=!0;else if(O==="+a")u=!0;else if(O==="+x")c=!0;else if(O==="--"){E.push(...t.slice(A+1));break}else if(O.startsWith("+")){for(let M of O.slice(1))if(M==="n")l=!0;else if(M==="a")u=!0;else if(M==="x")c=!0;else if(M!=="r"){if(M!=="i"){if(!(M==="f"||M==="F"))return F(R,W(`bash: typeset: +${M}: invalid option
87
+ `),2)}}}else if(O==="-i")f=!0;else if(O==="-l")d=!0;else if(O==="-u")p=!0;else if(O==="-f")m=!0;else if(O==="-F")h=!0;else if(O==="-g")b=!0;else if(O.startsWith("-"))for(let M of O.slice(1))if(M==="a")s=!0;else if(M==="A")r=!0;else if(M==="r")n=!0;else if(M==="x")i=!0;else if(M==="p")a=!0;else if(M==="n")o=!0;else if(M==="i")f=!0;else if(M==="l")d=!0;else if(M==="u")p=!0;else if(M==="f")m=!0;else if(M==="F")h=!0;else if(M==="g")b=!0;else return F(R,W(`bash: typeset: -${M}: invalid option
88
+ `),2);else E.push(O)}let y=e.state.localScopes.length>0&&!b,v=A=>{if(!y)return;let O=e.state.localScopes[e.state.localScopes.length-1];O.has(A)||O.set(A,e.state.env.get(A))},C=A=>{if(!y)return;let O=e.state.localScopes[e.state.localScopes.length-1];O.has(A)||O.set(A,e.state.env.get(A));let M=`${A}_`;for(let _ of e.state.env.keys())_.startsWith(M)&&!_.includes("__")&&(O.has(_)||O.set(_,e.state.env.get(_)));let x=`${A}__length`;e.state.env.has(x)&&!O.has(x)&&O.set(x,e.state.env.get(x))},N=A=>{y&&st(e,A)};if(h){if(E.length===0){let M=Array.from(e.state.functions.keys()).sort(),x="";for(let _ of M)x+=`declare -f ${_}
89
+ `;return H(x)}let A=!0,O="";for(let M of E)e.state.functions.has(M)?O+=`${M}
90
+ `:A=!1;return F(W(O),R,A?0:1)}if(m){if(E.length===0){let O="",M=Array.from(e.state.functions.keys()).sort();for(let x of M)O+=`${x} ()
100
91
  {
101
92
  # function body
102
93
  }
103
- `;return X(x)}let N=!0;for(let x of y)e.state.functions.has(x)||(N=!1);return R(F,F,N?0:1)}if(o&&y.length>0)return Cn(e,y);if(o&&y.length===0)return xn(e,{filterExport:i,filterReadonly:n,filterNameref:a,filterIndexedArray:s,filterAssocArray:r});if(y.length===0&&r&&!o)return Nn(e);if(y.length===0&&s&&!o)return Tn(e);if(y.length===0&&!o)return On(e);let $="",P=0;for(let N of y){let x=N.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(x&&!u){let E=x[1],L=x[2];if(r&&ce(e,E).length>0){$+=`bash: declare: ${E}: cannot convert indexed to associative array
104
- `,P=1;continue}if((s||!r&&!s)&&e.state.associativeArrays?.has(E)){$+=`bash: declare: ${E}: cannot convert associative to indexed array
105
- `,P=1;continue}if(_(E),r&&(e.state.associativeArrays??=new Set,e.state.associativeArrays.add(E)),Oe(e,E),e.state.env.delete(E),e.state.env.delete(`${E}__length`),r&&L.includes("[")){let W=Jt(L);for(let[oe,q]of W){let te=J(e,q);g(e.state.env,`${E}_${oe}`,te)}}else if(r){let W=Re(L);for(let oe=0;oe<W.length;oe+=2){let q=W[oe],te=oe+1<W.length?J(e,W[oe+1]):"";g(e.state.env,`${E}_${q}`,te)}}else{let W=Re(L);if(W.some(q=>/^\[[^\]]+\]=/.test(q))){let q=0;for(let te of W){let fe=te.match(/^\[([^\]]+)\]=(.*)$/);if(fe){let be=fe[1],Qe=fe[2],$i=J(e,Qe),wt;if(/^-?\d+$/.test(be))wt=Number.parseInt(be,10);else try{let Pi=new Z,Ai=ne(Pi,be);wt=await K(e,Ai.expression)}catch{wt=0}g(e.state.env,`${E}_${wt}`,$i),q=wt+1}else{let be=J(e,te);g(e.state.env,`${E}_${q}`,be),q++}}}else{for(let q=0;q<W.length;q++)g(e.state.env,`${E}_${q}`,W[q]);g(e.state.env,`${E}__length`,String(W.length))}}M(E),n&&ge(e,E),i&&xe(e,E);continue}if(l){let E=N.includes("=")?N.slice(0,N.indexOf("=")):N;if(Rr(e,E),!N.includes("="))continue}if(c){let E=N.includes("=")?N.slice(0,N.indexOf("=")):N;if(Ft(e,E),!N.includes("="))continue}let z=Ao(N);if(z){let{name:E,indexExpr:L,value:W}=z,oe=ae(e,E);if(oe)return oe;_(E);let q;try{let fe=new Z,be=ne(fe,L);q=await K(e,be.expression)}catch{let fe=parseInt(L,10);q=Number.isNaN(fe)?0:fe}g(e.state.env,`${E}_${q}`,W);let te=parseInt(T(e.state.env,`${E}__length`,"0"),10);q>=te&&g(e.state.env,`${E}__length`,String(q+1)),M(E),n&&ge(e,E),i&&xe(e,E);continue}let I=N.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=\((.*)\)$/s);if(I&&!u){let E=I[1],L=I[2],W=ae(e,E);if(W)return W;_(E);let oe=Re(L);if(e.state.associativeArrays?.has(E)){let q=Jt(L);for(let[te,fe]of q){let be=J(e,fe);g(e.state.env,`${E}_${te}`,be)}}else{let q=ce(e,E),te=0,fe=e.state.env.get(E);q.length===0&&fe!==void 0?(e.state.env.set(`${E}_0`,fe),e.state.env.delete(E),te=1):q.length>0&&(te=Math.max(...q)+1);for(let Qe=0;Qe<oe.length;Qe++)g(e.state.env,`${E}_${te+Qe}`,J(e,oe[Qe]));let be=te+oe.length;g(e.state.env,`${E}__length`,String(be))}M(E),n&&ge(e,E),i&&xe(e,E);continue}let D=N.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(D){let E=D[1],L=J(e,D[2]),W=ae(e,E);if(W)return W;b(E),f&&qs(e,E),h&&Zs(e,E),d&&Xs(e,E);let q=ce(e,E).length>0||e.state.associativeArrays?.has(E);if($t(e,E)){let te=T(e.state.env,E,"0"),fe=parseInt(te,10)||0,be=parseInt(await Dn(e,L),10)||0;L=String(fe+be),g(e.state.env,E,L)}else if(q){L=ut(e,E,L);let te=`${E}_0`,fe=T(e.state.env,te);g(e.state.env,te,fe+L)}else{L=ut(e,E,L);let te=T(e.state.env,E);g(e.state.env,E,te+L)}M(E),n&&ge(e,E),i&&xe(e,E),e.state.options.allexport&&!c&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(E));continue}if(N.includes("=")){let E=N.indexOf("="),L=N.slice(0,E),W=N.slice(E+1);if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(L)){$+=`bash: typeset: \`${L}': not a valid identifier
106
- `,P=1;continue}let oe=ae(e,L);if(oe)return oe;if(b(L),a){if(W!==""&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(W)){$+=`bash: declare: \`${W}': invalid variable name for name reference
107
- `,P=1;continue}g(e.state.env,L,W),Le(e,L),W!==""&&Es(e,W)&&bs(e,L),M(L),n&&ge(e,L),i&&xe(e,L);continue}if(f&&qs(e,L),h&&Zs(e,L),d&&Xs(e,L),$t(e,L)&&(W=await Dn(e,W)),W=ut(e,L,W),ye(e,L)){let q=De(e,L);q&&q!==L?g(e.state.env,q,W):g(e.state.env,L,W)}else g(e.state.env,L,W);M(L),n&&ge(e,L),i&&xe(e,L),e.state.options.allexport&&!c&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(L))}else{let E=N;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(E)){$+=`bash: typeset: \`${E}': not a valid identifier
108
- `,P=1;continue}if(s||r?_(E):b(E),a){Le(e,E);let W=T(e.state.env,E);W!==""&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(W)?Mr(e,E):W&&Es(e,W)&&bs(e,E),M(E),n&&ge(e,E),i&&xe(e,E);continue}if(f&&qs(e,E),h&&Zs(e,E),d&&Xs(e,E),r){if(ce(e,E).length>0){$+=`bash: declare: ${E}: cannot convert indexed to associative array
109
- `,P=1;continue}e.state.associativeArrays??=new Set,e.state.associativeArrays.add(E)}let L=Array.from(e.state.env.keys()).some(W=>W.startsWith(`${E}_`)&&!W.startsWith(`${E}__length`));!e.state.env.has(E)&&!L&&(s||r?g(e.state.env,`${E}__length`,"0"):(e.state.declaredVars??=new Set,e.state.declaredVars.add(E))),M(E),n&&ge(e,E),i&&xe(e,E)}}return R(F,B($),P)}async function Ks(e,t){let s=!1,r=!1,n=!1,i=[];for(let o=0;o<t.length;o++){let a=t[o];if(a==="-a")s=!0;else if(a==="-A")r=!0;else if(a==="-p")n=!0;else if(a==="--"){i.push(...t.slice(o+1));break}else a.startsWith("-")||i.push(a)}if(i.length===0){let o="",a=Array.from(e.state.readonlyVars||[]).sort();for(let l of a){let u=e.state.env.get(l);if(u!==void 0){let c=j(u??F).replace(/\\/g,"\\\\").replace(/"/g,'\\"');o+=`declare -r ${l}="${c}"
110
- `}}return X(o)}for(let o of i){let a=o.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=\((.*)\)$/s);if(a){let f=a[1],h=a[2],d=ae(e,f);if(d)return d;let m=Re(h);if(e.state.associativeArrays?.has(f)){let p=Jt(h);for(let[v,y]of p){let S=J(e,y);g(e.state.env,`${f}_${v}`,S)}}else{let p=ce(e,f),v=0,y=e.state.env.get(f);p.length===0&&y!==void 0?(e.state.env.set(`${f}_0`,y),e.state.env.delete(f),v=1):p.length>0&&(v=Math.max(...p)+1);for(let A=0;A<m.length;A++)g(e.state.env,`${f}_${v+A}`,J(e,m[A]));let S=v+m.length;g(e.state.env,`${f}__length`,String(S))}ge(e,f);continue}let l=o.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(l){let f=l[1],h=J(e,l[2]),d=ae(e,f);if(d)return d;let m=T(e.state.env,f);g(e.state.env,f,m+h),ge(e,f);continue}let u=gn(o);if(u.value===void 0&&!u.isArray){ge(e,u.name);continue}let c=await wn(e,u,{makeReadonly:!0});if(c)return c}return it}function Qs(e){return e.state.directoryStack??=[],e.state.directoryStack}function Pt(e,t){return t&&e===t?"~":t&&e.startsWith(`${t}/`)?`~${e.slice(t.length)}`:e}function ko(e){let t=e.split("/").filter(r=>r&&r!=="."),s=[];for(let r of t)r===".."?s.pop():s.push(r);return`/${s.join("/")}`}async function Js(e,t){let s=Qs(e),r;for(let a=0;a<t.length;a++){let l=t[a];if(l==="--"){if(a+1<t.length){if(r!==void 0)return k(`bash: pushd: too many arguments
111
- `,2);r=t[a+1],a++}}else{if(l.startsWith("-")&&l!=="-")return k(`bash: pushd: ${l}: invalid option
112
- `,2);if(r!==void 0)return k(`bash: pushd: too many arguments
113
- `,2);r=l}}if(r===void 0){if(s.length<2)return k(`bash: pushd: no other directory
114
- `,1);let a=s[0];s[0]=s[1],s[1]=a,r=s[0]}let n;if(r.startsWith("/"))n=r;else if(r===".."){let a=e.state.cwd.split("/").filter(l=>l);a.pop(),n=`/${a.join("/")}`}else r==="."?n=e.state.cwd:r.startsWith("~")?n=T(e.state.env,"HOME","/")+r.slice(1):n=`${e.state.cwd}/${r}`;n=ko(n);try{if(!(await e.fs.stat(n)).isDirectory)return k(`bash: pushd: ${r}: Not a directory
115
- `,1)}catch{return k(`bash: pushd: ${r}: No such file or directory
116
- `,1)}s.unshift(e.state.cwd),e.state.previousDir=e.state.cwd,e.state.cwd=n,g(e.state.env,"PWD",n),g(e.state.env,"OLDPWD",e.state.previousDir);let i=T(e.state.env,"HOME",""),o=`${[n,...s].map(a=>Pt(a,i)).join(" ")}
117
- `;return X(o)}function er(e,t){let s=Qs(e);for(let o of t)if(o!=="--")return o.startsWith("-")&&o!=="-"?k(`bash: popd: ${o}: invalid option
118
- `,2):k(`bash: popd: too many arguments
119
- `,2);if(s.length===0)return k(`bash: popd: directory stack empty
120
- `,1);let r=s.shift();if(!r)return k(`bash: popd: directory stack empty
121
- `,1);e.state.previousDir=e.state.cwd,e.state.cwd=r,g(e.state.env,"PWD",r),g(e.state.env,"OLDPWD",e.state.previousDir);let n=T(e.state.env,"HOME",""),i=`${[r,...s].map(o=>Pt(o,n)).join(" ")}
122
- `;return X(i)}function tr(e,t){let s=Qs(e),r=!1,n=!1,i=!1,o=!1;for(let c of t)if(c!=="--")if(c.startsWith("-"))for(let f of c.slice(1))if(f==="c")r=!0;else if(f==="l")n=!0;else if(f==="p")i=!0;else if(f==="v")i=!0,o=!0;else return k(`bash: dirs: -${f}: invalid option
123
- `,2);else return k(`bash: dirs: too many arguments
124
- `,1);if(r)return e.state.directoryStack=[],it;let a=[e.state.cwd,...s],l=T(e.state.env,"HOME",""),u;return o?(u=a.map((c,f)=>{let h=n?c:Pt(c,l);return` ${f} ${h}`}).join(`
94
+ `;return H(O)}let A=!0;for(let O of E)e.state.functions.has(O)||(A=!1);return F(R,R,A?0:1)}if(a&&E.length>0)return mi(e,E);if(a&&E.length===0)return yi(e,{filterExport:i,filterReadonly:n,filterNameref:o,filterIndexedArray:s,filterAssocArray:r});if(E.length===0&&r&&!a)return gi(e);if(E.length===0&&s&&!a)return wi(e);if(E.length===0&&!a)return vi(e);let I="",k=0;for(let A of E){let O=A.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(O&&!u){let w=O[1],D=O[2];if(r&&me(e,w).length>0){I+=`bash: declare: ${w}: cannot convert indexed to associative array
95
+ `,k=1;continue}if((s||!r&&!s)&&e.state.associativeArrays?.has(w)){I+=`bash: declare: ${w}: cannot convert associative to indexed array
96
+ `,k=1;continue}if(C(w),r&&(e.state.associativeArrays??=new Set,e.state.associativeArrays.add(w)),Ve(e,w),e.state.env.delete(w),e.state.env.delete(`${w}__length`),r&&D.includes("[")){let L=vs(D);for(let[J,j]of L){let Q=ne(e,j);g(e.state.env,`${w}_${J}`,Q)}}else if(r){let L=Be(D);for(let J=0;J<L.length;J+=2){let j=L[J],Q=J+1<L.length?ne(e,L[J+1]):"";g(e.state.env,`${w}_${j}`,Q)}}else{let L=Be(D);if(L.some(j=>/^\[[^\]]+\]=/.test(j))){let j=0;for(let Q of L){let oe=Q.match(/^\[([^\]]+)\]=(.*)$/);if(oe){let Pe=oe[1],ut=oe[2],lo=ne(e,ut),Ot;if(/^-?\d+$/.test(Pe))Ot=Number.parseInt(Pe,10);else try{let co=new X,uo=ce(co,Pe);Ot=await ee(e,uo.expression)}catch{Ot=0}g(e.state.env,`${w}_${Ot}`,lo),j=Ot+1}else{let Pe=ne(e,Q);g(e.state.env,`${w}_${j}`,Pe),j++}}}else{for(let j=0;j<L.length;j++)g(e.state.env,`${w}_${j}`,L[j]);g(e.state.env,`${w}__length`,String(L.length))}}N(w),n&&Se(e,w),i&&Re(e,w);continue}if(l){let w=A.includes("=")?A.slice(0,A.indexOf("=")):A;if(wn(e,w),!A.includes("="))continue}if(c){let w=A.includes("=")?A.slice(0,A.indexOf("=")):A;if(ns(e,w),!A.includes("="))continue}let M=ha(A);if(M){let{name:w,indexExpr:D,value:L}=M,J=await de(e,w);if(J)return J;C(w);let j;try{let oe=new X,Pe=ce(oe,D);j=await ee(e,Pe.expression)}catch{let oe=parseInt(D,10);j=Number.isNaN(oe)?0:oe}g(e.state.env,`${w}_${j}`,L);let Q=parseInt(T(e.state.env,`${w}__length`,"0"),10);j>=Q&&g(e.state.env,`${w}__length`,String(j+1)),N(w),n&&Se(e,w),i&&Re(e,w);continue}let x=A.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=\((.*)\)$/s);if(x&&!u){let w=x[1],D=x[2],L=await de(e,w);if(L)return L;C(w);let J=Be(D);if(e.state.associativeArrays?.has(w)){let j=vs(D);for(let[Q,oe]of j){let Pe=ne(e,oe);g(e.state.env,`${w}_${Q}`,Pe)}}else{let j=me(e,w),Q=0,oe=e.state.env.get(w);j.length===0&&oe!==void 0?(e.state.env.set(`${w}_0`,oe),e.state.env.delete(w),Q=1):j.length>0&&(Q=Math.max(...j)+1);for(let ut=0;ut<J.length;ut++)g(e.state.env,`${w}_${Q+ut}`,ne(e,J[ut]));let Pe=Q+J.length;g(e.state.env,`${w}__length`,String(Pe))}N(w),n&&Se(e,w),i&&Re(e,w);continue}let _=A.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(_){let w=_[1],D=ne(e,_[2]),L=await de(e,w);if(L)return L;v(w),f&&Cr(e,w),d&&Ar(e,w),p&&kr(e,w);let j=me(e,w).length>0||e.state.associativeArrays?.has(w);if(Bt(e,w)){let Q=T(e.state.env,w,"0"),oe=parseInt(Q,10)||0,Pe=parseInt(await bi(e,D),10)||0;D=String(oe+Pe),g(e.state.env,w,D)}else if(j){D=$t(e,w,D);let Q=`${w}_0`,oe=T(e.state.env,Q);g(e.state.env,Q,oe+D)}else{D=$t(e,w,D);let Q=T(e.state.env,w);g(e.state.env,w,Q+D)}N(w),n&&Se(e,w),i&&Re(e,w),e.state.options.allexport&&!c&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(w));continue}if(A.includes("=")){let w=A.indexOf("="),D=A.slice(0,w),L=A.slice(w+1);if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(D)){I+=`bash: typeset: \`${D}': not a valid identifier
97
+ `,k=1;continue}let J=await de(e,D);if(J)return J;if(v(D),o){if(L!==""&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(L)){I+=`bash: declare: \`${L}': invalid variable name for name reference
98
+ `,k=1;continue}g(e.state.env,D,L),qe(e,D),L!==""&&Js(e,L)&&Xs(e,D),N(D),n&&Se(e,D),i&&Re(e,D);continue}if(f&&Cr(e,D),d&&Ar(e,D),p&&kr(e,D),Bt(e,D)&&(L=await bi(e,L)),L=$t(e,D,L),Ee(e,D)){let j=ze(e,D);j&&j!==D?g(e.state.env,j,L):g(e.state.env,D,L)}else g(e.state.env,D,L);N(D),n&&Se(e,D),i&&Re(e,D),e.state.options.allexport&&!c&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(D))}else{let w=A;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(w)){I+=`bash: typeset: \`${w}': not a valid identifier
99
+ `,k=1;continue}if(s||r?C(w):v(w),o){qe(e,w);let L=T(e.state.env,w);L!==""&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(L)?vn(e,w):L&&Js(e,L)&&Xs(e,w),N(w),n&&Se(e,w),i&&Re(e,w);continue}if(f&&Cr(e,w),d&&Ar(e,w),p&&kr(e,w),r){if(me(e,w).length>0){I+=`bash: declare: ${w}: cannot convert indexed to associative array
100
+ `,k=1;continue}e.state.associativeArrays??=new Set,e.state.associativeArrays.add(w)}let D=Array.from(e.state.env.keys()).some(L=>L.startsWith(`${w}_`)&&!L.startsWith(`${w}__length`));!e.state.env.has(w)&&!D&&(s||r?g(e.state.env,`${w}__length`,"0"):(e.state.declaredVars??=new Set,e.state.declaredVars.add(w))),N(w),n&&Se(e,w),i&&Re(e,w)}}return F(R,W(I),k)}async function _r(e,t){let s=!1,r=!1,n=!1,i=[];for(let a=0;a<t.length;a++){let o=t[a];if(o==="-a")s=!0;else if(o==="-A")r=!0;else if(o==="-p")n=!0;else if(o==="--"){i.push(...t.slice(a+1));break}else o.startsWith("-")||i.push(o)}if(i.length===0){let a="",o=Array.from(e.state.readonlyVars||[]).sort();for(let l of o){let u=e.state.env.get(l);if(u!==void 0){let c=B(u??R).replace(/\\/g,"\\\\").replace(/"/g,'\\"');a+=`declare -r ${l}="${c}"
101
+ `}}return H(a)}for(let a of i){let o=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=\((.*)\)$/s);if(o){let f=o[1],d=o[2],p=await de(e,f);if(p)return p;let m=Be(d);if(e.state.associativeArrays?.has(f)){let h=vs(d);for(let[b,E]of h){let $=ne(e,E);g(e.state.env,`${f}_${b}`,$)}}else{let h=me(e,f),b=0,E=e.state.env.get(f);h.length===0&&E!==void 0?(e.state.env.set(`${f}_0`,E),e.state.env.delete(f),b=1):h.length>0&&(b=Math.max(...h)+1);for(let y=0;y<m.length;y++)g(e.state.env,`${f}_${b+y}`,ne(e,m[y]));let $=b+m.length;g(e.state.env,`${f}__length`,String($))}Se(e,f);continue}let l=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(l){let f=l[1],d=ne(e,l[2]),p=await de(e,f);if(p)return p;let m=T(e.state.env,f);g(e.state.env,f,m+d),Se(e,f);continue}let u=ti(a);if(u.value===void 0&&!u.isArray){Se(e,u.name);continue}let c=await si(e,u,{makeReadonly:!0});if(c)return c}return wt}function Tr(e){return e.state.directoryStack??=[],e.state.directoryStack}function Ut(e,t){return t&&e===t?"~":t&&e.startsWith(`${t}/`)?`~${e.slice(t.length)}`:e}function pa(e){let t=e.split("/").filter(r=>r&&r!=="."),s=[];for(let r of t)r===".."?s.pop():s.push(r);return`/${s.join("/")}`}async function Nr(e,t){let s=Tr(e),r;for(let o=0;o<t.length;o++){let l=t[o];if(l==="--"){if(o+1<t.length){if(r!==void 0)return P(`bash: pushd: too many arguments
102
+ `,2);r=t[o+1],o++}}else{if(l.startsWith("-")&&l!=="-")return P(`bash: pushd: ${l}: invalid option
103
+ `,2);if(r!==void 0)return P(`bash: pushd: too many arguments
104
+ `,2);r=l}}if(r===void 0){if(s.length<2)return P(`bash: pushd: no other directory
105
+ `,1);let o=s[0];s[0]=s[1],s[1]=o,r=s[0]}let n;if(r.startsWith("/"))n=r;else if(r===".."){let o=e.state.cwd.split("/").filter(l=>l);o.pop(),n=`/${o.join("/")}`}else r==="."?n=e.state.cwd:r.startsWith("~")?n=T(e.state.env,"HOME","/")+r.slice(1):n=`${e.state.cwd}/${r}`;n=pa(n);try{if(!(await e.fs.stat(n)).isDirectory)return P(`bash: pushd: ${r}: Not a directory
106
+ `,1)}catch{return P(`bash: pushd: ${r}: No such file or directory
107
+ `,1)}s.unshift(e.state.cwd),e.state.previousDir=e.state.cwd,e.state.cwd=n,g(e.state.env,"PWD",n),g(e.state.env,"OLDPWD",e.state.previousDir);let i=T(e.state.env,"HOME",""),a=`${[n,...s].map(o=>Ut(o,i)).join(" ")}
108
+ `;return H(a)}function Or(e,t){let s=Tr(e);for(let a of t)if(a!=="--")return a.startsWith("-")&&a!=="-"?P(`bash: popd: ${a}: invalid option
109
+ `,2):P(`bash: popd: too many arguments
110
+ `,2);if(s.length===0)return P(`bash: popd: directory stack empty
111
+ `,1);let r=s.shift();if(!r)return P(`bash: popd: directory stack empty
112
+ `,1);e.state.previousDir=e.state.cwd,e.state.cwd=r,g(e.state.env,"PWD",r),g(e.state.env,"OLDPWD",e.state.previousDir);let n=T(e.state.env,"HOME",""),i=`${[r,...s].map(a=>Ut(a,n)).join(" ")}
113
+ `;return H(i)}function Dr(e,t){let s=Tr(e),r=!1,n=!1,i=!1,a=!1;for(let c of t)if(c!=="--")if(c.startsWith("-"))for(let f of c.slice(1))if(f==="c")r=!0;else if(f==="l")n=!0;else if(f==="p")i=!0;else if(f==="v")i=!0,a=!0;else return P(`bash: dirs: -${f}: invalid option
114
+ `,2);else return P(`bash: dirs: too many arguments
115
+ `,1);if(r)return e.state.directoryStack=[],wt;let o=[e.state.cwd,...s],l=T(e.state.env,"HOME",""),u;return a?(u=o.map((c,f)=>{let d=n?c:Ut(c,l);return` ${f} ${d}`}).join(`
125
116
  `),u+=`
126
- `):i?u=a.map(c=>n?c:Pt(c,l)).join(`
117
+ `):i?u=o.map(c=>n?c:Ut(c,l)).join(`
127
118
  `)+`
128
- `:u=a.map(c=>n?c:Pt(c,l)).join(" ")+`
129
- `,X(u)}async function is(e,t,s){let r=t;if(r.length>0){let a=r[0];if(a==="--")r=r.slice(1);else if(a.startsWith("-")&&a!=="-"&&a.length>1)return k(`bash: eval: ${a}: invalid option
119
+ `:u=o.map(c=>n?c:Ut(c,l)).join(" ")+`
120
+ `,H(u)}async function xs(e,t,s){let r=t;if(r.length>0){let o=r[0];if(o==="--")r=r.slice(1);else if(o.startsWith("-")&&o!=="-"&&o.length>1)return P(`bash: eval: ${o}: invalid option
130
121
  eval: usage: eval [arg ...]
131
- `,2)}if(r.length===0)return U();let n=r.join(" ");if(n.trim()==="")return U();let i=e.state.groupStdin,o=s??e.state.groupStdin;o!==void 0&&(e.state.groupStdin=o);try{let a=Te(n);return await e.executeScript(a)}catch(a){if(a instanceof Ee||a instanceof Se||a instanceof me||a instanceof Y)throw a;if(a.name==="ParseException")return k(`bash: eval: ${a.message}
132
- `);throw a}finally{e.state.groupStdin=i}}function sr(e,t){let s,r=w();if(t.length===0)s=e.state.lastExitCode;else{let n=t[0],i=Number.parseInt(n,10);n===""||Number.isNaN(i)||!/^-?\d+$/.test(n)?(r=C(`bash: exit: ${n}: numeric argument required
133
- `),s=2):s=(i%256+256)%256}throw new Y(s,w(),r)}function rr(e,t){let s=!1,r=[];for(let o of t)o==="-n"?s=!0:o==="-p"||o==="--"||r.push(o);if(r.length===0&&!s){let o="",a=e.state.exportedVars??new Set,l=Array.from(a).sort();for(let u of l){let c=e.state.env.get(u);if(c!==void 0){let f=j(c??F).replace(/\\/g,"\\\\").replace(/"/g,'\\"');o+=`declare -x ${u}="${f}"
134
- `}}return X(o)}if(s){for(let o of r){let a,l;if(o.includes("=")){let u=o.indexOf("=");a=o.slice(0,u),l=J(e,o.slice(u+1)),g(e.state.env,a,l)}else a=o;Ft(e,a)}return it}let n="",i=0;for(let o of r){let a,l,u=!1,c=o.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(c)a=c[1],l=J(e,c[2]),u=!0;else if(o.includes("=")){let f=o.indexOf("=");a=o.slice(0,f),l=J(e,o.slice(f+1))}else a=o;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(a)){n+=`bash: export: \`${o}': not a valid identifier
135
- `,i=1;continue}if(l!==void 0)if(u){let f=T(e.state.env,a);g(e.state.env,a,f+l)}else g(e.state.env,a,l);else e.state.env.has(a)||g(e.state.env,a,"");xe(e,a)}return R(F,B(n),i)}function os(e,t){if(t.length<2)return k(`bash: getopts: usage: getopts optstring name [arg ...]
136
- `);let s=t[0],r=t[1],n=!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r),i=s.startsWith(":"),o=i?s.slice(1):s,a;if(t.length>2)a=t.slice(2);else{let p=Number.parseInt(T(e.state.env,"#","0"),10);a=[];for(let v=1;v<=p;v++)a.push(T(e.state.env,String(v))||"")}let l=Number.parseInt(T(e.state.env,"OPTIND","1"),10);l<1&&(l=1);let u=Number.parseInt(T(e.state.env,"__GETOPTS_CHARINDEX","0"),10);if(g(e.state.env,"OPTARG",""),l>a.length)return n||g(e.state.env,r,"?"),g(e.state.env,"OPTIND",String(a.length+1)),g(e.state.env,"__GETOPTS_CHARINDEX","0"),{exitCode:n?2:1,stdout:w(),stderr:w()};let c=a[l-1];if(!c||c==="-"||!c.startsWith("-"))return n||g(e.state.env,r,"?"),{exitCode:n?2:1,stdout:w(),stderr:w()};if(c==="--")return g(e.state.env,"OPTIND",String(l+1)),g(e.state.env,"__GETOPTS_CHARINDEX","0"),n||g(e.state.env,r,"?"),{exitCode:n?2:1,stdout:w(),stderr:w()};let f=u===0?1:u,h=c[f];if(!h)return g(e.state.env,"OPTIND",String(l+1)),g(e.state.env,"__GETOPTS_CHARINDEX","0"),os(e,t);let d=o.indexOf(h);if(d===-1){let p="";return i?g(e.state.env,"OPTARG",h):p=`bash: illegal option -- ${h}
137
- `,n||g(e.state.env,r,"?"),f+1<c.length?(g(e.state.env,"__GETOPTS_CHARINDEX",String(f+1)),g(e.state.env,"OPTIND",String(l))):(g(e.state.env,"OPTIND",String(l+1)),g(e.state.env,"__GETOPTS_CHARINDEX","0")),{exitCode:n?2:0,stdout:w(),stderr:C(p)}}if(d+1<o.length&&o[d+1]===":")if(f+1<c.length)g(e.state.env,"OPTARG",c.slice(f+1)),g(e.state.env,"OPTIND",String(l+1)),g(e.state.env,"__GETOPTS_CHARINDEX","0");else{if(l>=a.length){let p="";return i?(g(e.state.env,"OPTARG",h),n||g(e.state.env,r,":")):(p=`bash: option requires an argument -- ${h}
138
- `,n||g(e.state.env,r,"?")),g(e.state.env,"OPTIND",String(l+1)),g(e.state.env,"__GETOPTS_CHARINDEX","0"),{exitCode:n?2:0,stdout:w(),stderr:C(p)}}g(e.state.env,"OPTARG",a[l]),g(e.state.env,"OPTIND",String(l+2)),g(e.state.env,"__GETOPTS_CHARINDEX","0")}else f+1<c.length?(g(e.state.env,"__GETOPTS_CHARINDEX",String(f+1)),g(e.state.env,"OPTIND",String(l))):(g(e.state.env,"OPTIND",String(l+1)),g(e.state.env,"__GETOPTS_CHARINDEX","0"));return n||g(e.state.env,r,h),{exitCode:n?2:0,stdout:w(),stderr:w()}}async function nr(e,t){e.state.hashTable||(e.state.hashTable=new Map);let s=!1,r=!1,n=!1,i=!1,o=!1,a="",l=[],u=0;for(;u<t.length;){let m=t[u];if(m==="--"){u++,l.push(...t.slice(u));break}if(m==="-r")s=!0,u++;else if(m==="-d")r=!0,u++;else if(m==="-l")n=!0,u++;else if(m==="-t")o=!0,u++;else if(m==="-p"){if(i=!0,u++,u>=t.length)return k(`bash: hash: -p: option requires an argument
139
- `,1);a=t[u],u++}else if(m.startsWith("-")&&m.length>1){for(let p of m.slice(1))if(p==="r")s=!0;else if(p==="d")r=!0;else if(p==="l")n=!0;else if(p==="t")o=!0;else return p==="p"?k(`bash: hash: -p: option requires an argument
140
- `,1):k(`bash: hash: -${p}: invalid option
141
- `,1);u++}else l.push(m),u++}if(s)return e.state.hashTable.clear(),U();if(r){if(l.length===0)return k(`bash: hash: -d: option requires an argument
142
- `,1);let m=!1,p="";for(let v of l)e.state.hashTable.has(v)?e.state.hashTable.delete(v):(p+=`bash: hash: ${v}: not found
143
- `,m=!0);return m?k(p,1):U()}if(o){if(l.length===0)return k(`bash: hash: -t: option requires an argument
144
- `,1);let m="",p=!1,v="";for(let y of l){let S=e.state.hashTable.get(y);S?l.length>1?m+=`${y} ${S}
145
- `:m+=`${S}
146
- `:(v+=`bash: hash: ${y}: not found
147
- `,p=!0)}return p?{exitCode:1,stdout:C(m),stderr:C(v)}:X(m)}if(i){if(l.length===0)return k(`bash: hash: usage: hash [-lr] [-p pathname] [-dt] [name ...]
148
- `,1);let m=l[0];return e.state.hashTable.set(m,a),U()}if(l.length===0){if(e.state.hashTable.size===0)return X(`hash: hash table empty
149
- `);let m="";if(n)for(let[p,v]of e.state.hashTable)m+=`builtin hash -p ${v} ${p}
122
+ `,2)}if(r.length===0)return U();let n=r.join(" ");if(n.trim()==="")return U();let i=e.state.groupStdin,a=s??e.state.groupStdin;a!==void 0&&(e.state.groupStdin=a);try{let o=Fe(n),l=await e.executeScript(o);return await Y(e,l)}catch(o){if(await te(e,o),o instanceof Ce||o instanceof Ae||o instanceof ve||o instanceof q)throw o;if(o.name==="ParseException")return P(`bash: eval: ${o.message}
123
+ `);throw o}finally{e.state.groupStdin=i}}async function Ir(e,t){let s,r;if(t.length===0)s=e.state.lastExitCode;else{let n=t[0],i=Number.parseInt(n,10);n===""||Number.isNaN(i)||!/^-?\d+$/.test(n)?(r=`bash: exit: ${n}: numeric argument required
124
+ `,s=2):s=(i%256+256)%256}throw r&&await G(e,2,r,!0),new q(s)}function Rr(e,t){let s=!1,r=[];for(let a of t)a==="-n"?s=!0:a==="-p"||a==="--"||r.push(a);if(r.length===0&&!s){let a="",o=e.state.exportedVars??new Set,l=Array.from(o).sort();for(let u of l){let c=e.state.env.get(u);if(c!==void 0){let f=B(c??R).replace(/\\/g,"\\\\").replace(/"/g,'\\"');a+=`declare -x ${u}="${f}"
125
+ `}}return H(a)}if(s){for(let a of r){let o,l;if(a.includes("=")){let u=a.indexOf("=");o=a.slice(0,u),l=ne(e,a.slice(u+1)),g(e.state.env,o,l)}else o=a;ns(e,o)}return wt}let n="",i=0;for(let a of r){let o,l,u=!1,c=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(c)o=c[1],l=ne(e,c[2]),u=!0;else if(a.includes("=")){let f=a.indexOf("=");o=a.slice(0,f),l=ne(e,a.slice(f+1))}else o=a;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(o)){n+=`bash: export: \`${a}': not a valid identifier
126
+ `,i=1;continue}if(l!==void 0)if(u){let f=T(e.state.env,o);g(e.state.env,o,f+l)}else g(e.state.env,o,l);else e.state.env.has(o)||g(e.state.env,o,"");Re(e,o)}return F(R,W(n),i)}function _s(e,t){if(t.length<2)return P(`bash: getopts: usage: getopts optstring name [arg ...]
127
+ `);let s=t[0],r=t[1],n=!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r),i=s.startsWith(":"),a=i?s.slice(1):s,o;if(t.length>2)o=t.slice(2);else{let h=Number.parseInt(T(e.state.env,"#","0"),10);o=[];for(let b=1;b<=h;b++)o.push(T(e.state.env,String(b))||"")}let l=Number.parseInt(T(e.state.env,"OPTIND","1"),10);l<1&&(l=1);let u=Number.parseInt(T(e.state.env,"__GETOPTS_CHARINDEX","0"),10);if(g(e.state.env,"OPTARG",""),l>o.length)return n||g(e.state.env,r,"?"),g(e.state.env,"OPTIND",String(o.length+1)),g(e.state.env,"__GETOPTS_CHARINDEX","0"),{exitCode:n?2:1,stdout:S(),stderr:S()};let c=o[l-1];if(!c||c==="-"||!c.startsWith("-"))return n||g(e.state.env,r,"?"),{exitCode:n?2:1,stdout:S(),stderr:S()};if(c==="--")return g(e.state.env,"OPTIND",String(l+1)),g(e.state.env,"__GETOPTS_CHARINDEX","0"),n||g(e.state.env,r,"?"),{exitCode:n?2:1,stdout:S(),stderr:S()};let f=u===0?1:u,d=c[f];if(!d)return g(e.state.env,"OPTIND",String(l+1)),g(e.state.env,"__GETOPTS_CHARINDEX","0"),_s(e,t);let p=a.indexOf(d);if(p===-1){let h="";return i?g(e.state.env,"OPTARG",d):h=`bash: illegal option -- ${d}
128
+ `,n||g(e.state.env,r,"?"),f+1<c.length?(g(e.state.env,"__GETOPTS_CHARINDEX",String(f+1)),g(e.state.env,"OPTIND",String(l))):(g(e.state.env,"OPTIND",String(l+1)),g(e.state.env,"__GETOPTS_CHARINDEX","0")),{exitCode:n?2:0,stdout:S(),stderr:V(h)}}if(p+1<a.length&&a[p+1]===":")if(f+1<c.length)g(e.state.env,"OPTARG",c.slice(f+1)),g(e.state.env,"OPTIND",String(l+1)),g(e.state.env,"__GETOPTS_CHARINDEX","0");else{if(l>=o.length){let h="";return i?(g(e.state.env,"OPTARG",d),n||g(e.state.env,r,":")):(h=`bash: option requires an argument -- ${d}
129
+ `,n||g(e.state.env,r,"?")),g(e.state.env,"OPTIND",String(l+1)),g(e.state.env,"__GETOPTS_CHARINDEX","0"),{exitCode:n?2:0,stdout:S(),stderr:V(h)}}g(e.state.env,"OPTARG",o[l]),g(e.state.env,"OPTIND",String(l+2)),g(e.state.env,"__GETOPTS_CHARINDEX","0")}else f+1<c.length?(g(e.state.env,"__GETOPTS_CHARINDEX",String(f+1)),g(e.state.env,"OPTIND",String(l))):(g(e.state.env,"OPTIND",String(l+1)),g(e.state.env,"__GETOPTS_CHARINDEX","0"));return n||g(e.state.env,r,d),{exitCode:n?2:0,stdout:S(),stderr:S()}}async function Mr(e,t){e.state.hashTable||(e.state.hashTable=new Map);let s=!1,r=!1,n=!1,i=!1,a=!1,o="",l=[],u=0;for(;u<t.length;){let m=t[u];if(m==="--"){u++,l.push(...t.slice(u));break}if(m==="-r")s=!0,u++;else if(m==="-d")r=!0,u++;else if(m==="-l")n=!0,u++;else if(m==="-t")a=!0,u++;else if(m==="-p"){if(i=!0,u++,u>=t.length)return P(`bash: hash: -p: option requires an argument
130
+ `,1);o=t[u],u++}else if(m.startsWith("-")&&m.length>1){for(let h of m.slice(1))if(h==="r")s=!0;else if(h==="d")r=!0;else if(h==="l")n=!0;else if(h==="t")a=!0;else return h==="p"?P(`bash: hash: -p: option requires an argument
131
+ `,1):P(`bash: hash: -${h}: invalid option
132
+ `,1);u++}else l.push(m),u++}if(s)return e.state.hashTable.clear(),U();if(r){if(l.length===0)return P(`bash: hash: -d: option requires an argument
133
+ `,1);let m=!1,h="";for(let b of l)e.state.hashTable.has(b)?e.state.hashTable.delete(b):(h+=`bash: hash: ${b}: not found
134
+ `,m=!0);return m?P(h,1):U()}if(a){if(l.length===0)return P(`bash: hash: -t: option requires an argument
135
+ `,1);let m="",h=!1,b="";for(let E of l){let $=e.state.hashTable.get(E);$?l.length>1?m+=`${E} ${$}
136
+ `:m+=`${$}
137
+ `:(b+=`bash: hash: ${E}: not found
138
+ `,h=!0)}return h?{exitCode:1,stdout:V(m),stderr:V(b)}:H(m)}if(i){if(l.length===0)return P(`bash: hash: usage: hash [-lr] [-p pathname] [-dt] [name ...]
139
+ `,1);let m=l[0];return e.state.hashTable.set(m,o),U()}if(l.length===0){if(e.state.hashTable.size===0)return H(`hash: hash table empty
140
+ `);let m="";if(n)for(let[h,b]of e.state.hashTable)m+=`builtin hash -p ${b} ${h}
150
141
  `;else{m=`hits command
151
- `;for(let[,p]of e.state.hashTable)m+=` 1 ${p}
152
- `}return X(m)}let c=!1,f="",d=T(e.state.env,"PATH","/usr/bin:/bin").split(":");for(let m of l){if(m.includes("/")){f+=`bash: hash: ${m}: cannot use / in name
153
- `,c=!0;continue}let p=!1;for(let v of d){if(!v)continue;let y=`${v}/${m}`;if(await e.fs.exists(y)){e.state.hashTable.set(m,y),p=!0;break}}p||(f+=`bash: hash: ${m}: not found
154
- `,c=!0)}return c?k(f,1):U()}var In=new Map([[":",[": [arguments]",`Null command.
142
+ `;for(let[,h]of e.state.hashTable)m+=` 1 ${h}
143
+ `}return H(m)}let c=!1,f="",p=T(e.state.env,"PATH","/usr/bin:/bin").split(":");for(let m of l){if(m.includes("/")){f+=`bash: hash: ${m}: cannot use / in name
144
+ `,c=!0;continue}let h=!1;for(let b of p){if(!b)continue;let E=`${b}/${m}`;if(await e.fs.exists(E)){e.state.hashTable.set(m,E),h=!0;break}}h||(f+=`bash: hash: ${m}: not found
145
+ `,c=!0)}return c?P(f,1):U()}var Ei=new Map([[":",[": [arguments]",`Null command.
155
146
  No effect; the command does nothing.
156
147
  Exit Status:
157
148
  Always succeeds.`]],[".",[". filename [arguments]",`Execute commands from a file in the current shell.
@@ -316,12 +307,12 @@ eval: usage: eval [arg ...]
316
307
  Display the history list with line numbers, prefixing each modified
317
308
  entry with a \`*'.
318
309
  Exit Status:
319
- Returns success unless an invalid option is given or an error occurs.`]],["jobs",["jobs [-lnprs] [jobspec ...] or jobs -x command [args]",`Display status of jobs.
320
- Lists the active jobs.
310
+ Returns success unless an invalid option is given or an error occurs.`]],["jobs",["jobs [jobspec ...]",`Display status of jobs.
311
+ Lists all active jobs, or only the jobs identified by JOBSPEC.
321
312
  Exit Status:
322
- Returns success unless an invalid option is given or an error occurs.`]],["kill",["kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]",`Send a signal to a job.
313
+ Returns success unless a JOBSPEC is unknown or an invalid option is given.`]],["kill",["kill [-TERM|-KILL|-INT|-15|-9|-2] pid | jobspec ...",`Send a signal to a job.
323
314
  Send the processes identified by PID or JOBSPEC the signal named by
324
- SIGSPEC or SIGNUM.
315
+ the option. SIGTERM is used when no option is supplied.
325
316
  Exit Status:
326
317
  Returns success unless an invalid option is given or an error occurs.`]],["let",["let arg [arg ...]",`Evaluate arithmetic expressions.
327
318
  Evaluate each ARG as an arithmetic expression. Evaluation is done in
@@ -491,37 +482,52 @@ eval: usage: eval [arg ...]
491
482
  Without options, unset first tries to unset a variable, and if that fails,
492
483
  tries to unset a function.
493
484
  Exit Status:
494
- Returns success unless an invalid option is given or a NAME is read-only.`]],["wait",["wait [-fn] [id ...]",`Wait for job completion and return exit status.
485
+ Returns success unless an invalid option is given or a NAME is read-only.`]],["wait",["wait [id ...]",`Wait for job completion and return exit status.
495
486
  Waits for each process identified by an ID, which may be a process ID or a
496
- job specification, and reports its termination status.
487
+ job specification. With no ID, waits for all known jobs.
497
488
  Exit Status:
498
489
  Returns the status of the last ID; fails if ID is invalid or an invalid
499
- option is given.`]]]),Rn=[...In.keys()].sort();function ir(e,t){let s=!1,r=[],n=0;for(;n<t.length;){let l=t[n];if(l==="--"){for(n++;n<t.length;)r.push(t[n]),n++;break}if(l.startsWith("-")&&l.length>1){for(let u=1;u<l.length;u++){let c=l[u];if(c==="s")s=!0;else return k(`bash: help: -${c}: invalid option
500
- `,2)}n++}else r.push(l),n++}if(r.length===0)return Co();let i="",o=!1,a="";for(let l of r){let u=_o(l);if(u.length===0){a+=`bash: help: no help topics match \`${l}'. Try \`help help' or \`man -k ${l}' or \`info ${l}'.
501
- `,o=!0;continue}for(let c of u){let f=In.get(c);if(!f)continue;let[h,d]=f;s?i+=`${c}: ${h}
502
- `:i+=`${c}: ${h}
503
- ${d}
504
- `}}return{exitCode:o?1:0,stdout:C(i),stderr:C(a)}}function _o(e){let t=e.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,"."),s=bt(`^${t}$`);return Rn.filter(r=>s.test(r))}function Co(){let e=[];e.push("just-bash shell builtins"),e.push("These shell commands are defined internally. Type `help' to see this list."),e.push("Type `help name' to find out more about the function `name'."),e.push("");let t=36,s=Rn.slice(),r=Math.ceil(s.length/2);for(let n=0;n<r;n++){let i=s[n]||"",o=s[n+r]||"",a=i.padEnd(t);e.push(o?`${a}${o}`:i)}return X(`${e.join(`
490
+ option is given.`]]]),Si=[...Ei.keys()].sort();function Lr(e,t){let s=!1,r=[],n=0;for(;n<t.length;){let l=t[n];if(l==="--"){for(n++;n<t.length;)r.push(t[n]),n++;break}if(l.startsWith("-")&&l.length>1){for(let u=1;u<l.length;u++){let c=l[u];if(c==="s")s=!0;else return P(`bash: help: -${c}: invalid option
491
+ `,2)}n++}else r.push(l),n++}if(r.length===0)return ya();let i="",a=!1,o="";for(let l of r){let u=ma(l);if(u.length===0){o+=`bash: help: no help topics match \`${l}'. Try \`help help' or \`man -k ${l}' or \`info ${l}'.
492
+ `,a=!0;continue}for(let c of u){let f=Ei.get(c);if(!f)continue;let[d,p]=f;s?i+=`${c}: ${d}
493
+ `:i+=`${c}: ${d}
494
+ ${p}
495
+ `}}return{exitCode:a?1:0,stdout:V(i),stderr:V(o)}}function ma(e){let t=e.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,"."),s=Rt(`^${t}$`);return Si.filter(r=>s.test(r))}function ya(){let e=[];e.push("just-bash shell builtins"),e.push("These shell commands are defined internally. Type `help' to see this list."),e.push("Type `help name' to find out more about the function `name'."),e.push("");let t=36,s=Si.slice(),r=Math.ceil(s.length/2);for(let n=0;n<r;n++){let i=s[n]||"",a=s[n+r]||"",o=i.padEnd(t);e.push(a?`${o}${a}`:i)}return H(`${e.join(`
505
496
  `)}
506
- `)}function xo(e){let t=[],s="",r=0;for(let n of e){for(let i of n)i==="("?r++:i===")"&&r--;s?s+=` ${n}`:s=n,r===0&&(t.push(s),s="")}return s&&t.push(s),t}async function or(e,t){if(t.length===0)return k(`bash: let: expression expected
507
- `);let s=xo(t),r=0;for(let n of s)try{let o=Te(`(( ${n} ))`).statements[0];if(o&&o.pipelines.length>0&&o.pipelines[0].commands.length>0){let a=o.pipelines[0].commands[0];a.type==="ArithmeticCommand"&&(r=await K(e,a.expression.expression))}}catch(i){return k(`bash: let: ${n}: ${i.message}
508
- `)}return R(F,F,r===0?1:0)}async function ar(e,t){if(e.state.localScopes.length===0)return k(`bash: local: can only be used in a function
509
- `);let s=e.state.localScopes[e.state.localScopes.length-1],r="",n=0,i=!1,o=!1,a=!1,l=[];for(let u of t)if(u==="-n")i=!0;else if(u==="-a")o=!0;else if(u==="-p")a=!0;else if(u.startsWith("-")&&!u.includes("="))for(let c of u.slice(1))c==="n"?i=!0:c==="a"?o=!0:c==="p"&&(a=!0);else l.push(u);if(l.length===0){let u="",c=Array.from(s.keys()).filter(f=>!f.includes("_")||!f.match(/_\d+$/)).filter(f=>!f.includes("__length")).sort();for(let f of c){let h=e.state.env.get(f);if(h!==void 0){let d=j(h);u+=`${f}=${d}
510
- `}}return R(B(u),F,0)}for(let u of l){let c,f,h=u.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(h){c=h[1];let y=h[2];if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(c)){r+=`bash: local: \`${u}': not a valid identifier
511
- `,n=1;continue}if(ae(e,c,"bash"),!s.has(c)){s.set(c,e.state.env.get(c));let b=`${c}_`;for(let _ of e.state.env.keys())_.startsWith(b)&&!_.includes("__")&&(s.has(_)||s.set(_,e.state.env.get(_)))}let S=`${c}_`;for(let b of e.state.env.keys())b.startsWith(S)&&!b.includes("__")&&e.state.env.delete(b);let A=Re(y);for(let b=0;b<A.length;b++)g(e.state.env,`${c}_${b}`,A[b]);g(e.state.env,`${c}__length`,String(A.length)),He(e,c),i&&Le(e,c);continue}let d=u.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=\((.*)\)$/s);if(d){c=d[1];let y=d[2];if(ae(e,c,"bash"),!s.has(c)){s.set(c,e.state.env.get(c));let $=`${c}_`;for(let N of e.state.env.keys())N.startsWith($)&&!N.includes("__")&&(s.has(N)||s.set(N,e.state.env.get(N)));let P=`${c}__length`;e.state.env.has(P)&&!s.has(P)&&s.set(P,e.state.env.get(P))}let S=Re(y),A=ce(e,c),b=0,_=e.state.env.get(c);A.length===0&&_!==void 0?(e.state.env.set(`${c}_0`,_),e.state.env.delete(c),b=1):A.length>0&&(b=Math.max(...A)+1);for(let $=0;$<S.length;$++)g(e.state.env,`${c}_${b+$}`,J(e,S[$]));let M=b+S.length;g(e.state.env,`${c}__length`,String(M)),He(e,c),i&&Le(e,c);continue}let m=u.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(m){c=m[1];let y=J(e,m[2]);ae(e,c,"bash"),s.has(c)||s.set(c,e.state.env.get(c));let S=T(e.state.env,c);g(e.state.env,c,S+y),He(e,c),i&&Le(e,c);continue}let p=u.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([^\]]+)\]=(.*)$/s);if(p){c=p[1];let y=p[2],S=J(e,p[3]);if(ae(e,c,"bash"),!s.has(c)){s.set(c,e.state.env.get(c));let _=`${c}_`;for(let $ of e.state.env.keys())$.startsWith(_)&&!$.includes("__")&&(s.has($)||s.set($,e.state.env.get($)));let M=`${c}__length`;e.state.env.has(M)&&!s.has(M)&&s.set(M,e.state.env.get(M))}let A;try{let _=new Z,M=ne(_,y);A=await K(e,M.expression)}catch{let _=parseInt(y,10);A=Number.isNaN(_)?0:_}g(e.state.env,`${c}_${A}`,S);let b=parseInt(T(e.state.env,`${c}__length`,"0"),10);A>=b&&g(e.state.env,`${c}__length`,String(A+1)),He(e,c),i&&Le(e,c);continue}if(u.includes("=")){let y=u.indexOf("=");c=u.slice(0,y),f=J(e,u.slice(y+1))}else c=u;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(c)){r+=`bash: local: \`${u}': not a valid identifier
512
- `,n=1;continue}let v=s.has(c);if(f!==void 0){let y=e.state.env.get(c);if(e.state.tempEnvBindings){let S=e.state.accessedTempEnvVars?.has(c),A=e.state.mutatedTempEnvVars?.has(c);if(!S&&!A)for(let b=e.state.tempEnvBindings.length-1;b>=0;b--){let _=e.state.tempEnvBindings[b];if(_.has(c)){y=_.get(c);break}}}vn(e,c,y)}if(!v){let y=e.state.env.get(c);if(e.state.tempEnvBindings)for(let S=e.state.tempEnvBindings.length-1;S>=0;S--){let A=e.state.tempEnvBindings[S];if(A.has(c)){y=A.get(c);break}}if(s.set(c,y),o){let S=`${c}_`;for(let b of e.state.env.keys())b.startsWith(S)&&!b.includes("__")&&(s.has(b)||s.set(b,e.state.env.get(b)));let A=`${c}__length`;e.state.env.has(A)&&!s.has(A)&&s.set(A,e.state.env.get(A))}}if(o&&f===void 0){let y=`${c}_`;for(let S of e.state.env.keys())S.startsWith(y)&&!S.includes("__")&&e.state.env.delete(S);g(e.state.env,`${c}__length`,"0")}else if(f!==void 0){if(ae(e,c,"bash"),i&&f!==""&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(f)){r+=`bash: local: \`${f}': invalid variable name for name reference
513
- `,n=1;continue}g(e.state.env,c,f),e.state.options.allexport&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(c))}else{let y=e.state.tempEnvBindings?.some(S=>S.has(c));!v&&!y&&e.state.env.delete(c)}He(e,c),i&&Le(e,c)}return R(F,B(r),n)}async function lr(e,t,s){let r=j(s),n=`
514
- `,i=0,o=0,a=0,l=!1,u="MAPFILE",c=0;for(;c<t.length;){let A=t[c];A==="-d"&&c+1<t.length?(n=t[c+1]===""?"\0":t[c+1]||`
515
- `,c+=2):A==="-n"&&c+1<t.length?(i=Number.parseInt(t[c+1],10)||0,c+=2):A==="-O"&&c+1<t.length?(o=Number.parseInt(t[c+1],10)||0,c+=2):A==="-s"&&c+1<t.length?(a=Number.parseInt(t[c+1],10)||0,c+=2):A==="-t"?(l=!0,c++):A==="-u"||A==="-C"||A==="-c"?c+=2:(A.startsWith("-")||(u=A),c++)}let f=r;!f&&e.state.groupStdin!==void 0&&(f=j(await H(e.state.groupStdin)));let h=[],d=f,m=0,p=0,v=e.limits?.maxArrayElements??1e5;for(;d.length>0;){let A=d.indexOf(n);if(A===-1){if(d.length>0){if(p<a)p++;else if(i===0||m<i){if(o+m>=v)return R(F,B(`mapfile: array element limit exceeded (${v})
516
- `),1);let M=d,$=M.indexOf("\0");$!==-1&&(M=M.substring(0,$)),h.push(M),m++}}break}let b=d.substring(0,A),_=b.indexOf("\0");if(_!==-1&&(b=b.substring(0,_)),!l&&n!=="\0"&&(b+=n),d=d.substring(A+n.length),p<a){p++;continue}if(i>0&&m>=i)break;if(o+m>=v)return R(F,B(`mapfile: array element limit exceeded (${v})
517
- `),1);h.push(b),m++}o===0&&Oe(e,u);for(let A=0;A<h.length;A++)g(e.state.env,`${u}_${o+A}`,h[A]);let y=parseInt(T(e.state.env,`${u}__length`,"0"),10),S=o+h.length;return g(e.state.env,`${u}__length`,String(Math.max(y,S))),e.state.groupStdin!==void 0&&!r&&(e.state.groupStdin=w()),R(F,F,0)}function No(e){if(!e.startsWith("__rw__:"))return null;let t=e.slice(7),s=t.indexOf(":");if(s===-1)return null;let r=Number.parseInt(t.slice(0,s),10);if(Number.isNaN(r)||r<0)return null;let n=s+1,i=t.slice(n,n+r),o=n+r+1,a=t.slice(o),l=a.indexOf(":");if(l===-1)return null;let u=Number.parseInt(a.slice(0,l),10);if(Number.isNaN(u)||u<0)return null;let c=a.slice(l+1);return{path:i,position:u,content:c}}function To(e,t,s){return`__rw__:${e.length}:${e}:${t}:${s}`}async function cr(e,t,s,r=-1){let n=j(s),i=!1,o=`
518
- `,a="",l=-1,u=-1,c=null,f=-1,h=-1,d=[],m=0,p=!1,v=(I,D)=>{let E=1;for(;E<I.length;){let L=I[E];if(L==="r")i=!0,E++;else if(L==="s")E++;else{if(L==="d")return E+1<I.length?(o=I.substring(E+1),{nextArgIndex:D+1}):D+1<t.length?(o=t[D+1],{nextArgIndex:D+2}):{nextArgIndex:D+1};if(L==="n"){if(E+1<I.length){let W=I.substring(E+1);return l=Number.parseInt(W,10),(Number.isNaN(l)||l<0)&&(p=!0,l=0),{nextArgIndex:D+1}}else if(D+1<t.length)return l=Number.parseInt(t[D+1],10),(Number.isNaN(l)||l<0)&&(p=!0,l=0),{nextArgIndex:D+2};return{nextArgIndex:D+1}}else if(L==="N"){if(E+1<I.length){let W=I.substring(E+1);return u=Number.parseInt(W,10),(Number.isNaN(u)||u<0)&&(p=!0,u=0),{nextArgIndex:D+1}}else if(D+1<t.length)return u=Number.parseInt(t[D+1],10),(Number.isNaN(u)||u<0)&&(p=!0,u=0),{nextArgIndex:D+2};return{nextArgIndex:D+1}}else{if(L==="a")return E+1<I.length?(c=I.substring(E+1),{nextArgIndex:D+1}):D+1<t.length?(c=t[D+1],{nextArgIndex:D+2}):{nextArgIndex:D+1};if(L==="p")return E+1<I.length?(a=I.substring(E+1),{nextArgIndex:D+1}):D+1<t.length?(a=t[D+1],{nextArgIndex:D+2}):{nextArgIndex:D+1};if(L==="u"){if(E+1<I.length){let W=I.substring(E+1);return f=Number.parseInt(W,10),Number.isNaN(f)||f<0?{nextArgIndex:-2}:{nextArgIndex:D+1}}else if(D+1<t.length)return f=Number.parseInt(t[D+1],10),Number.isNaN(f)||f<0?{nextArgIndex:-2}:{nextArgIndex:D+2};return{nextArgIndex:D+1}}else if(L==="t"){if(E+1<I.length){let W=I.substring(E+1);return h=Number.parseFloat(W),Number.isNaN(h)&&(h=0),{nextArgIndex:D+1}}else if(D+1<t.length)return h=Number.parseFloat(t[D+1]),Number.isNaN(h)&&(h=0),{nextArgIndex:D+2};return{nextArgIndex:D+1}}else if(L==="e"||L==="i"||L==="P"){if(L==="i"&&D+1<t.length)return{nextArgIndex:D+2};E++}else E++}}}return{nextArgIndex:D+1}};for(;m<t.length;){let I=t[m];if(I.startsWith("-")&&I.length>1&&I!=="--"){let D=v(I,m);if(D.nextArgIndex===-1)return{stdout:w(),stderr:w(),exitCode:2};if(D.nextArgIndex===-2)return{stdout:w(),stderr:w(),exitCode:1};m=D.nextArgIndex}else if(I==="--")for(m++;m<t.length;)d.push(t[m]),m++;else d.push(I),m++}if(p)return R(F,F,1);if(d.length===0&&c===null&&d.push("REPLY"),h===0){if(c)Oe(e,c);else{for(let I of d)g(e.state.env,I,"");d.length===0&&g(e.state.env,"REPLY","")}return R(F,F,0)}if(h<0&&h!==-1)return R(F,F,1);let y=n;f>=0?e.state.fileDescriptors?y=e.state.fileDescriptors.get(f)||"":y="":!y&&e.state.groupStdin!==void 0&&(y=j(await H(e.state.groupStdin)));let S=o===""?"\0":o,A="",b=0,_=!0,M=I=>{if(f>=0&&e.state.fileDescriptors)e.state.fileDescriptors.set(f,y.substring(I));else if(r>=0&&e.state.fileDescriptors){let D=e.state.fileDescriptors.get(r);if(D?.startsWith("__rw__:")){let E=No(D);if(E){let L=E.position+I;e.state.fileDescriptors.set(r,To(E.path,L,E.content))}}}else e.state.groupStdin!==void 0&&!n&&(e.state.groupStdin=se(B(y.substring(I))))};if(u>=0){let I=Math.min(u,y.length);A=y.substring(0,I),b=I,_=I>=u,M(b);let D=d[0]||"REPLY";g(e.state.env,D,A);for(let E=1;E<d.length;E++)g(e.state.env,d[E],"");return R(F,F,_?0:1)}else if(l>=0){let I=0,D=0,E=!1;for(;D<y.length&&I<l;){let L=y[D];if(L===S){b=D+1,E=!0;break}if(!i&&L==="\\"&&D+1<y.length){let W=y[D+1];if(W===S&&S===`
519
- `){D+=2,b=D;continue}if(W===S){D+=2,I++,A+=W,b=D;continue}A+=W,D+=2,I++,b=D}else A+=L,D++,I++,b=D}_=I>=l||E,M(b)}else{b=0;let I=0;for(;I<y.length;){let D=y[I];if(D===S){b=I+S.length,_=!0;break}if(!i&&D==="\\"&&I+1<y.length){let E=y[I+1];if(E===`
520
- `){I+=2;continue}if(E===S){A+=E,I+=2;continue}A+=D,A+=E,I+=2;continue}A+=D,I++}if(I>=y.length&&(_=!1,b=I,A.length===0&&y.length===0)){for(let D of d)g(e.state.env,D,"");return c&&Oe(e,c),R(F,F,1)}M(b)}S===`
521
- `&&A.endsWith(`
522
- `)&&(A=A.slice(0,-1));let $=I=>i?I:I.replace(/\\(.)/g,"$1");if(d.length===1&&d[0]==="REPLY")return g(e.state.env,"REPLY",$(A)),R(F,F,_?0:1);let P=Dr(e.state.env);if(c){let{words:I}=vs(A,P,void 0,i),D=e.limits?.maxArrayElements??1e5;if(I.length>D)return R(F,B(`read: array element limit exceeded (${D})
523
- `),1);Oe(e,c);for(let E=0;E<I.length;E++)g(e.state.env,`${c}_${E}`,$(I[E]));return R(F,F,_?0:1)}let N=d.length,{words:x,wordStarts:z}=vs(A,P,N,i);for(let I=0;I<d.length;I++){let D=d[I];if(I<d.length-1)g(e.state.env,D,$(x[I]??""));else if(I<z.length){let E=A.substring(z[I]);E=Ir(E,P,i),E=$(E),g(e.state.env,D,E)}else g(e.state.env,D,"")}return R(F,F,_?0:1)}function ur(e,t){if(e.state.callDepth===0&&e.state.sourceDepth===0)return k("bash: return: can only `return' from a function or sourced script\n");let s=e.state.lastExitCode;if(t.length>0){let r=t[0],n=Number.parseInt(r,10);if(r===""||Number.isNaN(n)||!/^-?\d+$/.test(r))return k(`bash: return: ${r}: numeric argument required
524
- `,2);s=(n%256+256)%256}throw new me(s)}var as=`set: usage: set [-eux] [+eux] [-o option] [+o option]
497
+ `)}var ga=`jobs: usage: jobs [-lnprs] [jobspec ...] or jobs -x command [args]
498
+ `;function wa(e){return{stdout:S(),stderr:V(`bash: jobs: ${e}: invalid option
499
+ ${ga}`),exitCode:2}}async function Fr(e,t,s){if(t[0]==="-x"){let f=t[1];if(!f)return{stdout:S(),stderr:S(),exitCode:0};if(!s)return{stdout:S(),stderr:V(`bash: jobs: -x: command execution unavailable
500
+ `),exitCode:1};let d=[];for(let p of t.slice(2)){if(!p.startsWith("%")){d.push(p);continue}let m=e.processes.resolveJobSpec(p);if(m===void 0)return{stdout:S(),stderr:V(`bash: ${p}: no such job
501
+ `),exitCode:1};d.push(String(m))}return s(f,d)}let r={long:!1,pidsOnly:!1,runningOnly:!1,stoppedOnly:!1,changedOnly:!1},n=0;for(;n<t.length;n++){let f=t[n];if(f==="--"){n++;break}if(!f.startsWith("-")||f==="-")break;for(let d of f.slice(1))if(d==="l")r.long=!0;else if(d==="n")r.changedOnly=!0;else if(d==="p")r.pidsOnly=!0;else if(d==="r")r.runningOnly=!0;else if(d==="s")r.stoppedOnly=!0;else return wa(`-${d}`)}let i=t.slice(n),a=i.length===0?void 0:new Set(i.map(f=>e.processes.resolveJobSpec(f)).filter(f=>f!==void 0)),o="",l="",u=0;for(let f of i)e.processes.resolveJobSpec(f)===void 0&&(l+=`bash: jobs: ${f}: no such job
502
+ `,u=1);let c=e.processes.listJobs(a,{changedOnly:r.changedOnly,runningOnly:r.runningOnly,stoppedOnly:r.stoppedOnly});for(let f of c){if(r.pidsOnly){o+=`${f.pid}
503
+ `;continue}let d=f.state==="running"?"Running ":"Done ",p=r.long?`[${f.jobNumber}]${f.marker} ${f.pid} `:`[${f.jobNumber}]${f.marker} `;o+=`${p}${d}${f.command}
504
+ `}return{stdout:V(o),stderr:V(l),exitCode:u}}var $i=`kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
505
+ `,Ts=typeof process<"u"&&process.platform==="darwin",Wr=[{name:"HUP",number:1,delivery:"SIGTERM"},{name:"INT",number:2,delivery:"SIGINT"},{name:"QUIT",number:3,delivery:"SIGTERM"},{name:"KILL",number:9,delivery:"SIGKILL"},{name:"TERM",number:15,delivery:"SIGTERM"},{name:"USR1",number:Ts?30:10,delivery:"SIGTERM"},{name:"USR2",number:Ts?31:12,delivery:"SIGTERM"},{name:"STOP",number:Ts?17:19,delivery:"SIGSTOP"},{name:"CONT",number:Ts?19:18,delivery:"SIGCONT"}];function Ns(e){let t=e.toUpperCase().replace(/^SIG/,"");if(/^\d+$/.test(t)){let s=Number.parseInt(t,10);return Wr.find(r=>r.number===s)}return Wr.find(s=>s.name===t)}function Vr(e){return{stdout:S(),stderr:V(`bash: kill: ${e.replace(/^-/,"")}: invalid signal specification
506
+ `),exitCode:1}}function va(e){if(e.length===0)return{stdout:V(`${Wr.map(s=>`${s.number}) SIG${s.name}`).join(" ")}
507
+ `),stderr:S(),exitCode:0};let t="";for(let s of e){let r=/^\d+$/.test(s)?String(Number.parseInt(s,10)-(Number(s)>128?128:0)):s,n=Ns(r);if(!n)return Vr(s);t+=/^\d+$/.test(s)?`${n.name}
508
+ `:`${n.number}
509
+ `}return{stdout:V(t),stderr:S(),exitCode:0}}function zr(e,t){let s=Ns("TERM"),r=0;if(t[0]==="-l")return va(t.slice(1));if(t[0]==="-s"||t[0]==="-n"){let o=t[1];if(!o)return{stdout:S(),stderr:V($i),exitCode:2};let l=Ns(o);if(!l)return Vr(o);s=l,r=2}else if(t[0]?.startsWith("-")&&t[0]!=="--"){let o=t[0].slice(1),l=Ns(o);if(!l)return Vr(o);s=l,r=1}else t[0]==="--"&&(r=1);let n=t.slice(r);if(n.length===0)return{stdout:S(),stderr:V($i),exitCode:2};let i="",a=0;for(let o of n){let l;if(o.startsWith("%")){if(l=e.processes.resolveJobSpec(o),l===void 0){i+=`bash: kill: ${o}: no such job
510
+ `,a=1;continue}}else if(/^\d+$/.test(o)){let u=Number(o);Number.isSafeInteger(u)&&u>0&&(l=u)}if(l===void 0){i+=`bash: kill: ${o}: arguments must be process or job IDs
511
+ `,a=1;continue}e.processes.kill(l,s.delivery,s.number)||(i+=`bash: kill: (${l}) - No such process
512
+ `,a=1)}return{stdout:S(),stderr:V(i),exitCode:a}}function ba(e){let t=[],s="",r=0;for(let n of e){for(let i of n)i==="("?r++:i===")"&&r--;s?s+=` ${n}`:s=n,r===0&&(t.push(s),s="")}return s&&t.push(s),t}async function jr(e,t){if(t.length===0)return P(`bash: let: expression expected
513
+ `);let s=ba(t),r=0;for(let n of s)try{let a=Fe(`(( ${n} ))`).statements[0];if(a&&a.pipelines.length>0&&a.pipelines[0].commands.length>0){let o=a.pipelines[0].commands[0];o.type==="ArithmeticCommand"&&(r=await ee(e,o.expression.expression))}}catch(i){return P(`bash: let: ${n}: ${i.message}
514
+ `)}return F(R,R,r===0?1:0)}async function Br(e,t){if(e.state.localScopes.length===0)return P(`bash: local: can only be used in a function
515
+ `);let s=e.state.localScopes[e.state.localScopes.length-1],r="",n=0,i=!1,a=!1,o=!1,l=[];for(let u of t)if(u==="-n")i=!0;else if(u==="-a")a=!0;else if(u==="-p")o=!0;else if(u.startsWith("-")&&!u.includes("="))for(let c of u.slice(1))c==="n"?i=!0:c==="a"?a=!0:c==="p"&&(o=!0);else l.push(u);if(l.length===0){let u="",c=Array.from(s.keys()).filter(f=>!f.includes("_")||!f.match(/_\d+$/)).filter(f=>!f.includes("__length")).sort();for(let f of c){let d=e.state.env.get(f);if(d!==void 0){let p=B(d);u+=`${f}=${p}
516
+ `}}return F(W(u),R,0)}for(let u of l){let c,f,d=u.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(d){c=d[1];let E=d[2];if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(c)){r+=`bash: local: \`${u}': not a valid identifier
517
+ `,n=1;continue}if(await de(e,c,"bash"),!s.has(c)){s.set(c,e.state.env.get(c));let v=`${c}_`;for(let C of e.state.env.keys())C.startsWith(v)&&!C.includes("__")&&(s.has(C)||s.set(C,e.state.env.get(C)))}let $=`${c}_`;for(let v of e.state.env.keys())v.startsWith($)&&!v.includes("__")&&e.state.env.delete(v);let y=Be(E);for(let v=0;v<y.length;v++)g(e.state.env,`${c}_${v}`,y[v]);g(e.state.env,`${c}__length`,String(y.length)),st(e,c),i&&qe(e,c);continue}let p=u.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=\((.*)\)$/s);if(p){c=p[1];let E=p[2];if(await de(e,c,"bash"),!s.has(c)){s.set(c,e.state.env.get(c));let I=`${c}_`;for(let A of e.state.env.keys())A.startsWith(I)&&!A.includes("__")&&(s.has(A)||s.set(A,e.state.env.get(A)));let k=`${c}__length`;e.state.env.has(k)&&!s.has(k)&&s.set(k,e.state.env.get(k))}let $=Be(E),y=me(e,c),v=0,C=e.state.env.get(c);y.length===0&&C!==void 0?(e.state.env.set(`${c}_0`,C),e.state.env.delete(c),v=1):y.length>0&&(v=Math.max(...y)+1);for(let I=0;I<$.length;I++)g(e.state.env,`${c}_${v+I}`,ne(e,$[I]));let N=v+$.length;g(e.state.env,`${c}__length`,String(N)),st(e,c),i&&qe(e,c);continue}let m=u.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(m){c=m[1];let E=ne(e,m[2]);await de(e,c,"bash"),s.has(c)||s.set(c,e.state.env.get(c));let $=T(e.state.env,c);g(e.state.env,c,$+E),st(e,c),i&&qe(e,c);continue}let h=u.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([^\]]+)\]=(.*)$/s);if(h){c=h[1];let E=h[2],$=ne(e,h[3]);if(await de(e,c,"bash"),!s.has(c)){s.set(c,e.state.env.get(c));let C=`${c}_`;for(let I of e.state.env.keys())I.startsWith(C)&&!I.includes("__")&&(s.has(I)||s.set(I,e.state.env.get(I)));let N=`${c}__length`;e.state.env.has(N)&&!s.has(N)&&s.set(N,e.state.env.get(N))}let y;try{let C=new X,N=ce(C,E);y=await ee(e,N.expression)}catch{let C=parseInt(E,10);y=Number.isNaN(C)?0:C}g(e.state.env,`${c}_${y}`,$);let v=parseInt(T(e.state.env,`${c}__length`,"0"),10);y>=v&&g(e.state.env,`${c}__length`,String(y+1)),st(e,c),i&&qe(e,c);continue}if(u.includes("=")){let E=u.indexOf("=");c=u.slice(0,E),f=ne(e,u.slice(E+1))}else c=u;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(c)){r+=`bash: local: \`${u}': not a valid identifier
518
+ `,n=1;continue}let b=s.has(c);if(f!==void 0){let E=e.state.env.get(c);if(e.state.tempEnvBindings){let $=e.state.accessedTempEnvVars?.has(c),y=e.state.mutatedTempEnvVars?.has(c);if(!$&&!y)for(let v=e.state.tempEnvBindings.length-1;v>=0;v--){let C=e.state.tempEnvBindings[v];if(C.has(c)){E=C.get(c);break}}}ri(e,c,E)}if(!b){let E=e.state.env.get(c);if(e.state.tempEnvBindings)for(let $=e.state.tempEnvBindings.length-1;$>=0;$--){let y=e.state.tempEnvBindings[$];if(y.has(c)){E=y.get(c);break}}if(s.set(c,E),a){let $=`${c}_`;for(let v of e.state.env.keys())v.startsWith($)&&!v.includes("__")&&(s.has(v)||s.set(v,e.state.env.get(v)));let y=`${c}__length`;e.state.env.has(y)&&!s.has(y)&&s.set(y,e.state.env.get(y))}}if(a&&f===void 0){let E=`${c}_`;for(let $ of e.state.env.keys())$.startsWith(E)&&!$.includes("__")&&e.state.env.delete($);g(e.state.env,`${c}__length`,"0")}else if(f!==void 0){if(await de(e,c,"bash"),i&&f!==""&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(f)){r+=`bash: local: \`${f}': invalid variable name for name reference
519
+ `,n=1;continue}g(e.state.env,c,f),e.state.options.allexport&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(c))}else{let E=e.state.tempEnvBindings?.some($=>$.has(c));!b&&!E&&e.state.env.delete(c)}st(e,c),i&&qe(e,c)}return F(R,W(r),n)}async function Ur(e,t,s){let r=B(s),n=`
520
+ `,i=0,a=0,o=0,l=!1,u="MAPFILE",c=0;for(;c<t.length;){let y=t[c];y==="-d"&&c+1<t.length?(n=t[c+1]===""?"\0":t[c+1]||`
521
+ `,c+=2):y==="-n"&&c+1<t.length?(i=Number.parseInt(t[c+1],10)||0,c+=2):y==="-O"&&c+1<t.length?(a=Number.parseInt(t[c+1],10)||0,c+=2):y==="-s"&&c+1<t.length?(o=Number.parseInt(t[c+1],10)||0,c+=2):y==="-t"?(l=!0,c++):y==="-u"||y==="-C"||y==="-c"?c+=2:(y.startsWith("-")||(u=y),c++)}let f=r;!f&&e.state.groupStdin!==void 0&&(f=B(await re(e.state.groupStdin)));let d=[],p=f,m=0,h=0,b=e.limits?.maxArrayElements??1e5;for(;p.length>0;){let y=p.indexOf(n);if(y===-1){if(p.length>0){if(h<o)h++;else if(i===0||m<i){if(a+m>=b)return F(R,W(`mapfile: array element limit exceeded (${b})
522
+ `),1);let N=p,I=N.indexOf("\0");I!==-1&&(N=N.substring(0,I)),d.push(N),m++}}break}let v=p.substring(0,y),C=v.indexOf("\0");if(C!==-1&&(v=v.substring(0,C)),!l&&n!=="\0"&&(v+=n),p=p.substring(y+n.length),h<o){h++;continue}if(i>0&&m>=i)break;if(a+m>=b)return F(R,W(`mapfile: array element limit exceeded (${b})
523
+ `),1);d.push(v),m++}a===0&&Ve(e,u);for(let y=0;y<d.length;y++)g(e.state.env,`${u}_${a+y}`,d[y]);let E=parseInt(T(e.state.env,`${u}__length`,"0"),10),$=a+d.length;return g(e.state.env,`${u}__length`,String(Math.max(E,$))),e.state.groupStdin!==void 0&&!r&&(e.state.groupStdin=S()),F(R,R,0)}function Ea(e){if(!e.startsWith("__rw__:"))return null;let t=e.slice(7),s=t.indexOf(":");if(s===-1)return null;let r=Number.parseInt(t.slice(0,s),10);if(Number.isNaN(r)||r<0)return null;let n=s+1,i=t.slice(n,n+r),a=n+r+1,o=t.slice(a),l=o.indexOf(":");if(l===-1)return null;let u=Number.parseInt(o.slice(0,l),10);if(Number.isNaN(u)||u<0)return null;let c=o.slice(l+1);return{path:i,position:u,content:c}}function Sa(e,t,s){return`__rw__:${e.length}:${e}:${t}:${s}`}async function Gr(e,t,s,r=-1){let n=B(s),i=!1,a=`
524
+ `,o="",l=-1,u=-1,c=null,f=-1,d=-1,p=[],m=0,h=!1,b=(x,_)=>{let w=1;for(;w<x.length;){let D=x[w];if(D==="r")i=!0,w++;else if(D==="s")w++;else{if(D==="d")return w+1<x.length?(a=x.substring(w+1),{nextArgIndex:_+1}):_+1<t.length?(a=t[_+1],{nextArgIndex:_+2}):{nextArgIndex:_+1};if(D==="n"){if(w+1<x.length){let L=x.substring(w+1);return l=Number.parseInt(L,10),(Number.isNaN(l)||l<0)&&(h=!0,l=0),{nextArgIndex:_+1}}else if(_+1<t.length)return l=Number.parseInt(t[_+1],10),(Number.isNaN(l)||l<0)&&(h=!0,l=0),{nextArgIndex:_+2};return{nextArgIndex:_+1}}else if(D==="N"){if(w+1<x.length){let L=x.substring(w+1);return u=Number.parseInt(L,10),(Number.isNaN(u)||u<0)&&(h=!0,u=0),{nextArgIndex:_+1}}else if(_+1<t.length)return u=Number.parseInt(t[_+1],10),(Number.isNaN(u)||u<0)&&(h=!0,u=0),{nextArgIndex:_+2};return{nextArgIndex:_+1}}else{if(D==="a")return w+1<x.length?(c=x.substring(w+1),{nextArgIndex:_+1}):_+1<t.length?(c=t[_+1],{nextArgIndex:_+2}):{nextArgIndex:_+1};if(D==="p")return w+1<x.length?(o=x.substring(w+1),{nextArgIndex:_+1}):_+1<t.length?(o=t[_+1],{nextArgIndex:_+2}):{nextArgIndex:_+1};if(D==="u"){if(w+1<x.length){let L=x.substring(w+1);return f=Number.parseInt(L,10),Number.isNaN(f)||f<0?{nextArgIndex:-2}:{nextArgIndex:_+1}}else if(_+1<t.length)return f=Number.parseInt(t[_+1],10),Number.isNaN(f)||f<0?{nextArgIndex:-2}:{nextArgIndex:_+2};return{nextArgIndex:_+1}}else if(D==="t"){if(w+1<x.length){let L=x.substring(w+1);return d=Number.parseFloat(L),Number.isNaN(d)&&(d=0),{nextArgIndex:_+1}}else if(_+1<t.length)return d=Number.parseFloat(t[_+1]),Number.isNaN(d)&&(d=0),{nextArgIndex:_+2};return{nextArgIndex:_+1}}else if(D==="e"||D==="i"||D==="P"){if(D==="i"&&_+1<t.length)return{nextArgIndex:_+2};w++}else w++}}}return{nextArgIndex:_+1}};for(;m<t.length;){let x=t[m];if(x.startsWith("-")&&x.length>1&&x!=="--"){let _=b(x,m);if(_.nextArgIndex===-1)return{stdout:S(),stderr:S(),exitCode:2};if(_.nextArgIndex===-2)return{stdout:S(),stderr:S(),exitCode:1};m=_.nextArgIndex}else if(x==="--")for(m++;m<t.length;)p.push(t[m]),m++;else p.push(x),m++}if(h)return F(R,R,1);if(p.length===0&&c===null&&p.push("REPLY"),d===0){if(c)Ve(e,c);else{for(let x of p)g(e.state.env,x,"");p.length===0&&g(e.state.env,"REPLY","")}return F(R,R,0)}if(d<0&&d!==-1)return F(R,R,1);let E=n;f>=0?e.state.fileDescriptors?E=e.state.fileDescriptors.get(f)||"":E="":!E&&e.state.groupStdin!==void 0&&(E=B(await re(e.state.groupStdin)));let $=a===""?"\0":a,y="",v=0,C=!0,N=x=>{if(f>=0&&e.state.fileDescriptors)e.state.fileDescriptors.set(f,E.substring(x));else if(r>=0&&e.state.fileDescriptors){let _=e.state.fileDescriptors.get(r);if(_?.startsWith("__rw__:")){let w=Ea(_);if(w){let D=w.position+x;e.state.fileDescriptors.set(r,Sa(w.path,D,w.content))}}}else e.state.groupStdin!==void 0&&!n&&(e.state.groupStdin=fe(W(E.substring(x))))};if(u>=0){let x=Math.min(u,E.length);y=E.substring(0,x),v=x,C=x>=u,N(v);let _=p[0]||"REPLY";g(e.state.env,_,y);for(let w=1;w<p.length;w++)g(e.state.env,p[w],"");return F(R,R,C?0:1)}else if(l>=0){let x=0,_=0,w=!1;for(;_<E.length&&x<l;){let D=E[_];if(D===$){v=_+1,w=!0;break}if(!i&&D==="\\"&&_+1<E.length){let L=E[_+1];if(L===$&&$===`
525
+ `){_+=2,v=_;continue}if(L===$){_+=2,x++,y+=L,v=_;continue}y+=L,_+=2,x++,v=_}else y+=D,_++,x++,v=_}C=x>=l||w,N(v)}else{v=0;let x=0;for(;x<E.length;){let _=E[x];if(_===$){v=x+$.length,C=!0;break}if(!i&&_==="\\"&&x+1<E.length){let w=E[x+1];if(w===`
526
+ `){x+=2;continue}if(w===$){y+=w,x+=2;continue}y+=_,y+=w,x+=2;continue}y+=_,x++}if(x>=E.length&&(C=!1,v=x,y.length===0&&E.length===0)){for(let _ of p)g(e.state.env,_,"");return c&&Ve(e,c),F(R,R,1)}N(v)}$===`
527
+ `&&y.endsWith(`
528
+ `)&&(y=y.slice(0,-1));let I=x=>i?x:x.replace(/\\(.)/g,"$1");if(p.length===1&&p[0]==="REPLY")return g(e.state.env,"REPLY",I(y)),F(R,R,C?0:1);let k=yn(e.state.env);if(c){let{words:x}=Zs(y,k,void 0,i),_=e.limits?.maxArrayElements??1e5;if(x.length>_)return F(R,W(`read: array element limit exceeded (${_})
529
+ `),1);Ve(e,c);for(let w=0;w<x.length;w++)g(e.state.env,`${c}_${w}`,I(x[w]));return F(R,R,C?0:1)}let A=p.length,{words:O,wordStarts:M}=Zs(y,k,A,i);for(let x=0;x<p.length;x++){let _=p[x];if(x<p.length-1)g(e.state.env,_,I(O[x]??""));else if(x<M.length){let w=y.substring(M[x]);w=gn(w,k,i),w=I(w),g(e.state.env,_,w)}else g(e.state.env,_,"")}return F(R,R,C?0:1)}function Hr(e,t){if(e.state.callDepth===0&&e.state.sourceDepth===0)return P("bash: return: can only `return' from a function or sourced script\n");let s=e.state.lastExitCode;if(t.length>0){let r=t[0],n=Number.parseInt(r,10);if(r===""||Number.isNaN(n)||!/^-?\d+$/.test(r))return P(`bash: return: ${r}: numeric argument required
530
+ `,2);s=(n%256+256)%256}throw new ve(s)}var Os=`set: usage: set [-eux] [+eux] [-o option] [+o option]
525
531
  Options:
526
532
  -e Exit immediately if a command exits with non-zero status
527
533
  +e Disable -e
@@ -537,152 +543,163 @@ Options:
537
543
  +o pipefail Disable pipefail
538
544
  -o xtrace Same as -x
539
545
  +o xtrace Disable xtrace
540
- `,Mn=new Map([["e","errexit"],["u","nounset"],["x","xtrace"],["v","verbose"],["f","noglob"],["C","noclobber"],["a","allexport"],["n","noexec"],["h",null],["b",null],["m",null],["B",null],["H",null],["P",null],["T",null],["E",null],["p",null]]),Fn=new Map([["errexit","errexit"],["pipefail","pipefail"],["nounset","nounset"],["xtrace","xtrace"],["verbose","verbose"],["noclobber","noclobber"],["noglob","noglob"],["allexport","allexport"],["noexec","noexec"],["posix","posix"],["vi","vi"],["emacs","emacs"],["notify",null],["monitor",null],["braceexpand",null],["histexpand",null],["physical",null],["functrace",null],["errtrace",null],["privileged",null],["hashall",null],["ignoreeof",null],["interactive-comments",null],["keyword",null],["onecmd",null]]),Ln=["errexit","nounset","pipefail","verbose","xtrace","posix","allexport","noclobber","noglob","noexec","vi","emacs"],zn=["braceexpand","errtrace","functrace","hashall","histexpand","history","ignoreeof","interactive-comments","keyword","monitor","nolog","notify","onecmd","physical","privileged"];function Wn(e,t,s){t!==null&&(s&&(t==="vi"?e.state.options.emacs=!1:t==="emacs"&&(e.state.options.vi=!1)),e.state.options[t]=s,nt(e))}function Oo(e,t){return t+1<e.length&&!e[t+1].startsWith("-")&&!e[t+1].startsWith("+")}function Do(e,t){let s=ce(e,t);if(s.length===0)return`${t}=()`;let r=s.map(n=>{let i=T(e.state.env,`${t}_${n}`,"");return`[${n}]=${Ke(i)}`});return`${t}=(${r.join(" ")})`}function Io(e){return/^[a-zA-Z0-9_]+$/.test(e)?e:`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function Ro(e,t){let s=je(e,t);if(s.length===0)return`${t}=()`;let r=s.map(n=>{let i=T(e.state.env,`${t}_${n}`,"");return`[${Io(n)}]=${Ke(i)}`});return`${t}=(${r.join(" ")} )`}function Mo(e){let t=new Set,s=e.state.associativeArrays??new Set;for(let r of e.state.env.keys()){let n=r.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_(\d+)$/);if(n){let i=n[1];s.has(i)||t.add(i)}}return t}function Fo(e){return e.state.associativeArrays??new Set}function dr(e,t){if(t.includes("--help"))return X(as);if(t.length===0){let r=Mo(e),n=Fo(e),i=l=>{for(let u of n){let c=`${u}_`,f=`${u}__length`;if(l!==f&&l.startsWith(c)){if(l.slice(c.length).startsWith("_length"))continue;return!0}}return!1},o=[];for(let[l,u]of e.state.env){if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(l)||r.has(l)||n.has(l))continue;let c=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_(\d+)$/);if(c&&r.has(c[1]))continue;let f=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)__length$/);f&&r.has(f[1])||i(l)||f&&n.has(f[1])||o.push([l,j(u)])}let a=[];for(let[l,u]of o.sort(([c],[f])=>c<f?-1:c>f?1:0))a.push(`${l}=${ns(u)}`);for(let l of[...r].sort((u,c)=>u<c?-1:u>c?1:0))a.push(Do(e,l));for(let l of[...n].sort((u,c)=>u<c?-1:u>c?1:0))a.push(Ro(e,l));return a.sort((l,u)=>{let c=l.split("=")[0],f=u.split("=")[0];return c<f?-1:c>f?1:0}),X(a.length>0?`${a.join(`
546
+ `,Pi=new Map([["e","errexit"],["u","nounset"],["x","xtrace"],["v","verbose"],["f","noglob"],["C","noclobber"],["a","allexport"],["n","noexec"],["h",null],["b",null],["m",null],["B",null],["H",null],["P",null],["T",null],["E",null],["p",null]]),Ci=new Map([["errexit","errexit"],["pipefail","pipefail"],["nounset","nounset"],["xtrace","xtrace"],["verbose","verbose"],["noclobber","noclobber"],["noglob","noglob"],["allexport","allexport"],["noexec","noexec"],["posix","posix"],["vi","vi"],["emacs","emacs"],["notify",null],["monitor",null],["braceexpand",null],["histexpand",null],["physical",null],["functrace",null],["errtrace",null],["privileged",null],["hashall",null],["ignoreeof",null],["interactive-comments",null],["keyword",null],["onecmd",null]]),Ai=["errexit","nounset","pipefail","verbose","xtrace","posix","allexport","noclobber","noglob","noexec","vi","emacs"],ki=["braceexpand","errtrace","functrace","hashall","histexpand","history","ignoreeof","interactive-comments","keyword","monitor","nolog","notify","onecmd","physical","privileged"];function xi(e,t,s){t!==null&&(s&&(t==="vi"?e.state.options.emacs=!1:t==="emacs"&&(e.state.options.vi=!1)),e.state.options[t]=s,gt(e))}function $a(e,t){return t+1<e.length&&!e[t+1].startsWith("-")&&!e[t+1].startsWith("+")}function Pa(e,t){let s=me(e,t);if(s.length===0)return`${t}=()`;let r=s.map(n=>{let i=T(e.state.env,`${t}_${n}`,"");return`[${n}]=${ct(i)}`});return`${t}=(${r.join(" ")})`}function Ca(e){return/^[a-zA-Z0-9_]+$/.test(e)?e:`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function Aa(e,t){let s=et(e,t);if(s.length===0)return`${t}=()`;let r=s.map(n=>{let i=T(e.state.env,`${t}_${n}`,"");return`[${Ca(n)}]=${ct(i)}`});return`${t}=(${r.join(" ")} )`}function ka(e){let t=new Set,s=e.state.associativeArrays??new Set;for(let r of e.state.env.keys()){let n=r.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_(\d+)$/);if(n){let i=n[1];s.has(i)||t.add(i)}}return t}function xa(e){return e.state.associativeArrays??new Set}async function Zr(e,t){if(t.includes("--help"))return H(Os);if(t.length===0){let r=ka(e),n=xa(e),i=l=>{for(let u of n){let c=`${u}_`,f=`${u}__length`;if(l!==f&&l.startsWith(c)){if(l.slice(c.length).startsWith("_length"))continue;return!0}}return!1},a=[];for(let[l,u]of e.state.env){if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(l)||r.has(l)||n.has(l))continue;let c=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_(\d+)$/);if(c&&r.has(c[1]))continue;let f=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)__length$/);f&&r.has(f[1])||i(l)||f&&n.has(f[1])||a.push([l,B(u)])}let o=[];for(let[l,u]of a.sort(([c],[f])=>c<f?-1:c>f?1:0))o.push(`${l}=${ks(u)}`);for(let l of[...r].sort((u,c)=>u<c?-1:u>c?1:0))o.push(Pa(e,l));for(let l of[...n].sort((u,c)=>u<c?-1:u>c?1:0))o.push(Aa(e,l));return o.sort((l,u)=>{let c=l.split("=")[0],f=u.split("=")[0];return c<f?-1:c>f?1:0}),H(o.length>0?`${o.join(`
541
547
  `)}
542
- `:"")}let s=0;for(;s<t.length;){let r=t[s];if((r==="-o"||r==="+o")&&Oo(t,s)){let n=t[s+1];if(!Fn.has(n)){let i=`bash: set: ${n}: invalid option name
543
- ${as}`;if(e.state.options.posix)throw new ke(1,w(),C(i));return k(i)}Wn(e,Fn.get(n)??null,r==="-o"),s+=2;continue}if(r==="-o"){let n=Ln.map(a=>`${a.padEnd(16)}${e.state.options[a]?"on":"off"}`),i=zn.map(a=>`${a.padEnd(16)}off`),o=[...n,...i].sort();return X(`${o.join(`
548
+ `:"")}let s=0;for(;s<t.length;){let r=t[s];if((r==="-o"||r==="+o")&&$a(t,s)){let n=t[s+1];if(!Ci.has(n)){let i=`bash: set: ${n}: invalid option name
549
+ ${Os}`;if(e.state.options.posix)throw await G(e,2,i,!0),new be(1);return P(i)}xi(e,Ci.get(n)??null,r==="-o"),s+=2;continue}if(r==="-o"){let n=Ai.map(o=>`${o.padEnd(16)}${e.state.options[o]?"on":"off"}`),i=ki.map(o=>`${o.padEnd(16)}off`),a=[...n,...i].sort();return H(`${a.join(`
544
550
  `)}
545
- `)}if(r==="+o"){let n=Ln.map(a=>`set ${e.state.options[a]?"-o":"+o"} ${a}`),i=zn.map(a=>`set +o ${a}`),o=[...n,...i].sort();return X(`${o.join(`
551
+ `)}if(r==="+o"){let n=Ai.map(o=>`set ${e.state.options[o]?"-o":"+o"} ${o}`),i=ki.map(o=>`set +o ${o}`),a=[...n,...i].sort();return H(`${a.join(`
546
552
  `)}
547
- `)}if(r.length>1&&(r[0]==="-"||r[0]==="+")&&r[1]!=="-"){let n=r[0]==="-";for(let i=1;i<r.length;i++){let o=r[i];if(!Mn.has(o)){let a=`bash: set: ${r[0]}${o}: invalid option
548
- ${as}`;if(e.state.options.posix)throw new ke(1,w(),C(a));return k(a)}Wn(e,Mn.get(o)??null,n)}s++;continue}if(r==="--")return fr(e,t.slice(s+1)),U();if(r==="-"){if(e.state.options.xtrace=!1,e.state.options.verbose=!1,nt(e),s+1<t.length)return fr(e,t.slice(s+1)),U();s++;continue}if(r==="+"){s++;continue}if(r.startsWith("-")||r.startsWith("+")){let n=`bash: set: ${r}: invalid option
549
- ${as}`;if(e.state.options.posix)throw new ke(1,w(),C(n));return k(n)}return fr(e,t.slice(s)),U()}return U()}function fr(e,t){let s=1;for(;e.state.env.has(String(s));)e.state.env.delete(String(s)),s++;for(let r=0;r<t.length;r++)g(e.state.env,String(r+1),t[r]);g(e.state.env,"#",String(t.length)),g(e.state.env,"@",t.join(" ")),g(e.state.env,"*",t.join(" "))}function hr(e,t){let s=1;if(t.length>0){let o=Number.parseInt(t[0],10);if(Number.isNaN(o)||o<0){let a=`bash: shift: ${t[0]}: numeric argument required
550
- `;if(e.state.options.posix)throw new ke(1,w(),C(a));return k(a)}s=o}let r=Number.parseInt(T(e.state.env,"#","0"),10);if(s>r){let o=`bash: shift: shift count out of range
551
- `;if(e.state.options.posix)throw new ke(1,w(),C(o));return k(o)}if(s===0)return U();let n=[];for(let o=1;o<=r;o++)n.push(T(e.state.env,String(o))||"");let i=n.slice(s);for(let o=1;o<=r;o++)e.state.env.delete(String(o));for(let o=0;o<i.length;o++)g(e.state.env,String(o+1),i[o]);return g(e.state.env,"#",String(i.length)),g(e.state.env,"@",i.join(" ")),U()}async function pr(e,t){let s=t;if(s.length>0&&s[0]==="--"&&(s=s.slice(1)),s.length===0)return R(F,B(`bash: source: filename argument required
552
- `),2);let r=s[0],n=null,i=null;if(r.includes("/")){let u=e.fs.resolvePath(e.state.cwd,r);try{i=await e.fs.readFileText(u),n=u}catch{}}else{let c=T(e.state.env,"PATH","").split(":").filter(f=>f);for(let f of c){let h=e.fs.resolvePath(e.state.cwd,`${f}/${r}`);try{if((await e.fs.stat(h)).isDirectory)continue;i=await e.fs.readFileText(h),n=h;break}catch{}}if(i===null){let f=e.fs.resolvePath(e.state.cwd,r);try{i=await e.fs.readFileText(f),n=f}catch{}}}if(i===null)return k(`bash: ${r}: No such file or directory
553
- `);let o=new Map;if(s.length>1){for(let c=1;c<=9;c++)o.set(String(c),T(e.state.env,String(c)));o.set("#",T(e.state.env,"#")),o.set("@",T(e.state.env,"@"));let u=s.slice(1);g(e.state.env,"#",String(u.length)),g(e.state.env,"@",u.join(" "));for(let c=0;c<u.length&&c<9;c++)g(e.state.env,String(c+1),u[c]);for(let c=u.length+1;c<=9;c++)e.state.env.delete(String(c))}let a=e.state.currentSource,l=()=>{if(e.state.sourceDepth--,e.state.currentSource=a,s.length>1)for(let[u,c]of o)c===void 0?e.state.env.delete(u):g(e.state.env,u,c)};e.state.sourceDepth++,e.state.currentSource=r;try{let u=Te(i),c=await e.executeScript(u);return l(),c}catch(u){if(l(),u instanceof Y)throw u;if(u instanceof me)return R(u.stdout,u.stderr,u.exitCode);if(u.name==="ParseException")return k(`bash: ${r}: ${u.message}
554
- `);throw u}}function Vn(e){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)}function Lo(e){return e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"')}async function Bn(e,t){if(Lo(t))return null;try{let s=new Z,r=ne(s,t);return await K(e,r.expression)}catch{let s=parseInt(t,10);return Number.isNaN(s)?0:s}}function jn(e,t){if(e.state.localVarStack?.has(t)){let r=ts(e,t);if(r){r.value===void 0?e.state.env.delete(t):e.state.env.set(t,r.value);let n=e.state.localVarStack?.get(t);if(!n||n.length===0)es(e,t),e.state.localVarStack?.delete(t),e.state.fullyUnsetLocals=e.state.fullyUnsetLocals||new Map,e.state.fullyUnsetLocals.set(t,r.scopeIndex),mr(e,t);else{let i=n[n.length-1];e.state.localVarDepth=e.state.localVarDepth||new Map,e.state.localVarDepth.set(t,i.scopeIndex+1)}return!0}return e.state.env.delete(t),es(e,t),e.state.localVarStack?.delete(t),e.state.fullyUnsetLocals=e.state.fullyUnsetLocals||new Map,e.state.fullyUnsetLocals.set(t,0),!0}for(let r=e.state.localScopes.length-1;r>=0;r--){let n=e.state.localScopes[r];if(n.has(t)){let i=n.get(t);i===void 0?e.state.env.delete(t):e.state.env.set(t,i),n.delete(t);let o=!1;for(let a=r-1;a>=0;a--)if(e.state.localScopes[a].has(t)){e.state.localVarDepth&&e.state.localVarDepth.set(t,a+1),o=!0;break}return o||es(e,t),!0}}return!1}function mr(e,t){if(!e.state.tempEnvBindings||e.state.tempEnvBindings.length===0)return!1;for(let s=e.state.tempEnvBindings.length-1;s>=0;s--){let r=e.state.tempEnvBindings[s];if(r.has(t)){let n=r.get(t);return n===void 0?e.state.env.delete(t):e.state.env.set(t,n),r.delete(t),!0}}return!1}async function Un(e,t){if(t.startsWith("'")&&t.endsWith("'"))return t.slice(1,-1);if(t.startsWith('"')&&t.endsWith('"')){let s=t.slice(1,-1),n=new Z().parseWordFromString(s,!0,!1);return V(e,n)}if(t.includes("$")){let r=new Z().parseWordFromString(t,!1,!1);return V(e,r)}return t}async function yr(e,t){let s="both",r="",n=0;for(let i of t){if(i==="-v"){s="variable";continue}if(i==="-f"){s="function";continue}if(s==="function"){e.state.functions.delete(i);continue}if(s==="variable"){let u=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(u){let h=u[1],d=u[2];if(d==="@"||d==="*"){let A=Ce(e,h);for(let[b]of A)e.state.env.delete(`${h}_${b}`);e.state.env.delete(h);continue}let m=e.state.associativeArrays?.has(h);if(m){let A=await Un(e,d);e.state.env.delete(`${h}_${A}`);continue}let p=Ss(e,h),v=e.state.declaredVars?.has(h);if((e.state.env.has(h)||v)&&!p&&!m){r+=`bash: unset: ${h}: not an array variable
555
- `,n=1;continue}let S=await Bn(e,d);if(S===null&&p){r+=`bash: unset: ${d}: not a valid identifier
556
- `,n=1;continue}if(S===null)continue;if(S<0){let A=Ce(e,h),b=A.length,_=e.state.currentLine;if(b===0){r+=`bash: line ${_}: unset: [${S}]: bad array subscript
557
- `,n=1;continue}let M=b+S;if(M<0){r+=`bash: line ${_}: unset: [${S}]: bad array subscript
558
- `,n=1;continue}let $=A[M][0];e.state.env.delete(`${h}_${$}`);continue}e.state.env.delete(`${h}_${S}`);continue}if(!Vn(i)){r+=`bash: unset: \`${i}': not a valid identifier
559
- `,n=1;continue}let c=i;if(ye(e,i)){let h=De(e,i);h&&h!==i&&(c=h)}if(Ze(e,c)){r+=`bash: unset: ${c}: cannot unset: readonly variable
560
- `,n=1;continue}let f=at(e,c);if(f!==void 0&&f!==e.state.callDepth)jn(e,c);else if(e.state.fullyUnsetLocals?.has(c))e.state.env.delete(c);else if(f!==void 0){let h=e.state.accessedTempEnvVars?.has(c),d=e.state.mutatedTempEnvVars?.has(c);if((h||d)&&e.state.localVarStack?.has(c)){let m=ts(e,c);m?m.value===void 0?e.state.env.delete(c):e.state.env.set(c,m.value):e.state.env.delete(c)}else e.state.env.delete(c)}else mr(e,c)||e.state.env.delete(c);e.state.exportedVars?.delete(c);continue}let o=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(o){let u=o[1],c=o[2];if(c==="@"||c==="*"){let p=Ce(e,u);for(let[v]of p)e.state.env.delete(`${u}_${v}`);e.state.env.delete(u);continue}let f=e.state.associativeArrays?.has(u);if(f){let p=await Un(e,c);e.state.env.delete(`${u}_${p}`);continue}let h=Ss(e,u);if(e.state.env.has(u)&&!h&&!f){r+=`bash: unset: ${u}: not an array variable
561
- `,n=1;continue}let m=await Bn(e,c);if(m===null&&h){r+=`bash: unset: ${c}: not a valid identifier
562
- `,n=1;continue}if(m===null)continue;if(m<0){let p=Ce(e,u),v=p.length,y=e.state.currentLine;if(v===0){r+=`bash: line ${y}: unset: [${m}]: bad array subscript
563
- `,n=1;continue}let S=v+m;if(S<0){r+=`bash: line ${y}: unset: [${m}]: bad array subscript
564
- `,n=1;continue}let A=p[S][0];e.state.env.delete(`${u}_${A}`);continue}e.state.env.delete(`${u}_${m}`);continue}if(!Vn(i)){r+=`bash: unset: \`${i}': not a valid identifier
565
- `,n=1;continue}let a=i;if(ye(e,i)){let u=De(e,i);u&&u!==i&&(a=u)}if(Ze(e,a)){r+=`bash: unset: ${a}: cannot unset: readonly variable
566
- `,n=1;continue}let l=at(e,a);if(l!==void 0&&l!==e.state.callDepth)jn(e,a);else if(e.state.fullyUnsetLocals?.has(a))e.state.env.delete(a);else if(l!==void 0){let u=e.state.accessedTempEnvVars?.has(a),c=e.state.mutatedTempEnvVars?.has(a);if((u||c)&&e.state.localVarStack?.has(a)){let f=ts(e,a);f?f.value===void 0?e.state.env.delete(a):e.state.env.set(a,f.value):e.state.env.delete(a)}else e.state.env.delete(a)}else mr(e,a)||e.state.env.delete(a);e.state.exportedVars?.delete(a),e.state.functions.delete(i)}return R(F,B(r),n)}var gr=["extglob","dotglob","nullglob","failglob","globstar","globskipdots","nocaseglob","nocasematch","expand_aliases","lastpipe","xpg_echo"],zo=["autocd","cdable_vars","cdspell","checkhash","checkjobs","checkwinsize","cmdhist","compat31","compat32","compat40","compat41","compat42","compat43","compat44","complete_fullquote","direxpand","dirspell","execfail","extdebug","extquote","force_fignore","globasciiranges","gnu_errfmt","histappend","histreedit","histverify","hostcomplete","huponexit","inherit_errexit","interactive_comments","lithist","localvar_inherit","localvar_unset","login_shell","mailwarn","no_empty_cmd_completion","progcomp","progcomp_alias","promptvars","restricted_shell","shift_verbose","sourcepath"];function ls(e){return gr.includes(e)}function Wo(e){return zo.includes(e)}function Hn(e,t){let s=!1,r=!1,n=!1,i=!1,o=!1,a=[],l=0;for(;l<t.length;){let h=t[l];if(h==="--"){l++;break}if(h.startsWith("-")&&h.length>1){for(let d=1;d<h.length;d++){let m=h[d];switch(m){case"s":s=!0;break;case"u":r=!0;break;case"p":n=!0;break;case"q":i=!0;break;case"o":o=!0;break;default:return{exitCode:2,stdout:w(),stderr:C(`shopt: -${m}: invalid option
567
- `)}}}l++}else break}for(;l<t.length;)a.push(t[l]),l++;if(o)return Vo(e,a,s,r,n,i);if(s&&r)return{exitCode:1,stdout:w(),stderr:C(`shopt: cannot set and unset shell options simultaneously
568
- `)};if(a.length===0){if(s||r){let d=[];for(let m of gr){let p=e.state.shoptOptions[m];s&&p?d.push(n?`shopt -s ${m}`:`${m} on`):r&&!p&&d.push(n?`shopt -u ${m}`:`${m} off`)}return{exitCode:0,stdout:d.length>0?C(`${d.join(`
553
+ `)}if(r.length>1&&(r[0]==="-"||r[0]==="+")&&r[1]!=="-"){let n=r[0]==="-";for(let i=1;i<r.length;i++){let a=r[i];if(!Pi.has(a)){let o=`bash: set: ${r[0]}${a}: invalid option
554
+ ${Os}`;if(e.state.options.posix)throw await G(e,2,o,!0),new be(1);return P(o)}xi(e,Pi.get(a)??null,n)}s++;continue}if(r==="--")return qr(e,t.slice(s+1)),U();if(r==="-"){if(e.state.options.xtrace=!1,e.state.options.verbose=!1,gt(e),s+1<t.length)return qr(e,t.slice(s+1)),U();s++;continue}if(r==="+"){s++;continue}if(r.startsWith("-")||r.startsWith("+")){let n=`bash: set: ${r}: invalid option
555
+ ${Os}`;if(e.state.options.posix)throw await G(e,2,n,!0),new be(1);return P(n)}return qr(e,t.slice(s)),U()}return U()}function qr(e,t){let s=1;for(;e.state.env.has(String(s));)e.state.env.delete(String(s)),s++;for(let r=0;r<t.length;r++)g(e.state.env,String(r+1),t[r]);g(e.state.env,"#",String(t.length)),g(e.state.env,"@",t.join(" ")),g(e.state.env,"*",t.join(" "))}async function Xr(e,t){let s=1;if(t.length>0){let a=Number.parseInt(t[0],10);if(Number.isNaN(a)||a<0){let o=`bash: shift: ${t[0]}: numeric argument required
556
+ `;if(e.state.options.posix)throw await G(e,2,o,!0),new be(1);return P(o)}s=a}let r=Number.parseInt(T(e.state.env,"#","0"),10);if(s>r){let a=`bash: shift: shift count out of range
557
+ `;if(e.state.options.posix)throw await G(e,2,a,!0),new be(1);return P(a)}if(s===0)return U();let n=[];for(let a=1;a<=r;a++)n.push(T(e.state.env,String(a))||"");let i=n.slice(s);for(let a=1;a<=r;a++)e.state.env.delete(String(a));for(let a=0;a<i.length;a++)g(e.state.env,String(a+1),i[a]);return g(e.state.env,"#",String(i.length)),g(e.state.env,"@",i.join(" ")),U()}async function Jr(e,t){let s=t;if(s.length>0&&s[0]==="--"&&(s=s.slice(1)),s.length===0)return F(R,W(`bash: source: filename argument required
558
+ `),2);let r=s[0],n=null,i=null;if(r.includes("/")){let u=e.fs.resolvePath(e.state.cwd,r);try{i=await e.fs.readFileText(u),n=u}catch{}}else{let c=T(e.state.env,"PATH","").split(":").filter(f=>f);for(let f of c){let d=e.fs.resolvePath(e.state.cwd,`${f}/${r}`);try{if((await e.fs.stat(d)).isDirectory)continue;i=await e.fs.readFileText(d),n=d;break}catch{}}if(i===null){let f=e.fs.resolvePath(e.state.cwd,r);try{i=await e.fs.readFileText(f),n=f}catch{}}}if(i===null)return P(`bash: ${r}: No such file or directory
559
+ `);let a=new Map;if(s.length>1){for(let c=1;c<=9;c++)a.set(String(c),T(e.state.env,String(c)));a.set("#",T(e.state.env,"#")),a.set("@",T(e.state.env,"@"));let u=s.slice(1);g(e.state.env,"#",String(u.length)),g(e.state.env,"@",u.join(" "));for(let c=0;c<u.length&&c<9;c++)g(e.state.env,String(c+1),u[c]);for(let c=u.length+1;c<=9;c++)e.state.env.delete(String(c))}let o=e.state.currentSource,l=()=>{if(e.state.sourceDepth--,e.state.currentSource=o,s.length>1)for(let[u,c]of a)c===void 0?e.state.env.delete(u):g(e.state.env,u,c)};e.state.sourceDepth++,e.state.currentSource=r;try{let u=Fe(i),c=await e.executeScript(u),f=await Y(e,c);return l(),f}catch(u){if(l(),await te(e,u),u instanceof q)throw u;if(u instanceof ve)return F(R,R,u.exitCode);if(u.name==="ParseException")return P(`bash: ${r}: ${u.message}
560
+ `);throw u}}function _i(e){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)}function _a(e){return e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"')}async function Ti(e,t){if(_a(t))return null;try{let s=new X,r=ce(s,t);return await ee(e,r.expression)}catch{let s=parseInt(t,10);return Number.isNaN(s)?0:s}}function Ni(e,t){if(e.state.localVarStack?.has(t)){let r=Es(e,t);if(r){r.value===void 0?e.state.env.delete(t):e.state.env.set(t,r.value);let n=e.state.localVarStack?.get(t);if(!n||n.length===0)bs(e,t),e.state.localVarStack?.delete(t),e.state.fullyUnsetLocals=e.state.fullyUnsetLocals||new Map,e.state.fullyUnsetLocals.set(t,r.scopeIndex),Kr(e,t);else{let i=n[n.length-1];e.state.localVarDepth=e.state.localVarDepth||new Map,e.state.localVarDepth.set(t,i.scopeIndex+1)}return!0}return e.state.env.delete(t),bs(e,t),e.state.localVarStack?.delete(t),e.state.fullyUnsetLocals=e.state.fullyUnsetLocals||new Map,e.state.fullyUnsetLocals.set(t,0),!0}for(let r=e.state.localScopes.length-1;r>=0;r--){let n=e.state.localScopes[r];if(n.has(t)){let i=n.get(t);i===void 0?e.state.env.delete(t):e.state.env.set(t,i),n.delete(t);let a=!1;for(let o=r-1;o>=0;o--)if(e.state.localScopes[o].has(t)){e.state.localVarDepth&&e.state.localVarDepth.set(t,o+1),a=!0;break}return a||bs(e,t),!0}}return!1}function Kr(e,t){if(!e.state.tempEnvBindings||e.state.tempEnvBindings.length===0)return!1;for(let s=e.state.tempEnvBindings.length-1;s>=0;s--){let r=e.state.tempEnvBindings[s];if(r.has(t)){let n=r.get(t);return n===void 0?e.state.env.delete(t):e.state.env.set(t,n),r.delete(t),!0}}return!1}async function Oi(e,t){if(t.startsWith("'")&&t.endsWith("'"))return t.slice(1,-1);if(t.startsWith('"')&&t.endsWith('"')){let s=t.slice(1,-1),n=new X().parseWordFromString(s,!0,!1);return z(e,n)}if(t.includes("$")){let r=new X().parseWordFromString(t,!1,!1);return z(e,r)}return t}async function Yr(e,t){let s="both",r="",n=0;for(let i of t){if(i==="-v"){s="variable";continue}if(i==="-f"){s="function";continue}if(s==="function"){e.state.functions.delete(i);continue}if(s==="variable"){let u=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(u){let d=u[1],p=u[2];if(p==="@"||p==="*"){let y=Ie(e,d);for(let[v]of y)e.state.env.delete(`${d}_${v}`);e.state.env.delete(d);continue}let m=e.state.associativeArrays?.has(d);if(m){let y=await Oi(e,p);e.state.env.delete(`${d}_${y}`);continue}let h=Ks(e,d),b=e.state.declaredVars?.has(d);if((e.state.env.has(d)||b)&&!h&&!m){r+=`bash: unset: ${d}: not an array variable
561
+ `,n=1;continue}let $=await Ti(e,p);if($===null&&h){r+=`bash: unset: ${p}: not a valid identifier
562
+ `,n=1;continue}if($===null)continue;if($<0){let y=Ie(e,d),v=y.length,C=e.state.currentLine;if(v===0){r+=`bash: line ${C}: unset: [${$}]: bad array subscript
563
+ `,n=1;continue}let N=v+$;if(N<0){r+=`bash: line ${C}: unset: [${$}]: bad array subscript
564
+ `,n=1;continue}let I=y[N][0];e.state.env.delete(`${d}_${I}`);continue}e.state.env.delete(`${d}_${$}`);continue}if(!_i(i)){r+=`bash: unset: \`${i}': not a valid identifier
565
+ `,n=1;continue}let c=i;if(Ee(e,i)){let d=ze(e,i);d&&d!==i&&(c=d)}if(ot(e,c)){r+=`bash: unset: ${c}: cannot unset: readonly variable
566
+ `,n=1;continue}let f=bt(e,c);if(f!==void 0&&f!==e.state.callDepth)Ni(e,c);else if(e.state.fullyUnsetLocals?.has(c))e.state.env.delete(c);else if(f!==void 0){let d=e.state.accessedTempEnvVars?.has(c),p=e.state.mutatedTempEnvVars?.has(c);if((d||p)&&e.state.localVarStack?.has(c)){let m=Es(e,c);m?m.value===void 0?e.state.env.delete(c):e.state.env.set(c,m.value):e.state.env.delete(c)}else e.state.env.delete(c)}else Kr(e,c)||e.state.env.delete(c);e.state.exportedVars?.delete(c);continue}let a=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(a){let u=a[1],c=a[2];if(c==="@"||c==="*"){let h=Ie(e,u);for(let[b]of h)e.state.env.delete(`${u}_${b}`);e.state.env.delete(u);continue}let f=e.state.associativeArrays?.has(u);if(f){let h=await Oi(e,c);e.state.env.delete(`${u}_${h}`);continue}let d=Ks(e,u);if(e.state.env.has(u)&&!d&&!f){r+=`bash: unset: ${u}: not an array variable
567
+ `,n=1;continue}let m=await Ti(e,c);if(m===null&&d){r+=`bash: unset: ${c}: not a valid identifier
568
+ `,n=1;continue}if(m===null)continue;if(m<0){let h=Ie(e,u),b=h.length,E=e.state.currentLine;if(b===0){r+=`bash: line ${E}: unset: [${m}]: bad array subscript
569
+ `,n=1;continue}let $=b+m;if($<0){r+=`bash: line ${E}: unset: [${m}]: bad array subscript
570
+ `,n=1;continue}let y=h[$][0];e.state.env.delete(`${u}_${y}`);continue}e.state.env.delete(`${u}_${m}`);continue}if(!_i(i)){r+=`bash: unset: \`${i}': not a valid identifier
571
+ `,n=1;continue}let o=i;if(Ee(e,i)){let u=ze(e,i);u&&u!==i&&(o=u)}if(ot(e,o)){r+=`bash: unset: ${o}: cannot unset: readonly variable
572
+ `,n=1;continue}let l=bt(e,o);if(l!==void 0&&l!==e.state.callDepth)Ni(e,o);else if(e.state.fullyUnsetLocals?.has(o))e.state.env.delete(o);else if(l!==void 0){let u=e.state.accessedTempEnvVars?.has(o),c=e.state.mutatedTempEnvVars?.has(o);if((u||c)&&e.state.localVarStack?.has(o)){let f=Es(e,o);f?f.value===void 0?e.state.env.delete(o):e.state.env.set(o,f.value):e.state.env.delete(o)}else e.state.env.delete(o)}else Kr(e,o)||e.state.env.delete(o);e.state.exportedVars?.delete(o),e.state.functions.delete(i)}return F(R,W(r),n)}var Ta=`wait: usage: wait [id ...]
573
+ `;async function Qr(e,t){let s=t.find(i=>i.startsWith("-"));if(s)return{stdout:S(),stderr:V(`bash: wait: ${s}: invalid option
574
+ ${Ta}`),exitCode:2};if(Ke(e.signal),t.length===0){let i,a=new Promise((o,l)=>{i=()=>l(new pe(e.signal?.reason)),e.signal?.addEventListener("abort",i,{once:!0})});try{let o=await(e.signal?Promise.race([e.processes.waitForLineage(e.lineageId),a]):e.processes.waitForLineage(e.lineageId));return{stdout:S(),stderr:S(),exitCode:o}}finally{i&&e.signal?.removeEventListener("abort",i)}}let r=0,n="";for(let i of t){Ke(e.signal);let a=i.startsWith("%")?e.processes.resolveJobSpec(i):/^\d+$/.test(i)?Number(i):void 0;if(a===void 0||!Number.isSafeInteger(a)||!e.processes.canWait(a)){n+=i.startsWith("%")?`bash: wait: ${i}: no such job
575
+ `:`bash: wait: pid ${i} is not a child of this shell
576
+ `,r=127;continue}let o,l=new Promise((u,c)=>{o=()=>c(new pe(e.signal?.reason)),e.signal?.addEventListener("abort",o,{once:!0})});try{r=await(e.signal?Promise.race([e.processes.wait(a),l]):e.processes.wait(a))}finally{o&&e.signal?.removeEventListener("abort",o)}}return{stdout:S(),stderr:V(n),exitCode:r}}var en=["extglob","dotglob","nullglob","failglob","globstar","globskipdots","nocaseglob","nocasematch","expand_aliases","lastpipe","xpg_echo"],Na=["autocd","cdable_vars","cdspell","checkhash","checkjobs","checkwinsize","cmdhist","compat31","compat32","compat40","compat41","compat42","compat43","compat44","complete_fullquote","direxpand","dirspell","execfail","extdebug","extquote","force_fignore","globasciiranges","gnu_errfmt","histappend","histreedit","histverify","hostcomplete","huponexit","inherit_errexit","interactive_comments","lithist","localvar_inherit","localvar_unset","login_shell","mailwarn","no_empty_cmd_completion","progcomp","progcomp_alias","promptvars","restricted_shell","shift_verbose","sourcepath"];function Ds(e){return en.includes(e)}function Oa(e){return Na.includes(e)}function Di(e,t){let s=!1,r=!1,n=!1,i=!1,a=!1,o=[],l=0;for(;l<t.length;){let d=t[l];if(d==="--"){l++;break}if(d.startsWith("-")&&d.length>1){for(let p=1;p<d.length;p++){let m=d[p];switch(m){case"s":s=!0;break;case"u":r=!0;break;case"p":n=!0;break;case"q":i=!0;break;case"o":a=!0;break;default:return{exitCode:2,stdout:S(),stderr:V(`shopt: -${m}: invalid option
577
+ `)}}}l++}else break}for(;l<t.length;)o.push(t[l]),l++;if(a)return Da(e,o,s,r,n,i);if(s&&r)return{exitCode:1,stdout:S(),stderr:V(`shopt: cannot set and unset shell options simultaneously
578
+ `)};if(o.length===0){if(s||r){let p=[];for(let m of en){let h=e.state.shoptOptions[m];s&&h?p.push(n?`shopt -s ${m}`:`${m} on`):r&&!h&&p.push(n?`shopt -u ${m}`:`${m} off`)}return{exitCode:0,stdout:p.length>0?V(`${p.join(`
569
579
  `)}
570
- `):w(),stderr:w()}}let h=[];for(let d of gr){let m=e.state.shoptOptions[d];h.push(n?`shopt ${m?"-s":"-u"} ${d}`:`${d} ${m?"on":"off"}`)}return{exitCode:0,stdout:C(`${h.join(`
580
+ `):S(),stderr:S()}}let d=[];for(let p of en){let m=e.state.shoptOptions[p];d.push(n?`shopt ${m?"-s":"-u"} ${p}`:`${p} ${m?"on":"off"}`)}return{exitCode:0,stdout:V(`${d.join(`
571
581
  `)}
572
- `),stderr:w()}}let u=!1,c="",f=[];for(let h of a){if(!ls(h)&&!Wo(h)){c+=`shopt: ${h}: invalid shell option name
573
- `,u=!0;continue}if(s)ls(h)&&(e.state.shoptOptions[h]=!0,_s(e));else if(r)ls(h)&&(e.state.shoptOptions[h]=!1,_s(e));else if(ls(h)){let d=e.state.shoptOptions[h];i?d||(u=!0):n?(f.push(`shopt ${d?"-s":"-u"} ${h}`),d||(u=!0)):(f.push(`${h} ${d?"on":"off"}`),d||(u=!0))}else i?u=!0:n?(f.push(`shopt -u ${h}`),u=!0):(f.push(`${h} off`),u=!0)}return{exitCode:u?1:0,stdout:f.length>0?C(`${f.join(`
582
+ `),stderr:S()}}let u=!1,c="",f=[];for(let d of o){if(!Ds(d)&&!Oa(d)){c+=`shopt: ${d}: invalid shell option name
583
+ `,u=!0;continue}if(s)Ds(d)&&(e.state.shoptOptions[d]=!0,tr(e));else if(r)Ds(d)&&(e.state.shoptOptions[d]=!1,tr(e));else if(Ds(d)){let p=e.state.shoptOptions[d];i?p||(u=!0):n?(f.push(`shopt ${p?"-s":"-u"} ${d}`),p||(u=!0)):(f.push(`${d} ${p?"on":"off"}`),p||(u=!0))}else i?u=!0:n?(f.push(`shopt -u ${d}`),u=!0):(f.push(`${d} off`),u=!0)}return{exitCode:u?1:0,stdout:f.length>0?V(`${f.join(`
574
584
  `)}
575
- `):w(),stderr:C(c)}}function Vo(e,t,s,r,n,i){let o=new Map([["errexit","errexit"],["pipefail","pipefail"],["nounset","nounset"],["xtrace","xtrace"],["verbose","verbose"],["posix","posix"],["allexport","allexport"],["noclobber","noclobber"],["noglob","noglob"],["noexec","noexec"],["vi","vi"],["emacs","emacs"]]),a=["braceexpand","errtrace","functrace","hashall","histexpand","history","ignoreeof","interactive-comments","keyword","monitor","nolog","notify","onecmd","physical","privileged"],l=[...o.keys(),...a].sort();if(t.length===0){let h=[];for(let d of l){let m=a.includes(d),p=o.get(d),v=m||!p?!1:e.state.options[p];s&&!v||r&&v||h.push(n?`set ${v?"-o":"+o"} ${d}`:`${d} ${v?"on":"off"}`)}return{exitCode:0,stdout:h.length>0?C(`${h.join(`
585
+ `):S(),stderr:V(c)}}function Da(e,t,s,r,n,i){let a=new Map([["errexit","errexit"],["pipefail","pipefail"],["nounset","nounset"],["xtrace","xtrace"],["verbose","verbose"],["posix","posix"],["allexport","allexport"],["noclobber","noclobber"],["noglob","noglob"],["noexec","noexec"],["vi","vi"],["emacs","emacs"]]),o=["braceexpand","errtrace","functrace","hashall","histexpand","history","ignoreeof","interactive-comments","keyword","monitor","nolog","notify","onecmd","physical","privileged"],l=[...a.keys(),...o].sort();if(t.length===0){let d=[];for(let p of l){let m=o.includes(p),h=a.get(p),b=m||!h?!1:e.state.options[h];s&&!b||r&&b||d.push(n?`set ${b?"-o":"+o"} ${p}`:`${p} ${b?"on":"off"}`)}return{exitCode:0,stdout:d.length>0?V(`${d.join(`
576
586
  `)}
577
- `):w(),stderr:w()}}let u=!1,c="",f=[];for(let h of t){let d=o.has(h),m=a.includes(h);if(!d&&!m){c+=`shopt: ${h}: invalid option name
578
- `,u=!0;continue}if(m){s||r||(i?u=!0:n?(f.push(`set +o ${h}`),u=!0):(f.push(`${h} off`),u=!0));continue}let p=o.get(h);if(p)if(s)p==="vi"?e.state.options.emacs=!1:p==="emacs"&&(e.state.options.vi=!1),e.state.options[p]=!0,nt(e);else if(r)e.state.options[p]=!1,nt(e);else{let v=e.state.options[p];i?v||(u=!0):n?(f.push(`set ${v?"-o":"+o"} ${h}`),v||(u=!0)):(f.push(`${h} ${v?"on":"off"}`),v||(u=!0))}}return{exitCode:u?1:0,stdout:f.length>0?C(`${f.join(`
587
+ `):S(),stderr:S()}}let u=!1,c="",f=[];for(let d of t){let p=a.has(d),m=o.includes(d);if(!p&&!m){c+=`shopt: ${d}: invalid option name
588
+ `,u=!0;continue}if(m){s||r||(i?u=!0:n?(f.push(`set +o ${d}`),u=!0):(f.push(`${d} off`),u=!0));continue}let h=a.get(d);if(h)if(s)h==="vi"?e.state.options.emacs=!1:h==="emacs"&&(e.state.options.vi=!1),e.state.options[h]=!0,gt(e);else if(r)e.state.options[h]=!1,gt(e);else{let b=e.state.options[h];i?b||(u=!0):n?(f.push(`set ${b?"-o":"+o"} ${d}`),b||(u=!0)):(f.push(`${d} ${b?"on":"off"}`),b||(u=!0))}}return{exitCode:u?1:0,stdout:f.length>0?V(`${f.join(`
579
589
  `)}
580
- `):w(),stderr:C(c)}}async function Gn(e,t,s){if(t.includes("/")){let o=e.fs.resolvePath(e.state.cwd,t);if(!await e.fs.exists(o))return{error:"not_found",path:o};let a=o.split("/").pop()||t,l=e.commands.get(a);try{let u=await e.fs.stat(o);return u.isDirectory?{error:"permission_denied",path:o}:l?{cmd:l,path:o}:(u.mode&73)!==0?{script:!0,path:o}:{error:"permission_denied",path:o}}catch{return{error:"not_found",path:o}}}if(!s&&e.state.hashTable){let o=e.state.hashTable.get(t);if(o)if(await e.fs.exists(o)){let a=e.commands.get(t);if(a)return{cmd:a,path:o};try{let l=await e.fs.stat(o);if(!l.isDirectory&&(l.mode&73)!==0)return{script:!0,path:o}}catch{}}else e.state.hashTable.delete(t)}let n=(s??T(e.state.env,"PATH","/usr/bin:/bin")).split(":");for(let o of n){if(!o)continue;let l=`${o.startsWith("/")?o:e.fs.resolvePath(e.state.cwd,o)}/${t}`;if(await e.fs.exists(l))try{let u=await e.fs.stat(l);if(u.isDirectory)continue;let c=(u.mode&73)!==0,f=e.commands.get(t),h=o==="/bin"||o==="/usr/bin";if(f&&h)return{cmd:f,path:l};if(c){if(f&&!h)return{script:!0,path:l};if(!f)return{script:!0,path:l}}}catch{}}if(!await e.fs.exists("/usr/bin")){let o=e.commands.get(t);if(o)return{cmd:o,path:`/usr/bin/${t}`}}return null}async function cs(e,t){let s=[];if(t.includes("/")){let i=e.fs.resolvePath(e.state.cwd,t);if(await e.fs.exists(i))try{let o=await e.fs.stat(i);o.isDirectory||(o.mode&73)!==0&&s.push(t)}catch{}return s}let n=T(e.state.env,"PATH","/usr/bin:/bin").split(":");for(let i of n){if(!i)continue;let a=`${i.startsWith("/")?i:e.fs.resolvePath(e.state.cwd,i)}/${t}`;if(await e.fs.exists(a)){try{if((await e.fs.stat(a)).isDirectory)continue}catch{continue}s.push(i.startsWith("/")?a:`${i}/${t}`)}}return s}async function Yn(e,t,s,r){let n=!1,i=!1,o=!1,a=!1,l=!1,u=[];for(let p of t)if(p.startsWith("-")&&p.length>1)for(let v of p.slice(1))v==="t"?n=!0:v==="p"?i=!0:v==="P"?o=!0:v==="a"?a=!0:v==="f"&&(l=!0);else u.push(p);let c="",f="",h=0,d=!1,m=!1;for(let p of u){let v=!1;if(o){if(a){let M=await r(p);if(M.length>0){for(let $ of M)c+=`${$}
581
- `;d=!0,v=!0}}else{let M=await s(p);M&&(c+=`${M}
582
- `,d=!0,v=!0)}v||(m=!0);continue}let y=!l&&e.state.functions.has(p);if(a&&y){if(!i)if(n)c+=`function
583
- `;else{let M=e.state.functions.get(p),$=M?qn(p,M):`${p} is a function
584
- `;c+=$}v=!0}let S=e.state.env.get(`BASH_ALIAS_${p}`);if(S!==void 0&&(a||!v)&&(i||(n?c+=`alias
585
- `:c+=`${p} is aliased to \`${j(S)}'
586
- `),v=!0,!a)||Rs.has(p)&&(a||!v)&&(i||(n?c+=`keyword
587
- `:c+=`${p} is a shell keyword
588
- `),v=!0,!a))continue;if(!a&&y&&!v){if(!i)if(n)c+=`function
589
- `;else{let M=e.state.functions.get(p),$=M?qn(p,M):`${p} is a function
590
- `;c+=$}v=!0;continue}if(!(lt.has(p)&&(a||!v)&&(i||(n?c+=`builtin
591
- `:c+=`${p} is a shell builtin
592
- `),v=!0,!a))){if(a){let M=await r(p);for(let $ of M)i?c+=`${$}
590
+ `):S(),stderr:V(c)}}async function Ii(e,t,s){if(t.includes("/")){let a=e.fs.resolvePath(e.state.cwd,t);if(!await e.fs.exists(a))return{error:"not_found",path:a};let o=a.split("/").pop()||t,l=e.commands.get(o);try{let u=await e.fs.stat(a);return u.isDirectory?{error:"permission_denied",path:a}:l?{cmd:l,path:a}:(u.mode&73)!==0?{script:!0,path:a}:{error:"permission_denied",path:a}}catch{return{error:"not_found",path:a}}}if(!s&&e.state.hashTable){let a=e.state.hashTable.get(t);if(a)if(await e.fs.exists(a)){let o=e.commands.get(t);if(o)return{cmd:o,path:a};try{let l=await e.fs.stat(a);if(!l.isDirectory&&(l.mode&73)!==0)return{script:!0,path:a}}catch{}}else e.state.hashTable.delete(t)}let n=(s??T(e.state.env,"PATH","/usr/bin:/bin")).split(":");for(let a of n){if(!a)continue;let l=`${a.startsWith("/")?a:e.fs.resolvePath(e.state.cwd,a)}/${t}`;if(await e.fs.exists(l))try{let u=await e.fs.stat(l);if(u.isDirectory)continue;let c=(u.mode&73)!==0,f=e.commands.get(t),d=a==="/bin"||a==="/usr/bin";if(f&&d)return{cmd:f,path:l};if(c){if(f&&!d)return{script:!0,path:l};if(!f)return{script:!0,path:l}}}catch{}}if(!await e.fs.exists("/usr/bin")){let a=e.commands.get(t);if(a)return{cmd:a,path:`/usr/bin/${t}`}}return null}async function Is(e,t){let s=[];if(t.includes("/")){let i=e.fs.resolvePath(e.state.cwd,t);if(await e.fs.exists(i))try{let a=await e.fs.stat(i);a.isDirectory||(a.mode&73)!==0&&s.push(t)}catch{}return s}let n=T(e.state.env,"PATH","/usr/bin:/bin").split(":");for(let i of n){if(!i)continue;let o=`${i.startsWith("/")?i:e.fs.resolvePath(e.state.cwd,i)}/${t}`;if(await e.fs.exists(o)){try{if((await e.fs.stat(o)).isDirectory)continue}catch{continue}s.push(i.startsWith("/")?o:`${i}/${t}`)}}return s}async function Fi(e,t,s,r){let n=!1,i=!1,a=!1,o=!1,l=!1,u=[];for(let h of t)if(h.startsWith("-")&&h.length>1)for(let b of h.slice(1))b==="t"?n=!0:b==="p"?i=!0:b==="P"?a=!0:b==="a"?o=!0:b==="f"&&(l=!0);else u.push(h);let c="",f="",d=0,p=!1,m=!1;for(let h of u){let b=!1;if(a){if(o){let N=await r(h);if(N.length>0){for(let I of N)c+=`${I}
591
+ `;p=!0,b=!0}}else{let N=await s(h);N&&(c+=`${N}
592
+ `,p=!0,b=!0)}b||(m=!0);continue}let E=!l&&e.state.functions.has(h);if(o&&E){if(!i)if(n)c+=`function
593
+ `;else{let N=e.state.functions.get(h),I=N?Ri(h,N):`${h} is a function
594
+ `;c+=I}b=!0}let $=e.state.env.get(`BASH_ALIAS_${h}`);if($!==void 0&&(o||!b)&&(i||(n?c+=`alias
595
+ `:c+=`${h} is aliased to \`${B($)}'
596
+ `),b=!0,!o)||cr.has(h)&&(o||!b)&&(i||(n?c+=`keyword
597
+ `:c+=`${h} is a shell keyword
598
+ `),b=!0,!o))continue;if(!o&&E&&!b){if(!i)if(n)c+=`function
599
+ `;else{let N=e.state.functions.get(h),I=N?Ri(h,N):`${h} is a function
600
+ `;c+=I}b=!0;continue}if(!(Je.has(h)&&(o||!b)&&(i||(n?c+=`builtin
601
+ `:c+=`${h} is a shell builtin
602
+ `),b=!0,!o))){if(o){let N=await r(h);for(let I of N)i?c+=`${I}
593
603
  `:n?c+=`file
594
- `:c+=`${p} is ${$}
595
- `,d=!0,v=!0}else if(!v){let M=await s(p);M&&(i?c+=`${M}
604
+ `:c+=`${h} is ${I}
605
+ `,p=!0,b=!0}else if(!b){let N=await s(h);N&&(i?c+=`${N}
596
606
  `:n?c+=`file
597
- `:c+=`${p} is ${M}
598
- `,d=!0,v=!0)}if(!v&&(m=!0,!n&&!i)){let M=!0;if(p.includes("/")){let $=e.fs.resolvePath(e.state.cwd,p);await e.fs.exists($)&&(M=!1)}M&&(f+=`bash: type: ${p}: not found
599
- `)}}}return i?h=m&&!d?1:0:h=m?1:0,R(B(c),B(f),h)}function qn(e,t){let s;return t.body.type==="Group"?s=t.body.body.map(n=>At(n)).join("; "):s=At(t.body),`${e} is a function
607
+ `:c+=`${h} is ${N}
608
+ `,p=!0,b=!0)}if(!b&&(m=!0,!n&&!i)){let N=!0;if(h.includes("/")){let I=e.fs.resolvePath(e.state.cwd,h);await e.fs.exists(I)&&(N=!1)}N&&(f+=`bash: type: ${h}: not found
609
+ `)}}}return i?d=m&&!p?1:0:d=m?1:0,F(W(c),W(f),d)}function Ri(e,t){let s;return t.body.type==="Group"?s=t.body.body.map(n=>Gt(n)).join("; "):s=Gt(t.body),`${e} is a function
600
610
  ${e} ()
601
611
  {
602
612
  ${s}
603
613
  }
604
- `}function At(e){if(Array.isArray(e))return e.map(t=>At(t)).join("; ");if(e.type==="Statement"){let t=[];for(let s=0;s<e.pipelines.length;s++){let r=e.pipelines[s];t.push(Bo(r)),e.operators[s]&&t.push(e.operators[s])}return t.join(" ")}if(e.type==="SimpleCommand"){let t=e,s=[];t.name&&s.push(Zn(t.name));for(let r of t.args)s.push(Zn(r));return s.join(" ")}return e.type==="Group"?`{ ${e.body.map(r=>At(r)).join("; ")}; }`:"..."}function Bo(e){let t=e.commands.map(s=>At(s));return(e.negated?"! ":"")+t.join(" | ")}function Zn(e){let t="";for(let s of e.parts)s.type==="Literal"?t+=s.value:s.type==="DoubleQuoted"?t+=`"${s.parts.map(r=>Xn(r)).join("")}"`:s.type==="SingleQuoted"?t+=`'${s.value}'`:t+=Xn(s);return t}function Xn(e){let t=e;return t.type==="Literal"?t.value??"":t.type==="Variable"?`$${t.name}`:""}async function Kn(e,t,s,r){let n="",i="",o=0;for(let a of t){if(!a){o=1;continue}let l=e.state.env.get(`BASH_ALIAS_${a}`);if(l!==void 0)r?n+=`${a} is an alias for "${j(l)}"
605
- `:n+=`alias ${a}='${j(l)}'
606
- `;else if(Rs.has(a))r?n+=`${a} is a shell keyword
607
- `:n+=`${a}
608
- `;else if(lt.has(a))r?n+=`${a} is a shell builtin
609
- `:n+=`${a}
610
- `;else if(e.state.functions.has(a))r?n+=`${a} is a function
611
- `:n+=`${a}
612
- `;else if(a.includes("/")){let u=e.fs.resolvePath(e.state.cwd,a),c=!1;if(await e.fs.exists(u))try{let f=await e.fs.stat(u);f.isDirectory||(f.mode&73)!==0&&(r?n+=`${a} is ${a}
613
- `:n+=`${a}
614
- `,c=!0)}catch{}c||(r&&(i+=`${a}: not found
615
- `),o=1)}else if(e.commands.has(a)){let c=T(e.state.env,"PATH","/usr/bin:/bin").split(":"),f=null;for(let h of c){if(!h)continue;let d=`${h}/${a}`;try{let m=await e.fs.stat(d);if(!m.isDirectory&&(m.mode&73)!==0){f=d;break}}catch{}}f||(f=`/usr/bin/${a}`),r?n+=`${a} is ${f}
614
+ `}function Gt(e){if(Array.isArray(e))return e.map(t=>Gt(t)).join("; ");if(e.type==="Statement"){let t=[];for(let s=0;s<e.pipelines.length;s++){let r=e.pipelines[s];t.push(Ia(r)),e.operators[s]&&t.push(e.operators[s])}return t.join(" ")}if(e.type==="SimpleCommand"){let t=e,s=[];t.name&&s.push(Mi(t.name));for(let r of t.args)s.push(Mi(r));return s.join(" ")}return e.type==="Group"?`{ ${e.body.map(r=>Gt(r)).join("; ")}; }`:"..."}function Ia(e){let t=e.commands.map(s=>Gt(s));return(e.negated?"! ":"")+t.join(" | ")}function Mi(e){let t="";for(let s of e.parts)s.type==="Literal"?t+=s.value:s.type==="DoubleQuoted"?t+=`"${s.parts.map(r=>Li(r)).join("")}"`:s.type==="SingleQuoted"?t+=`'${s.value}'`:t+=Li(s);return t}function Li(e){let t=e;return t.type==="Literal"?t.value??"":t.type==="Variable"?`$${t.name}`:""}async function Wi(e,t,s,r){let n="",i="",a=0;for(let o of t){if(!o){a=1;continue}let l=e.state.env.get(`BASH_ALIAS_${o}`);if(l!==void 0)r?n+=`${o} is an alias for "${B(l)}"
615
+ `:n+=`alias ${o}='${B(l)}'
616
+ `;else if(cr.has(o))r?n+=`${o} is a shell keyword
617
+ `:n+=`${o}
618
+ `;else if(Je.has(o))r?n+=`${o} is a shell builtin
619
+ `:n+=`${o}
620
+ `;else if(e.state.functions.has(o))r?n+=`${o} is a function
621
+ `:n+=`${o}
622
+ `;else if(o.includes("/")){let u=e.fs.resolvePath(e.state.cwd,o),c=!1;if(await e.fs.exists(u))try{let f=await e.fs.stat(u);f.isDirectory||(f.mode&73)!==0&&(r?n+=`${o} is ${o}
623
+ `:n+=`${o}
624
+ `,c=!0)}catch{}c||(r&&(i+=`${o}: not found
625
+ `),a=1)}else if(e.commands.has(o)){let c=T(e.state.env,"PATH","/usr/bin:/bin").split(":"),f=null;for(let d of c){if(!d)continue;let p=`${d}/${o}`;try{let m=await e.fs.stat(p);if(!m.isDirectory&&(m.mode&73)!==0){f=p;break}}catch{}}f||(f=`/usr/bin/${o}`),r?n+=`${o} is ${f}
616
626
  `:n+=`${f}
617
- `}else r&&(i+=`${a}: not found
618
- `),o=1}return R(B(n),B(i),o)}async function Qn(e,t){if(t.includes("/")){let n=e.fs.resolvePath(e.state.cwd,t);if(await e.fs.exists(n)){try{let i=await e.fs.stat(n);if(i.isDirectory||!((i.mode&73)!==0))return null}catch{return null}return t}return null}let r=T(e.state.env,"PATH","/usr/bin:/bin").split(":");for(let n of r){if(!n)continue;let o=`${n.startsWith("/")?n:e.fs.resolvePath(e.state.cwd,n)}/${t}`;if(await e.fs.exists(o)){try{if((await e.fs.stat(o)).isDirectory)continue}catch{continue}return`${n}/${t}`}}if(e.commands.has(t)){for(let n of r)if(n==="/usr/bin"||n==="/bin")return`${n}/${t}`;return`/usr/bin/${t}`}return null}async function Jn(e,t,s,r,n,i,o,a){let{ctx:l,runCommand:u}=e,c=Je(s);if(l.coverage&&lt.has(t)&&l.coverage.hit(`bash:builtin:${t}`),t==="export")return rr(l,c);if(t==="unset")return yr(l,c);if(t==="exit")return sr(l,c);if(t==="local")return ar(l,c);if(t==="set")return dr(l,c);if(t==="break")return xs(l,c);if(t==="continue")return Bs(l,c);if(t==="return")return ur(l,c);if(t==="eval"&&l.state.options.posix)return is(l,c,n);if(t==="shift")return hr(l,c);if(t==="getopts")return os(l,c);if(t==="compgen")return Ls(l,c);if(t==="complete")return Ws(l,c);if(t==="compopt")return Vs(l,c);if(t==="pushd")return await Js(l,c);if(t==="popd")return er(l,c);if(t==="dirs")return tr(l,c);if(t==="source"||t===".")return pr(l,c);if(t==="read")return await cr(l,c,await H(n),a);if(t==="mapfile"||t==="readarray")return await lr(l,c,await H(n));if(t==="declare"||t==="typeset")return Ys(l,c);if(t==="readonly")return Ks(l,c);if(!i){let f=l.state.functions.get(t);if(f)return rs(l,f,c,n)}if(t==="eval")return is(l,c,n);if(t==="cd")return await Ns(l,c);if(t===":"||t==="true")return U();if(t==="false")return re(!1);if(t==="let")return or(l,c);if(t==="command")return jo(e,c,n);if(t==="builtin")return Uo(e,c,n);if(t==="shopt")return Hn(l,c);if(t==="exec"){if(s.length===0)return U();let[f,...h]=s;return u(j(f),h,[],n,!1,!1,-1)}if(t==="wait")return U();if(t==="type")return await Yn(l,c,f=>Qn(l,f),f=>cs(l,f));if(t==="hash")return nr(l,c);if(t==="help")return ir(l,c);if(t==="["||t==="test"){let f=c;if(t==="["){if(c[c.length-1]!=="]")return k("[: missing `]'\n",2);f=c.slice(0,-1)}return St(l,f)}return null}async function jo(e,t,s){let{ctx:r,runCommand:n}=e;if(t.length===0)return U();let i=!1,o=!1,a=!1,l=t;for(;l.length>0&&l[0].startsWith("-");){let f=l[0];if(f==="--"){l=l.slice(1);break}for(let h of f.slice(1))h==="p"?i=!0:h==="V"?o=!0:h==="v"&&(a=!0);l=l.slice(1)}if(l.length===0)return U();if(a||o)return await Kn(r,l,a,o);let[u,...c]=l;return n(u,c.map(f=>B(f)),[],s,!0,i,-1)}async function Uo(e,t,s){let{runCommand:r}=e;if(t.length===0)return U();let n=t;if(n[0]==="--"&&(n=n.slice(1),n.length===0))return U();let i=n[0];if(!lt.has(i))return k(`bash: builtin: ${i}: not a shell builtin
619
- `);let[,...o]=n;return r(i,o.map(a=>B(a)),[],s,!0,!1,-1)}async function ei(e,t,s,r,n){let{ctx:i,buildExportedEnv:o,executeUserScript:a}=e,u=await Gn(i,t,n?"/usr/bin:/bin":void 0);if(!u)return ln(t)?k(`bash: ${t}: command not available in browser environments. Exclude '${t}' from your commands or use the Node.js bundle.
620
- `,127):k(`bash: ${t}: command not found
621
- `,127);if("error"in u)return u.error==="permission_denied"?k(`bash: ${t}: Permission denied
622
- `,126):k(`bash: ${t}: No such file or directory
623
- `,127);if("script"in u)return t.includes("/")||(i.state.hashTable||(i.state.hashTable=new Map),i.state.hashTable.set(t,u.path)),await a(u.path,s,r);let{cmd:c,path:f}=u;t.includes("/")||(i.state.hashTable||(i.state.hashTable=new Map),i.state.hashTable.set(t,f));let h,d=r.getReader(),m=await d.read();d.releaseLock(),m.done||!m.value||m.value.length===0?i.state.groupStdin?h=i.state.groupStdin:h=w():h=O(se(m.value),r);let p=o(),v={fs:i.fs,cwd:i.state.cwd,env:i.state.env,exportedEnv:p,stdin:h,limits:i.limits,exec:i.execFn,fetch:i.fetch,getRegisteredCommands:()=>Array.from(i.commands.keys()),sleep:i.sleep,trace:i.trace,fileDescriptors:i.state.fileDescriptors,xpgEcho:i.state.shoptOptions.xpg_echo,coverage:i.coverage};try{return await c.execute(s,v)}catch(y){if(y instanceof de)throw y;return k(`${t}: ${Fe(y)}
624
- `)}}async function wr(e,t){let s=e.state.inCondition;e.state.inCondition=!0;let r=w(),n=w(),i=0;try{for(let o of t){let a=await e.executeStatement(o);r=O(r,a.stdout),n=O(n,a.stderr),i=a.exitCode}}finally{e.state.inCondition=s}return{stdout:r,stderr:n,exitCode:i}}function kt(e,t,s,r){if(e instanceof Ee)return t=O(t,e.stdout),s=O(s,e.stderr),e.levels>1&&r>1?(e.levels--,e.stdout=t,e.stderr=s,{action:"rethrow",stdout:t,stderr:s,error:e}):{action:"break",stdout:t,stderr:s};if(e instanceof Se)return t=O(t,e.stdout),s=O(s,e.stderr),e.levels>1&&r>1?(e.levels--,e.stdout=t,e.stderr=s,{action:"rethrow",stdout:t,stderr:s,error:e}):{action:"continue",stdout:t,stderr:s};if(e instanceof me||e instanceof Ae||e instanceof Y||e instanceof de)return e.prependOutput(t,s),{action:"rethrow",stdout:t,stderr:s,error:e};let n=Fe(e);return{action:"error",stdout:t,stderr:O(s,C(`${n}
625
- `)),exitCode:1}}async function us(e,t,s=w(),r=w()){let n=s,i=r,o=0;try{for(let a of t){let l=await e.executeStatement(a);n=O(n,l.stdout),i=O(i,l.stderr),o=l.exitCode}}catch(a){if(It(a)||a instanceof Ae||a instanceof Y||a instanceof de||a instanceof Ve)throw a.prependOutput(n,i),a;return{stdout:n,stderr:O(i,C(`${Fe(a)}
626
- `)),exitCode:1}}return{stdout:n,stderr:i,exitCode:o}}async function ti(e,t){let s=w(),r=w();for(let n of t.clauses){let i=await wr(e,n.condition);if(s=O(s,i.stdout),r=O(r,i.stderr),i.exitCode===0)return us(e,n.body,s,r)}return t.elseBody?us(e,t.elseBody,s,r):{stdout:s,stderr:r,exitCode:0}}async function si(e,t){let s=await Me(e,t.redirections);if(s)return s;let r=[],n=[],i=async(h,d)=>{let m=await H(d);m.length>0&&h.push(m)},o=()=>he(r),a=()=>he(n),l=0,u=0;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t.variable))return k(`bash: \`${t.variable}': not a valid identifier
627
- `);let c=[];if(t.words===null)c=T(e.state.env,"@","").split(" ").filter(Boolean);else if(t.words.length===0)c=[];else try{for(let h of t.words){let d=await Ie(e,h);c.push(...d.values)}}catch(h){if(h instanceof Dt)return{stdout:w(),stderr:h.stderr,exitCode:1};throw h}e.state.loopDepth++;try{for(let h of c){u++,u>e.limits.maxLoopIterations&&Ne(`for loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",o(),a()),g(e.state.env,t.variable,h);try{for(let d of t.body){let m=await e.executeStatement(d);await i(r,m.stdout),await i(n,m.stderr),l=m.exitCode}}catch(d){let m=kt(d,o(),a(),e.state.loopDepth);if(r.length=0,n.length=0,m.action==="break"){await i(r,m.stdout),await i(n,m.stderr);break}if(m.action==="continue"){await i(r,m.stdout),await i(n,m.stderr);continue}if(m.action==="error"){let p=R(m.stdout,m.stderr,m.exitCode??1);return Q(e,p,t.redirections)}throw m.error}}}finally{e.state.loopDepth--}let f=R(o(),a(),l);return Q(e,f,t.redirections)}async function ri(e,t){let s=await Me(e,t.redirections);if(s)return s;let r=t.line;r!==void 0&&(e.state.currentLine=r);let n=[],i=[],o=async(h,d)=>{let m=await H(d);m.length>0&&h.push(m)},a=()=>he(n),l=()=>he(i),u=0,c=0;t.init&&await K(e,t.init.expression),e.state.loopDepth++;try{for(;c++,c>e.limits.maxLoopIterations&&Ne(`for loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",a(),l()),!(t.condition&&(r!==void 0&&(e.state.currentLine=r),await K(e,t.condition.expression)===0));){try{for(let h of t.body){let d=await e.executeStatement(h);await o(n,d.stdout),await o(i,d.stderr),u=d.exitCode}}catch(h){let d=kt(h,a(),l(),e.state.loopDepth);if(n.length=0,i.length=0,d.action==="break"){await o(n,d.stdout),await o(i,d.stderr);break}if(d.action==="continue"){await o(n,d.stdout),await o(i,d.stderr),t.update&&await K(e,t.update.expression);continue}if(d.action==="error"){let m=R(d.stdout,d.stderr,d.exitCode??1);return Q(e,m,t.redirections)}throw d.error}t.update&&await K(e,t.update.expression)}}finally{e.state.loopDepth--}let f=R(a(),l(),u);return Q(e,f,t.redirections)}async function ni(e,t,s=w()){let r=[],n=[],i=async(d,m)=>{let p=await H(m);p.length>0&&d.push(p)},o=()=>he(r),a=()=>he(n),l=0,u=0,c=s,f=!1;for(let d of t.redirections)if((d.operator==="<<"||d.operator==="<<-")&&d.target.type==="HereDoc"){let m=d.target,p=await V(e,m.content);m.stripTabs&&(p=p.split(`
628
- `).map(v=>v.replace(/^\t+/,"")).join(`
629
- `)),c=C(p),f=!0}else if(d.operator==="<<<"&&d.target.type==="Word")c=C(`${await V(e,d.target)}
630
- `),f=!0;else if(d.operator==="<"&&d.target.type==="Word")try{let m=await V(e,d.target),p=e.fs.resolvePath(e.state.cwd,m);c=await e.fs.readFile(p),f=!0}catch{let m=await V(e,d.target);return k(`bash: ${m}: No such file or directory
631
- `)}let h=e.state.groupStdin;if(f)e.state.groupStdin=c;else{let d=await H(s);d.length>0&&(e.state.groupStdin=se(d))}e.state.loopDepth++;try{for(;;){u++,u>e.limits.maxLoopIterations&&Ne(`while loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",o(),a());let d=0,m=!1,p=!1,v=e.state.inCondition;e.state.inCondition=!0;try{for(let y of t.condition){let S=await e.executeStatement(y);await i(r,S.stdout),await i(n,S.stderr),d=S.exitCode}}catch(y){if(y instanceof Ee){if(await i(r,y.stdout),await i(n,y.stderr),y.levels>1&&e.state.loopDepth>1)throw y.levels--,y.stdout=o(),y.stderr=a(),e.state.inCondition=v,y;m=!0}else if(y instanceof Se){if(await i(r,y.stdout),await i(n,y.stderr),y.levels>1&&e.state.loopDepth>1)throw y.levels--,y.stdout=o(),y.stderr=a(),e.state.inCondition=v,y;p=!0}else throw e.state.inCondition=v,y}finally{e.state.inCondition=v}if(m)break;if(!p){if(d!==0)break;try{for(let y of t.body){let S=await e.executeStatement(y);await i(r,S.stdout),await i(n,S.stderr),l=S.exitCode}}catch(y){let S=kt(y,o(),a(),e.state.loopDepth);if(r.length=0,n.length=0,S.action==="break"){await i(r,S.stdout),await i(n,S.stderr);break}if(S.action==="continue"){await i(r,S.stdout),await i(n,S.stderr);continue}if(S.action==="error")return R(S.stdout,S.stderr,S.exitCode??1);throw S.error}}}}finally{e.state.loopDepth--,e.state.groupStdin=h}return R(o(),a(),l)}async function ii(e,t){let s=[],r=[],n=async(u,c)=>{let f=await H(c);f.length>0&&u.push(f)},i=()=>he(s),o=()=>he(r),a=0,l=0;e.state.loopDepth++;try{for(;;){l++,l>e.limits.maxLoopIterations&&Ne(`until loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",i(),o());let u=await wr(e,t.condition);if(await n(s,u.stdout),await n(r,u.stderr),u.exitCode===0)break;try{for(let c of t.body){let f=await e.executeStatement(c);await n(s,f.stdout),await n(r,f.stderr),a=f.exitCode}}catch(c){let f=kt(c,i(),o(),e.state.loopDepth);if(s.length=0,r.length=0,f.action==="break"){await n(s,f.stdout),await n(r,f.stderr);break}if(f.action==="continue"){await n(s,f.stdout),await n(r,f.stderr);continue}if(f.action==="error")return R(f.stdout,f.stderr,f.exitCode??1);throw f.error}}}finally{e.state.loopDepth--}return R(i(),o(),a)}async function oi(e,t){let s=await Me(e,t.redirections);if(s)return s;let r=w(),n=w(),i=0,o=await V(e,t.word),a=!1;for(let u=0;u<t.items.length;u++){let c=t.items[u],f=a;if(!a)for(let h of c.patterns){let d=await V(e,h);Vr(h)&&(d=zr(d));let m=e.state.shoptOptions.nocasematch,p=e.state.shoptOptions.extglob;if(ot(o,d,m,p)){f=!0;break}}if(f){let h=await us(e,c.body,r,n);if(r=h.stdout,n=h.stderr,i=h.exitCode,c.terminator===";;")break;c.terminator===";&"?a=!0:a=!1}else a=!1}let l=R(r,n,i);return Q(e,l,t.redirections)}function vr(e,t){if(e.parts.length!==1)return!1;let s=e.parts[0];return s.type!=="Literal"?!1:t.includes(s.value)}function ai(e){if(!e.startsWith("__rw__:"))return null;let t=e.slice(7),s=t.indexOf(":");if(s===-1)return null;let r=Number.parseInt(t.slice(0,s),10);if(Number.isNaN(r)||r<0)return null;let n=s+1,i=t.slice(n,n+r),o=n+r+1,a=t.slice(o),l=a.indexOf(":");if(l===-1)return null;let u=Number.parseInt(a.slice(0,l),10);if(Number.isNaN(u)||u<0)return null;let c=a.slice(l+1);return{path:i,position:u,content:c}}var li="+ ";async function ci(e){let t=e.state.env.get("PS4");if(t===void 0)return li;let s=j(t);if(s==="")return"";try{let n=new Z().parseWordFromString(s,!1,!1);return await V(e,n)}catch{return e.state.expansionStderr=`${e.state.expansionStderr||""}bash: ${s}: bad substitution
632
- `,s||li}}function Ho(e){return e.map(t=>Go(t)).join(" ")}function Go(e){if(e==="")return"''";if(!/[\s'"\\$`!*?[\]{}|&;<>()~#\n\t]/.test(e))return e;let s=/[\x00-\x1f\x7f]/.test(e),r=e.includes(`
633
- `),n=e.includes(" "),i=e.includes("\\"),o=e.includes("'");if(s||r||n||i){let l="";for(let u of e){let c=u.charCodeAt(0);u===`
634
- `?l+="\\n":u===" "?l+="\\t":u==="\\"?l+="\\\\":u==="'"?l+="'":u==='"'?l+='"':c<32||c===127?c<256?l+=`\\x${c.toString(16).padStart(2,"0")}`:l+=`\\u${c.toString(16).padStart(4,"0")}`:l+=u}return`$'${l}'`}return o?`"${e.replace(/([\\$`"])/g,"\\$1")}"`:`'${e}'`}async function ui(e,t,s){if(!e.state.options.xtrace)return"";let r=await ci(e),n=[t,...s],i=Ho(n);return`${r}${i}
635
- `}async function fi(e,t,s){return e.state.options.xtrace?`${await ci(e)}${t}=${s}
636
- `:""}async function di(e,t,s){let r=t.timed?performance.now():0,n=w(),i=U(),o=0,a=[],l=t.commands.length>1,u=e.state.lastArg;for(let f=0;f<t.commands.length;f++){let h=t.commands[f],d=f===t.commands.length-1,m=f===0;l&&(e.state.lastArg=B(""),m||(e.state.groupStdin=void 0));let v=l&&(!d||!e.state.shoptOptions.lastpipe)?new Map(e.state.env):null,y;try{y=await s(h,n)}catch(S){if(S instanceof Ot)y={stdout:S.stdout,stderr:S.stderr,exitCode:1};else if(S instanceof Y&&t.commands.length>1)y={stdout:S.stdout,stderr:S.stderr,exitCode:S.exitCode};else if(S instanceof Ae&&t.commands.length>1)y={stdout:S.stdout,stderr:S.stderr,exitCode:S.exitCode};else throw v&&(e.state.env=v),S}v&&(e.state.env=v),a.push(y.exitCode),y.exitCode!==0&&(o=y.exitCode),d?i=y:t.pipeStderr?.[f]??!1?(n=O(y.stderr,y.stdout),i={stdout:w(),stderr:w(),exitCode:y.exitCode}):(n=y.stdout,i={stdout:w(),stderr:y.stderr,exitCode:y.exitCode})}if(t.commands.length>1||t.commands.length===1&&t.commands[0].type==="SimpleCommand"){for(let f of e.state.env.keys())f.startsWith("PIPESTATUS_")&&e.state.env.delete(f);for(let f=0;f<a.length;f++)g(e.state.env,`PIPESTATUS_${f}`,String(a[f]));g(e.state.env,"PIPESTATUS__length",String(a.length))}if(e.state.options.pipefail&&o!==0&&(i={...i,exitCode:o}),t.negated&&(i={...i,exitCode:i.exitCode===0?1:0}),t.timed){let h=(performance.now()-r)/1e3,d=Math.floor(h/60),m=h%60,p;t.timePosix?p=`real ${h.toFixed(2)}
627
+ `}else r&&(i+=`${o}: not found
628
+ `),a=1}return F(W(n),W(i),a)}async function Vi(e,t){if(t.includes("/")){let n=e.fs.resolvePath(e.state.cwd,t);if(await e.fs.exists(n)){try{let i=await e.fs.stat(n);if(i.isDirectory||!((i.mode&73)!==0))return null}catch{return null}return t}return null}let r=T(e.state.env,"PATH","/usr/bin:/bin").split(":");for(let n of r){if(!n)continue;let a=`${n.startsWith("/")?n:e.fs.resolvePath(e.state.cwd,n)}/${t}`;if(await e.fs.exists(a)){try{if((await e.fs.stat(a)).isDirectory)continue}catch{continue}return`${n}/${t}`}}if(e.commands.has(t)){for(let n of r)if(n==="/usr/bin"||n==="/bin")return`${n}/${t}`;return`/usr/bin/${t}`}return null}async function zi(e,t,s,r,n,i,a,o){let{ctx:l,runCommand:u}=e,c=ft(s);if(l.coverage&&Je.has(t)&&l.coverage.hit(`bash:builtin:${t}`),t==="export")return Rr(l,c);if(t==="unset")return Yr(l,c);if(t==="exit")return Ir(l,c);if(t==="local")return Br(l,c);if(t==="set")return Zr(l,c);if(t==="break")return rr(l,c);if(t==="continue")return br(l,c);if(t==="return")return Hr(l,c);if(t==="eval"&&l.state.options.posix)return xs(l,c,n);if(t==="shift")return Xr(l,c);if(t==="getopts")return _s(l,c);if(t==="compgen")return yr(l,c);if(t==="complete")return wr(l,c);if(t==="compopt")return vr(l,c);if(t==="pushd")return await Nr(l,c);if(t==="popd")return Or(l,c);if(t==="dirs")return Dr(l,c);if(t==="source"||t===".")return Jr(l,c);if(t==="read")return await Gr(l,c,await re(n),o);if(t==="mapfile"||t==="readarray")return await Ur(l,c,await re(n));if(t==="declare"||t==="typeset")return xr(l,c);if(t==="readonly")return _r(l,c);if(!i){let f=l.state.functions.get(t);if(f)return As(l,f,c,n)}if(t==="eval")return xs(l,c,n);if(t==="cd")return await nr(l,c);if(t===":"||t==="true")return U();if(t==="false")return le(!1);if(t==="let")return jr(l,c);if(t==="command")return Ra(e,c,n);if(t==="builtin")return Ma(e,c,n);if(t==="shopt")return Di(l,c);if(t==="exec"){if(s.length===0)return U();let[f,...d]=s;return u(B(f),d,[],n,!1,!1,-1)}if(t==="wait")return await Qr(l,c);if(t==="jobs")return await Fr(l,c,(f,d)=>u(f,d.map(W),d.map(()=>!1),S()));if(t==="kill")return zr(l,c);if(t==="type")return await Fi(l,c,f=>Vi(l,f),f=>Is(l,f));if(t==="hash")return Mr(l,c);if(t==="help")return Lr(l,c);if(t==="["||t==="test"){let f=c;if(t==="["){if(c[c.length-1]!=="]")return P("[: missing `]'\n",2);f=c.slice(0,-1)}return zt(l,f)}return null}async function Ra(e,t,s){let{ctx:r,runCommand:n}=e;if(t.length===0)return U();let i=!1,a=!1,o=!1,l=t;for(;l.length>0&&l[0].startsWith("-");){let f=l[0];if(f==="--"){l=l.slice(1);break}for(let d of f.slice(1))d==="p"?i=!0:d==="V"?a=!0:d==="v"&&(o=!0);l=l.slice(1)}if(l.length===0)return U();if(o||a)return await Wi(r,l,o,a);let[u,...c]=l;return n(u,c.map(f=>W(f)),[],s,!0,i,-1)}async function Ma(e,t,s){let{runCommand:r}=e;if(t.length===0)return U();let n=t;if(n[0]==="--"&&(n=n.slice(1),n.length===0))return U();let i=n[0];if(!Je.has(i))return P(`bash: builtin: ${i}: not a shell builtin
629
+ `);let[,...a]=n;return r(i,a.map(o=>W(o)),[],s,!0,!1,-1)}async function ji(e,t,s,r,n){let{buildExportedEnv:i,ctx:a,executeUserScript:o}=e,u=await Ii(a,t,n?"/usr/bin:/bin":void 0);if(!u)return Hn(t)?P(`bash: ${t}: command not available in browser environments. Exclude '${t}' from your commands or use the Node.js bundle.
630
+ `,127):P(`bash: ${t}: command not found
631
+ `,127);if("error"in u)return u.error==="permission_denied"?P(`bash: ${t}: Permission denied
632
+ `,126):P(`bash: ${t}: No such file or directory
633
+ `,127);if("script"in u)return t.includes("/")||(a.state.hashTable||(a.state.hashTable=new Map),a.state.hashTable.set(t,u.path)),await o(u.path,s,r);let{cmd:c,path:f}=u;t.includes("/")||(a.state.hashTable||(a.state.hashTable=new Map),a.state.hashTable.set(t,f));let d,p=r.getReader(),m=await p.read();p.releaseLock(),m.done||!m.value||m.value.length===0?a.state.groupStdin?d=a.state.groupStdin:d=S():d=rt(fe(m.value),r);let h=i(),b={fs:a.fs,cwd:a.state.cwd,env:a.state.env,exportedEnv:h,stdin:d,limits:a.limits,exec:a.execFn,fetch:a.fetch,getRegisteredCommands:()=>Array.from(a.commands.keys()),sleep:a.sleep,trace:a.trace,fileDescriptors:a.state.fileDescriptors,xpgEcho:a.state.shoptOptions.xpg_echo,coverage:a.coverage,signal:a.signal};try{return await c.execute(s,b)}catch(E){if(E instanceof ae)throw E;return P(`${t}: ${He(E)}
634
+ `)}}async function Rs(e,t){let s=e.state.inCondition;e.state.inCondition=!0;let r=0;try{for(let n of t){let i=await e.executeStatement(n);await Y(e,i),r=i.exitCode}}catch(n){throw await te(e,n),n}finally{e.state.inCondition=s}return{stdout:S(),stderr:S(),exitCode:r}}function Ht(e,t){return e instanceof Ce?e.levels>1&&t>1?(e.levels--,{action:"rethrow",error:e}):{action:"break"}:e instanceof Ae?e.levels>1&&t>1?(e.levels--,{action:"rethrow",error:e}):{action:"continue"}:e instanceof ve||e instanceof ke||e instanceof q||e instanceof ae?{action:"rethrow",error:e}:{action:"error",exitCode:1,error:e}}async function Ms(e,t){let s=0;try{for(let r of t){let n=await e.executeStatement(r);await Y(e,n),s=n.exitCode}}catch(r){let n=await te(e,r);if(es(r)||r instanceof ke||r instanceof q||r instanceof ae||r instanceof Ge)throw r;if(!n){let i=He(r);await Y(e,P(i.endsWith(`
635
+ `)?i:`${i}
636
+ `))}return{stdout:S(),stderr:S(),exitCode:1}}return{stdout:S(),stderr:S(),exitCode:s}}var La="+ ";async function Bi(e){let t=e.state.env.get("PS4"),s=e.substitutionDepth??0;if(t===void 0)return`${"+".repeat(s+1)} `;let r=B(t);if(r==="")return"";try{let i=new X().parseWordFromString(r,!1,!1),a=await z(e,i);return s>0&&a.length>0?`${a[0].repeat(s)}${a}`:a}catch{await G(e,2,`bash: ${r}: bad substitution
637
+ `);let n=r||La;return s>0&&n.length>0?`${n[0].repeat(s)}${n}`:n}}function Fa(e){return e.map(t=>Wa(t)).join(" ")}function Wa(e){if(e==="")return"''";if(!/[\s'"\\$`!*?[\]{}|&;<>()~#\n\t]/.test(e))return e;let s=/[\x00-\x1f\x7f]/.test(e),r=e.includes(`
638
+ `),n=e.includes(" "),i=e.includes("\\"),a=e.includes("'");if(s||r||n||i){let l="";for(let u of e){let c=u.charCodeAt(0);u===`
639
+ `?l+="\\n":u===" "?l+="\\t":u==="\\"?l+="\\\\":u==="'"?l+="'":u==='"'?l+='"':c<32||c===127?c<256?l+=`\\x${c.toString(16).padStart(2,"0")}`:l+=`\\u${c.toString(16).padStart(4,"0")}`:l+=u}return`$'${l}'`}return a?`"${e.replace(/([\\$`"])/g,"\\$1")}"`:`'${e}'`}async function Ls(e,t,s){if(!e.state.options.xtrace)return"";let r=await Bi(e),n=[t,...s],i=Fa(n);return`${r}${i}
640
+ `}async function Ui(e,t,s){return e.state.options.xtrace?`${await Bi(e)}${t}=${s}
641
+ `:""}function qt(e){let t=He(e);return t.endsWith(`
642
+ `)?t:`${t}
643
+ `}async function Pt(e,t,s){let r=await De(e,e.outputChannels,t);return r.error?K(e,r.channels,()=>Y(e,r.error)):K(e,r.channels,async()=>{try{let n=await s(r.legacyRedirections);return{stdout:S(),stderr:S(),exitCode:n}}catch(n){let i=await te(e,n);if(n instanceof Error&&"code"in n&&n.code==="ENOSPC")return i?{stdout:S(),stderr:S(),exitCode:1}:await Y(e,P(qt(n)));throw n}})}async function Gi(e,t){return Pt(e,t.redirections,async()=>{for(let s of t.clauses)if((await Rs(e,s.condition)).exitCode===0)return(await Ms(e,s.body)).exitCode;return t.elseBody?(await Ms(e,t.elseBody)).exitCode:0})}async function Hi(e,t){return Pt(e,t.redirections,async()=>{let s=0,r=0;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t.variable))return await Y(e,P(`bash: \`${t.variable}': not a valid identifier
644
+ `)),1;let n=[];if(t.words===null)n=T(e.state.env,"@","").split(" ").filter(Boolean);else if(t.words.length>0)try{for(let i of t.words){let a=await je(e,i);n.push(...a.values)}}catch(i){if(i instanceof Qt)return await te(e,i),1;throw i}e.state.loopDepth++;try{for(let i of n){if(r++,e.signal?.aborted)throw new pe(e.signal.reason);r>e.limits.maxLoopIterations&&Me(`for loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations"),g(e.state.env,t.variable,i),e.state.options.xtrace&&await G(e,2,await Ls(e,"for",[t.variable,"in",...n]));try{for(let a of t.body){let o=await e.executeStatement(a);await Y(e,o),s=o.exitCode}}catch(a){let o=await te(e,a),l=Ht(a,e.state.loopDepth);if(l.action==="break")break;if(l.action==="continue")continue;if(l.action==="error")return o||await Y(e,P(qt(l.error))),l.exitCode??1;throw l.error}}}finally{e.state.loopDepth--}return s})}async function qi(e,t){return Pt(e,t.redirections,async()=>{let s=t.line;s!==void 0&&(e.state.currentLine=s);let r=0,n=0;t.init&&await ee(e,t.init.expression),e.state.loopDepth++;try{for(;;){if(n++,e.signal?.aborted)throw new pe(e.signal.reason);if(n>e.limits.maxLoopIterations&&Me(`for loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations"),t.condition&&(s!==void 0&&(e.state.currentLine=s),await ee(e,t.condition.expression)===0))break;try{for(let i of t.body){let a=await e.executeStatement(i);await Y(e,a),r=a.exitCode}}catch(i){let a=await te(e,i),o=Ht(i,e.state.loopDepth);if(o.action==="break")break;if(o.action==="continue"){t.update&&await ee(e,t.update.expression);continue}if(o.action==="error")return a||await Y(e,P(qt(o.error))),o.exitCode??1;throw o.error}t.update&&await ee(e,t.update.expression)}}finally{e.state.loopDepth--}return r})}async function Zi(e,t,s=S()){return Pt(e,t.redirections,async r=>{let n=0,i=0,a=s,o=!1;for(let u of r)if((u.operator==="<<"||u.operator==="<<-")&&u.target.type==="HereDoc"){let c=u.target,f=await z(e,c.content);c.stripTabs&&(f=f.split(`
645
+ `).map(d=>d.replace(/^\t+/,"")).join(`
646
+ `)),a=V(f),o=!0}else if(u.operator==="<<<"&&u.target.type==="Word")a=V(`${await z(e,u.target)}
647
+ `),o=!0;else if(u.operator==="<"&&u.target.type==="Word"){let c=await z(e,u.target);try{let f=e.fs.resolvePath(e.state.cwd,c);a=await e.fs.readFile(f),o=!0}catch{return await Y(e,P(`bash: ${c}: No such file or directory
648
+ `)),1}}let l=e.state.groupStdin;if(o)e.state.groupStdin=a;else{let u=await re(s);u.length>0&&(e.state.groupStdin=fe(u))}e.state.loopDepth++;try{for(;;){if(i++,e.signal?.aborted)throw new pe(e.signal.reason);i>e.limits.maxLoopIterations&&Me(`while loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations");let u=0,c=!1,f=!1;try{u=(await Rs(e,t.condition)).exitCode}catch(d){if(await te(e,d),d instanceof Ce){if(d.levels>1&&e.state.loopDepth>1)throw d.levels--,d;c=!0}else if(d instanceof Ae){if(d.levels>1&&e.state.loopDepth>1)throw d.levels--,d;f=!0}else throw d}if(c)break;if(!f){if(u!==0)break;try{for(let d of t.body){let p=await e.executeStatement(d);await Y(e,p),n=p.exitCode}}catch(d){let p=await te(e,d),m=Ht(d,e.state.loopDepth);if(m.action==="break")break;if(m.action==="continue")continue;if(m.action==="error")return p||await Y(e,P(qt(m.error))),m.exitCode??1;throw m.error}}}}finally{e.state.loopDepth--,e.state.groupStdin=l}return n})}async function Xi(e,t){return Pt(e,t.redirections,async()=>{let s=0,r=0;e.state.loopDepth++;try{for(;;){if(r++,e.signal?.aborted)throw new pe(e.signal.reason);if(r>e.limits.maxLoopIterations&&Me(`until loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations"),(await Rs(e,t.condition)).exitCode===0)break;try{for(let i of t.body){let a=await e.executeStatement(i);await Y(e,a),s=a.exitCode}}catch(i){let a=await te(e,i),o=Ht(i,e.state.loopDepth);if(o.action==="break")break;if(o.action==="continue")continue;if(o.action==="error")return a||await Y(e,P(qt(o.error))),o.exitCode??1;throw o.error}}}finally{e.state.loopDepth--}return s})}async function Ji(e,t){return Pt(e,t.redirections,async()=>{let s=0,r=await z(e,t.word),n=!1;for(let i=0;i<t.items.length;i++){let a=t.items[i],o=n;if(!n)for(let l of a.patterns){let u=await z(e,l);Pn(l)&&(u=Sn(u));let c=e.state.shoptOptions.nocasematch,f=e.state.shoptOptions.extglob;if(vt(r,u,c,f)){o=!0;break}}if(o){if(s=(await Ms(e,a.body)).exitCode,a.terminator===";;")break;a.terminator===";&"?n=!0:n=!1}else n=!1}return s})}async function Va(e,t,s){let r=_e(),n=s?_e():void 0,i=it(e.outputChannels);Gs(i,1,r),n&&Gs(i,2,n);try{let a=await K(e,i,t);return{...a,stdout:rt(a.stdout,r.stream()),stderr:n?rt(a.stderr,n.stream()):a.stderr}}catch(a){await K(e,i,()=>te(e,a));let o=r.stream(),l=n?.stream()??S();if(a instanceof It)return{stdout:o,stderr:l,exitCode:1};if(a instanceof q)return{stdout:o,stderr:l,exitCode:a.exitCode};if(a instanceof ke)return{stdout:o,stderr:l,exitCode:a.exitCode};throw await Y(e,{stdout:o,stderr:l,exitCode:1},!1),a}}async function Ki(e,t,s){let r=t.timed?performance.now():0,n=S(),i=U(),a=0,o=[],l=t.commands.length>1,u=e.state.lastArg;for(let d=0;d<t.commands.length;d++){let p=t.commands[d],m=d===t.commands.length-1,h=d===0,b=t.pipeStderr?.[d]??!1;l&&(e.state.lastArg=W(""),h||(e.state.groupStdin=void 0));let E=l&&(!m||!e.state.shoptOptions.lastpipe),$=E?new Map(e.state.env):null,y;try{if(m){let v=()=>s(p,n);y=E?await K(e,it(e.outputChannels),v):await v()}else y=await Va(e,()=>s(p,n),b)}catch(v){if(await te(e,v),v instanceof It)y={stdout:S(),stderr:S(),exitCode:1};else if(v instanceof q&&t.commands.length>1)y={stdout:S(),stderr:S(),exitCode:v.exitCode};else if(v instanceof ke&&t.commands.length>1)y={stdout:S(),stderr:S(),exitCode:v.exitCode};else throw $&&(e.state.env=$),v}if($&&(e.state.env=$),e.signal?.aborted===!0&&y.exitCode===new pe(e.signal.reason).exitCode)throw await Y(e,y,!1),new pe(e.signal.reason);if(o.push(y.exitCode),y.exitCode!==0&&(a=y.exitCode),m)i=y;else if(b)n=rt(y.stderr,y.stdout),i={stdout:S(),stderr:S(),exitCode:y.exitCode};else{let v=y.stdout;await Y(e,y,!0,[2]),n=v,i={stdout:S(),stderr:S(),exitCode:y.exitCode}}}e.state.options.pipefail&&a!==0&&(i={...i,exitCode:a}),t.negated&&(i={...i,exitCode:i.exitCode===0?1:0});let c=i.exitCode;if(i=await Y(e,i),i.exitCode!==c&&o.length>0&&(o[o.length-1]=i.exitCode),t.commands.length>1||t.commands.length===1&&t.commands[0].type==="SimpleCommand"){for(let d of e.state.env.keys())d.startsWith("PIPESTATUS_")&&e.state.env.delete(d);for(let d=0;d<o.length;d++)g(e.state.env,`PIPESTATUS_${d}`,String(o[d]));g(e.state.env,"PIPESTATUS__length",String(o.length))}if(t.timed){let p=(performance.now()-r)/1e3,m=Math.floor(p/60),h=p%60,b;t.timePosix?b=`real ${p.toFixed(2)}
637
649
  user 0.00
638
650
  sys 0.00
639
- `:p=`
640
- real ${`${d}m${m.toFixed(3)}s`}
651
+ `:b=`
652
+ real ${`${m}m${h.toFixed(3)}s`}
641
653
  user 0m0.000s
642
654
  sys 0m0.000s
643
- `,i={...i,stderr:O(i.stderr,C(p))}}return l&&!e.state.shoptOptions.lastpipe&&(e.state.lastArg=u),i}async function hi(e,t){let s=new Map,r="";for(let n of t.assignments){let i=n.name;if(n.array){let f=await qo(e,t,i,n.array,n.append,s);if(f.error)return{continueToNext:!1,xtraceOutput:r,tempAssignments:s,error:f.error};if(r+=f.xtraceOutput,f.continueToNext)continue}let o=n.value?await tt(e,n.value):F,a=n.value?j(o):"";if(a.length>e.limits.maxStringLength&&Ne(`word expansion: string length limit exceeded (${e.limits.maxStringLength} bytes)`,"iterations"),i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[\]$/))return{continueToNext:!1,xtraceOutput:r,tempAssignments:s,error:k(`bash: ${i}: bad array subscript
644
- `)};let u=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(u){let f=await Qo(e,t,u[1],u[2],a,n.append,s);if(f.error)return{continueToNext:!1,xtraceOutput:r,tempAssignments:s,error:f.error};if(f.continueToNext)continue}let c=await ea(e,t,i,a,n.append,s,o);if(c.error)return{continueToNext:!1,xtraceOutput:r,tempAssignments:s,error:c.error};r+=c.xtraceOutput,c.continueToNext}return{continueToNext:!1,xtraceOutput:r,tempAssignments:s}}async function qo(e,t,s,r,n,i){let o="";if(/\[.+\]$/.test(s))return{continueToNext:!1,xtraceOutput:"",error:k(`bash: ${s}: cannot assign list to array member
645
- `)};if(ye(e,s)){let c=Fr(e,s);if(c===void 0||c==="")throw new Y(1,w(),w());let f=De(e,s);if(f&&/^[a-zA-Z_][a-zA-Z0-9_]*\[@\]$/.test(f))return{continueToNext:!1,xtraceOutput:"",error:k(`bash: ${s}: cannot assign list to array member
646
- `)}}if(Ze(e,s)){if(t.name)return o+=`bash: ${s}: readonly variable
647
- `,{continueToNext:!0,xtraceOutput:o};let c=ae(e,s);if(c)return{continueToNext:!1,xtraceOutput:"",error:c}}let a=e.state.associativeArrays?.has(s),l=Zo(r),u=()=>{let c=`${s}_`;for(let f of e.state.env.keys())f.startsWith(c)&&!f.includes("__")&&e.state.env.delete(f);e.state.env.delete(s)};if(a&&l?await Xo(e,t,s,r,n,u,c=>{o+=c}):l?await Yo(e,s,r,n,u):await Ko(e,s,r,n,u),t.name){i.set(s,e.state.env.get(s));let f=`(${r.map(h=>Mt(h)).join(" ")})`;g(e.state.env,s,f)}return{continueToNext:!0,xtraceOutput:o}}function Zo(e){return e.some(t=>{if(t.parts.length>=2){let s=t.parts[0],r=t.parts[1];if(s.type!=="Glob"||!s.pattern.startsWith("["))return!1;if(s.pattern==="["&&(r.type==="DoubleQuoted"||r.type==="SingleQuoted")){if(t.parts.length<3)return!1;let n=t.parts[2];return n.type!=="Literal"?!1:n.value.startsWith("]=")||n.value.startsWith("]+=")}return r.type!=="Literal"?!1:r.value.startsWith("]")?r.value.startsWith("]=")||r.value.startsWith("]+="):s.pattern.endsWith("]")?r.value.startsWith("=")||r.value.startsWith("+="):!1}return!1})}async function Xo(e,t,s,r,n,i,o){let a=[];for(let l of r){let u=ws(l);if(u){let{key:c,valueParts:f,append:h}=u,d;f.length>0?d=await V(e,{type:"Word",parts:f}):d="",d=J(e,d),a.push({type:"keyed",key:c,value:d,append:h})}else{let c=await V(e,l);a.push({type:"invalid",expandedValue:c})}}n||i();for(let l of a)if(l.type==="keyed")if(l.append){let u=T(e.state.env,`${s}_${l.key}`,"");g(e.state.env,`${s}_${l.key}`,u+l.value)}else g(e.state.env,`${s}_${l.key}`,l.value);else{let u=t.line??e.state.currentLine??1;o(`bash: line ${u}: ${s}: ${l.expandedValue}: must use subscript when assigning associative array
648
- `)}}async function Yo(e,t,s,r,n){let i=[];for(let a of s){let l=ws(a);if(l){let{key:u,valueParts:c,append:f}=l,h;c.length>0?h=await V(e,{type:"Word",parts:c}):h="",h=J(e,h),i.push({type:"keyed",indexExpr:u,value:h,append:f})}else{let u=await Ie(e,a);i.push({type:"non-keyed",values:u.values})}}r||n();let o=0;for(let a of i)if(a.type==="keyed"){let l;try{let u=new Z,c=ne(u,a.indexExpr);l=await K(e,c.expression,!1)}catch{if(/^-?\d+$/.test(a.indexExpr))l=Number.parseInt(a.indexExpr,10);else{let u=T(e.state.env,a.indexExpr);l=u?Number.parseInt(u,10):0,Number.isNaN(l)&&(l=0)}}if(a.append){let u=T(e.state.env,`${t}_${l}`,"");g(e.state.env,`${t}_${l}`,u+a.value)}else g(e.state.env,`${t}_${l}`,a.value);o=l+1}else for(let l of a.values)g(e.state.env,`${t}_${o++}`,l)}async function Ko(e,t,s,r,n){let i=[];for(let a of s){let l=await Ie(e,a);i.push(...l.values)}let o=0;if(r){let a=Ce(e,t);if(a.length>0)o=Math.max(...a.map(([u])=>typeof u=="number"?u:0))+1;else{let l=e.state.env.get(t);l!==void 0&&(e.state.env.set(`${t}_0`,l),e.state.env.delete(t),o=1)}}else n();for(let a=0;a<i.length;a++)g(e.state.env,`${t}_${o+a}`,i[a]);r||g(e.state.env,`${t}__length`,String(i.length))}async function Qo(e,t,s,r,n,i,o){let a=s;if(ye(e,s)){let f=De(e,s);if(f&&f!==s){if(f.includes("["))return{continueToNext:!1,xtraceOutput:"",error:k(`bash: \`${f}': not a valid identifier
649
- `)};a=f}}if(Ze(e,a)){if(t.name)return{continueToNext:!0,xtraceOutput:""};let f=ae(e,a);if(f)return{continueToNext:!1,xtraceOutput:"",error:f}}let l=e.state.associativeArrays?.has(a),u;if(l)u=await pi(e,a,r);else{let f=await Jo(e,a,r);if(f.error)return{continueToNext:!1,xtraceOutput:"",error:f.error};u=`${a}_${f.index}`}let c=i?T(e.state.env,u)+n:n;if(t.name)o.set(u,e.state.env.get(u)),g(e.state.env,u,c);else{let f=at(e,a);if(f!==void 0&&f===e.state.callDepth&&e.state.localScopes.length>0){let h=e.state.localScopes[e.state.localScopes.length-1];h.has(u)||h.set(u,e.state.env.get(u))}g(e.state.env,u,c)}return{continueToNext:!0,xtraceOutput:""}}async function pi(e,t,s){let r;if(s.startsWith("'")&&s.endsWith("'"))r=s.slice(1,-1);else if(s.startsWith('"')&&s.endsWith('"')){let n=s.slice(1,-1),o=new Z().parseWordFromString(n,!0,!1);r=await V(e,o)}else if(s.includes("$")){let i=new Z().parseWordFromString(s,!1,!1);r=await V(e,i)}else r=s;return`${t}_${r}`}async function Jo(e,t,s){let r=s;s.startsWith('"')&&s.endsWith('"')&&s.length>=2&&(r=s.slice(1,-1));let n;if(/^-?\d+$/.test(r))n=Number.parseInt(r,10);else{try{let i=new Z,o=ne(i,r);n=await K(e,o.expression,!1)}catch(i){if(i instanceof qe){let l=`bash: line ${e.state.currentLine}: ${s}: ${i.message}
650
- `;if(i.fatal)throw new Y(1,w(),C(l));return{index:0,error:k(l)}}let o=T(e.state.env,s);n=o?Number.parseInt(o,10):0}Number.isNaN(n)&&(n=0)}if(n<0){let i=Ce(e,t);if(i.length===0){let a=e.state.currentLine;return{index:0,error:k(`bash: line ${a}: ${t}[${s}]: bad array subscript
651
- `)}}if(n=Math.max(...i.map(([a])=>typeof a=="number"?a:0))+1+n,n<0){let a=e.state.currentLine;return{index:0,error:k(`bash: line ${a}: ${t}[${s}]: bad array subscript
652
- `)}}}return{index:n}}async function ea(e,t,s,r,n,i,o){let a="",l=s,u=null;if(ye(e,s)){let p=Lr(e,s,r);if(p===void 0)return{continueToNext:!1,xtraceOutput:"",error:k(`bash: ${s}: circular name reference
653
- `)};if(p===null)return{continueToNext:!0,xtraceOutput:""};l=p;let v=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);v&&(u={arrayName:v[1],subscriptExpr:v[2]},l=v[1])}if(Ze(e,l)){if(t.name)return a+=`bash: ${l}: readonly variable
654
- `,{continueToNext:!0,xtraceOutput:a};let p=ae(e,l);if(p)return{continueToNext:!1,xtraceOutput:"",error:p}}let c,f=!!o&&!n&&!u;if($t(e,l)){f=!1;try{let p=new Z;if(n){let y=`(${T(e.state.env,l,"0")}) + (${r})`,S=ne(p,y);c=String(await K(e,S.expression))}else{let v=ne(p,r);c=String(await K(e,v.expression))}}catch{c="0"}}else{let{isArray:p}=await import("./chunks/expansion-TBT2U5OQ.js"),v=p(e,l);v&&(f=!1);let y=v?`${l}_0`:l;c=n?T(e.state.env,y)+r:r}let h=ut(e,l,c);h!==c&&(f=!1),c=h,a+=await fi(e,l,c);let d=l;if(u)d=await ta(e,u);else{let{isArray:p}=await import("./chunks/expansion-TBT2U5OQ.js");p(e,l)&&(d=`${l}_0`,f=!1)}let m=f?()=>e.state.env.set(d,o):()=>g(e.state.env,d,c);return t.name?(i.set(d,e.state.env.get(d)),m()):(m(),e.state.options.allexport&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(l)),e.state.tempEnvBindings?.some(p=>p.has(l))&&(e.state.mutatedTempEnvVars=e.state.mutatedTempEnvVars||new Set,e.state.mutatedTempEnvVars.add(l))),{continueToNext:!1,xtraceOutput:a}}async function ta(e,t){let{arrayName:s,subscriptExpr:r}=t;if(e.state.associativeArrays?.has(s))return pi(e,s,r);let i;if(/^-?\d+$/.test(r))i=Number.parseInt(r,10);else{try{let o=new Z,a=ne(o,r);i=await K(e,a.expression,!1)}catch{let o=T(e.state.env,r);i=o?Number.parseInt(o,10):0}Number.isNaN(i)&&(i=0)}if(i<0){let o=Ce(e,s);o.length>0&&(i=Math.max(...o.map(l=>l[0]))+1+i)}return`${s}_${i}`}async function mi(e,t,s,r){let n=await Me(e,t.redirections);if(n)return n;let i=new Map(e.state.env),o=e.state.cwd,a={...e.state.options},l=new Map(e.state.functions),u=e.state.localScopes,c=e.state.localVarStack,f=e.state.localVarDepth,h=e.state.fullyUnsetLocals;if(e.state.localScopes=u.map(P=>new Map(P)),c){e.state.localVarStack=new Map;for(let[P,N]of c.entries())e.state.localVarStack.set(P,N.map(x=>({...x})))}f&&(e.state.localVarDepth=new Map(f)),h&&(e.state.fullyUnsetLocals=new Map(h));let d=e.state.loopDepth,m=e.state.parentHasLoopContext;e.state.parentHasLoopContext=d>0,e.state.loopDepth=0;let p=e.state.lastArg,v=e.state.bashPid;e.state.bashPid=e.state.nextVirtualPid++;let y=e.state.groupStdin,S=await H(s);S.length>0&&(e.state.groupStdin=se(S));let A=w(),b=w(),_=0,M=()=>{e.state.env=i,e.state.cwd=o,e.state.options=a,e.state.functions=l,e.state.localScopes=u,e.state.localVarStack=c,e.state.localVarDepth=f,e.state.fullyUnsetLocals=h,e.state.loopDepth=d,e.state.parentHasLoopContext=m,e.state.groupStdin=y,e.state.bashPid=v,e.state.lastArg=p};try{for(let P of t.body){let N=await r(P);A=O(A,N.stdout),b=O(b,N.stderr),_=N.exitCode}}catch(P){if(M(),P instanceof de)throw P;if(P instanceof Ve){A=O(A,P.stdout),b=O(b,P.stderr);let x=R(A,b,0);return Q(e,x,t.redirections)}if(P instanceof Ee||P instanceof Se){A=O(A,P.stdout),b=O(b,P.stderr);let x=R(A,b,0);return Q(e,x,t.redirections)}if(P instanceof Y){A=O(A,P.stdout),b=O(b,P.stderr);let x=R(A,b,P.exitCode);return Q(e,x,t.redirections)}if(P instanceof me){A=O(A,P.stdout),b=O(b,P.stderr);let x=R(A,b,P.exitCode);return Q(e,x,t.redirections)}if(P instanceof Ae){let x=R(O(A,P.stdout),O(b,P.stderr),P.exitCode);return Q(e,x,t.redirections)}let N=R(A,O(b,C(`${Fe(P)}
655
- `)),1);return Q(e,N,t.redirections)}M();let $=R(A,b,_);return Q(e,$,t.redirections)}async function yi(e,t,s,r){let n=w(),i=w(),o=0,a=await ss(e,t.redirections);if(a)return a;let l=await H(s),u=se(l),c=!1;for(let d of t.redirections)if((d.operator==="<<"||d.operator==="<<-")&&d.target.type==="HereDoc"){let m=d.target,p=await V(e,m.content);m.stripTabs&&(p=p.split(`
656
- `).map(y=>y.replace(/^\t+/,"")).join(`
657
- `));let v=d.fd??0;v!==0?(e.state.fileDescriptors||(e.state.fileDescriptors=new Map),e.state.fileDescriptors.set(v,p)):(u=C(p),c=!0)}else if(d.operator==="<<<"&&d.target.type==="Word")u=C(`${await V(e,d.target)}
658
- `),c=!0;else if(d.operator==="<"&&d.target.type==="Word")try{let m=await V(e,d.target),p=e.fs.resolvePath(e.state.cwd,m);u=await e.fs.readFile(p),c=!0}catch{let m=await V(e,d.target);return k(`bash: ${m}: No such file or directory
659
- `)}let f=e.state.groupStdin;(c||l.length>0)&&(e.state.groupStdin=u);try{for(let d of t.body){let m=await r(d);n=O(n,m.stdout),i=O(i,m.stderr),o=m.exitCode}}catch(d){if(e.state.groupStdin=f,d instanceof de)throw d;if(It(d)||d instanceof Ae||d instanceof Y)throw d.prependOutput(n,i),d;return R(n,O(i,C(`${Fe(d)}
660
- `)),1)}e.state.groupStdin=f;let h=R(n,i,o);return Q(e,h,t.redirections)}async function gi(e,t,s,r,n){let i;try{i=await e.fs.readFileText(t)}catch{return k(`bash: ${t}: No such file or directory
661
- `,127)}if(i.startsWith("#!")){let y=i.indexOf(`
662
- `);y!==-1&&(i=i.slice(y+1))}let o=new Map(e.state.env),a=e.state.cwd,l={...e.state.options},u=e.state.loopDepth,c=e.state.parentHasLoopContext,f=e.state.lastArg,h=e.state.bashPid,d=e.state.groupStdin,m=e.state.currentSource;e.state.parentHasLoopContext=u>0,e.state.loopDepth=0,e.state.bashPid=e.state.nextVirtualPid++;let p=await H(r);p.length>0&&(e.state.groupStdin=se(p)),e.state.currentSource=t,g(e.state.env,"0",t),g(e.state.env,"#",String(s.length)),g(e.state.env,"@",s.join(" ")),g(e.state.env,"*",s.join(" "));for(let y=0;y<s.length&&y<9;y++)g(e.state.env,String(y+1),s[y]);for(let y=s.length+1;y<=9;y++)e.state.env.delete(String(y));let v=()=>{e.state.env=o,e.state.cwd=a,e.state.options=l,e.state.loopDepth=u,e.state.parentHasLoopContext=c,e.state.lastArg=f,e.state.bashPid=h,e.state.groupStdin=d,e.state.currentSource=m};try{let S=new Z().parse(i),A=await n(S);return v(),A}catch(y){if(v(),y instanceof Y||y instanceof de)throw y;if(y.name==="ParseException")return k(`bash: ${t}: ${y.message}
663
- `);throw y}}function sa(e,t){for(let s of t.parts)switch(s.type){case"Bytes":case"Literal":case"SingleQuoted":case"Escaped":continue;case"DoubleQuoted":for(let r of s.parts)switch(r.type){case"Bytes":case"Literal":case"SingleQuoted":case"Escaped":continue;case"ParameterExpansion":if(r.operation||r.parameter==="@"||r.parameter==="*"||r.parameter.endsWith("[@]")||r.parameter.endsWith("[*]"))return!1;if(ye(e,r.parameter)){let n=De(e,r.parameter);if(n&&(n.endsWith("[@]")||n.endsWith("[*]")))return!1}continue;case"CommandSubstitution":continue;default:return!1}continue;case"ParameterExpansion":return!1;default:return!1}return t.parts.length>0}var _t=class{ctx;constructor(t,s){this.ctx={state:s,fs:t.fs,commands:t.commands,limits:t.limits,execFn:t.exec,executeScript:this.executeScript.bind(this),executeStatement:this.executeStatement.bind(this),executeCommand:this.executeCommand.bind(this),fetch:t.fetch,sleep:t.sleep,trace:t.trace,coverage:t.coverage}}buildExportedEnv(){let t=this.ctx.state.exportedVars,s=this.ctx.state.tempExportedVars,r=new Set;if(t)for(let i of t)r.add(i);if(s)for(let i of s)r.add(i);if(r.size===0)return Object.create(null);let n=Object.create(null);for(let i of r)this.ctx.state.env.has(i)&&(n[i]=T(this.ctx.state.env,i));return n}async executeScript(t){let s=w(),r=w(),n=0;for(let i of t.statements)try{let o=await this.executeStatement(i);s=O(s,o.stdout),r=O(r,o.stderr),n=o.exitCode,this.ctx.state.lastExitCode=n,g(this.ctx.state.env,"?",String(n))}catch(o){if(o instanceof Y)throw o.prependOutput(s,r),o;if(o instanceof ke)return s=O(s,o.stdout),r=O(r,o.stderr),n=o.exitCode,this.ctx.state.lastExitCode=n,g(this.ctx.state.env,"?",String(n)),{stdout:s,stderr:r,exitCode:n,env:Be(this.ctx.state.env)};if(o instanceof de)throw o;if(o instanceof Ae)return s=O(s,o.stdout),r=O(r,o.stderr),n=o.exitCode,this.ctx.state.lastExitCode=n,g(this.ctx.state.env,"?",String(n)),{stdout:s,stderr:r,exitCode:n,env:Be(this.ctx.state.env)};if(o instanceof _r)return s=O(s,o.stdout),r=O(r,o.stderr),n=1,this.ctx.state.lastExitCode=n,g(this.ctx.state.env,"?",String(n)),{stdout:s,stderr:r,exitCode:n,env:Be(this.ctx.state.env)};if(o instanceof Ot)return s=O(s,o.stdout),r=O(r,o.stderr),n=1,this.ctx.state.lastExitCode=n,g(this.ctx.state.env,"?",String(n)),{stdout:s,stderr:r,exitCode:n,env:Be(this.ctx.state.env)};if(o instanceof qe){s=O(s,o.stdout),r=O(r,o.stderr),n=1,this.ctx.state.lastExitCode=n,g(this.ctx.state.env,"?",String(n));continue}if(o instanceof Cr){s=O(s,o.stdout),r=O(r,o.stderr),n=1,this.ctx.state.lastExitCode=n,g(this.ctx.state.env,"?",String(n));continue}if(o instanceof Ee||o instanceof Se){if(this.ctx.state.loopDepth>0)throw o.prependOutput(s,r),o;s=O(s,o.stdout),r=O(r,o.stderr);continue}throw o instanceof me&&o.prependOutput(s,r),o}return{stdout:s,stderr:r,exitCode:n,env:Be(this.ctx.state.env)}}async executeUserScript(t,s,r=w()){return gi(this.ctx,t,Je(s),r,n=>this.executeScript(n))}async executeStatement(t){if(this.ctx.state.commandCount++,this.ctx.state.commandCount>this.ctx.limits.maxCommandCount&&Ne(`too many commands executed (>${this.ctx.limits.maxCommandCount}), increase executionLimits.maxCommandCount`,"commands"),t.deferredError)throw new Rt(t.deferredError.message,t.line??1,1);if(this.ctx.state.options.noexec)return U();this.ctx.state.errexitSafe=!1;let s=w(),r=w();this.ctx.state.options.verbose&&!this.ctx.state.suppressVerbose&&t.sourceText&&(r=O(r,C(`${t.sourceText}
664
- `)));let n=0,i=-1,o=!1;for(let u=0;u<t.pipelines.length;u++){let c=t.pipelines[u],f=u>0?t.operators[u-1]:null;if(f==="&&"&&n!==0||f==="||"&&n===0)continue;let h=await this.executePipeline(c);s=O(s,h.stdout),r=O(r,h.stderr),n=h.exitCode,i=u,o=c.negated,this.ctx.state.lastExitCode=n,g(this.ctx.state.env,"?",String(n))}let a=i<t.pipelines.length-1,l=this.ctx.state.errexitSafe;if(this.ctx.state.errexitSafe=a||o||l,this.ctx.state.options.errexit&&n!==0&&i===t.pipelines.length-1&&!o&&!this.ctx.state.inCondition&&!l)throw new Ae(n,s,r);return{stdout:s,stderr:r,exitCode:n}}async executePipeline(t){return di(this.ctx,t,(s,r)=>this.executeCommand(s,r))}async executeCommand(t,s){switch(this.ctx.coverage?.hit(`bash:cmd:${t.type}`),t.type){case"SimpleCommand":return this.executeSimpleCommand(t,s);case"If":return ti(this.ctx,t);case"For":return si(this.ctx,t);case"CStyleFor":return ri(this.ctx,t);case"While":return ni(this.ctx,t,s);case"Until":return ii(this.ctx,t);case"Case":return oi(this.ctx,t);case"Subshell":return this.executeSubshell(t,s);case"Group":return this.executeGroup(t,s);case"FunctionDef":return $n(this.ctx,t);case"ArithmeticCommand":return this.executeArithmeticCommand(t);case"ConditionalCommand":return this.executeConditionalCommand(t);default:return U()}}async executeSimpleCommand(t,s){try{return await this.executeSimpleCommandInner(t,s)}catch(r){if(r instanceof Dt)return{stdout:w(),stderr:r.stderr,exitCode:1};throw r}}async executeSimpleCommandInner(t,s){if(t.line!==void 0&&(this.ctx.state.currentLine=t.line),this.ctx.state.shoptOptions.expand_aliases&&t.name){let $=t,P=100;for(;P>0;){let N=this.expandAlias($);if(N===$)break;$=N,P--}this.aliasExpansionStack.clear(),$!==t&&(t=$)}this.ctx.state.expansionStderr="";let r=await hi(this.ctx,t);if(r.error)return r.error;let n=r.tempAssignments,i=r.xtraceOutput;if(!t.name){if(t.redirections.length>0){let P=await Me(this.ctx,t.redirections);if(P)return P;let N={stdout:w(),stderr:C(i),exitCode:0};return Q(this.ctx,N,t.redirections)}this.ctx.state.lastArg=B("");let $=(this.ctx.state.expansionStderr||"")+i;return this.ctx.state.expansionStderr="",{stdout:w(),stderr:C($),exitCode:this.ctx.state.lastExitCode}}let o=t.name&&vr(t.name,["local","declare","typeset","export","readonly"]),a=Array.from(n.keys());if(a.length>0&&!o){this.ctx.state.tempExportedVars=this.ctx.state.tempExportedVars||new Set;for(let $ of a)this.ctx.state.tempExportedVars.add($)}let l=await ss(this.ctx,t.redirections);if(l){for(let[$,P]of n)P===void 0?this.ctx.state.env.delete($):this.ctx.state.env.set($,P);return l}let u=-1,c=t.redirections.some($=>{if($.operator==="<<"||$.operator==="<<-"||$.operator==="<<<")return!0;let P=$.fd??0;return($.operator==="<"||$.operator==="<&")&&P===0}),f=null,h=F;c?h=await H(s):f=s;for(let $ of t.redirections){if(($.operator==="<<"||$.operator==="<<-")&&$.target.type==="HereDoc"){let P=$.target,N=$.fd??0;if(N===0&&!P.stripTabs)h=await tt(this.ctx,P.content);else{let x=await V(this.ctx,P.content);P.stripTabs&&(x=x.split(`
665
- `).map(z=>z.replace(/^\t+/,"")).join(`
666
- `)),N!==0?(this.ctx.state.fileDescriptors||(this.ctx.state.fileDescriptors=new Map),this.ctx.state.fileDescriptors.set(N,x)):h=B(x)}continue}if($.operator==="<<<"&&$.target.type==="Word"){let P=await tt(this.ctx,$.target);h=Ar(P,B(`
667
- `));continue}if($.operator==="<"&&$.target.type==="Word")try{let P=await V(this.ctx,$.target),N=this.ctx.fs.resolvePath(this.ctx.state.cwd,P);h=await H(await this.ctx.fs.readFile(N))}catch{let P=await V(this.ctx,$.target);for(let[N,x]of n)x===void 0?this.ctx.state.env.delete(N):this.ctx.state.env.set(N,x);return k(`bash: ${P}: No such file or directory
668
- `)}if($.operator==="<&"&&$.target.type==="Word"){let P=await V(this.ctx,$.target),N=Number.parseInt(P,10);if(!Number.isNaN(N)&&this.ctx.state.fileDescriptors){let x=this.ctx.state.fileDescriptors.get(N);if(x!==void 0)if(x.startsWith("__rw__:")){let z=ai(x);z&&(h=B(z.content.slice(z.position)),u=N)}else x.startsWith("__file__:")||x.startsWith("__file_append__:")||(h=B(x))}}}let d=await V(this.ctx,t.name),m=[],p=[];if(vr(t.name,["local","declare","typeset","export","readonly"])&&(d==="local"||d==="declare"||d==="typeset"||d==="export"||d==="readonly"))for(let $ of t.args){let P=await on(this.ctx,$);if(P)m.push(B(P)),p.push(!0);else{let N=await an(this.ctx,$);if(N!==null)m.push(B(N)),p.push(!0);else{let x=await Ie(this.ctx,$);for(let z of x.values)m.push(B(z)),p.push(x.quoted)}}}else for(let $ of t.args)if(sa(this.ctx,$))m.push(await tt(this.ctx,$)),p.push(!0);else{let P=await Ie(this.ctx,$);for(let N of P.values)m.push(B(N)),p.push(P.quoted)}if(!d){if(t.name.parts.every(P=>P.type==="CommandSubstitution"||P.type==="ParameterExpansion"||P.type==="ArithmeticExpansion")){if(m.length>0){let P=j(m.shift());return p.shift(),await this.runCommand(P,m,p,f??se(h),!1,!1,u)}return{stdout:w(),stderr:w(),exitCode:this.ctx.state.lastExitCode}}return k(`bash: : command not found
669
- `,127)}if(d==="exec"&&(m.length===0||j(m[0])==="--")){for(let $ of t.redirections){if($.target.type==="HereDoc"||$.fdVariable)continue;let P=await V(this.ctx,$.target),N=$.fd??($.operator==="<"||$.operator==="<>"?0:1);switch(this.ctx.state.fileDescriptors||(this.ctx.state.fileDescriptors=new Map),$.operator){case">":case">|":{let x=this.ctx.fs.resolvePath(this.ctx.state.cwd,P);await this.ctx.fs.writeFile(x,"","utf8"),this.ctx.state.fileDescriptors.set(N,`__file__:${x}`);break}case">>":{let x=this.ctx.fs.resolvePath(this.ctx.state.cwd,P);this.ctx.state.fileDescriptors.set(N,`__file_append__:${x}`);break}case"<":{let x=this.ctx.fs.resolvePath(this.ctx.state.cwd,P);try{let z=await this.ctx.fs.readFileText(x);this.ctx.state.fileDescriptors.set(N,z)}catch{return k(`bash: ${P}: No such file or directory
670
- `)}break}case"<>":{let x=this.ctx.fs.resolvePath(this.ctx.state.cwd,P);try{let z=await this.ctx.fs.readFileText(x);this.ctx.state.fileDescriptors.set(N,`__rw__:${x.length}:${x}:0:${z}`)}catch{await this.ctx.fs.writeFile(x,"","utf8"),this.ctx.state.fileDescriptors.set(N,`__rw__:${x.length}:${x}:0:`)}break}case">&":{if(P==="-")this.ctx.state.fileDescriptors.delete(N);else if(P.endsWith("-")){let x=P.slice(0,-1),z=Number.parseInt(x,10);if(!Number.isNaN(z)){let I=this.ctx.state.fileDescriptors.get(z);I!==void 0?this.ctx.state.fileDescriptors.set(N,I):this.ctx.state.fileDescriptors.set(N,`__dupout__:${z}`),this.ctx.state.fileDescriptors.delete(z)}}else{let x=Number.parseInt(P,10);Number.isNaN(x)||this.ctx.state.fileDescriptors.set(N,`__dupout__:${x}`)}break}case"<&":{if(P==="-")this.ctx.state.fileDescriptors.delete(N);else if(P.endsWith("-")){let x=P.slice(0,-1),z=Number.parseInt(x,10);if(!Number.isNaN(z)){let I=this.ctx.state.fileDescriptors.get(z);I!==void 0?this.ctx.state.fileDescriptors.set(N,I):this.ctx.state.fileDescriptors.set(N,`__dupin__:${z}`),this.ctx.state.fileDescriptors.delete(z)}}else{let x=Number.parseInt(P,10);Number.isNaN(x)||this.ctx.state.fileDescriptors.set(N,`__dupin__:${x}`)}break}}}for(let[$,P]of n)P===void 0?this.ctx.state.env.delete($):this.ctx.state.env.set($,P);if(this.ctx.state.tempExportedVars)for(let $ of n.keys())this.ctx.state.tempExportedVars.delete($);return U()}let y=await ui(this.ctx,d,m.map($=>j($)));n.size>0&&(this.ctx.state.tempEnvBindings=this.ctx.state.tempEnvBindings||[],this.ctx.state.tempEnvBindings.push(new Map(n)));let S,A=null;try{S=await this.runCommand(d,m,p,f??se(h),!1,!1,u)}catch($){if($ instanceof Ee||$ instanceof Se)A=$,S=U();else throw $}let b=i+y;if(b&&(S={...S,stderr:O(C(b),S.stderr)}),S=await Q(this.ctx,S,t.redirections),A)throw A;if(m.length>0){let $=j(m[m.length-1]);if((d==="declare"||d==="local"||d==="typeset")&&/^[a-zA-Z_][a-zA-Z0-9_]*=\(/.test($)){let P=$.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\(/);P&&($=P[1])}this.ctx.state.lastArg=B($)}else this.ctx.state.lastArg=B(d);let _=En(d)&&d!=="unset"&&d!=="eval";if(!this.ctx.state.options.posix||!_)for(let[$,P]of n)this.ctx.state.fullyUnsetLocals?.has($)||(P===void 0?this.ctx.state.env.delete($):this.ctx.state.env.set($,P));if(this.ctx.state.tempExportedVars)for(let $ of n.keys())this.ctx.state.tempExportedVars.delete($);return n.size>0&&this.ctx.state.tempEnvBindings&&this.ctx.state.tempEnvBindings.pop(),this.ctx.state.expansionStderr&&(S={...S,stderr:O(C(this.ctx.state.expansionStderr),S.stderr)},this.ctx.state.expansionStderr=""),S}async runCommand(t,s,r,n,i=!1,o=!1,a=-1){let l={ctx:this.ctx,runCommand:(c,f,h,d,m,p,v)=>this.runCommand(c,f,h,d,m,p,v),buildExportedEnv:()=>this.buildExportedEnv(),executeUserScript:(c,f,h)=>this.executeUserScript(c,f,h??w())},u=await Jn(l,t,s,r,n,i,o,a);return u!==null?u:ei(l,t,s,n,o)}aliasExpansionStack=new Set;expandAlias(t){return Cs(this.ctx.state,t,this.aliasExpansionStack)}async findCommandInPath(t){return cs(this.ctx,t)}async executeSubshell(t,s=w()){return mi(this.ctx,t,s,r=>this.executeStatement(r))}async executeGroup(t,s=w()){return yi(this.ctx,t,s,r=>this.executeStatement(r))}async executeArithmeticCommand(t){t.line!==void 0&&(this.ctx.state.currentLine=t.line);let s=await Me(this.ctx,t.redirections);if(s)return s;try{let r=await K(this.ctx,t.expression.expression),n=re(r!==0);return this.ctx.state.expansionStderr&&(n={...n,stderr:O(C(this.ctx.state.expansionStderr),n.stderr)},this.ctx.state.expansionStderr=""),Q(this.ctx,n,t.redirections)}catch(r){let n=k(`bash: arithmetic expression: ${r.message}
671
- `);return Q(this.ctx,n,t.redirections)}}async executeConditionalCommand(t){t.line!==void 0&&(this.ctx.state.currentLine=t.line);let s=await Me(this.ctx,t.redirections);if(s)return s;try{let r=await Ue(this.ctx,t.expression),n=re(r);return this.ctx.state.expansionStderr&&(n={...n,stderr:O(C(this.ctx.state.expansionStderr),n.stderr)},this.ctx.state.expansionStderr=""),Q(this.ctx,n,t.redirections)}catch(r){let n=r instanceof qe?1:2,i=k(`bash: conditional expression: ${r.message}
672
- `,n);return Q(this.ctx,i,t.redirections)}}};var we={maxCallDepth:100,maxCommandCount:1e4,maxLoopIterations:1e4,maxAwkIterations:1e4,maxSedIterations:1e4,maxJqIterations:1e4,maxSqliteTimeoutMs:5e3,maxPythonTimeoutMs:3e4,maxGlobOperations:1e5,maxStringLength:10485760,maxArrayElements:1e5,maxHeredocSize:10485760,maxSubstitutionDepth:50};function wi(e){return e?{maxCallDepth:e.maxCallDepth??we.maxCallDepth,maxCommandCount:e.maxCommandCount??we.maxCommandCount,maxLoopIterations:e.maxLoopIterations??we.maxLoopIterations,maxAwkIterations:e.maxAwkIterations??we.maxAwkIterations,maxSedIterations:e.maxSedIterations??we.maxSedIterations,maxJqIterations:e.maxJqIterations??we.maxJqIterations,maxSqliteTimeoutMs:e.maxSqliteTimeoutMs??we.maxSqliteTimeoutMs,maxPythonTimeoutMs:e.maxPythonTimeoutMs??we.maxPythonTimeoutMs,maxGlobOperations:e.maxGlobOperations??we.maxGlobOperations,maxStringLength:e.maxStringLength??we.maxStringLength,maxArrayElements:e.maxArrayElements??we.maxArrayElements,maxHeredocSize:e.maxHeredocSize??we.maxHeredocSize,maxSubstitutionDepth:e.maxSubstitutionDepth??we.maxSubstitutionDepth}:{...we}}function vi(e){try{let t=new URL(e);return{origin:t.origin,pathname:t.pathname,href:t.href}}catch{return null}}function ra(e){let t=vi(e);return t?{origin:t.origin,pathPrefix:t.pathname}:null}function na(e,t){let s=vi(e);if(!s)return!1;let r=ra(t);return!r||s.origin!==r.origin?!1:r.pathPrefix==="/"||r.pathPrefix===""?!0:s.pathname.startsWith(r.pathPrefix)}function br(e,t){return!t||t.length===0?!1:t.some(s=>na(e,s))}var ft=class extends Error{constructor(t){super(`Network access denied: URL not in allow-list: ${t}`),this.name="NetworkAccessDeniedError"}},dt=class extends Error{constructor(t){super(`Too many redirects (max: ${t})`),this.name="TooManyRedirectsError"}},ht=class extends Error{constructor(t){super(`Redirect target not in allow-list: ${t}`),this.name="RedirectNotAllowedError"}},fs=class extends Error{constructor(t,s){super(`HTTP method '${t}' not allowed. Allowed methods: ${s.join(", ")}`),this.name="MethodNotAllowedError"}},Ct=class extends Error{constructor(t){super(`Response body too large (max: ${t} bytes)`),this.name="ResponseTooLargeError"}};var ia=20,oa=3e4,aa=10485760,la=["GET","HEAD"],ca=new Set(["GET","HEAD","OPTIONS"]),ua=new Set([301,302,303,307,308]);function Er(e){let t=e.maxRedirects??ia,s=e.timeoutMs??oa,r=e.maxResponseSize??aa,n=e.dangerouslyAllowFullInternetAccess?["GET","HEAD","POST","PUT","DELETE","PATCH","OPTIONS"]:e.allowedMethods??la;function i(l){if(!e.dangerouslyAllowFullInternetAccess&&!br(l,e.allowedUrlPrefixes??[]))throw new ft(l)}function o(l){if(e.dangerouslyAllowFullInternetAccess)return;let u=l.toUpperCase();if(!n.includes(u))throw new fs(u,n)}async function a(l,u={}){let c=u.method?.toUpperCase()??"GET";i(l),o(c);let f=l,h=0,d=u.followRedirects??!0,m=u.timeoutMs!==void 0?Math.min(u.timeoutMs,s):s;for(;;){let p=new AbortController,v=setTimeout(()=>p.abort(),m);try{let y={method:c,headers:u.headers,signal:p.signal,redirect:"manual"};u.body&&!ca.has(c)&&(y.body=u.body);let S=await fetch(f,y);if(ua.has(S.status)&&d){let A=S.headers.get("location");if(!A)return await bi(S,f,r);let b=new URL(A,f).href;if(!e.dangerouslyAllowFullInternetAccess&&!br(b,e.allowedUrlPrefixes??[]))throw new ht(b);if(h++,h>t)throw new dt(t);f=b;continue}return await bi(S,f,r)}finally{clearTimeout(v)}}}return a}async function bi(e,t,s){let r=Object.create(null);if(e.headers.forEach((i,o)=>{r[o.toLowerCase()]=i}),s>0){let i=e.headers.get("content-length");if(i){let o=parseInt(i,10);if(!Number.isNaN(o)&&o>s)throw new Ct(s)}}let n;if(s>0&&e.body){let i=e.body.getReader(),o=new TextDecoder,a=[],l=0;for(;;){let{done:u,value:c}=await i.read();if(u)break;if(l+=c.byteLength,l>s)throw i.cancel(),new Ct(s);a.push(o.decode(c,{stream:!0}))}a.push(o.decode()),n=a.join("")}else n=await e.text();return{status:e.status,statusText:e.statusText,headers:r,body:n,url:t}}function Sr(){let e=[{prop:"Function",target:globalThis,violationType:"function_constructor",strategy:"throw",reason:"Function constructor allows arbitrary code execution"},{prop:"eval",target:globalThis,violationType:"eval",strategy:"throw",reason:"eval() allows arbitrary code execution"},{prop:"setTimeout",target:globalThis,violationType:"setTimeout",strategy:"throw",reason:"setTimeout with string argument allows code execution"},{prop:"setInterval",target:globalThis,violationType:"setInterval",strategy:"throw",reason:"setInterval with string argument allows code execution"},{prop:"setImmediate",target:globalThis,violationType:"setImmediate",strategy:"throw",reason:"setImmediate could be used to escape sandbox context"},{prop:"env",target:process,violationType:"process_env",strategy:"throw",reason:"process.env could leak sensitive environment variables"},{prop:"binding",target:process,violationType:"process_binding",strategy:"throw",reason:"process.binding provides access to native Node.js modules"},{prop:"_linkedBinding",target:process,violationType:"process_binding",strategy:"throw",reason:"process._linkedBinding provides access to native Node.js modules"},{prop:"dlopen",target:process,violationType:"process_dlopen",strategy:"throw",reason:"process.dlopen allows loading native addons"},{prop:"WeakRef",target:globalThis,violationType:"weak_ref",strategy:"throw",reason:"WeakRef could be used to leak references outside sandbox"},{prop:"FinalizationRegistry",target:globalThis,violationType:"finalization_registry",strategy:"throw",reason:"FinalizationRegistry could be used to leak references outside sandbox"},{prop:"Reflect",target:globalThis,violationType:"reflect",strategy:"freeze",reason:"Reflect provides introspection capabilities"},{prop:"Proxy",target:globalThis,violationType:"proxy",strategy:"throw",reason:"Proxy allows intercepting and modifying object behavior"},{prop:"WebAssembly",target:globalThis,violationType:"webassembly",strategy:"throw",reason:"WebAssembly allows executing arbitrary compiled code"},{prop:"SharedArrayBuffer",target:globalThis,violationType:"shared_array_buffer",strategy:"throw",reason:"SharedArrayBuffer could enable side-channel communication or timing attacks"},{prop:"Atomics",target:globalThis,violationType:"atomics",strategy:"throw",reason:"Atomics could enable side-channel communication or timing attacks"}];try{let t=Object.getPrototypeOf(async()=>{}).constructor;t&&t!==Function&&e.push({prop:"constructor",target:Object.getPrototypeOf(async()=>{}),violationType:"async_function_constructor",strategy:"throw",reason:"AsyncFunction constructor allows arbitrary async code execution"})}catch{}try{let t=Object.getPrototypeOf(function*(){}).constructor;t&&t!==Function&&e.push({prop:"constructor",target:Object.getPrototypeOf(function*(){}),violationType:"generator_function_constructor",strategy:"throw",reason:"GeneratorFunction constructor allows arbitrary generator code execution"})}catch{}try{let t=Object.getPrototypeOf(async function*(){}).constructor;t&&t!==Function&&t!==Object.getPrototypeOf(async()=>{}).constructor&&e.push({prop:"constructor",target:Object.getPrototypeOf(async function*(){}),violationType:"async_generator_function_constructor",strategy:"throw",reason:"AsyncGeneratorFunction constructor allows arbitrary async generator code execution"})}catch{}return e.filter(t=>{try{return t.target[t.prop]!==void 0}catch{return!1}})}var xt=typeof __BROWSER__<"u"&&__BROWSER__;function Ei(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}var Pr=null;if(!xt)try{let e="node:module",{createRequire:t}=await import(e);Pr=t(import.meta.url)("node:async_hooks").AsyncLocalStorage}catch(e){console.debug("[DefenseInDepthBox] AsyncLocalStorage not available, defense-in-depth disabled:",e instanceof Error?e.message:e)}var fa=`
673
-
674
- This is a defense-in-depth measure and indicates a bug in just-bash. Please report this at security@vercel.com`,ue=class extends Error{violation;constructor(t,s){super(t+fa),this.violation=s,this.name="SecurityViolationError"}},ve=!xt&&Pr?new Pr:null,da=1e3,$r={enabled:!0,auditMode:!1};function ha(e){return e===void 0?{...$r,enabled:!1}:typeof e=="boolean"?{...$r,enabled:e}:{...$r,...e}}var pt=class e{static instance=null;config;refCount=0;originalDescriptors=[];violations=[];activationTime=0;totalActiveTimeMs=0;constructor(t){this.config=t}static getInstance(t){return e.instance||(e.instance=new e(ha(t))),e.instance}static resetInstance(){e.instance&&(e.instance.forceDeactivate(),e.instance=null)}static isInSandboxedContext(){return ve?ve?.getStore()?.sandboxActive===!0:!1}static getCurrentExecutionId(){if(ve)return ve?.getStore()?.executionId}updateConfig(t){this.config={...this.config,...t}}activate(){if(xt||!this.config.enabled){let s=Ei();return{run:r=>r(),deactivate:()=>{},executionId:s}}this.refCount++,this.refCount===1&&(this.applyPatches(),this.activationTime=Date.now());let t=Ei();return{run:s=>ve.run({sandboxActive:!0,executionId:t},s),deactivate:()=>{this.refCount--,this.refCount===0&&(this.restorePatches(),this.totalActiveTimeMs+=Date.now()-this.activationTime),this.refCount<0&&(this.refCount=0)},executionId:t}}forceDeactivate(){this.refCount>0&&(this.restorePatches(),this.totalActiveTimeMs+=Date.now()-this.activationTime),this.refCount=0}isActive(){return this.refCount>0}getStats(){return{violationsBlocked:this.violations.length,violations:[...this.violations],activeTimeMs:this.totalActiveTimeMs+(this.refCount>0?Date.now()-this.activationTime:0),refCount:this.refCount}}clearViolations(){this.violations=[]}getPathForTarget(t,s){return t===globalThis?`globalThis.${s}`:t===process?`process.${s}`:t===Error?`Error.${s}`:t===Function.prototype?`Function.prototype.${s}`:t===Object.prototype?`Object.prototype.${s}`:`<object>.${s}`}shouldBlock(){return xt||this.config.auditMode||!ve?!1:ve?.getStore()?.sandboxActive===!0}recordViolation(t,s,r){let n={timestamp:Date.now(),type:t,message:r,path:s,stack:new Error().stack,executionId:ve?.getStore()?.executionId};if(this.violations.length<da&&this.violations.push(n),this.config.onViolation)try{this.config.onViolation(n)}catch(i){console.debug("[DefenseInDepthBox] onViolation callback threw:",i instanceof Error?i.message:i)}return n}createBlockingProxy(t,s,r){let n=this;return new Proxy(t,{apply(i,o,a){if(n.shouldBlock()){let l=`${s} is blocked during script execution`,u=n.recordViolation(r,s,l);throw new ue(l,u)}return n.config.auditMode&&ve?.getStore()?.sandboxActive===!0&&n.recordViolation(r,s,`${s} called (audit mode)`),Reflect.apply(i,o,a)},construct(i,o,a){if(n.shouldBlock()){let l=`${s} constructor is blocked during script execution`,u=n.recordViolation(r,s,l);throw new ue(l,u)}return n.config.auditMode&&ve?.getStore()?.sandboxActive===!0&&n.recordViolation(r,s,`${s} constructor called (audit mode)`),Reflect.construct(i,o,a)}})}createBlockingObjectProxy(t,s,r){let n=this;return new Proxy(t,{get(i,o,a){if(n.shouldBlock()){let l=`${s}.${String(o)}`,u=`${l} is blocked during script execution`,c=n.recordViolation(r,l,u);throw new ue(u,c)}if(n.config.auditMode&&ve?.getStore()?.sandboxActive===!0){let l=`${s}.${String(o)}`;n.recordViolation(r,l,`${l} accessed (audit mode)`)}return Reflect.get(i,o,a)},set(i,o,a,l){if(n.shouldBlock()){let u=`${s}.${String(o)}`,c=`${u} modification is blocked during script execution`,f=n.recordViolation(r,u,c);throw new ue(c,f)}return Reflect.set(i,o,a,l)},ownKeys(i){if(n.shouldBlock()){let o=`${s} enumeration is blocked during script execution`,a=n.recordViolation(r,s,o);throw new ue(o,a)}return Reflect.ownKeys(i)},getOwnPropertyDescriptor(i,o){if(n.shouldBlock()){let a=`${s}.${String(o)}`,l=`${a} descriptor access is blocked during script execution`,u=n.recordViolation(r,a,l);throw new ue(l,u)}return Reflect.getOwnPropertyDescriptor(i,o)},has(i,o){if(n.shouldBlock()){let a=`${s}.${String(o)}`,l=`${a} existence check is blocked during script execution`,u=n.recordViolation(r,a,l);throw new ue(l,u)}return Reflect.has(i,o)}})}applyPatches(){let t=Sr();for(let s of t)this.applyPatch(s);this.protectConstructorChain(),this.protectErrorPrepareStackTrace(),this.protectModuleLoad(),this.protectProcessMainModule()}protectConstructorChain(){this.patchPrototypeConstructor(Function.prototype,"Function.prototype.constructor","function_constructor");try{let t=Object.getPrototypeOf(async()=>{}).constructor;t&&t!==Function&&this.patchPrototypeConstructor(t.prototype,"AsyncFunction.prototype.constructor","async_function_constructor")}catch(t){console.debug("[DefenseInDepthBox] Could not patch AsyncFunction.prototype.constructor:",t instanceof Error?t.message:t)}try{let t=Object.getPrototypeOf(function*(){}).constructor;t&&t!==Function&&this.patchPrototypeConstructor(t.prototype,"GeneratorFunction.prototype.constructor","generator_function_constructor")}catch(t){console.debug("[DefenseInDepthBox] Could not patch GeneratorFunction.prototype.constructor:",t instanceof Error?t.message:t)}try{let t=Object.getPrototypeOf(async function*(){}).constructor,s=Object.getPrototypeOf(async()=>{}).constructor;t&&t!==Function&&t!==s&&this.patchPrototypeConstructor(t.prototype,"AsyncGeneratorFunction.prototype.constructor","async_generator_function_constructor")}catch(t){console.debug("[DefenseInDepthBox] Could not patch AsyncGeneratorFunction.prototype.constructor:",t instanceof Error?t.message:t)}}protectErrorPrepareStackTrace(){let t=this;try{let s=Object.getOwnPropertyDescriptor(Error,"prepareStackTrace");this.originalDescriptors.push({target:Error,prop:"prepareStackTrace",descriptor:s});let r=s?.value;Object.defineProperty(Error,"prepareStackTrace",{get(){return r},set(n){if(t.shouldBlock()){let i="Error.prepareStackTrace modification is blocked during script execution",o=t.recordViolation("error_prepare_stack_trace","Error.prepareStackTrace",i);throw new ue(i,o)}t.config.auditMode&&ve?.getStore()?.sandboxActive===!0&&t.recordViolation("error_prepare_stack_trace","Error.prepareStackTrace","Error.prepareStackTrace set (audit mode)"),r=n},configurable:!0})}catch(s){console.debug("[DefenseInDepthBox] Could not protect Error.prepareStackTrace:",s instanceof Error?s.message:s)}}patchPrototypeConstructor(t,s,r){let n=this;try{let i=Object.getOwnPropertyDescriptor(t,"constructor");this.originalDescriptors.push({target:t,prop:"constructor",descriptor:i});let o=i?.value;Object.defineProperty(t,"constructor",{get(){if(n.shouldBlock()){let a=`${s} access is blocked during script execution`,l=n.recordViolation(r,s,a);throw new ue(a,l)}return n.config.auditMode&&ve?.getStore()?.sandboxActive===!0&&n.recordViolation(r,s,`${s} accessed (audit mode)`),o},set(a){if(n.shouldBlock()){let l=`${s} modification is blocked during script execution`,u=n.recordViolation(r,s,l);throw new ue(l,u)}Object.defineProperty(this,"constructor",{value:a,writable:!0,configurable:!0})},configurable:!0})}catch(i){console.debug(`[DefenseInDepthBox] Could not patch ${s}:`,i instanceof Error?i.message:i)}}protectProcessMainModule(){if(typeof process>"u")return;let t=this;try{let s=Object.getOwnPropertyDescriptor(process,"mainModule");this.originalDescriptors.push({target:process,prop:"mainModule",descriptor:s});let r=s?.value;r!==void 0&&Object.defineProperty(process,"mainModule",{get(){if(t.shouldBlock()){let n="process.mainModule access is blocked during script execution",i=t.recordViolation("process_main_module","process.mainModule",n);throw new ue(n,i)}return t.config.auditMode&&ve?.getStore()?.sandboxActive===!0&&t.recordViolation("process_main_module","process.mainModule","process.mainModule accessed (audit mode)"),r},set(n){if(t.shouldBlock()){let i="process.mainModule modification is blocked during script execution",o=t.recordViolation("process_main_module","process.mainModule",i);throw new ue(i,o)}Object.defineProperty(process,"mainModule",{value:n,writable:!0,configurable:!0})},configurable:!0})}catch(s){console.debug("[DefenseInDepthBox] Could not protect process.mainModule:",s instanceof Error?s.message:s)}}protectModuleLoad(){if(!xt)try{let t=null;if(typeof process<"u"){let o=process.mainModule;o&&typeof o=="object"&&(t=o.constructor)}if(!t&&typeof vt<"u"&&typeof vt.main<"u"&&(t=vt.main.constructor),!t||typeof t._load!="function")return;let s=t._load,r=Object.getOwnPropertyDescriptor(t,"_load");this.originalDescriptors.push({target:t,prop:"_load",descriptor:r});let i=this.createBlockingProxy(s,"Module._load","module_load");Object.defineProperty(t,"_load",{value:i,writable:!0,configurable:!0})}catch(t){console.debug("[DefenseInDepthBox] Could not protect Module._load:",t instanceof Error?t.message:t)}}applyPatch(t){let{target:s,prop:r,violationType:n,strategy:i}=t;try{let o=s[r];if(o===void 0)return;let a=Object.getOwnPropertyDescriptor(s,r);if(this.originalDescriptors.push({target:s,prop:r,descriptor:a}),i==="freeze")typeof o=="object"&&o!==null&&Object.freeze(o);else{let l=this.getPathForTarget(s,r),u=typeof o=="function"?this.createBlockingProxy(o,l,n):this.createBlockingObjectProxy(o,l,n);Object.defineProperty(s,r,{value:u,writable:!0,configurable:!0})}}catch(o){let a=this.getPathForTarget(s,r);console.debug(`[DefenseInDepthBox] Could not patch ${a}:`,o instanceof Error?o.message:o)}}restorePatches(){for(let t=this.originalDescriptors.length-1;t>=0;t--){let{target:s,prop:r,descriptor:n}=this.originalDescriptors[t];try{n?Object.defineProperty(s,r,n):delete s[r]}catch(i){let o=this.getPathForTarget(s,r);console.debug(`[DefenseInDepthBox] Could not restore ${o}:`,i instanceof Error?i.message:i)}}this.originalDescriptors=[]}};var Nt=class{fs;commands=new Map;useDefaultLayout=!1;limits;secureFetch;sleepFn;traceFn;logger;defenseInDepthConfig;coverageWriter;state;constructor(t={}){let s=t.fs??new We(t.files);this.fs=s,this.useDefaultLayout=!t.cwd&&!t.files;let r=t.cwd||(this.useDefaultLayout?"/home/user":"/"),n=new Map,i=[["HOME",this.useDefaultLayout?"/home/user":"/"],["PATH","/usr/bin:/bin"],["IFS",`
675
- `],["OSTYPE","linux-gnu"],["MACHTYPE","x86_64-pc-linux-gnu"],["HOSTTYPE","x86_64"],["HOSTNAME","localhost"],["PWD",r],["OLDPWD",r],["OPTIND","1"]];for(let[o,a]of i)g(n,o,a);for(let[o,a]of Object.entries(t.env??{}))g(n,o,a);if(this.limits=wi({...t.executionLimits,...t.maxCallDepth!==void 0&&{maxCallDepth:t.maxCallDepth},...t.maxCommandCount!==void 0&&{maxCommandCount:t.maxCommandCount},...t.maxLoopIterations!==void 0&&{maxLoopIterations:t.maxLoopIterations}}),t.network&&(this.secureFetch=Er(t.network)),this.sleepFn=t.sleep,this.traceFn=t.trace,this.logger=t.logger,this.defenseInDepthConfig=t.defenseInDepth,this.coverageWriter=t.coverage,this.state={env:n,cwd:r,previousDir:"/home/user",functions:new Map,localScopes:[],callDepth:0,sourceDepth:0,commandCount:0,lastExitCode:0,lastArg:F,startTime:Date.now(),lastBackgroundPid:0,bashPid:gs().pid,nextVirtualPid:gs().pid+1,currentLine:1,options:{errexit:!1,pipefail:!1,nounset:!1,xtrace:!1,verbose:!1,posix:!1,allexport:!1,noclobber:!1,noglob:!1,noexec:!1,vi:!1,emacs:!1},shoptOptions:{extglob:!1,dotglob:!1,nullglob:!1,failglob:!1,globstar:!1,globskipdots:!0,nocaseglob:!1,nocasematch:!1,expand_aliases:!1,lastpipe:!1,xpg_echo:!1},inCondition:!1,loopDepth:0,exportedVars:new Set(["HOME","PATH","PWD","OLDPWD",...Object.keys(t.env||{})]),readonlyVars:new Set(["SHELLOPTS","BASHOPTS"]),hashTable:new Map},g(this.state.env,"SHELLOPTS",As(this.state.options)),g(this.state.env,"BASHOPTS",ks(this.state.shoptOptions)),Jr(s,this.useDefaultLayout),r!=="/"&&s instanceof We)try{s.mkdirSync(r,{recursive:!0})}catch{}for(let o of Gr(t.commands))this.registerCommand(o);if(t.network)for(let o of qr())this.registerCommand(o);if(t.python)for(let o of Zr())this.registerCommand(o);if(t.customCommands)for(let o of t.customCommands)Xr(o)?this.registerCommand(Yr(o)):this.registerCommand(o)}registerCommand(t){this.commands.set(t.name,t);let s=this.fs;if(typeof s.writeFileSync=="function"){let r=`#!/bin/bash
655
+ `,await G(e,2,b)}return l&&!e.state.shoptOptions.lastpipe&&(e.state.lastArg=u),i}async function Yi(e,t){let s=new Map,r="";for(let n of t.assignments){let i=n.name;if(n.array){let f=await za(e,t,i,n.array,n.append,s);if(f.error)return{continueToNext:!1,xtraceOutput:r,tempAssignments:s,error:f.error};if(r+=f.xtraceOutput,f.continueToNext)continue}let a=n.value?await pt(e,n.value):R,o=n.value?B(a):"";if(o.length>e.limits.maxStringLength&&Me(`word expansion: string length limit exceeded (${e.limits.maxStringLength} bytes)`,"iterations"),i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[\]$/))return{continueToNext:!1,xtraceOutput:r,tempAssignments:s,error:P(`bash: ${i}: bad array subscript
656
+ `)};let u=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(u){let f=await Ha(e,t,u[1],u[2],o,n.append,s);if(f.error)return{continueToNext:!1,xtraceOutput:r,tempAssignments:s,error:f.error};if(f.continueToNext)continue}let c=await Za(e,t,i,o,n.append,s,a);if(c.error)return{continueToNext:!1,xtraceOutput:r,tempAssignments:s,error:c.error};r+=c.xtraceOutput,c.continueToNext}return{continueToNext:!1,xtraceOutput:r,tempAssignments:s}}async function za(e,t,s,r,n,i){let a="";if(/\[.+\]$/.test(s))return{continueToNext:!1,xtraceOutput:"",error:P(`bash: ${s}: cannot assign list to array member
657
+ `)};if(Ee(e,s)){let c=bn(e,s);if(c===void 0||c==="")throw new q(1);let f=ze(e,s);if(f&&/^[a-zA-Z_][a-zA-Z0-9_]*\[@\]$/.test(f))return{continueToNext:!1,xtraceOutput:"",error:P(`bash: ${s}: cannot assign list to array member
658
+ `)}}if(ot(e,s)){if(t.name)return a+=`bash: ${s}: readonly variable
659
+ `,{continueToNext:!0,xtraceOutput:a};let c=await de(e,s);if(c)return{continueToNext:!1,xtraceOutput:"",error:c}}let o=e.state.associativeArrays?.has(s),l=ja(r),u=()=>{let c=`${s}_`;for(let f of e.state.env.keys())f.startsWith(c)&&!f.includes("__")&&e.state.env.delete(f);e.state.env.delete(s)};if(o&&l?await Ba(e,t,s,r,n,u,c=>{a+=c}):l?await Ua(e,s,r,n,u):await Ga(e,s,r,n,u),t.name){i.set(s,e.state.env.get(s));let f=`(${r.map(d=>rs(d)).join(" ")})`;g(e.state.env,s,f)}return{continueToNext:!0,xtraceOutput:a}}function ja(e){return e.some(t=>{if(t.parts.length>=2){let s=t.parts[0],r=t.parts[1];if(s.type!=="Glob"||!s.pattern.startsWith("["))return!1;if(s.pattern==="["&&(r.type==="DoubleQuoted"||r.type==="SingleQuoted")){if(t.parts.length<3)return!1;let n=t.parts[2];return n.type!=="Literal"?!1:n.value.startsWith("]=")||n.value.startsWith("]+=")}return r.type!=="Literal"?!1:r.value.startsWith("]")?r.value.startsWith("]=")||r.value.startsWith("]+="):s.pattern.endsWith("]")?r.value.startsWith("=")||r.value.startsWith("+="):!1}return!1})}async function Ba(e,t,s,r,n,i,a){let o=[];for(let l of r){let u=qs(l);if(u){let{key:c,valueParts:f,append:d}=u,p;f.length>0?p=await z(e,{type:"Word",parts:f}):p="",p=ne(e,p),o.push({type:"keyed",key:c,value:p,append:d})}else{let c=await z(e,l);o.push({type:"invalid",expandedValue:c})}}n||i();for(let l of o)if(l.type==="keyed")if(l.append){let u=T(e.state.env,`${s}_${l.key}`,"");g(e.state.env,`${s}_${l.key}`,u+l.value)}else g(e.state.env,`${s}_${l.key}`,l.value);else{let u=t.line??e.state.currentLine??1;a(`bash: line ${u}: ${s}: ${l.expandedValue}: must use subscript when assigning associative array
660
+ `)}}async function Ua(e,t,s,r,n){let i=[];for(let o of s){let l=qs(o);if(l){let{key:u,valueParts:c,append:f}=l,d;c.length>0?d=await z(e,{type:"Word",parts:c}):d="",d=ne(e,d),i.push({type:"keyed",indexExpr:u,value:d,append:f})}else{let u=await je(e,o);i.push({type:"non-keyed",values:u.values})}}r||n();let a=0;for(let o of i)if(o.type==="keyed"){let l;try{let u=new X,c=ce(u,o.indexExpr);l=await ee(e,c.expression,!1)}catch{if(/^-?\d+$/.test(o.indexExpr))l=Number.parseInt(o.indexExpr,10);else{let u=T(e.state.env,o.indexExpr);l=u?Number.parseInt(u,10):0,Number.isNaN(l)&&(l=0)}}if(o.append){let u=T(e.state.env,`${t}_${l}`,"");g(e.state.env,`${t}_${l}`,u+o.value)}else g(e.state.env,`${t}_${l}`,o.value);a=l+1}else for(let l of o.values)g(e.state.env,`${t}_${a++}`,l)}async function Ga(e,t,s,r,n){let i=[];for(let o of s){let l=await je(e,o);i.push(...l.values)}let a=0;if(r){let o=Ie(e,t);if(o.length>0)a=Math.max(...o.map(([u])=>typeof u=="number"?u:0))+1;else{let l=e.state.env.get(t);l!==void 0&&(e.state.env.set(`${t}_0`,l),e.state.env.delete(t),a=1)}}else n();for(let o=0;o<i.length;o++)g(e.state.env,`${t}_${a+o}`,i[o]);r||g(e.state.env,`${t}__length`,String(i.length))}async function Ha(e,t,s,r,n,i,a){let o=s;if(Ee(e,s)){let f=ze(e,s);if(f&&f!==s){if(f.includes("["))return{continueToNext:!1,xtraceOutput:"",error:P(`bash: \`${f}': not a valid identifier
661
+ `)};o=f}}if(ot(e,o)){if(t.name)return{continueToNext:!0,xtraceOutput:""};let f=await de(e,o);if(f)return{continueToNext:!1,xtraceOutput:"",error:f}}let l=e.state.associativeArrays?.has(o),u;if(l)u=await Qi(e,o,r);else{let f=await qa(e,o,r);if(f.error)return{continueToNext:!1,xtraceOutput:"",error:f.error};u=`${o}_${f.index}`}let c=i?T(e.state.env,u)+n:n;if(t.name)a.set(u,e.state.env.get(u)),g(e.state.env,u,c);else{let f=bt(e,o);if(f!==void 0&&f===e.state.callDepth&&e.state.localScopes.length>0){let d=e.state.localScopes[e.state.localScopes.length-1];d.has(u)||d.set(u,e.state.env.get(u))}g(e.state.env,u,c)}return{continueToNext:!0,xtraceOutput:""}}async function Qi(e,t,s){let r;if(s.startsWith("'")&&s.endsWith("'"))r=s.slice(1,-1);else if(s.startsWith('"')&&s.endsWith('"')){let n=s.slice(1,-1),a=new X().parseWordFromString(n,!0,!1);r=await z(e,a)}else if(s.includes("$")){let i=new X().parseWordFromString(s,!1,!1);r=await z(e,i)}else r=s;return`${t}_${r}`}async function qa(e,t,s){let r=s;s.startsWith('"')&&s.endsWith('"')&&s.length>=2&&(r=s.slice(1,-1));let n;if(/^-?\d+$/.test(r))n=Number.parseInt(r,10);else{try{let i=new X,a=ce(i,r);n=await ee(e,a.expression,!1)}catch(i){if(i instanceof nt){let l=`bash: line ${e.state.currentLine}: ${s}: ${i.message}
662
+ `;if(i.fatal)throw await G(e,2,l,!0),new q(1);return{index:0,error:P(l)}}let a=T(e.state.env,s);n=a?Number.parseInt(a,10):0}Number.isNaN(n)&&(n=0)}if(n<0){let i=Ie(e,t);if(i.length===0){let o=e.state.currentLine;return{index:0,error:P(`bash: line ${o}: ${t}[${s}]: bad array subscript
663
+ `)}}if(n=Math.max(...i.map(([o])=>typeof o=="number"?o:0))+1+n,n<0){let o=e.state.currentLine;return{index:0,error:P(`bash: line ${o}: ${t}[${s}]: bad array subscript
664
+ `)}}}return{index:n}}async function Za(e,t,s,r,n,i,a){let o="",l=s,u=null;if(Ee(e,s)){let h=En(e,s,r);if(h===void 0)return{continueToNext:!1,xtraceOutput:"",error:P(`bash: ${s}: circular name reference
665
+ `)};if(h===null)return{continueToNext:!0,xtraceOutput:""};l=h;let b=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);b&&(u={arrayName:b[1],subscriptExpr:b[2]},l=b[1])}if(ot(e,l)){if(t.name)return o+=`bash: ${l}: readonly variable
666
+ `,{continueToNext:!0,xtraceOutput:o};let h=await de(e,l);if(h)return{continueToNext:!1,xtraceOutput:"",error:h}}let c,f=!!a&&!n&&!u;if(Bt(e,l)){f=!1;try{let h=new X;if(n){let E=`(${T(e.state.env,l,"0")}) + (${r})`,$=ce(h,E);c=String(await ee(e,$.expression))}else{let b=ce(h,r);c=String(await ee(e,b.expression))}}catch{c="0"}}else{let{isArray:h}=await import("./chunks/expansion-QM4WQBBG.js"),b=h(e,l);b&&(f=!1);let E=b?`${l}_0`:l;c=n?T(e.state.env,E)+r:r}let d=$t(e,l,c);d!==c&&(f=!1),c=d,o+=await Ui(e,l,c);let p=l;if(u)p=await Xa(e,u);else{let{isArray:h}=await import("./chunks/expansion-QM4WQBBG.js");h(e,l)&&(p=`${l}_0`,f=!1)}let m=f?()=>e.state.env.set(p,a):()=>g(e.state.env,p,c);return t.name?(i.set(p,e.state.env.get(p)),m()):(m(),e.state.options.allexport&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(l)),e.state.tempEnvBindings?.some(h=>h.has(l))&&(e.state.mutatedTempEnvVars=e.state.mutatedTempEnvVars||new Set,e.state.mutatedTempEnvVars.add(l))),{continueToNext:!1,xtraceOutput:o}}async function Xa(e,t){let{arrayName:s,subscriptExpr:r}=t;if(e.state.associativeArrays?.has(s))return Qi(e,s,r);let i;if(/^-?\d+$/.test(r))i=Number.parseInt(r,10);else{try{let a=new X,o=ce(a,r);i=await ee(e,o.expression,!1)}catch{let a=T(e.state.env,r);i=a?Number.parseInt(a,10):0}Number.isNaN(i)&&(i=0)}if(i<0){let a=Ie(e,s);a.length>0&&(i=Math.max(...a.map(l=>l[0]))+1+i)}return`${s}_${i}`}async function eo(e,t,s,r){let n=it(e.outputChannels),i=new Map(e.state.env),a=e.state.cwd,o=e.state.fileDescriptors,l=e.state.nextFd;e.state.fileDescriptors=o?new Map(o):void 0;let u={...e.state.options},c=new Map(e.state.functions),f=e.state.localScopes,d=e.state.localVarStack,p=e.state.localVarDepth,m=e.state.fullyUnsetLocals;if(e.state.localScopes=f.map(C=>new Map(C)),d){e.state.localVarStack=new Map;for(let[C,N]of d.entries())e.state.localVarStack.set(C,N.map(I=>({...I})))}p&&(e.state.localVarDepth=new Map(p)),m&&(e.state.fullyUnsetLocals=new Map(m));let h=e.state.loopDepth,b=e.state.parentHasLoopContext;e.state.parentHasLoopContext=h>0,e.state.loopDepth=0;let E=e.state.lastArg,$=e.state.bashPid;e.state.bashPid=e.state.nextVirtualPid++;let y=e.state.groupStdin,v=()=>{e.state.env=i,e.state.cwd=a,e.state.fileDescriptors=o,e.state.nextFd=l,e.state.options=u,e.state.functions=c,e.state.localScopes=f,e.state.localVarStack=d,e.state.localVarDepth=p,e.state.fullyUnsetLocals=m,e.state.loopDepth=h,e.state.parentHasLoopContext=b,e.state.groupStdin=y,e.state.bashPid=$,e.state.lastArg=E};try{let C=t.redirections.length===0?{channels:n,legacyRedirections:[]}:await De(e,n,t.redirections);return C.error?await K(e,C.channels,()=>se(e,()=>Promise.resolve(C.error))):await K(e,C.channels,async()=>{let N=I=>F(S(),S(),I);try{let I=await re(s);I.length>0&&(e.state.groupStdin=fe(I));let k=0;for(let A of t.body){let O=await r(A);k=(await se(e,()=>Promise.resolve(O))).exitCode}return await N(k)}catch(I){let{diagnosticWritten:k,writeFailure:A}=await Qe(e,I);if(A)return A;if(I instanceof ae)throw I;return I instanceof Ge||I instanceof Ce||I instanceof Ae?await N(0):I instanceof q||I instanceof ve||I instanceof ke||I instanceof be?await N(I.exitCode):(k||await se(e,()=>Promise.resolve(P(`${He(I)}
667
+ `))),await N(1))}})}catch(C){throw await K(e,n,()=>te(e,C)),C}finally{v()}}async function to(e,t,s,r){let n=t.redirections.length===0?{channels:e.outputChannels,legacyRedirections:[]}:await De(e,e.outputChannels,t.redirections);return n.error?K(e,n.channels,()=>se(e,()=>Promise.resolve(n.error))):K(e,n.channels,async()=>{let i=e.state.groupStdin;try{let a=await Et(e,n.legacyRedirections);if(a)return await se(e,()=>Promise.resolve(a));let o=await re(s),l=fe(o),u=!1;for(let f of n.legacyRedirections)if(!f.fdVariable){if((f.operator==="<<"||f.operator==="<<-")&&f.target.type==="HereDoc"){let d=f.target,p=await z(e,d.content);d.stripTabs&&(p=p.split(`
668
+ `).map(h=>h.replace(/^\t+/,"")).join(`
669
+ `));let m=f.fd??0;m!==0?(e.state.fileDescriptors||(e.state.fileDescriptors=new Map),e.state.fileDescriptors.set(m,p)):(l=V(p),u=!0)}else if(f.operator==="<<<"&&f.target.type==="Word")l=V(`${await z(e,f.target)}
670
+ `),u=!0;else if(f.operator==="<"&&f.target.type==="Word"){let d=await z(e,f.target);try{let p=e.fs.resolvePath(e.state.cwd,d);l=await e.fs.readFile(p),u=!0}catch{return await se(e,()=>Promise.resolve(P(`bash: ${d}: No such file or directory
671
+ `)))}}}(u||o.length>0)&&(e.state.groupStdin=l);let c=0;for(let f of t.body){let d=await r(f);c=(await se(e,()=>Promise.resolve(d))).exitCode}return F(S(),S(),c)}catch(a){let{diagnosticWritten:o,writeFailure:l}=await Qe(e,a);if(l)return l;if(es(a)||a instanceof ke||a instanceof q||a instanceof be||a instanceof Ge||a instanceof ae)throw a;return o||await se(e,()=>Promise.resolve(P(`${He(a)}
672
+ `))),F(S(),S(),1)}finally{e.state.groupStdin=i}})}async function so(e,t,s,r,n){let i;try{i=await e.fs.readFileText(t)}catch{return P(`bash: ${t}: No such file or directory
673
+ `,127)}if(i.startsWith("#!")){let b=i.indexOf(`
674
+ `);b!==-1&&(i=i.slice(b+1))}let a=new Map(e.state.env),o=e.state.cwd,l={...e.state.options},u=e.state.loopDepth,c=e.state.parentHasLoopContext,f=e.state.lastArg,d=e.state.bashPid,p=e.state.groupStdin,m=e.state.currentSource,h=()=>{e.state.env=a,e.state.cwd=o,e.state.options=l,e.state.loopDepth=u,e.state.parentHasLoopContext=c,e.state.lastArg=f,e.state.bashPid=d,e.state.groupStdin=p,e.state.currentSource=m};try{e.state.parentHasLoopContext=u>0,e.state.loopDepth=0,e.state.bashPid=e.state.nextVirtualPid++;let b=await re(r);b.length>0&&(e.state.groupStdin=fe(b)),e.state.currentSource=t,g(e.state.env,"0",t),g(e.state.env,"#",String(s.length)),g(e.state.env,"@",s.join(" ")),g(e.state.env,"*",s.join(" "));for(let v=0;v<s.length&&v<9;v++)g(e.state.env,String(v+1),s[v]);for(let v=s.length+1;v<=9;v++)e.state.env.delete(String(v));let $=new X().parse(i),y=await n($);return await se(e,()=>Promise.resolve(y))}catch(b){let{writeFailure:E}=await Qe(e,b);if(E)return E;if(b instanceof q||b instanceof ae)throw b;if(b.name==="ParseException")return P(`bash: ${t}: ${b.message}
675
+ `);throw b}finally{h()}}function Ja(e,t){for(let s of t.parts)switch(s.type){case"Bytes":case"Literal":case"SingleQuoted":case"Escaped":continue;case"DoubleQuoted":for(let r of s.parts)switch(r.type){case"Bytes":case"Literal":case"SingleQuoted":case"Escaped":continue;case"ParameterExpansion":if(r.operation||r.parameter==="@"||r.parameter==="*"||r.parameter.endsWith("[@]")||r.parameter.endsWith("[*]"))return!1;if(Ee(e,r.parameter)){let n=ze(e,r.parameter);if(n&&(n.endsWith("[@]")||n.endsWith("[*]")))return!1}continue;case"CommandSubstitution":continue;default:return!1}continue;case"ParameterExpansion":return!1;default:return!1}return t.parts.length>0}var Zt=class e{ctx;constructor(t,s){this.ctx={state:s,fs:t.fs,commands:t.commands,processes:t.processes,lineageId:t.lineageId,outputChannels:t.outputChannels,reportedDiagnostics:new WeakSet,limits:t.limits,jobTracker:t.jobTracker,execFn:t.exec,executeScript:this.executeScript.bind(this),executeStatement:this.executeStatement.bind(this),executeCommand:this.executeCommand.bind(this),fetch:t.fetch,sleep:t.sleep,trace:t.trace,coverage:t.coverage,signal:t.signal}}buildExportedEnv(){let t=this.ctx.state.exportedVars,s=this.ctx.state.tempExportedVars,r=new Set;if(t)for(let i of t)r.add(i);if(s)for(let i of s)r.add(i);if(r.size===0)return Object.create(null);let n=Object.create(null);for(let i of r)this.ctx.state.env.has(i)&&(n[i]=T(this.ctx.state.env,i));return n}async executeRootScript(t){let s=await this.executeScript(t);return Ke(this.ctx.signal),Y(this.ctx,s)}async executeScript(t){let s=0;for(let r of t.statements)try{let n=await this.executeStatement(r),i=this.ctx.signal?.aborted===!0&&n.exitCode===new pe(this.ctx.signal.reason).exitCode;await Y(this.ctx,n,!i),s=n.exitCode,this.ctx.state.lastExitCode=s,g(this.ctx.state.env,"?",String(s))}catch(n){if(await te(this.ctx,n),n instanceof q)throw n;if(n instanceof be)return s=n.exitCode,this.ctx.state.lastExitCode=s,g(this.ctx.state.env,"?",String(s)),{stdout:S(),stderr:S(),exitCode:s,env:Ye(this.ctx.state.env)};if(n instanceof ae)throw n;if(n instanceof ke)return s=n.exitCode,this.ctx.state.lastExitCode=s,g(this.ctx.state.env,"?",String(s)),{stdout:S(),stderr:S(),exitCode:s,env:Ye(this.ctx.state.env)};if(n instanceof cn)return s=1,this.ctx.state.lastExitCode=s,g(this.ctx.state.env,"?",String(s)),{stdout:S(),stderr:S(),exitCode:s,env:Ye(this.ctx.state.env)};if(n instanceof It)return s=1,this.ctx.state.lastExitCode=s,g(this.ctx.state.env,"?",String(s)),{stdout:S(),stderr:S(),exitCode:s,env:Ye(this.ctx.state.env)};if(n instanceof nt){s=1,this.ctx.state.lastExitCode=s,g(this.ctx.state.env,"?",String(s));continue}if(n instanceof un){s=1,this.ctx.state.lastExitCode=s,g(this.ctx.state.env,"?",String(s));continue}if(n instanceof Ce||n instanceof Ae){if(this.ctx.state.loopDepth>0)throw n;continue}throw n instanceof ve,n}return{stdout:S(),stderr:S(),exitCode:s,env:Ye(this.ctx.state.env)}}async executeUserScript(t,s,r=S()){return so(this.ctx,t,ft(s),r,n=>this.executeScript(n))}async executeStatement(t){if(Ke(this.ctx.signal),this.ctx.state.commandCount++,this.ctx.state.commandCount>this.ctx.limits.maxCommandCount&&Me(`too many commands executed (>${this.ctx.limits.maxCommandCount}), increase executionLimits.maxCommandCount`,"commands"),this.ctx.signal&&this.ctx.state.commandCount%1024===0&&(await new Promise(o=>setTimeout(o,0)),Ke(this.ctx.signal)),t.deferredError)throw new ts(t.deferredError.message,t.line??1,1);if(this.ctx.state.options.noexec)return U();if(this.ctx.state.errexitSafe=!1,this.ctx.state.options.verbose&&!this.ctx.state.suppressVerbose&&t.sourceText&&await G(this.ctx,2,`${t.sourceText}
676
+ `),t.background){if(this.ctx.processes.runningCount>=this.ctx.limits.maxConcurrentJobs)return this.ctx.jobTracker.limitExceeded=!0,await G(this.ctx,2,`bash: maximum concurrent jobs (${this.ctx.limits.maxConcurrentJobs}) exceeded
677
+ `),P("",ae.EXIT_CODE);let o=this.ctx.state,l={...o,env:new Map([...o.env].map(([m,h])=>[m,h.slice()])),functions:new Map(o.functions),localScopes:o.localScopes.map(m=>new Map([...m].map(([h,b])=>[h,b?.slice()]))),options:{...o.options},shoptOptions:{...o.shoptOptions},lastArg:o.lastArg.slice(),groupStdin:void 0,...o.fileDescriptors?{fileDescriptors:new Map(o.fileDescriptors)}:{},...o.readonlyVars?{readonlyVars:new Set(o.readonlyVars)}:{},...o.associativeArrays?{associativeArrays:new Set(o.associativeArrays)}:{},...o.namerefs?{namerefs:new Set(o.namerefs)}:{},...o.boundNamerefs?{boundNamerefs:new Set(o.boundNamerefs)}:{},...o.invalidNamerefs?{invalidNamerefs:new Set(o.invalidNamerefs)}:{},...o.integerVars?{integerVars:new Set(o.integerVars)}:{},...o.lowercaseVars?{lowercaseVars:new Set(o.lowercaseVars)}:{},...o.uppercaseVars?{uppercaseVars:new Set(o.uppercaseVars)}:{},...o.exportedVars?{exportedVars:new Set(o.exportedVars)}:{},...o.tempExportedVars?{tempExportedVars:new Set(o.tempExportedVars)}:{},...o.localExportedVars?{localExportedVars:o.localExportedVars.map(m=>new Set(m))}:{},...o.declaredVars?{declaredVars:new Set(o.declaredVars)}:{},...o.localVarDepth?{localVarDepth:new Map(o.localVarDepth)}:{},...o.localVarStack?{localVarStack:new Map([...o.localVarStack].map(([m,h])=>[m,h.map(b=>({...b,value:b.value?.slice()}))]))}:{},...o.fullyUnsetLocals?{fullyUnsetLocals:new Map(o.fullyUnsetLocals)}:{},...o.tempEnvBindings?{tempEnvBindings:o.tempEnvBindings.map(m=>new Map([...m].map(([h,b])=>[h,b?.slice()])))}:{},...o.mutatedTempEnvVars?{mutatedTempEnvVars:new Set(o.mutatedTempEnvVars)}:{},...o.accessedTempEnvVars?{accessedTempEnvVars:new Set(o.accessedTempEnvVars)}:{},...o.callLineStack?{callLineStack:[...o.callLineStack]}:{},...o.funcNameStack?{funcNameStack:[...o.funcNameStack]}:{},...o.sourceStack?{sourceStack:[...o.sourceStack]}:{},...o.completionSpecs?{completionSpecs:new Map(o.completionSpecs)}:{},...o.directoryStack?{directoryStack:[...o.directoryStack]}:{},...o.hashTable?{hashTable:new Map(o.hashTable)}:{}},u=this.ctx.processes,c=this.ctx.outputChannels,f=m=>it(c,(h,b)=>u.observesOutput?_e({write(E){return u.observeOutput(m,h,E),b.write(E)}},!1):b),d=t.sourceText?.trim()||"<background job>",p;try{p=u.start(d,async(m,h)=>{let b=f(m);l.bashPid=m,l.nextVirtualPid=Math.max(l.nextVirtualPid,m+1);let E=Mt(this.ctx.signal,h),$=new e({fs:this.ctx.fs,commands:this.ctx.commands,processes:u,lineageId:this.ctx.lineageId,outputChannels:b,limits:this.ctx.limits,jobTracker:this.ctx.jobTracker,exec:(y,v)=>this.ctx.execFn(y,{...v,signal:Mt(E,v?.signal)}),fetch:this.ctx.fetch,sleep:this.ctx.sleep,trace:this.ctx.trace,coverage:this.ctx.coverage,signal:E},l);try{return(await $.executeRootScript({type:"Script",statements:[{...t,background:!1,sourceText:void 0}]})).exitCode}catch(y){if(y instanceof pe||y instanceof q)return y.exitCode;if(y instanceof ae)return this.ctx.jobTracker.limitExceeded=!0,ae.EXIT_CODE;throw y}},this.ctx.lineageId),this.ctx.jobTracker.started=!0}catch(m){return await G(this.ctx,2,`bash: ${m instanceof Error?m.message:String(m)}
678
+ `),P("",1)}return this.ctx.state.lastBackgroundPid=p,U()}let s=0,r=-1,n=!1;for(let o=0;o<t.pipelines.length;o++){let l=t.pipelines[o],u=o>0?t.operators[o-1]:null;if(u==="&&"&&s!==0||u==="||"&&s===0)continue;s=(await this.executePipeline(l)).exitCode,r=o,n=l.negated,this.ctx.state.lastExitCode=s,g(this.ctx.state.env,"?",String(s))}let i=r<t.pipelines.length-1,a=this.ctx.state.errexitSafe;if(this.ctx.state.errexitSafe=i||n||a,this.ctx.state.options.errexit&&s!==0&&r===t.pipelines.length-1&&!n&&!this.ctx.state.inCondition&&!a)throw new ke(s);return{stdout:S(),stderr:S(),exitCode:s}}async executePipeline(t){return Ki(this.ctx,t,(s,r)=>this.executeCommand(s,r))}async executeCommand(t,s){switch(this.ctx.coverage?.hit(`bash:cmd:${t.type}`),t.type){case"SimpleCommand":return this.executeSimpleCommand(t,s);case"If":return Gi(this.ctx,t);case"For":return Hi(this.ctx,t);case"CStyleFor":return qi(this.ctx,t);case"While":return Zi(this.ctx,t,s);case"Until":return Xi(this.ctx,t);case"Case":return Ji(this.ctx,t);case"Subshell":return this.executeSubshell(t,s);case"Group":return this.executeGroup(t,s);case"FunctionDef":return ui(this.ctx,t);case"ArithmeticCommand":return this.executeArithmeticCommand(t);case"ConditionalCommand":return this.executeConditionalCommand(t);default:return U()}}async executeSimpleCommand(t,s){this.ctx.reportedDiagnostics=new WeakSet;try{return await this.executeSimpleCommandInner(t,s)}catch(r){if(r instanceof Qt)return await te(this.ctx,r),{stdout:S(),stderr:S(),exitCode:1};throw r}}async executeSimpleCommandInner(t,s){if(t.line!==void 0&&(this.ctx.state.currentLine=t.line),this.ctx.state.shoptOptions.expand_aliases&&t.name){let k=t,A=100;for(;A>0;){let O=this.expandAlias(k);if(O===k)break;k=O,A--}this.aliasExpansionStack.clear(),k!==t&&(t=k)}let r=await Yi(this.ctx,t);if(r.error)return r.error;let n=r.tempAssignments,i=r.xtraceOutput;if(!t.name){if(await G(this.ctx,2,i),t.redirections.length>0){let k=this.ctx.outputChannels,A=await De(this.ctx,k,t.redirections);if(A.error)return await K(this.ctx,A.channels,()=>se(this.ctx,()=>Promise.resolve(A.error)));let O={stdout:S(),stderr:S(),exitCode:0},M=[1,2].filter(x=>{let _=k.bindings.get(x),w=A.channels.bindings.get(x);return _?.sink!==w?.sink||We(k,x)!==We(A.channels,x)});return await K(this.ctx,A.channels,()=>se(this.ctx,()=>Promise.resolve(O),M))}return this.ctx.state.lastArg=W(""),{stdout:S(),stderr:S(),exitCode:this.ctx.state.lastExitCode}}let a=t.name&&jt(t.name,["local","declare","typeset","export","readonly"]),o=Array.from(n.keys());if(o.length>0&&!a){this.ctx.state.tempExportedVars=this.ctx.state.tempExportedVars||new Set;for(let k of o)this.ctx.state.tempExportedVars.add(k)}let l=-1,u=jt(t.name,["exec"])&&(t.args.length===0||t.args.length===1&&jt(t.args[0],["--"])),c=await z(this.ctx,t.name),f=[],d=[];if(jt(t.name,["local","declare","typeset","export","readonly"])&&(c==="local"||c==="declare"||c==="typeset"||c==="export"||c==="readonly"))for(let k of t.args){let A=await Un(this.ctx,k);if(A)f.push(W(A)),d.push(!0);else{let O=await Gn(this.ctx,k);if(O!==null)f.push(W(O)),d.push(!0);else{let M=await je(this.ctx,k);for(let x of M.values)f.push(W(x)),d.push(M.quoted)}}}else for(let k of t.args)if(Ja(this.ctx,k))f.push(await pt(this.ctx,k)),d.push(!0);else{let A=await je(this.ctx,k);for(let O of A.values)f.push(W(O)),d.push(A.quoted)}let m=this.ctx.outputChannels,h=!u&&t.redirections.length>0?await De(this.ctx,m,t.redirections,{persistMovedSource:Je.has(c)}):void 0;if(h?.error){await G(this.ctx,2,i);for(let[k,A]of n)A===void 0?this.ctx.state.env.delete(k):this.ctx.state.env.set(k,A);return await K(this.ctx,h.channels,()=>se(this.ctx,()=>Promise.resolve(h.error)))}let b=t.redirections.some(k=>{if(u&&(k.operator==="<"||k.operator==="<&")||k.fdVariable)return!1;if(k.operator==="<<"||k.operator==="<<-"||k.operator==="<<<")return!0;let A=k.fd??0;return(k.operator==="<"||k.operator==="<&")&&A===0}),E=null,$=R;b?$=await re(s):E=s;let y=h?.legacyRedirections??t.redirections;for(let k of y)if(!(k.fdVariable||u&&(k.operator==="<"||k.operator==="<&"))){if((k.operator==="<<"||k.operator==="<<-")&&k.target.type==="HereDoc"){let A=k.target,O=k.fd??0;if(O===0&&!A.stripTabs)$=await pt(this.ctx,A.content);else{let M=await z(this.ctx,A.content);A.stripTabs&&(M=M.split(`
679
+ `).map(x=>x.replace(/^\t+/,"")).join(`
680
+ `)),O!==0?(this.ctx.state.fileDescriptors||(this.ctx.state.fileDescriptors=new Map),this.ctx.state.fileDescriptors.set(O,M)):$=W(M)}continue}if(k.operator==="<<<"&&k.target.type==="Word"){let A=await pt(this.ctx,k.target);$=an(A,W(`
681
+ `));continue}if(k.operator==="<"&&k.target.type==="Word")try{let A=await z(this.ctx,k.target),O=this.ctx.fs.resolvePath(this.ctx.state.cwd,A);$=await re(await this.ctx.fs.readFile(O))}catch{let A=await z(this.ctx,k.target);for(let[O,M]of n)M===void 0?this.ctx.state.env.delete(O):this.ctx.state.env.set(O,M);return P(`bash: ${A}: No such file or directory
682
+ `)}if(k.operator==="<&"&&(k.fd??0)===0&&k.target.type==="Word"){let A=await z(this.ctx,k.target),O=A.startsWith("&")?A.slice(1):A;if(O!=="-"&&!/^\d+-?$/.test(O)){for(let[x,_]of n)_===void 0?this.ctx.state.env.delete(x):this.ctx.state.env.set(x,_);return P(`bash: ${A}: ambiguous redirect
683
+ `)}let M=Number.parseInt(O,10);if(!Number.isNaN(M)&&We(this.ctx.outputChannels,M)){for(let[x,_]of n)_===void 0?this.ctx.state.env.delete(x):this.ctx.state.env.set(x,_);return P(Ue(M))}if(!Number.isNaN(M)&&this.ctx.state.fileDescriptors){let x=this.ctx.state.fileDescriptors.get(M);if(x!==void 0)if(x.startsWith("__rw__:")){let _=Ss(x);_&&($=W(_.content.slice(_.position)),l=M)}else x.startsWith("__file__:")||x.startsWith("__file_append__:")||($=W(x));else if(M>=3&&!this.ctx.outputChannels.bindings.get(M)?.sink){for(let[_,w]of n)w===void 0?this.ctx.state.env.delete(_):this.ctx.state.env.set(_,w);return P(Ue(M))}}else if(!Number.isNaN(M)&&M>=3&&!this.ctx.outputChannels.bindings.get(M)?.sink){for(let[x,_]of n)_===void 0?this.ctx.state.env.delete(x):this.ctx.state.env.set(x,_);return P(Ue(M))}}}if(!c){if(t.name.parts.every(A=>A.type==="CommandSubstitution"||A.type==="ParameterExpansion"||A.type==="ArithmeticExpansion")){if(f.length>0){let A=B(f.shift());return d.shift(),await this.runCommand(A,f,d,E??fe($),!1,!1,l)}return{stdout:S(),stderr:S(),exitCode:this.ctx.state.lastExitCode}}return P(`bash: : command not found
684
+ `,127)}await G(this.ctx,2,i);let v=await Ls(this.ctx,c,f.map(k=>B(k)));if(await G(this.ctx,2,v),c==="exec"&&(f.length===0||B(f[0])==="--")){let k=[],A=this.ctx.outputChannels;for(;A;)k.push([A,new Map(A.bindings)]),A=A.parent;let O=this.ctx.state.fileDescriptors?new Map(this.ctx.state.fileDescriptors):void 0,M=this.ctx.state.nextFd,x=new Map;for(let w of t.redirections)w.fdVariable&&!x.has(w.fdVariable)&&x.set(w.fdVariable,this.ctx.state.env.get(w.fdVariable));let _=await ci(this.ctx,t.redirections);if(_.error){let w;try{w=await K(this.ctx,_.channels,()=>se(this.ctx,()=>Promise.resolve(_.error)))}finally{for(let[D,L]of k)D.bindings=new Map(L);this.ctx.state.fileDescriptors=O,this.ctx.state.nextFd=M;for(let[D,L]of x)L===void 0?this.ctx.state.env.delete(D):this.ctx.state.env.set(D,L)}return w}for(let w of _.legacyRedirections){if(w.target.type==="HereDoc"||w.fdVariable)continue;let D=await z(this.ctx,w.target),L=w.fd??(w.operator==="<"||w.operator==="<>"?0:1);if(this.ctx.state.fileDescriptors||(this.ctx.state.fileDescriptors=new Map),w.operator==="<"){let J=this.ctx.fs.resolvePath(this.ctx.state.cwd,D);try{let j=await this.ctx.fs.readFileText(J);this.ctx.state.fileDescriptors.set(L,j)}catch{let j;try{j=await se(this.ctx,()=>Promise.resolve(P(`bash: ${D}: No such file or directory
685
+ `)))}finally{for(let[Q,oe]of k)Q.bindings=new Map(oe);this.ctx.state.fileDescriptors=O,this.ctx.state.nextFd=M;for(let[Q,oe]of x)oe===void 0?this.ctx.state.env.delete(Q):this.ctx.state.env.set(Q,oe)}return j}}else if(w.operator==="<>"){let J=this.ctx.fs.resolvePath(this.ctx.state.cwd,D);try{let j=await this.ctx.fs.readFileText(J);this.ctx.state.fileDescriptors.set(L,`__rw__:${J.length}:${J}:0:${j}`)}catch{await this.ctx.fs.writeFile(J,"","utf8"),this.ctx.state.fileDescriptors.set(L,`__rw__:${J.length}:${J}:0:`)}}else if(w.operator==="<&")if(D==="-")this.ctx.state.fileDescriptors.delete(L);else{let J=D.endsWith("-"),j=Number.parseInt(J?D.slice(0,-1):D,10);if(!Number.isNaN(j)){let Q=this.ctx.state.fileDescriptors.get(j)??`__dupin__:${j}`;this.ctx.state.fileDescriptors.set(L,Q),J&&this.ctx.state.fileDescriptors.delete(j)}}}for(let[w,D]of n)D===void 0?this.ctx.state.env.delete(w):this.ctx.state.env.set(w,D);if(this.ctx.state.tempExportedVars)for(let w of n.keys())this.ctx.state.tempExportedVars.delete(w);return U()}n.size>0&&(this.ctx.state.tempEnvBindings=this.ctx.state.tempEnvBindings||[],this.ctx.state.tempEnvBindings.push(new Map(n)));let C,N=null,I=h?[1,2].filter(k=>{let A=m.bindings.get(k),O=h.channels.bindings.get(k);return A?.sink!==O?.sink||We(m,k)!==We(h.channels,k)}):[];try{try{let k=()=>this.runCommand(c,f,d,E??fe($),!1,!1,l);C=h?await K(this.ctx,h.channels,k):await k()}catch(k){let A=null;if(h&&(A=(await K(this.ctx,h.channels,()=>Qe(this.ctx,k,I))).writeFailure,A&&(C=A)),!A)if(k instanceof Ce||k instanceof Ae)N=k,C=U();else throw k}if(C.exitCode===127&&Je.has(c)&&h?.channels.bindings.get(1)?.descriptor==="__file__:/dev/full"&&(C=H(`
686
+ `)),h&&I.length>0&&(C=await K(this.ctx,h.channels,()=>se(this.ctx,()=>Promise.resolve(C),I))),N)throw N;if(f.length>0){let k=B(f[f.length-1]);if((c==="declare"||c==="local"||c==="typeset")&&/^[a-zA-Z_][a-zA-Z0-9_]*=\(/.test(k)){let A=k.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\(/);A&&(k=A[1])}this.ctx.state.lastArg=W(k)}else this.ctx.state.lastArg=W(c)}finally{let k=ii(c)&&c!=="unset"&&c!=="eval";if(!this.ctx.state.options.posix||!k)for(let[O,M]of n)this.ctx.state.fullyUnsetLocals?.has(O)||(M===void 0?this.ctx.state.env.delete(O):this.ctx.state.env.set(O,M));if(this.ctx.state.tempExportedVars)for(let O of n.keys())this.ctx.state.tempExportedVars.delete(O);n.size>0&&this.ctx.state.tempEnvBindings&&this.ctx.state.tempEnvBindings.pop()}return C}async runCommand(t,s,r,n,i=!1,a=!1,o=-1){let l={ctx:this.ctx,runCommand:(c,f,d,p,m,h,b)=>this.runCommand(c,f,d,p,m,h,b),buildExportedEnv:()=>this.buildExportedEnv(),executeUserScript:(c,f,d)=>this.executeUserScript(c,f,d??S())},u=await zi(l,t,s,r,n,i,a,o);return u!==null?u:ji(l,t,s,n,a)}aliasExpansionStack=new Set;expandAlias(t){return sr(this.ctx.state,t,this.aliasExpansionStack)}async findCommandInPath(t){return Is(this.ctx,t)}async executeSubshell(t,s=S()){return eo(this.ctx,t,s,r=>this.executeStatement(r))}async executeGroup(t,s=S()){return to(this.ctx,t,s,r=>this.executeStatement(r))}async executeArithmeticCommand(t){t.line!==void 0&&(this.ctx.state.currentLine=t.line);let s=this.ctx.outputChannels,r=await De(this.ctx,s,t.redirections);if(r.error)return K(this.ctx,r.channels,()=>se(this.ctx,()=>Promise.resolve(r.error)));let n=[1,2].filter(i=>{let a=s.bindings.get(i),o=r.channels.bindings.get(i);return a?.sink!==o?.sink||We(s,i)!==We(r.channels,i)});return K(this.ctx,r.channels,async()=>{let i;try{let a=await ee(this.ctx,t.expression.expression);i=le(a!==0)}catch(a){i=P(`bash: arithmetic expression: ${a.message}
687
+ `)}return n.length>0?se(this.ctx,()=>Promise.resolve(i),n):i})}async executeConditionalCommand(t){t.line!==void 0&&(this.ctx.state.currentLine=t.line);let s=this.ctx.outputChannels,r=await De(this.ctx,s,t.redirections);if(r.error)return K(this.ctx,r.channels,()=>se(this.ctx,()=>Promise.resolve(r.error)));let n=[1,2].filter(i=>{let a=s.bindings.get(i),o=r.channels.bindings.get(i);return a?.sink!==o?.sink||We(s,i)!==We(r.channels,i)});return K(this.ctx,r.channels,async()=>{let i;try{let a=await tt(this.ctx,t.expression);i=le(a)}catch(a){let o=a instanceof nt?1:2;i=P(`bash: conditional expression: ${a.message}
688
+ `,o)}return n.length>0?se(this.ctx,()=>Promise.resolve(i),n):i})}};var ge={maxCallDepth:100,maxCommandCount:1e4,maxLoopIterations:1e4,maxAwkIterations:1e4,maxSedIterations:1e4,maxJqIterations:1e4,maxSqliteTimeoutMs:5e3,maxPythonTimeoutMs:3e4,maxGlobOperations:1e5,maxStringLength:10485760,maxArrayElements:1e5,maxHeredocSize:10485760,maxSubstitutionDepth:50,maxConcurrentJobs:128};function ro(e){return e?{maxCallDepth:e.maxCallDepth??ge.maxCallDepth,maxCommandCount:e.maxCommandCount??ge.maxCommandCount,maxLoopIterations:e.maxLoopIterations??ge.maxLoopIterations,maxAwkIterations:e.maxAwkIterations??ge.maxAwkIterations,maxSedIterations:e.maxSedIterations??ge.maxSedIterations,maxJqIterations:e.maxJqIterations??ge.maxJqIterations,maxSqliteTimeoutMs:e.maxSqliteTimeoutMs??ge.maxSqliteTimeoutMs,maxPythonTimeoutMs:e.maxPythonTimeoutMs??ge.maxPythonTimeoutMs,maxGlobOperations:e.maxGlobOperations??ge.maxGlobOperations,maxStringLength:e.maxStringLength??ge.maxStringLength,maxArrayElements:e.maxArrayElements??ge.maxArrayElements,maxHeredocSize:e.maxHeredocSize??ge.maxHeredocSize,maxSubstitutionDepth:e.maxSubstitutionDepth??ge.maxSubstitutionDepth,maxConcurrentJobs:e.maxConcurrentJobs??ge.maxConcurrentJobs}:{...ge}}function no(e){try{let t=new URL(e);return{origin:t.origin,pathname:t.pathname,href:t.href}}catch{return null}}function Ka(e){let t=no(e);return t?{origin:t.origin,pathPrefix:t.pathname}:null}function Ya(e,t){let s=no(e);if(!s)return!1;let r=Ka(t);return!r||s.origin!==r.origin?!1:r.pathPrefix==="/"||r.pathPrefix===""?!0:s.pathname.startsWith(r.pathPrefix)}function tn(e,t){return!t||t.length===0?!1:t.some(s=>Ya(e,s))}var Ct=class extends Error{constructor(t){super(`Network access denied: URL not in allow-list: ${t}`),this.name="NetworkAccessDeniedError"}},At=class extends Error{constructor(t){super(`Too many redirects (max: ${t})`),this.name="TooManyRedirectsError"}},kt=class extends Error{constructor(t){super(`Redirect target not in allow-list: ${t}`),this.name="RedirectNotAllowedError"}},Fs=class extends Error{constructor(t,s){super(`HTTP method '${t}' not allowed. Allowed methods: ${s.join(", ")}`),this.name="MethodNotAllowedError"}},Xt=class extends Error{constructor(t){super(`Response body too large (max: ${t} bytes)`),this.name="ResponseTooLargeError"}};var Qa=20,el=3e4,tl=10485760,sl=["GET","HEAD"],rl=new Set(["GET","HEAD","OPTIONS"]),nl=new Set([301,302,303,307,308]);function sn(e){let t=e.maxRedirects??Qa,s=e.timeoutMs??el,r=e.maxResponseSize??tl,n=e.dangerouslyAllowFullInternetAccess?["GET","HEAD","POST","PUT","DELETE","PATCH","OPTIONS"]:e.allowedMethods??sl;function i(l){if(!e.dangerouslyAllowFullInternetAccess&&!tn(l,e.allowedUrlPrefixes??[]))throw new Ct(l)}function a(l){if(e.dangerouslyAllowFullInternetAccess)return;let u=l.toUpperCase();if(!n.includes(u))throw new Fs(u,n)}async function o(l,u={}){let c=u.method?.toUpperCase()??"GET";i(l),a(c);let f=l,d=0,p=u.followRedirects??!0,m=u.timeoutMs!==void 0?Math.min(u.timeoutMs,s):s;for(;;){let h=new AbortController,b=setTimeout(()=>h.abort(),m);try{let E={method:c,headers:u.headers,signal:h.signal,redirect:"manual"};u.body&&!rl.has(c)&&(E.body=u.body);let $=await fetch(f,E);if(nl.has($.status)&&p){let y=$.headers.get("location");if(!y)return await io($,f,r);let v=new URL(y,f).href;if(!e.dangerouslyAllowFullInternetAccess&&!tn(v,e.allowedUrlPrefixes??[]))throw new kt(v);if(d++,d>t)throw new At(t);f=v;continue}return await io($,f,r)}finally{clearTimeout(b)}}}return o}async function io(e,t,s){let r=Object.create(null);if(e.headers.forEach((i,a)=>{r[a.toLowerCase()]=i}),s>0){let i=e.headers.get("content-length");if(i){let a=parseInt(i,10);if(!Number.isNaN(a)&&a>s)throw new Xt(s)}}let n;if(s>0&&e.body){let i=e.body.getReader(),a=new TextDecoder,o=[],l=0;for(;;){let{done:u,value:c}=await i.read();if(u)break;if(l+=c.byteLength,l>s)throw i.cancel(),new Xt(s);o.push(a.decode(c,{stream:!0}))}o.push(a.decode()),n=o.join("")}else n=await e.text();return{status:e.status,statusText:e.statusText,headers:r,body:n,url:t}}var il=1e3,ol=64,al=globalThis.setTimeout.bind(globalThis),ll=globalThis.clearTimeout.bind(globalThis),Le=class{jobs=new Map;reapedWaitStatuses=new Map;reapedWaitLineages=new Map;options;nextPid=il;nextLineageId=1;highestJobNumber=0;runningJobs=0;disposed=!1;disposePromise;constructor(t={}){this.options=t}start(t,s,r){if(this.disposed)throw new Error("Cannot start a job on a disposed ProcessTable");let n=this.nextPid++,i=new AbortController,a=this.highestJobNumber+1,o={info:{pid:n,command:t,startedAt:Date.now(),state:"running"},jobNumber:a,lineageId:r,controller:i,promise:Promise.resolve(0)};return this.jobs.set(n,o),this.highestJobNumber=a,this.runningJobs++,o.promise=Promise.resolve().then(()=>s(n,i.signal)).catch(()=>i.signal.aborted?fn(i.signal.reason):1).then(l=>{this.jobs.get(n)===o&&this.runningJobs--,o.info={...o.info,state:"done",exitCode:l},o.controller=void 0,o.promise=void 0;try{Promise.resolve(this.options.onJobExit?.(n,l)).catch(()=>{})}catch{}return l}),n}list(){return[...this.jobs.values()].sort((t,s)=>t.jobNumber-s.jobNumber).map(t=>({...t.info}))}listJobs(t,s={}){let r=[...this.jobs.values()].sort((l,u)=>l.jobNumber-u.jobNumber),n=r.at(-1)?.info.pid,i=r.at(-2)?.info.pid,a=[],o=[];for(let l of r)t&&!t.has(l.info.pid)||s.runningOnly&&l.info.state!=="running"||s.stoppedOnly||s.changedOnly&&l.changedStateReported===l.info.state||(o.push({...l.info,jobNumber:l.jobNumber,marker:l.info.pid===n?"+":l.info.pid===i?"-":" "}),s.changedOnly&&(l.changedStateReported=l.info.state),l.info.state==="done"&&(a.push(l.info.pid),this.rememberWaitStatus(l.info.pid,l.info.exitCode??1,l.lineageId)));return this.deleteJobs(a),o}get(t){let s=this.jobs.get(t)?.info;return s?{...s}:void 0}kill(t,s,r){let n=this.jobs.get(t);return!n||n.info.state==="done"?!1:(s!=="SIGSTOP"&&s!=="SIGCONT"&&n.controller?.abort(r??s),!0)}async wait(t){if(t!==void 0){let n=this.jobs.get(t);if(!n)return this.reapedWaitStatuses.get(t)??127;let i=n.info.state==="done"?n.info.exitCode??1:await(n.promise??Promise.resolve(1));return this.jobs.get(t)===n&&(this.rememberWaitStatus(t,i,n.lineageId),this.deleteJobs([t])),i}let s=[...this.jobs.values()],r=new Set([...this.reapedWaitStatuses.keys(),...s.map(n=>n.info.pid)]);s.length>0&&(await Promise.all(s.map(n=>n.promise??Promise.resolve(n.info.exitCode??1))),this.deleteJobs(s.map(n=>n.info.pid)));for(let n of r)this.reapedWaitStatuses.delete(n),this.reapedWaitLineages.delete(n);return 0}async waitForLineage(t){let s=[...this.jobs.values()].filter(n=>n.lineageId===t),r=[...this.reapedWaitLineages.entries()].flatMap(([n,i])=>i===t?[n]:[]);s.length>0&&(await Promise.all(s.map(n=>n.promise??Promise.resolve(n.info.exitCode??1))),this.deleteJobs(s.map(n=>n.info.pid)));for(let n of[...r,...s.map(i=>i.info.pid)])this.reapedWaitStatuses.delete(n),this.reapedWaitLineages.delete(n);return 0}createLineageId(){return this.nextLineageId++}abortAll(t="SIGTERM"){for(let s of this.jobs.values())s.info.state==="running"&&s.controller?.abort(t)}dispose(){if(this.disposePromise)return this.disposePromise;this.disposed=!0;let t=[...this.jobs.values()],s=()=>{};this.disposePromise=new Promise(n=>{s=n}),this.abortAll("SIGKILL"),this.jobs.clear(),this.reapedWaitStatuses.clear(),this.reapedWaitLineages.clear(),this.highestJobNumber=0,this.runningJobs=0;let r=al(s,this.options.disposeTimeoutMs??1e3);return Promise.allSettled(t.flatMap(n=>n.promise?[n.promise]:[])).then(()=>{ll(r),s()}),this.disposePromise}get runningCount(){return this.runningJobs}getJobNumber(t){return this.jobs.get(t)?.jobNumber}canWait(t){return this.jobs.has(t)||this.reapedWaitStatuses.has(t)}resolveJobSpec(t){let s=[...this.jobs.values()].sort((i,a)=>i.jobNumber-a.jobNumber);if(t==="%+"||t==="%%")return s.at(-1)?.info.pid;if(t==="%-")return s.at(-2)?.info.pid;let r=/^%(\d+)$/.exec(t);if(!r)return;let n=Number.parseInt(r[1],10);return s.find(i=>i.jobNumber===n)?.info.pid}get observesOutput(){return this.options.onJobOutput!==void 0}observeOutput(t,s,r){try{Promise.resolve(this.options.onJobOutput?.(t,s,r)).catch(()=>{})}catch{}}rememberWaitStatus(t,s,r){if(this.reapedWaitStatuses.delete(t),this.reapedWaitLineages.delete(t),this.reapedWaitStatuses.set(t,s),this.reapedWaitLineages.set(t,r),this.reapedWaitStatuses.size>ol){let n=this.reapedWaitStatuses.keys().next().value;n!==void 0&&(this.reapedWaitStatuses.delete(n),this.reapedWaitLineages.delete(n))}}deleteJobs(t){let s=!1;for(let r of t){let n=this.jobs.get(r);n&&(this.jobs.delete(r),s||=n.jobNumber===this.highestJobNumber)}if(s){this.highestJobNumber=0;for(let r of this.jobs.values())this.highestJobNumber=Math.max(this.highestJobNumber,r.jobNumber)}}};function rn(){let e=[{prop:"Function",target:globalThis,violationType:"function_constructor",strategy:"throw",reason:"Function constructor allows arbitrary code execution"},{prop:"eval",target:globalThis,violationType:"eval",strategy:"throw",reason:"eval() allows arbitrary code execution"},{prop:"setTimeout",target:globalThis,violationType:"setTimeout",strategy:"throw",reason:"setTimeout with string argument allows code execution"},{prop:"setInterval",target:globalThis,violationType:"setInterval",strategy:"throw",reason:"setInterval with string argument allows code execution"},{prop:"setImmediate",target:globalThis,violationType:"setImmediate",strategy:"throw",reason:"setImmediate could be used to escape sandbox context"},{prop:"env",target:process,violationType:"process_env",strategy:"throw",reason:"process.env could leak sensitive environment variables"},{prop:"binding",target:process,violationType:"process_binding",strategy:"throw",reason:"process.binding provides access to native Node.js modules"},{prop:"_linkedBinding",target:process,violationType:"process_binding",strategy:"throw",reason:"process._linkedBinding provides access to native Node.js modules"},{prop:"dlopen",target:process,violationType:"process_dlopen",strategy:"throw",reason:"process.dlopen allows loading native addons"},{prop:"WeakRef",target:globalThis,violationType:"weak_ref",strategy:"throw",reason:"WeakRef could be used to leak references outside sandbox"},{prop:"FinalizationRegistry",target:globalThis,violationType:"finalization_registry",strategy:"throw",reason:"FinalizationRegistry could be used to leak references outside sandbox"},{prop:"Reflect",target:globalThis,violationType:"reflect",strategy:"freeze",reason:"Reflect provides introspection capabilities"},{prop:"Proxy",target:globalThis,violationType:"proxy",strategy:"throw",reason:"Proxy allows intercepting and modifying object behavior"},{prop:"WebAssembly",target:globalThis,violationType:"webassembly",strategy:"throw",reason:"WebAssembly allows executing arbitrary compiled code"},{prop:"SharedArrayBuffer",target:globalThis,violationType:"shared_array_buffer",strategy:"throw",reason:"SharedArrayBuffer could enable side-channel communication or timing attacks"},{prop:"Atomics",target:globalThis,violationType:"atomics",strategy:"throw",reason:"Atomics could enable side-channel communication or timing attacks"}];try{let t=Object.getPrototypeOf(async()=>{}).constructor;t&&t!==Function&&e.push({prop:"constructor",target:Object.getPrototypeOf(async()=>{}),violationType:"async_function_constructor",strategy:"throw",reason:"AsyncFunction constructor allows arbitrary async code execution"})}catch{}try{let t=Object.getPrototypeOf(function*(){}).constructor;t&&t!==Function&&e.push({prop:"constructor",target:Object.getPrototypeOf(function*(){}),violationType:"generator_function_constructor",strategy:"throw",reason:"GeneratorFunction constructor allows arbitrary generator code execution"})}catch{}try{let t=Object.getPrototypeOf(async function*(){}).constructor;t&&t!==Function&&t!==Object.getPrototypeOf(async()=>{}).constructor&&e.push({prop:"constructor",target:Object.getPrototypeOf(async function*(){}),violationType:"async_generator_function_constructor",strategy:"throw",reason:"AsyncGeneratorFunction constructor allows arbitrary async generator code execution"})}catch{}return e.filter(t=>{try{return t.target[t.prop]!==void 0}catch{return!1}})}var Jt=typeof __BROWSER__<"u"&&__BROWSER__;function oo(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}var on=null;if(!Jt)try{let e="node:module",{createRequire:t}=await import(e);on=t(import.meta.url)("node:async_hooks").AsyncLocalStorage}catch(e){console.debug("[DefenseInDepthBox] AsyncLocalStorage not available, defense-in-depth disabled:",e instanceof Error?e.message:e)}var cl=`
689
+
690
+ This is a defense-in-depth measure and indicates a bug in just-bash. Please report this at security@vercel.com`,ye=class extends Error{violation;constructor(t,s){super(t+cl),this.violation=s,this.name="SecurityViolationError"}},$e=!Jt&&on?new on:null,ul=1e3,nn={enabled:!0,auditMode:!1};function fl(e){return e===void 0?{...nn,enabled:!1}:typeof e=="boolean"?{...nn,enabled:e}:{...nn,...e}}var xt=class e{static instance=null;config;refCount=0;originalDescriptors=[];violations=[];activationTime=0;totalActiveTimeMs=0;constructor(t){this.config=t}static getInstance(t){return e.instance||(e.instance=new e(fl(t))),e.instance}static resetInstance(){e.instance&&(e.instance.forceDeactivate(),e.instance=null)}static isInSandboxedContext(){return $e?$e?.getStore()?.sandboxActive===!0:!1}static getCurrentExecutionId(){if($e)return $e?.getStore()?.executionId}updateConfig(t){this.config={...this.config,...t}}activate(){if(Jt||!this.config.enabled){let s=oo();return{run:r=>r(),deactivate:()=>{},executionId:s}}this.refCount++,this.refCount===1&&(this.applyPatches(),this.activationTime=Date.now());let t=oo();return{run:s=>$e.run({sandboxActive:!0,executionId:t},s),deactivate:()=>{this.refCount--,this.refCount===0&&(this.restorePatches(),this.totalActiveTimeMs+=Date.now()-this.activationTime),this.refCount<0&&(this.refCount=0)},executionId:t}}forceDeactivate(){this.refCount>0&&(this.restorePatches(),this.totalActiveTimeMs+=Date.now()-this.activationTime),this.refCount=0}isActive(){return this.refCount>0}getStats(){return{violationsBlocked:this.violations.length,violations:[...this.violations],activeTimeMs:this.totalActiveTimeMs+(this.refCount>0?Date.now()-this.activationTime:0),refCount:this.refCount}}clearViolations(){this.violations=[]}getPathForTarget(t,s){return t===globalThis?`globalThis.${s}`:t===process?`process.${s}`:t===Error?`Error.${s}`:t===Function.prototype?`Function.prototype.${s}`:t===Object.prototype?`Object.prototype.${s}`:`<object>.${s}`}shouldBlock(){return Jt||this.config.auditMode||!$e?!1:$e?.getStore()?.sandboxActive===!0}recordViolation(t,s,r){let n={timestamp:Date.now(),type:t,message:r,path:s,stack:new Error().stack,executionId:$e?.getStore()?.executionId};if(this.violations.length<ul&&this.violations.push(n),this.config.onViolation)try{this.config.onViolation(n)}catch(i){console.debug("[DefenseInDepthBox] onViolation callback threw:",i instanceof Error?i.message:i)}return n}createBlockingProxy(t,s,r){let n=this;return new Proxy(t,{apply(i,a,o){if(n.shouldBlock()){let l=`${s} is blocked during script execution`,u=n.recordViolation(r,s,l);throw new ye(l,u)}return n.config.auditMode&&$e?.getStore()?.sandboxActive===!0&&n.recordViolation(r,s,`${s} called (audit mode)`),Reflect.apply(i,a,o)},construct(i,a,o){if(n.shouldBlock()){let l=`${s} constructor is blocked during script execution`,u=n.recordViolation(r,s,l);throw new ye(l,u)}return n.config.auditMode&&$e?.getStore()?.sandboxActive===!0&&n.recordViolation(r,s,`${s} constructor called (audit mode)`),Reflect.construct(i,a,o)}})}createBlockingObjectProxy(t,s,r){let n=this;return new Proxy(t,{get(i,a,o){if(n.shouldBlock()){let l=`${s}.${String(a)}`,u=`${l} is blocked during script execution`,c=n.recordViolation(r,l,u);throw new ye(u,c)}if(n.config.auditMode&&$e?.getStore()?.sandboxActive===!0){let l=`${s}.${String(a)}`;n.recordViolation(r,l,`${l} accessed (audit mode)`)}return Reflect.get(i,a,o)},set(i,a,o,l){if(n.shouldBlock()){let u=`${s}.${String(a)}`,c=`${u} modification is blocked during script execution`,f=n.recordViolation(r,u,c);throw new ye(c,f)}return Reflect.set(i,a,o,l)},ownKeys(i){if(n.shouldBlock()){let a=`${s} enumeration is blocked during script execution`,o=n.recordViolation(r,s,a);throw new ye(a,o)}return Reflect.ownKeys(i)},getOwnPropertyDescriptor(i,a){if(n.shouldBlock()){let o=`${s}.${String(a)}`,l=`${o} descriptor access is blocked during script execution`,u=n.recordViolation(r,o,l);throw new ye(l,u)}return Reflect.getOwnPropertyDescriptor(i,a)},has(i,a){if(n.shouldBlock()){let o=`${s}.${String(a)}`,l=`${o} existence check is blocked during script execution`,u=n.recordViolation(r,o,l);throw new ye(l,u)}return Reflect.has(i,a)}})}applyPatches(){let t=rn();for(let s of t)this.applyPatch(s);this.protectConstructorChain(),this.protectErrorPrepareStackTrace(),this.protectModuleLoad(),this.protectProcessMainModule()}protectConstructorChain(){this.patchPrototypeConstructor(Function.prototype,"Function.prototype.constructor","function_constructor");try{let t=Object.getPrototypeOf(async()=>{}).constructor;t&&t!==Function&&this.patchPrototypeConstructor(t.prototype,"AsyncFunction.prototype.constructor","async_function_constructor")}catch(t){console.debug("[DefenseInDepthBox] Could not patch AsyncFunction.prototype.constructor:",t instanceof Error?t.message:t)}try{let t=Object.getPrototypeOf(function*(){}).constructor;t&&t!==Function&&this.patchPrototypeConstructor(t.prototype,"GeneratorFunction.prototype.constructor","generator_function_constructor")}catch(t){console.debug("[DefenseInDepthBox] Could not patch GeneratorFunction.prototype.constructor:",t instanceof Error?t.message:t)}try{let t=Object.getPrototypeOf(async function*(){}).constructor,s=Object.getPrototypeOf(async()=>{}).constructor;t&&t!==Function&&t!==s&&this.patchPrototypeConstructor(t.prototype,"AsyncGeneratorFunction.prototype.constructor","async_generator_function_constructor")}catch(t){console.debug("[DefenseInDepthBox] Could not patch AsyncGeneratorFunction.prototype.constructor:",t instanceof Error?t.message:t)}}protectErrorPrepareStackTrace(){let t=this;try{let s=Object.getOwnPropertyDescriptor(Error,"prepareStackTrace");this.originalDescriptors.push({target:Error,prop:"prepareStackTrace",descriptor:s});let r=s?.value;Object.defineProperty(Error,"prepareStackTrace",{get(){return r},set(n){if(t.shouldBlock()){let i="Error.prepareStackTrace modification is blocked during script execution",a=t.recordViolation("error_prepare_stack_trace","Error.prepareStackTrace",i);throw new ye(i,a)}t.config.auditMode&&$e?.getStore()?.sandboxActive===!0&&t.recordViolation("error_prepare_stack_trace","Error.prepareStackTrace","Error.prepareStackTrace set (audit mode)"),r=n},configurable:!0})}catch(s){console.debug("[DefenseInDepthBox] Could not protect Error.prepareStackTrace:",s instanceof Error?s.message:s)}}patchPrototypeConstructor(t,s,r){let n=this;try{let i=Object.getOwnPropertyDescriptor(t,"constructor");this.originalDescriptors.push({target:t,prop:"constructor",descriptor:i});let a=i?.value;Object.defineProperty(t,"constructor",{get(){if(n.shouldBlock()){let o=`${s} access is blocked during script execution`,l=n.recordViolation(r,s,o);throw new ye(o,l)}return n.config.auditMode&&$e?.getStore()?.sandboxActive===!0&&n.recordViolation(r,s,`${s} accessed (audit mode)`),a},set(o){if(n.shouldBlock()){let l=`${s} modification is blocked during script execution`,u=n.recordViolation(r,s,l);throw new ye(l,u)}Object.defineProperty(this,"constructor",{value:o,writable:!0,configurable:!0})},configurable:!0})}catch(i){console.debug(`[DefenseInDepthBox] Could not patch ${s}:`,i instanceof Error?i.message:i)}}protectProcessMainModule(){if(typeof process>"u")return;let t=this;try{let s=Object.getOwnPropertyDescriptor(process,"mainModule");this.originalDescriptors.push({target:process,prop:"mainModule",descriptor:s});let r=s?.value;r!==void 0&&Object.defineProperty(process,"mainModule",{get(){if(t.shouldBlock()){let n="process.mainModule access is blocked during script execution",i=t.recordViolation("process_main_module","process.mainModule",n);throw new ye(n,i)}return t.config.auditMode&&$e?.getStore()?.sandboxActive===!0&&t.recordViolation("process_main_module","process.mainModule","process.mainModule accessed (audit mode)"),r},set(n){if(t.shouldBlock()){let i="process.mainModule modification is blocked during script execution",a=t.recordViolation("process_main_module","process.mainModule",i);throw new ye(i,a)}Object.defineProperty(process,"mainModule",{value:n,writable:!0,configurable:!0})},configurable:!0})}catch(s){console.debug("[DefenseInDepthBox] Could not protect process.mainModule:",s instanceof Error?s.message:s)}}protectModuleLoad(){if(!Jt)try{let t=null;if(typeof process<"u"){let a=process.mainModule;a&&typeof a=="object"&&(t=a.constructor)}if(!t&&typeof Dt<"u"&&typeof Dt.main<"u"&&(t=Dt.main.constructor),!t||typeof t._load!="function")return;let s=t._load,r=Object.getOwnPropertyDescriptor(t,"_load");this.originalDescriptors.push({target:t,prop:"_load",descriptor:r});let i=this.createBlockingProxy(s,"Module._load","module_load");Object.defineProperty(t,"_load",{value:i,writable:!0,configurable:!0})}catch(t){console.debug("[DefenseInDepthBox] Could not protect Module._load:",t instanceof Error?t.message:t)}}applyPatch(t){let{target:s,prop:r,violationType:n,strategy:i}=t;try{let a=s[r];if(a===void 0)return;let o=Object.getOwnPropertyDescriptor(s,r);if(this.originalDescriptors.push({target:s,prop:r,descriptor:o}),i==="freeze")typeof a=="object"&&a!==null&&Object.freeze(a);else{let l=this.getPathForTarget(s,r),u=typeof a=="function"?this.createBlockingProxy(a,l,n):this.createBlockingObjectProxy(a,l,n);Object.defineProperty(s,r,{value:u,writable:!0,configurable:!0})}}catch(a){let o=this.getPathForTarget(s,r);console.debug(`[DefenseInDepthBox] Could not patch ${o}:`,a instanceof Error?a.message:a)}}restorePatches(){for(let t=this.originalDescriptors.length-1;t>=0;t--){let{target:s,prop:r,descriptor:n}=this.originalDescriptors[t];try{n?Object.defineProperty(s,r,n):delete s[r]}catch(i){let a=this.getPathForTarget(s,r);console.debug(`[DefenseInDepthBox] Could not restore ${a}:`,i instanceof Error?i.message:i)}}this.originalDescriptors=[]}};var dl=globalThis.setTimeout.bind(globalThis),Kt=class{fs;processes;commands=new Map;useDefaultLayout=!1;limits;secureFetch;sleepFn;traceFn;logger;defenseInDepthConfig;coverageWriter;state;constructor(t={}){let s=t.fs??new Xe(t.files);this.fs=s,this.processes=t.processes??new Le,this.useDefaultLayout=!t.cwd&&!t.files;let r=t.cwd||(this.useDefaultLayout?"/home/user":"/"),n=new Map,i=[["HOME",this.useDefaultLayout?"/home/user":"/"],["PATH","/usr/bin:/bin"],["IFS",`
691
+ `],["OSTYPE","linux-gnu"],["MACHTYPE","x86_64-pc-linux-gnu"],["HOSTTYPE","x86_64"],["HOSTNAME","localhost"],["PWD",r],["OLDPWD",r],["OPTIND","1"]];for(let[a,o]of i)g(n,a,o);for(let[a,o]of Object.entries(t.env??{}))g(n,a,o);if(this.limits=ro({...t.executionLimits,...t.maxCallDepth!==void 0&&{maxCallDepth:t.maxCallDepth},...t.maxCommandCount!==void 0&&{maxCommandCount:t.maxCommandCount},...t.maxLoopIterations!==void 0&&{maxLoopIterations:t.maxLoopIterations}}),t.network&&(this.secureFetch=sn(t.network)),this.sleepFn=t.sleep,this.traceFn=t.trace,this.logger=t.logger,this.defenseInDepthConfig=t.defenseInDepth,this.coverageWriter=t.coverage,this.state={env:n,cwd:r,previousDir:"/home/user",functions:new Map,localScopes:[],callDepth:0,sourceDepth:0,commandCount:0,lastExitCode:0,lastArg:R,startTime:Date.now(),lastBackgroundPid:0,bashPid:Us().pid,nextVirtualPid:Us().pid+1,currentLine:1,options:{errexit:!1,pipefail:!1,nounset:!1,xtrace:!1,verbose:!1,posix:!1,allexport:!1,noclobber:!1,noglob:!1,noexec:!1,vi:!1,emacs:!1},shoptOptions:{extglob:!1,dotglob:!1,nullglob:!1,failglob:!1,globstar:!1,globskipdots:!0,nocaseglob:!1,nocasematch:!1,expand_aliases:!1,lastpipe:!1,xpg_echo:!1},inCondition:!1,loopDepth:0,exportedVars:new Set(["HOME","PATH","PWD","OLDPWD",...Object.keys(t.env||{})]),readonlyVars:new Set(["SHELLOPTS","BASHOPTS"]),hashTable:new Map},g(this.state.env,"SHELLOPTS",Qs(this.state.options)),g(this.state.env,"BASHOPTS",er(this.state.shoptOptions)),Fn(s,this.useDefaultLayout),r!=="/"&&s instanceof Xe)try{s.mkdirSync(r,{recursive:!0})}catch{}for(let a of Nn(t.commands))this.registerCommand(a);if(t.network)for(let a of On())this.registerCommand(a);if(t.python)for(let a of Dn())this.registerCommand(a);if(t.customCommands)for(let a of t.customCommands)In(a)?this.registerCommand(Rn(a)):this.registerCommand(a)}registerCommand(t){this.commands.set(t.name,t);let s=this.fs;if(typeof s.writeFileSync=="function"){let r=`#!/bin/bash
676
692
  # Built-in command: ${t.name}
677
- `;try{s.writeFileSync(`/bin/${t.name}`,r)}catch{}try{s.writeFileSync(`/usr/bin/${t.name}`,r)}catch{}}}async logResult(t){if(!this.logger)return t;let s=this.logger,[r,n]=Tt(t.stdout),[i,o]=Tt(t.stderr),[a,l]=await Promise.all([Ge(n),Ge(o)]);return a.length>0&&s.debug("stdout",{output:a}),l.length>0&&s.info("stderr",{output:l}),s.info("exit",{exitCode:t.exitCode}),{...t,stdout:r,stderr:i}}async exec(t,s){if(this.state.callDepth===0&&(this.state.commandCount=0),this.state.commandCount++,this.state.commandCount>this.limits.maxCommandCount)return{stdout:w(),stderr:C(`bash: maximum command count (${this.limits.maxCommandCount}) exceeded (possible infinite loop). Increase with executionLimits.maxCommandCount option.
678
- `),exitCode:1,env:_e(this.state.env,s?.env)};if(!t.trim())return{stdout:w(),stderr:w(),exitCode:0,env:_e(this.state.env,s?.env)};this.logger?.info("exec",{command:t});let r=s?.cwd??this.state.cwd,n,i=r;if(s?.cwd)if(s.env&&"PWD"in s.env)n=s.env.PWD;else if(s?.env&&!("PWD"in s.env))try{n=await this.fs.realpath(r),i=n}catch{n=r}else n=r;let o=new Map(this.state.env);if(s?.env)for(let[f,h]of Object.entries(s.env))g(o,f,h);n!==void 0&&g(o,"PWD",n);let a={...this.state,env:o,cwd:i,functions:new Map(this.state.functions),localScopes:[...this.state.localScopes],options:{...this.state.options},hashTable:this.state.hashTable,groupStdin:s?.stdin||void 0},l=t;s?.rawScript||(l=pa(t));let c=(this.defenseInDepthConfig?pt.getInstance(this.defenseInDepthConfig):null)?.activate();try{let f=async()=>{let h=Te(l),d={fs:this.fs,commands:this.commands,limits:this.limits,exec:this.exec.bind(this),fetch:this.secureFetch,sleep:this.sleepFn,trace:this.traceFn,coverage:this.coverageWriter},p=await new _t(d,a).executeScript(h);return this.logResult(p)};return c?await c.run(f):await f()}catch(f){if(f instanceof Y)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:_e(this.state.env,s?.env)});if(f instanceof ke)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:_e(this.state.env,s?.env)});if(f instanceof qe)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:1,env:_e(this.state.env,s?.env)});if(f instanceof de)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:de.EXIT_CODE,env:_e(this.state.env,s?.env)});if(f instanceof ue)return this.logResult({stdout:w(),stderr:C(`bash: security violation: ${f.message}
679
- `),exitCode:1,env:_e(this.state.env,s?.env)});if(f.name==="ParseException")return this.logResult({stdout:w(),stderr:C(`bash: syntax error: ${f.message}
680
- `),exitCode:2,env:_e(this.state.env,s?.env)});if(f instanceof Or)return this.logResult({stdout:w(),stderr:C(`bash: ${f.message}
681
- `),exitCode:2,env:_e(this.state.env,s?.env)});if(f instanceof RangeError)return this.logResult({stdout:w(),stderr:C(`bash: ${f.message}
682
- `),exitCode:1,env:_e(this.state.env,s?.env)});throw f}finally{c?.deactivate()}}async readFile(t){return this.fs.readFileText(this.fs.resolvePath(this.state.cwd,t))}async writeFile(t,s){return this.fs.writeFile(this.fs.resolvePath(this.state.cwd,t),s)}getCwd(){return this.state.cwd}getEnv(){return Be(this.state.env)}};function pa(e){let t=e.split(`
683
- `),s=[],r=[];for(let n=0;n<t.length;n++){let i=t[n];if(r.length>0){let l=r[r.length-1];if((l.stripTabs?i.replace(/^\t+/,""):i)===l.delimiter){s.push(i.trimStart()),r.pop();continue}s.push(i);continue}let o=i.trimStart();s.push(o);let a=/<<(-?)\s*(['"]?)([\w-]+)\2/g;for(let l of o.matchAll(a)){let u=l[1]==="-",c=l[3];r.push({delimiter:c,stripTabs:u})}}return s.join(`
684
- `)}var ds=class{baseFs;mounts=new Map;constructor(t){if(this.baseFs=t?.base??new We,t?.mounts)for(let{mountPoint:s,filesystem:r}of t.mounts)this.mount(s,r)}mount(t,s){this.validateMountPath(t);let r=this.normalizePath(t);this.validateMount(r),this.mounts.set(r,{mountPoint:r,filesystem:s})}unmount(t){let s=this.normalizePath(t);if(!this.mounts.has(s))throw new Error(`No filesystem mounted at '${t}'`);this.mounts.delete(s)}getMounts(){return Array.from(this.mounts.values()).map(t=>({mountPoint:t.mountPoint,filesystem:t.filesystem}))}isMountPoint(t){let s=this.normalizePath(t);return this.mounts.has(s)}validateMountPath(t){let s=t.split("/");for(let r of s)if(r==="."||r==="..")throw new Error(`Invalid mount point '${t}': contains '.' or '..' segments`)}validateMount(t){if(t==="/")throw new Error("Cannot mount at root '/'");for(let s of this.mounts.keys())if(s!==t){if(t.startsWith(`${s}/`))throw new Error(`Cannot mount at '${t}': inside existing mount '${s}'`);if(s.startsWith(`${t}/`))throw new Error(`Cannot mount at '${t}': would contain existing mount '${s}'`)}}normalizePath(t){if(!t||t==="/")return"/";let s=t.endsWith("/")&&t!=="/"?t.slice(0,-1):t;s.startsWith("/")||(s=`/${s}`);let r=s.split("/").filter(i=>i&&i!=="."),n=[];for(let i of r)i===".."?n.pop():n.push(i);return`/${n.join("/")}`}routePath(t){let s=this.normalizePath(t),r=null,n=0;for(let i of this.mounts.values()){let o=i.mountPoint;if(s===o)return{fs:i.filesystem,relativePath:"/"};s.startsWith(`${o}/`)&&o.length>n&&(r=i,n=o.length)}if(r){let i=s.slice(n);return{fs:r.filesystem,relativePath:i||"/"}}return{fs:this.baseFs,relativePath:s}}getChildMountPoints(t){let s=this.normalizePath(t),r=s==="/"?"/":`${s}/`,n=[];for(let i of this.mounts.keys())if(i.startsWith(r)){let a=i.slice(r.length).split("/")[0];a&&!n.includes(a)&&n.push(a)}return n}async readFile(t){let{fs:s,relativePath:r}=this.routePath(t);return s.readFile(r)}async readRange(t,s,r){let{fs:n,relativePath:i}=this.routePath(t);return n.readRange(i,s,r)}async readFileText(t,s){let{fs:r,relativePath:n}=this.routePath(t);return r.readFileText(n,s)}async writeFile(t,s,r){let{fs:n,relativePath:i}=this.routePath(t);return n.writeFile(i,s,r)}async appendFile(t,s,r){let{fs:n,relativePath:i}=this.routePath(t);return n.appendFile(i,s,r)}async exists(t){let s=this.normalizePath(t);if(this.mounts.has(s)||this.getChildMountPoints(s).length>0)return!0;let{fs:n,relativePath:i}=this.routePath(t);return n.exists(i)}async stat(t){let s=this.normalizePath(t),r=this.mounts.get(s);if(r)try{return await r.filesystem.stat("/")}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}if(this.getChildMountPoints(s).length>0)try{return await this.baseFs.stat(s)}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}let{fs:i,relativePath:o}=this.routePath(t);return i.stat(o)}async lstat(t){let s=this.normalizePath(t),r=this.mounts.get(s);if(r)try{return await r.filesystem.lstat("/")}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}if(this.getChildMountPoints(s).length>0)try{return await this.baseFs.lstat(s)}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}let{fs:i,relativePath:o}=this.routePath(t);return i.lstat(o)}async mkdir(t,s){let r=this.normalizePath(t);if(this.mounts.has(r)){if(s?.recursive)return;throw new Error(`EEXIST: directory already exists, mkdir '${t}'`)}if(this.getChildMountPoints(r).length>0&&s?.recursive)return;let{fs:i,relativePath:o}=this.routePath(t);return i.mkdir(o,s)}async readdir(t){let s=this.normalizePath(t),r=new Set,n=null,{fs:i,relativePath:o}=this.routePath(t);try{let l=await i.readdir(o);for(let u of l)r.add(u)}catch(l){let u=l.code,c=l.message||"";if(u!=="ENOENT"&&!c.includes("ENOENT"))throw l;n=l}let a=this.getChildMountPoints(s);for(let l of a)r.add(l);if(r.size===0&&n&&!this.mounts.has(s))throw n;return Array.from(r).sort()}async rm(t,s){let r=this.normalizePath(t);if(this.mounts.has(r))throw new Error(`EBUSY: mount point, cannot remove '${t}'`);if(this.getChildMountPoints(r).length>0)throw new Error(`EBUSY: contains mount points, cannot remove '${t}'`);let{fs:i,relativePath:o}=this.routePath(t);return i.rm(o,s)}async cp(t,s,r){let n=this.routePath(t),i=this.routePath(s);return n.fs===i.fs?n.fs.cp(n.relativePath,i.relativePath,r):this.crossMountCopy(t,s,r)}async mv(t,s){let r=this.normalizePath(t);if(this.mounts.has(r))throw new Error(`EBUSY: mount point, cannot move '${t}'`);let n=this.routePath(t),i=this.routePath(s);if(n.fs===i.fs)return n.fs.mv(n.relativePath,i.relativePath);await this.cp(t,s,{recursive:!0}),await this.rm(t,{recursive:!0})}resolvePath(t,s){if(s.startsWith("/"))return this.normalizePath(s);let r=t==="/"?`/${s}`:`${t}/${s}`;return this.normalizePath(r)}getAllPaths(){let t=new Set;for(let s of this.baseFs.getAllPaths())t.add(s);for(let s of this.mounts.keys()){let r=s.split("/").filter(Boolean),n="";for(let o of r)n=`${n}/${o}`,t.add(n);let i=this.mounts.get(s);if(i)for(let o of i.filesystem.getAllPaths())o==="/"?t.add(s):t.add(`${s}${o}`)}return Array.from(t).sort()}async chmod(t,s){let r=this.normalizePath(t),n=this.mounts.get(r);if(n)return n.filesystem.chmod("/",s);let{fs:i,relativePath:o}=this.routePath(t);return i.chmod(o,s)}async symlink(t,s){let{fs:r,relativePath:n}=this.routePath(s);return r.symlink(t,n)}async link(t,s){let r=this.routePath(t),n=this.routePath(s);if(r.fs!==n.fs)throw new Error(`EXDEV: cross-device link not permitted, link '${t}' -> '${s}'`);return r.fs.link(r.relativePath,n.relativePath)}async readlink(t){let{fs:s,relativePath:r}=this.routePath(t);return s.readlink(r)}async realpath(t){let s=this.normalizePath(t);if(this.mounts.get(s))return s;let{fs:n,relativePath:i}=this.routePath(t),o=await n.realpath(i);for(let[a,l]of this.mounts)if(s===a||s.startsWith(`${a}/`))return o==="/"?a:`${a}${o}`;return o}async crossMountCopy(t,s,r){let n=await this.lstat(t);if(n.isFile){let i=await this.readFile(t);await this.writeFile(s,i),await this.chmod(s,n.mode)}else if(n.isDirectory){if(!r?.recursive)throw new Error(`cp: ${t} is a directory (not copied)`);await this.mkdir(s,{recursive:!0});let i=await this.readdir(t);for(let o of i){let a=t==="/"?`/${o}`:`${t}/${o}`,l=s==="/"?`/${o}`:`${s}/${o}`;await this.crossMountCopy(a,l,r)}}else if(n.isSymbolicLink){let i=await this.readlink(t);await this.symlink(i,s)}}async utimes(t,s,r){let{fs:n,relativePath:i}=this.routePath(t);return n.utimes(i,s,r)}};import*as ee from"node:fs";import*as mt from"node:path";var ma="/home/user/project";function le(e,t){if(e.includes("\0"))throw new Error(`ENOENT: path contains null byte, ${t} '${e}'`)}var yt=class{root;mountPoint;readOnly;maxFileReadSize;memory=new Map;deleted=new Set;constructor(t){this.root=mt.resolve(t.root);let s=t.mountPoint??ma;if(this.mountPoint=s==="/"?"/":s.replace(/\/+$/,""),!this.mountPoint.startsWith("/"))throw new Error(`Mount point must be an absolute path: ${s}`);if(this.readOnly=t.readOnly??!1,this.maxFileReadSize=t.maxFileReadSize??10485760,!ee.existsSync(this.root))throw new Error(`OverlayFs root does not exist: ${this.root}`);if(!ee.statSync(this.root).isDirectory())throw new Error(`OverlayFs root is not a directory: ${this.root}`);this.createMountPointDirs()}assertWritable(t){if(this.readOnly)throw new Error(`EROFS: read-only file system, ${t}`)}createMountPointDirs(){let t=this.mountPoint.split("/").filter(Boolean),s="";for(let r of t)s+=`/${r}`,this.memory.has(s)||this.memory.set(s,{type:"directory",mode:493,mtime:new Date});this.memory.has("/")||this.memory.set("/",{type:"directory",mode:493,mtime:new Date})}getMountPoint(){return this.mountPoint}mkdirSync(t,s){let n=this.normalizePath(t).split("/").filter(Boolean),i="";for(let o of n)i+=`/${o}`,this.memory.has(i)||this.memory.set(i,{type:"directory",mode:493,mtime:new Date})}writeFileSync(t,s){let r=this.normalizePath(t),n=this.getDirname(r);n!=="/"&&this.mkdirSync(n);let{chunks:i,size:o}=st(s);this.memory.set(r,{type:"file",chunks:i,size:o,mode:420,mtime:new Date})}getDirname(t){let s=t.lastIndexOf("/");return s===0?"/":t.slice(0,s)}normalizePath(t){if(!t||t==="/")return"/";let s=t.endsWith("/")&&t!=="/"?t.slice(0,-1):t;s.startsWith("/")||(s=`/${s}`);let r=s.split("/").filter(i=>i&&i!=="."),n=[];for(let i of r)i===".."?n.pop():n.push(i);return`/${n.join("/")}`||"/"}getRelativeToMount(t){return this.mountPoint==="/"?t:t===this.mountPoint?"/":t.startsWith(`${this.mountPoint}/`)?t.slice(this.mountPoint.length):null}toRealPath(t){let s=this.normalizePath(t),r=this.getRelativeToMount(s);if(r===null)return null;let n=mt.join(this.root,r),i=mt.resolve(n);return!i.startsWith(this.root)&&i!==this.root.replace(/\/$/,"")?null:i}dirname(t){let s=this.normalizePath(t);if(s==="/")return"/";let r=s.lastIndexOf("/");return r===0?"/":s.slice(0,r)}ensureParentDirs(t){let s=this.dirname(t);s!=="/"&&(this.memory.has(s)||(this.ensureParentDirs(s),this.memory.set(s,{type:"directory",mode:493,mtime:new Date})),this.deleted.delete(s))}async existsInOverlay(t){let s=this.normalizePath(t);if(this.deleted.has(s))return!1;if(this.memory.has(s))return!0;let r=this.toRealPath(s);if(!r)return!1;try{return await ee.promises.access(r),!0}catch{return!1}}async readFile(t){let s=await this.readFileChunks(t);return he(s)}async readRange(t,s,r){rt(s,r);let n=await this.resolveForRead(t);if(n.kind==="memory")return Vt(n.chunks,n.size,s,r);if(r===0||s>=n.size)return new Uint8Array(0);let i=Math.min(r,n.size-s),o=new Uint8Array(i),a=await ee.promises.open(n.realPath,"r");try{let{bytesRead:l}=await a.read(o,0,i,s);return l===i?o:o.subarray(0,l)}finally{await a.close()}}async resolveForRead(t,s=new Set){le(t,"open");let r=this.normalizePath(t);if(s.has(r))throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`);if(s.add(r),this.deleted.has(r))throw new Error(`ENOENT: no such file or directory, open '${t}'`);let n=this.memory.get(r);if(n){if(n.type==="symlink"){let o=this.resolveSymlink(r,n.target);return this.resolveForRead(o,s)}if(n.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);return{kind:"memory",chunks:n.chunks,size:n.size}}let i=this.toRealPath(r);if(!i)throw new Error(`ENOENT: no such file or directory, open '${t}'`);try{let o=await ee.promises.lstat(i);if(o.isSymbolicLink()){let a=await ee.promises.readlink(i),l=this.resolveSymlink(r,a);return this.resolveForRead(l,s)}if(o.isDirectory())throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);if(this.maxFileReadSize>0&&o.size>this.maxFileReadSize)throw new Error(`EFBIG: file too large, read '${t}' (${o.size} bytes, max ${this.maxFileReadSize})`);return{kind:"real",realPath:i,size:o.size}}catch(o){throw o.code==="ENOENT"?new Error(`ENOENT: no such file or directory, open '${t}'`):o}}async readFileText(t,s){let r=await this.readFileChunks(t),n=$e(s);return Wt(r,n)}async readFileChunks(t,s=new Set){le(t,"open");let r=this.normalizePath(t);if(s.has(r))throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`);if(s.add(r),this.deleted.has(r))throw new Error(`ENOENT: no such file or directory, open '${t}'`);let n=this.memory.get(r);if(n){if(n.type==="symlink"){let o=this.resolveSymlink(r,n.target);return this.readFileChunks(o,s)}if(n.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);return n.chunks}let i=this.toRealPath(r);if(!i)throw new Error(`ENOENT: no such file or directory, open '${t}'`);try{let o=await ee.promises.lstat(i);if(o.isSymbolicLink()){let c=await ee.promises.readlink(i),f=this.resolveSymlink(r,c);return this.readFileChunks(f,s)}if(o.isDirectory())throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);if(this.maxFileReadSize>0&&o.size>this.maxFileReadSize)throw new Error(`EFBIG: file too large, read '${t}' (${o.size} bytes, max ${this.maxFileReadSize})`);let a=await ee.promises.readFile(i),l=new Uint8Array(a.buffer,a.byteOffset,a.byteLength),{chunks:u}=st(l);return u}catch(o){throw o.code==="ENOENT"?new Error(`ENOENT: no such file or directory, open '${t}'`):o}}async writeFile(t,s,r){le(t,"write"),this.assertWritable(`write '${t}'`);let n=this.normalizePath(t);this.ensureParentDirs(n);let i=$e(r),{chunks:o,size:a}=await ze(s,i);this.memory.set(n,{type:"file",chunks:o,size:a,mode:420,mtime:new Date}),this.deleted.delete(n)}async appendFile(t,s,r){le(t,"append"),this.assertWritable(`append '${t}'`);let n=this.normalizePath(t),i=$e(r),{chunks:o,size:a}=await ze(s,i),l=[],u=0;try{l=await this.readFileChunks(n);for(let c of l)u+=c.length}catch{}this.ensureParentDirs(n),this.memory.set(n,{type:"file",chunks:[...l,...o],size:u+a,mode:420,mtime:new Date}),this.deleted.delete(n)}async exists(t){return t.includes("\0")?!1:this.existsInOverlay(t)}async stat(t,s=new Set){le(t,"stat");let r=this.normalizePath(t);if(s.has(r))throw new Error(`ELOOP: too many levels of symbolic links, stat '${t}'`);if(s.add(r),this.deleted.has(r))throw new Error(`ENOENT: no such file or directory, stat '${t}'`);let n=this.memory.get(r);if(n){if(n.type==="symlink"){let a=this.resolveSymlink(r,n.target);return this.stat(a,s)}let o=0;return n.type==="file"&&(o=n.size),{isFile:n.type==="file",isDirectory:n.type==="directory",isSymbolicLink:!1,mode:n.mode,size:o,mtime:n.mtime}}let i=this.toRealPath(r);if(!i)throw new Error(`ENOENT: no such file or directory, stat '${t}'`);try{let o=await ee.promises.stat(i);return{isFile:o.isFile(),isDirectory:o.isDirectory(),isSymbolicLink:!1,mode:o.mode,size:o.size,mtime:o.mtime}}catch(o){throw o.code==="ENOENT"?new Error(`ENOENT: no such file or directory, stat '${t}'`):o}}async lstat(t){le(t,"lstat");let s=this.normalizePath(t);if(this.deleted.has(s))throw new Error(`ENOENT: no such file or directory, lstat '${t}'`);let r=this.memory.get(s);if(r){if(r.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:r.mode,size:r.target.length,mtime:r.mtime};let i=0;return r.type==="file"&&(i=r.size),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:i,mtime:r.mtime}}let n=this.toRealPath(s);if(!n)throw new Error(`ENOENT: no such file or directory, lstat '${t}'`);try{let i=await ee.promises.lstat(n);return{isFile:i.isFile(),isDirectory:i.isDirectory(),isSymbolicLink:i.isSymbolicLink(),mode:i.mode,size:i.size,mtime:i.mtime}}catch(i){throw i.code==="ENOENT"?new Error(`ENOENT: no such file or directory, lstat '${t}'`):i}}resolveSymlink(t,s){if(s.startsWith("/"))return this.normalizePath(s);let r=this.dirname(t);return this.normalizePath(r==="/"?`/${s}`:`${r}/${s}`)}async mkdir(t,s){le(t,"mkdir"),this.assertWritable(`mkdir '${t}'`);let r=this.normalizePath(t);if(await this.existsInOverlay(r)){if(!s?.recursive)throw new Error(`EEXIST: file already exists, mkdir '${t}'`);return}let i=this.dirname(r);if(i!=="/"&&!await this.existsInOverlay(i))if(s?.recursive)await this.mkdir(i,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${t}'`);this.memory.set(r,{type:"directory",mode:493,mtime:new Date}),this.deleted.delete(r)}async readdirCore(t,s){if(this.deleted.has(s))throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);let r=new Map,n=new Set,i=s==="/"?"/":`${s}/`;for(let a of this.deleted)if(a.startsWith(i)){let l=a.slice(i.length),u=l.split("/")[0];u&&!l.includes("/",u.length)&&n.add(u)}for(let[a,l]of this.memory)if(a!==s&&a.startsWith(i)){let u=a.slice(i.length),c=u.split("/")[0];c&&!n.has(c)&&!u.includes("/",1)&&r.set(c,{name:c,isFile:l.type==="file",isDirectory:l.type==="directory",isSymbolicLink:l.type==="symlink"})}let o=this.toRealPath(s);if(o)try{let a=await ee.promises.readdir(o,{withFileTypes:!0});for(let l of a)!n.has(l.name)&&!r.has(l.name)&&r.set(l.name,{name:l.name,isFile:l.isFile(),isDirectory:l.isDirectory(),isSymbolicLink:l.isSymbolicLink()})}catch(a){if(a.code==="ENOENT"){if(!this.memory.has(s))throw new Error(`ENOENT: no such file or directory, scandir '${t}'`)}else if(a.code!=="ENOTDIR")throw a}return r}async resolveForReaddir(t,s=!1){let r=this.normalizePath(t),n=new Set,i=s,o=this.memory.get(r);for(;o&&o.type==="symlink";){if(n.has(r))throw new Error(`ELOOP: too many levels of symbolic links, scandir '${t}'`);n.add(r),i=!0,r=this.resolveSymlink(r,o.target),o=this.memory.get(r)}if(o)return{normalized:r,outsideOverlay:!1};if(this.getRelativeToMount(r)===null)return{normalized:r,outsideOverlay:!0};let l=this.toRealPath(r);if(!l)return{normalized:r,outsideOverlay:!0};try{if((await ee.promises.lstat(l)).isSymbolicLink()){let c=await ee.promises.readlink(l),f=this.resolveSymlink(r,c);return this.resolveForReaddir(f,!0)}return{normalized:r,outsideOverlay:!1}}catch{return i?{normalized:r,outsideOverlay:!0}:{normalized:r,outsideOverlay:!1}}}async readdir(t){le(t,"scandir");let{normalized:s,outsideOverlay:r}=await this.resolveForReaddir(t);if(r)return[];let n=await this.readdirCore(t,s);return Array.from(n.keys()).sort((i,o)=>i<o?-1:i>o?1:0)}async readdirWithFileTypes(t){le(t,"scandir");let{normalized:s,outsideOverlay:r}=await this.resolveForReaddir(t);if(r)return[];let n=await this.readdirCore(t,s);return Array.from(n.values()).sort((i,o)=>i.name<o.name?-1:i.name>o.name?1:0)}async rm(t,s){le(t,"rm"),this.assertWritable(`rm '${t}'`);let r=this.normalizePath(t);if(!await this.existsInOverlay(r)){if(s?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${t}'`)}try{if((await this.stat(r)).isDirectory){let o=await this.readdir(r);if(o.length>0){if(!s?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${t}'`);for(let a of o){let l=r==="/"?`/${a}`:`${r}/${a}`;await this.rm(l,s)}}}}catch{}this.deleted.add(r),this.memory.delete(r)}async cp(t,s,r){le(t,"cp"),le(s,"cp"),this.assertWritable(`cp '${s}'`);let n=this.normalizePath(t),i=this.normalizePath(s);if(!await this.existsInOverlay(n))throw new Error(`ENOENT: no such file or directory, cp '${t}'`);let a=await this.stat(n);if(a.isFile){let l=await this.readFileChunks(n);await this.writeFile(i,he(l))}else if(a.isDirectory){if(!r?.recursive)throw new Error(`EISDIR: is a directory, cp '${t}'`);await this.mkdir(i,{recursive:!0});let l=await this.readdir(n);for(let u of l){let c=n==="/"?`/${u}`:`${n}/${u}`,f=i==="/"?`/${u}`:`${i}/${u}`;await this.cp(c,f,r)}}}async mv(t,s){this.assertWritable(`mv '${s}'`),await this.cp(t,s,{recursive:!0}),await this.rm(t,{recursive:!0})}resolvePath(t,s){if(s.startsWith("/"))return this.normalizePath(s);let r=t==="/"?`/${s}`:`${t}/${s}`;return this.normalizePath(r)}getAllPaths(){let t=new Set(this.memory.keys());for(let s of this.deleted)t.delete(s);return this.scanRealFs("/",t),Array.from(t)}scanRealFs(t,s){if(this.deleted.has(t))return;let r=this.toRealPath(t);if(r)try{let n=ee.readdirSync(r);for(let i of n){let o=t==="/"?`/${i}`:`${t}/${i}`;if(this.deleted.has(o))continue;s.add(o);let a=mt.join(r,i);ee.statSync(a).isDirectory()&&this.scanRealFs(o,s)}}catch{}}async chmod(t,s){le(t,"chmod"),this.assertWritable(`chmod '${t}'`);let r=this.normalizePath(t);if(!await this.existsInOverlay(r))throw new Error(`ENOENT: no such file or directory, chmod '${t}'`);let i=this.memory.get(r);if(i){i.mode=s;return}let o=await this.stat(r);if(o.isFile){let a=await this.readFileChunks(r),l=0;for(let u of a)l+=u.length;this.memory.set(r,{type:"file",chunks:a,size:l,mode:s,mtime:new Date})}else o.isDirectory&&this.memory.set(r,{type:"directory",mode:s,mtime:new Date})}async symlink(t,s){le(s,"symlink"),this.assertWritable(`symlink '${s}'`);let r=this.normalizePath(s);if(await this.existsInOverlay(r))throw new Error(`EEXIST: file already exists, symlink '${s}'`);this.ensureParentDirs(r),this.memory.set(r,{type:"symlink",target:t,mode:511,mtime:new Date}),this.deleted.delete(r)}async link(t,s){le(t,"link"),le(s,"link"),this.assertWritable(`link '${s}'`);let r=this.normalizePath(t),n=this.normalizePath(s);if(!await this.existsInOverlay(r))throw new Error(`ENOENT: no such file or directory, link '${t}'`);let o=await this.stat(r);if(!o.isFile)throw new Error(`EPERM: operation not permitted, link '${t}'`);if(await this.existsInOverlay(n))throw new Error(`EEXIST: file already exists, link '${s}'`);let l=await this.readFileChunks(r),u=0;for(let c of l)u+=c.length;this.ensureParentDirs(n),this.memory.set(n,{type:"file",chunks:l,size:u,mode:o.mode,mtime:new Date}),this.deleted.delete(n)}async readlink(t){le(t,"readlink");let s=this.normalizePath(t);if(this.deleted.has(s))throw new Error(`ENOENT: no such file or directory, readlink '${t}'`);let r=this.memory.get(s);if(r){if(r.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${t}'`);return r.target}let n=this.toRealPath(s);if(!n)throw new Error(`ENOENT: no such file or directory, readlink '${t}'`);try{return await ee.promises.readlink(n)}catch(i){throw i.code==="ENOENT"?new Error(`ENOENT: no such file or directory, readlink '${t}'`):i.code==="EINVAL"?new Error(`EINVAL: invalid argument, readlink '${t}'`):i}}async realpath(t){le(t,"realpath");let s=this.normalizePath(t),r=new Set,n=async a=>{let l=a==="/"?[]:a.slice(1).split("/"),u="";for(let c of l){if(u=`${u}/${c}`,r.has(u))throw new Error(`ELOOP: too many levels of symbolic links, realpath '${t}'`);if(this.deleted.has(u))throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);let f=this.memory.get(u),h=0,d=40;for(;f&&f.type==="symlink"&&h<d;){if(r.add(u),u=this.resolveSymlink(u,f.target),h++,r.has(u))throw new Error(`ELOOP: too many levels of symbolic links, realpath '${t}'`);if(this.deleted.has(u))throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);f=this.memory.get(u)}if(h>=d)throw new Error(`ELOOP: too many levels of symbolic links, realpath '${t}'`);if(!f){let m=this.toRealPath(u);if(m)try{if((await ee.promises.lstat(m)).isSymbolicLink()){let v=await ee.promises.readlink(m);return r.add(u),u=this.resolveSymlink(u,v),n(u)}}catch(p){throw p.code==="ENOENT"?new Error(`ENOENT: no such file or directory, realpath '${t}'`):p}}}return u||"/"},i=await n(s);if(!await this.existsInOverlay(i))throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);return i}async utimes(t,s,r){le(t,"utimes"),this.assertWritable(`utimes '${t}'`);let n=this.normalizePath(t);if(!await this.existsInOverlay(n))throw new Error(`ENOENT: no such file or directory, utimes '${t}'`);let o=this.memory.get(n);if(o){o.mtime=r;return}let a=await this.stat(n);if(a.isFile){let l=await this.readFileChunks(n),u=0;for(let c of l)u+=c.length;this.memory.set(n,{type:"file",chunks:l,size:u,mode:a.mode,mtime:r})}else a.isDirectory&&this.memory.set(n,{type:"directory",mode:a.mode,mtime:r})}};import*as G from"node:fs";import*as pe from"node:path";import{Readable as ya}from"node:stream";var hs=class{root;maxFileReadSize;constructor(t){if(this.root=pe.resolve(t.root),this.maxFileReadSize=t.maxFileReadSize??10485760,!G.existsSync(this.root))throw new Error(`ReadWriteFs root does not exist: ${this.root}`);if(!G.statSync(this.root).isDirectory())throw new Error(`ReadWriteFs root is not a directory: ${this.root}`)}toRealPath(t){let s=this.normalizePath(t),r=pe.join(this.root,s);return pe.resolve(r)}normalizePath(t){if(!t||t==="/")return"/";let s=t.endsWith("/")&&t!=="/"?t.slice(0,-1):t;s.startsWith("/")||(s=`/${s}`);let r=s.split("/").filter(i=>i&&i!=="."),n=[];for(let i of r)i===".."?n.pop():n.push(i);return`/${n.join("/")}`||"/"}async readFile(t){let s=this.toRealPath(t);try{let n=await G.promises.lstat(s);if(n.isDirectory())throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);if(this.maxFileReadSize>0&&n.size>this.maxFileReadSize)throw new Error(`EFBIG: file too large, read '${t}' (${n.size} bytes, max ${this.maxFileReadSize})`)}catch(n){throw n.code==="ENOENT"?new Error(`ENOENT: no such file or directory, open '${t}'`):n}let r=G.createReadStream(s);return ya.toWeb(r)}async readRange(t,s,r){rt(s,r);let n=this.toRealPath(t),i;try{i=await G.promises.lstat(n)}catch(u){throw u.code==="ENOENT"?new Error(`ENOENT: no such file or directory, open '${t}'`):u}if(i.isDirectory())throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);if(r===0||s>=i.size)return new Uint8Array(0);let o=Math.min(r,i.size-s),a=new Uint8Array(o),l=await G.promises.open(n,"r");try{let{bytesRead:u}=await l.read(a,0,o,s);return u===o?a:a.subarray(0,u)}finally{await l.close()}}async readFileText(t,s){let r=await this.readFile(t),n=await H(r),i=$e(s)??"utf8";return i==="utf8"||i==="utf-8"?new TextDecoder().decode(n):typeof Buffer<"u"?Buffer.from(n).toString(i):new TextDecoder().decode(n)}async writeFile(t,s,r){let n=this.toRealPath(t),i=$e(r),o=pe.dirname(n);await G.promises.mkdir(o,{recursive:!0});let{chunks:a,size:l}=await ze(s,i),u=new Uint8Array(l),c=0;for(let f of a)u.set(f,c),c+=f.length;await G.promises.writeFile(n,u)}async appendFile(t,s,r){let n=this.toRealPath(t),i=$e(r),o=pe.dirname(n);await G.promises.mkdir(o,{recursive:!0});let{chunks:a,size:l}=await ze(s,i),u=new Uint8Array(l),c=0;for(let f of a)u.set(f,c),c+=f.length;await G.promises.appendFile(n,u)}async exists(t){let s=this.toRealPath(t);try{return await G.promises.access(s),!0}catch{return!1}}async stat(t){let s=this.toRealPath(t);try{let r=await G.promises.stat(s);return{isFile:r.isFile(),isDirectory:r.isDirectory(),isSymbolicLink:!1,mode:r.mode,size:r.size,mtime:r.mtime}}catch(r){throw r.code==="ENOENT"?new Error(`ENOENT: no such file or directory, stat '${t}'`):r}}async lstat(t){let s=this.toRealPath(t);try{let r=await G.promises.lstat(s);return{isFile:r.isFile(),isDirectory:r.isDirectory(),isSymbolicLink:r.isSymbolicLink(),mode:r.mode,size:r.size,mtime:r.mtime}}catch(r){throw r.code==="ENOENT"?new Error(`ENOENT: no such file or directory, lstat '${t}'`):r}}async mkdir(t,s){let r=this.toRealPath(t);try{await G.promises.mkdir(r,{recursive:s?.recursive})}catch(n){let i=n;throw i.code==="EEXIST"?new Error(`EEXIST: file already exists, mkdir '${t}'`):i.code==="ENOENT"?new Error(`ENOENT: no such file or directory, mkdir '${t}'`):n}}async readdir(t){return(await this.readdirWithFileTypes(t)).map(r=>r.name)}async readdirWithFileTypes(t){let s=this.toRealPath(t);try{return(await G.promises.readdir(s,{withFileTypes:!0})).map(n=>({name:n.name,isFile:n.isFile(),isDirectory:n.isDirectory(),isSymbolicLink:n.isSymbolicLink()})).sort((n,i)=>n.name<i.name?-1:n.name>i.name?1:0)}catch(r){let n=r;throw n.code==="ENOENT"?new Error(`ENOENT: no such file or directory, scandir '${t}'`):n.code==="ENOTDIR"?new Error(`ENOTDIR: not a directory, scandir '${t}'`):r}}async rm(t,s){let r=this.toRealPath(t);try{await G.promises.rm(r,{recursive:s?.recursive??!1,force:s?.force??!1})}catch(n){let i=n;throw i.code==="ENOENT"&&!s?.force?new Error(`ENOENT: no such file or directory, rm '${t}'`):i.code==="ENOTEMPTY"?new Error(`ENOTEMPTY: directory not empty, rm '${t}'`):n}}async cp(t,s,r){let n=this.toRealPath(t),i=this.toRealPath(s);try{await G.promises.cp(n,i,{recursive:r?.recursive??!1})}catch(o){let a=o;throw a.code==="ENOENT"?new Error(`ENOENT: no such file or directory, cp '${t}'`):a.code==="EISDIR"?new Error(`EISDIR: is a directory, cp '${t}'`):o}}async mv(t,s){let r=this.toRealPath(t),n=this.toRealPath(s),i=pe.dirname(n);await G.promises.mkdir(i,{recursive:!0});try{await G.promises.rename(r,n)}catch(o){let a=o;if(a.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, mv '${t}'`);if(a.code==="EXDEV"){await this.cp(t,s,{recursive:!0}),await this.rm(t,{recursive:!0});return}throw o}}resolvePath(t,s){if(s.startsWith("/"))return this.normalizePath(s);let r=t==="/"?`/${s}`:`${t}/${s}`;return this.normalizePath(r)}getAllPaths(){let t=[];return this.scanDir("/",t),t}scanDir(t,s){let r=this.toRealPath(t);try{let n=G.readdirSync(r);for(let i of n){let o=t==="/"?`/${i}`:`${t}/${i}`;s.push(o);let a=pe.join(r,i);G.statSync(a).isDirectory()&&this.scanDir(o,s)}}catch{}}async chmod(t,s){let r=this.toRealPath(t);try{await G.promises.chmod(r,s)}catch(n){throw n.code==="ENOENT"?new Error(`ENOENT: no such file or directory, chmod '${t}'`):n}}async symlink(t,s){let r=this.toRealPath(s),n=this.normalizePath(s),i=this.normalizePath(pe.dirname(n)),o=t.startsWith("/")?this.normalizePath(t):this.normalizePath(i==="/"?`/${t}`:`${i}/${t}`),a=pe.join(this.root,o),l=pe.dirname(r),u=t.startsWith("/")?a:pe.relative(l,a);try{await G.promises.symlink(u,r)}catch(c){throw c.code==="EEXIST"?new Error(`EEXIST: file already exists, symlink '${s}'`):c}}async link(t,s){let r=this.toRealPath(t),n=this.toRealPath(s);try{await G.promises.link(r,n)}catch(i){let o=i;throw o.code==="ENOENT"?new Error(`ENOENT: no such file or directory, link '${t}'`):o.code==="EEXIST"?new Error(`EEXIST: file already exists, link '${s}'`):o.code==="EPERM"?new Error(`EPERM: operation not permitted, link '${t}'`):i}}async readlink(t){let s=this.toRealPath(t);try{return await G.promises.readlink(s)}catch(r){let n=r;throw n.code==="ENOENT"?new Error(`ENOENT: no such file or directory, readlink '${t}'`):n.code==="EINVAL"?new Error(`EINVAL: invalid argument, readlink '${t}'`):r}}async realpath(t){let s=this.toRealPath(t);try{let r=await G.promises.realpath(s),n=await G.promises.realpath(this.root);if(r.startsWith(n))return r.slice(n.length)||"/";throw new Error(`ENOENT: no such file or directory, realpath '${t}'`)}catch(r){let n=r;throw n.code==="ENOENT"?new Error(`ENOENT: no such file or directory, realpath '${t}'`):n.code==="ELOOP"?new Error(`ELOOP: too many levels of symbolic links, realpath '${t}'`):r}}async utimes(t,s,r){let n=this.toRealPath(t);try{await G.promises.utimes(n,s,r)}catch(i){throw i.code==="ENOENT"?new Error(`ENOENT: no such file or directory, utimes '${t}'`):i}}};var gt=class{cmdId;cwd;startedAt;exitCode;bashEnv;cmdLine;env;explicitCwd;resultPromise;constructor(t,s,r,n,i=!1){this.cmdId=crypto.randomUUID(),this.cwd=r,this.startedAt=new Date,this.bashEnv=t,this.cmdLine=s,this.env=n,this.explicitCwd=i,this.resultPromise=this.execute()}async execute(){let t=this.env||this.explicitCwd?{cwd:this.explicitCwd?this.cwd:void 0,env:this.env}:void 0,s=await this.bashEnv.exec(this.cmdLine,t);this.exitCode=s.exitCode;let[r,n]=await Promise.all([Ge(s.stdout),Ge(s.stderr)]);return{stdoutText:r,stderrText:n,exitCode:s.exitCode}}async*logs(){let t=await this.resultPromise;t.stdoutText.length>0&&(yield{type:"stdout",data:t.stdoutText,timestamp:new Date}),t.stderrText.length>0&&(yield{type:"stderr",data:t.stderrText,timestamp:new Date})}async wait(){return await this.resultPromise,this}async output(){let t=await this.resultPromise;return t.stdoutText+t.stderrText}async stdout(){return(await this.resultPromise).stdoutText}async stderr(){return(await this.resultPromise).stderrText}async kill(){}};var ps=class e{bashEnv;constructor(t){this.bashEnv=t}static async create(t){let s=t?.fs;if(t?.overlayRoot){if(t?.fs)throw new Error("Cannot specify both 'fs' and 'overlayRoot' options");s=new yt({root:t.overlayRoot})}let r=new Nt({env:t?.env,cwd:t?.cwd,fs:s,maxCallDepth:t?.maxCallDepth,maxCommandCount:t?.maxCommandCount,maxLoopIterations:t?.maxLoopIterations,network:t?.network});return new e(r)}async runCommand(t,s){let r=s?.cwd??this.bashEnv.getCwd(),n=s?.cwd!==void 0;return new gt(this.bashEnv,t,r,s?.env,n)}async writeFiles(t){for(let[s,r]of Object.entries(t)){let n;typeof r=="string"?n=r:r.encoding==="base64"?n=Buffer.from(r.content,"base64").toString("utf-8"):n=r.content;let i=s.substring(0,s.lastIndexOf("/"))||"/";i!=="/"&&await this.bashEnv.exec(`mkdir -p ${i}`),await this.bashEnv.writeFile(s,n)}}async readFile(t,s){let r=await this.bashEnv.readFile(t);return s==="base64"?Buffer.from(r).toString("base64"):r}async mkDir(t,s){let r=s?.recursive?"-p":"";await this.bashEnv.exec(`mkdir ${r} ${t}`)}async stop(){}async extendTimeout(t){}get domain(){}get bashEnvInstance(){return this.bashEnv}};var ms=class{violations=[];violationsByType=new Map;options;constructor(t={}){this.options={maxViolationsPerType:t.maxViolationsPerType??100,includeStackTraces:t.includeStackTraces??!0,onViolation:t.onViolation??(()=>{}),logToConsole:t.logToConsole??!1}}record(t){let s=this.options.includeStackTraces?t:{...t,stack:void 0};this.violations.unshift(s);let r=this.violationsByType.get(t.type);r||(r=[],this.violationsByType.set(t.type,r)),r.length<this.options.maxViolationsPerType&&r.push(s),this.options.logToConsole&&console.warn(`[SecurityViolation] ${t.type}: ${t.message}`,t.path),this.options.onViolation(s)}getViolations(){return[...this.violations]}getViolationsByType(t){return[...this.violationsByType.get(t)??[]]}getSummary(){let t=[];for(let[s,r]of this.violationsByType){if(r.length===0)continue;let n=new Set,i=Number.POSITIVE_INFINITY,o=0;for(let a of r)n.add(a.path),i=Math.min(i,a.timestamp),o=Math.max(o,a.timestamp);t.push({type:s,count:r.length,firstSeen:i,lastSeen:o,paths:Array.from(n)})}return t.sort((s,r)=>r.count-s.count),t}getTotalCount(){return this.violations.length}hasViolations(){return this.violations.length>0}clear(){this.violations=[],this.violationsByType.clear()}createCallback(){return t=>this.record(t)}};function Si(){return e=>{console.warn("[DefenseInDepth] Security violation detected:",`
693
+ `;try{s.writeFileSync(`/bin/${t.name}`,r)}catch{}try{s.writeFileSync(`/usr/bin/${t.name}`,r)}catch{}}}logResult(t,s,r){try{let n=this.logger;if(n){let i=s.text(),a=r.text();i.length>0&&n.debug("stdout",{output:i}),a.length>0&&n.info("stderr",{output:a}),n.info("exit",{exitCode:t.exitCode})}return{...t,stdout:s.stream(),stderr:r.stream()}}finally{s.seal(),r.seal()}}async exec(t,s){if(this.state.callDepth===0&&(this.state.commandCount=0),this.state.commandCount++,this.state.commandCount>this.limits.maxCommandCount)return{stdout:S(),stderr:V(`bash: maximum command count (${this.limits.maxCommandCount}) exceeded (possible infinite loop). Increase with executionLimits.maxCommandCount option.
694
+ `),exitCode:1,env:xe(this.state.env,s?.env)};if(!t.trim())return{stdout:S(),stderr:S(),exitCode:0,env:xe(this.state.env,s?.env)};if(s?.signal?.aborted)return{stdout:S(),stderr:S(),exitCode:new pe(s.signal.reason).exitCode,env:xe(this.state.env,s?.env)};let r=new Set,n=y=>{if(y)return{async write(v){try{await y.write(v)}catch(C){throw r.add(C),C}}}},i=_e(n(s?.stdoutSink)),a=_e(n(s?.stderrSink)),o=s?.processes??this.processes,l=s?.lineageId??o.createLineageId(),u=s?.jobTracker??{started:!1,limitExceeded:!1};this.logger?.info("exec",{command:t});let c=s?.cwd??this.state.cwd,f,d=c;if(s?.cwd)if(s.env&&"PWD"in s.env)f=s.env.PWD;else if(s?.env&&!("PWD"in s.env))try{f=await this.fs.realpath(c),d=f}catch{f=c}else f=c;let p=new Map(this.state.env);if(s?.env)for(let[y,v]of Object.entries(s.env))g(p,y,v);f!==void 0&&g(p,"PWD",f);let m={...this.state,env:p,cwd:d,functions:new Map(this.state.functions),localScopes:[...this.state.localScopes],options:{...this.state.options},fileDescriptors:this.state.fileDescriptors?new Map(this.state.fileDescriptors):void 0,hashTable:this.state.hashTable,groupStdin:s?.stdin||void 0},h=t;s?.rawScript||(h=hl(t));let E=(this.defenseInDepthConfig?xt.getInstance(this.defenseInDepthConfig):null)?.activate(),$=!1;try{let y=async()=>{let v=Fe(h);$=!0;let C={fs:this.fs,commands:this.commands,outputChannels:{bindings:new Map([[1,{sink:i}],[2,{sink:a}]])},limits:this.limits,jobTracker:u,processes:o,lineageId:l,exec:(k,A)=>this.exec(k,{...A,jobTracker:u,processes:o,lineageId:l,signal:Mt(s?.signal,A?.signal)}),fetch:this.secureFetch,sleep:this.sleepFn,trace:this.traceFn,coverage:this.coverageWriter,signal:s?.signal},I=await new Zt(C,m).executeRootScript(v);return u.started&&(await new Promise(k=>dl(k,0)),u.limitExceeded&&(I={...I,exitCode:ae.EXIT_CODE})),this.logResult(I,i,a)};return E?await E.run(y):await y()}catch(y){if(r.has(y))throw y;if(y instanceof q)return this.logResult({exitCode:y.exitCode,env:xe(this.state.env,s?.env)},i,a);if(y instanceof be)return this.logResult({exitCode:y.exitCode,env:xe(this.state.env,s?.env)},i,a);if(y instanceof nt)return $||await a.write(W(`bash: ${y.message}
695
+ `)),this.logResult({exitCode:1,env:xe(this.state.env,s?.env)},i,a);if(y instanceof pe)return this.logResult({exitCode:y.exitCode,env:xe(this.state.env,s?.env)},i,a);if(y instanceof ae)return this.logResult({exitCode:ae.EXIT_CODE,env:xe(this.state.env,s?.env)},i,a);if(y instanceof ye)return await a.write(W(`bash: security violation: ${y.message}
696
+ `)),this.logResult({exitCode:1,env:xe(this.state.env,s?.env)},i,a);if(y.name==="ParseException")return await a.write(W(`bash: syntax error: ${y.message}
697
+ `)),this.logResult({exitCode:2,env:xe(this.state.env,s?.env)},i,a);if(y instanceof mn)return await a.write(W(`bash: ${y.message}
698
+ `)),this.logResult({exitCode:2,env:xe(this.state.env,s?.env)},i,a);if(y instanceof RangeError)return await a.write(W(`bash: ${y.message}
699
+ `)),this.logResult({exitCode:1,env:xe(this.state.env,s?.env)},i,a);throw y}finally{E?.deactivate()}}async readFile(t){return this.fs.readFileText(this.fs.resolvePath(this.state.cwd,t))}async writeFile(t,s){return this.fs.writeFile(this.fs.resolvePath(this.state.cwd,t),s)}getCwd(){return this.state.cwd}getEnv(){return Ye(this.state.env)}};function hl(e){let t=e.split(`
700
+ `),s=[],r=[];for(let n=0;n<t.length;n++){let i=t[n];if(r.length>0){let l=r[r.length-1];if((l.stripTabs?i.replace(/^\t+/,""):i)===l.delimiter){s.push(i.trimStart()),r.pop();continue}s.push(i);continue}let a=i.trimStart();s.push(a);let o=/<<(-?)\s*(['"]?)([\w-]+)\2/g;for(let l of a.matchAll(o)){let u=l[1]==="-",c=l[3];r.push({delimiter:c,stripTabs:u})}}return s.join(`
701
+ `)}var Ws=class{baseFs;mounts=new Map;constructor(t){if(this.baseFs=t?.base??new Xe,t?.mounts)for(let{mountPoint:s,filesystem:r}of t.mounts)this.mount(s,r)}mount(t,s){this.validateMountPath(t);let r=this.normalizePath(t);this.validateMount(r),this.mounts.set(r,{mountPoint:r,filesystem:s})}unmount(t){let s=this.normalizePath(t);if(!this.mounts.has(s))throw new Error(`No filesystem mounted at '${t}'`);this.mounts.delete(s)}getMounts(){return Array.from(this.mounts.values()).map(t=>({mountPoint:t.mountPoint,filesystem:t.filesystem}))}isMountPoint(t){let s=this.normalizePath(t);return this.mounts.has(s)}validateMountPath(t){let s=t.split("/");for(let r of s)if(r==="."||r==="..")throw new Error(`Invalid mount point '${t}': contains '.' or '..' segments`)}validateMount(t){if(t==="/")throw new Error("Cannot mount at root '/'");for(let s of this.mounts.keys())if(s!==t){if(t.startsWith(`${s}/`))throw new Error(`Cannot mount at '${t}': inside existing mount '${s}'`);if(s.startsWith(`${t}/`))throw new Error(`Cannot mount at '${t}': would contain existing mount '${s}'`)}}normalizePath(t){if(!t||t==="/")return"/";let s=t.endsWith("/")&&t!=="/"?t.slice(0,-1):t;s.startsWith("/")||(s=`/${s}`);let r=s.split("/").filter(i=>i&&i!=="."),n=[];for(let i of r)i===".."?n.pop():n.push(i);return`/${n.join("/")}`}routePath(t){let s=this.normalizePath(t),r=null,n=0;for(let i of this.mounts.values()){let a=i.mountPoint;if(s===a)return{fs:i.filesystem,relativePath:"/"};s.startsWith(`${a}/`)&&a.length>n&&(r=i,n=a.length)}if(r){let i=s.slice(n);return{fs:r.filesystem,relativePath:i||"/"}}return{fs:this.baseFs,relativePath:s}}getChildMountPoints(t){let s=this.normalizePath(t),r=s==="/"?"/":`${s}/`,n=[];for(let i of this.mounts.keys())if(i.startsWith(r)){let o=i.slice(r.length).split("/")[0];o&&!n.includes(o)&&n.push(o)}return n}async readFile(t){let{fs:s,relativePath:r}=this.routePath(t);return s.readFile(r)}async readRange(t,s,r){let{fs:n,relativePath:i}=this.routePath(t);return n.readRange(i,s,r)}async readFileText(t,s){let{fs:r,relativePath:n}=this.routePath(t);return r.readFileText(n,s)}async writeFile(t,s,r){let{fs:n,relativePath:i}=this.routePath(t);return n.writeFile(i,s,r)}async appendFile(t,s,r){let{fs:n,relativePath:i}=this.routePath(t);return n.appendFile(i,s,r)}async exists(t){let s=this.normalizePath(t);if(this.mounts.has(s)||this.getChildMountPoints(s).length>0)return!0;let{fs:n,relativePath:i}=this.routePath(t);return n.exists(i)}async stat(t){let s=this.normalizePath(t),r=this.mounts.get(s);if(r)try{return await r.filesystem.stat("/")}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}if(this.getChildMountPoints(s).length>0)try{return await this.baseFs.stat(s)}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}let{fs:i,relativePath:a}=this.routePath(t);return i.stat(a)}async lstat(t){let s=this.normalizePath(t),r=this.mounts.get(s);if(r)try{return await r.filesystem.lstat("/")}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}if(this.getChildMountPoints(s).length>0)try{return await this.baseFs.lstat(s)}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}let{fs:i,relativePath:a}=this.routePath(t);return i.lstat(a)}async mkdir(t,s){let r=this.normalizePath(t);if(this.mounts.has(r)){if(s?.recursive)return;throw new Error(`EEXIST: directory already exists, mkdir '${t}'`)}if(this.getChildMountPoints(r).length>0&&s?.recursive)return;let{fs:i,relativePath:a}=this.routePath(t);return i.mkdir(a,s)}async readdir(t){let s=this.normalizePath(t),r=new Set,n=null,{fs:i,relativePath:a}=this.routePath(t);try{let l=await i.readdir(a);for(let u of l)r.add(u)}catch(l){let u=l.code,c=l.message||"";if(u!=="ENOENT"&&!c.includes("ENOENT"))throw l;n=l}let o=this.getChildMountPoints(s);for(let l of o)r.add(l);if(r.size===0&&n&&!this.mounts.has(s))throw n;return Array.from(r).sort()}async rm(t,s){let r=this.normalizePath(t);if(this.mounts.has(r))throw new Error(`EBUSY: mount point, cannot remove '${t}'`);if(this.getChildMountPoints(r).length>0)throw new Error(`EBUSY: contains mount points, cannot remove '${t}'`);let{fs:i,relativePath:a}=this.routePath(t);return i.rm(a,s)}async cp(t,s,r){let n=this.routePath(t),i=this.routePath(s);return n.fs===i.fs?n.fs.cp(n.relativePath,i.relativePath,r):this.crossMountCopy(t,s,r)}async mv(t,s){let r=this.normalizePath(t);if(this.mounts.has(r))throw new Error(`EBUSY: mount point, cannot move '${t}'`);let n=this.routePath(t),i=this.routePath(s);if(n.fs===i.fs)return n.fs.mv(n.relativePath,i.relativePath);await this.cp(t,s,{recursive:!0}),await this.rm(t,{recursive:!0})}resolvePath(t,s){if(s.startsWith("/"))return this.normalizePath(s);let r=t==="/"?`/${s}`:`${t}/${s}`;return this.normalizePath(r)}getAllPaths(){let t=new Set;for(let s of this.baseFs.getAllPaths())t.add(s);for(let s of this.mounts.keys()){let r=s.split("/").filter(Boolean),n="";for(let a of r)n=`${n}/${a}`,t.add(n);let i=this.mounts.get(s);if(i)for(let a of i.filesystem.getAllPaths())a==="/"?t.add(s):t.add(`${s}${a}`)}return Array.from(t).sort()}async chmod(t,s){let r=this.normalizePath(t),n=this.mounts.get(r);if(n)return n.filesystem.chmod("/",s);let{fs:i,relativePath:a}=this.routePath(t);return i.chmod(a,s)}async symlink(t,s){let{fs:r,relativePath:n}=this.routePath(s);return r.symlink(t,n)}async link(t,s){let r=this.routePath(t),n=this.routePath(s);if(r.fs!==n.fs)throw new Error(`EXDEV: cross-device link not permitted, link '${t}' -> '${s}'`);return r.fs.link(r.relativePath,n.relativePath)}async readlink(t){let{fs:s,relativePath:r}=this.routePath(t);return s.readlink(r)}async realpath(t){let s=this.normalizePath(t);if(this.mounts.get(s))return s;let{fs:n,relativePath:i}=this.routePath(t),a=await n.realpath(i);for(let[o,l]of this.mounts)if(s===o||s.startsWith(`${o}/`))return a==="/"?o:`${o}${a}`;return a}async crossMountCopy(t,s,r){let n=await this.lstat(t);if(n.isFile){let i=await this.readFile(t);await this.writeFile(s,i),await this.chmod(s,n.mode)}else if(n.isDirectory){if(!r?.recursive)throw new Error(`cp: ${t} is a directory (not copied)`);await this.mkdir(s,{recursive:!0});let i=await this.readdir(t);for(let a of i){let o=t==="/"?`/${a}`:`${t}/${a}`,l=s==="/"?`/${a}`:`${s}/${a}`;await this.crossMountCopy(o,l,r)}}else if(n.isSymbolicLink){let i=await this.readlink(t);await this.symlink(i,s)}}async utimes(t,s,r){let{fs:n,relativePath:i}=this.routePath(t);return n.utimes(i,s,r)}};import*as ie from"node:fs";import*as _t from"node:path";var pl="/home/user/project";function he(e,t){if(e.includes("\0"))throw new Error(`ENOENT: path contains null byte, ${t} '${e}'`)}var Tt=class{root;mountPoint;readOnly;maxFileReadSize;memory=new Map;deleted=new Set;constructor(t){this.root=_t.resolve(t.root);let s=t.mountPoint??pl;if(this.mountPoint=s==="/"?"/":s.replace(/\/+$/,""),!this.mountPoint.startsWith("/"))throw new Error(`Mount point must be an absolute path: ${s}`);if(this.readOnly=t.readOnly??!1,this.maxFileReadSize=t.maxFileReadSize??10485760,!ie.existsSync(this.root))throw new Error(`OverlayFs root does not exist: ${this.root}`);if(!ie.statSync(this.root).isDirectory())throw new Error(`OverlayFs root is not a directory: ${this.root}`);this.createMountPointDirs()}assertWritable(t){if(this.readOnly)throw new Error(`EROFS: read-only file system, ${t}`)}createMountPointDirs(){let t=this.mountPoint.split("/").filter(Boolean),s="";for(let r of t)s+=`/${r}`,this.memory.has(s)||this.memory.set(s,{type:"directory",mode:493,mtime:new Date});this.memory.has("/")||this.memory.set("/",{type:"directory",mode:493,mtime:new Date})}getMountPoint(){return this.mountPoint}mkdirSync(t,s){let n=this.normalizePath(t).split("/").filter(Boolean),i="";for(let a of n)i+=`/${a}`,this.memory.has(i)||this.memory.set(i,{type:"directory",mode:493,mtime:new Date})}writeFileSync(t,s){let r=this.normalizePath(t),n=this.getDirname(r);n!=="/"&&this.mkdirSync(n);let{chunks:i,size:a}=mt(s);this.memory.set(r,{type:"file",chunks:i,size:a,mode:420,mtime:new Date})}getDirname(t){let s=t.lastIndexOf("/");return s===0?"/":t.slice(0,s)}normalizePath(t){if(!t||t==="/")return"/";let s=t.endsWith("/")&&t!=="/"?t.slice(0,-1):t;s.startsWith("/")||(s=`/${s}`);let r=s.split("/").filter(i=>i&&i!=="."),n=[];for(let i of r)i===".."?n.pop():n.push(i);return`/${n.join("/")}`||"/"}getRelativeToMount(t){return this.mountPoint==="/"?t:t===this.mountPoint?"/":t.startsWith(`${this.mountPoint}/`)?t.slice(this.mountPoint.length):null}toRealPath(t){let s=this.normalizePath(t),r=this.getRelativeToMount(s);if(r===null)return null;let n=_t.join(this.root,r),i=_t.resolve(n);return!i.startsWith(this.root)&&i!==this.root.replace(/\/$/,"")?null:i}dirname(t){let s=this.normalizePath(t);if(s==="/")return"/";let r=s.lastIndexOf("/");return r===0?"/":s.slice(0,r)}ensureParentDirs(t){let s=this.dirname(t);s!=="/"&&(this.memory.has(s)||(this.ensureParentDirs(s),this.memory.set(s,{type:"directory",mode:493,mtime:new Date})),this.deleted.delete(s))}async existsInOverlay(t){let s=this.normalizePath(t);if(this.deleted.has(s))return!1;if(this.memory.has(s))return!0;let r=this.toRealPath(s);if(!r)return!1;try{return await ie.promises.access(r),!0}catch{return!1}}async readFile(t){let s=await this.readFileChunks(t);return ht(s)}async readRange(t,s,r){yt(s,r);let n=await this.resolveForRead(t);if(n.kind==="memory")return as(n.chunks,n.size,s,r);if(r===0||s>=n.size)return new Uint8Array(0);let i=Math.min(r,n.size-s),a=new Uint8Array(i),o=await ie.promises.open(n.realPath,"r");try{let{bytesRead:l}=await o.read(a,0,i,s);return l===i?a:a.subarray(0,l)}finally{await o.close()}}async resolveForRead(t,s=new Set){he(t,"open");let r=this.normalizePath(t);if(s.has(r))throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`);if(s.add(r),this.deleted.has(r))throw new Error(`ENOENT: no such file or directory, open '${t}'`);let n=this.memory.get(r);if(n){if(n.type==="symlink"){let a=this.resolveSymlink(r,n.target);return this.resolveForRead(a,s)}if(n.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);return{kind:"memory",chunks:n.chunks,size:n.size}}let i=this.toRealPath(r);if(!i)throw new Error(`ENOENT: no such file or directory, open '${t}'`);try{let a=await ie.promises.lstat(i);if(a.isSymbolicLink()){let o=await ie.promises.readlink(i),l=this.resolveSymlink(r,o);return this.resolveForRead(l,s)}if(a.isDirectory())throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);if(this.maxFileReadSize>0&&a.size>this.maxFileReadSize)throw new Error(`EFBIG: file too large, read '${t}' (${a.size} bytes, max ${this.maxFileReadSize})`);return{kind:"real",realPath:i,size:a.size}}catch(a){throw a.code==="ENOENT"?new Error(`ENOENT: no such file or directory, open '${t}'`):a}}async readFileText(t,s){let r=await this.readFileChunks(t),n=Te(s);return os(r,n)}async readFileChunks(t,s=new Set){he(t,"open");let r=this.normalizePath(t);if(s.has(r))throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`);if(s.add(r),this.deleted.has(r))throw new Error(`ENOENT: no such file or directory, open '${t}'`);let n=this.memory.get(r);if(n){if(n.type==="symlink"){let a=this.resolveSymlink(r,n.target);return this.readFileChunks(a,s)}if(n.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);return n.chunks}let i=this.toRealPath(r);if(!i)throw new Error(`ENOENT: no such file or directory, open '${t}'`);try{let a=await ie.promises.lstat(i);if(a.isSymbolicLink()){let c=await ie.promises.readlink(i),f=this.resolveSymlink(r,c);return this.readFileChunks(f,s)}if(a.isDirectory())throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);if(this.maxFileReadSize>0&&a.size>this.maxFileReadSize)throw new Error(`EFBIG: file too large, read '${t}' (${a.size} bytes, max ${this.maxFileReadSize})`);let o=await ie.promises.readFile(i),l=new Uint8Array(o.buffer,o.byteOffset,o.byteLength),{chunks:u}=mt(l);return u}catch(a){throw a.code==="ENOENT"?new Error(`ENOENT: no such file or directory, open '${t}'`):a}}async writeFile(t,s,r){he(t,"write"),this.assertWritable(`write '${t}'`);let n=this.normalizePath(t);this.ensureParentDirs(n);let i=Te(r),{chunks:a,size:o}=await Ze(s,i);this.memory.set(n,{type:"file",chunks:a,size:o,mode:420,mtime:new Date}),this.deleted.delete(n)}async appendFile(t,s,r){he(t,"append"),this.assertWritable(`append '${t}'`);let n=this.normalizePath(t),i=Te(r),{chunks:a,size:o}=await Ze(s,i),l=[],u=0;try{l=await this.readFileChunks(n);for(let c of l)u+=c.length}catch{}this.ensureParentDirs(n),this.memory.set(n,{type:"file",chunks:[...l,...a],size:u+o,mode:420,mtime:new Date}),this.deleted.delete(n)}async exists(t){return t.includes("\0")?!1:this.existsInOverlay(t)}async stat(t,s=new Set){he(t,"stat");let r=this.normalizePath(t);if(s.has(r))throw new Error(`ELOOP: too many levels of symbolic links, stat '${t}'`);if(s.add(r),this.deleted.has(r))throw new Error(`ENOENT: no such file or directory, stat '${t}'`);let n=this.memory.get(r);if(n){if(n.type==="symlink"){let o=this.resolveSymlink(r,n.target);return this.stat(o,s)}let a=0;return n.type==="file"&&(a=n.size),{isFile:n.type==="file",isDirectory:n.type==="directory",isSymbolicLink:!1,mode:n.mode,size:a,mtime:n.mtime}}let i=this.toRealPath(r);if(!i)throw new Error(`ENOENT: no such file or directory, stat '${t}'`);try{let a=await ie.promises.stat(i);return{isFile:a.isFile(),isDirectory:a.isDirectory(),isSymbolicLink:!1,mode:a.mode,size:a.size,mtime:a.mtime}}catch(a){throw a.code==="ENOENT"?new Error(`ENOENT: no such file or directory, stat '${t}'`):a}}async lstat(t){he(t,"lstat");let s=this.normalizePath(t);if(this.deleted.has(s))throw new Error(`ENOENT: no such file or directory, lstat '${t}'`);let r=this.memory.get(s);if(r){if(r.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:r.mode,size:r.target.length,mtime:r.mtime};let i=0;return r.type==="file"&&(i=r.size),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:i,mtime:r.mtime}}let n=this.toRealPath(s);if(!n)throw new Error(`ENOENT: no such file or directory, lstat '${t}'`);try{let i=await ie.promises.lstat(n);return{isFile:i.isFile(),isDirectory:i.isDirectory(),isSymbolicLink:i.isSymbolicLink(),mode:i.mode,size:i.size,mtime:i.mtime}}catch(i){throw i.code==="ENOENT"?new Error(`ENOENT: no such file or directory, lstat '${t}'`):i}}resolveSymlink(t,s){if(s.startsWith("/"))return this.normalizePath(s);let r=this.dirname(t);return this.normalizePath(r==="/"?`/${s}`:`${r}/${s}`)}async mkdir(t,s){he(t,"mkdir"),this.assertWritable(`mkdir '${t}'`);let r=this.normalizePath(t);if(await this.existsInOverlay(r)){if(!s?.recursive)throw new Error(`EEXIST: file already exists, mkdir '${t}'`);return}let i=this.dirname(r);if(i!=="/"&&!await this.existsInOverlay(i))if(s?.recursive)await this.mkdir(i,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${t}'`);this.memory.set(r,{type:"directory",mode:493,mtime:new Date}),this.deleted.delete(r)}async readdirCore(t,s){if(this.deleted.has(s))throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);let r=new Map,n=new Set,i=s==="/"?"/":`${s}/`;for(let o of this.deleted)if(o.startsWith(i)){let l=o.slice(i.length),u=l.split("/")[0];u&&!l.includes("/",u.length)&&n.add(u)}for(let[o,l]of this.memory)if(o!==s&&o.startsWith(i)){let u=o.slice(i.length),c=u.split("/")[0];c&&!n.has(c)&&!u.includes("/",1)&&r.set(c,{name:c,isFile:l.type==="file",isDirectory:l.type==="directory",isSymbolicLink:l.type==="symlink"})}let a=this.toRealPath(s);if(a)try{let o=await ie.promises.readdir(a,{withFileTypes:!0});for(let l of o)!n.has(l.name)&&!r.has(l.name)&&r.set(l.name,{name:l.name,isFile:l.isFile(),isDirectory:l.isDirectory(),isSymbolicLink:l.isSymbolicLink()})}catch(o){if(o.code==="ENOENT"){if(!this.memory.has(s))throw new Error(`ENOENT: no such file or directory, scandir '${t}'`)}else if(o.code!=="ENOTDIR")throw o}return r}async resolveForReaddir(t,s=!1){let r=this.normalizePath(t),n=new Set,i=s,a=this.memory.get(r);for(;a&&a.type==="symlink";){if(n.has(r))throw new Error(`ELOOP: too many levels of symbolic links, scandir '${t}'`);n.add(r),i=!0,r=this.resolveSymlink(r,a.target),a=this.memory.get(r)}if(a)return{normalized:r,outsideOverlay:!1};if(this.getRelativeToMount(r)===null)return{normalized:r,outsideOverlay:!0};let l=this.toRealPath(r);if(!l)return{normalized:r,outsideOverlay:!0};try{if((await ie.promises.lstat(l)).isSymbolicLink()){let c=await ie.promises.readlink(l),f=this.resolveSymlink(r,c);return this.resolveForReaddir(f,!0)}return{normalized:r,outsideOverlay:!1}}catch{return i?{normalized:r,outsideOverlay:!0}:{normalized:r,outsideOverlay:!1}}}async readdir(t){he(t,"scandir");let{normalized:s,outsideOverlay:r}=await this.resolveForReaddir(t);if(r)return[];let n=await this.readdirCore(t,s);return Array.from(n.keys()).sort((i,a)=>i<a?-1:i>a?1:0)}async readdirWithFileTypes(t){he(t,"scandir");let{normalized:s,outsideOverlay:r}=await this.resolveForReaddir(t);if(r)return[];let n=await this.readdirCore(t,s);return Array.from(n.values()).sort((i,a)=>i.name<a.name?-1:i.name>a.name?1:0)}async rm(t,s){he(t,"rm"),this.assertWritable(`rm '${t}'`);let r=this.normalizePath(t);if(!await this.existsInOverlay(r)){if(s?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${t}'`)}try{if((await this.stat(r)).isDirectory){let a=await this.readdir(r);if(a.length>0){if(!s?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${t}'`);for(let o of a){let l=r==="/"?`/${o}`:`${r}/${o}`;await this.rm(l,s)}}}}catch{}this.deleted.add(r),this.memory.delete(r)}async cp(t,s,r){he(t,"cp"),he(s,"cp"),this.assertWritable(`cp '${s}'`);let n=this.normalizePath(t),i=this.normalizePath(s);if(!await this.existsInOverlay(n))throw new Error(`ENOENT: no such file or directory, cp '${t}'`);let o=await this.stat(n);if(o.isFile){let l=await this.readFileChunks(n);await this.writeFile(i,ht(l))}else if(o.isDirectory){if(!r?.recursive)throw new Error(`EISDIR: is a directory, cp '${t}'`);await this.mkdir(i,{recursive:!0});let l=await this.readdir(n);for(let u of l){let c=n==="/"?`/${u}`:`${n}/${u}`,f=i==="/"?`/${u}`:`${i}/${u}`;await this.cp(c,f,r)}}}async mv(t,s){this.assertWritable(`mv '${s}'`),await this.cp(t,s,{recursive:!0}),await this.rm(t,{recursive:!0})}resolvePath(t,s){if(s.startsWith("/"))return this.normalizePath(s);let r=t==="/"?`/${s}`:`${t}/${s}`;return this.normalizePath(r)}getAllPaths(){let t=new Set(this.memory.keys());for(let s of this.deleted)t.delete(s);return this.scanRealFs("/",t),Array.from(t)}scanRealFs(t,s){if(this.deleted.has(t))return;let r=this.toRealPath(t);if(r)try{let n=ie.readdirSync(r);for(let i of n){let a=t==="/"?`/${i}`:`${t}/${i}`;if(this.deleted.has(a))continue;s.add(a);let o=_t.join(r,i);ie.statSync(o).isDirectory()&&this.scanRealFs(a,s)}}catch{}}async chmod(t,s){he(t,"chmod"),this.assertWritable(`chmod '${t}'`);let r=this.normalizePath(t);if(!await this.existsInOverlay(r))throw new Error(`ENOENT: no such file or directory, chmod '${t}'`);let i=this.memory.get(r);if(i){i.mode=s;return}let a=await this.stat(r);if(a.isFile){let o=await this.readFileChunks(r),l=0;for(let u of o)l+=u.length;this.memory.set(r,{type:"file",chunks:o,size:l,mode:s,mtime:new Date})}else a.isDirectory&&this.memory.set(r,{type:"directory",mode:s,mtime:new Date})}async symlink(t,s){he(s,"symlink"),this.assertWritable(`symlink '${s}'`);let r=this.normalizePath(s);if(await this.existsInOverlay(r))throw new Error(`EEXIST: file already exists, symlink '${s}'`);this.ensureParentDirs(r),this.memory.set(r,{type:"symlink",target:t,mode:511,mtime:new Date}),this.deleted.delete(r)}async link(t,s){he(t,"link"),he(s,"link"),this.assertWritable(`link '${s}'`);let r=this.normalizePath(t),n=this.normalizePath(s);if(!await this.existsInOverlay(r))throw new Error(`ENOENT: no such file or directory, link '${t}'`);let a=await this.stat(r);if(!a.isFile)throw new Error(`EPERM: operation not permitted, link '${t}'`);if(await this.existsInOverlay(n))throw new Error(`EEXIST: file already exists, link '${s}'`);let l=await this.readFileChunks(r),u=0;for(let c of l)u+=c.length;this.ensureParentDirs(n),this.memory.set(n,{type:"file",chunks:l,size:u,mode:a.mode,mtime:new Date}),this.deleted.delete(n)}async readlink(t){he(t,"readlink");let s=this.normalizePath(t);if(this.deleted.has(s))throw new Error(`ENOENT: no such file or directory, readlink '${t}'`);let r=this.memory.get(s);if(r){if(r.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${t}'`);return r.target}let n=this.toRealPath(s);if(!n)throw new Error(`ENOENT: no such file or directory, readlink '${t}'`);try{return await ie.promises.readlink(n)}catch(i){throw i.code==="ENOENT"?new Error(`ENOENT: no such file or directory, readlink '${t}'`):i.code==="EINVAL"?new Error(`EINVAL: invalid argument, readlink '${t}'`):i}}async realpath(t){he(t,"realpath");let s=this.normalizePath(t),r=new Set,n=async o=>{let l=o==="/"?[]:o.slice(1).split("/"),u="";for(let c of l){if(u=`${u}/${c}`,r.has(u))throw new Error(`ELOOP: too many levels of symbolic links, realpath '${t}'`);if(this.deleted.has(u))throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);let f=this.memory.get(u),d=0,p=40;for(;f&&f.type==="symlink"&&d<p;){if(r.add(u),u=this.resolveSymlink(u,f.target),d++,r.has(u))throw new Error(`ELOOP: too many levels of symbolic links, realpath '${t}'`);if(this.deleted.has(u))throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);f=this.memory.get(u)}if(d>=p)throw new Error(`ELOOP: too many levels of symbolic links, realpath '${t}'`);if(!f){let m=this.toRealPath(u);if(m)try{if((await ie.promises.lstat(m)).isSymbolicLink()){let b=await ie.promises.readlink(m);return r.add(u),u=this.resolveSymlink(u,b),n(u)}}catch(h){throw h.code==="ENOENT"?new Error(`ENOENT: no such file or directory, realpath '${t}'`):h}}}return u||"/"},i=await n(s);if(!await this.existsInOverlay(i))throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);return i}async utimes(t,s,r){he(t,"utimes"),this.assertWritable(`utimes '${t}'`);let n=this.normalizePath(t);if(!await this.existsInOverlay(n))throw new Error(`ENOENT: no such file or directory, utimes '${t}'`);let a=this.memory.get(n);if(a){a.mtime=r;return}let o=await this.stat(n);if(o.isFile){let l=await this.readFileChunks(n),u=0;for(let c of l)u+=c.length;this.memory.set(n,{type:"file",chunks:l,size:u,mode:o.mode,mtime:r})}else o.isDirectory&&this.memory.set(n,{type:"directory",mode:o.mode,mtime:r})}};import*as Z from"node:fs";import*as we from"node:path";import{Readable as ml}from"node:stream";var Vs=class{root;maxFileReadSize;constructor(t){if(this.root=we.resolve(t.root),this.maxFileReadSize=t.maxFileReadSize??10485760,!Z.existsSync(this.root))throw new Error(`ReadWriteFs root does not exist: ${this.root}`);if(!Z.statSync(this.root).isDirectory())throw new Error(`ReadWriteFs root is not a directory: ${this.root}`)}toRealPath(t){let s=this.normalizePath(t),r=we.join(this.root,s);return we.resolve(r)}normalizePath(t){if(!t||t==="/")return"/";let s=t.endsWith("/")&&t!=="/"?t.slice(0,-1):t;s.startsWith("/")||(s=`/${s}`);let r=s.split("/").filter(i=>i&&i!=="."),n=[];for(let i of r)i===".."?n.pop():n.push(i);return`/${n.join("/")}`||"/"}async readFile(t){let s=this.toRealPath(t);try{let n=await Z.promises.lstat(s);if(n.isDirectory())throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);if(this.maxFileReadSize>0&&n.size>this.maxFileReadSize)throw new Error(`EFBIG: file too large, read '${t}' (${n.size} bytes, max ${this.maxFileReadSize})`)}catch(n){throw n.code==="ENOENT"?new Error(`ENOENT: no such file or directory, open '${t}'`):n}let r=Z.createReadStream(s);return ml.toWeb(r)}async readRange(t,s,r){yt(s,r);let n=this.toRealPath(t),i;try{i=await Z.promises.lstat(n)}catch(u){throw u.code==="ENOENT"?new Error(`ENOENT: no such file or directory, open '${t}'`):u}if(i.isDirectory())throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);if(r===0||s>=i.size)return new Uint8Array(0);let a=Math.min(r,i.size-s),o=new Uint8Array(a),l=await Z.promises.open(n,"r");try{let{bytesRead:u}=await l.read(o,0,a,s);return u===a?o:o.subarray(0,u)}finally{await l.close()}}async readFileText(t,s){let r=await this.readFile(t),n=await re(r),i=Te(s)??"utf8";return i==="utf8"||i==="utf-8"?new TextDecoder().decode(n):typeof Buffer<"u"?Buffer.from(n).toString(i):new TextDecoder().decode(n)}async writeFile(t,s,r){let n=this.toRealPath(t),i=Te(r),a=we.dirname(n);await Z.promises.mkdir(a,{recursive:!0});let{chunks:o,size:l}=await Ze(s,i),u=new Uint8Array(l),c=0;for(let f of o)u.set(f,c),c+=f.length;await Z.promises.writeFile(n,u)}async appendFile(t,s,r){let n=this.toRealPath(t),i=Te(r),a=we.dirname(n);await Z.promises.mkdir(a,{recursive:!0});let{chunks:o,size:l}=await Ze(s,i),u=new Uint8Array(l),c=0;for(let f of o)u.set(f,c),c+=f.length;await Z.promises.appendFile(n,u)}async exists(t){let s=this.toRealPath(t);try{return await Z.promises.access(s),!0}catch{return!1}}async stat(t){let s=this.toRealPath(t);try{let r=await Z.promises.stat(s);return{isFile:r.isFile(),isDirectory:r.isDirectory(),isSymbolicLink:!1,mode:r.mode,size:r.size,mtime:r.mtime}}catch(r){throw r.code==="ENOENT"?new Error(`ENOENT: no such file or directory, stat '${t}'`):r}}async lstat(t){let s=this.toRealPath(t);try{let r=await Z.promises.lstat(s);return{isFile:r.isFile(),isDirectory:r.isDirectory(),isSymbolicLink:r.isSymbolicLink(),mode:r.mode,size:r.size,mtime:r.mtime}}catch(r){throw r.code==="ENOENT"?new Error(`ENOENT: no such file or directory, lstat '${t}'`):r}}async mkdir(t,s){let r=this.toRealPath(t);try{await Z.promises.mkdir(r,{recursive:s?.recursive})}catch(n){let i=n;throw i.code==="EEXIST"?new Error(`EEXIST: file already exists, mkdir '${t}'`):i.code==="ENOENT"?new Error(`ENOENT: no such file or directory, mkdir '${t}'`):n}}async readdir(t){return(await this.readdirWithFileTypes(t)).map(r=>r.name)}async readdirWithFileTypes(t){let s=this.toRealPath(t);try{return(await Z.promises.readdir(s,{withFileTypes:!0})).map(n=>({name:n.name,isFile:n.isFile(),isDirectory:n.isDirectory(),isSymbolicLink:n.isSymbolicLink()})).sort((n,i)=>n.name<i.name?-1:n.name>i.name?1:0)}catch(r){let n=r;throw n.code==="ENOENT"?new Error(`ENOENT: no such file or directory, scandir '${t}'`):n.code==="ENOTDIR"?new Error(`ENOTDIR: not a directory, scandir '${t}'`):r}}async rm(t,s){let r=this.toRealPath(t);try{await Z.promises.rm(r,{recursive:s?.recursive??!1,force:s?.force??!1})}catch(n){let i=n;throw i.code==="ENOENT"&&!s?.force?new Error(`ENOENT: no such file or directory, rm '${t}'`):i.code==="ENOTEMPTY"?new Error(`ENOTEMPTY: directory not empty, rm '${t}'`):n}}async cp(t,s,r){let n=this.toRealPath(t),i=this.toRealPath(s);try{await Z.promises.cp(n,i,{recursive:r?.recursive??!1})}catch(a){let o=a;throw o.code==="ENOENT"?new Error(`ENOENT: no such file or directory, cp '${t}'`):o.code==="EISDIR"?new Error(`EISDIR: is a directory, cp '${t}'`):a}}async mv(t,s){let r=this.toRealPath(t),n=this.toRealPath(s),i=we.dirname(n);await Z.promises.mkdir(i,{recursive:!0});try{await Z.promises.rename(r,n)}catch(a){let o=a;if(o.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, mv '${t}'`);if(o.code==="EXDEV"){await this.cp(t,s,{recursive:!0}),await this.rm(t,{recursive:!0});return}throw a}}resolvePath(t,s){if(s.startsWith("/"))return this.normalizePath(s);let r=t==="/"?`/${s}`:`${t}/${s}`;return this.normalizePath(r)}getAllPaths(){let t=[];return this.scanDir("/",t),t}scanDir(t,s){let r=this.toRealPath(t);try{let n=Z.readdirSync(r);for(let i of n){let a=t==="/"?`/${i}`:`${t}/${i}`;s.push(a);let o=we.join(r,i);Z.statSync(o).isDirectory()&&this.scanDir(a,s)}}catch{}}async chmod(t,s){let r=this.toRealPath(t);try{await Z.promises.chmod(r,s)}catch(n){throw n.code==="ENOENT"?new Error(`ENOENT: no such file or directory, chmod '${t}'`):n}}async symlink(t,s){let r=this.toRealPath(s),n=this.normalizePath(s),i=this.normalizePath(we.dirname(n)),a=t.startsWith("/")?this.normalizePath(t):this.normalizePath(i==="/"?`/${t}`:`${i}/${t}`),o=we.join(this.root,a),l=we.dirname(r),u=t.startsWith("/")?o:we.relative(l,o);try{await Z.promises.symlink(u,r)}catch(c){throw c.code==="EEXIST"?new Error(`EEXIST: file already exists, symlink '${s}'`):c}}async link(t,s){let r=this.toRealPath(t),n=this.toRealPath(s);try{await Z.promises.link(r,n)}catch(i){let a=i;throw a.code==="ENOENT"?new Error(`ENOENT: no such file or directory, link '${t}'`):a.code==="EEXIST"?new Error(`EEXIST: file already exists, link '${s}'`):a.code==="EPERM"?new Error(`EPERM: operation not permitted, link '${t}'`):i}}async readlink(t){let s=this.toRealPath(t);try{return await Z.promises.readlink(s)}catch(r){let n=r;throw n.code==="ENOENT"?new Error(`ENOENT: no such file or directory, readlink '${t}'`):n.code==="EINVAL"?new Error(`EINVAL: invalid argument, readlink '${t}'`):r}}async realpath(t){let s=this.toRealPath(t);try{let r=await Z.promises.realpath(s),n=await Z.promises.realpath(this.root);if(r.startsWith(n))return r.slice(n.length)||"/";throw new Error(`ENOENT: no such file or directory, realpath '${t}'`)}catch(r){let n=r;throw n.code==="ENOENT"?new Error(`ENOENT: no such file or directory, realpath '${t}'`):n.code==="ELOOP"?new Error(`ELOOP: too many levels of symbolic links, realpath '${t}'`):r}}async utimes(t,s,r){let n=this.toRealPath(t);try{await Z.promises.utimes(n,s,r)}catch(i){throw i.code==="ENOENT"?new Error(`ENOENT: no such file or directory, utimes '${t}'`):i}}};var Nt=class{cmdId;cwd;pid;startedAt;exitCode;bashEnv;cmdLine;env;explicitCwd;processes;shellProcesses;logMessages=[];logReaders=new Set;logsComplete=!1;stdoutDecoder=new TextDecoder;stderrDecoder=new TextDecoder;resultPromise;constructor(t,s,r,n,i=!1,a=new Le,o=t.processes){this.cmdId=crypto.randomUUID(),this.cwd=r,this.startedAt=new Date,this.bashEnv=t,this.processes=a,this.shellProcesses=o,this.cmdLine=s,this.env=n,this.explicitCwd=i;let l=()=>{},u=()=>{};this.resultPromise=new Promise((c,f)=>{l=c,u=f}),this.pid=a.start(this.cmdLine,async(c,f)=>{try{let d=await this.execute(f);return l(d),d.exitCode}catch(d){throw u(d),d}finally{this.appendLog("stdout",this.stdoutDecoder.decode(),new Date),this.appendLog("stderr",this.stderrDecoder.decode(),new Date),this.logsComplete=!0;let d=[...this.logReaders];this.logReaders.clear();for(let p of d)p()}}),a.wait(this.pid)}appendLog(t,s,r){if(s.length===0)return;this.logMessages.push({type:t,data:s,timestamp:r});let n=[...this.logReaders];this.logReaders.clear();for(let i of n)i()}async execute(t){let s={write:l=>{this.appendLog("stdout",this.stdoutDecoder.decode(l,{stream:!0}),new Date)}},r={write:l=>{this.appendLog("stderr",this.stderrDecoder.decode(l,{stream:!0}),new Date)}},n={cwd:this.explicitCwd?this.cwd:void 0,env:this.env,processes:this.shellProcesses,signal:t,stdoutSink:s,stderrSink:r},i=await this.bashEnv.exec(this.cmdLine,n);this.exitCode=i.exitCode;let[a,o]=await Promise.all([Yt(i.stdout),Yt(i.stderr)]);return{stdoutText:a,stderrText:o,exitCode:i.exitCode}}async*logs(){let t=0;for(;;){for(;t<this.logMessages.length;)yield this.logMessages[t++];if(this.logsComplete)return;await new Promise(s=>{this.logReaders.add(s)})}}async wait(){return await this.resultPromise,this}async output(){let t=await this.resultPromise;return t.stdoutText+t.stderrText}async stdout(){return(await this.resultPromise).stdoutText}async stderr(){return(await this.resultPromise).stderrText}async kill(t="SIGTERM"){this.processes.kill(this.pid,t)}};var zs=class e{bashEnv;commandProcesses;baseShellProcesses;commandShellProcesses=new Set;stopped=!1;stopPromise;constructor(t,s,r){this.bashEnv=t,this.commandProcesses=s,this.baseShellProcesses=r}static async create(t){let s=t?.fs;if(t?.overlayRoot){if(t?.fs)throw new Error("Cannot specify both 'fs' and 'overlayRoot' options");s=new Tt({root:t.overlayRoot})}let r=new Le,n=new Le,i=new Kt({env:t?.env,cwd:t?.cwd,fs:s,processes:n,maxCallDepth:t?.maxCallDepth,maxCommandCount:t?.maxCommandCount,maxLoopIterations:t?.maxLoopIterations,network:t?.network});return new e(i,r,n)}async runCommand(t,s){if(this.stopped)throw new Error("Cannot run commands after Sandbox.stop()");let r=s?.cwd??this.bashEnv.getCwd(),n=s?.cwd!==void 0,i=!1,a=()=>{!i||o.runningCount!==0||(this.commandShellProcesses.delete(o),o.dispose())},o=new Le({onJobExit:a});this.commandShellProcesses.add(o);let l=new Nt(this.bashEnv,t,r,s?.env,n,this.commandProcesses,o);return l.wait().then(()=>{i=!0,a()},()=>{i=!0,a()}),l}async writeFiles(t){for(let[s,r]of Object.entries(t)){let n;typeof r=="string"?n=r:r.encoding==="base64"?n=Buffer.from(r.content,"base64").toString("utf-8"):n=r.content;let i=s.substring(0,s.lastIndexOf("/"))||"/";i!=="/"&&await this.bashEnv.exec(`mkdir -p ${i}`),await this.bashEnv.writeFile(s,n)}}async readFile(t,s){let r=await this.bashEnv.readFile(t);return s==="base64"?Buffer.from(r).toString("base64"):r}async mkDir(t,s){let r=s?.recursive?"-p":"";await this.bashEnv.exec(`mkdir ${r} ${t}`)}async stop(){if(!this.stopPromise){this.stopped=!0;let t=new Set([this.commandProcesses,this.baseShellProcesses,...this.commandShellProcesses]);this.commandShellProcesses.clear(),this.stopPromise=Promise.all([...t].map(s=>s.dispose())).then(()=>{})}await this.stopPromise}async extendTimeout(t){}get domain(){}get bashEnvInstance(){return this.bashEnv}};var js=class{violations=[];violationsByType=new Map;options;constructor(t={}){this.options={maxViolationsPerType:t.maxViolationsPerType??100,includeStackTraces:t.includeStackTraces??!0,onViolation:t.onViolation??(()=>{}),logToConsole:t.logToConsole??!1}}record(t){let s=this.options.includeStackTraces?t:{...t,stack:void 0};this.violations.unshift(s);let r=this.violationsByType.get(t.type);r||(r=[],this.violationsByType.set(t.type,r)),r.length<this.options.maxViolationsPerType&&r.push(s),this.options.logToConsole&&console.warn(`[SecurityViolation] ${t.type}: ${t.message}`,t.path),this.options.onViolation(s)}getViolations(){return[...this.violations]}getViolationsByType(t){return[...this.violationsByType.get(t)??[]]}getSummary(){let t=[];for(let[s,r]of this.violationsByType){if(r.length===0)continue;let n=new Set,i=Number.POSITIVE_INFINITY,a=0;for(let o of r)n.add(o.path),i=Math.min(i,o.timestamp),a=Math.max(a,o.timestamp);t.push({type:s,count:r.length,firstSeen:i,lastSeen:a,paths:Array.from(n)})}return t.sort((s,r)=>r.count-s.count),t}getTotalCount(){return this.violations.length}hasViolations(){return this.violations.length>0}clear(){this.violations=[],this.violationsByType.clear()}createCallback(){return t=>this.record(t)}};function ao(){return e=>{console.warn("[DefenseInDepth] Security violation detected:",`
685
702
  Type: ${e.type}`,`
686
703
  Path: ${e.path}`,`
687
704
  Message: ${e.message}`,e.executionId?`
688
- ExecutionId: ${e.executionId}`:"")}}export{Nt as Bash,et as CHUNK_SIZE,pt as DefenseInDepthBox,F as EMPTY,We as InMemoryFs,ds as MountableFs,ft as NetworkAccessDeniedError,yt as OverlayFs,hs as ReadWriteFs,ht as RedirectNotAllowedError,ps as Sandbox,gt as SandboxCommand,ue as SecurityViolationError,ms as SecurityViolationLogger,dt as TooManyRedirectsError,H as collectBytes,Ge as collectText,O as concatStreams,Si as createConsoleViolationCallback,j as decode,Oi as defineCommand,_i as drain,w as emptyStream,B as encode,se as fromBytes,he as fromChunks,C as fromString,xi as getCommandNames,Ni as getNetworkCommandNames,Ti as getPythonCommandNames,Ci as mapChunks,ys as streamChunks,ki as streamLines,Tt as teeStream};
705
+ ExecutionId: ${e.executionId}`:"")}}export{pe as AbortExecutionError,Kt as Bash,dt as CHUNK_SIZE,xt as DefenseInDepthBox,R as EMPTY,Xe as InMemoryFs,Ws as MountableFs,Ct as NetworkAccessDeniedError,Tt as OverlayFs,Le as ProcessTable,Vs as ReadWriteFs,kt as RedirectNotAllowedError,zs as Sandbox,Nt as SandboxCommand,ye as SecurityViolationError,js as SecurityViolationLogger,At as TooManyRedirectsError,Ke as checkAborted,re as collectBytes,Yt as collectText,rt as concatStreams,ao as createConsoleViolationCallback,B as decode,vo as defineCommand,po as drain,S as emptyStream,W as encode,fe as fromBytes,ht as fromChunks,V as fromString,yo as getCommandNames,go as getNetworkCommandNames,wo as getPythonCommandNames,mo as mapChunks,Bs as streamChunks,ho as streamLines,fo as teeStream};