just-binary 3.2.4 → 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.
- package/README.md +1 -1
- package/dist/Bash.d.ts +56 -1
- package/dist/bin/chunks/alias-MILMQPGR.js +2 -0
- package/dist/bin/chunks/awk2-FB5MXVFV.js +2 -0
- package/dist/bin/chunks/base64-NGAPXZAM.js +2 -0
- package/dist/bin/chunks/basename-ZFBDKUVW.js +2 -0
- package/dist/bin/chunks/bash-FQY3C37R.js +2 -0
- package/dist/bin/chunks/cat-UO3ZDQHP.js +2 -0
- package/dist/bin/chunks/chmod-GYXHDITN.js +2 -0
- package/dist/bin/chunks/chunk-2FWUPGJH.js +6 -0
- package/dist/bin/chunks/chunk-2JQKBSIH.js +14 -0
- package/dist/bin/chunks/chunk-2MX7URRE.js +10 -0
- package/dist/bin/chunks/chunk-3G7ONQFJ.js +11 -0
- package/dist/bin/chunks/chunk-3KKXX5QY.js +13 -0
- package/dist/bin/chunks/chunk-3SWITKTS.js +7 -0
- package/dist/bin/chunks/chunk-3V7N5SEN.js +9 -0
- package/dist/bin/chunks/chunk-45S6IACR.js +3 -0
- package/dist/bin/chunks/chunk-4PDI7A54.js +20 -0
- package/dist/bin/chunks/chunk-532RLOPK.js +14 -0
- package/dist/bin/chunks/chunk-5B4HIQFQ.js +7 -0
- package/dist/bin/chunks/chunk-5CTS5L3T.js +18 -0
- package/dist/bin/chunks/chunk-5RANCCE2.js +6 -0
- package/dist/bin/chunks/chunk-63FHXCEF.js +4 -0
- package/dist/bin/chunks/chunk-64ICY43M.js +8 -0
- package/dist/bin/chunks/chunk-6MJ6NBIG.js +8 -0
- package/dist/bin/chunks/chunk-6N6IRP6G.js +6 -0
- package/dist/bin/chunks/chunk-6VQWCKYE.js +2 -0
- package/dist/bin/chunks/chunk-6WKRPHAZ.js +36 -0
- package/dist/bin/chunks/chunk-73X3QWRT.js +80 -0
- package/dist/bin/chunks/chunk-7FCHB2LT.js +14 -0
- package/dist/bin/chunks/chunk-7FGPQVVJ.js +12 -0
- package/dist/bin/chunks/chunk-7FUCLMNU.js +7 -0
- package/dist/bin/chunks/chunk-7LGOLTRR.js +5 -0
- package/dist/bin/chunks/chunk-7POGKC42.js +11 -0
- package/dist/bin/chunks/chunk-A257OMG4.js +2 -0
- package/dist/bin/chunks/chunk-BH4O34VZ.js +26 -0
- package/dist/bin/chunks/chunk-BTCJZ7OY.js +10 -0
- package/dist/bin/chunks/chunk-CEU7KGBV.js +24 -0
- package/dist/bin/chunks/chunk-COM2NIBS.js +3 -0
- package/dist/bin/chunks/chunk-CXEBUGVP.js +7 -0
- package/dist/bin/chunks/chunk-CY4RP66Q.js +21 -0
- package/dist/bin/chunks/chunk-DM55Q4EM.js +5 -0
- package/dist/bin/chunks/chunk-DUBCYODB.js +11 -0
- package/dist/bin/chunks/chunk-DUPNDZ3H.js +6 -0
- package/dist/bin/chunks/chunk-EKD22SYR.js +23 -0
- package/dist/bin/chunks/chunk-EOMAF5KQ.js +6 -0
- package/dist/bin/chunks/chunk-EQOXJHK3.js +2 -0
- package/dist/bin/chunks/chunk-EYZ62W3A.js +8 -0
- package/dist/bin/chunks/chunk-FHWRQZ3L.js +9 -0
- package/dist/bin/chunks/chunk-FUPQF256.js +10 -0
- package/dist/bin/chunks/chunk-GNVKOWAD.js +7 -0
- package/dist/bin/chunks/chunk-GZGWA6JM.js +3 -0
- package/dist/bin/chunks/chunk-HMHPYX5K.js +9 -0
- package/dist/bin/chunks/chunk-IA7QY73Z.js +9 -0
- package/dist/bin/chunks/chunk-J7ARATA6.js +4 -0
- package/dist/bin/chunks/chunk-JGKR7YR7.js +2 -0
- package/dist/bin/chunks/chunk-JILAHEMU.js +2 -0
- package/dist/bin/chunks/chunk-JKVUWQVK.js +12 -0
- package/dist/bin/chunks/chunk-JVUFZWPW.js +3 -0
- package/dist/bin/chunks/chunk-JYZZJOWW.js +2 -0
- package/dist/bin/chunks/chunk-KSXVXC3N.js +2 -0
- package/dist/bin/chunks/chunk-KTGY5SRV.js +2 -0
- package/dist/bin/chunks/chunk-KTZIEG4R.js +13 -0
- package/dist/bin/chunks/chunk-LNAXROAQ.js +5 -0
- package/dist/bin/chunks/chunk-LV3CC7SU.js +7 -0
- package/dist/bin/chunks/chunk-LVWII44I.js +23 -0
- package/dist/bin/chunks/chunk-LZC6DGAO.js +8 -0
- package/dist/bin/chunks/chunk-M3JG3HYB.js +14 -0
- package/dist/bin/chunks/chunk-MJODCFGH.js +140 -0
- package/dist/bin/chunks/chunk-MJTA3OJF.js +7 -0
- package/dist/bin/chunks/chunk-N7YAMUQG.js +34 -0
- package/dist/bin/chunks/chunk-OF45CXLB.js +2 -0
- package/dist/bin/chunks/chunk-PAD6GYRH.js +5 -0
- package/dist/bin/chunks/chunk-PJ7H3LY6.js +8 -0
- package/dist/bin/chunks/chunk-QD4WQ5KK.js +17 -0
- package/dist/bin/chunks/chunk-R2BBWDS3.js +2 -0
- package/dist/bin/chunks/chunk-SIDKYUUQ.js +7 -0
- package/dist/bin/chunks/chunk-TDOAJ4YU.js +3 -0
- package/dist/bin/chunks/chunk-U34CFKX2.js +13 -0
- package/dist/bin/chunks/chunk-U7TJRQHK.js +16 -0
- package/dist/bin/chunks/chunk-UIRJNX5Z.js +2 -0
- package/dist/bin/chunks/chunk-UKL6PNC2.js +63 -0
- package/dist/bin/chunks/chunk-UN3P7MOR.js +16 -0
- package/dist/bin/chunks/chunk-UQKQCSRP.js +16 -0
- package/dist/bin/chunks/chunk-UYAEZFQS.js +100 -0
- package/dist/bin/chunks/chunk-V7OGIT4K.js +3 -0
- package/dist/bin/chunks/chunk-VK4UPKZF.js +3 -0
- package/dist/bin/chunks/chunk-VUUGFF6A.js +9 -0
- package/dist/bin/chunks/chunk-WATFCWHB.js +12 -0
- package/dist/bin/chunks/chunk-WIJCOCAS.js +9 -0
- package/dist/bin/chunks/chunk-XSCMU2VT.js +19 -0
- package/dist/bin/chunks/chunk-XWJ3KFMY.js +287 -0
- package/dist/bin/chunks/chunk-Y6NUYQQX.js +84 -0
- package/dist/bin/chunks/chunk-YLIFZDMR.js +9 -0
- package/dist/bin/chunks/chunk-YQFW27YU.js +33 -0
- package/dist/bin/chunks/chunk-YXVJUBRG.js +5 -0
- package/dist/bin/chunks/chunk-Z6BNZUNQ.js +32 -0
- package/dist/bin/chunks/chunk-ZLGIFJBA.js +5 -0
- package/dist/bin/chunks/chunk-ZMMCLDDP.js +2 -0
- package/dist/bin/chunks/clear-FZZM6QD2.js +2 -0
- package/dist/bin/chunks/column-UCIEGSHJ.js +2 -0
- package/dist/bin/chunks/comm-WKYJTISA.js +2 -0
- package/dist/bin/chunks/cp-YSXTOMBS.js +2 -0
- package/dist/bin/chunks/curl-YFYJ2XNC.js +26 -0
- package/dist/bin/chunks/cut-2MSOLU4C.js +2 -0
- package/dist/bin/chunks/date-5LA42436.js +2 -0
- package/dist/bin/chunks/diff-4PEKV4XS.js +2 -0
- package/dist/bin/chunks/dirname-XXQNLCA4.js +2 -0
- package/dist/bin/chunks/du-IKBAW7PG.js +2 -0
- package/dist/bin/chunks/echo-DHVSEP57.js +2 -0
- package/dist/bin/chunks/env-A43LGO53.js +2 -0
- package/dist/bin/chunks/expand-L4NT2YFK.js +2 -0
- package/dist/bin/chunks/expansion-IB7ZIBIF.js +2 -0
- package/dist/bin/chunks/expr-BGBONRHV.js +2 -0
- package/dist/bin/chunks/file-DZRWWDPH.js +2 -0
- package/dist/bin/chunks/find-B6JV4QSG.js +2 -0
- package/dist/bin/chunks/flag-coverage-FTS7XXHM.js +2 -0
- package/dist/bin/chunks/fold-OVU7UR2E.js +2 -0
- package/dist/bin/chunks/grep-RG26XCUN.js +2 -0
- package/dist/bin/chunks/gzip-XZZL25AV.js +2 -0
- package/dist/bin/chunks/head-HT46A7YT.js +2 -0
- package/dist/bin/chunks/help-AOETY73Q.js +2 -0
- package/dist/bin/chunks/history-WO6CMWMT.js +2 -0
- package/dist/bin/chunks/hostname-4O6NEPL2.js +2 -0
- package/dist/bin/chunks/html-to-markdown-34LV4LFQ.js +2 -0
- package/dist/bin/chunks/join-6M3ARIFB.js +2 -0
- package/dist/bin/chunks/jq-HP7VLWBL.js +2 -0
- package/dist/bin/chunks/ln-2OLFXJYU.js +2 -0
- package/dist/bin/chunks/ls-LBW3TTPI.js +2 -0
- package/dist/bin/chunks/md5sum-GAWU76ZU.js +2 -0
- package/dist/bin/chunks/mkdir-UUOVKGHS.js +2 -0
- package/dist/bin/chunks/mv-7VY5OVAU.js +2 -0
- package/dist/bin/chunks/nl-34JIXDXD.js +2 -0
- package/dist/bin/chunks/od-IGVFBAFH.js +2 -0
- package/dist/bin/chunks/paste-Q23K6FU7.js +2 -0
- package/dist/bin/chunks/printf-CVEJOTYB.js +2 -0
- package/dist/bin/chunks/pwd-6OLMY3MQ.js +2 -0
- package/dist/bin/chunks/python3-VZL5HRHR.js +14 -0
- package/dist/bin/chunks/readlink-T4CDCG4Z.js +2 -0
- package/dist/bin/chunks/rev-O3PQMT23.js +2 -0
- package/dist/bin/chunks/rg-PQP4HTR3.js +2 -0
- package/dist/bin/chunks/rm-UMIY7ESO.js +2 -0
- package/dist/bin/chunks/rmdir-NJCSEPRP.js +2 -0
- package/dist/bin/chunks/sed-BZW7POX3.js +2 -0
- package/dist/bin/chunks/seq-3FRPQG5E.js +2 -0
- package/dist/bin/chunks/sha1sum-AOZWHFTU.js +2 -0
- package/dist/bin/chunks/sha256sum-EXJTAPU4.js +2 -0
- package/dist/bin/chunks/sleep-HDMKKRCV.js +2 -0
- package/dist/bin/chunks/sort-TO3IPXI2.js +2 -0
- package/dist/bin/chunks/split-JXCUP73P.js +2 -0
- package/dist/bin/chunks/sqlite3-K7LHCU76.js +2 -0
- package/dist/bin/chunks/stat-J5TUE4U5.js +2 -0
- package/dist/bin/chunks/strings-TDUSHGAB.js +2 -0
- package/dist/bin/chunks/tac-QXOHN3J4.js +2 -0
- package/dist/bin/chunks/tail-LOVA3SKT.js +2 -0
- package/dist/bin/chunks/tar-BAKR5OJO.js +2 -0
- package/dist/bin/chunks/tee-SREYEKO6.js +2 -0
- package/dist/bin/chunks/time-GS6SIFPK.js +2 -0
- package/dist/bin/chunks/timeout-XBYZ5LW5.js +2 -0
- package/dist/bin/chunks/touch-4ZSEFYEW.js +2 -0
- package/dist/bin/chunks/tr-ARR7JBLN.js +2 -0
- package/dist/bin/chunks/tree-7Y7H64VI.js +2 -0
- package/dist/bin/chunks/true-CKHNKYAT.js +2 -0
- package/dist/bin/chunks/unexpand-B4WHWJHL.js +2 -0
- package/dist/bin/chunks/uniq-I2KNCRR6.js +2 -0
- package/dist/bin/chunks/wc-TDIG4RIU.js +2 -0
- package/dist/bin/chunks/which-QMZ276XE.js +2 -0
- package/dist/bin/chunks/whoami-XYB47VCX.js +2 -0
- package/dist/bin/chunks/xan-STBKXZ5W.js +2 -0
- package/dist/bin/chunks/xan-view-BIT4WIPP.js +2 -0
- package/dist/bin/chunks/xargs-6K57XYD6.js +2 -0
- package/dist/bin/chunks/yes-7ZGUE2PX.js +2 -0
- package/dist/bin/chunks/yq-ZHYSTGN3.js +2 -0
- package/dist/bin/just-bash.js +320 -303
- package/dist/bin/shell/chunks/alias-MILMQPGR.js +2 -0
- package/dist/bin/shell/chunks/awk2-FB5MXVFV.js +2 -0
- package/dist/bin/shell/chunks/base64-NGAPXZAM.js +2 -0
- package/dist/bin/shell/chunks/basename-ZFBDKUVW.js +2 -0
- package/dist/bin/shell/chunks/bash-FQY3C37R.js +2 -0
- package/dist/bin/shell/chunks/cat-UO3ZDQHP.js +2 -0
- package/dist/bin/shell/chunks/chmod-GYXHDITN.js +2 -0
- package/dist/bin/shell/chunks/chunk-2FWUPGJH.js +6 -0
- package/dist/bin/shell/chunks/chunk-2JQKBSIH.js +14 -0
- package/dist/bin/shell/chunks/chunk-2MX7URRE.js +10 -0
- package/dist/bin/shell/chunks/chunk-3G7ONQFJ.js +11 -0
- package/dist/bin/shell/chunks/chunk-3KKXX5QY.js +13 -0
- package/dist/bin/shell/chunks/chunk-3SWITKTS.js +7 -0
- package/dist/bin/shell/chunks/chunk-3V7N5SEN.js +9 -0
- package/dist/bin/shell/chunks/chunk-45S6IACR.js +3 -0
- package/dist/bin/shell/chunks/chunk-4PDI7A54.js +20 -0
- package/dist/bin/shell/chunks/chunk-532RLOPK.js +14 -0
- package/dist/bin/shell/chunks/chunk-5B4HIQFQ.js +7 -0
- package/dist/bin/shell/chunks/chunk-5CTS5L3T.js +18 -0
- package/dist/bin/shell/chunks/chunk-5RANCCE2.js +6 -0
- package/dist/bin/shell/chunks/chunk-63FHXCEF.js +4 -0
- package/dist/bin/shell/chunks/chunk-64ICY43M.js +8 -0
- package/dist/bin/shell/chunks/chunk-6MJ6NBIG.js +8 -0
- package/dist/bin/shell/chunks/chunk-6N6IRP6G.js +6 -0
- package/dist/bin/shell/chunks/chunk-6VQWCKYE.js +2 -0
- package/dist/bin/shell/chunks/chunk-6WKRPHAZ.js +36 -0
- package/dist/bin/shell/chunks/chunk-73X3QWRT.js +80 -0
- package/dist/bin/shell/chunks/chunk-7FCHB2LT.js +14 -0
- package/dist/bin/shell/chunks/chunk-7FGPQVVJ.js +12 -0
- package/dist/bin/shell/chunks/chunk-7FUCLMNU.js +7 -0
- package/dist/bin/shell/chunks/chunk-7LGOLTRR.js +5 -0
- package/dist/bin/shell/chunks/chunk-7POGKC42.js +11 -0
- package/dist/bin/shell/chunks/chunk-A257OMG4.js +2 -0
- package/dist/bin/shell/chunks/chunk-BH4O34VZ.js +26 -0
- package/dist/bin/shell/chunks/chunk-BTCJZ7OY.js +10 -0
- package/dist/bin/shell/chunks/chunk-CEU7KGBV.js +24 -0
- package/dist/bin/shell/chunks/chunk-COM2NIBS.js +3 -0
- package/dist/bin/shell/chunks/chunk-CXEBUGVP.js +7 -0
- package/dist/bin/shell/chunks/chunk-CY4RP66Q.js +21 -0
- package/dist/bin/shell/chunks/chunk-DM55Q4EM.js +5 -0
- package/dist/bin/shell/chunks/chunk-DUBCYODB.js +11 -0
- package/dist/bin/shell/chunks/chunk-DUPNDZ3H.js +6 -0
- package/dist/bin/shell/chunks/chunk-EKD22SYR.js +23 -0
- package/dist/bin/shell/chunks/chunk-EOMAF5KQ.js +6 -0
- package/dist/bin/shell/chunks/chunk-EQOXJHK3.js +2 -0
- package/dist/bin/shell/chunks/chunk-EYZ62W3A.js +8 -0
- package/dist/bin/shell/chunks/chunk-FHWRQZ3L.js +9 -0
- package/dist/bin/shell/chunks/chunk-FUPQF256.js +10 -0
- package/dist/bin/shell/chunks/chunk-GNVKOWAD.js +7 -0
- package/dist/bin/shell/chunks/chunk-GZGWA6JM.js +3 -0
- package/dist/bin/shell/chunks/chunk-HMHPYX5K.js +9 -0
- package/dist/bin/shell/chunks/chunk-IA7QY73Z.js +9 -0
- package/dist/bin/shell/chunks/chunk-J7ARATA6.js +4 -0
- package/dist/bin/shell/chunks/chunk-JGKR7YR7.js +2 -0
- package/dist/bin/shell/chunks/chunk-JILAHEMU.js +2 -0
- package/dist/bin/shell/chunks/chunk-JKVUWQVK.js +12 -0
- package/dist/bin/shell/chunks/chunk-JVUFZWPW.js +3 -0
- package/dist/bin/shell/chunks/chunk-JYZZJOWW.js +2 -0
- package/dist/bin/shell/chunks/chunk-KSXVXC3N.js +2 -0
- package/dist/bin/shell/chunks/chunk-KTGY5SRV.js +2 -0
- package/dist/bin/shell/chunks/chunk-KTZIEG4R.js +13 -0
- package/dist/bin/shell/chunks/chunk-LNAXROAQ.js +5 -0
- package/dist/bin/shell/chunks/chunk-LV3CC7SU.js +7 -0
- package/dist/bin/shell/chunks/chunk-LVWII44I.js +23 -0
- package/dist/bin/shell/chunks/chunk-LZC6DGAO.js +8 -0
- package/dist/bin/shell/chunks/chunk-M3JG3HYB.js +14 -0
- package/dist/bin/shell/chunks/chunk-MJODCFGH.js +140 -0
- package/dist/bin/shell/chunks/chunk-MJTA3OJF.js +7 -0
- package/dist/bin/shell/chunks/chunk-N7YAMUQG.js +34 -0
- package/dist/bin/shell/chunks/chunk-OF45CXLB.js +2 -0
- package/dist/bin/shell/chunks/chunk-PAD6GYRH.js +5 -0
- package/dist/bin/shell/chunks/chunk-PJ7H3LY6.js +8 -0
- package/dist/bin/shell/chunks/chunk-QD4WQ5KK.js +17 -0
- package/dist/bin/shell/chunks/chunk-R2BBWDS3.js +2 -0
- package/dist/bin/shell/chunks/chunk-SIDKYUUQ.js +7 -0
- package/dist/bin/shell/chunks/chunk-TDOAJ4YU.js +3 -0
- package/dist/bin/shell/chunks/chunk-U34CFKX2.js +13 -0
- package/dist/bin/shell/chunks/chunk-U7TJRQHK.js +16 -0
- package/dist/bin/shell/chunks/chunk-UIRJNX5Z.js +2 -0
- package/dist/bin/shell/chunks/chunk-UKL6PNC2.js +63 -0
- package/dist/bin/shell/chunks/chunk-UN3P7MOR.js +16 -0
- package/dist/bin/shell/chunks/chunk-UQKQCSRP.js +16 -0
- package/dist/bin/shell/chunks/chunk-UYAEZFQS.js +100 -0
- package/dist/bin/shell/chunks/chunk-V7OGIT4K.js +3 -0
- package/dist/bin/shell/chunks/chunk-VK4UPKZF.js +3 -0
- package/dist/bin/shell/chunks/chunk-VUUGFF6A.js +9 -0
- package/dist/bin/shell/chunks/chunk-WATFCWHB.js +12 -0
- package/dist/bin/shell/chunks/chunk-WIJCOCAS.js +9 -0
- package/dist/bin/shell/chunks/chunk-XSCMU2VT.js +19 -0
- package/dist/bin/shell/chunks/chunk-XWJ3KFMY.js +287 -0
- package/dist/bin/shell/chunks/chunk-Y6NUYQQX.js +84 -0
- package/dist/bin/shell/chunks/chunk-YLIFZDMR.js +9 -0
- package/dist/bin/shell/chunks/chunk-YQFW27YU.js +33 -0
- package/dist/bin/shell/chunks/chunk-YXVJUBRG.js +5 -0
- package/dist/bin/shell/chunks/chunk-Z6BNZUNQ.js +32 -0
- package/dist/bin/shell/chunks/chunk-ZLGIFJBA.js +5 -0
- package/dist/bin/shell/chunks/chunk-ZMMCLDDP.js +2 -0
- package/dist/bin/shell/chunks/clear-FZZM6QD2.js +2 -0
- package/dist/bin/shell/chunks/column-UCIEGSHJ.js +2 -0
- package/dist/bin/shell/chunks/comm-WKYJTISA.js +2 -0
- package/dist/bin/shell/chunks/cp-YSXTOMBS.js +2 -0
- package/dist/bin/shell/chunks/curl-YFYJ2XNC.js +26 -0
- package/dist/bin/shell/chunks/cut-2MSOLU4C.js +2 -0
- package/dist/bin/shell/chunks/date-5LA42436.js +2 -0
- package/dist/bin/shell/chunks/diff-4PEKV4XS.js +2 -0
- package/dist/bin/shell/chunks/dirname-XXQNLCA4.js +2 -0
- package/dist/bin/shell/chunks/du-IKBAW7PG.js +2 -0
- package/dist/bin/shell/chunks/echo-DHVSEP57.js +2 -0
- package/dist/bin/shell/chunks/env-A43LGO53.js +2 -0
- package/dist/bin/shell/chunks/expand-L4NT2YFK.js +2 -0
- package/dist/bin/shell/chunks/expansion-IB7ZIBIF.js +2 -0
- package/dist/bin/shell/chunks/expr-BGBONRHV.js +2 -0
- package/dist/bin/shell/chunks/file-DZRWWDPH.js +2 -0
- package/dist/bin/shell/chunks/find-B6JV4QSG.js +2 -0
- package/dist/bin/shell/chunks/flag-coverage-FTS7XXHM.js +2 -0
- package/dist/bin/shell/chunks/fold-OVU7UR2E.js +2 -0
- package/dist/bin/shell/chunks/grep-RG26XCUN.js +2 -0
- package/dist/bin/shell/chunks/gzip-XZZL25AV.js +2 -0
- package/dist/bin/shell/chunks/head-HT46A7YT.js +2 -0
- package/dist/bin/shell/chunks/help-AOETY73Q.js +2 -0
- package/dist/bin/shell/chunks/history-WO6CMWMT.js +2 -0
- package/dist/bin/shell/chunks/hostname-4O6NEPL2.js +2 -0
- package/dist/bin/shell/chunks/html-to-markdown-34LV4LFQ.js +2 -0
- package/dist/bin/shell/chunks/join-6M3ARIFB.js +2 -0
- package/dist/bin/shell/chunks/jq-HP7VLWBL.js +2 -0
- package/dist/bin/shell/chunks/ln-2OLFXJYU.js +2 -0
- package/dist/bin/shell/chunks/ls-LBW3TTPI.js +2 -0
- package/dist/bin/shell/chunks/md5sum-GAWU76ZU.js +2 -0
- package/dist/bin/shell/chunks/mkdir-UUOVKGHS.js +2 -0
- package/dist/bin/shell/chunks/mv-7VY5OVAU.js +2 -0
- package/dist/bin/shell/chunks/nl-34JIXDXD.js +2 -0
- package/dist/bin/shell/chunks/od-IGVFBAFH.js +2 -0
- package/dist/bin/shell/chunks/paste-Q23K6FU7.js +2 -0
- package/dist/bin/shell/chunks/printf-CVEJOTYB.js +2 -0
- package/dist/bin/shell/chunks/pwd-6OLMY3MQ.js +2 -0
- package/dist/bin/shell/chunks/python3-VZL5HRHR.js +14 -0
- package/dist/bin/shell/chunks/readlink-T4CDCG4Z.js +2 -0
- package/dist/bin/shell/chunks/rev-O3PQMT23.js +2 -0
- package/dist/bin/shell/chunks/rg-PQP4HTR3.js +2 -0
- package/dist/bin/shell/chunks/rm-UMIY7ESO.js +2 -0
- package/dist/bin/shell/chunks/rmdir-NJCSEPRP.js +2 -0
- package/dist/bin/shell/chunks/sed-BZW7POX3.js +2 -0
- package/dist/bin/shell/chunks/seq-3FRPQG5E.js +2 -0
- package/dist/bin/shell/chunks/sha1sum-AOZWHFTU.js +2 -0
- package/dist/bin/shell/chunks/sha256sum-EXJTAPU4.js +2 -0
- package/dist/bin/shell/chunks/sleep-HDMKKRCV.js +2 -0
- package/dist/bin/shell/chunks/sort-TO3IPXI2.js +2 -0
- package/dist/bin/shell/chunks/split-JXCUP73P.js +2 -0
- package/dist/bin/shell/chunks/sqlite3-K7LHCU76.js +2 -0
- package/dist/bin/shell/chunks/stat-J5TUE4U5.js +2 -0
- package/dist/bin/shell/chunks/strings-TDUSHGAB.js +2 -0
- package/dist/bin/shell/chunks/tac-QXOHN3J4.js +2 -0
- package/dist/bin/shell/chunks/tail-LOVA3SKT.js +2 -0
- package/dist/bin/shell/chunks/tar-BAKR5OJO.js +2 -0
- package/dist/bin/shell/chunks/tee-SREYEKO6.js +2 -0
- package/dist/bin/shell/chunks/time-GS6SIFPK.js +2 -0
- package/dist/bin/shell/chunks/timeout-XBYZ5LW5.js +2 -0
- package/dist/bin/shell/chunks/touch-4ZSEFYEW.js +2 -0
- package/dist/bin/shell/chunks/tr-ARR7JBLN.js +2 -0
- package/dist/bin/shell/chunks/tree-7Y7H64VI.js +2 -0
- package/dist/bin/shell/chunks/true-CKHNKYAT.js +2 -0
- package/dist/bin/shell/chunks/unexpand-B4WHWJHL.js +2 -0
- package/dist/bin/shell/chunks/uniq-I2KNCRR6.js +2 -0
- package/dist/bin/shell/chunks/wc-TDIG4RIU.js +2 -0
- package/dist/bin/shell/chunks/which-QMZ276XE.js +2 -0
- package/dist/bin/shell/chunks/whoami-XYB47VCX.js +2 -0
- package/dist/bin/shell/chunks/xan-STBKXZ5W.js +2 -0
- package/dist/bin/shell/chunks/xan-view-BIT4WIPP.js +2 -0
- package/dist/bin/shell/chunks/xargs-6K57XYD6.js +2 -0
- package/dist/bin/shell/chunks/yes-7ZGUE2PX.js +2 -0
- package/dist/bin/shell/chunks/yq-ZHYSTGN3.js +2 -0
- package/dist/bin/shell/shell.js +325 -308
- package/dist/browser.d.ts +4 -0
- package/dist/bundle/browser.js +875 -854
- package/dist/bundle/chunks/alias-CIPN5HGG.js +1 -0
- package/dist/bundle/chunks/awk2-RAKURI6M.js +1 -0
- package/dist/bundle/chunks/base64-4GSA7KNI.js +1 -0
- package/dist/bundle/chunks/basename-Q7SIX77Q.js +1 -0
- package/dist/bundle/chunks/bash-HKSQMKKV.js +1 -0
- package/dist/bundle/chunks/cat-L3YELBYM.js +1 -0
- package/dist/bundle/chunks/chmod-IJMA7OGQ.js +1 -0
- package/dist/bundle/chunks/chunk-23R5HQHH.js +22 -0
- package/dist/bundle/chunks/chunk-2C5744E3.js +16 -0
- package/dist/bundle/chunks/chunk-2UAAXNHX.js +1 -0
- package/dist/bundle/chunks/chunk-3JEPB2CL.js +10 -0
- package/dist/bundle/chunks/chunk-4NRX5HFD.js +2 -0
- package/dist/bundle/chunks/chunk-4YUPFOYA.js +1 -0
- package/dist/bundle/chunks/chunk-5JHQRYUS.js +5 -0
- package/dist/bundle/chunks/chunk-6B44NYQO.js +8 -0
- package/dist/bundle/chunks/chunk-6D5UCV65.js +23 -0
- package/dist/bundle/chunks/chunk-6TAOLIZ7.js +13 -0
- package/dist/bundle/chunks/chunk-734O2UB7.js +9 -0
- package/dist/bundle/chunks/chunk-7B7AWU7X.js +2 -0
- package/dist/bundle/chunks/chunk-7KFBK6FW.js +1 -0
- package/dist/bundle/chunks/chunk-7ROHLV74.js +31 -0
- package/dist/bundle/chunks/chunk-7SQ2RTI2.js +139 -0
- package/dist/bundle/chunks/chunk-7UPROJVF.js +4 -0
- package/dist/bundle/chunks/chunk-7Z65ZFBM.js +10 -0
- package/dist/bundle/chunks/chunk-A5FEGJHF.js +4 -0
- package/dist/bundle/chunks/chunk-AAVEDJ2B.js +4 -0
- package/dist/bundle/chunks/chunk-AFEP7ZTB.js +4 -0
- package/dist/bundle/chunks/chunk-ALZ5CSTK.js +9 -0
- package/dist/bundle/chunks/chunk-ANMMLK7G.js +2 -0
- package/dist/bundle/chunks/chunk-AXMBAF6A.js +5 -0
- package/dist/bundle/chunks/chunk-BX5K34KY.js +1 -0
- package/dist/bundle/chunks/chunk-BZXBFTL2.js +4 -0
- package/dist/bundle/chunks/chunk-C4UC4TPC.js +8 -0
- package/dist/bundle/chunks/chunk-CNBBFQPC.js +1 -0
- package/dist/bundle/chunks/chunk-CVM2MFM3.js +2 -0
- package/dist/bundle/chunks/chunk-DL5GRV7N.js +5 -0
- package/dist/bundle/chunks/chunk-DS5ORKKQ.js +3 -0
- package/dist/bundle/chunks/chunk-ESLB4XKL.js +15 -0
- package/dist/bundle/chunks/chunk-FPJIAK37.js +8 -0
- package/dist/bundle/chunks/chunk-GBVVD7OP.js +12 -0
- package/dist/bundle/chunks/chunk-GJQGDOOO.js +8 -0
- package/dist/bundle/chunks/chunk-GZRZD5YF.js +4 -0
- package/dist/bundle/chunks/chunk-HDHI347R.js +6 -0
- package/dist/bundle/chunks/chunk-HKMBFRTV.js +2 -0
- package/dist/bundle/chunks/chunk-HMRLLHZE.js +7 -0
- package/dist/bundle/chunks/chunk-HVMFTOQY.js +1 -0
- package/dist/bundle/chunks/chunk-IVTIGXSE.js +11 -0
- package/dist/bundle/chunks/chunk-IXPY5PYY.js +13 -0
- package/dist/bundle/chunks/chunk-J2BTXVXN.js +6 -0
- package/dist/bundle/chunks/chunk-J2GAF4HH.js +15 -0
- package/dist/bundle/chunks/chunk-JJXSCNTG.js +5 -0
- package/dist/bundle/chunks/chunk-JZLKE4XX.js +23 -0
- package/dist/bundle/chunks/chunk-KL7SL7ES.js +1 -0
- package/dist/bundle/chunks/chunk-KLSVVM53.js +6 -0
- package/dist/bundle/chunks/chunk-KMDWD5I5.js +8 -0
- package/dist/bundle/chunks/chunk-KMFEA7OG.js +2 -0
- package/dist/bundle/chunks/chunk-KXZALX7Z.js +7 -0
- package/dist/bundle/chunks/chunk-MQY52TBM.js +7 -0
- package/dist/bundle/chunks/chunk-N552BMHP.js +1 -0
- package/dist/bundle/chunks/chunk-NCNBSBGV.js +286 -0
- package/dist/bundle/chunks/chunk-OBYDR4XV.js +4 -0
- package/dist/bundle/chunks/chunk-OGUNWUEY.js +17 -0
- package/dist/bundle/chunks/chunk-ORNEVHL4.js +99 -0
- package/dist/bundle/chunks/chunk-P3THD7GM.js +6 -0
- package/dist/bundle/chunks/chunk-PEEBONF2.js +2 -0
- package/dist/bundle/chunks/chunk-PMGKXEU7.js +13 -0
- package/dist/bundle/chunks/chunk-PVCFRKJJ.js +13 -0
- package/dist/bundle/chunks/chunk-QFO6LPNQ.js +7 -0
- package/dist/bundle/chunks/chunk-QMUDG3KU.js +12 -0
- package/dist/bundle/chunks/chunk-QWZOR6OX.js +5 -0
- package/dist/bundle/chunks/chunk-R42D4RK2.js +15 -0
- package/dist/bundle/chunks/chunk-S6UKQQAB.js +79 -0
- package/dist/bundle/chunks/chunk-SRQ7BXVR.js +1 -0
- package/dist/bundle/chunks/chunk-SXA5BV42.js +20 -0
- package/dist/bundle/chunks/chunk-TL7ILCBE.js +6 -0
- package/dist/bundle/chunks/chunk-TMW4OG4N.js +6 -0
- package/dist/bundle/chunks/chunk-UPLN3OMW.js +11 -0
- package/dist/bundle/chunks/chunk-UPUUONKD.js +6 -0
- package/dist/bundle/chunks/chunk-USPQ6LOW.js +10 -0
- package/dist/bundle/chunks/chunk-UY2R54E5.js +8 -0
- package/dist/bundle/chunks/chunk-V6WGFVZA.js +6 -0
- package/dist/bundle/chunks/chunk-VAEB4OUK.js +1 -0
- package/dist/bundle/chunks/chunk-VEE747JZ.js +6 -0
- package/dist/bundle/chunks/chunk-WBPZNWSY.js +35 -0
- package/dist/bundle/chunks/chunk-WPPIJX5K.js +22 -0
- package/dist/bundle/chunks/chunk-X7M472ST.js +32 -0
- package/dist/bundle/chunks/chunk-XAYT3L2B.js +1 -0
- package/dist/bundle/chunks/chunk-XCI3COKM.js +12 -0
- package/dist/bundle/chunks/chunk-XDY76TEA.js +19 -0
- package/dist/bundle/chunks/chunk-XEKBP4I4.js +62 -0
- package/dist/bundle/chunks/chunk-XGMYS2QC.js +3 -0
- package/dist/bundle/chunks/chunk-XYWNAVNS.js +33 -0
- package/dist/bundle/chunks/chunk-YIIBJSJS.js +11 -0
- package/dist/bundle/chunks/chunk-YMPJSDL2.js +7 -0
- package/dist/bundle/chunks/chunk-YU2FN4NA.js +8 -0
- package/dist/bundle/chunks/chunk-YZSDCIXP.js +9 -0
- package/dist/bundle/chunks/chunk-ZLBJV2VD.js +1 -0
- package/dist/bundle/chunks/clear-J6WBUIX6.js +1 -0
- package/dist/bundle/chunks/column-N7MHP5SX.js +1 -0
- package/dist/bundle/chunks/comm-X7VETT2U.js +1 -0
- package/dist/bundle/chunks/cp-73PGBEPL.js +1 -0
- package/dist/bundle/chunks/curl-MGBYKD7U.js +25 -0
- package/dist/bundle/chunks/cut-7I6UA67F.js +1 -0
- package/dist/bundle/chunks/date-MOZRIQXR.js +1 -0
- package/dist/bundle/chunks/diff-O5NFSBS5.js +1 -0
- package/dist/bundle/chunks/dirname-2TM4IG7K.js +1 -0
- package/dist/bundle/chunks/du-KTUJVIGD.js +1 -0
- package/dist/bundle/chunks/echo-PC3TVS6B.js +1 -0
- package/dist/bundle/chunks/env-MFQH47JH.js +1 -0
- package/dist/bundle/chunks/expand-OYPZZOZC.js +1 -0
- package/dist/bundle/chunks/expansion-QM4WQBBG.js +1 -0
- package/dist/bundle/chunks/expr-4PIUWNB7.js +1 -0
- package/dist/bundle/chunks/file-DZRW6GNH.js +1 -0
- package/dist/bundle/chunks/find-DESNHKKS.js +1 -0
- package/dist/bundle/chunks/flag-coverage-QMBN7WOW.js +1 -0
- package/dist/bundle/chunks/fold-5VRJN4CL.js +1 -0
- package/dist/bundle/chunks/grep-7RC5DPOS.js +1 -0
- package/dist/bundle/chunks/gzip-WH2JWAWT.js +1 -0
- package/dist/bundle/chunks/head-EFRLGDOE.js +1 -0
- package/dist/bundle/chunks/help-3XYFOR43.js +1 -0
- package/dist/bundle/chunks/history-J3C24VIU.js +1 -0
- package/dist/bundle/chunks/hostname-D54LLZ5I.js +1 -0
- package/dist/bundle/chunks/html-to-markdown-TFBDHAZZ.js +1 -0
- package/dist/bundle/chunks/join-36QXZEGR.js +1 -0
- package/dist/bundle/chunks/jq-5KN27BBY.js +1 -0
- package/dist/bundle/chunks/ln-SHI7B5FY.js +1 -0
- package/dist/bundle/chunks/ls-7JNJXADY.js +1 -0
- package/dist/bundle/chunks/md5sum-J7XPNTQZ.js +1 -0
- package/dist/bundle/chunks/mkdir-NM4BUUUC.js +1 -0
- package/dist/bundle/chunks/mv-VDGF4VTT.js +1 -0
- package/dist/bundle/chunks/nl-PD7BPFUB.js +1 -0
- package/dist/bundle/chunks/od-D6RO3GJE.js +1 -0
- package/dist/bundle/chunks/paste-HD4NKO4X.js +1 -0
- package/dist/bundle/chunks/printf-6XMXHDAE.js +1 -0
- package/dist/bundle/chunks/pwd-KKLARPNT.js +1 -0
- package/dist/bundle/chunks/python3-KPG6SQQV.js +13 -0
- package/dist/bundle/chunks/readlink-6XCFQQJH.js +1 -0
- package/dist/bundle/chunks/rev-NJ2ZPNAT.js +1 -0
- package/dist/bundle/chunks/rg-NIW2Q5SV.js +1 -0
- package/dist/bundle/chunks/rm-7ERREV4V.js +1 -0
- package/dist/bundle/chunks/rmdir-Z4ZRV32S.js +1 -0
- package/dist/bundle/chunks/sed-VLSHT4XR.js +1 -0
- package/dist/bundle/chunks/seq-RCBD3IYO.js +1 -0
- package/dist/bundle/chunks/sha1sum-RMRQ75AE.js +1 -0
- package/dist/bundle/chunks/sha256sum-TGW5BMJR.js +1 -0
- package/dist/bundle/chunks/sleep-SAQIXUFW.js +1 -0
- package/dist/bundle/chunks/sort-KCG2A34N.js +1 -0
- package/dist/bundle/chunks/split-EVSSQ6VR.js +1 -0
- package/dist/bundle/chunks/sqlite3-M6BXLMYI.js +1 -0
- package/dist/bundle/chunks/stat-Z22X56GM.js +1 -0
- package/dist/bundle/chunks/strings-EKWOLUFJ.js +1 -0
- package/dist/bundle/chunks/tac-RSIVIUEI.js +1 -0
- package/dist/bundle/chunks/tail-TULUAGKH.js +1 -0
- package/dist/bundle/chunks/tar-KQPQPRTZ.js +1 -0
- package/dist/bundle/chunks/tee-DPV6AVMH.js +1 -0
- package/dist/bundle/chunks/time-RXWT5RNC.js +1 -0
- package/dist/bundle/chunks/timeout-YRSN3MWF.js +1 -0
- package/dist/bundle/chunks/touch-PC42E2OS.js +1 -0
- package/dist/bundle/chunks/tr-F7JZV44S.js +1 -0
- package/dist/bundle/chunks/tree-SVRMFKLQ.js +1 -0
- package/dist/bundle/chunks/true-T4XKISHJ.js +1 -0
- package/dist/bundle/chunks/unexpand-KAIAW5TX.js +1 -0
- package/dist/bundle/chunks/uniq-7HD4DCMD.js +1 -0
- package/dist/bundle/chunks/wc-U424DF7O.js +1 -0
- package/dist/bundle/chunks/which-OY73BBGP.js +1 -0
- package/dist/bundle/chunks/whoami-KUZQQOVR.js +1 -0
- package/dist/bundle/chunks/xan-N66EXZFT.js +1 -0
- package/dist/bundle/chunks/xan-view-RLM3746X.js +1 -0
- package/dist/bundle/chunks/xargs-SWPLSROG.js +1 -0
- package/dist/bundle/chunks/yes-5BWAW2VY.js +1 -0
- package/dist/bundle/chunks/yq-URX6MHLP.js +1 -0
- package/dist/bundle/index.js +313 -296
- package/dist/commands/search-engine/index.d.ts +1 -1
- package/dist/commands/search-engine/stream-matcher.d.ts +13 -0
- package/dist/index.d.ts +4 -0
- package/dist/interpreter/builtins/break.d.ts +1 -1
- package/dist/interpreter/builtins/continue.d.ts +1 -1
- package/dist/interpreter/builtins/exit.d.ts +1 -1
- package/dist/interpreter/builtins/index.d.ts +3 -0
- package/dist/interpreter/builtins/jobs.d.ts +5 -0
- package/dist/interpreter/builtins/kill.d.ts +3 -0
- package/dist/interpreter/builtins/set.d.ts +1 -1
- package/dist/interpreter/builtins/shift.d.ts +1 -1
- package/dist/interpreter/builtins/wait.d.ts +3 -0
- package/dist/interpreter/errors.d.ts +45 -26
- package/dist/interpreter/functions.d.ts +1 -1
- package/dist/interpreter/helpers/condition.d.ts +1 -1
- package/dist/interpreter/helpers/loop.d.ts +1 -6
- package/dist/interpreter/helpers/readonly.d.ts +1 -1
- package/dist/interpreter/helpers/result.d.ts +1 -1
- package/dist/interpreter/helpers/statements.d.ts +2 -5
- package/dist/interpreter/index.d.ts +1 -1
- package/dist/interpreter/interpreter.d.ts +12 -2
- package/dist/interpreter/output-channels.d.ts +50 -0
- package/dist/interpreter/redirect-channels.d.ts +34 -0
- package/dist/interpreter/redirections.d.ts +22 -27
- package/dist/interpreter/types.d.ts +20 -6
- package/dist/limits.d.ts +2 -0
- package/dist/process/process-table.d.ts +92 -0
- package/dist/sandbox/Command.d.ts +15 -2
- package/dist/sandbox/Sandbox.d.ts +5 -0
- package/dist/types.d.ts +13 -1
- package/dist/utils/abort.d.ts +12 -0
- package/dist/utils/stream.d.ts +5 -0
- package/package.json +2 -1
- package/dist/bin/chunks/alias-DRSSCAUM.js +0 -2
- package/dist/bin/chunks/awk2-GM5WBRLU.js +0 -2
- package/dist/bin/chunks/base64-KLZ4B6VS.js +0 -2
- package/dist/bin/chunks/basename-XCXGYZPS.js +0 -2
- package/dist/bin/chunks/bash-U2E2FSIE.js +0 -2
- package/dist/bin/chunks/cat-D4E4FTXJ.js +0 -2
- package/dist/bin/chunks/chmod-OY5CP5QF.js +0 -2
- package/dist/bin/chunks/chunk-23CC4423.js +0 -287
- package/dist/bin/chunks/chunk-23EV7RYO.js +0 -10
- package/dist/bin/chunks/chunk-2IOUIOWE.js +0 -12
- package/dist/bin/chunks/chunk-3IJEW4BN.js +0 -9
- package/dist/bin/chunks/chunk-3VDZW42W.js +0 -5
- package/dist/bin/chunks/chunk-444WPTN5.js +0 -8
- package/dist/bin/chunks/chunk-446TXLPR.js +0 -9
- package/dist/bin/chunks/chunk-44ROJVH3.js +0 -6
- package/dist/bin/chunks/chunk-4VVLCPRH.js +0 -8
- package/dist/bin/chunks/chunk-4W52T6KS.js +0 -63
- package/dist/bin/chunks/chunk-4Y3GINAY.js +0 -33
- package/dist/bin/chunks/chunk-5IL5CXJC.js +0 -3
- package/dist/bin/chunks/chunk-5KQNIOZS.js +0 -84
- package/dist/bin/chunks/chunk-66PXNTAV.js +0 -2
- package/dist/bin/chunks/chunk-67SBKZZD.js +0 -9
- package/dist/bin/chunks/chunk-6U6CK6V4.js +0 -16
- package/dist/bin/chunks/chunk-7J7OY2YE.js +0 -12
- package/dist/bin/chunks/chunk-7VWUKGDV.js +0 -4
- package/dist/bin/chunks/chunk-7YOACDUK.js +0 -140
- package/dist/bin/chunks/chunk-AN2KBMAK.js +0 -12
- package/dist/bin/chunks/chunk-ASU2EQWZ.js +0 -32
- package/dist/bin/chunks/chunk-AZQ66C5R.js +0 -14
- package/dist/bin/chunks/chunk-B4GXMUCA.js +0 -20
- package/dist/bin/chunks/chunk-BXOX2H2G.js +0 -22
- package/dist/bin/chunks/chunk-CD3NCHIB.js +0 -7
- package/dist/bin/chunks/chunk-CE2ILL65.js +0 -9
- package/dist/bin/chunks/chunk-D34QBGQ3.js +0 -7
- package/dist/bin/chunks/chunk-D44C6YVE.js +0 -6
- package/dist/bin/chunks/chunk-DFAHK2EQ.js +0 -23
- package/dist/bin/chunks/chunk-DMTOGHTU.js +0 -6
- package/dist/bin/chunks/chunk-EHJW6FCX.js +0 -36
- package/dist/bin/chunks/chunk-EXCMJ23H.js +0 -100
- package/dist/bin/chunks/chunk-FVFLR7NF.js +0 -21
- package/dist/bin/chunks/chunk-GIFF636B.js +0 -2
- package/dist/bin/chunks/chunk-GIVPKQT5.js +0 -16
- package/dist/bin/chunks/chunk-GUZJZK5O.js +0 -2
- package/dist/bin/chunks/chunk-H7TGYILF.js +0 -3
- package/dist/bin/chunks/chunk-HEO6EBJ2.js +0 -14
- package/dist/bin/chunks/chunk-HY6WUGWS.js +0 -10
- package/dist/bin/chunks/chunk-HZM5PBQF.js +0 -8
- package/dist/bin/chunks/chunk-I2N72LXH.js +0 -9
- package/dist/bin/chunks/chunk-IAUA3FL7.js +0 -8
- package/dist/bin/chunks/chunk-IPWJZ22H.js +0 -14
- package/dist/bin/chunks/chunk-IQY3I4OH.js +0 -2
- package/dist/bin/chunks/chunk-JU5KTPFP.js +0 -17
- package/dist/bin/chunks/chunk-KAWPUEQM.js +0 -3
- package/dist/bin/chunks/chunk-L2KFCEBW.js +0 -13
- package/dist/bin/chunks/chunk-LVSKOXVG.js +0 -5
- package/dist/bin/chunks/chunk-MPX22C7Y.js +0 -5
- package/dist/bin/chunks/chunk-N7P3SUNH.js +0 -6
- package/dist/bin/chunks/chunk-NNVWOCET.js +0 -2
- package/dist/bin/chunks/chunk-NSSLXYEG.js +0 -8
- package/dist/bin/chunks/chunk-OH3VVXF7.js +0 -3
- package/dist/bin/chunks/chunk-PKKBPSVJ.js +0 -7
- package/dist/bin/chunks/chunk-PRQYRYWV.js +0 -3
- package/dist/bin/chunks/chunk-PZ46XEZ4.js +0 -2
- package/dist/bin/chunks/chunk-Q2BKN6MV.js +0 -11
- package/dist/bin/chunks/chunk-QFPJQSDK.js +0 -7
- package/dist/bin/chunks/chunk-QKQUVK53.js +0 -10
- package/dist/bin/chunks/chunk-QXOUI5BS.js +0 -11
- package/dist/bin/chunks/chunk-RAL2LVDX.js +0 -7
- package/dist/bin/chunks/chunk-RAUBS6MJ.js +0 -2
- package/dist/bin/chunks/chunk-RFIBBYTO.js +0 -6
- package/dist/bin/chunks/chunk-RIV3HSPK.js +0 -19
- package/dist/bin/chunks/chunk-RMG637UR.js +0 -26
- package/dist/bin/chunks/chunk-RUNWFUUE.js +0 -7
- package/dist/bin/chunks/chunk-RX4PT2U7.js +0 -9
- package/dist/bin/chunks/chunk-RZ6FAJ25.js +0 -18
- package/dist/bin/chunks/chunk-SDTTNNEH.js +0 -23
- package/dist/bin/chunks/chunk-SE4C7FJY.js +0 -33
- package/dist/bin/chunks/chunk-SL4D2YES.js +0 -4
- package/dist/bin/chunks/chunk-SZM4GZ4H.js +0 -2
- package/dist/bin/chunks/chunk-U4LP6WPJ.js +0 -11
- package/dist/bin/chunks/chunk-UAZICDKU.js +0 -5
- package/dist/bin/chunks/chunk-V3N6H3L5.js +0 -9
- package/dist/bin/chunks/chunk-VWJBSJYM.js +0 -2
- package/dist/bin/chunks/chunk-WXI44VNZ.js +0 -5
- package/dist/bin/chunks/chunk-X7PEK6W7.js +0 -13
- package/dist/bin/chunks/chunk-XB426ZI7.js +0 -3
- package/dist/bin/chunks/chunk-XILOLP4K.js +0 -8
- package/dist/bin/chunks/chunk-XRZNW2KP.js +0 -7
- package/dist/bin/chunks/chunk-XSBNCA43.js +0 -7
- package/dist/bin/chunks/chunk-YER5PEKD.js +0 -2
- package/dist/bin/chunks/chunk-YG67AAKF.js +0 -5
- package/dist/bin/chunks/chunk-YGAHXCGB.js +0 -13
- package/dist/bin/chunks/chunk-YJFLWG5Q.js +0 -73
- package/dist/bin/chunks/chunk-Z72PSRMX.js +0 -3
- package/dist/bin/chunks/chunk-Z73LISDU.js +0 -16
- package/dist/bin/chunks/chunk-ZZPPBMHW.js +0 -14
- package/dist/bin/chunks/clear-P5EG7Z6I.js +0 -2
- package/dist/bin/chunks/column-5CUPANJY.js +0 -2
- package/dist/bin/chunks/comm-LMDA7QZC.js +0 -2
- package/dist/bin/chunks/cp-7TMSGOID.js +0 -2
- package/dist/bin/chunks/curl-P6DHVAKR.js +0 -26
- package/dist/bin/chunks/cut-P6LPALWP.js +0 -2
- package/dist/bin/chunks/date-P3YMHSRG.js +0 -2
- package/dist/bin/chunks/diff-SGBANTKE.js +0 -2
- package/dist/bin/chunks/dirname-3LHNBKNB.js +0 -2
- package/dist/bin/chunks/du-DEYTW2KI.js +0 -2
- package/dist/bin/chunks/echo-5EBIR54T.js +0 -2
- package/dist/bin/chunks/env-PWRJFDWL.js +0 -2
- package/dist/bin/chunks/expand-672ZQYZF.js +0 -2
- package/dist/bin/chunks/expansion-OPTOOC4Q.js +0 -2
- package/dist/bin/chunks/expr-SWYNZXDP.js +0 -2
- package/dist/bin/chunks/file-MIXTZ4NP.js +0 -2
- package/dist/bin/chunks/find-BXGQE44U.js +0 -2
- package/dist/bin/chunks/flag-coverage-JA424IHF.js +0 -2
- package/dist/bin/chunks/fold-SK55D7OX.js +0 -2
- package/dist/bin/chunks/grep-6OXCYWRV.js +0 -2
- package/dist/bin/chunks/gzip-AKQBQW7Y.js +0 -2
- package/dist/bin/chunks/head-YZQN4BHR.js +0 -2
- package/dist/bin/chunks/help-R7JNUPU2.js +0 -2
- package/dist/bin/chunks/history-W57S3E3C.js +0 -2
- package/dist/bin/chunks/hostname-NPAYFT3O.js +0 -2
- package/dist/bin/chunks/html-to-markdown-2AHE4ET2.js +0 -2
- package/dist/bin/chunks/join-ZK67SMQ3.js +0 -2
- package/dist/bin/chunks/jq-2BGA6KZ3.js +0 -2
- package/dist/bin/chunks/ln-PZ7JHGH2.js +0 -2
- package/dist/bin/chunks/ls-SLO257WP.js +0 -2
- package/dist/bin/chunks/md5sum-WYOOUOWI.js +0 -2
- package/dist/bin/chunks/mkdir-EOATYYLD.js +0 -2
- package/dist/bin/chunks/mv-QUAFQDCT.js +0 -2
- package/dist/bin/chunks/nl-WZC4GKMG.js +0 -2
- package/dist/bin/chunks/od-IMVAQQIR.js +0 -2
- package/dist/bin/chunks/paste-6XYPZQXQ.js +0 -2
- package/dist/bin/chunks/printf-OCMANWQ5.js +0 -2
- package/dist/bin/chunks/pwd-PQGDLYLZ.js +0 -2
- package/dist/bin/chunks/python3-HNLPOBYQ.js +0 -14
- package/dist/bin/chunks/readlink-F66ORZVY.js +0 -2
- package/dist/bin/chunks/rev-67WGH7WN.js +0 -2
- package/dist/bin/chunks/rg-LTQYHOCO.js +0 -2
- package/dist/bin/chunks/rm-BZWDOVUX.js +0 -2
- package/dist/bin/chunks/rmdir-5MNK2AUK.js +0 -2
- package/dist/bin/chunks/sed-HN3E3YFB.js +0 -2
- package/dist/bin/chunks/seq-IDAAUGIL.js +0 -2
- package/dist/bin/chunks/sha1sum-Y2J25KOM.js +0 -2
- package/dist/bin/chunks/sha256sum-NFAAGL44.js +0 -2
- package/dist/bin/chunks/sleep-CPJ3WJE7.js +0 -2
- package/dist/bin/chunks/sort-FT4OVPSS.js +0 -2
- package/dist/bin/chunks/split-AXXLODUK.js +0 -2
- package/dist/bin/chunks/sqlite3-DUARNSNG.js +0 -2
- package/dist/bin/chunks/stat-6QXPS4BF.js +0 -2
- package/dist/bin/chunks/strings-7CJI5ESD.js +0 -2
- package/dist/bin/chunks/tac-Q5VNKVXE.js +0 -2
- package/dist/bin/chunks/tail-EI24LQBP.js +0 -2
- package/dist/bin/chunks/tar-M7QCUJ4B.js +0 -2
- package/dist/bin/chunks/tee-6TEQ3DXN.js +0 -2
- package/dist/bin/chunks/time-GJWZLHLN.js +0 -2
- package/dist/bin/chunks/timeout-LPVVIBNB.js +0 -2
- package/dist/bin/chunks/touch-J6X4OW3P.js +0 -2
- package/dist/bin/chunks/tr-2C3Q77EZ.js +0 -2
- package/dist/bin/chunks/tree-RLXLQJVI.js +0 -2
- package/dist/bin/chunks/true-ZPDUMWHQ.js +0 -2
- package/dist/bin/chunks/unexpand-AUQHJMGI.js +0 -2
- package/dist/bin/chunks/uniq-C3ZUQTF4.js +0 -2
- package/dist/bin/chunks/wc-NNQHXBLM.js +0 -2
- package/dist/bin/chunks/which-QKNHOQPQ.js +0 -2
- package/dist/bin/chunks/whoami-KIB3RVBF.js +0 -2
- package/dist/bin/chunks/xan-BGDVQKRZ.js +0 -2
- package/dist/bin/chunks/xan-view-GTANKIPW.js +0 -2
- package/dist/bin/chunks/xargs-I7QRUR36.js +0 -2
- package/dist/bin/chunks/yes-A2LPETVU.js +0 -2
- package/dist/bin/chunks/yq-W7OKSS7Z.js +0 -2
- package/dist/bin/shell/chunks/alias-DRSSCAUM.js +0 -2
- package/dist/bin/shell/chunks/awk2-GM5WBRLU.js +0 -2
- package/dist/bin/shell/chunks/base64-KLZ4B6VS.js +0 -2
- package/dist/bin/shell/chunks/basename-XCXGYZPS.js +0 -2
- package/dist/bin/shell/chunks/bash-U2E2FSIE.js +0 -2
- package/dist/bin/shell/chunks/cat-D4E4FTXJ.js +0 -2
- package/dist/bin/shell/chunks/chmod-OY5CP5QF.js +0 -2
- package/dist/bin/shell/chunks/chunk-23CC4423.js +0 -287
- package/dist/bin/shell/chunks/chunk-23EV7RYO.js +0 -10
- package/dist/bin/shell/chunks/chunk-2IOUIOWE.js +0 -12
- package/dist/bin/shell/chunks/chunk-3IJEW4BN.js +0 -9
- package/dist/bin/shell/chunks/chunk-3VDZW42W.js +0 -5
- package/dist/bin/shell/chunks/chunk-444WPTN5.js +0 -8
- package/dist/bin/shell/chunks/chunk-446TXLPR.js +0 -9
- package/dist/bin/shell/chunks/chunk-44ROJVH3.js +0 -6
- package/dist/bin/shell/chunks/chunk-4VVLCPRH.js +0 -8
- package/dist/bin/shell/chunks/chunk-4W52T6KS.js +0 -63
- package/dist/bin/shell/chunks/chunk-4Y3GINAY.js +0 -33
- package/dist/bin/shell/chunks/chunk-5IL5CXJC.js +0 -3
- package/dist/bin/shell/chunks/chunk-5KQNIOZS.js +0 -84
- package/dist/bin/shell/chunks/chunk-66PXNTAV.js +0 -2
- package/dist/bin/shell/chunks/chunk-67SBKZZD.js +0 -9
- package/dist/bin/shell/chunks/chunk-6U6CK6V4.js +0 -16
- package/dist/bin/shell/chunks/chunk-7J7OY2YE.js +0 -12
- package/dist/bin/shell/chunks/chunk-7VWUKGDV.js +0 -4
- package/dist/bin/shell/chunks/chunk-7YOACDUK.js +0 -140
- package/dist/bin/shell/chunks/chunk-AN2KBMAK.js +0 -12
- package/dist/bin/shell/chunks/chunk-ASU2EQWZ.js +0 -32
- package/dist/bin/shell/chunks/chunk-AZQ66C5R.js +0 -14
- package/dist/bin/shell/chunks/chunk-B4GXMUCA.js +0 -20
- package/dist/bin/shell/chunks/chunk-BXOX2H2G.js +0 -22
- package/dist/bin/shell/chunks/chunk-CD3NCHIB.js +0 -7
- package/dist/bin/shell/chunks/chunk-CE2ILL65.js +0 -9
- package/dist/bin/shell/chunks/chunk-D34QBGQ3.js +0 -7
- package/dist/bin/shell/chunks/chunk-D44C6YVE.js +0 -6
- package/dist/bin/shell/chunks/chunk-DFAHK2EQ.js +0 -23
- package/dist/bin/shell/chunks/chunk-DMTOGHTU.js +0 -6
- package/dist/bin/shell/chunks/chunk-EHJW6FCX.js +0 -36
- package/dist/bin/shell/chunks/chunk-EXCMJ23H.js +0 -100
- package/dist/bin/shell/chunks/chunk-FVFLR7NF.js +0 -21
- package/dist/bin/shell/chunks/chunk-GIFF636B.js +0 -2
- package/dist/bin/shell/chunks/chunk-GIVPKQT5.js +0 -16
- package/dist/bin/shell/chunks/chunk-GUZJZK5O.js +0 -2
- package/dist/bin/shell/chunks/chunk-H7TGYILF.js +0 -3
- package/dist/bin/shell/chunks/chunk-HEO6EBJ2.js +0 -14
- package/dist/bin/shell/chunks/chunk-HY6WUGWS.js +0 -10
- package/dist/bin/shell/chunks/chunk-HZM5PBQF.js +0 -8
- package/dist/bin/shell/chunks/chunk-I2N72LXH.js +0 -9
- package/dist/bin/shell/chunks/chunk-IAUA3FL7.js +0 -8
- package/dist/bin/shell/chunks/chunk-IPWJZ22H.js +0 -14
- package/dist/bin/shell/chunks/chunk-IQY3I4OH.js +0 -2
- package/dist/bin/shell/chunks/chunk-JU5KTPFP.js +0 -17
- package/dist/bin/shell/chunks/chunk-KAWPUEQM.js +0 -3
- package/dist/bin/shell/chunks/chunk-L2KFCEBW.js +0 -13
- package/dist/bin/shell/chunks/chunk-LVSKOXVG.js +0 -5
- package/dist/bin/shell/chunks/chunk-MPX22C7Y.js +0 -5
- package/dist/bin/shell/chunks/chunk-N7P3SUNH.js +0 -6
- package/dist/bin/shell/chunks/chunk-NNVWOCET.js +0 -2
- package/dist/bin/shell/chunks/chunk-NSSLXYEG.js +0 -8
- package/dist/bin/shell/chunks/chunk-OH3VVXF7.js +0 -3
- package/dist/bin/shell/chunks/chunk-PKKBPSVJ.js +0 -7
- package/dist/bin/shell/chunks/chunk-PRQYRYWV.js +0 -3
- package/dist/bin/shell/chunks/chunk-PZ46XEZ4.js +0 -2
- package/dist/bin/shell/chunks/chunk-Q2BKN6MV.js +0 -11
- package/dist/bin/shell/chunks/chunk-QFPJQSDK.js +0 -7
- package/dist/bin/shell/chunks/chunk-QKQUVK53.js +0 -10
- package/dist/bin/shell/chunks/chunk-QXOUI5BS.js +0 -11
- package/dist/bin/shell/chunks/chunk-RAL2LVDX.js +0 -7
- package/dist/bin/shell/chunks/chunk-RAUBS6MJ.js +0 -2
- package/dist/bin/shell/chunks/chunk-RFIBBYTO.js +0 -6
- package/dist/bin/shell/chunks/chunk-RIV3HSPK.js +0 -19
- package/dist/bin/shell/chunks/chunk-RMG637UR.js +0 -26
- package/dist/bin/shell/chunks/chunk-RUNWFUUE.js +0 -7
- package/dist/bin/shell/chunks/chunk-RX4PT2U7.js +0 -9
- package/dist/bin/shell/chunks/chunk-RZ6FAJ25.js +0 -18
- package/dist/bin/shell/chunks/chunk-SDTTNNEH.js +0 -23
- package/dist/bin/shell/chunks/chunk-SE4C7FJY.js +0 -33
- package/dist/bin/shell/chunks/chunk-SL4D2YES.js +0 -4
- package/dist/bin/shell/chunks/chunk-SZM4GZ4H.js +0 -2
- package/dist/bin/shell/chunks/chunk-U4LP6WPJ.js +0 -11
- package/dist/bin/shell/chunks/chunk-UAZICDKU.js +0 -5
- package/dist/bin/shell/chunks/chunk-V3N6H3L5.js +0 -9
- package/dist/bin/shell/chunks/chunk-VWJBSJYM.js +0 -2
- package/dist/bin/shell/chunks/chunk-WXI44VNZ.js +0 -5
- package/dist/bin/shell/chunks/chunk-X7PEK6W7.js +0 -13
- package/dist/bin/shell/chunks/chunk-XB426ZI7.js +0 -3
- package/dist/bin/shell/chunks/chunk-XILOLP4K.js +0 -8
- package/dist/bin/shell/chunks/chunk-XRZNW2KP.js +0 -7
- package/dist/bin/shell/chunks/chunk-XSBNCA43.js +0 -7
- package/dist/bin/shell/chunks/chunk-YER5PEKD.js +0 -2
- package/dist/bin/shell/chunks/chunk-YG67AAKF.js +0 -5
- package/dist/bin/shell/chunks/chunk-YGAHXCGB.js +0 -13
- package/dist/bin/shell/chunks/chunk-YJFLWG5Q.js +0 -73
- package/dist/bin/shell/chunks/chunk-Z72PSRMX.js +0 -3
- package/dist/bin/shell/chunks/chunk-Z73LISDU.js +0 -16
- package/dist/bin/shell/chunks/chunk-ZZPPBMHW.js +0 -14
- package/dist/bin/shell/chunks/clear-P5EG7Z6I.js +0 -2
- package/dist/bin/shell/chunks/column-5CUPANJY.js +0 -2
- package/dist/bin/shell/chunks/comm-LMDA7QZC.js +0 -2
- package/dist/bin/shell/chunks/cp-7TMSGOID.js +0 -2
- package/dist/bin/shell/chunks/curl-P6DHVAKR.js +0 -26
- package/dist/bin/shell/chunks/cut-P6LPALWP.js +0 -2
- package/dist/bin/shell/chunks/date-P3YMHSRG.js +0 -2
- package/dist/bin/shell/chunks/diff-SGBANTKE.js +0 -2
- package/dist/bin/shell/chunks/dirname-3LHNBKNB.js +0 -2
- package/dist/bin/shell/chunks/du-DEYTW2KI.js +0 -2
- package/dist/bin/shell/chunks/echo-5EBIR54T.js +0 -2
- package/dist/bin/shell/chunks/env-PWRJFDWL.js +0 -2
- package/dist/bin/shell/chunks/expand-672ZQYZF.js +0 -2
- package/dist/bin/shell/chunks/expansion-OPTOOC4Q.js +0 -2
- package/dist/bin/shell/chunks/expr-SWYNZXDP.js +0 -2
- package/dist/bin/shell/chunks/file-MIXTZ4NP.js +0 -2
- package/dist/bin/shell/chunks/find-BXGQE44U.js +0 -2
- package/dist/bin/shell/chunks/flag-coverage-JA424IHF.js +0 -2
- package/dist/bin/shell/chunks/fold-SK55D7OX.js +0 -2
- package/dist/bin/shell/chunks/grep-6OXCYWRV.js +0 -2
- package/dist/bin/shell/chunks/gzip-AKQBQW7Y.js +0 -2
- package/dist/bin/shell/chunks/head-YZQN4BHR.js +0 -2
- package/dist/bin/shell/chunks/help-R7JNUPU2.js +0 -2
- package/dist/bin/shell/chunks/history-W57S3E3C.js +0 -2
- package/dist/bin/shell/chunks/hostname-NPAYFT3O.js +0 -2
- package/dist/bin/shell/chunks/html-to-markdown-2AHE4ET2.js +0 -2
- package/dist/bin/shell/chunks/join-ZK67SMQ3.js +0 -2
- package/dist/bin/shell/chunks/jq-2BGA6KZ3.js +0 -2
- package/dist/bin/shell/chunks/ln-PZ7JHGH2.js +0 -2
- package/dist/bin/shell/chunks/ls-SLO257WP.js +0 -2
- package/dist/bin/shell/chunks/md5sum-WYOOUOWI.js +0 -2
- package/dist/bin/shell/chunks/mkdir-EOATYYLD.js +0 -2
- package/dist/bin/shell/chunks/mv-QUAFQDCT.js +0 -2
- package/dist/bin/shell/chunks/nl-WZC4GKMG.js +0 -2
- package/dist/bin/shell/chunks/od-IMVAQQIR.js +0 -2
- package/dist/bin/shell/chunks/paste-6XYPZQXQ.js +0 -2
- package/dist/bin/shell/chunks/printf-OCMANWQ5.js +0 -2
- package/dist/bin/shell/chunks/pwd-PQGDLYLZ.js +0 -2
- package/dist/bin/shell/chunks/python3-HNLPOBYQ.js +0 -14
- package/dist/bin/shell/chunks/readlink-F66ORZVY.js +0 -2
- package/dist/bin/shell/chunks/rev-67WGH7WN.js +0 -2
- package/dist/bin/shell/chunks/rg-LTQYHOCO.js +0 -2
- package/dist/bin/shell/chunks/rm-BZWDOVUX.js +0 -2
- package/dist/bin/shell/chunks/rmdir-5MNK2AUK.js +0 -2
- package/dist/bin/shell/chunks/sed-HN3E3YFB.js +0 -2
- package/dist/bin/shell/chunks/seq-IDAAUGIL.js +0 -2
- package/dist/bin/shell/chunks/sha1sum-Y2J25KOM.js +0 -2
- package/dist/bin/shell/chunks/sha256sum-NFAAGL44.js +0 -2
- package/dist/bin/shell/chunks/sleep-CPJ3WJE7.js +0 -2
- package/dist/bin/shell/chunks/sort-FT4OVPSS.js +0 -2
- package/dist/bin/shell/chunks/split-AXXLODUK.js +0 -2
- package/dist/bin/shell/chunks/sqlite3-DUARNSNG.js +0 -2
- package/dist/bin/shell/chunks/stat-6QXPS4BF.js +0 -2
- package/dist/bin/shell/chunks/strings-7CJI5ESD.js +0 -2
- package/dist/bin/shell/chunks/tac-Q5VNKVXE.js +0 -2
- package/dist/bin/shell/chunks/tail-EI24LQBP.js +0 -2
- package/dist/bin/shell/chunks/tar-M7QCUJ4B.js +0 -2
- package/dist/bin/shell/chunks/tee-6TEQ3DXN.js +0 -2
- package/dist/bin/shell/chunks/time-GJWZLHLN.js +0 -2
- package/dist/bin/shell/chunks/timeout-LPVVIBNB.js +0 -2
- package/dist/bin/shell/chunks/touch-J6X4OW3P.js +0 -2
- package/dist/bin/shell/chunks/tr-2C3Q77EZ.js +0 -2
- package/dist/bin/shell/chunks/tree-RLXLQJVI.js +0 -2
- package/dist/bin/shell/chunks/true-ZPDUMWHQ.js +0 -2
- package/dist/bin/shell/chunks/unexpand-AUQHJMGI.js +0 -2
- package/dist/bin/shell/chunks/uniq-C3ZUQTF4.js +0 -2
- package/dist/bin/shell/chunks/wc-NNQHXBLM.js +0 -2
- package/dist/bin/shell/chunks/which-QKNHOQPQ.js +0 -2
- package/dist/bin/shell/chunks/whoami-KIB3RVBF.js +0 -2
- package/dist/bin/shell/chunks/xan-BGDVQKRZ.js +0 -2
- package/dist/bin/shell/chunks/xan-view-GTANKIPW.js +0 -2
- package/dist/bin/shell/chunks/xargs-I7QRUR36.js +0 -2
- package/dist/bin/shell/chunks/yes-A2LPETVU.js +0 -2
- package/dist/bin/shell/chunks/yq-W7OKSS7Z.js +0 -2
- package/dist/bundle/chunks/alias-JHV3WNPA.js +0 -1
- package/dist/bundle/chunks/awk2-LA5EZ6UJ.js +0 -1
- package/dist/bundle/chunks/base64-DP3BVL7J.js +0 -1
- package/dist/bundle/chunks/basename-NCIQLNXY.js +0 -1
- package/dist/bundle/chunks/bash-CN3UUJ3N.js +0 -1
- package/dist/bundle/chunks/cat-KHANCARN.js +0 -1
- package/dist/bundle/chunks/chmod-A3HCFC4L.js +0 -1
- package/dist/bundle/chunks/chunk-26DNZXYZ.js +0 -23
- package/dist/bundle/chunks/chunk-26VNLF3H.js +0 -6
- package/dist/bundle/chunks/chunk-2AMXQD57.js +0 -11
- package/dist/bundle/chunks/chunk-2OIUNVMP.js +0 -10
- package/dist/bundle/chunks/chunk-2V4QPJXQ.js +0 -19
- package/dist/bundle/chunks/chunk-2WN53CVO.js +0 -15
- package/dist/bundle/chunks/chunk-3ANOKDIL.js +0 -5
- package/dist/bundle/chunks/chunk-3P5XOPF6.js +0 -1
- package/dist/bundle/chunks/chunk-44V5AOJ4.js +0 -8
- package/dist/bundle/chunks/chunk-4PFDHMBC.js +0 -8
- package/dist/bundle/chunks/chunk-53I2XH4A.js +0 -9
- package/dist/bundle/chunks/chunk-5BF5Z7CI.js +0 -1
- package/dist/bundle/chunks/chunk-5J57FRET.js +0 -4
- package/dist/bundle/chunks/chunk-5PIFIDMP.js +0 -13
- package/dist/bundle/chunks/chunk-5PV2QBWC.js +0 -5
- package/dist/bundle/chunks/chunk-6RAG3BOS.js +0 -2
- package/dist/bundle/chunks/chunk-6V537K6X.js +0 -1
- package/dist/bundle/chunks/chunk-72YPFG2Z.js +0 -5
- package/dist/bundle/chunks/chunk-7USKQKOT.js +0 -1
- package/dist/bundle/chunks/chunk-ATPJVO6F.js +0 -8
- package/dist/bundle/chunks/chunk-BJQMZYH3.js +0 -22
- package/dist/bundle/chunks/chunk-BQFHZOZH.js +0 -99
- package/dist/bundle/chunks/chunk-BTTTDUMD.js +0 -1
- package/dist/bundle/chunks/chunk-BXVXYDEI.js +0 -286
- package/dist/bundle/chunks/chunk-C325X4RB.js +0 -7
- package/dist/bundle/chunks/chunk-C44B5265.js +0 -2
- package/dist/bundle/chunks/chunk-D3IE6KOV.js +0 -21
- package/dist/bundle/chunks/chunk-D4LWWAJ2.js +0 -6
- package/dist/bundle/chunks/chunk-DNPCEBCN.js +0 -2
- package/dist/bundle/chunks/chunk-EHRCEDXN.js +0 -13
- package/dist/bundle/chunks/chunk-EHY6GWKP.js +0 -8
- package/dist/bundle/chunks/chunk-F77E6PCM.js +0 -7
- package/dist/bundle/chunks/chunk-GET3OC3O.js +0 -8
- package/dist/bundle/chunks/chunk-GMCBEP44.js +0 -16
- package/dist/bundle/chunks/chunk-GNXHG75U.js +0 -1
- package/dist/bundle/chunks/chunk-GQSJJXDG.js +0 -3
- package/dist/bundle/chunks/chunk-H5X25CTO.js +0 -6
- package/dist/bundle/chunks/chunk-IAFRFK2O.js +0 -9
- package/dist/bundle/chunks/chunk-IJXFPKNC.js +0 -1
- package/dist/bundle/chunks/chunk-INJTM5VR.js +0 -5
- package/dist/bundle/chunks/chunk-J7YL5K5B.js +0 -2
- package/dist/bundle/chunks/chunk-JJ5E4XJI.js +0 -13
- package/dist/bundle/chunks/chunk-JMFP263D.js +0 -1
- package/dist/bundle/chunks/chunk-JSLN56GJ.js +0 -7
- package/dist/bundle/chunks/chunk-K374E7Q4.js +0 -8
- package/dist/bundle/chunks/chunk-K7ZRPFN6.js +0 -6
- package/dist/bundle/chunks/chunk-KBCEHRTU.js +0 -4
- package/dist/bundle/chunks/chunk-KRXVUD4L.js +0 -4
- package/dist/bundle/chunks/chunk-LBJIRX7Z.js +0 -6
- package/dist/bundle/chunks/chunk-M5Z2PSET.js +0 -31
- package/dist/bundle/chunks/chunk-MOCB6GPI.js +0 -62
- package/dist/bundle/chunks/chunk-NDPSDM3Q.js +0 -32
- package/dist/bundle/chunks/chunk-OZ76IUC5.js +0 -10
- package/dist/bundle/chunks/chunk-PEPBD26Q.js +0 -2
- package/dist/bundle/chunks/chunk-PES2WOIM.js +0 -15
- package/dist/bundle/chunks/chunk-PLMPLLOW.js +0 -12
- package/dist/bundle/chunks/chunk-PQPG4QOY.js +0 -22
- package/dist/bundle/chunks/chunk-PUUP54QP.js +0 -9
- package/dist/bundle/chunks/chunk-Q5XZ24VX.js +0 -6
- package/dist/bundle/chunks/chunk-QOFUETQV.js +0 -4
- package/dist/bundle/chunks/chunk-QPHABKP3.js +0 -11
- package/dist/bundle/chunks/chunk-R7SSLDTN.js +0 -6
- package/dist/bundle/chunks/chunk-RTGKIAVM.js +0 -6
- package/dist/bundle/chunks/chunk-RZ4GSKWY.js +0 -7
- package/dist/bundle/chunks/chunk-SF2462OV.js +0 -3
- package/dist/bundle/chunks/chunk-SJ7F47VW.js +0 -6
- package/dist/bundle/chunks/chunk-SMOO4IXI.js +0 -1
- package/dist/bundle/chunks/chunk-SYTEZ2Y4.js +0 -5
- package/dist/bundle/chunks/chunk-TOK4OQFP.js +0 -13
- package/dist/bundle/chunks/chunk-U5Z7TJRO.js +0 -11
- package/dist/bundle/chunks/chunk-U6GF4IJH.js +0 -72
- package/dist/bundle/chunks/chunk-ULK572PS.js +0 -7
- package/dist/bundle/chunks/chunk-URMOT4S7.js +0 -4
- package/dist/bundle/chunks/chunk-USGCTFXK.js +0 -2
- package/dist/bundle/chunks/chunk-VKPVP3LD.js +0 -4
- package/dist/bundle/chunks/chunk-W4YQKIRV.js +0 -35
- package/dist/bundle/chunks/chunk-WMCZEPWH.js +0 -8
- package/dist/bundle/chunks/chunk-WTT2UCIA.js +0 -20
- package/dist/bundle/chunks/chunk-WVUVOYGQ.js +0 -10
- package/dist/bundle/chunks/chunk-XXS34VJC.js +0 -12
- package/dist/bundle/chunks/chunk-XZMBEDQL.js +0 -7
- package/dist/bundle/chunks/chunk-XZZ3XIZH.js +0 -15
- package/dist/bundle/chunks/chunk-YJHMB6QD.js +0 -17
- package/dist/bundle/chunks/chunk-YNYSPYQ5.js +0 -32
- package/dist/bundle/chunks/chunk-YR4NQYT4.js +0 -1
- package/dist/bundle/chunks/chunk-YZPQ2W3A.js +0 -139
- package/dist/bundle/chunks/chunk-Z6DABRIE.js +0 -12
- package/dist/bundle/chunks/chunk-ZEHOKNGQ.js +0 -2
- package/dist/bundle/chunks/chunk-ZILSBZZ6.js +0 -4
- package/dist/bundle/chunks/clear-7SIFUXVD.js +0 -1
- package/dist/bundle/chunks/column-OUJRIWLX.js +0 -1
- package/dist/bundle/chunks/comm-47FVEMHB.js +0 -1
- package/dist/bundle/chunks/cp-FD6I3O6B.js +0 -1
- package/dist/bundle/chunks/curl-3MHMRKXA.js +0 -25
- package/dist/bundle/chunks/cut-LQZW2NZP.js +0 -1
- package/dist/bundle/chunks/date-4I2XIKHX.js +0 -1
- package/dist/bundle/chunks/diff-7ZYMEVUP.js +0 -1
- package/dist/bundle/chunks/dirname-IVA4YYRE.js +0 -1
- package/dist/bundle/chunks/du-H4GJHM4R.js +0 -1
- package/dist/bundle/chunks/echo-ZPFMTGPQ.js +0 -1
- package/dist/bundle/chunks/env-ZCKP6263.js +0 -1
- package/dist/bundle/chunks/expand-Y7EMR5BJ.js +0 -1
- package/dist/bundle/chunks/expansion-GYIQOAHW.js +0 -1
- package/dist/bundle/chunks/expr-WDFXVU43.js +0 -1
- package/dist/bundle/chunks/file-7WSECN2B.js +0 -1
- package/dist/bundle/chunks/find-BYG3GTNV.js +0 -1
- package/dist/bundle/chunks/flag-coverage-IEYW6QK2.js +0 -1
- package/dist/bundle/chunks/fold-6O4H3AW4.js +0 -1
- package/dist/bundle/chunks/grep-KLQ4A2OH.js +0 -1
- package/dist/bundle/chunks/gzip-BYGAV4XY.js +0 -1
- package/dist/bundle/chunks/head-CIKXFGO5.js +0 -1
- package/dist/bundle/chunks/help-B2UCSYQN.js +0 -1
- package/dist/bundle/chunks/history-N2VRLHEO.js +0 -1
- package/dist/bundle/chunks/hostname-W7U3GOEK.js +0 -1
- package/dist/bundle/chunks/html-to-markdown-ZDG5GHHM.js +0 -1
- package/dist/bundle/chunks/join-CFMKSF44.js +0 -1
- package/dist/bundle/chunks/jq-BE76GAFF.js +0 -1
- package/dist/bundle/chunks/ln-N3OWFM3J.js +0 -1
- package/dist/bundle/chunks/ls-JAO4QNWZ.js +0 -1
- package/dist/bundle/chunks/md5sum-ZK2D5HMO.js +0 -1
- package/dist/bundle/chunks/mkdir-O74MZREV.js +0 -1
- package/dist/bundle/chunks/mv-66ALAQRO.js +0 -1
- package/dist/bundle/chunks/nl-JSPXHHOM.js +0 -1
- package/dist/bundle/chunks/od-NUINXLUX.js +0 -1
- package/dist/bundle/chunks/paste-Y7CG4TKC.js +0 -1
- package/dist/bundle/chunks/printf-223LFYZL.js +0 -1
- package/dist/bundle/chunks/pwd-BP6H5JPD.js +0 -1
- package/dist/bundle/chunks/python3-2KEMASKS.js +0 -13
- package/dist/bundle/chunks/readlink-JL7TKP5U.js +0 -1
- package/dist/bundle/chunks/rev-UN4ZHPP5.js +0 -1
- package/dist/bundle/chunks/rg-RA3U4BVJ.js +0 -1
- package/dist/bundle/chunks/rm-NIZVTCU7.js +0 -1
- package/dist/bundle/chunks/rmdir-LGJXG7S3.js +0 -1
- package/dist/bundle/chunks/sed-JJ3WRWYT.js +0 -1
- package/dist/bundle/chunks/seq-SXS6YKWX.js +0 -1
- package/dist/bundle/chunks/sha1sum-BB464H3H.js +0 -1
- package/dist/bundle/chunks/sha256sum-PPJUHZ6A.js +0 -1
- package/dist/bundle/chunks/sleep-YQMDXMVK.js +0 -1
- package/dist/bundle/chunks/sort-BNPU2P3T.js +0 -1
- package/dist/bundle/chunks/split-SVMZIFGF.js +0 -1
- package/dist/bundle/chunks/sqlite3-PZGLI6XB.js +0 -1
- package/dist/bundle/chunks/stat-2CKLARLN.js +0 -1
- package/dist/bundle/chunks/strings-LG7URPXR.js +0 -1
- package/dist/bundle/chunks/tac-NXGTFB5T.js +0 -1
- package/dist/bundle/chunks/tail-GJ536HFQ.js +0 -1
- package/dist/bundle/chunks/tar-3KCFO6WZ.js +0 -1
- package/dist/bundle/chunks/tee-PJ6B6JJF.js +0 -1
- package/dist/bundle/chunks/time-IENYNVU4.js +0 -1
- package/dist/bundle/chunks/timeout-SXUKTL7R.js +0 -1
- package/dist/bundle/chunks/touch-7BNOFP74.js +0 -1
- package/dist/bundle/chunks/tr-TB6CSIUV.js +0 -1
- package/dist/bundle/chunks/tree-4XRVONUX.js +0 -1
- package/dist/bundle/chunks/true-4UI5ZW75.js +0 -1
- package/dist/bundle/chunks/unexpand-LDC3OTY4.js +0 -1
- package/dist/bundle/chunks/uniq-ZHYLWEFM.js +0 -1
- package/dist/bundle/chunks/wc-PWYVRT3X.js +0 -1
- package/dist/bundle/chunks/which-EIT2IJGG.js +0 -1
- package/dist/bundle/chunks/whoami-QZJHAL2R.js +0 -1
- package/dist/bundle/chunks/xan-JDD2TEQH.js +0 -1
- package/dist/bundle/chunks/xan-view-WKPGEZFG.js +0 -1
- package/dist/bundle/chunks/xargs-CB3LOKW5.js +0 -1
- package/dist/bundle/chunks/yes-2J55KNKF.js +0 -1
- package/dist/bundle/chunks/yq-JFXSVU6G.js +0 -1
package/dist/bin/shell/shell.js
CHANGED
|
@@ -1,158 +1,149 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{A as ms,C as Or,D as Dr,E as ye,F as He,G as oe,H as Pe,I as Tt,J as Ir,K as V,L as Rr,M as Lr,N as De,O as ys,P as Ot,Q as Ze,R as X,a as $r,b as us,c as Ar,d as _r,e as Nt,f as re,g as G,h as xe,i as ce,j as Te,k as ze,l as fs,m as xt,n as kr,o as ds,p as Cr,q as me,r as Le,s as Pr,t as Nr,u as hs,v as ps,w as Oe,x as xr,y as Tr,z as Ce}from"./chunks/chunk-YJFLWG5Q.js";import{a as Er}from"./chunks/chunk-RUESYAVK.js";import{a as We,b as ke}from"./chunks/chunk-CAXM2HMK.js";import{a as ut}from"./chunks/chunk-SE4C7FJY.js";import{a as be,b as Se,c as pe,d as $e,e as br,f as Z,g as je,h as kt,i as Ct,j as Sr,k as fe,l as Fe,m as Pt,n as Ae}from"./chunks/chunk-XILOLP4K.js";import"./chunks/chunk-OBH7XN5N.js";import{a as _e}from"./chunks/chunk-4VDEBYW7.js";import{a as lt,b as w,c as se,d as he,e as N,f as Y,g as ct,h as D,i as cs,j as _t}from"./chunks/chunk-RAUBS6MJ.js";import{a as At,g as M,h as B,i as H,j as vr,k as at,l as T,m as g}from"./chunks/chunk-463VWH7H.js";import*as mi from"node:fs";import*as yi from"node:readline";var Ye=[{name:"echo",load:async()=>(await import("./chunks/echo-5EBIR54T.js")).echoCommand},{name:"cat",load:async()=>(await import("./chunks/cat-D4E4FTXJ.js")).catCommand},{name:"printf",load:async()=>(await import("./chunks/printf-OCMANWQ5.js")).printfCommand},{name:"ls",load:async()=>(await import("./chunks/ls-SLO257WP.js")).lsCommand},{name:"mkdir",load:async()=>(await import("./chunks/mkdir-EOATYYLD.js")).mkdirCommand},{name:"rmdir",load:async()=>(await import("./chunks/rmdir-5MNK2AUK.js")).rmdirCommand},{name:"touch",load:async()=>(await import("./chunks/touch-J6X4OW3P.js")).touchCommand},{name:"rm",load:async()=>(await import("./chunks/rm-BZWDOVUX.js")).rmCommand},{name:"cp",load:async()=>(await import("./chunks/cp-7TMSGOID.js")).cpCommand},{name:"mv",load:async()=>(await import("./chunks/mv-QUAFQDCT.js")).mvCommand},{name:"ln",load:async()=>(await import("./chunks/ln-PZ7JHGH2.js")).lnCommand},{name:"chmod",load:async()=>(await import("./chunks/chmod-OY5CP5QF.js")).chmodCommand},{name:"pwd",load:async()=>(await import("./chunks/pwd-PQGDLYLZ.js")).pwdCommand},{name:"readlink",load:async()=>(await import("./chunks/readlink-F66ORZVY.js")).readlinkCommand},{name:"head",load:async()=>(await import("./chunks/head-YZQN4BHR.js")).headCommand},{name:"tail",load:async()=>(await import("./chunks/tail-EI24LQBP.js")).tailCommand},{name:"wc",load:async()=>(await import("./chunks/wc-NNQHXBLM.js")).wcCommand},{name:"stat",load:async()=>(await import("./chunks/stat-6QXPS4BF.js")).statCommand},{name:"grep",load:async()=>(await import("./chunks/grep-6OXCYWRV.js")).grepCommand},{name:"fgrep",load:async()=>(await import("./chunks/grep-6OXCYWRV.js")).fgrepCommand},{name:"egrep",load:async()=>(await import("./chunks/grep-6OXCYWRV.js")).egrepCommand},{name:"rg",load:async()=>(await import("./chunks/rg-LTQYHOCO.js")).rgCommand},{name:"sed",load:async()=>(await import("./chunks/sed-HN3E3YFB.js")).sedCommand},{name:"awk",load:async()=>(await import("./chunks/awk2-GM5WBRLU.js")).awkCommand2},{name:"sort",load:async()=>(await import("./chunks/sort-FT4OVPSS.js")).sortCommand},{name:"uniq",load:async()=>(await import("./chunks/uniq-C3ZUQTF4.js")).uniqCommand},{name:"comm",load:async()=>(await import("./chunks/comm-LMDA7QZC.js")).commCommand},{name:"cut",load:async()=>(await import("./chunks/cut-P6LPALWP.js")).cutCommand},{name:"paste",load:async()=>(await import("./chunks/paste-6XYPZQXQ.js")).pasteCommand},{name:"tr",load:async()=>(await import("./chunks/tr-2C3Q77EZ.js")).trCommand},{name:"rev",load:async()=>(await import("./chunks/rev-67WGH7WN.js")).rev},{name:"nl",load:async()=>(await import("./chunks/nl-WZC4GKMG.js")).nl},{name:"fold",load:async()=>(await import("./chunks/fold-SK55D7OX.js")).fold},{name:"expand",load:async()=>(await import("./chunks/expand-672ZQYZF.js")).expand},{name:"unexpand",load:async()=>(await import("./chunks/unexpand-AUQHJMGI.js")).unexpand},{name:"strings",load:async()=>(await import("./chunks/strings-7CJI5ESD.js")).strings},{name:"split",load:async()=>(await import("./chunks/split-AXXLODUK.js")).split},{name:"column",load:async()=>(await import("./chunks/column-5CUPANJY.js")).column},{name:"join",load:async()=>(await import("./chunks/join-ZK67SMQ3.js")).join},{name:"tee",load:async()=>(await import("./chunks/tee-6TEQ3DXN.js")).teeCommand},{name:"find",load:async()=>(await import("./chunks/find-BXGQE44U.js")).findCommand},{name:"basename",load:async()=>(await import("./chunks/basename-XCXGYZPS.js")).basenameCommand},{name:"dirname",load:async()=>(await import("./chunks/dirname-3LHNBKNB.js")).dirnameCommand},{name:"tree",load:async()=>(await import("./chunks/tree-RLXLQJVI.js")).treeCommand},{name:"du",load:async()=>(await import("./chunks/du-DEYTW2KI.js")).duCommand},{name:"env",load:async()=>(await import("./chunks/env-PWRJFDWL.js")).envCommand},{name:"printenv",load:async()=>(await import("./chunks/env-PWRJFDWL.js")).printenvCommand},{name:"alias",load:async()=>(await import("./chunks/alias-DRSSCAUM.js")).aliasCommand},{name:"unalias",load:async()=>(await import("./chunks/alias-DRSSCAUM.js")).unaliasCommand},{name:"history",load:async()=>(await import("./chunks/history-W57S3E3C.js")).historyCommand},{name:"xargs",load:async()=>(await import("./chunks/xargs-I7QRUR36.js")).xargsCommand},{name:"true",load:async()=>(await import("./chunks/true-ZPDUMWHQ.js")).trueCommand},{name:"false",load:async()=>(await import("./chunks/true-ZPDUMWHQ.js")).falseCommand},{name:"clear",load:async()=>(await import("./chunks/clear-P5EG7Z6I.js")).clearCommand},{name:"yes",load:async()=>(await import("./chunks/yes-A2LPETVU.js")).yesCommand},{name:"bash",load:async()=>(await import("./chunks/bash-U2E2FSIE.js")).bashCommand},{name:"sh",load:async()=>(await import("./chunks/bash-U2E2FSIE.js")).shCommand},{name:"jq",load:async()=>(await import("./chunks/jq-2BGA6KZ3.js")).jqCommand},{name:"base64",load:async()=>(await import("./chunks/base64-KLZ4B6VS.js")).base64Command},{name:"diff",load:async()=>(await import("./chunks/diff-SGBANTKE.js")).diffCommand},{name:"date",load:async()=>(await import("./chunks/date-P3YMHSRG.js")).dateCommand},{name:"sleep",load:async()=>(await import("./chunks/sleep-CPJ3WJE7.js")).sleepCommand},{name:"timeout",load:async()=>(await import("./chunks/timeout-LPVVIBNB.js")).timeoutCommand},{name:"time",load:async()=>(await import("./chunks/time-GJWZLHLN.js")).timeCommand},{name:"seq",load:async()=>(await import("./chunks/seq-IDAAUGIL.js")).seqCommand},{name:"expr",load:async()=>(await import("./chunks/expr-SWYNZXDP.js")).exprCommand},{name:"md5sum",load:async()=>(await import("./chunks/md5sum-WYOOUOWI.js")).md5sumCommand},{name:"sha1sum",load:async()=>(await import("./chunks/sha1sum-Y2J25KOM.js")).sha1sumCommand},{name:"sha256sum",load:async()=>(await import("./chunks/sha256sum-NFAAGL44.js")).sha256sumCommand},{name:"file",load:async()=>(await import("./chunks/file-MIXTZ4NP.js")).fileCommand},{name:"html-to-markdown",load:async()=>(await import("./chunks/html-to-markdown-2AHE4ET2.js")).htmlToMarkdownCommand},{name:"help",load:async()=>(await import("./chunks/help-R7JNUPU2.js")).helpCommand},{name:"which",load:async()=>(await import("./chunks/which-QKNHOQPQ.js")).whichCommand},{name:"tac",load:async()=>(await import("./chunks/tac-Q5VNKVXE.js")).tac},{name:"hostname",load:async()=>(await import("./chunks/hostname-NPAYFT3O.js")).hostname},{name:"whoami",load:async()=>(await import("./chunks/whoami-KIB3RVBF.js")).whoami},{name:"od",load:async()=>(await import("./chunks/od-IMVAQQIR.js")).od},{name:"gzip",load:async()=>(await import("./chunks/gzip-AKQBQW7Y.js")).gzipCommand},{name:"gunzip",load:async()=>(await import("./chunks/gzip-AKQBQW7Y.js")).gunzipCommand},{name:"zcat",load:async()=>(await import("./chunks/gzip-AKQBQW7Y.js")).zcatCommand}];(typeof __BROWSER__>"u"||!__BROWSER__)&&(Ye.push({name:"tar",load:async()=>(await import("./chunks/tar-M7QCUJ4B.js")).tarCommand}),Ye.push({name:"yq",load:async()=>(await import("./chunks/yq-W7OKSS7Z.js")).yqCommand}),Ye.push({name:"xan",load:async()=>(await import("./chunks/xan-BGDVQKRZ.js")).xanCommand}),Ye.push({name:"sqlite3",load:async()=>(await import("./chunks/sqlite3-DUARNSNG.js")).sqlite3Command}));var gs=[];(typeof __BROWSER__>"u"||!__BROWSER__)&&(gs.push({name:"python3",load:async()=>(await import("./chunks/python3-HNLPOBYQ.js")).python3Command}),gs.push({name:"python",load:async()=>(await import("./chunks/python3-HNLPOBYQ.js")).pythonCommand}));var bi=[{name:"curl",load:async()=>(await import("./chunks/curl-P6DHVAKR.js")).curlCommand}],Mr=new Map;function ws(e){return{name:e.name,async execute(t,s){let r=Mr.get(e.name);if(r||(r=await e.load(),Mr.set(e.name,r)),s.coverage&&(typeof __BROWSER__>"u"||!__BROWSER__)){let{emitFlagCoverage:n}=await import("./chunks/flag-coverage-JA424IHF.js"),{decodeArgs:i}=await import("./chunks/bytes-C34BYEMS.js");n(s.coverage,e.name,i(t))}return r.execute(t,s)}}}function Fr(e){return(e?Ye.filter(s=>e.includes(s.name)):Ye).map(ws)}function Wr(){return bi.map(ws)}function zr(){return gs.map(ws)}function Vr(e){return"load"in e&&typeof e.load=="function"}function Br(e){let t=null;return{name:e.name,async execute(s,r){return t||(t=await e.load()),t.execute(s,r)}}}var Si=new TextEncoder;function Ei(e){return typeof e=="object"&&e!==null&&typeof e.getReader=="function"}function $i(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 Si.encode(e)}function Hr(e){if(e.length===0)return[];if(e.length<=lt)return[e];let t=[];for(let s=0;s<e.length;s+=lt)t.push(e.subarray(s,Math.min(s+lt,e.length)));return t}function Xe(e,t){let s=$i(e,t);return{chunks:Hr(s),size:s.length}}async function Ke(e,t){if(Ei(e)){let s=[],r=0;for await(let n of _t(e))if(n.length<=lt)s.push(n),r+=n.length;else for(let i of Hr(n))s.push(i),r+=i.length;return{chunks:s,size:r}}return Xe(e,t)}function Dt(e,t){if(t==="base64")return btoa(Er(jr(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(jr(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 jr(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 Me(e){if(e!=null)return typeof e=="string"?e:e.encoding??void 0}function It(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 Rt(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 Ai(e){return typeof e=="object"&&e!==null&&!(e instanceof Uint8Array)&&!(e instanceof ReadableStream)&&"content"in e}function ne(e,t){if(e.includes("\0"))throw new Error(`ENOENT: path contains null byte, ${t} '${e}'`)}var ft=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(Ai(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){ne(t,"write");let i=this.normalizePath(t);this.ensureParentDirs(i);let o=Me(r),{chunks:a,size:l}=Xe(s,o);this.data.set(i,{type:"file",chunks:a,size:l,mode:n?.mode??420,mtime:n?.mtime??new Date})}async readFile(t){ne(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){It(s,r),ne(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 Rt(i.chunks,i.size,s,r)}async readFileText(t,s){ne(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=Me(s);return Dt(n.chunks,i)}async writeFile(t,s,r){ne(t,"write");let n=this.normalizePath(t);this.ensureParentDirs(n);let i=Me(r),{chunks:o,size:a}=await Ke(s,i);this.data.set(n,{type:"file",chunks:o,size:a,mode:420,mtime:new Date})}async appendFile(t,s,r){ne(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=Me(r),{chunks:a,size:l}=await Ke(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){ne(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){ne(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){ne(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){ne(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){ne(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){ne(t,"cp"),ne(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){ne(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){ne(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){ne(t,"link"),ne(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){ne(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){ne(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){ne(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 _i(e){let t=e;return typeof t.mkdirSync=="function"&&typeof t.writeFileSync=="function"}function ki(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 Ci(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 Pi(e){e.mkdirSync("/proc/self/fd",{recursive:!0}),e.writeFileSync("/proc/version",`${$r}
|
|
2
|
+
import{$ as vr,A as Fs,B as Kt,C as cr,D as Vs,E as ur,F as be,G as He,H as fr,I as dr,J as zs,K as js,L as Fe,M as hr,N as pr,O as De,P as Bs,R as mr,S as gr,T as Se,U as tt,V as ue,W as Ie,X as Yt,Y as yr,Z as z,_ as wr,a as or,aa as Ve,b as Ls,ba as br,c as ar,ca as Sr,d as lr,da as ot,e as Zt,ea as Q,f as le,g as Z,h as Le,i as Jt,j as et,k as Ms,l as Ws,m as Me,n as kt,o as Pt,p as U,q as _e,r as K,s as _t,t as Y,u as ee,v as Ze,w as te,x as pe,y as We,z as Je}from"./chunks/chunk-73X3QWRT.js";import{a as Ct}from"./chunks/chunk-JGKR7YR7.js";import{a as ir}from"./chunks/chunk-RUESYAVK.js";import{a as qe,b as Pe}from"./chunks/chunk-CAXM2HMK.js";import{a as At}from"./chunks/chunk-N7YAMUQG.js";import{a as Ae,b as Ce,c as we,d as ke,e as sr,f as q,g as Xe,h as $t,i as Gt,j as nr,k as oe,l as rr,m as me,n as Qe,o as Be,p as qt,q as ve}from"./chunks/chunk-A257OMG4.js";import"./chunks/chunk-OBH7XN5N.js";import{a as Oe}from"./chunks/chunk-4VDEBYW7.js";import{a as St,b as E,d as he,e as Et,f as V,g as ie,h as tr,i as it,j as Ut}from"./chunks/chunk-6VQWCKYE.js";import{a as Ht,g as L,h as F,i as H,j as er,k as bt,l as x,m as y}from"./chunks/chunk-463VWH7H.js";import*as eo from"node:fs";import*as to from"node:readline";var at=[{name:"echo",load:async()=>(await import("./chunks/echo-DHVSEP57.js")).echoCommand},{name:"cat",load:async()=>(await import("./chunks/cat-UO3ZDQHP.js")).catCommand},{name:"printf",load:async()=>(await import("./chunks/printf-CVEJOTYB.js")).printfCommand},{name:"ls",load:async()=>(await import("./chunks/ls-LBW3TTPI.js")).lsCommand},{name:"mkdir",load:async()=>(await import("./chunks/mkdir-UUOVKGHS.js")).mkdirCommand},{name:"rmdir",load:async()=>(await import("./chunks/rmdir-NJCSEPRP.js")).rmdirCommand},{name:"touch",load:async()=>(await import("./chunks/touch-4ZSEFYEW.js")).touchCommand},{name:"rm",load:async()=>(await import("./chunks/rm-UMIY7ESO.js")).rmCommand},{name:"cp",load:async()=>(await import("./chunks/cp-YSXTOMBS.js")).cpCommand},{name:"mv",load:async()=>(await import("./chunks/mv-7VY5OVAU.js")).mvCommand},{name:"ln",load:async()=>(await import("./chunks/ln-2OLFXJYU.js")).lnCommand},{name:"chmod",load:async()=>(await import("./chunks/chmod-GYXHDITN.js")).chmodCommand},{name:"pwd",load:async()=>(await import("./chunks/pwd-6OLMY3MQ.js")).pwdCommand},{name:"readlink",load:async()=>(await import("./chunks/readlink-T4CDCG4Z.js")).readlinkCommand},{name:"head",load:async()=>(await import("./chunks/head-HT46A7YT.js")).headCommand},{name:"tail",load:async()=>(await import("./chunks/tail-LOVA3SKT.js")).tailCommand},{name:"wc",load:async()=>(await import("./chunks/wc-TDIG4RIU.js")).wcCommand},{name:"stat",load:async()=>(await import("./chunks/stat-J5TUE4U5.js")).statCommand},{name:"grep",load:async()=>(await import("./chunks/grep-RG26XCUN.js")).grepCommand},{name:"fgrep",load:async()=>(await import("./chunks/grep-RG26XCUN.js")).fgrepCommand},{name:"egrep",load:async()=>(await import("./chunks/grep-RG26XCUN.js")).egrepCommand},{name:"rg",load:async()=>(await import("./chunks/rg-PQP4HTR3.js")).rgCommand},{name:"sed",load:async()=>(await import("./chunks/sed-BZW7POX3.js")).sedCommand},{name:"awk",load:async()=>(await import("./chunks/awk2-FB5MXVFV.js")).awkCommand2},{name:"sort",load:async()=>(await import("./chunks/sort-TO3IPXI2.js")).sortCommand},{name:"uniq",load:async()=>(await import("./chunks/uniq-I2KNCRR6.js")).uniqCommand},{name:"comm",load:async()=>(await import("./chunks/comm-WKYJTISA.js")).commCommand},{name:"cut",load:async()=>(await import("./chunks/cut-2MSOLU4C.js")).cutCommand},{name:"paste",load:async()=>(await import("./chunks/paste-Q23K6FU7.js")).pasteCommand},{name:"tr",load:async()=>(await import("./chunks/tr-ARR7JBLN.js")).trCommand},{name:"rev",load:async()=>(await import("./chunks/rev-O3PQMT23.js")).rev},{name:"nl",load:async()=>(await import("./chunks/nl-34JIXDXD.js")).nl},{name:"fold",load:async()=>(await import("./chunks/fold-OVU7UR2E.js")).fold},{name:"expand",load:async()=>(await import("./chunks/expand-L4NT2YFK.js")).expand},{name:"unexpand",load:async()=>(await import("./chunks/unexpand-B4WHWJHL.js")).unexpand},{name:"strings",load:async()=>(await import("./chunks/strings-TDUSHGAB.js")).strings},{name:"split",load:async()=>(await import("./chunks/split-JXCUP73P.js")).split},{name:"column",load:async()=>(await import("./chunks/column-UCIEGSHJ.js")).column},{name:"join",load:async()=>(await import("./chunks/join-6M3ARIFB.js")).join},{name:"tee",load:async()=>(await import("./chunks/tee-SREYEKO6.js")).teeCommand},{name:"find",load:async()=>(await import("./chunks/find-B6JV4QSG.js")).findCommand},{name:"basename",load:async()=>(await import("./chunks/basename-ZFBDKUVW.js")).basenameCommand},{name:"dirname",load:async()=>(await import("./chunks/dirname-XXQNLCA4.js")).dirnameCommand},{name:"tree",load:async()=>(await import("./chunks/tree-7Y7H64VI.js")).treeCommand},{name:"du",load:async()=>(await import("./chunks/du-IKBAW7PG.js")).duCommand},{name:"env",load:async()=>(await import("./chunks/env-A43LGO53.js")).envCommand},{name:"printenv",load:async()=>(await import("./chunks/env-A43LGO53.js")).printenvCommand},{name:"alias",load:async()=>(await import("./chunks/alias-MILMQPGR.js")).aliasCommand},{name:"unalias",load:async()=>(await import("./chunks/alias-MILMQPGR.js")).unaliasCommand},{name:"history",load:async()=>(await import("./chunks/history-WO6CMWMT.js")).historyCommand},{name:"xargs",load:async()=>(await import("./chunks/xargs-6K57XYD6.js")).xargsCommand},{name:"true",load:async()=>(await import("./chunks/true-CKHNKYAT.js")).trueCommand},{name:"false",load:async()=>(await import("./chunks/true-CKHNKYAT.js")).falseCommand},{name:"clear",load:async()=>(await import("./chunks/clear-FZZM6QD2.js")).clearCommand},{name:"yes",load:async()=>(await import("./chunks/yes-7ZGUE2PX.js")).yesCommand},{name:"bash",load:async()=>(await import("./chunks/bash-FQY3C37R.js")).bashCommand},{name:"sh",load:async()=>(await import("./chunks/bash-FQY3C37R.js")).shCommand},{name:"jq",load:async()=>(await import("./chunks/jq-HP7VLWBL.js")).jqCommand},{name:"base64",load:async()=>(await import("./chunks/base64-NGAPXZAM.js")).base64Command},{name:"diff",load:async()=>(await import("./chunks/diff-4PEKV4XS.js")).diffCommand},{name:"date",load:async()=>(await import("./chunks/date-5LA42436.js")).dateCommand},{name:"sleep",load:async()=>(await import("./chunks/sleep-HDMKKRCV.js")).sleepCommand},{name:"timeout",load:async()=>(await import("./chunks/timeout-XBYZ5LW5.js")).timeoutCommand},{name:"time",load:async()=>(await import("./chunks/time-GS6SIFPK.js")).timeCommand},{name:"seq",load:async()=>(await import("./chunks/seq-3FRPQG5E.js")).seqCommand},{name:"expr",load:async()=>(await import("./chunks/expr-BGBONRHV.js")).exprCommand},{name:"md5sum",load:async()=>(await import("./chunks/md5sum-GAWU76ZU.js")).md5sumCommand},{name:"sha1sum",load:async()=>(await import("./chunks/sha1sum-AOZWHFTU.js")).sha1sumCommand},{name:"sha256sum",load:async()=>(await import("./chunks/sha256sum-EXJTAPU4.js")).sha256sumCommand},{name:"file",load:async()=>(await import("./chunks/file-DZRWWDPH.js")).fileCommand},{name:"html-to-markdown",load:async()=>(await import("./chunks/html-to-markdown-34LV4LFQ.js")).htmlToMarkdownCommand},{name:"help",load:async()=>(await import("./chunks/help-AOETY73Q.js")).helpCommand},{name:"which",load:async()=>(await import("./chunks/which-QMZ276XE.js")).whichCommand},{name:"tac",load:async()=>(await import("./chunks/tac-QXOHN3J4.js")).tac},{name:"hostname",load:async()=>(await import("./chunks/hostname-4O6NEPL2.js")).hostname},{name:"whoami",load:async()=>(await import("./chunks/whoami-XYB47VCX.js")).whoami},{name:"od",load:async()=>(await import("./chunks/od-IGVFBAFH.js")).od},{name:"gzip",load:async()=>(await import("./chunks/gzip-XZZL25AV.js")).gzipCommand},{name:"gunzip",load:async()=>(await import("./chunks/gzip-XZZL25AV.js")).gunzipCommand},{name:"zcat",load:async()=>(await import("./chunks/gzip-XZZL25AV.js")).zcatCommand}];(typeof __BROWSER__>"u"||!__BROWSER__)&&(at.push({name:"tar",load:async()=>(await import("./chunks/tar-BAKR5OJO.js")).tarCommand}),at.push({name:"yq",load:async()=>(await import("./chunks/yq-ZHYSTGN3.js")).yqCommand}),at.push({name:"xan",load:async()=>(await import("./chunks/xan-STBKXZ5W.js")).xanCommand}),at.push({name:"sqlite3",load:async()=>(await import("./chunks/sqlite3-K7LHCU76.js")).sqlite3Command}));var Hs=[];(typeof __BROWSER__>"u"||!__BROWSER__)&&(Hs.push({name:"python3",load:async()=>(await import("./chunks/python3-VZL5HRHR.js")).python3Command}),Hs.push({name:"python",load:async()=>(await import("./chunks/python3-VZL5HRHR.js")).pythonCommand}));var io=[{name:"curl",load:async()=>(await import("./chunks/curl-YFYJ2XNC.js")).curlCommand}],Er=new Map;function Us(e){return{name:e.name,async execute(t,s){let n=Er.get(e.name);if(n||(n=await e.load(),Er.set(e.name,n)),s.coverage&&(typeof __BROWSER__>"u"||!__BROWSER__)){let{emitFlagCoverage:r}=await import("./chunks/flag-coverage-FTS7XXHM.js"),{decodeArgs:i}=await import("./chunks/bytes-C34BYEMS.js");r(s.coverage,e.name,i(t))}return n.execute(t,s)}}}function $r(e){return(e?at.filter(s=>e.includes(s.name)):at).map(Us)}function Ar(){return io.map(Us)}function Cr(){return Hs.map(Us)}function kr(e){return"load"in e&&typeof e.load=="function"}function Pr(e){let t=null;return{name:e.name,async execute(s,n){return t||(t=await e.load()),t.execute(s,n)}}}var oo=new TextEncoder;function ao(e){return typeof e=="object"&&e!==null&&typeof e.getReader=="function"}function lo(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 n=0;n<e.length;n+=2)s[n/2]=parseInt(e.slice(n,n+2),16);return s}if(t==="binary"||t==="latin1"){if(e.length<=65536)return Uint8Array.from(e,r=>r.charCodeAt(0));let n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e.charCodeAt(r);return n}return oo.encode(e)}function Tr(e){if(e.length===0)return[];if(e.length<=St)return[e];let t=[];for(let s=0;s<e.length;s+=St)t.push(e.subarray(s,Math.min(s+St,e.length)));return t}function lt(e,t){let s=lo(e,t);return{chunks:Tr(s),size:s.length}}async function ct(e,t){if(ao(e)){let s=[],n=0;for await(let r of Ut(e))if(r.length<=St)s.push(r),n+=r.length;else for(let i of Tr(r))s.push(i),n+=i.length;return{chunks:s,size:n}}return lt(e,t)}function Xt(e,t){if(t==="base64")return btoa(ir(_r(e)));if(t==="hex"){let r="";for(let i of e)for(let a=0;a<i.length;a++)r+=i[a].toString(16).padStart(2,"0");return r}if(t==="binary"||t==="latin1"){if(typeof Buffer<"u")return Buffer.from(_r(e)).toString(t);let r=65536,i="";for(let a of e)if(a.length<=r)i+=String.fromCharCode(...a);else for(let o=0;o<a.length;o+=r){let l=a.subarray(o,o+r);i+=String.fromCharCode(...l)}return i}let s=new TextDecoder,n="";for(let r of e)r.length>0&&(n+=s.decode(r,{stream:!0}));return n+=s.decode(),n}function _r(e){let t=0;for(let r of e)t+=r.length;if(t===0)return new Uint8Array(0);if(e.length===1)return e[0];let s=new Uint8Array(t),n=0;for(let r of e)s.set(r,n),n+=r.length;return s}function Ue(e){if(e!=null)return typeof e=="string"?e:e.encoding??void 0}function Qt(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 es(e,t,s,n){if(s>=t||n===0)return new Uint8Array(0);let r=Math.min(s+n,t),i=r-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<r){let f=Math.max(0,s-l),d=Math.min(u.length,r-l),p=u.subarray(f,d);a.set(p,o),o+=p.length}l=c}return a}function co(e){return typeof e=="object"&&e!==null&&!(e instanceof Uint8Array)&&!(e instanceof ReadableStream)&&"content"in e}function ce(e,t){if(e.includes("\0"))throw new Error(`ENOENT: path contains null byte, ${t} '${e}'`)}var Tt=class{data=new Map;constructor(t){if(this.data.set("/",{type:"directory",mode:493,mtime:new Date}),t)for(let[s,n]of Object.entries(t))if(co(n)){if(n.content instanceof ReadableStream)throw new Error("InMemoryFs: streams not supported in InitialFiles; use writeFile() after construction");this.writeFileSync(s,n.content,void 0,{mode:n.mode,mtime:n.mtime})}else{if(n instanceof ReadableStream)throw new Error("InMemoryFs: streams not supported in InitialFiles; use writeFile() after construction");this.writeFileSync(s,n)}}normalizePath(t){if(!t||t==="/")return"/";let s=t.endsWith("/")&&t!=="/"?t.slice(0,-1):t;s.startsWith("/")||(s=`/${s}`);let n=s.split("/").filter(i=>i&&i!=="."),r=[];for(let i of n)i===".."?r.pop():r.push(i);return`/${r.join("/")}`||"/"}dirname(t){let s=this.normalizePath(t);if(s==="/")return"/";let n=s.lastIndexOf("/");return n===0?"/":s.slice(0,n)}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,n,r){ce(t,"write");let i=this.normalizePath(t);this.ensureParentDirs(i);let a=Ue(n),{chunks:o,size:l}=lt(s,a);this.data.set(i,{type:"file",chunks:o,size:l,mode:r?.mode??420,mtime:r?.mtime??new Date})}async readFile(t){ce(t,"open");let s=this.resolvePathWithSymlinks(t),n=this.data.get(s);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}'`);return Et(n.chunks)}async readRange(t,s,n){Qt(s,n),ce(t,"open");let r=this.resolvePathWithSymlinks(t),i=this.data.get(r);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 es(i.chunks,i.size,s,n)}async readFileText(t,s){ce(t,"open");let n=this.resolvePathWithSymlinks(t),r=this.data.get(n);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}'`);let i=Ue(s);return Xt(r.chunks,i)}async writeFile(t,s,n){ce(t,"write");let r=this.normalizePath(t);this.ensureParentDirs(r);let i=Ue(n),{chunks:a,size:o}=await ct(s,i);this.data.set(r,{type:"file",chunks:a,size:o,mode:420,mtime:new Date})}async appendFile(t,s,n){ce(t,"append");let r=this.normalizePath(t),i=this.data.get(r);if(i&&i.type==="directory")throw new Error(`EISDIR: illegal operation on a directory, write '${t}'`);let a=Ue(n),{chunks:o,size:l}=await ct(s,a);i?.type==="file"?this.data.set(r,{type:"file",chunks:[...i.chunks,...o],size:i.size+l,mode:i.mode,mtime:new Date}):(this.ensureParentDirs(r),this.data.set(r,{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){ce(t,"stat");let s=this.resolvePathWithSymlinks(t),n=this.data.get(s);if(!n)throw new Error(`ENOENT: no such file or directory, stat '${t}'`);let r=0;return n.type==="file"&&(r=n.size),{isFile:n.type==="file",isDirectory:n.type==="directory",isSymbolicLink:!1,mode:n.mode,size:r,mtime:n.mtime||new Date}}async lstat(t){ce(t,"lstat");let s=this.resolveIntermediateSymlinks(t),n=this.data.get(s);if(!n)throw new Error(`ENOENT: no such file or directory, lstat '${t}'`);if(n.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:n.mode,size:n.target.length,mtime:n.mtime||new Date};let r=0;return n.type==="file"&&(r=n.size),{isFile:n.type==="file",isDirectory:n.type==="directory",isSymbolicLink:!1,mode:n.mode,size:r,mtime:n.mtime||new Date}}resolveSymlink(t,s){if(s.startsWith("/"))return this.normalizePath(s);let n=this.dirname(t);return this.normalizePath(n==="/"?`/${s}`:`${n}/${s}`)}resolveIntermediateSymlinks(t){let s=this.normalizePath(t);if(s==="/")return"/";let n=s.slice(1).split("/");if(n.length<=1)return s;let r="",i=new Set;for(let a=0;a<n.length-1;a++){let o=n[a];r=`${r}/${o}`;let l=this.data.get(r),u=0,c=40;for(;l&&l.type==="symlink"&&u<c;){if(i.has(r))throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`);i.add(r),r=this.resolveSymlink(r,l.target),l=this.data.get(r),u++}if(u>=c)throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`)}return`${r}/${n[n.length-1]}`}resolvePathWithSymlinks(t){let s=this.normalizePath(t);if(s==="/")return"/";let n=s.slice(1).split("/"),r="",i=new Set;for(let a of n){r=`${r}/${a}`;let o=this.data.get(r),l=0,u=40;for(;o&&o.type==="symlink"&&l<u;){if(i.has(r))throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`);i.add(r),r=this.resolveSymlink(r,o.target),o=this.data.get(r),l++}if(l>=u)throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`)}return r}async mkdir(t,s){this.mkdirSync(t,s)}mkdirSync(t,s){ce(t,"mkdir");let n=this.normalizePath(t);if(this.data.has(n)){if(this.data.get(n)?.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 r=this.dirname(n);if(r!=="/"&&!this.data.has(r))if(s?.recursive)this.mkdirSync(r,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${t}'`);this.data.set(n,{type:"directory",mode:493,mtime:new Date})}async readdir(t){return(await this.readdirWithFileTypes(t)).map(n=>n.name)}async readdirWithFileTypes(t){ce(t,"scandir");let s=this.normalizePath(t),n=this.data.get(s);if(!n)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);let r=new Set;for(;n&&n.type==="symlink";){if(r.has(s))throw new Error(`ELOOP: too many levels of symbolic links, scandir '${t}'`);r.add(s),s=this.resolveSymlink(s,n.target),n=this.data.get(s)}if(!n)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);if(n.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){ce(t,"rm");let n=this.normalizePath(t),r=this.data.get(n);if(!r){if(s?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${t}'`)}if(r.type==="directory"){let i=await this.readdir(n);if(i.length>0){if(!s?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${t}'`);for(let a of i){let o=n==="/"?`/${a}`:`${n}/${a}`;await this.rm(o,s)}}}this.data.delete(n)}async cp(t,s,n){ce(t,"cp"),ce(s,"cp");let r=this.normalizePath(t),i=this.normalizePath(s),a=this.data.get(r);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(!n?.recursive)throw new Error(`EISDIR: is a directory, cp '${t}'`);await this.mkdir(i,{recursive:!0});let o=await this.readdir(r);for(let l of o){let u=r==="/"?`/${l}`:`${r}/${l}`,c=i==="/"?`/${l}`:`${i}/${l}`;await this.cp(u,c,n)}}}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 n=t==="/"?`/${s}`:`${t}/${s}`;return this.normalizePath(n)}async chmod(t,s){ce(t,"chmod");let n=this.normalizePath(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, chmod '${t}'`);r.mode=s}async symlink(t,s){ce(s,"symlink");let n=this.normalizePath(s);if(this.data.has(n))throw new Error(`EEXIST: file already exists, symlink '${s}'`);this.ensureParentDirs(n),this.data.set(n,{type:"symlink",target:t,mode:511,mtime:new Date})}async link(t,s){ce(t,"link"),ce(s,"link");let n=this.normalizePath(t),r=this.normalizePath(s),i=this.data.get(n);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(r))throw new Error(`EEXIST: file already exists, link '${s}'`);this.ensureParentDirs(r),this.data.set(r,{type:"file",chunks:[...i.chunks],size:i.size,mode:i.mode,mtime:i.mtime})}async readlink(t){ce(t,"readlink");let s=this.normalizePath(t),n=this.data.get(s);if(!n)throw new Error(`ENOENT: no such file or directory, readlink '${t}'`);if(n.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${t}'`);return n.target}async realpath(t){ce(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,n){ce(t,"utimes");let r=this.normalizePath(t),i=this.resolvePathWithSymlinks(r),a=this.data.get(i);if(!a)throw new Error(`ENOENT: no such file or directory, utimes '${t}'`);a.mtime=n}};function uo(e){let t=e;return typeof t.mkdirSync=="function"&&typeof t.writeFileSync=="function"}function fo(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 ho(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 po(e){e.mkdirSync("/proc/self/fd",{recursive:!0}),e.writeFileSync("/proc/version",`${or}
|
|
3
3
|
`),e.writeFileSync("/proc/self/exe","/bin/bash"),e.writeFileSync("/proc/self/cmdline","bash\0"),e.writeFileSync("/proc/self/comm",`bash
|
|
4
|
-
`),e.writeFileSync("/proc/self/status",
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
`)}catch{return
|
|
8
|
-
`)}}let c=u||"/";if(
|
|
9
|
-
`):
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
`,2):
|
|
13
|
-
`,2):
|
|
14
|
-
`,2):
|
|
15
|
-
`)&&!r
|
|
16
|
-
`;if(
|
|
17
|
-
`}catch{}return null}function
|
|
18
|
-
`}
|
|
19
|
-
|
|
20
|
-
`)
|
|
21
|
-
`)
|
|
22
|
-
`),1)
|
|
23
|
-
`),
|
|
24
|
-
`)
|
|
25
|
-
`)
|
|
26
|
-
`)
|
|
27
|
-
|
|
28
|
-
`)),o=1;break}if(f==="/dev/null")i=w();else{let p=e.fs.resolvePath(e.state.cwd,f),v=await Ue(e,p,f,{checkNoclobber:!0,isClobber:m});if(v){i=D(i,N(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=D(i,n),n=w();break}if(f==="/dev/full"){i=D(i,N(`bash: echo: write error: No space left on device
|
|
29
|
-
`)),o=1,n=w();break}let m=e.fs.resolvePath(e.state.cwd,f),p=await Ue(e,m,f,{});if(p){i=D(i,N(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=D(n,i),i=w();break}if(f==="/dev/full"){i=D(i,N(`bash: echo: write error: No space left on device
|
|
30
|
-
`)),o=1;break}let m=e.fs.resolvePath(e.state.cwd,f),p=await Ue(e,m,f,{});if(p){i=D(i,N(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=D(i,N(`bash: ${p}: Bad file descriptor
|
|
31
|
-
`)),o=1)}break}if(f==="2"||f==="&2")d===1&&(i=D(i,n),n=w());else if(f==="1"||f==="&1")d===2?(n=D(n,i),i=w()):(n=D(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 Ue(e,p,f,{checkNoclobber:!0});if(v){i=N(v),o=1,n=w();break}if(c.fd==null){let y=await Y(n),E=await Y(i);await e.fs.writeFile(p,y),await e.fs.appendFile(p,E),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=Ui(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=D(i,n),n=w());else{let y=e.state.fileDescriptors?.get(v);if(y?.startsWith("__file__:")){let E=y.slice(9);d===1?(await e.fs.appendFile(E,n),n=w()):d===2&&(await e.fs.appendFile(E,i),i=w())}}}else p?.startsWith("__dupin__:")?(i=D(i,N(`bash: ${m}: Bad file descriptor
|
|
32
|
-
`)),o=1,n=w()):m>=3&&(i=D(i,N(`bash: ${m}: Bad file descriptor
|
|
33
|
-
`)),o=1,n=w())}}break}case"&>":{if(f==="/dev/full"){i=N(`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 Ue(e,d,f,{checkNoclobber:!0});if(m){i=N(m),o=1,n=w();break}let p=await Y(n),v=await Y(i);await e.fs.writeFile(d,p),await e.fs.appendFile(d,v),n=w(),i=w();break}case"&>>":{if(f==="/dev/full"){i=N(`bash: echo: write error: No space left on device
|
|
35
|
-
`),o=1,n=w();break}let d=e.fs.resolvePath(e.state.cwd,f),m=await Ue(e,d,f,{});if(m){i=N(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=D(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=D(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 mn(e,t){if(e.state.options.posix&&Ps.has(t.name)){let r=`bash: line ${e.state.currentLine}: \`${t.name}': is a special builtin
|
|
36
|
-
`;throw new Z(2,w(),N(r))}let s={...t,sourceFile:t.sourceFile??e.state.currentSource??"main"};return e.state.functions.set(t.name,s),j()}async function qi(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(`
|
|
4
|
+
`),e.writeFileSync("/proc/self/status",ar()),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 xr(e,t){uo(e)&&(fo(e,t),ho(e),po(e))}var mo=["allexport","errexit","noglob","noclobber","noexec","nounset","pipefail","posix","verbose","xtrace"],go=["braceexpand","hashall","interactive-comments"];function Gs(e){let t=[],s=[...go.map(n=>({name:n,enabled:!0})),...mo.map(n=>({name:n,enabled:e[n]}))].sort((n,r)=>n.name.localeCompare(r.name));for(let n of s)n.enabled&&t.push(n.name);return t.join(":")}function ut(e){y(e.state.env,"SHELLOPTS",Gs(e.state.options))}var yo=["dotglob","expand_aliases","extglob","failglob","globskipdots","globstar","lastpipe","nocaseglob","nocasematch","nullglob","xpg_echo"];function qs(e){let t=[];for(let s of yo)e[s]&&t.push(s);return t.join(":")}function Zs(e){y(e.state.env,"BASHOPTS",qs(e.state.shoptOptions))}var wo="BASH_ALIAS_";function Nr(e){return e.parts.length!==1?!1:e.parts[0].type==="Literal"}function Or(e){if(e.parts.length!==1)return null;let t=e.parts[0];return t.type==="Literal"?t.value:null}function Dr(e,t){let s=e.env.get(`${wo}${t}`);return s!==void 0?H(s):void 0}function Js(e,t,s){if(!t.name||!Nr(t.name))return t;let n=Or(t.name);if(!n)return t;let r=Dr(e,n);if(!r||s.has(n))return t;try{s.add(n);let i=new Z,a=r,o=r.endsWith(" ");if(!o)for(let f of t.args){let d=Rr(f);a+=` ${d}`}let l;try{l=i.parse(a)}catch(f){if(f instanceof Zt)throw f;return t}if(l.statements.length!==1||l.statements[0].pipelines.length!==1||l.statements[0].pipelines[0].commands.length!==1)return Ir(t,r);let u=l.statements[0].pipelines[0].commands[0];if(u.type!=="SimpleCommand")return Ir(t,r);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(Nr(f)){let d=Or(f);if(d&&Dr(e,d)){let p={type:"SimpleCommand",name:f,args:c.args.slice(1),assignments:[],redirections:[]},m=Js(e,p,s);m!==p&&(c={...c,name:m.name,args:[...m.args]})}}}return c}catch(i){throw s.delete(n),i}}function Ir(e,t){let s=t;for(let a of e.args){let o=Rr(a);s+=` ${o}`}let n=new Z,r=n.parseWordFromString("eval",!1,!1),i=n.parseWordFromString(`'${s.replace(/'/g,"'\\''")}'`,!1,!1);return{type:"SimpleCommand",name:r,args:[i],assignments:e.assignments,redirections:e.redirections,line:e.line}}function Rr(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(n=>n.type==="Literal"?n.value:`$${n.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 Lr(e,t){let s=t.parts.map(c=>c.type==="Literal"?c.value:"\0").join(""),n=s.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\(/);if(!n||!s.endsWith(")"))return null;let r=n[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+=Kt({type:"Word",parts:[c]});else{(o||l)&&(i.push(o),o="",l=!1);let d=await Ve(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`${r}=(${u.join(" ")})`}async function Mr(e,t){let s=-1,n=-1,r=!1;for(let h=0;h<t.parts.length;h++){let b=t.parts[h];if(b.type==="Literal"){let S=b.value.indexOf("+=");if(S!==-1){let g=b.value.slice(0,S);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(g)){s=h,n=S,r=!0;break}if(/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(g)){s=h,n=S,r=!0;break}}let $=b.value.indexOf("=");if($!==-1&&($===0||b.value[$-1]!=="+")){let g=b.value.slice(0,$);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(g)||/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(g)){s=h,n=$;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=r?2:1,l=a.value.slice(0,n),u=a.value.slice(n+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}${r?"+=":"="}${p}`}var vo=["tar","yq","xan","sqlite3","python3","python"];function Wr(e){return vo.includes(e)}function B(){return{stdout:E(),stderr:E(),exitCode:0}}var ft={get stdout(){return E()},get stderr(){return E()},exitCode:0};function Te(e=E()){return{stdout:e,stderr:E(),exitCode:0}}function G(e){return{stdout:V(e),stderr:E(),exitCode:0}}function A(e,t=1){return{stdout:E(),stderr:V(e),exitCode:t}}function W(e,t,s){return{stdout:e instanceof Uint8Array?he(e):e,stderr:t instanceof Uint8Array?he(t):t,exitCode:s}}function ae(e){return{stdout:E(),stderr:E(),exitCode:e?0:1}}function Re(e,t){throw new oe(e,t)}async function Ks(e,t){if(e.state.loopDepth===0){if(e.state.parentHasLoopContext)throw new Be;return B()}if(t.length>1)throw await U(e,2,`bash: break: too many arguments
|
|
5
|
+
`,!0),new q(1);let s=1;if(t.length>0){let n=Number.parseInt(t[0],10);if(Number.isNaN(n)||n<1)throw await U(e,2,`bash: break: ${t[0]}: numeric argument required
|
|
6
|
+
`,!0),new q(128);s=n}throw new Ae(s)}async function Ys(e,t){let s,n=!1,r=!1,i=0;for(;i<t.length;)if(t[i]==="--"){i++;break}else if(t[i]==="-L")r=!1,i++;else if(t[i]==="-P")r=!0,i++;else if(t[i].startsWith("-")&&t[i]!=="-")i++;else break;let a=t.slice(i);if(a.length===0?s=x(e.state.env,"HOME","/"):a[0]==="~"?s=x(e.state.env,"HOME","/"):a[0]==="-"?(s=e.state.previousDir,n=!0):s=a[0],!s.startsWith("/")&&!s.startsWith("./")&&!s.startsWith("../")&&s!=="."&&s!==".."){let f=e.state.env.get("CDPATH");if(f){let d=H(f??L).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,n=!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 A(`bash: cd: ${s}: Not a directory
|
|
7
|
+
`)}catch{return A(`bash: cd: ${s}: No such file or directory
|
|
8
|
+
`)}}let c=u||"/";if(r)try{c=await e.fs.realpath(c)}catch{}return e.state.previousDir=e.state.cwd,e.state.cwd=c,y(e.state.env,"PWD",e.state.cwd),y(e.state.env,"OLDPWD",e.state.previousDir),n?G(`${c}
|
|
9
|
+
`):Te()}function Xs(e,t){return e.fs.resolvePath(e.state.cwd,t)}var bo=["-e","-a","-f","-d","-r","-w","-x","-s","-L","-h","-k","-g","-u","-G","-O","-b","-c","-p","-S","-t","-N"];function ts(e){return bo.includes(e)}async function ss(e,t,s){let n=Xs(e,s);switch(t){case"-e":case"-a":return e.fs.exists(n);case"-f":return await e.fs.exists(n)?(await e.fs.stat(n)).isFile:!1;case"-d":return await e.fs.exists(n)?(await e.fs.stat(n)).isDirectory:!1;case"-r":return await e.fs.exists(n)?((await e.fs.stat(n)).mode&256)!==0:!1;case"-w":return await e.fs.exists(n)?((await e.fs.stat(n)).mode&128)!==0:!1;case"-x":return await e.fs.exists(n)?((await e.fs.stat(n)).mode&64)!==0:!1;case"-s":return await e.fs.exists(n)?(await e.fs.stat(n)).size>0:!1;case"-L":case"-h":try{return(await e.fs.lstat(n)).isSymbolicLink}catch{return!1}case"-k":return await e.fs.exists(n)?((await e.fs.stat(n)).mode&512)!==0:!1;case"-g":return await e.fs.exists(n)?((await e.fs.stat(n)).mode&1024)!==0:!1;case"-u":return await e.fs.exists(n)?((await e.fs.stat(n)).mode&2048)!==0:!1;case"-G":case"-O":return e.fs.exists(n);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=>n===i||n.endsWith(i));case"-p":return!1;case"-S":return!1;case"-t":return!1;case"-N":return e.fs.exists(n);default:return!1}}var So=["-nt","-ot","-ef"];function ns(e){return So.includes(e)}async function rs(e,t,s,n){let r=Xs(e,s),i=Xs(e,n);switch(t){case"-nt":try{let a=await e.fs.stat(r),o=await e.fs.stat(i);return a.mtime>o.mtime}catch{return!1}case"-ot":try{let a=await e.fs.stat(r),o=await e.fs.stat(i);return a.mtime<o.mtime}catch{return!1}case"-ef":try{if(!await e.fs.exists(r)||!await e.fs.exists(i))return!1;let a=e.fs.resolvePath(e.state.cwd,r),o=e.fs.resolvePath(e.state.cwd,i);return a===o}catch{return!1}default:return!1}}var Eo=new Set(["-eq","-ne","-lt","-le","-gt","-ge"]);function is(e){return Eo.has(e)}function os(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 xt(e){return e==="="||e==="=="||e==="!="}function as(e,t,s,n=!1,r=!1,i=!1){if(n){let o=dt(t,s,r,i);return e==="!="?!o:o}if(r){let o=t.toLowerCase()===s.toLowerCase();return e==="!="?!o:o}let a=t===s;return e==="!="?!a:a}var $o=new Set(["-z","-n"]);function ls(e){return $o.has(e)}function cs(e,t){switch(e){case"-z":return t==="";case"-n":return t!==""}}async function us(e,t){let s=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(s){let n=s[1],r=s[2];if(e.state.associativeArrays?.has(n)){let o=r;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)=>x(e.state.env,u)),e.state.env.has(`${n}_${o}`)}let a;try{let o=new Z,l=le(o,r);a=await Q(e,l.expression)}catch{if(/^-?\d+$/.test(r))a=Number.parseInt(r,10);else{let o=x(e.state.env,r);a=o?Number.parseInt(o,10):0}}if(a<0){let o=pe(e,n),l=e.state.currentLine;if(o.length===0)return await U(e,2,`bash: line ${l}: ${n}: bad array subscript
|
|
10
|
+
`),!1;if(a=Math.max(...o)+1+a,a<0)return await U(e,2,`bash: line ${l}: ${n}: bad array subscript
|
|
11
|
+
`),!1}return e.state.env.has(`${n}_${a}`)}return e.state.env.has(t)?!0:e.state.associativeArrays?.has(t)?Je(e,t).length>0:pe(e,t).length>0}async function Ke(e,t){switch(t.type){case"CondBinary":{let s=await z(e,t.left),n=t.right.parts.length>0&&t.right.parts.every(i=>i.type==="SingleQuoted"||i.type==="DoubleQuoted"||i.type==="Escaped"&&t.operator!=="=~"),r;if(t.operator==="=~")if(n){let i=await z(e,t.right);r=gr(i)}else r=await wr(e,t.right);else xt(t.operator)&&!n?r=await vr(e,t.right):r=await z(e,t.right);if(xt(t.operator)){let i=e.state.shoptOptions.nocasematch;return as(t.operator,s,r,!n,i,!0)}if(is(t.operator))return os(t.operator,await Vr(e,s),await Vr(e,r));if(ns(t.operator))return rs(e,t.operator,s,r);switch(t.operator){case"=~":try{let i=e.state.shoptOptions.nocasematch,a=Po(r),l=At(a,i?"i":"").match(s);if(We(e,"BASH_REMATCH"),l)for(let u=0;u<l.length;u++)y(e.state.env,`BASH_REMATCH_${u}`,l[u]||"");return l!==null}catch{throw new Error("syntax error in regular expression")}case"<":return s<r;case">":return s>r;default:return!1}}case"CondUnary":{let s=await z(e,t.operand);return ts(t.operator)?ss(e,t.operator,s):ls(t.operator)?cs(t.operator,s):t.operator==="-v"?await us(e,s):t.operator==="-o"?en(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 Ke(e,t.operand);case"CondAnd":return await Ke(e,t.left)?await Ke(e,t.right):!1;case"CondOr":return await Ke(e,t.left)?!0:await Ke(e,t.right);case"CondGroup":return await Ke(e,t.expression);case"CondWord":return await z(e,t.word)!=="";default:return!1}}async function Nt(e,t){if(t.length===0)return W(L,L,1);if(t.length===1)return ae(!!t[0]);if(t.length===2){let n=t[0],r=t[1];return n==="("?A(`test: '(' without matching ')'
|
|
12
|
+
`,2):ts(n)?ae(await ss(e,n,r)):ls(n)?ae(cs(n,r)):n==="!"?ae(!r):n==="-v"?ae(await us(e,r)):n==="-o"?ae(en(e,r)):n==="="||n==="=="||n==="!="||n==="<"||n===">"||n==="-eq"||n==="-ne"||n==="-lt"||n==="-le"||n==="-gt"||n==="-ge"||n==="-nt"||n==="-ot"||n==="-ef"?A(`test: ${n}: unary operator expected
|
|
13
|
+
`,2):W(L,L,1)}if(t.length===3){let n=t[0],r=t[1],i=t[2];if(xt(r))return ae(as(r,n,i));if(is(r)){let a=fs(n),o=fs(i);return!a.valid||!o.valid?W(L,L,2):ae(os(r,a.value,o.value))}if(ns(r))return ae(await rs(e,r,n,i));switch(r){case"-a":return ae(n!==""&&i!=="");case"-o":return ae(n!==""||i!=="");case">":return ae(n>i);case"<":return ae(n<i)}if(n==="!"){let a=await Nt(e,[r,i]);return W(L,a.stderr,a.exitCode===0?1:a.exitCode===1?0:a.exitCode)}if(n==="("&&i===")")return ae(r!=="")}if(t.length===4){if(t[0]==="!"){let n=await Nt(e,t.slice(1));return W(L,n.stderr,n.exitCode===0?1:n.exitCode===1?0:n.exitCode)}if(t[0]==="("&&t[3]===")")return Nt(e,[t[1],t[2]])}let s=await jr(e,t,0);return s.pos<t.length?A(`test: too many arguments
|
|
14
|
+
`,2):ae(s.value)}async function jr(e,t,s){return Ao(e,t,s)}async function Ao(e,t,s){let{value:n,pos:r}=await Fr(e,t,s);for(;t[r]==="-o";){let i=await Fr(e,t,r+1);n=n||i.value,r=i.pos}return{value:n,pos:r}}async function Fr(e,t,s){let{value:n,pos:r}=await Qs(e,t,s);for(;t[r]==="-a";){let i=await Qs(e,t,r+1);n=n&&i.value,r=i.pos}return{value:n,pos:r}}async function Qs(e,t,s){if(t[s]==="!"){let{value:n,pos:r}=await Qs(e,t,s+1);return{value:!n,pos:r}}return Co(e,t,s)}async function Co(e,t,s){let n=t[s];if(n==="("){let{value:i,pos:a}=await jr(e,t,s+1);return{value:i,pos:t[a]===")"?a+1:a}}let r=t[s+1];if(xt(r)){let i=n,a=t[s+2]??"";return{value:as(r,i,a),pos:s+3}}if(is(r)){let i=fs(n),a=fs(t[s+2]??"0");return!i.valid||!a.valid?{value:!1,pos:s+3}:{value:os(r,i.value,a.value),pos:s+3}}if(ns(r)){let i=n,a=t[s+2]??"";return{value:await rs(e,r,i,a),pos:s+3}}if(ts(n)){let i=t[s+1]??"";return{value:await ss(e,n,i),pos:s+2}}if(ls(n)){let i=t[s+1]??"";return{value:cs(n,i),pos:s+2}}if(n==="-v"){let i=t[s+1]??"";return{value:await us(e,i),pos:s+2}}if(n==="-o"){let i=t[s+1]??"";return{value:en(e,i),pos:s+2}}return{value:n!==void 0&&n!=="",pos:s+1}}function dt(e,t,s=!1,n=!1){let r=`^${Br(t,n)}$`;return At(r,s?"is":"s").test(e)}function Br(e,t){let s="";for(let n=0;n<e.length;n++){let r=e[n];if(t&&(r==="@"||r==="*"||r==="+"||r==="?"||r==="!")&&n+1<e.length&&e[n+1]==="("){let i=Hr(e,n+1);if(i!==-1){let a=e.slice(n+2,i),o=Ur(a),l=o.map(c=>Br(c,t)),u=l.length>0?l.join("|"):"(?:)";if(r==="@")s+=`(?:${u})`;else if(r==="*")s+=`(?:${u})*`;else if(r==="+")s+=`(?:${u})+`;else if(r==="?")s+=`(?:${u})?`;else if(r==="!")if(i<e.length-1){let f=o.map(p=>Gr(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})$).*`;n=i;continue}}if(r==="\\")if(n+1<e.length){let i=e[n+1];/[\\^$.|+(){}[\]*?]/.test(i)?s+=`\\${i}`:s+=i,n++}else s+="\\\\";else if(r==="*")s+=".*";else if(r==="?")s+=".";else if(r==="["){let i=e.indexOf("]",n+1);i!==-1?(s+=e.slice(n,i+1),n=i):s+="\\["}else/[\\^$.|+(){}]/.test(r)?s+=`\\${r}`:s+=r}return s}function Hr(e,t){let s=1,n=t+1;for(;n<e.length&&s>0;){let r=e[n];if(r==="\\"){n+=2;continue}if(r==="(")s++;else if(r===")"&&(s--,s===0))return n;n++}return-1}function Ur(e){let t=[],s="",n=0,r=0;for(;r<e.length;){let i=e[r];if(i==="\\"){s+=i,r+1<e.length?(s+=e[r+1],r+=2):r++;continue}i==="("?(n++,s+=i):i===")"?(n--,s+=i):i==="|"&&n===0?(t.push(s),s=""):s+=i,r++}return t.push(s),t}function Gr(e,t){let s=0,n=0;for(;n<e.length;){let r=e[n];if(t&&(r==="@"||r==="*"||r==="+"||r==="?"||r==="!")&&n+1<e.length&&e[n+1]==="("){let i=Hr(e,n+1);if(i!==-1){if(r==="@"){let a=e.slice(n+2,i),l=Ur(a).map(u=>Gr(u,t));if(l.every(u=>u!==null)&&l.every(u=>u===l[0])){s+=l[0],n=i+1;continue}return null}return null}}if(r==="*")return null;if(r==="?"){s+=1,n++;continue}if(r==="["){let i=e.indexOf("]",n+1);if(i!==-1){s+=1,n=i+1;continue}s+=1,n++;continue}if(r==="\\"){s+=1,n+=2;continue}s+=1,n++}return s}function en(e,t){let n=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 n?n():!1}async function Vr(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 zr(t);try{let s=new Z,n=le(s,t);return await Q(e,n.expression)}catch{return zr(t)}}function ko(e,t){let s=0;for(let n of e){let r;if(n>="0"&&n<="9")r=n.charCodeAt(0)-48;else if(n>="a"&&n<="z")r=n.charCodeAt(0)-97+10;else if(n>="A"&&n<="Z")r=n.charCodeAt(0)-65+36;else if(n==="@")r=62;else if(n==="_")r=63;else return Number.NaN;if(r>=t)return Number.NaN;s=s*t+r}return s}function zr(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,n=e.match(/^(\d+)#([a-zA-Z0-9@_]+)$/);if(n){let r=Number.parseInt(n[1],10);r>=2&&r<=64?s=ko(n[2],r):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 fs(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 Po(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 n=_o(e,s);t+=n.converted,s=n.endIndex}else t+=e[s],s++;return t}function _o(e,t){let s=t+1,n="[";s<e.length&&(e[s]==="^"||e[s]==="!")&&(n+="^",s++);let r=!1;s<e.length&&e[s]==="]"&&(r=!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+=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 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?(r&&(n+="\\]"),i&&(n+="\\["),n+=a,n+="]",{converted:n,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 ze(e){let t=[],s="",n=!1,r=!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==="'"&&!r){n||(a=!0),n=!n;continue}if(o==='"'&&!n){r||(a=!0),r=!r;continue}if((o===" "||o===" "||o===`
|
|
15
|
+
`)&&!n&&!r){a&&(t.push(s),s="",a=!1);continue}s+=o,a=!0}return a&&t.push(s),t}function ds(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 n="";if(e[s]==="'"||e[s]==='"'){let i=e[s];for(s++;s<e.length&&e[s]!==i;)n+=e[s],s++;e[s]===i&&s++}else for(;s<e.length&&e[s]!=="]"&&e[s]!=="=";)n+=e[s],s++;for(;s<e.length&&e[s]!=="]";)s++;if(e[s]==="]"&&s++,e[s]!=="=")continue;s++;let r="";if(e[s]==="'"||e[s]==='"'){let i=e[s];for(s++;s<e.length&&e[s]!==i;)e[s]==="\\"&&s+1<e.length&&s++,r+=e[s],s++;e[s]===i&&s++}else for(;s<e.length&&!/\s/.test(e[s]);)r+=e[s],s++;t.push([n,r])}return t}function qr(e){let t=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(t)return{name:t[1],isArray:!0,arrayElements:ze(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 n=e.indexOf("=");return{name:e.slice(0,n),isArray:!1,value:e.slice(n+1)}}return{name:e,isArray:!1}}async function xo(e,t){try{let s=new Z,n=le(s,t);return await Q(e,n.expression)}catch{let s=parseInt(t,10);return Number.isNaN(s)?0:s}}async function Zr(e,t,s={}){let{name:n,isArray:r,arrayElements:i,value:a,arrayIndex:o}=t,{makeReadonly:l=!1,checkReadonly:u=!0}=s;if(u){let c=await ue(e,n);if(c)return c}if(r&&i){for(let c=0;c<i.length;c++)y(e.state.env,`${n}_${c}`,i[c]);y(e.state.env,`${n}__length`,String(i.length))}else if(o!==void 0&&a!==void 0){let c=await xo(e,o);y(e.state.env,`${n}_${c}`,a);let f=parseInt(x(e.state.env,`${n}__length`,"0"),10);c>=f&&y(e.state.env,`${n}__length`,String(c+1))}else a!==void 0&&y(e.state.env,n,a);return l&&Se(e,n),null}function Ye(e,t){e.state.localVarDepth=e.state.localVarDepth||new Map,e.state.localVarDepth.set(t,e.state.callDepth)}function ht(e,t){return e.state.localVarDepth?.get(t)}function hs(e,t){e.state.localVarDepth?.delete(t)}function Jr(e,t,s){e.state.localVarStack=e.state.localVarStack||new Map;let n=e.state.localVarStack.get(t)||[];n.push({value:s,scopeIndex:e.state.localScopes.length-1}),e.state.localVarStack.set(t,n)}function ps(e,t){let s=e.state.localVarStack?.get(t);if(!(!s||s.length===0))return s.pop()}function Kr(e,t){if(e.state.localVarStack)for(let[s,n]of e.state.localVarStack.entries()){for(;n.length>0&&n[n.length-1].scopeIndex===t;)n.pop();n.length===0&&e.state.localVarStack.delete(s)}}var tn=new Set([":",".","break","continue","eval","exec","exit","export","readonly","return","set","shift","trap","unset"]);function Yr(e){return tn.has(e)}var sn=new Set(["if","then","else","elif","fi","case","esac","for","select","while","until","do","done","in","function","{","}","time","[[","]]","!"]),Ge=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 Ot(e,t){if(e.parts.length!==1)return!1;let s=e.parts[0];return s.type!=="Literal"?!1:t.includes(s.value)}function ms(e){if(!e.startsWith("__rw__:"))return null;let t=e.slice(7),s=t.indexOf(":");if(s===-1)return null;let n=Number.parseInt(t.slice(0,s),10);if(Number.isNaN(n)||n<0)return null;let r=s+1,i=t.slice(r,r+n),a=r+n+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 Xr(e,t,s,n){try{if((await e.fs.stat(t)).isDirectory)return`bash: ${s}: Is a directory
|
|
16
|
+
`;if(n.checkNoclobber&&e.state.options.noclobber&&!n.isClobber&&s!=="/dev/null")return`bash: ${s}: cannot overwrite existing file
|
|
17
|
+
`}catch{}return null}async function gs(e,t){if(t.target.type==="HereDoc")throw new Error("Here-document targets are not words");return t.operator===">&"||t.operator==="<&"?br(e,t.target)?{error:`bash: $@: ambiguous redirect
|
|
18
|
+
`}:{target:await z(e,t.target)}:Sr(e,t.target)}function nn(e){return e.includes("\0")?`bash: ${e.replace(/\0/g,"")}: No such file or directory
|
|
19
|
+
`:null}function je(e){return`bash: ${e}: Bad file descriptor
|
|
20
|
+
`}function rn(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 pt(e,t,s){for(let n of t){if(!n.fdVariable)continue;e.state.fileDescriptors||(e.state.fileDescriptors=new Map);let r;if((n.operator===">&"||n.operator==="<&")&&n.target.type==="Word"&&(r=await z(e,n.target),r==="-")){if(e.state.env.has(n.fdVariable)){let a=Number.parseInt(x(e.state.env,n.fdVariable),10);Number.isNaN(a)||e.state.fileDescriptors.delete(a)}continue}let i=rn(e,s);if(y(e.state.env,n.fdVariable,String(i)),n.target.type==="Word"){let a=r??await z(e,n.target);if(n.operator===">&"||n.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 W(E(),V(je(o)),1);continue}}if(n.operator===">"||n.operator===">>"||n.operator===">|"||n.operator==="&>"||n.operator==="&>>"){let o=e.fs.resolvePath(e.state.cwd,a);(n.operator===">"||n.operator===">|"||n.operator==="&>")&&await e.fs.writeFile(o,""),e.state.fileDescriptors.set(i,`__file__:${o}`)}else if(n.operator==="<<<")e.state.fileDescriptors.set(i,`${a}
|
|
21
|
+
`);else if(n.operator==="<"||n.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 W(E(),V(`bash: ${a}: No such file or directory
|
|
22
|
+
`),1)}}}return null}var No={write(){}},Oo={write(){let e=new Error(`bash: echo: write error: No space left on device
|
|
23
|
+
`);return e.code="ENOSPC",Promise.reject(e)}};function Do(e){return e.target.type==="HereDoc"||e.operator==="<"||e.operator==="<>"||e.operator==="<<<"||e.operator==="<<"||e.operator==="<<-"}function on(e,t){return{...e,target:{type:"Word",parts:[{type:"Literal",value:t}]}}}function ws(e,t){let s=Promise.resolve();return{write(n){let r=s.then(()=>e.fs.appendFile(t,n));return s=r.catch(()=>{}),r}}}function ei(e,t,s,n=new Set){let r=t.bindings.get(s),i=r?.sink;if(i)return i;if(n.has(s))return;n.add(s);let a=r?.descriptor,o;if(a?.startsWith("__file__:"))o=ws(e,a.slice(9));else if(a?.startsWith("__file_append__:"))o=ws(e,a.slice(16));else if(a?.startsWith("__rw__:")){let l=ms(a);l&&(o=ws(e,l.path))}else if(a?.startsWith("__dupout__:")){let l=Number.parseInt(a.slice(11),10);Number.isNaN(l)||(o=ei(e,t,l,n))}return o&&t.bindings.set(s,{...r,sink:o}),o}async function Qr(e,t,s,n,r=!1){if(s==="/dev/null")return{sink:No,descriptor:"__file__:/dev/null"};if(s==="/dev/full")return{sink:Oo,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:je(o)}}let i=e.fs.resolvePath(e.state.cwd,s),a=await Xr(e,i,s,{checkNoclobber:n==="truncate",isClobber:r});return a?{error:a}:(n==="truncate"?await e.fs.writeFile(i,""):await e.fs.appendFile(i,new Uint8Array),{sink:ws(e,i),descriptor:n==="append"?`__file_append__:${i}`:`__file__:${i}`})}function st(e,t,s){e.state.fileDescriptors||(e.state.fileDescriptors=new Map),e.state.fileDescriptors.set(t,s)}function Io(e,t){return e.bindings.get(t)?.descriptor??`__dupout__:${t}`}function an(e,t,s,n,r){if(!(!r&&!t.fdVariable)){if(t.fdVariable&&n.startsWith("__file_append__:")){st(e,s,`__file__:${n.slice(16)}`);return}st(e,s,n)}}function ys(e,t,s,n,r,i=!0){let a=e.state.fileDescriptors?.get(s),o=r?.startsWith("__file_append__:")?`__file__:${r.slice(16)}`:r;(n||t.fdVariable)&&i&&a!==void 0&&a===o&&e.state.fileDescriptors?.delete(s)}function xe(e,t,s){return{channels:e,legacyRedirections:t,error:A(s)}}async function Ne(e,t,s,n={}){let r={bindings:new Map(t.bindings),parent:t,overrides:new Set};for(let[o,l]of e.state.fileDescriptors??[]){let u=r.bindings.get(o);u?.descriptor===void 0&&r.bindings.set(o,{...u,descriptor:l})}let i=[],a=n.persistent===!0;for(let o of s){let l;if(o.operator==="<&"&&o.target.type==="Word"){let S=await gs(e,o);if("error"in S)return xe(r,i,S.error);l=S.target;let $=l.startsWith("&")?l.slice(1):l,g=/^\d+-?$/.test($);if(l!=="-"&&!g)return xe(r,i,`bash: ${l}: ambiguous redirect
|
|
24
|
+
`);if(!o.fdVariable&&(o.fd??0)===0){i.push(on(o,l));continue}}if(o.operator==="<"&&!o.fdVariable&&o.target.type==="Word"){let S=await gs(e,o);if("error"in S)return xe(r,i,S.error);let $=nn(S.target);if($)return xe(r,i,$);try{let g=e.fs.resolvePath(e.state.cwd,S.target);await e.fs.readFile(g)}catch{return xe(r,i,`bash: ${S.target}: No such file or directory
|
|
25
|
+
`)}i.push(on(o,S.target));continue}if(Do(o)){if(o.fdVariable&&o.target.type==="Word"){let S=await pt(e,[o],v=>Ws(r,v));if(S)return{channels:r,legacyRedirections:i,error:S};let $=Number.parseInt(x(e.state.env,o.fdVariable),10),g=e.state.fileDescriptors?.get($);if(!Number.isNaN($)&&g!==void 0){let v=r.bindings.get($);r.bindings.set($,{...v,descriptor:g})}}else i.push(o);continue}let u;if(l!==void 0)u=l;else{let S=await gs(e,o);if("error"in S)return xe(r,i,S.error);u=S.target}let c=nn(u);if(c)return xe(r,i,c);if((o.operator===">&"||o.operator==="<&")&&u==="-"&&o.fdVariable){if(e.state.env.has(o.fdVariable)){let S=Number.parseInt(x(e.state.env,o.fdVariable),10);if(!Number.isNaN(S)){let $=r.bindings.get(S)?.descriptor,g=Pt(r,S);ys(e,o,S,a,$,g)}}continue}let f=o.fdVariable?rn(e,S=>Ws(r,S)):o.fd??(o.operator==="<&"?0:1);if(o.fdVariable&&y(e.state.env,o.fdVariable,String(f)),!Number.isInteger(f)||f<0)return xe(r,i,je(f));if(o.operator===">"||o.operator===">|"||o.operator===">>"||o.operator==="&>"||o.operator==="&>>"){let S=o.operator===">>"||o.operator==="&>>",$=await Qr(e,r,u,S?"append":"truncate",o.operator===">|");if("error"in $)return xe(r,i,$.error);o.operator==="&>"||o.operator==="&>>"?(r.bindings.set(1,{sink:$.sink,descriptor:$.descriptor}),r.bindings.set(2,{sink:$.sink,descriptor:$.descriptor}),r.overrides?.add(1),r.overrides?.add(2),a&&(st(e,1,$.descriptor),st(e,2,$.descriptor))):(o.fdVariable?kt(r,f,$.sink,$.descriptor):(r.bindings.set(f,{sink:$.sink,descriptor:$.descriptor}),r.overrides?.add(f)),an(e,o,f,$.descriptor,a));continue}if(o.operator!==">&"&&o.operator!=="<&"){i.push(o);continue}if(u==="-"){let S=r.bindings.get(f)?.descriptor;r.overrides?.add(f),r.bindings.set(f,{descriptor:Jt}),ys(e,o,f,a,S);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 S=ei(e,r,h);if(!S){let g=r.bindings.get(h)?.descriptor;if(g===Jt)return xe(r,i,je(h));if(o.operator==="<&"&&o.fdVariable&&g!==void 0){if(r.bindings.set(f,{descriptor:g}),st(e,f,g),d){let v=Pt(r,h);ys(e,o,h,a,g,v)}continue}if(o.operator==="<&"&&!o.fdVariable){i.push(on(o,u));continue}return xe(r,i,je(h))}let $=Io(r,h);if(o.fdVariable?kt(r,f,S,$):r.bindings.set(f,{sink:S,descriptor:$}),an(e,o,f,$,a),d){let g=!0;o.fdVariable?g=Pt(r,h):(r.overrides?.add(h),r.bindings.set(h,{descriptor:Jt}),n.persistMovedSource&&r.parent&&(g=Pt(r.parent,h))),ys(e,o,h,a||n.persistMovedSource===!0,$,g)}o.fdVariable||r.overrides?.add(f);continue}if(o.operator==="<&")return xe(r,i,`bash: ${u}: ambiguous redirect
|
|
26
|
+
`);let b=await Qr(e,r,u,"truncate");if("error"in b)return xe(r,i,b.error);o.fd==null&&!o.fdVariable?(r.bindings.set(1,{sink:b.sink,descriptor:b.descriptor}),r.bindings.set(2,{sink:b.sink,descriptor:b.descriptor}),r.overrides?.add(1),r.overrides?.add(2),a&&(st(e,1,b.descriptor),st(e,2,b.descriptor))):(o.fdVariable?kt(r,f,b.sink,b.descriptor):(r.bindings.set(f,{sink:b.sink,descriptor:b.descriptor}),r.overrides?.add(f)),an(e,o,f,b.descriptor,a))}return{channels:r,legacyRedirections:i}}async function ti(e,t){let s=e.outputChannels,n=await Ne(e,s,t,{persistent:!0});if(n.error)return n;for(let r of n.channels.overrides??[]){let i=n.channels.bindings.get(r);i?.descriptor!==void 0&&kt(s,r,i.sink,i.descriptor)}return{...n,channels:s}}async function si(e,t){if(e.state.options.posix&&tn.has(t.name)){let n=`bash: line ${e.state.currentLine}: \`${t.name}': is a special builtin
|
|
27
|
+
`;throw await U(e,2,n,!0),new q(2)}let s={...t,sourceFile:t.sourceFile??e.state.currentSource??"main"};return e.state.functions.set(t.name,s),B()}async function Ro(e,t){let s=E(),n=!1;for(let r of t)if(!r.fdVariable){if((r.operator==="<<"||r.operator==="<<-")&&r.target.type==="HereDoc"){let i=r.target,a=await z(e,i.content);i.stripTabs&&(a=a.split(`
|
|
37
28
|
`).map(l=>l.replace(/^\t+/,"")).join(`
|
|
38
|
-
`)),(
|
|
39
|
-
`),
|
|
40
|
-
`,2);let
|
|
41
|
-
`,2);s.push(
|
|
42
|
-
`,2);
|
|
43
|
-
`,2);
|
|
44
|
-
`,2);i=t[
|
|
45
|
-
`,2);let
|
|
46
|
-
`,2)}else if(C==="-F"){if(
|
|
47
|
-
`,2);f=t[
|
|
48
|
-
`,2);
|
|
49
|
-
`,2);c=t[
|
|
50
|
-
`,2)}else if(C==="--"){
|
|
51
|
-
`);for(let
|
|
52
|
-
`,2);throw
|
|
53
|
-
`),
|
|
54
|
-
`:"");return
|
|
55
|
-
`);if(s.length===0)return[t];let
|
|
56
|
-
`,2);i=t[f]}else if(
|
|
57
|
-
`,2);
|
|
58
|
-
`,2);let
|
|
59
|
-
`,2);l.push(
|
|
60
|
-
`,2);u.push(t[f])}else if(
|
|
61
|
-
`,2);
|
|
62
|
-
`,2)}else if(
|
|
63
|
-
`,2)}else if(
|
|
64
|
-
`,2)}else if(
|
|
65
|
-
`,2)}else if(
|
|
66
|
-
`,2);if(
|
|
67
|
-
`;return
|
|
68
|
-
`)+(
|
|
69
|
-
`:"")),
|
|
70
|
-
`),1);continue}let
|
|
29
|
+
`)),(r.fd??0)===0&&(s=V(a),n=!0)}else if(r.operator==="<<<"&&r.target.type==="Word")s=V(`${await z(e,r.target)}
|
|
30
|
+
`),n=!0;else if(r.operator==="<"&&r.target.type==="Word"){let i=await z(e,r.target),a=e.fs.resolvePath(e.state.cwd,i);try{s=await e.fs.readFile(a),n=!0}catch{}}}return s}async function vs(e,t,s,n=E(),r){e.state.callDepth++,e.state.callDepth>e.limits.maxCallDepth&&(e.state.callDepth--,Re(`${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(r??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),x(e.state.env,String(o+1))),y(e.state.env,String(o+1),s[o]);i.set("@",x(e.state.env,"@")),i.set("#",x(e.state.env,"#")),y(e.state.env,"@",s.join(" ")),y(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(Kr(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):y(e.state.env,u,c);e.state.funcNameStack?.shift(),e.state.callLineStack?.shift(),e.state.sourceStack?.shift(),e.state.callDepth--};try{let o=await Ne(e,e.outputChannels,t.redirections);return o.error?await K(e,o.channels,()=>te(e,()=>Promise.resolve(o.error))):await K(e,o.channels,async()=>{try{let l=await pt(e,o.legacyRedirections);if(l)return await te(e,()=>Promise.resolve(l));let u=await ie(n),c=u.length>0?he(u):await Ro(e,o.legacyRedirections),f=await e.executeCommand(t.body,c);return await te(e,()=>Promise.resolve(f))}catch(l){let{writeFailure:u}=await Ze(e,l);if(u)return u;if(l instanceof we)return W(E(),E(),l.exitCode);throw l}})}catch(o){throw await ee(e,o),o}finally{a()}}var ri=["!","[[","]]","case","do","done","elif","else","esac","fi","for","function","if","in","then","time","until","while","{","}"],cn=[".",":","[","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"],Lo=["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"],Mo=cn;async function un(e,t){let s=[],n=null,r="",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 A(`compgen: -A: option requires an argument
|
|
31
|
+
`,2);let N=t[v];if(!m.includes(N))return A(`compgen: ${N}: invalid action name
|
|
32
|
+
`,2);s.push(N)}else if(C==="-W"){if(v++,v>=t.length)return A(`compgen: -W: option requires an argument
|
|
33
|
+
`,2);n=t[v]}else if(C==="-P"){if(v++,v>=t.length)return A(`compgen: -P: option requires an argument
|
|
34
|
+
`,2);r=t[v]}else if(C==="-S"){if(v++,v>=t.length)return A(`compgen: -S: option requires an argument
|
|
35
|
+
`,2);i=t[v]}else if(C==="-o"){if(v++,v>=t.length)return A(`compgen: -o: option requires an argument
|
|
36
|
+
`,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 A(`compgen: ${N}: invalid option name
|
|
37
|
+
`,2)}else if(C==="-F"){if(v++,v>=t.length)return A(`compgen: -F: option requires an argument
|
|
38
|
+
`,2);f=t[v]}else if(C==="-C"){if(v++,v>=t.length)return A(`compgen: -C: option requires an argument
|
|
39
|
+
`,2);d=t[v]}else if(C==="-X"){if(v++,v>=t.length)return A(`compgen: -X: option requires an argument
|
|
40
|
+
`,2);c=t[v]}else if(C==="-G"){if(v++,v>=t.length)return A(`compgen: -G: option requires an argument
|
|
41
|
+
`,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 ln(e,a);h.push(...v)}if(u){let v=await ni(e,a);h.push(...v)}for(let v of s)if(v==="variable"){let C=Wo(e,a);h.push(...C)}else if(v==="export"){let C=Fo(e,a);h.push(...C)}else if(v==="function"){let C=Vo(e,a);h.push(...C)}else if(v==="builtin"){let C=zo(a);h.push(...C)}else if(v==="keyword"){let C=jo(a);h.push(...C)}else if(v==="alias"){let C=Bo(e,a);h.push(...C)}else if(v==="shopt"){let C=Ho(a);h.push(...C)}else if(v==="helptopic"){let C=Uo(a);h.push(...C)}else if(v==="directory"){let C=await ln(e,a);h.push(...C)}else if(v==="file"){let C=await ni(e,a);h.push(...C)}else if(v==="user"){let C=Go(a);h.push(...C)}else if(v==="command"){let C=await qo(e,a);h.push(...C)}if(n!==null)try{let v=await Zo(e,n),C=Jo(e,v);for(let N of C)(a===null||N.startsWith(a))&&h.push(N)}catch{return W(L,L,1)}if(o){let v=await ln(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",x(e.state.env,"COMP_WORDS__length")),y(e.state.env,"COMP_WORDS__length","0"),C.set("COMP_CWORD",x(e.state.env,"COMP_CWORD")),y(e.state.env,"COMP_CWORD","-1"),C.set("COMP_LINE",x(e.state.env,"COMP_LINE")),y(e.state.env,"COMP_LINE",""),C.set("COMP_POINT",x(e.state.env,"COMP_POINT")),y(e.state.env,"COMP_POINT","0");let N=new Map;for(let P of e.state.env.keys())(P==="COMPREPLY"||P.startsWith("COMPREPLY_")||P==="COMPREPLY__length")&&(N.set(P,x(e.state.env,P)),e.state.env.delete(P));let I=["compgen",p[0]??"",""];try{let P=_e(),k=_e(),O=await K(e,{bindings:new Map([[1,{sink:P}],[2,{sink:k}]])},()=>vs(e,v,I,E()));if(await _t(e,O.stderr,k),O.exitCode!==0)return mt(e,C),mt(e,N),W(L,k.stream(),1);await _t(e,O.stdout,P),b=H(await ie(P.stream()));let R=Ko(e);h.push(...R)}catch{return mt(e,C),mt(e,N),W(L,L,1)}mt(e,C),mt(e,N)}}if(d!==null)try{let v=Le(d),C=_e(),N=_e(),I=await K(e,{bindings:new Map([[1,{sink:C}],[2,{sink:N}]])},()=>e.executeScript(v));if(await _t(e,I.stderr,N),I.exitCode!==0)return W(L,N.stream(),I.exitCode);await _t(e,I.stdout,C);let P=await ie(C.stream());if(P.length>0){let k=H(P).split(`
|
|
42
|
+
`);for(let O of k)O.length>0&&h.push(O)}}catch(v){if(v.name==="ParseException")return A(`compgen: -C: ${v.message}
|
|
43
|
+
`,2);throw v}let S=h;if(c!==null){let v=c.startsWith("!"),C=v?c.slice(1):c;S=h.filter(N=>{let I=dt(N,C,!1,!0);return v?I:!I})}if(S.length===0&&a!==null)return W(F(b),L,1);let $=S.map(v=>`${r}${v}${i}`).join(`
|
|
44
|
+
`),g=b+($?`${$}
|
|
45
|
+
`:"");return G(g)}function Wo(e,t){let s=new Set;for(let r of e.state.env.keys()){if(r.includes("_")&&/^[a-zA-Z_][a-zA-Z0-9_]*_\d+$/.test(r)||r.endsWith("__length"))continue;let i=r.split("_")[0];/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)?s.add(r):i&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i)&&e.state.env.has(`${i}__length`)&&s.add(i)}let n=Array.from(s);return t!==null&&(n=n.filter(r=>r.startsWith(t))),n.sort()}function Fo(e,t){let s=e.state.exportedVars??new Set,n=Array.from(s);return t!==null&&(n=n.filter(r=>r.startsWith(t))),n=n.filter(r=>r.includes("_")&&/^[a-zA-Z_][a-zA-Z0-9_]*_\d+$/.test(r)||r.endsWith("__length")?!1:e.state.env.has(r)),n.sort()}function Vo(e,t){let s=Array.from(e.state.functions.keys());return t!==null&&(s=s.filter(n=>n.startsWith(t))),s.sort()}function zo(e){let t=[...cn];return e!==null&&(t=t.filter(s=>s.startsWith(e))),t.sort()}function jo(e){let t=[...ri];return e!==null&&(t=t.filter(s=>s.startsWith(e))),t.sort()}function Bo(e,t){let s=[];for(let r of e.state.env.keys())if(r.startsWith("BASH_ALIAS_")){let i=r.slice(11);s.push(i)}let n=s;return t!==null&&(n=n.filter(r=>r.startsWith(t))),n.sort()}function Ho(e){let t=[...Lo];return e!==null&&(t=t.filter(s=>s.startsWith(e))),t.sort()}function Uo(e){let t=[...Mo];return e!==null&&(t=t.filter(s=>s.startsWith(e))),t.sort()}async function ln(e,t){let s=[];try{let n=e.state.cwd,r=t??"";if(t){let a=t.lastIndexOf("/");if(a!==-1){let o=t.slice(0,a)||"/";r=t.slice(a+1),o.startsWith("/")?n=o:n=`${e.state.cwd}/${o}`}}let i=await e.fs.readdir(n);for(let a of i){let o=`${n}/${a}`;try{if((await e.fs.stat(o)).isDirectory&&(!r||a.startsWith(r)))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 ni(e,t){let s=[];try{let n=e.state.cwd,r=t??"";if(t){let a=t.lastIndexOf("/");if(a!==-1){let o=t.slice(0,a)||"/";r=t.slice(a+1),o.startsWith("/")?n=o:n=`${e.state.cwd}/${o}`}}let i=await e.fs.readdir(n);for(let a of i)if(!r||a.startsWith(r))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 Go(e){return["root","nobody"]}async function qo(e,t){let s=new Set;for(let i of cn)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 ri)s.add(i);let n=x(e.state.env,"PATH","/usr/bin:/bin");for(let i of n.split(":"))if(i)try{let a=await e.fs.readdir(i);for(let o of a)s.add(o)}catch{}let r=Array.from(s);return t!==null&&(r=r.filter(i=>i.startsWith(t))),r.sort()}async function Zo(e,t){let n=new Z().parseWordFromString(t,!1,!1);return await z(e,n)}function Jo(e,t){let s=x(e.state.env,"IFS",`
|
|
46
|
+
`);if(s.length===0)return[t];let n=new Set(s.split("")),r=[],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 n.has(o)?(i.length>0&&(r.push(i),i=""),a++):(i+=o,a++)}return i.length>0&&r.push(i),r}function mt(e,t){for(let[s,n]of t)n===void 0?e.state.env.delete(s):y(e.state.env,s,n)}function Ko(e){let t=[];if(e.state.env.get("COMPREPLY__length")!==void 0){let r=De(e,"COMPREPLY");for(let[,i]of r)t.push(i)}else e.state.env.has("COMPREPLY")&&t.push(x(e.state.env,"COMPREPLY"));return t}var Yo=["bashdefault","default","dirnames","filenames","noquote","nosort","nospace","plusdirs"];function dn(e,t){e.state.completionSpecs||(e.state.completionSpecs=new Map);let s=!1,n=!1,r=!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")n=!0;else if(d==="-D")r=!0;else if(d==="-W"){if(f++,f>=t.length)return A(`complete: -W: option requires an argument
|
|
47
|
+
`,2);i=t[f]}else if(d==="-F"){if(f++,f>=t.length)return A(`complete: -F: option requires an argument
|
|
48
|
+
`,2);a=t[f]}else if(d==="-o"){if(f++,f>=t.length)return A(`complete: -o: option requires an argument
|
|
49
|
+
`,2);let p=t[f];if(!Yo.includes(p))return A(`complete: ${p}: invalid option name
|
|
50
|
+
`,2);l.push(p)}else if(d==="-A"){if(f++,f>=t.length)return A(`complete: -A: option requires an argument
|
|
51
|
+
`,2);u.push(t[f])}else if(d==="-C"){if(f++,f>=t.length)return A(`complete: -C: option requires an argument
|
|
52
|
+
`,2);o=t[f]}else if(d==="-G"){if(f++,f>=t.length)return A(`complete: -G: option requires an argument
|
|
53
|
+
`,2)}else if(d==="-P"){if(f++,f>=t.length)return A(`complete: -P: option requires an argument
|
|
54
|
+
`,2)}else if(d==="-S"){if(f++,f>=t.length)return A(`complete: -S: option requires an argument
|
|
55
|
+
`,2)}else if(d==="-X"){if(f++,f>=t.length)return A(`complete: -X: option requires an argument
|
|
56
|
+
`,2)}else if(d==="--"){c.push(...t.slice(f+1));break}else d.startsWith("-")||c.push(d)}if(n){if(c.length===0)return e.state.completionSpecs.clear(),Te();for(let f of c)e.state.completionSpecs.delete(f);return Te()}if(s)return c.length===0?fn(e):fn(e,c);if(t.length===0||c.length===0&&!i&&!a&&!o&&l.length===0&&u.length===0&&!r)return fn(e);if(a&&c.length===0&&!r)return A(`complete: -F: option requires a command name
|
|
57
|
+
`,2);if(r){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),Te()}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 Te()}function fn(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
|
|
58
|
+
`;return W(L,F(i),1)}return Te()}let n=[],r=t||Array.from(s.keys());for(let i of r){if(i==="__default__")continue;let a=s.get(i);if(!a){if(t)return W(F(n.join(`
|
|
59
|
+
`)+(n.length>0?`
|
|
60
|
+
`:"")),F(`complete: ${i}: no completion specification
|
|
61
|
+
`),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}`,n.push(o)}return n.length===0?Te():G(`${n.join(`
|
|
71
62
|
`)}
|
|
72
|
-
`)}var
|
|
73
|
-
`,2);let u=t[
|
|
74
|
-
`,2);
|
|
75
|
-
`,2);let u=t[
|
|
76
|
-
`,2);i.push(u)}else if(l==="--"){
|
|
77
|
-
`,1)}function
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
`;else{let c=u.map(f=>{let
|
|
81
|
-
`}continue}let l=
|
|
63
|
+
`)}var ii=["bashdefault","default","dirnames","filenames","noquote","nosort","nospace","plusdirs"];function hn(e,t){e.state.completionSpecs||(e.state.completionSpecs=new Map);let s=!1,n=!1,r=[],i=[],a=[];for(let o=0;o<t.length;o++){let l=t[o];if(l==="-D")s=!0;else if(l==="-E")n=!0;else if(l==="-o"){if(o++,o>=t.length)return A(`compopt: -o: option requires an argument
|
|
64
|
+
`,2);let u=t[o];if(!ii.includes(u))return A(`compopt: ${u}: invalid option name
|
|
65
|
+
`,2);r.push(u)}else if(l==="+o"){if(o++,o>=t.length)return A(`compopt: +o: option requires an argument
|
|
66
|
+
`,2);let u=t[o];if(!ii.includes(u))return A(`compopt: ${u}: invalid option name
|
|
67
|
+
`,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 r)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),Te()}if(n){let o=e.state.completionSpecs.get("__empty__")??{},l=new Set(o.options??[]);for(let u of r)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),Te()}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 r)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 Te()}return A(`compopt: not currently executing completion function
|
|
68
|
+
`,1)}async function pn(e,t){if(e.state.loopDepth===0){if(e.state.parentHasLoopContext)throw new Be;return B()}if(t.length>1)throw await U(e,2,`bash: continue: too many arguments
|
|
69
|
+
`,!0),new q(1);let s=1;if(t.length>0){let n=Number.parseInt(t[0],10);if(Number.isNaN(n)||n<1)throw await U(e,2,`bash: continue: ${t[0]}: numeric argument required
|
|
70
|
+
`,!0),new q(1);s=n}throw new Ce(s)}function se(e,t){let s=x(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 mn(e){for(let t=0;t<e.length;t++){let s=e.charCodeAt(t);if(s<32||s===127)return!0}return!1}function gn(e){let t="$'";for(let s=0;s<e.length;s++){let n=e[s],r=e.charCodeAt(s);r===7?t+="\\a":r===8?t+="\\b":r===9?t+="\\t":r===10?t+="\\n":r===11?t+="\\v":r===12?t+="\\f":r===13?t+="\\r":r===27?t+="\\e":r===39?t+="\\'":r===92?t+="\\\\":r<32||r===127?t+=`\\${r.toString(8).padStart(3,"0")}`:t+=n}return t+="'",t}function bs(e){return mn(e)?gn(e):/^[a-zA-Z0-9_/.:\-@%+,=]*$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}function nt(e){return mn(e)?gn(e):`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function yn(e){return mn(e)?gn(e):`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function oi(e,t){let s="";return e.state.integerVars?.has(t)&&(s+="i"),e.state.lowercaseVars?.has(t)&&(s+="l"),be(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 wn(e){return e===""?"''":/[\s'\\]/.test(e)?`'${e.replace(/'/g,"'\\''")}'`:e}function ai(e,t){let s="",n="",r=!1;for(let i of t){let a=oi(e,i);if(e.state.associativeArrays?.has(i)){let u=Je(e,i);if(u.length===0)s+=`declare -A ${i}=()
|
|
71
|
+
`;else{let c=u.map(f=>{let d=x(e.state.env,`${i}_${f}`,""),p=wn(d);return`['${f}']=${p}`});s+=`declare -A ${i}=(${c.join(" ")})
|
|
72
|
+
`}continue}let l=pe(e,i);if(l.length>0){let u=l.map(c=>{let f=x(e.state.env,`${i}_${c}`,"");return`[${c}]=${nt(f)}`});s+=`declare -a ${i}=(${u.join(" ")})
|
|
82
73
|
`;continue}if(e.state.env.has(`${i}__length`)){s+=`declare -a ${i}=()
|
|
83
|
-
`;continue}if(e.state.env.has(i)){let u=
|
|
84
|
-
`}else{let u=e.state.declaredVars?.has(i),c=e.state.localVarDepth?.has(i);u||c?s+=`declare ${
|
|
85
|
-
`:(
|
|
86
|
-
`,
|
|
87
|
-
`;else{let
|
|
88
|
-
`}continue}if(m.length>0){let
|
|
74
|
+
`;continue}if(e.state.env.has(i)){let u=x(e.state.env,i);s+=`declare ${a} ${i}=${yn(u)}
|
|
75
|
+
`}else{let u=e.state.declaredVars?.has(i),c=e.state.localVarDepth?.has(i);u||c?s+=`declare ${a} ${i}
|
|
76
|
+
`:(n+=`bash: declare: ${i}: not found
|
|
77
|
+
`,r=!0)}}return W(F(s),F(n),r?1:0)}function li(e,t){let{filterExport:s,filterReadonly:n,filterNameref:r,filterIndexedArray:i,filterAssocArray:a}=t,o=s||n||r||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=oi(e,f),p=e.state.associativeArrays?.has(f),m=pe(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)||n&&!e.state.readonlyVars?.has(f)||r&&!be(e,f)))){if(p){let b=Je(e,f);if(b.length===0)l+=`declare -A ${f}=()
|
|
78
|
+
`;else{let S=b.map($=>{let g=x(e.state.env,`${f}_${$}`,""),v=wn(g);return`['${$}']=${v}`});l+=`declare -A ${f}=(${S.join(" ")})
|
|
79
|
+
`}continue}if(m.length>0){let b=m.map(S=>{let $=x(e.state.env,`${f}_${S}`,"");return`[${S}]=${nt($)}`});l+=`declare -a ${f}=(${b.join(" ")})
|
|
89
80
|
`;continue}if(e.state.env.has(`${f}__length`)){l+=`declare -a ${f}=()
|
|
90
|
-
`;continue}if(e.state.env.has(f)){let
|
|
91
|
-
`}}}return
|
|
92
|
-
`;else{let i=
|
|
93
|
-
`}}return
|
|
94
|
-
`;else{let
|
|
95
|
-
`}}return
|
|
96
|
-
`);return
|
|
97
|
-
`),2)}}}else if(
|
|
98
|
-
`),2);else
|
|
99
|
-
`;return
|
|
100
|
-
`:
|
|
81
|
+
`;continue}if(e.state.env.has(f)){let b=x(e.state.env,f);l+=`declare ${d} ${f}=${yn(b)}
|
|
82
|
+
`}}}return G(l)}function ci(e){let t="",s=Array.from(e.state.associativeArrays??[]).sort();for(let n of s){let r=Je(e,n);if(r.length===0)t+=`declare -A ${n}=()
|
|
83
|
+
`;else{let i=r.map(a=>{let o=x(e.state.env,`${n}_${a}`,""),l=wn(o);return`['${a}']=${l}`});t+=`declare -A ${n}=(${i.join(" ")})
|
|
84
|
+
`}}return G(t)}function ui(e){let t="",s=new Set;for(let r of e.state.env.keys()){if(r.startsWith("BASH_"))continue;if(r.endsWith("__length")){let a=r.slice(0,-8);e.state.associativeArrays?.has(a)||s.add(a);continue}let i=r.lastIndexOf("_");if(i>0){let a=r.slice(0,i),o=r.slice(i+1);/^\d+$/.test(o)&&(e.state.associativeArrays?.has(a)||s.add(a))}}let n=Array.from(s).sort();for(let r of n){let i=pe(e,r);if(i.length===0)t+=`declare -a ${r}=()
|
|
85
|
+
`;else{let a=i.map(o=>{let l=x(e.state.env,`${r}_${o}`,"");return`[${o}]=${nt(l)}`});t+=`declare -a ${r}=(${a.join(" ")})
|
|
86
|
+
`}}return G(t)}function fi(e){let t="",s=new Set;for(let r of e.state.env.keys()){if(r.startsWith("BASH_"))continue;if(r.endsWith("__length")){let a=r.slice(0,-8);s.add(a);continue}let i=r.lastIndexOf("_");if(i>0){let a=r.slice(0,i),o=r.slice(i+1);if(/^\d+$/.test(o)||e.state.associativeArrays?.has(a)){s.add(a);continue}}s.add(r)}let n=Array.from(s).sort();for(let r of n)e.state.associativeArrays?.has(r)||pe(e,r).length>0||e.state.env.has(`${r}__length`)||e.state.env.has(r)&&(t+=`${r}=${bs(x(e.state.env,r))}
|
|
87
|
+
`);return G(t)}function vn(e,t){e.state.integerVars??=new Set,e.state.integerVars.add(t)}function Dt(e,t){return e.state.integerVars?.has(t)??!1}function bn(e,t){e.state.lowercaseVars??=new Set,e.state.lowercaseVars.add(t),e.state.uppercaseVars?.delete(t)}function Xo(e,t){return e.state.lowercaseVars?.has(t)??!1}function Sn(e,t){e.state.uppercaseVars??=new Set,e.state.uppercaseVars.add(t),e.state.lowercaseVars?.delete(t)}function Qo(e,t){return e.state.uppercaseVars?.has(t)??!1}function gt(e,t,s){return Xo(e,t)?s.toLowerCase():Qo(e,t)?s.toUpperCase():s}async function di(e,t){try{let s=new Z,n=le(s,t),r=await Q(e,n.expression);return String(r)}catch{return"0"}}function ea(e){let t=e.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);if(!t)return null;let s=t[0],n=s.length;if(e[n]!=="[")return null;let r=0,i=n+1;for(;n<e.length;n++)if(e[n]==="[")r++;else if(e[n]==="]"&&(r--,r===0))break;if(r!==0)return null;let a=e.slice(i,n);if(n++,e[n]!=="=")return null;n++;let o=e.slice(n);return{name:s,indexExpr:a,value:o}}async function En(e,t){let s=!1,n=!1,r=!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,S=[];for(let k=0;k<t.length;k++){let O=t[k];if(O==="-a")s=!0;else if(O==="-A")n=!0;else if(O==="-r")r=!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==="--"){S.push(...t.slice(k+1));break}else if(O.startsWith("+")){for(let R of O.slice(1))if(R==="n")l=!0;else if(R==="a")u=!0;else if(R==="x")c=!0;else if(R!=="r"){if(R!=="i"){if(!(R==="f"||R==="F"))return W(L,F(`bash: typeset: +${R}: invalid option
|
|
88
|
+
`),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 R of O.slice(1))if(R==="a")s=!0;else if(R==="A")n=!0;else if(R==="r")r=!0;else if(R==="x")i=!0;else if(R==="p")a=!0;else if(R==="n")o=!0;else if(R==="i")f=!0;else if(R==="l")d=!0;else if(R==="u")p=!0;else if(R==="f")m=!0;else if(R==="F")h=!0;else if(R==="g")b=!0;else return W(L,F(`bash: typeset: -${R}: invalid option
|
|
89
|
+
`),2);else S.push(O)}let g=e.state.localScopes.length>0&&!b,v=k=>{if(!g)return;let O=e.state.localScopes[e.state.localScopes.length-1];O.has(k)||O.set(k,e.state.env.get(k))},C=k=>{if(!g)return;let O=e.state.localScopes[e.state.localScopes.length-1];O.has(k)||O.set(k,e.state.env.get(k));let R=`${k}_`;for(let T of e.state.env.keys())T.startsWith(R)&&!T.includes("__")&&(O.has(T)||O.set(T,e.state.env.get(T)));let _=`${k}__length`;e.state.env.has(_)&&!O.has(_)&&O.set(_,e.state.env.get(_))},N=k=>{g&&Ye(e,k)};if(h){if(S.length===0){let R=Array.from(e.state.functions.keys()).sort(),_="";for(let T of R)_+=`declare -f ${T}
|
|
90
|
+
`;return G(_)}let k=!0,O="";for(let R of S)e.state.functions.has(R)?O+=`${R}
|
|
91
|
+
`:k=!1;return W(F(O),L,k?0:1)}if(m){if(S.length===0){let O="",R=Array.from(e.state.functions.keys()).sort();for(let _ of R)O+=`${_} ()
|
|
101
92
|
{
|
|
102
93
|
# function body
|
|
103
94
|
}
|
|
104
|
-
`;return
|
|
105
|
-
`,
|
|
106
|
-
`,
|
|
107
|
-
`,
|
|
108
|
-
`,
|
|
109
|
-
`,
|
|
110
|
-
`,
|
|
111
|
-
`}}return
|
|
112
|
-
`,2);
|
|
113
|
-
`,2);if(
|
|
114
|
-
`,2);
|
|
115
|
-
`,1);let
|
|
116
|
-
`,1)}catch{return
|
|
117
|
-
`,1)}s.unshift(e.state.cwd),e.state.previousDir=e.state.cwd,e.state.cwd=
|
|
118
|
-
`;return
|
|
119
|
-
`,2):
|
|
120
|
-
`,2);if(s.length===0)return
|
|
121
|
-
`,1);let
|
|
122
|
-
`,1);e.state.previousDir=e.state.cwd,e.state.cwd=
|
|
123
|
-
`;return
|
|
124
|
-
`,2);else return
|
|
125
|
-
`,1);if(
|
|
95
|
+
`;return G(O)}let k=!0;for(let O of S)e.state.functions.has(O)||(k=!1);return W(L,L,k?0:1)}if(a&&S.length>0)return ai(e,S);if(a&&S.length===0)return li(e,{filterExport:i,filterReadonly:r,filterNameref:o,filterIndexedArray:s,filterAssocArray:n});if(S.length===0&&n&&!a)return ci(e);if(S.length===0&&s&&!a)return ui(e);if(S.length===0&&!a)return fi(e);let I="",P=0;for(let k of S){let O=k.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(O&&!u){let w=O[1],D=O[2];if(n&&pe(e,w).length>0){I+=`bash: declare: ${w}: cannot convert indexed to associative array
|
|
96
|
+
`,P=1;continue}if((s||!n&&!s)&&e.state.associativeArrays?.has(w)){I+=`bash: declare: ${w}: cannot convert associative to indexed array
|
|
97
|
+
`,P=1;continue}if(C(w),n&&(e.state.associativeArrays??=new Set,e.state.associativeArrays.add(w)),We(e,w),e.state.env.delete(w),e.state.env.delete(`${w}__length`),n&&D.includes("[")){let M=ds(D);for(let[J,j]of M){let X=se(e,j);y(e.state.env,`${w}_${J}`,X)}}else if(n){let M=ze(D);for(let J=0;J<M.length;J+=2){let j=M[J],X=J+1<M.length?se(e,M[J+1]):"";y(e.state.env,`${w}_${j}`,X)}}else{let M=ze(D);if(M.some(j=>/^\[[^\]]+\]=/.test(j))){let j=0;for(let X of M){let re=X.match(/^\[([^\]]+)\]=(.*)$/);if(re){let $e=re[1],rt=re[2],so=se(e,rt),vt;if(/^-?\d+$/.test($e))vt=Number.parseInt($e,10);else try{let no=new Z,ro=le(no,$e);vt=await Q(e,ro.expression)}catch{vt=0}y(e.state.env,`${w}_${vt}`,so),j=vt+1}else{let $e=se(e,X);y(e.state.env,`${w}_${j}`,$e),j++}}}else{for(let j=0;j<M.length;j++)y(e.state.env,`${w}_${j}`,M[j]);y(e.state.env,`${w}__length`,String(M.length))}}N(w),r&&Se(e,w),i&&Ie(e,w);continue}if(l){let w=k.includes("=")?k.slice(0,k.indexOf("=")):k;if(fr(e,w),!k.includes("="))continue}if(c){let w=k.includes("=")?k.slice(0,k.indexOf("=")):k;if(Yt(e,w),!k.includes("="))continue}let R=ea(k);if(R){let{name:w,indexExpr:D,value:M}=R,J=await ue(e,w);if(J)return J;C(w);let j;try{let re=new Z,$e=le(re,D);j=await Q(e,$e.expression)}catch{let re=parseInt(D,10);j=Number.isNaN(re)?0:re}y(e.state.env,`${w}_${j}`,M);let X=parseInt(x(e.state.env,`${w}__length`,"0"),10);j>=X&&y(e.state.env,`${w}__length`,String(j+1)),N(w),r&&Se(e,w),i&&Ie(e,w);continue}let _=k.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=\((.*)\)$/s);if(_&&!u){let w=_[1],D=_[2],M=await ue(e,w);if(M)return M;C(w);let J=ze(D);if(e.state.associativeArrays?.has(w)){let j=ds(D);for(let[X,re]of j){let $e=se(e,re);y(e.state.env,`${w}_${X}`,$e)}}else{let j=pe(e,w),X=0,re=e.state.env.get(w);j.length===0&&re!==void 0?(e.state.env.set(`${w}_0`,re),e.state.env.delete(w),X=1):j.length>0&&(X=Math.max(...j)+1);for(let rt=0;rt<J.length;rt++)y(e.state.env,`${w}_${X+rt}`,se(e,J[rt]));let $e=X+J.length;y(e.state.env,`${w}__length`,String($e))}N(w),r&&Se(e,w),i&&Ie(e,w);continue}let T=k.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(T){let w=T[1],D=se(e,T[2]),M=await ue(e,w);if(M)return M;v(w),f&&vn(e,w),d&&bn(e,w),p&&Sn(e,w);let j=pe(e,w).length>0||e.state.associativeArrays?.has(w);if(Dt(e,w)){let X=x(e.state.env,w,"0"),re=parseInt(X,10)||0,$e=parseInt(await di(e,D),10)||0;D=String(re+$e),y(e.state.env,w,D)}else if(j){D=gt(e,w,D);let X=`${w}_0`,re=x(e.state.env,X);y(e.state.env,X,re+D)}else{D=gt(e,w,D);let X=x(e.state.env,w);y(e.state.env,w,X+D)}N(w),r&&Se(e,w),i&&Ie(e,w),e.state.options.allexport&&!c&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(w));continue}if(k.includes("=")){let w=k.indexOf("="),D=k.slice(0,w),M=k.slice(w+1);if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(D)){I+=`bash: typeset: \`${D}': not a valid identifier
|
|
98
|
+
`,P=1;continue}let J=await ue(e,D);if(J)return J;if(v(D),o){if(M!==""&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(M)){I+=`bash: declare: \`${M}': invalid variable name for name reference
|
|
99
|
+
`,P=1;continue}y(e.state.env,D,M),He(e,D),M!==""&&js(e,M)&&zs(e,D),N(D),r&&Se(e,D),i&&Ie(e,D);continue}if(f&&vn(e,D),d&&bn(e,D),p&&Sn(e,D),Dt(e,D)&&(M=await di(e,M)),M=gt(e,D,M),be(e,D)){let j=Fe(e,D);j&&j!==D?y(e.state.env,j,M):y(e.state.env,D,M)}else y(e.state.env,D,M);N(D),r&&Se(e,D),i&&Ie(e,D),e.state.options.allexport&&!c&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(D))}else{let w=k;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(w)){I+=`bash: typeset: \`${w}': not a valid identifier
|
|
100
|
+
`,P=1;continue}if(s||n?C(w):v(w),o){He(e,w);let M=x(e.state.env,w);M!==""&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(M)?dr(e,w):M&&js(e,M)&&zs(e,w),N(w),r&&Se(e,w),i&&Ie(e,w);continue}if(f&&vn(e,w),d&&bn(e,w),p&&Sn(e,w),n){if(pe(e,w).length>0){I+=`bash: declare: ${w}: cannot convert indexed to associative array
|
|
101
|
+
`,P=1;continue}e.state.associativeArrays??=new Set,e.state.associativeArrays.add(w)}let D=Array.from(e.state.env.keys()).some(M=>M.startsWith(`${w}_`)&&!M.startsWith(`${w}__length`));!e.state.env.has(w)&&!D&&(s||n?y(e.state.env,`${w}__length`,"0"):(e.state.declaredVars??=new Set,e.state.declaredVars.add(w))),N(w),r&&Se(e,w),i&&Ie(e,w)}}return W(L,F(I),P)}async function $n(e,t){let s=!1,n=!1,r=!1,i=[];for(let a=0;a<t.length;a++){let o=t[a];if(o==="-a")s=!0;else if(o==="-A")n=!0;else if(o==="-p")r=!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=H(u??L).replace(/\\/g,"\\\\").replace(/"/g,'\\"');a+=`declare -r ${l}="${c}"
|
|
102
|
+
`}}return G(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 ue(e,f);if(p)return p;let m=ze(d);if(e.state.associativeArrays?.has(f)){let h=ds(d);for(let[b,S]of h){let $=se(e,S);y(e.state.env,`${f}_${b}`,$)}}else{let h=pe(e,f),b=0,S=e.state.env.get(f);h.length===0&&S!==void 0?(e.state.env.set(`${f}_0`,S),e.state.env.delete(f),b=1):h.length>0&&(b=Math.max(...h)+1);for(let g=0;g<m.length;g++)y(e.state.env,`${f}_${b+g}`,se(e,m[g]));let $=b+m.length;y(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=se(e,l[2]),p=await ue(e,f);if(p)return p;let m=x(e.state.env,f);y(e.state.env,f,m+d),Se(e,f);continue}let u=qr(a);if(u.value===void 0&&!u.isArray){Se(e,u.name);continue}let c=await Zr(e,u,{makeReadonly:!0});if(c)return c}return ft}function An(e){return e.state.directoryStack??=[],e.state.directoryStack}function It(e,t){return t&&e===t?"~":t&&e.startsWith(`${t}/`)?`~${e.slice(t.length)}`:e}function ta(e){let t=e.split("/").filter(n=>n&&n!=="."),s=[];for(let n of t)n===".."?s.pop():s.push(n);return`/${s.join("/")}`}async function Cn(e,t){let s=An(e),n;for(let o=0;o<t.length;o++){let l=t[o];if(l==="--"){if(o+1<t.length){if(n!==void 0)return A(`bash: pushd: too many arguments
|
|
103
|
+
`,2);n=t[o+1],o++}}else{if(l.startsWith("-")&&l!=="-")return A(`bash: pushd: ${l}: invalid option
|
|
104
|
+
`,2);if(n!==void 0)return A(`bash: pushd: too many arguments
|
|
105
|
+
`,2);n=l}}if(n===void 0){if(s.length<2)return A(`bash: pushd: no other directory
|
|
106
|
+
`,1);let o=s[0];s[0]=s[1],s[1]=o,n=s[0]}let r;if(n.startsWith("/"))r=n;else if(n===".."){let o=e.state.cwd.split("/").filter(l=>l);o.pop(),r=`/${o.join("/")}`}else n==="."?r=e.state.cwd:n.startsWith("~")?r=x(e.state.env,"HOME","/")+n.slice(1):r=`${e.state.cwd}/${n}`;r=ta(r);try{if(!(await e.fs.stat(r)).isDirectory)return A(`bash: pushd: ${n}: Not a directory
|
|
107
|
+
`,1)}catch{return A(`bash: pushd: ${n}: No such file or directory
|
|
108
|
+
`,1)}s.unshift(e.state.cwd),e.state.previousDir=e.state.cwd,e.state.cwd=r,y(e.state.env,"PWD",r),y(e.state.env,"OLDPWD",e.state.previousDir);let i=x(e.state.env,"HOME",""),a=`${[r,...s].map(o=>It(o,i)).join(" ")}
|
|
109
|
+
`;return G(a)}function kn(e,t){let s=An(e);for(let a of t)if(a!=="--")return a.startsWith("-")&&a!=="-"?A(`bash: popd: ${a}: invalid option
|
|
110
|
+
`,2):A(`bash: popd: too many arguments
|
|
111
|
+
`,2);if(s.length===0)return A(`bash: popd: directory stack empty
|
|
112
|
+
`,1);let n=s.shift();if(!n)return A(`bash: popd: directory stack empty
|
|
113
|
+
`,1);e.state.previousDir=e.state.cwd,e.state.cwd=n,y(e.state.env,"PWD",n),y(e.state.env,"OLDPWD",e.state.previousDir);let r=x(e.state.env,"HOME",""),i=`${[n,...s].map(a=>It(a,r)).join(" ")}
|
|
114
|
+
`;return G(i)}function Pn(e,t){let s=An(e),n=!1,r=!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")n=!0;else if(f==="l")r=!0;else if(f==="p")i=!0;else if(f==="v")i=!0,a=!0;else return A(`bash: dirs: -${f}: invalid option
|
|
115
|
+
`,2);else return A(`bash: dirs: too many arguments
|
|
116
|
+
`,1);if(n)return e.state.directoryStack=[],ft;let o=[e.state.cwd,...s],l=x(e.state.env,"HOME",""),u;return a?(u=o.map((c,f)=>{let d=r?c:It(c,l);return` ${f} ${d}`}).join(`
|
|
126
117
|
`),u+=`
|
|
127
|
-
`):i?u=
|
|
118
|
+
`):i?u=o.map(c=>r?c:It(c,l)).join(`
|
|
128
119
|
`)+`
|
|
129
|
-
`:u=
|
|
130
|
-
`,
|
|
120
|
+
`:u=o.map(c=>r?c:It(c,l)).join(" ")+`
|
|
121
|
+
`,G(u)}async function Ss(e,t,s){let n=t;if(n.length>0){let o=n[0];if(o==="--")n=n.slice(1);else if(o.startsWith("-")&&o!=="-"&&o.length>1)return A(`bash: eval: ${o}: invalid option
|
|
131
122
|
eval: usage: eval [arg ...]
|
|
132
|
-
`,2)}if(
|
|
133
|
-
`);throw
|
|
134
|
-
|
|
135
|
-
`}}return
|
|
136
|
-
`,i=1;continue}if(l!==void 0)if(u){let f=
|
|
137
|
-
`);let s=t[0],
|
|
138
|
-
`,
|
|
139
|
-
`,
|
|
140
|
-
`,1);
|
|
141
|
-
`,1):
|
|
142
|
-
`,1);u++}else l.push(m),u++}if(s)return e.state.hashTable.clear(),
|
|
143
|
-
`,1);let m=!1,
|
|
144
|
-
`,m=!0);return m?
|
|
145
|
-
`,1);let m="",
|
|
146
|
-
`:m+=`${
|
|
147
|
-
`:(
|
|
148
|
-
`,
|
|
149
|
-
`,1);let m=l[0];return e.state.hashTable.set(m,
|
|
150
|
-
`);let m="";if(
|
|
123
|
+
`,2)}if(n.length===0)return B();let r=n.join(" ");if(r.trim()==="")return B();let i=e.state.groupStdin,a=s??e.state.groupStdin;a!==void 0&&(e.state.groupStdin=a);try{let o=Le(r),l=await e.executeScript(o);return await Y(e,l)}catch(o){if(await ee(e,o),o instanceof Ae||o instanceof Ce||o instanceof we||o instanceof q)throw o;if(o.name==="ParseException")return A(`bash: eval: ${o.message}
|
|
124
|
+
`);throw o}finally{e.state.groupStdin=i}}async function _n(e,t){let s,n;if(t.length===0)s=e.state.lastExitCode;else{let r=t[0],i=Number.parseInt(r,10);r===""||Number.isNaN(i)||!/^-?\d+$/.test(r)?(n=`bash: exit: ${r}: numeric argument required
|
|
125
|
+
`,s=2):s=(i%256+256)%256}throw n&&await U(e,2,n,!0),new q(s)}function Tn(e,t){let s=!1,n=[];for(let a of t)a==="-n"?s=!0:a==="-p"||a==="--"||n.push(a);if(n.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=H(c??L).replace(/\\/g,"\\\\").replace(/"/g,'\\"');a+=`declare -x ${u}="${f}"
|
|
126
|
+
`}}return G(a)}if(s){for(let a of n){let o,l;if(a.includes("=")){let u=a.indexOf("=");o=a.slice(0,u),l=se(e,a.slice(u+1)),y(e.state.env,o,l)}else o=a;Yt(e,o)}return ft}let r="",i=0;for(let a of n){let o,l,u=!1,c=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(c)o=c[1],l=se(e,c[2]),u=!0;else if(a.includes("=")){let f=a.indexOf("=");o=a.slice(0,f),l=se(e,a.slice(f+1))}else o=a;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(o)){r+=`bash: export: \`${a}': not a valid identifier
|
|
127
|
+
`,i=1;continue}if(l!==void 0)if(u){let f=x(e.state.env,o);y(e.state.env,o,f+l)}else y(e.state.env,o,l);else e.state.env.has(o)||y(e.state.env,o,"");Ie(e,o)}return W(L,F(r),i)}function Es(e,t){if(t.length<2)return A(`bash: getopts: usage: getopts optstring name [arg ...]
|
|
128
|
+
`);let s=t[0],n=t[1],r=!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n),i=s.startsWith(":"),a=i?s.slice(1):s,o;if(t.length>2)o=t.slice(2);else{let h=Number.parseInt(x(e.state.env,"#","0"),10);o=[];for(let b=1;b<=h;b++)o.push(x(e.state.env,String(b))||"")}let l=Number.parseInt(x(e.state.env,"OPTIND","1"),10);l<1&&(l=1);let u=Number.parseInt(x(e.state.env,"__GETOPTS_CHARINDEX","0"),10);if(y(e.state.env,"OPTARG",""),l>o.length)return r||y(e.state.env,n,"?"),y(e.state.env,"OPTIND",String(o.length+1)),y(e.state.env,"__GETOPTS_CHARINDEX","0"),{exitCode:r?2:1,stdout:E(),stderr:E()};let c=o[l-1];if(!c||c==="-"||!c.startsWith("-"))return r||y(e.state.env,n,"?"),{exitCode:r?2:1,stdout:E(),stderr:E()};if(c==="--")return y(e.state.env,"OPTIND",String(l+1)),y(e.state.env,"__GETOPTS_CHARINDEX","0"),r||y(e.state.env,n,"?"),{exitCode:r?2:1,stdout:E(),stderr:E()};let f=u===0?1:u,d=c[f];if(!d)return y(e.state.env,"OPTIND",String(l+1)),y(e.state.env,"__GETOPTS_CHARINDEX","0"),Es(e,t);let p=a.indexOf(d);if(p===-1){let h="";return i?y(e.state.env,"OPTARG",d):h=`bash: illegal option -- ${d}
|
|
129
|
+
`,r||y(e.state.env,n,"?"),f+1<c.length?(y(e.state.env,"__GETOPTS_CHARINDEX",String(f+1)),y(e.state.env,"OPTIND",String(l))):(y(e.state.env,"OPTIND",String(l+1)),y(e.state.env,"__GETOPTS_CHARINDEX","0")),{exitCode:r?2:0,stdout:E(),stderr:V(h)}}if(p+1<a.length&&a[p+1]===":")if(f+1<c.length)y(e.state.env,"OPTARG",c.slice(f+1)),y(e.state.env,"OPTIND",String(l+1)),y(e.state.env,"__GETOPTS_CHARINDEX","0");else{if(l>=o.length){let h="";return i?(y(e.state.env,"OPTARG",d),r||y(e.state.env,n,":")):(h=`bash: option requires an argument -- ${d}
|
|
130
|
+
`,r||y(e.state.env,n,"?")),y(e.state.env,"OPTIND",String(l+1)),y(e.state.env,"__GETOPTS_CHARINDEX","0"),{exitCode:r?2:0,stdout:E(),stderr:V(h)}}y(e.state.env,"OPTARG",o[l]),y(e.state.env,"OPTIND",String(l+2)),y(e.state.env,"__GETOPTS_CHARINDEX","0")}else f+1<c.length?(y(e.state.env,"__GETOPTS_CHARINDEX",String(f+1)),y(e.state.env,"OPTIND",String(l))):(y(e.state.env,"OPTIND",String(l+1)),y(e.state.env,"__GETOPTS_CHARINDEX","0"));return r||y(e.state.env,n,d),{exitCode:r?2:0,stdout:E(),stderr:E()}}async function xn(e,t){e.state.hashTable||(e.state.hashTable=new Map);let s=!1,n=!1,r=!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")n=!0,u++;else if(m==="-l")r=!0,u++;else if(m==="-t")a=!0,u++;else if(m==="-p"){if(i=!0,u++,u>=t.length)return A(`bash: hash: -p: option requires an argument
|
|
131
|
+
`,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")n=!0;else if(h==="l")r=!0;else if(h==="t")a=!0;else return h==="p"?A(`bash: hash: -p: option requires an argument
|
|
132
|
+
`,1):A(`bash: hash: -${h}: invalid option
|
|
133
|
+
`,1);u++}else l.push(m),u++}if(s)return e.state.hashTable.clear(),B();if(n){if(l.length===0)return A(`bash: hash: -d: option requires an argument
|
|
134
|
+
`,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
|
|
135
|
+
`,m=!0);return m?A(h,1):B()}if(a){if(l.length===0)return A(`bash: hash: -t: option requires an argument
|
|
136
|
+
`,1);let m="",h=!1,b="";for(let S of l){let $=e.state.hashTable.get(S);$?l.length>1?m+=`${S} ${$}
|
|
137
|
+
`:m+=`${$}
|
|
138
|
+
`:(b+=`bash: hash: ${S}: not found
|
|
139
|
+
`,h=!0)}return h?{exitCode:1,stdout:V(m),stderr:V(b)}:G(m)}if(i){if(l.length===0)return A(`bash: hash: usage: hash [-lr] [-p pathname] [-dt] [name ...]
|
|
140
|
+
`,1);let m=l[0];return e.state.hashTable.set(m,o),B()}if(l.length===0){if(e.state.hashTable.size===0)return G(`hash: hash table empty
|
|
141
|
+
`);let m="";if(r)for(let[h,b]of e.state.hashTable)m+=`builtin hash -p ${b} ${h}
|
|
151
142
|
`;else{m=`hits command
|
|
152
|
-
`;for(let[,
|
|
153
|
-
`}return
|
|
154
|
-
`,c=!0;continue}let
|
|
155
|
-
`,c=!0)}return c?
|
|
143
|
+
`;for(let[,h]of e.state.hashTable)m+=` 1 ${h}
|
|
144
|
+
`}return G(m)}let c=!1,f="",p=x(e.state.env,"PATH","/usr/bin:/bin").split(":");for(let m of l){if(m.includes("/")){f+=`bash: hash: ${m}: cannot use / in name
|
|
145
|
+
`,c=!0;continue}let h=!1;for(let b of p){if(!b)continue;let S=`${b}/${m}`;if(await e.fs.exists(S)){e.state.hashTable.set(m,S),h=!0;break}}h||(f+=`bash: hash: ${m}: not found
|
|
146
|
+
`,c=!0)}return c?A(f,1):B()}var hi=new Map([[":",[": [arguments]",`Null command.
|
|
156
147
|
No effect; the command does nothing.
|
|
157
148
|
Exit Status:
|
|
158
149
|
Always succeeds.`]],[".",[". filename [arguments]",`Execute commands from a file in the current shell.
|
|
@@ -317,12 +308,12 @@ eval: usage: eval [arg ...]
|
|
|
317
308
|
Display the history list with line numbers, prefixing each modified
|
|
318
309
|
entry with a \`*'.
|
|
319
310
|
Exit Status:
|
|
320
|
-
Returns success unless an invalid option is given or an error occurs.`]],["jobs",["jobs [
|
|
321
|
-
Lists
|
|
311
|
+
Returns success unless an invalid option is given or an error occurs.`]],["jobs",["jobs [jobspec ...]",`Display status of jobs.
|
|
312
|
+
Lists all active jobs, or only the jobs identified by JOBSPEC.
|
|
322
313
|
Exit Status:
|
|
323
|
-
Returns success unless
|
|
314
|
+
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.
|
|
324
315
|
Send the processes identified by PID or JOBSPEC the signal named by
|
|
325
|
-
|
|
316
|
+
the option. SIGTERM is used when no option is supplied.
|
|
326
317
|
Exit Status:
|
|
327
318
|
Returns success unless an invalid option is given or an error occurs.`]],["let",["let arg [arg ...]",`Evaluate arithmetic expressions.
|
|
328
319
|
Evaluate each ARG as an arithmetic expression. Evaluation is done in
|
|
@@ -492,37 +483,52 @@ eval: usage: eval [arg ...]
|
|
|
492
483
|
Without options, unset first tries to unset a variable, and if that fails,
|
|
493
484
|
tries to unset a function.
|
|
494
485
|
Exit Status:
|
|
495
|
-
Returns success unless an invalid option is given or a NAME is read-only.`]],["wait",["wait [
|
|
486
|
+
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.
|
|
496
487
|
Waits for each process identified by an ID, which may be a process ID or a
|
|
497
|
-
job specification,
|
|
488
|
+
job specification. With no ID, waits for all known jobs.
|
|
498
489
|
Exit Status:
|
|
499
490
|
Returns the status of the last ID; fails if ID is invalid or an invalid
|
|
500
|
-
option is given.`]]]),
|
|
501
|
-
`,2)}
|
|
502
|
-
`,
|
|
503
|
-
`:i+=`${c}: ${
|
|
504
|
-
${
|
|
505
|
-
`}}return{exitCode:
|
|
491
|
+
option is given.`]]]),pi=[...hi.keys()].sort();function Nn(e,t){let s=!1,n=[],r=0;for(;r<t.length;){let l=t[r];if(l==="--"){for(r++;r<t.length;)n.push(t[r]),r++;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 A(`bash: help: -${c}: invalid option
|
|
492
|
+
`,2)}r++}else n.push(l),r++}if(n.length===0)return na();let i="",a=!1,o="";for(let l of n){let u=sa(l);if(u.length===0){o+=`bash: help: no help topics match \`${l}'. Try \`help help' or \`man -k ${l}' or \`info ${l}'.
|
|
493
|
+
`,a=!0;continue}for(let c of u){let f=hi.get(c);if(!f)continue;let[d,p]=f;s?i+=`${c}: ${d}
|
|
494
|
+
`:i+=`${c}: ${d}
|
|
495
|
+
${p}
|
|
496
|
+
`}}return{exitCode:a?1:0,stdout:V(i),stderr:V(o)}}function sa(e){let t=e.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,"."),s=At(`^${t}$`);return pi.filter(n=>s.test(n))}function na(){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=pi.slice(),n=Math.ceil(s.length/2);for(let r=0;r<n;r++){let i=s[r]||"",a=s[r+n]||"",o=i.padEnd(t);e.push(a?`${o}${a}`:i)}return G(`${e.join(`
|
|
506
497
|
`)}
|
|
507
|
-
`)}
|
|
508
|
-
|
|
509
|
-
`)
|
|
510
|
-
`);let
|
|
511
|
-
`}}return
|
|
512
|
-
`,
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
`),
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
`)
|
|
524
|
-
`)
|
|
525
|
-
|
|
498
|
+
`)}var ra=`jobs: usage: jobs [-lnprs] [jobspec ...] or jobs -x command [args]
|
|
499
|
+
`;function ia(e){return{stdout:E(),stderr:V(`bash: jobs: ${e}: invalid option
|
|
500
|
+
${ra}`),exitCode:2}}async function On(e,t,s){if(t[0]==="-x"){let f=t[1];if(!f)return{stdout:E(),stderr:E(),exitCode:0};if(!s)return{stdout:E(),stderr:V(`bash: jobs: -x: command execution unavailable
|
|
501
|
+
`),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:E(),stderr:V(`bash: ${p}: no such job
|
|
502
|
+
`),exitCode:1};d.push(String(m))}return s(f,d)}let n={long:!1,pidsOnly:!1,runningOnly:!1,stoppedOnly:!1,changedOnly:!1},r=0;for(;r<t.length;r++){let f=t[r];if(f==="--"){r++;break}if(!f.startsWith("-")||f==="-")break;for(let d of f.slice(1))if(d==="l")n.long=!0;else if(d==="n")n.changedOnly=!0;else if(d==="p")n.pidsOnly=!0;else if(d==="r")n.runningOnly=!0;else if(d==="s")n.stoppedOnly=!0;else return ia(`-${d}`)}let i=t.slice(r),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
|
|
503
|
+
`,u=1);let c=e.processes.listJobs(a,{changedOnly:n.changedOnly,runningOnly:n.runningOnly,stoppedOnly:n.stoppedOnly});for(let f of c){if(n.pidsOnly){o+=`${f.pid}
|
|
504
|
+
`;continue}let d=f.state==="running"?"Running ":"Done ",p=n.long?`[${f.jobNumber}]${f.marker} ${f.pid} `:`[${f.jobNumber}]${f.marker} `;o+=`${p}${d}${f.command}
|
|
505
|
+
`}return{stdout:V(o),stderr:V(l),exitCode:u}}var mi=`kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
|
|
506
|
+
`,$s=typeof process<"u"&&process.platform==="darwin",Dn=[{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:$s?30:10,delivery:"SIGTERM"},{name:"USR2",number:$s?31:12,delivery:"SIGTERM"},{name:"STOP",number:$s?17:19,delivery:"SIGSTOP"},{name:"CONT",number:$s?19:18,delivery:"SIGCONT"}];function As(e){let t=e.toUpperCase().replace(/^SIG/,"");if(/^\d+$/.test(t)){let s=Number.parseInt(t,10);return Dn.find(n=>n.number===s)}return Dn.find(s=>s.name===t)}function In(e){return{stdout:E(),stderr:V(`bash: kill: ${e.replace(/^-/,"")}: invalid signal specification
|
|
507
|
+
`),exitCode:1}}function oa(e){if(e.length===0)return{stdout:V(`${Dn.map(s=>`${s.number}) SIG${s.name}`).join(" ")}
|
|
508
|
+
`),stderr:E(),exitCode:0};let t="";for(let s of e){let n=/^\d+$/.test(s)?String(Number.parseInt(s,10)-(Number(s)>128?128:0)):s,r=As(n);if(!r)return In(s);t+=/^\d+$/.test(s)?`${r.name}
|
|
509
|
+
`:`${r.number}
|
|
510
|
+
`}return{stdout:V(t),stderr:E(),exitCode:0}}function Rn(e,t){let s=As("TERM"),n=0;if(t[0]==="-l")return oa(t.slice(1));if(t[0]==="-s"||t[0]==="-n"){let o=t[1];if(!o)return{stdout:E(),stderr:V(mi),exitCode:2};let l=As(o);if(!l)return In(o);s=l,n=2}else if(t[0]?.startsWith("-")&&t[0]!=="--"){let o=t[0].slice(1),l=As(o);if(!l)return In(o);s=l,n=1}else t[0]==="--"&&(n=1);let r=t.slice(n);if(r.length===0)return{stdout:E(),stderr:V(mi),exitCode:2};let i="",a=0;for(let o of r){let l;if(o.startsWith("%")){if(l=e.processes.resolveJobSpec(o),l===void 0){i+=`bash: kill: ${o}: no such job
|
|
511
|
+
`,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
|
|
512
|
+
`,a=1;continue}e.processes.kill(l,s.delivery,s.number)||(i+=`bash: kill: (${l}) - No such process
|
|
513
|
+
`,a=1)}return{stdout:E(),stderr:V(i),exitCode:a}}function aa(e){let t=[],s="",n=0;for(let r of e){for(let i of r)i==="("?n++:i===")"&&n--;s?s+=` ${r}`:s=r,n===0&&(t.push(s),s="")}return s&&t.push(s),t}async function Ln(e,t){if(t.length===0)return A(`bash: let: expression expected
|
|
514
|
+
`);let s=aa(t),n=0;for(let r of s)try{let a=Le(`(( ${r} ))`).statements[0];if(a&&a.pipelines.length>0&&a.pipelines[0].commands.length>0){let o=a.pipelines[0].commands[0];o.type==="ArithmeticCommand"&&(n=await Q(e,o.expression.expression))}}catch(i){return A(`bash: let: ${r}: ${i.message}
|
|
515
|
+
`)}return W(L,L,n===0?1:0)}async function Mn(e,t){if(e.state.localScopes.length===0)return A(`bash: local: can only be used in a function
|
|
516
|
+
`);let s=e.state.localScopes[e.state.localScopes.length-1],n="",r=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=H(d);u+=`${f}=${p}
|
|
517
|
+
`}}return W(F(u),L,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 S=d[2];if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(c)){n+=`bash: local: \`${u}': not a valid identifier
|
|
518
|
+
`,r=1;continue}if(await ue(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 g=ze(S);for(let v=0;v<g.length;v++)y(e.state.env,`${c}_${v}`,g[v]);y(e.state.env,`${c}__length`,String(g.length)),Ye(e,c),i&&He(e,c);continue}let p=u.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=\((.*)\)$/s);if(p){c=p[1];let S=p[2];if(await ue(e,c,"bash"),!s.has(c)){s.set(c,e.state.env.get(c));let I=`${c}_`;for(let k of e.state.env.keys())k.startsWith(I)&&!k.includes("__")&&(s.has(k)||s.set(k,e.state.env.get(k)));let P=`${c}__length`;e.state.env.has(P)&&!s.has(P)&&s.set(P,e.state.env.get(P))}let $=ze(S),g=pe(e,c),v=0,C=e.state.env.get(c);g.length===0&&C!==void 0?(e.state.env.set(`${c}_0`,C),e.state.env.delete(c),v=1):g.length>0&&(v=Math.max(...g)+1);for(let I=0;I<$.length;I++)y(e.state.env,`${c}_${v+I}`,se(e,$[I]));let N=v+$.length;y(e.state.env,`${c}__length`,String(N)),Ye(e,c),i&&He(e,c);continue}let m=u.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(m){c=m[1];let S=se(e,m[2]);await ue(e,c,"bash"),s.has(c)||s.set(c,e.state.env.get(c));let $=x(e.state.env,c);y(e.state.env,c,$+S),Ye(e,c),i&&He(e,c);continue}let h=u.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([^\]]+)\]=(.*)$/s);if(h){c=h[1];let S=h[2],$=se(e,h[3]);if(await ue(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 g;try{let C=new Z,N=le(C,S);g=await Q(e,N.expression)}catch{let C=parseInt(S,10);g=Number.isNaN(C)?0:C}y(e.state.env,`${c}_${g}`,$);let v=parseInt(x(e.state.env,`${c}__length`,"0"),10);g>=v&&y(e.state.env,`${c}__length`,String(g+1)),Ye(e,c),i&&He(e,c);continue}if(u.includes("=")){let S=u.indexOf("=");c=u.slice(0,S),f=se(e,u.slice(S+1))}else c=u;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(c)){n+=`bash: local: \`${u}': not a valid identifier
|
|
519
|
+
`,r=1;continue}let b=s.has(c);if(f!==void 0){let S=e.state.env.get(c);if(e.state.tempEnvBindings){let $=e.state.accessedTempEnvVars?.has(c),g=e.state.mutatedTempEnvVars?.has(c);if(!$&&!g)for(let v=e.state.tempEnvBindings.length-1;v>=0;v--){let C=e.state.tempEnvBindings[v];if(C.has(c)){S=C.get(c);break}}}Jr(e,c,S)}if(!b){let S=e.state.env.get(c);if(e.state.tempEnvBindings)for(let $=e.state.tempEnvBindings.length-1;$>=0;$--){let g=e.state.tempEnvBindings[$];if(g.has(c)){S=g.get(c);break}}if(s.set(c,S),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 g=`${c}__length`;e.state.env.has(g)&&!s.has(g)&&s.set(g,e.state.env.get(g))}}if(a&&f===void 0){let S=`${c}_`;for(let $ of e.state.env.keys())$.startsWith(S)&&!$.includes("__")&&e.state.env.delete($);y(e.state.env,`${c}__length`,"0")}else if(f!==void 0){if(await ue(e,c,"bash"),i&&f!==""&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(f)){n+=`bash: local: \`${f}': invalid variable name for name reference
|
|
520
|
+
`,r=1;continue}y(e.state.env,c,f),e.state.options.allexport&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(c))}else{let S=e.state.tempEnvBindings?.some($=>$.has(c));!b&&!S&&e.state.env.delete(c)}Ye(e,c),i&&He(e,c)}return W(L,F(n),r)}async function Wn(e,t,s){let n=H(s),r=`
|
|
521
|
+
`,i=0,a=0,o=0,l=!1,u="MAPFILE",c=0;for(;c<t.length;){let g=t[c];g==="-d"&&c+1<t.length?(r=t[c+1]===""?"\0":t[c+1]||`
|
|
522
|
+
`,c+=2):g==="-n"&&c+1<t.length?(i=Number.parseInt(t[c+1],10)||0,c+=2):g==="-O"&&c+1<t.length?(a=Number.parseInt(t[c+1],10)||0,c+=2):g==="-s"&&c+1<t.length?(o=Number.parseInt(t[c+1],10)||0,c+=2):g==="-t"?(l=!0,c++):g==="-u"||g==="-C"||g==="-c"?c+=2:(g.startsWith("-")||(u=g),c++)}let f=n;!f&&e.state.groupStdin!==void 0&&(f=H(await ie(e.state.groupStdin)));let d=[],p=f,m=0,h=0,b=e.limits?.maxArrayElements??1e5;for(;p.length>0;){let g=p.indexOf(r);if(g===-1){if(p.length>0){if(h<o)h++;else if(i===0||m<i){if(a+m>=b)return W(L,F(`mapfile: array element limit exceeded (${b})
|
|
523
|
+
`),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,g),C=v.indexOf("\0");if(C!==-1&&(v=v.substring(0,C)),!l&&r!=="\0"&&(v+=r),p=p.substring(g+r.length),h<o){h++;continue}if(i>0&&m>=i)break;if(a+m>=b)return W(L,F(`mapfile: array element limit exceeded (${b})
|
|
524
|
+
`),1);d.push(v),m++}a===0&&We(e,u);for(let g=0;g<d.length;g++)y(e.state.env,`${u}_${a+g}`,d[g]);let S=parseInt(x(e.state.env,`${u}__length`,"0"),10),$=a+d.length;return y(e.state.env,`${u}__length`,String(Math.max(S,$))),e.state.groupStdin!==void 0&&!n&&(e.state.groupStdin=E()),W(L,L,0)}function la(e){if(!e.startsWith("__rw__:"))return null;let t=e.slice(7),s=t.indexOf(":");if(s===-1)return null;let n=Number.parseInt(t.slice(0,s),10);if(Number.isNaN(n)||n<0)return null;let r=s+1,i=t.slice(r,r+n),a=r+n+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 ca(e,t,s){return`__rw__:${e.length}:${e}:${t}:${s}`}async function Fn(e,t,s,n=-1){let r=H(s),i=!1,a=`
|
|
525
|
+
`,o="",l=-1,u=-1,c=null,f=-1,d=-1,p=[],m=0,h=!1,b=(_,T)=>{let w=1;for(;w<_.length;){let D=_[w];if(D==="r")i=!0,w++;else if(D==="s")w++;else{if(D==="d")return w+1<_.length?(a=_.substring(w+1),{nextArgIndex:T+1}):T+1<t.length?(a=t[T+1],{nextArgIndex:T+2}):{nextArgIndex:T+1};if(D==="n"){if(w+1<_.length){let M=_.substring(w+1);return l=Number.parseInt(M,10),(Number.isNaN(l)||l<0)&&(h=!0,l=0),{nextArgIndex:T+1}}else if(T+1<t.length)return l=Number.parseInt(t[T+1],10),(Number.isNaN(l)||l<0)&&(h=!0,l=0),{nextArgIndex:T+2};return{nextArgIndex:T+1}}else if(D==="N"){if(w+1<_.length){let M=_.substring(w+1);return u=Number.parseInt(M,10),(Number.isNaN(u)||u<0)&&(h=!0,u=0),{nextArgIndex:T+1}}else if(T+1<t.length)return u=Number.parseInt(t[T+1],10),(Number.isNaN(u)||u<0)&&(h=!0,u=0),{nextArgIndex:T+2};return{nextArgIndex:T+1}}else{if(D==="a")return w+1<_.length?(c=_.substring(w+1),{nextArgIndex:T+1}):T+1<t.length?(c=t[T+1],{nextArgIndex:T+2}):{nextArgIndex:T+1};if(D==="p")return w+1<_.length?(o=_.substring(w+1),{nextArgIndex:T+1}):T+1<t.length?(o=t[T+1],{nextArgIndex:T+2}):{nextArgIndex:T+1};if(D==="u"){if(w+1<_.length){let M=_.substring(w+1);return f=Number.parseInt(M,10),Number.isNaN(f)||f<0?{nextArgIndex:-2}:{nextArgIndex:T+1}}else if(T+1<t.length)return f=Number.parseInt(t[T+1],10),Number.isNaN(f)||f<0?{nextArgIndex:-2}:{nextArgIndex:T+2};return{nextArgIndex:T+1}}else if(D==="t"){if(w+1<_.length){let M=_.substring(w+1);return d=Number.parseFloat(M),Number.isNaN(d)&&(d=0),{nextArgIndex:T+1}}else if(T+1<t.length)return d=Number.parseFloat(t[T+1]),Number.isNaN(d)&&(d=0),{nextArgIndex:T+2};return{nextArgIndex:T+1}}else if(D==="e"||D==="i"||D==="P"){if(D==="i"&&T+1<t.length)return{nextArgIndex:T+2};w++}else w++}}}return{nextArgIndex:T+1}};for(;m<t.length;){let _=t[m];if(_.startsWith("-")&&_.length>1&&_!=="--"){let T=b(_,m);if(T.nextArgIndex===-1)return{stdout:E(),stderr:E(),exitCode:2};if(T.nextArgIndex===-2)return{stdout:E(),stderr:E(),exitCode:1};m=T.nextArgIndex}else if(_==="--")for(m++;m<t.length;)p.push(t[m]),m++;else p.push(_),m++}if(h)return W(L,L,1);if(p.length===0&&c===null&&p.push("REPLY"),d===0){if(c)We(e,c);else{for(let _ of p)y(e.state.env,_,"");p.length===0&&y(e.state.env,"REPLY","")}return W(L,L,0)}if(d<0&&d!==-1)return W(L,L,1);let S=r;f>=0?e.state.fileDescriptors?S=e.state.fileDescriptors.get(f)||"":S="":!S&&e.state.groupStdin!==void 0&&(S=H(await ie(e.state.groupStdin)));let $=a===""?"\0":a,g="",v=0,C=!0,N=_=>{if(f>=0&&e.state.fileDescriptors)e.state.fileDescriptors.set(f,S.substring(_));else if(n>=0&&e.state.fileDescriptors){let T=e.state.fileDescriptors.get(n);if(T?.startsWith("__rw__:")){let w=la(T);if(w){let D=w.position+_;e.state.fileDescriptors.set(n,ca(w.path,D,w.content))}}}else e.state.groupStdin!==void 0&&!r&&(e.state.groupStdin=he(F(S.substring(_))))};if(u>=0){let _=Math.min(u,S.length);g=S.substring(0,_),v=_,C=_>=u,N(v);let T=p[0]||"REPLY";y(e.state.env,T,g);for(let w=1;w<p.length;w++)y(e.state.env,p[w],"");return W(L,L,C?0:1)}else if(l>=0){let _=0,T=0,w=!1;for(;T<S.length&&_<l;){let D=S[T];if(D===$){v=T+1,w=!0;break}if(!i&&D==="\\"&&T+1<S.length){let M=S[T+1];if(M===$&&$===`
|
|
526
|
+
`){T+=2,v=T;continue}if(M===$){T+=2,_++,g+=M,v=T;continue}g+=M,T+=2,_++,v=T}else g+=D,T++,_++,v=T}C=_>=l||w,N(v)}else{v=0;let _=0;for(;_<S.length;){let T=S[_];if(T===$){v=_+$.length,C=!0;break}if(!i&&T==="\\"&&_+1<S.length){let w=S[_+1];if(w===`
|
|
527
|
+
`){_+=2;continue}if(w===$){g+=w,_+=2;continue}g+=T,g+=w,_+=2;continue}g+=T,_++}if(_>=S.length&&(C=!1,v=_,g.length===0&&S.length===0)){for(let T of p)y(e.state.env,T,"");return c&&We(e,c),W(L,L,1)}N(v)}$===`
|
|
528
|
+
`&&g.endsWith(`
|
|
529
|
+
`)&&(g=g.slice(0,-1));let I=_=>i?_:_.replace(/\\(.)/g,"$1");if(p.length===1&&p[0]==="REPLY")return y(e.state.env,"REPLY",I(g)),W(L,L,C?0:1);let P=cr(e.state.env);if(c){let{words:_}=Vs(g,P,void 0,i),T=e.limits?.maxArrayElements??1e5;if(_.length>T)return W(L,F(`read: array element limit exceeded (${T})
|
|
530
|
+
`),1);We(e,c);for(let w=0;w<_.length;w++)y(e.state.env,`${c}_${w}`,I(_[w]));return W(L,L,C?0:1)}let k=p.length,{words:O,wordStarts:R}=Vs(g,P,k,i);for(let _=0;_<p.length;_++){let T=p[_];if(_<p.length-1)y(e.state.env,T,I(O[_]??""));else if(_<R.length){let w=g.substring(R[_]);w=ur(w,P,i),w=I(w),y(e.state.env,T,w)}else y(e.state.env,T,"")}return W(L,L,C?0:1)}function Vn(e,t){if(e.state.callDepth===0&&e.state.sourceDepth===0)return A("bash: return: can only `return' from a function or sourced script\n");let s=e.state.lastExitCode;if(t.length>0){let n=t[0],r=Number.parseInt(n,10);if(n===""||Number.isNaN(r)||!/^-?\d+$/.test(n))return A(`bash: return: ${n}: numeric argument required
|
|
531
|
+
`,2);s=(r%256+256)%256}throw new we(s)}var Cs=`set: usage: set [-eux] [+eux] [-o option] [+o option]
|
|
526
532
|
Options:
|
|
527
533
|
-e Exit immediately if a command exits with non-zero status
|
|
528
534
|
+e Disable -e
|
|
@@ -538,163 +544,174 @@ Options:
|
|
|
538
544
|
+o pipefail Disable pipefail
|
|
539
545
|
-o xtrace Same as -x
|
|
540
546
|
+o xtrace Disable xtrace
|
|
541
|
-
`,
|
|
547
|
+
`,gi=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]]),yi=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]]),wi=["errexit","nounset","pipefail","verbose","xtrace","posix","allexport","noclobber","noglob","noexec","vi","emacs"],vi=["braceexpand","errtrace","functrace","hashall","histexpand","history","ignoreeof","interactive-comments","keyword","monitor","nolog","notify","onecmd","physical","privileged"];function bi(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,ut(e))}function ua(e,t){return t+1<e.length&&!e[t+1].startsWith("-")&&!e[t+1].startsWith("+")}function fa(e,t){let s=pe(e,t);if(s.length===0)return`${t}=()`;let n=s.map(r=>{let i=x(e.state.env,`${t}_${r}`,"");return`[${r}]=${nt(i)}`});return`${t}=(${n.join(" ")})`}function da(e){return/^[a-zA-Z0-9_]+$/.test(e)?e:`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function ha(e,t){let s=Je(e,t);if(s.length===0)return`${t}=()`;let n=s.map(r=>{let i=x(e.state.env,`${t}_${r}`,"");return`[${da(r)}]=${nt(i)}`});return`${t}=(${n.join(" ")} )`}function pa(e){let t=new Set,s=e.state.associativeArrays??new Set;for(let n of e.state.env.keys()){let r=n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_(\d+)$/);if(r){let i=r[1];s.has(i)||t.add(i)}}return t}function ma(e){return e.state.associativeArrays??new Set}async function jn(e,t){if(t.includes("--help"))return G(Cs);if(t.length===0){let n=pa(e),r=ma(e),i=l=>{for(let u of r){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)||n.has(l)||r.has(l))continue;let c=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_(\d+)$/);if(c&&n.has(c[1]))continue;let f=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)__length$/);f&&n.has(f[1])||i(l)||f&&r.has(f[1])||a.push([l,H(u)])}let o=[];for(let[l,u]of a.sort(([c],[f])=>c<f?-1:c>f?1:0))o.push(`${l}=${bs(u)}`);for(let l of[...n].sort((u,c)=>u<c?-1:u>c?1:0))o.push(fa(e,l));for(let l of[...r].sort((u,c)=>u<c?-1:u>c?1:0))o.push(ha(e,l));return o.sort((l,u)=>{let c=l.split("=")[0],f=u.split("=")[0];return c<f?-1:c>f?1:0}),G(o.length>0?`${o.join(`
|
|
542
548
|
`)}
|
|
543
|
-
`:"")}let s=0;for(;s<t.length;){let
|
|
544
|
-
${
|
|
549
|
+
`:"")}let s=0;for(;s<t.length;){let n=t[s];if((n==="-o"||n==="+o")&&ua(t,s)){let r=t[s+1];if(!yi.has(r)){let i=`bash: set: ${r}: invalid option name
|
|
550
|
+
${Cs}`;if(e.state.options.posix)throw await U(e,2,i,!0),new ve(1);return A(i)}bi(e,yi.get(r)??null,n==="-o"),s+=2;continue}if(n==="-o"){let r=wi.map(o=>`${o.padEnd(16)}${e.state.options[o]?"on":"off"}`),i=vi.map(o=>`${o.padEnd(16)}off`),a=[...r,...i].sort();return G(`${a.join(`
|
|
545
551
|
`)}
|
|
546
|
-
`)}if(
|
|
552
|
+
`)}if(n==="+o"){let r=wi.map(o=>`set ${e.state.options[o]?"-o":"+o"} ${o}`),i=vi.map(o=>`set +o ${o}`),a=[...r,...i].sort();return G(`${a.join(`
|
|
547
553
|
`)}
|
|
548
|
-
`)}if(
|
|
549
|
-
${
|
|
550
|
-
${
|
|
551
|
-
`;if(e.state.options.posix)throw
|
|
552
|
-
`;if(e.state.options.posix)throw
|
|
553
|
-
`),2);let
|
|
554
|
-
`);let
|
|
555
|
-
`);throw u}}function
|
|
556
|
-
`,
|
|
557
|
-
`,
|
|
558
|
-
`,
|
|
559
|
-
`,
|
|
560
|
-
`,
|
|
561
|
-
`,
|
|
562
|
-
`,
|
|
563
|
-
`,
|
|
564
|
-
`,
|
|
565
|
-
`,
|
|
566
|
-
`,
|
|
567
|
-
`,
|
|
568
|
-
|
|
569
|
-
`)};if(
|
|
554
|
+
`)}if(n.length>1&&(n[0]==="-"||n[0]==="+")&&n[1]!=="-"){let r=n[0]==="-";for(let i=1;i<n.length;i++){let a=n[i];if(!gi.has(a)){let o=`bash: set: ${n[0]}${a}: invalid option
|
|
555
|
+
${Cs}`;if(e.state.options.posix)throw await U(e,2,o,!0),new ve(1);return A(o)}bi(e,gi.get(a)??null,r)}s++;continue}if(n==="--")return zn(e,t.slice(s+1)),B();if(n==="-"){if(e.state.options.xtrace=!1,e.state.options.verbose=!1,ut(e),s+1<t.length)return zn(e,t.slice(s+1)),B();s++;continue}if(n==="+"){s++;continue}if(n.startsWith("-")||n.startsWith("+")){let r=`bash: set: ${n}: invalid option
|
|
556
|
+
${Cs}`;if(e.state.options.posix)throw await U(e,2,r,!0),new ve(1);return A(r)}return zn(e,t.slice(s)),B()}return B()}function zn(e,t){let s=1;for(;e.state.env.has(String(s));)e.state.env.delete(String(s)),s++;for(let n=0;n<t.length;n++)y(e.state.env,String(n+1),t[n]);y(e.state.env,"#",String(t.length)),y(e.state.env,"@",t.join(" ")),y(e.state.env,"*",t.join(" "))}async function Bn(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
|
|
557
|
+
`;if(e.state.options.posix)throw await U(e,2,o,!0),new ve(1);return A(o)}s=a}let n=Number.parseInt(x(e.state.env,"#","0"),10);if(s>n){let a=`bash: shift: shift count out of range
|
|
558
|
+
`;if(e.state.options.posix)throw await U(e,2,a,!0),new ve(1);return A(a)}if(s===0)return B();let r=[];for(let a=1;a<=n;a++)r.push(x(e.state.env,String(a))||"");let i=r.slice(s);for(let a=1;a<=n;a++)e.state.env.delete(String(a));for(let a=0;a<i.length;a++)y(e.state.env,String(a+1),i[a]);return y(e.state.env,"#",String(i.length)),y(e.state.env,"@",i.join(" ")),B()}async function Hn(e,t){let s=t;if(s.length>0&&s[0]==="--"&&(s=s.slice(1)),s.length===0)return W(L,F(`bash: source: filename argument required
|
|
559
|
+
`),2);let n=s[0],r=null,i=null;if(n.includes("/")){let u=e.fs.resolvePath(e.state.cwd,n);try{i=await e.fs.readFileText(u),r=u}catch{}}else{let c=x(e.state.env,"PATH","").split(":").filter(f=>f);for(let f of c){let d=e.fs.resolvePath(e.state.cwd,`${f}/${n}`);try{if((await e.fs.stat(d)).isDirectory)continue;i=await e.fs.readFileText(d),r=d;break}catch{}}if(i===null){let f=e.fs.resolvePath(e.state.cwd,n);try{i=await e.fs.readFileText(f),r=f}catch{}}}if(i===null)return A(`bash: ${n}: No such file or directory
|
|
560
|
+
`);let a=new Map;if(s.length>1){for(let c=1;c<=9;c++)a.set(String(c),x(e.state.env,String(c)));a.set("#",x(e.state.env,"#")),a.set("@",x(e.state.env,"@"));let u=s.slice(1);y(e.state.env,"#",String(u.length)),y(e.state.env,"@",u.join(" "));for(let c=0;c<u.length&&c<9;c++)y(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):y(e.state.env,u,c)};e.state.sourceDepth++,e.state.currentSource=n;try{let u=Le(i),c=await e.executeScript(u),f=await Y(e,c);return l(),f}catch(u){if(l(),await ee(e,u),u instanceof q)throw u;if(u instanceof we)return W(L,L,u.exitCode);if(u.name==="ParseException")return A(`bash: ${n}: ${u.message}
|
|
561
|
+
`);throw u}}function Si(e){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)}function ga(e){return e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"')}async function Ei(e,t){if(ga(t))return null;try{let s=new Z,n=le(s,t);return await Q(e,n.expression)}catch{let s=parseInt(t,10);return Number.isNaN(s)?0:s}}function $i(e,t){if(e.state.localVarStack?.has(t)){let n=ps(e,t);if(n){n.value===void 0?e.state.env.delete(t):e.state.env.set(t,n.value);let r=e.state.localVarStack?.get(t);if(!r||r.length===0)hs(e,t),e.state.localVarStack?.delete(t),e.state.fullyUnsetLocals=e.state.fullyUnsetLocals||new Map,e.state.fullyUnsetLocals.set(t,n.scopeIndex),Un(e,t);else{let i=r[r.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),hs(e,t),e.state.localVarStack?.delete(t),e.state.fullyUnsetLocals=e.state.fullyUnsetLocals||new Map,e.state.fullyUnsetLocals.set(t,0),!0}for(let n=e.state.localScopes.length-1;n>=0;n--){let r=e.state.localScopes[n];if(r.has(t)){let i=r.get(t);i===void 0?e.state.env.delete(t):e.state.env.set(t,i),r.delete(t);let a=!1;for(let o=n-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||hs(e,t),!0}}return!1}function Un(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 n=e.state.tempEnvBindings[s];if(n.has(t)){let r=n.get(t);return r===void 0?e.state.env.delete(t):e.state.env.set(t,r),n.delete(t),!0}}return!1}async function Ai(e,t){if(t.startsWith("'")&&t.endsWith("'"))return t.slice(1,-1);if(t.startsWith('"')&&t.endsWith('"')){let s=t.slice(1,-1),r=new Z().parseWordFromString(s,!0,!1);return z(e,r)}if(t.includes("$")){let n=new Z().parseWordFromString(t,!1,!1);return z(e,n)}return t}async function Gn(e,t){let s="both",n="",r=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 g=De(e,d);for(let[v]of g)e.state.env.delete(`${d}_${v}`);e.state.env.delete(d);continue}let m=e.state.associativeArrays?.has(d);if(m){let g=await Ai(e,p);e.state.env.delete(`${d}_${g}`);continue}let h=Bs(e,d),b=e.state.declaredVars?.has(d);if((e.state.env.has(d)||b)&&!h&&!m){n+=`bash: unset: ${d}: not an array variable
|
|
562
|
+
`,r=1;continue}let $=await Ei(e,p);if($===null&&h){n+=`bash: unset: ${p}: not a valid identifier
|
|
563
|
+
`,r=1;continue}if($===null)continue;if($<0){let g=De(e,d),v=g.length,C=e.state.currentLine;if(v===0){n+=`bash: line ${C}: unset: [${$}]: bad array subscript
|
|
564
|
+
`,r=1;continue}let N=v+$;if(N<0){n+=`bash: line ${C}: unset: [${$}]: bad array subscript
|
|
565
|
+
`,r=1;continue}let I=g[N][0];e.state.env.delete(`${d}_${I}`);continue}e.state.env.delete(`${d}_${$}`);continue}if(!Si(i)){n+=`bash: unset: \`${i}': not a valid identifier
|
|
566
|
+
`,r=1;continue}let c=i;if(be(e,i)){let d=Fe(e,i);d&&d!==i&&(c=d)}if(tt(e,c)){n+=`bash: unset: ${c}: cannot unset: readonly variable
|
|
567
|
+
`,r=1;continue}let f=ht(e,c);if(f!==void 0&&f!==e.state.callDepth)$i(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=ps(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 Un(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=De(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 Ai(e,c);e.state.env.delete(`${u}_${h}`);continue}let d=Bs(e,u);if(e.state.env.has(u)&&!d&&!f){n+=`bash: unset: ${u}: not an array variable
|
|
568
|
+
`,r=1;continue}let m=await Ei(e,c);if(m===null&&d){n+=`bash: unset: ${c}: not a valid identifier
|
|
569
|
+
`,r=1;continue}if(m===null)continue;if(m<0){let h=De(e,u),b=h.length,S=e.state.currentLine;if(b===0){n+=`bash: line ${S}: unset: [${m}]: bad array subscript
|
|
570
|
+
`,r=1;continue}let $=b+m;if($<0){n+=`bash: line ${S}: unset: [${m}]: bad array subscript
|
|
571
|
+
`,r=1;continue}let g=h[$][0];e.state.env.delete(`${u}_${g}`);continue}e.state.env.delete(`${u}_${m}`);continue}if(!Si(i)){n+=`bash: unset: \`${i}': not a valid identifier
|
|
572
|
+
`,r=1;continue}let o=i;if(be(e,i)){let u=Fe(e,i);u&&u!==i&&(o=u)}if(tt(e,o)){n+=`bash: unset: ${o}: cannot unset: readonly variable
|
|
573
|
+
`,r=1;continue}let l=ht(e,o);if(l!==void 0&&l!==e.state.callDepth)$i(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=ps(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 Un(e,o)||e.state.env.delete(o);e.state.exportedVars?.delete(o),e.state.functions.delete(i)}return W(L,F(n),r)}var ya=`wait: usage: wait [id ...]
|
|
574
|
+
`;async function qn(e,t){let s=t.find(i=>i.startsWith("-"));if(s)return{stdout:E(),stderr:V(`bash: wait: ${s}: invalid option
|
|
575
|
+
${ya}`),exitCode:2};if(Qe(e.signal),t.length===0){let i,a=new Promise((o,l)=>{i=()=>l(new me(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:E(),stderr:E(),exitCode:o}}finally{i&&e.signal?.removeEventListener("abort",i)}}let n=0,r="";for(let i of t){Qe(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)){r+=i.startsWith("%")?`bash: wait: ${i}: no such job
|
|
576
|
+
`:`bash: wait: pid ${i} is not a child of this shell
|
|
577
|
+
`,n=127;continue}let o,l=new Promise((u,c)=>{o=()=>c(new me(e.signal?.reason)),e.signal?.addEventListener("abort",o,{once:!0})});try{n=await(e.signal?Promise.race([e.processes.wait(a),l]):e.processes.wait(a))}finally{o&&e.signal?.removeEventListener("abort",o)}}return{stdout:E(),stderr:V(r),exitCode:n}}var Zn=["extglob","dotglob","nullglob","failglob","globstar","globskipdots","nocaseglob","nocasematch","expand_aliases","lastpipe","xpg_echo"],wa=["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 ks(e){return Zn.includes(e)}function va(e){return wa.includes(e)}function Ci(e,t){let s=!1,n=!1,r=!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":n=!0;break;case"p":r=!0;break;case"q":i=!0;break;case"o":a=!0;break;default:return{exitCode:2,stdout:E(),stderr:V(`shopt: -${m}: invalid option
|
|
578
|
+
`)}}}l++}else break}for(;l<t.length;)o.push(t[l]),l++;if(a)return ba(e,o,s,n,r,i);if(s&&n)return{exitCode:1,stdout:E(),stderr:V(`shopt: cannot set and unset shell options simultaneously
|
|
579
|
+
`)};if(o.length===0){if(s||n){let p=[];for(let m of Zn){let h=e.state.shoptOptions[m];s&&h?p.push(r?`shopt -s ${m}`:`${m} on`):n&&!h&&p.push(r?`shopt -u ${m}`:`${m} off`)}return{exitCode:0,stdout:p.length>0?V(`${p.join(`
|
|
570
580
|
`)}
|
|
571
|
-
`):
|
|
581
|
+
`):E(),stderr:E()}}let d=[];for(let p of Zn){let m=e.state.shoptOptions[p];d.push(r?`shopt ${m?"-s":"-u"} ${p}`:`${p} ${m?"on":"off"}`)}return{exitCode:0,stdout:V(`${d.join(`
|
|
572
582
|
`)}
|
|
573
|
-
`),stderr:
|
|
574
|
-
`,u=!0;continue}if(s)
|
|
583
|
+
`),stderr:E()}}let u=!1,c="",f=[];for(let d of o){if(!ks(d)&&!va(d)){c+=`shopt: ${d}: invalid shell option name
|
|
584
|
+
`,u=!0;continue}if(s)ks(d)&&(e.state.shoptOptions[d]=!0,Zs(e));else if(n)ks(d)&&(e.state.shoptOptions[d]=!1,Zs(e));else if(ks(d)){let p=e.state.shoptOptions[d];i?p||(u=!0):r?(f.push(`shopt ${p?"-s":"-u"} ${d}`),p||(u=!0)):(f.push(`${d} ${p?"on":"off"}`),p||(u=!0))}else i?u=!0:r?(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(`
|
|
575
585
|
`)}
|
|
576
|
-
`):
|
|
586
|
+
`):E(),stderr:V(c)}}function ba(e,t,s,n,r,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||n&&b||d.push(r?`set ${b?"-o":"+o"} ${p}`:`${p} ${b?"on":"off"}`)}return{exitCode:0,stdout:d.length>0?V(`${d.join(`
|
|
577
587
|
`)}
|
|
578
|
-
`):
|
|
579
|
-
`,u=!0;continue}if(m){s||
|
|
588
|
+
`):E(),stderr:E()}}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
|
|
589
|
+
`,u=!0;continue}if(m){s||n||(i?u=!0:r?(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,ut(e);else if(n)e.state.options[h]=!1,ut(e);else{let b=e.state.options[h];i?b||(u=!0):r?(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(`
|
|
580
590
|
`)}
|
|
581
|
-
`):
|
|
582
|
-
`;
|
|
583
|
-
`,
|
|
584
|
-
`;else{let
|
|
585
|
-
`;c
|
|
586
|
-
`:c+=`${
|
|
587
|
-
`),
|
|
588
|
-
`:c+=`${
|
|
589
|
-
`),
|
|
590
|
-
`;else{let
|
|
591
|
-
`;c
|
|
592
|
-
`:c+=`${
|
|
593
|
-
`),
|
|
594
|
-
`:
|
|
595
|
-
`:c+=`${
|
|
596
|
-
`,
|
|
597
|
-
`:
|
|
598
|
-
`:c+=`${
|
|
599
|
-
`,
|
|
600
|
-
`)}}}return i?
|
|
591
|
+
`):E(),stderr:V(c)}}async function ki(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 r=(s??x(e.state.env,"PATH","/usr/bin:/bin")).split(":");for(let a of r){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 Ps(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 r=x(e.state.env,"PATH","/usr/bin:/bin").split(":");for(let i of r){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 xi(e,t,s,n){let r=!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"?r=!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 n(h);if(N.length>0){for(let I of N)c+=`${I}
|
|
592
|
+
`;p=!0,b=!0}}else{let N=await s(h);N&&(c+=`${N}
|
|
593
|
+
`,p=!0,b=!0)}b||(m=!0);continue}let S=!l&&e.state.functions.has(h);if(o&&S){if(!i)if(r)c+=`function
|
|
594
|
+
`;else{let N=e.state.functions.get(h),I=N?Pi(h,N):`${h} is a function
|
|
595
|
+
`;c+=I}b=!0}let $=e.state.env.get(`BASH_ALIAS_${h}`);if($!==void 0&&(o||!b)&&(i||(r?c+=`alias
|
|
596
|
+
`:c+=`${h} is aliased to \`${H($)}'
|
|
597
|
+
`),b=!0,!o)||sn.has(h)&&(o||!b)&&(i||(r?c+=`keyword
|
|
598
|
+
`:c+=`${h} is a shell keyword
|
|
599
|
+
`),b=!0,!o))continue;if(!o&&S&&!b){if(!i)if(r)c+=`function
|
|
600
|
+
`;else{let N=e.state.functions.get(h),I=N?Pi(h,N):`${h} is a function
|
|
601
|
+
`;c+=I}b=!0;continue}if(!(Ge.has(h)&&(o||!b)&&(i||(r?c+=`builtin
|
|
602
|
+
`:c+=`${h} is a shell builtin
|
|
603
|
+
`),b=!0,!o))){if(o){let N=await n(h);for(let I of N)i?c+=`${I}
|
|
604
|
+
`:r?c+=`file
|
|
605
|
+
`:c+=`${h} is ${I}
|
|
606
|
+
`,p=!0,b=!0}else if(!b){let N=await s(h);N&&(i?c+=`${N}
|
|
607
|
+
`:r?c+=`file
|
|
608
|
+
`:c+=`${h} is ${N}
|
|
609
|
+
`,p=!0,b=!0)}if(!b&&(m=!0,!r&&!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
|
|
610
|
+
`)}}}return i?d=m&&!p?1:0:d=m?1:0,W(F(c),F(f),d)}function Pi(e,t){let s;return t.body.type==="Group"?s=t.body.body.map(r=>Rt(r)).join("; "):s=Rt(t.body),`${e} is a function
|
|
601
611
|
${e} ()
|
|
602
612
|
{
|
|
603
613
|
${s}
|
|
604
614
|
}
|
|
605
|
-
`}function
|
|
606
|
-
`:
|
|
607
|
-
`;else if(
|
|
608
|
-
`:
|
|
609
|
-
`;else if(
|
|
610
|
-
`:
|
|
611
|
-
`;else if(e.state.functions.has(
|
|
612
|
-
`:
|
|
613
|
-
`;else if(
|
|
614
|
-
`:
|
|
615
|
-
`,c=!0)}catch{}c||(
|
|
616
|
-
`),
|
|
617
|
-
`:
|
|
618
|
-
`}else
|
|
619
|
-
`),
|
|
620
|
-
`);let[,...
|
|
621
|
-
`,127):
|
|
622
|
-
`,127);if("error"in u)return u.error==="permission_denied"?
|
|
623
|
-
`,126):
|
|
624
|
-
`,127);if("script"in u)return t.includes("/")||(
|
|
625
|
-
`)}}async function
|
|
626
|
-
`)
|
|
627
|
-
`)),exitCode:1}}return{stdout:
|
|
628
|
-
`);let
|
|
629
|
-
`).
|
|
630
|
-
|
|
631
|
-
`
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
`)
|
|
635
|
-
|
|
636
|
-
`
|
|
637
|
-
|
|
615
|
+
`}function Rt(e){if(Array.isArray(e))return e.map(t=>Rt(t)).join("; ");if(e.type==="Statement"){let t=[];for(let s=0;s<e.pipelines.length;s++){let n=e.pipelines[s];t.push(Sa(n)),e.operators[s]&&t.push(e.operators[s])}return t.join(" ")}if(e.type==="SimpleCommand"){let t=e,s=[];t.name&&s.push(_i(t.name));for(let n of t.args)s.push(_i(n));return s.join(" ")}return e.type==="Group"?`{ ${e.body.map(n=>Rt(n)).join("; ")}; }`:"..."}function Sa(e){let t=e.commands.map(s=>Rt(s));return(e.negated?"! ":"")+t.join(" | ")}function _i(e){let t="";for(let s of e.parts)s.type==="Literal"?t+=s.value:s.type==="DoubleQuoted"?t+=`"${s.parts.map(n=>Ti(n)).join("")}"`:s.type==="SingleQuoted"?t+=`'${s.value}'`:t+=Ti(s);return t}function Ti(e){let t=e;return t.type==="Literal"?t.value??"":t.type==="Variable"?`$${t.name}`:""}async function Ni(e,t,s,n){let r="",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)n?r+=`${o} is an alias for "${H(l)}"
|
|
616
|
+
`:r+=`alias ${o}='${H(l)}'
|
|
617
|
+
`;else if(sn.has(o))n?r+=`${o} is a shell keyword
|
|
618
|
+
`:r+=`${o}
|
|
619
|
+
`;else if(Ge.has(o))n?r+=`${o} is a shell builtin
|
|
620
|
+
`:r+=`${o}
|
|
621
|
+
`;else if(e.state.functions.has(o))n?r+=`${o} is a function
|
|
622
|
+
`:r+=`${o}
|
|
623
|
+
`;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&&(n?r+=`${o} is ${o}
|
|
624
|
+
`:r+=`${o}
|
|
625
|
+
`,c=!0)}catch{}c||(n&&(i+=`${o}: not found
|
|
626
|
+
`),a=1)}else if(e.commands.has(o)){let c=x(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}`),n?r+=`${o} is ${f}
|
|
627
|
+
`:r+=`${f}
|
|
628
|
+
`}else n&&(i+=`${o}: not found
|
|
629
|
+
`),a=1}return W(F(r),F(i),a)}async function Oi(e,t){if(t.includes("/")){let r=e.fs.resolvePath(e.state.cwd,t);if(await e.fs.exists(r)){try{let i=await e.fs.stat(r);if(i.isDirectory||!((i.mode&73)!==0))return null}catch{return null}return t}return null}let n=x(e.state.env,"PATH","/usr/bin:/bin").split(":");for(let r of n){if(!r)continue;let a=`${r.startsWith("/")?r:e.fs.resolvePath(e.state.cwd,r)}/${t}`;if(await e.fs.exists(a)){try{if((await e.fs.stat(a)).isDirectory)continue}catch{continue}return`${r}/${t}`}}if(e.commands.has(t)){for(let r of n)if(r==="/usr/bin"||r==="/bin")return`${r}/${t}`;return`/usr/bin/${t}`}return null}async function Di(e,t,s,n,r,i,a,o){let{ctx:l,runCommand:u}=e,c=bt(s);if(l.coverage&&Ge.has(t)&&l.coverage.hit(`bash:builtin:${t}`),t==="export")return Tn(l,c);if(t==="unset")return Gn(l,c);if(t==="exit")return _n(l,c);if(t==="local")return Mn(l,c);if(t==="set")return jn(l,c);if(t==="break")return Ks(l,c);if(t==="continue")return pn(l,c);if(t==="return")return Vn(l,c);if(t==="eval"&&l.state.options.posix)return Ss(l,c,r);if(t==="shift")return Bn(l,c);if(t==="getopts")return Es(l,c);if(t==="compgen")return un(l,c);if(t==="complete")return dn(l,c);if(t==="compopt")return hn(l,c);if(t==="pushd")return await Cn(l,c);if(t==="popd")return kn(l,c);if(t==="dirs")return Pn(l,c);if(t==="source"||t===".")return Hn(l,c);if(t==="read")return await Fn(l,c,await ie(r),o);if(t==="mapfile"||t==="readarray")return await Wn(l,c,await ie(r));if(t==="declare"||t==="typeset")return En(l,c);if(t==="readonly")return $n(l,c);if(!i){let f=l.state.functions.get(t);if(f)return vs(l,f,c,r)}if(t==="eval")return Ss(l,c,r);if(t==="cd")return await Ys(l,c);if(t===":"||t==="true")return B();if(t==="false")return ae(!1);if(t==="let")return Ln(l,c);if(t==="command")return Ea(e,c,r);if(t==="builtin")return $a(e,c,r);if(t==="shopt")return Ci(l,c);if(t==="exec"){if(s.length===0)return B();let[f,...d]=s;return u(H(f),d,[],r,!1,!1,-1)}if(t==="wait")return await qn(l,c);if(t==="jobs")return await On(l,c,(f,d)=>u(f,d.map(F),d.map(()=>!1),E()));if(t==="kill")return Rn(l,c);if(t==="type")return await xi(l,c,f=>Oi(l,f),f=>Ps(l,f));if(t==="hash")return xn(l,c);if(t==="help")return Nn(l,c);if(t==="["||t==="test"){let f=c;if(t==="["){if(c[c.length-1]!=="]")return A("[: missing `]'\n",2);f=c.slice(0,-1)}return Nt(l,f)}return null}async function Ea(e,t,s){let{ctx:n,runCommand:r}=e;if(t.length===0)return B();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 B();if(o||a)return await Ni(n,l,o,a);let[u,...c]=l;return r(u,c.map(f=>F(f)),[],s,!0,i,-1)}async function $a(e,t,s){let{runCommand:n}=e;if(t.length===0)return B();let r=t;if(r[0]==="--"&&(r=r.slice(1),r.length===0))return B();let i=r[0];if(!Ge.has(i))return A(`bash: builtin: ${i}: not a shell builtin
|
|
630
|
+
`);let[,...a]=r;return n(i,a.map(o=>F(o)),[],s,!0,!1,-1)}async function Ii(e,t,s,n,r){let{buildExportedEnv:i,ctx:a,executeUserScript:o}=e,u=await ki(a,t,r?"/usr/bin:/bin":void 0);if(!u)return Wr(t)?A(`bash: ${t}: command not available in browser environments. Exclude '${t}' from your commands or use the Node.js bundle.
|
|
631
|
+
`,127):A(`bash: ${t}: command not found
|
|
632
|
+
`,127);if("error"in u)return u.error==="permission_denied"?A(`bash: ${t}: Permission denied
|
|
633
|
+
`,126):A(`bash: ${t}: No such file or directory
|
|
634
|
+
`,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,n);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=n.getReader(),m=await p.read();p.releaseLock(),m.done||!m.value||m.value.length===0?a.state.groupStdin?d=a.state.groupStdin:d=E():d=it(he(m.value),n);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(S){if(S instanceof oe)throw S;return A(`${t}: ${Oe(S)}
|
|
635
|
+
`)}}async function _s(e,t){let s=e.state.inCondition;e.state.inCondition=!0;let n=0;try{for(let r of t){let i=await e.executeStatement(r);await Y(e,i),n=i.exitCode}}catch(r){throw await ee(e,r),r}finally{e.state.inCondition=s}return{stdout:E(),stderr:E(),exitCode:n}}function Lt(e,t){return e instanceof Ae?e.levels>1&&t>1?(e.levels--,{action:"rethrow",error:e}):{action:"break"}:e instanceof Ce?e.levels>1&&t>1?(e.levels--,{action:"rethrow",error:e}):{action:"continue"}:e instanceof we||e instanceof ke||e instanceof q||e instanceof oe?{action:"rethrow",error:e}:{action:"error",exitCode:1,error:e}}async function Ts(e,t){let s=0;try{for(let n of t){let r=await e.executeStatement(n);await Y(e,r),s=r.exitCode}}catch(n){let r=await ee(e,n);if(qt(n)||n instanceof ke||n instanceof q||n instanceof oe||n instanceof Be)throw n;if(!r){let i=Oe(n);await Y(e,A(i.endsWith(`
|
|
636
|
+
`)?i:`${i}
|
|
637
|
+
`))}return{stdout:E(),stderr:E(),exitCode:1}}return{stdout:E(),stderr:E(),exitCode:s}}var Aa="+ ";async function Ri(e){let t=e.state.env.get("PS4"),s=e.substitutionDepth??0;if(t===void 0)return`${"+".repeat(s+1)} `;let n=H(t);if(n==="")return"";try{let i=new Z().parseWordFromString(n,!1,!1),a=await z(e,i);return s>0&&a.length>0?`${a[0].repeat(s)}${a}`:a}catch{await U(e,2,`bash: ${n}: bad substitution
|
|
638
|
+
`);let r=n||Aa;return s>0&&r.length>0?`${r[0].repeat(s)}${r}`:r}}function Ca(e){return e.map(t=>ka(t)).join(" ")}function ka(e){if(e==="")return"''";if(!/[\s'"\\$`!*?[\]{}|&;<>()~#\n\t]/.test(e))return e;let s=/[\x00-\x1f\x7f]/.test(e),n=e.includes(`
|
|
639
|
+
`),r=e.includes(" "),i=e.includes("\\"),a=e.includes("'");if(s||n||r||i){let l="";for(let u of e){let c=u.charCodeAt(0);u===`
|
|
640
|
+
`?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 xs(e,t,s){if(!e.state.options.xtrace)return"";let n=await Ri(e),r=[t,...s],i=Ca(r);return`${n}${i}
|
|
641
|
+
`}async function Li(e,t,s){return e.state.options.xtrace?`${await Ri(e)}${t}=${s}
|
|
642
|
+
`:""}function Mt(e){let t=Oe(e);return t.endsWith(`
|
|
643
|
+
`)?t:`${t}
|
|
644
|
+
`}async function yt(e,t,s){let n=await Ne(e,e.outputChannels,t);return n.error?K(e,n.channels,()=>Y(e,n.error)):K(e,n.channels,async()=>{try{let r=await s(n.legacyRedirections);return{stdout:E(),stderr:E(),exitCode:r}}catch(r){let i=await ee(e,r);if(r instanceof Error&&"code"in r&&r.code==="ENOSPC")return i?{stdout:E(),stderr:E(),exitCode:1}:await Y(e,A(Mt(r)));throw r}})}async function Mi(e,t){return yt(e,t.redirections,async()=>{for(let s of t.clauses)if((await _s(e,s.condition)).exitCode===0)return(await Ts(e,s.body)).exitCode;return t.elseBody?(await Ts(e,t.elseBody)).exitCode:0})}async function Wi(e,t){return yt(e,t.redirections,async()=>{let s=0,n=0;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t.variable))return await Y(e,A(`bash: \`${t.variable}': not a valid identifier
|
|
645
|
+
`)),1;let r=[];if(t.words===null)r=x(e.state.env,"@","").split(" ").filter(Boolean);else if(t.words.length>0)try{for(let i of t.words){let a=await Ve(e,i);r.push(...a.values)}}catch(i){if(i instanceof Gt)return await ee(e,i),1;throw i}e.state.loopDepth++;try{for(let i of r){if(n++,e.signal?.aborted)throw new me(e.signal.reason);n>e.limits.maxLoopIterations&&Re(`for loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations"),y(e.state.env,t.variable,i),e.state.options.xtrace&&await U(e,2,await xs(e,"for",[t.variable,"in",...r]));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 ee(e,a),l=Lt(a,e.state.loopDepth);if(l.action==="break")break;if(l.action==="continue")continue;if(l.action==="error")return o||await Y(e,A(Mt(l.error))),l.exitCode??1;throw l.error}}}finally{e.state.loopDepth--}return s})}async function Fi(e,t){return yt(e,t.redirections,async()=>{let s=t.line;s!==void 0&&(e.state.currentLine=s);let n=0,r=0;t.init&&await Q(e,t.init.expression),e.state.loopDepth++;try{for(;;){if(r++,e.signal?.aborted)throw new me(e.signal.reason);if(r>e.limits.maxLoopIterations&&Re(`for loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations"),t.condition&&(s!==void 0&&(e.state.currentLine=s),await Q(e,t.condition.expression)===0))break;try{for(let i of t.body){let a=await e.executeStatement(i);await Y(e,a),n=a.exitCode}}catch(i){let a=await ee(e,i),o=Lt(i,e.state.loopDepth);if(o.action==="break")break;if(o.action==="continue"){t.update&&await Q(e,t.update.expression);continue}if(o.action==="error")return a||await Y(e,A(Mt(o.error))),o.exitCode??1;throw o.error}t.update&&await Q(e,t.update.expression)}}finally{e.state.loopDepth--}return n})}async function Vi(e,t,s=E()){return yt(e,t.redirections,async n=>{let r=0,i=0,a=s,o=!1;for(let u of n)if((u.operator==="<<"||u.operator==="<<-")&&u.target.type==="HereDoc"){let c=u.target,f=await z(e,c.content);c.stripTabs&&(f=f.split(`
|
|
646
|
+
`).map(d=>d.replace(/^\t+/,"")).join(`
|
|
647
|
+
`)),a=V(f),o=!0}else if(u.operator==="<<<"&&u.target.type==="Word")a=V(`${await z(e,u.target)}
|
|
648
|
+
`),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,A(`bash: ${c}: No such file or directory
|
|
649
|
+
`)),1}}let l=e.state.groupStdin;if(o)e.state.groupStdin=a;else{let u=await ie(s);u.length>0&&(e.state.groupStdin=he(u))}e.state.loopDepth++;try{for(;;){if(i++,e.signal?.aborted)throw new me(e.signal.reason);i>e.limits.maxLoopIterations&&Re(`while loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations");let u=0,c=!1,f=!1;try{u=(await _s(e,t.condition)).exitCode}catch(d){if(await ee(e,d),d instanceof Ae){if(d.levels>1&&e.state.loopDepth>1)throw d.levels--,d;c=!0}else if(d instanceof Ce){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),r=p.exitCode}}catch(d){let p=await ee(e,d),m=Lt(d,e.state.loopDepth);if(m.action==="break")break;if(m.action==="continue")continue;if(m.action==="error")return p||await Y(e,A(Mt(m.error))),m.exitCode??1;throw m.error}}}}finally{e.state.loopDepth--,e.state.groupStdin=l}return r})}async function zi(e,t){return yt(e,t.redirections,async()=>{let s=0,n=0;e.state.loopDepth++;try{for(;;){if(n++,e.signal?.aborted)throw new me(e.signal.reason);if(n>e.limits.maxLoopIterations&&Re(`until loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations"),(await _s(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 ee(e,i),o=Lt(i,e.state.loopDepth);if(o.action==="break")break;if(o.action==="continue")continue;if(o.action==="error")return a||await Y(e,A(Mt(o.error))),o.exitCode??1;throw o.error}}}finally{e.state.loopDepth--}return s})}async function ji(e,t){return yt(e,t.redirections,async()=>{let s=0,n=await z(e,t.word),r=!1;for(let i=0;i<t.items.length;i++){let a=t.items[i],o=r;if(!r)for(let l of a.patterns){let u=await z(e,l);yr(l)&&(u=mr(u));let c=e.state.shoptOptions.nocasematch,f=e.state.shoptOptions.extglob;if(dt(n,u,c,f)){o=!0;break}}if(o){if(s=(await Ts(e,a.body)).exitCode,a.terminator===";;")break;a.terminator===";&"?r=!0:r=!1}else r=!1}return s})}async function Pa(e,t,s){let n=_e(),r=s?_e():void 0,i=et(e.outputChannels);Ms(i,1,n),r&&Ms(i,2,r);try{let a=await K(e,i,t);return{...a,stdout:it(a.stdout,n.stream()),stderr:r?it(a.stderr,r.stream()):a.stderr}}catch(a){await K(e,i,()=>ee(e,a));let o=n.stream(),l=r?.stream()??E();if(a instanceof $t)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 Bi(e,t,s){let n=t.timed?performance.now():0,r=E(),i=B(),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=F(""),h||(e.state.groupStdin=void 0));let S=l&&(!m||!e.state.shoptOptions.lastpipe),$=S?new Map(e.state.env):null,g;try{if(m){let v=()=>s(p,r);g=S?await K(e,et(e.outputChannels),v):await v()}else g=await Pa(e,()=>s(p,r),b)}catch(v){if(await ee(e,v),v instanceof $t)g={stdout:E(),stderr:E(),exitCode:1};else if(v instanceof q&&t.commands.length>1)g={stdout:E(),stderr:E(),exitCode:v.exitCode};else if(v instanceof ke&&t.commands.length>1)g={stdout:E(),stderr:E(),exitCode:v.exitCode};else throw $&&(e.state.env=$),v}if($&&(e.state.env=$),e.signal?.aborted===!0&&g.exitCode===new me(e.signal.reason).exitCode)throw await Y(e,g,!1),new me(e.signal.reason);if(o.push(g.exitCode),g.exitCode!==0&&(a=g.exitCode),m)i=g;else if(b)r=it(g.stderr,g.stdout),i={stdout:E(),stderr:E(),exitCode:g.exitCode};else{let v=g.stdout;await Y(e,g,!0,[2]),r=v,i={stdout:E(),stderr:E(),exitCode:g.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++)y(e.state.env,`PIPESTATUS_${d}`,String(o[d]));y(e.state.env,"PIPESTATUS__length",String(o.length))}if(t.timed){let p=(performance.now()-n)/1e3,m=Math.floor(p/60),h=p%60,b;t.timePosix?b=`real ${p.toFixed(2)}
|
|
638
650
|
user 0.00
|
|
639
651
|
sys 0.00
|
|
640
|
-
`:
|
|
641
|
-
real ${`${
|
|
652
|
+
`:b=`
|
|
653
|
+
real ${`${m}m${h.toFixed(3)}s`}
|
|
642
654
|
user 0m0.000s
|
|
643
655
|
sys 0m0.000s
|
|
644
|
-
`,
|
|
645
|
-
`)};let u=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(u){let f=await
|
|
646
|
-
`)};if(
|
|
647
|
-
`)}}if(
|
|
648
|
-
`,{continueToNext:!0,xtraceOutput:
|
|
649
|
-
`)}}async function
|
|
650
|
-
`)};
|
|
651
|
-
`;if(i.fatal)throw
|
|
652
|
-
`)}}if(
|
|
653
|
-
`)}}}return{index:
|
|
654
|
-
`)};if(
|
|
655
|
-
`,{continueToNext:!0,xtraceOutput:
|
|
656
|
-
`)),1)
|
|
657
|
-
`).map(
|
|
658
|
-
`));let
|
|
659
|
-
`),
|
|
660
|
-
`)}
|
|
661
|
-
`)),1)}e.state.groupStdin=
|
|
662
|
-
`,127)}if(i.startsWith("#!")){let
|
|
663
|
-
`);
|
|
664
|
-
`);throw
|
|
665
|
-
`)
|
|
666
|
-
`).map(
|
|
667
|
-
`)),
|
|
668
|
-
`)
|
|
669
|
-
`)
|
|
670
|
-
|
|
671
|
-
`)}
|
|
672
|
-
`)
|
|
673
|
-
`,
|
|
674
|
-
|
|
675
|
-
This is a defense-in-depth measure and indicates a bug in just-bash. Please report this at security@vercel.com`,de=class extends Error{violation;constructor(t,s){super(t+Jo),this.violation=s,this.name="SecurityViolationError"}},we=!$t&&gr?new gr:null,ea=1e3,yr={enabled:!0,auditMode:!1};function ta(e){return e===void 0?{...yr,enabled:!1}:typeof e=="boolean"?{...yr,enabled:e}:{...yr,...e}}var os=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(ta(t))),e.instance}static resetInstance(){e.instance&&(e.instance.forceDeactivate(),e.instance=null)}static isInSandboxedContext(){return we?we?.getStore()?.sandboxActive===!0:!1}static getCurrentExecutionId(){if(we)return we?.getStore()?.executionId}updateConfig(t){this.config={...this.config,...t}}activate(){if($t||!this.config.enabled){let s=pi();return{run:r=>r(),deactivate:()=>{},executionId:s}}this.refCount++,this.refCount===1&&(this.applyPatches(),this.activationTime=Date.now());let t=pi();return{run:s=>we.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 $t||this.config.auditMode||!we?!1:we?.getStore()?.sandboxActive===!0}recordViolation(t,s,r){let n={timestamp:Date.now(),type:t,message:r,path:s,stack:new Error().stack,executionId:we?.getStore()?.executionId};if(this.violations.length<ea&&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 de(l,u)}return n.config.auditMode&&we?.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 de(l,u)}return n.config.auditMode&&we?.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 de(u,c)}if(n.config.auditMode&&we?.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 de(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 de(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 de(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 de(l,u)}return Reflect.has(i,o)}})}applyPatches(){let t=hi();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 de(i,o)}t.config.auditMode&&we?.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 de(a,l)}return n.config.auditMode&&we?.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 de(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 de(n,i)}return t.config.auditMode&&we?.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 de(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(!$t)try{let t=null;if(typeof process<"u"){let o=process.mainModule;o&&typeof o=="object"&&(t=o.constructor)}if(!t&&typeof At<"u"&&typeof At.main<"u"&&(t=At.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 as=class{fs;commands=new Map;useDefaultLayout=!1;limits;secureFetch;sleepFn;traceFn;logger;defenseInDepthConfig;coverageWriter;state;constructor(t={}){let s=t.fs??new ft(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",`
|
|
676
|
-
`
|
|
656
|
+
`,await U(e,2,b)}return l&&!e.state.shoptOptions.lastpipe&&(e.state.lastArg=u),i}async function Hi(e,t){let s=new Map,n="";for(let r of t.assignments){let i=r.name;if(r.array){let f=await _a(e,t,i,r.array,r.append,s);if(f.error)return{continueToNext:!1,xtraceOutput:n,tempAssignments:s,error:f.error};if(n+=f.xtraceOutput,f.continueToNext)continue}let a=r.value?await ot(e,r.value):L,o=r.value?H(a):"";if(o.length>e.limits.maxStringLength&&Re(`word expansion: string length limit exceeded (${e.limits.maxStringLength} bytes)`,"iterations"),i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[\]$/))return{continueToNext:!1,xtraceOutput:n,tempAssignments:s,error:A(`bash: ${i}: bad array subscript
|
|
657
|
+
`)};let u=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(u){let f=await Da(e,t,u[1],u[2],o,r.append,s);if(f.error)return{continueToNext:!1,xtraceOutput:n,tempAssignments:s,error:f.error};if(f.continueToNext)continue}let c=await Ra(e,t,i,o,r.append,s,a);if(c.error)return{continueToNext:!1,xtraceOutput:n,tempAssignments:s,error:c.error};n+=c.xtraceOutput,c.continueToNext}return{continueToNext:!1,xtraceOutput:n,tempAssignments:s}}async function _a(e,t,s,n,r,i){let a="";if(/\[.+\]$/.test(s))return{continueToNext:!1,xtraceOutput:"",error:A(`bash: ${s}: cannot assign list to array member
|
|
658
|
+
`)};if(be(e,s)){let c=hr(e,s);if(c===void 0||c==="")throw new q(1);let f=Fe(e,s);if(f&&/^[a-zA-Z_][a-zA-Z0-9_]*\[@\]$/.test(f))return{continueToNext:!1,xtraceOutput:"",error:A(`bash: ${s}: cannot assign list to array member
|
|
659
|
+
`)}}if(tt(e,s)){if(t.name)return a+=`bash: ${s}: readonly variable
|
|
660
|
+
`,{continueToNext:!0,xtraceOutput:a};let c=await ue(e,s);if(c)return{continueToNext:!1,xtraceOutput:"",error:c}}let o=e.state.associativeArrays?.has(s),l=Ta(n),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 xa(e,t,s,n,r,u,c=>{a+=c}):l?await Na(e,s,n,r,u):await Oa(e,s,n,r,u),t.name){i.set(s,e.state.env.get(s));let f=`(${n.map(d=>Kt(d)).join(" ")})`;y(e.state.env,s,f)}return{continueToNext:!0,xtraceOutput:a}}function Ta(e){return e.some(t=>{if(t.parts.length>=2){let s=t.parts[0],n=t.parts[1];if(s.type!=="Glob"||!s.pattern.startsWith("["))return!1;if(s.pattern==="["&&(n.type==="DoubleQuoted"||n.type==="SingleQuoted")){if(t.parts.length<3)return!1;let r=t.parts[2];return r.type!=="Literal"?!1:r.value.startsWith("]=")||r.value.startsWith("]+=")}return n.type!=="Literal"?!1:n.value.startsWith("]")?n.value.startsWith("]=")||n.value.startsWith("]+="):s.pattern.endsWith("]")?n.value.startsWith("=")||n.value.startsWith("+="):!1}return!1})}async function xa(e,t,s,n,r,i,a){let o=[];for(let l of n){let u=Fs(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=se(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})}}r||i();for(let l of o)if(l.type==="keyed")if(l.append){let u=x(e.state.env,`${s}_${l.key}`,"");y(e.state.env,`${s}_${l.key}`,u+l.value)}else y(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
|
|
661
|
+
`)}}async function Na(e,t,s,n,r){let i=[];for(let o of s){let l=Fs(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=se(e,d),i.push({type:"keyed",indexExpr:u,value:d,append:f})}else{let u=await Ve(e,o);i.push({type:"non-keyed",values:u.values})}}n||r();let a=0;for(let o of i)if(o.type==="keyed"){let l;try{let u=new Z,c=le(u,o.indexExpr);l=await Q(e,c.expression,!1)}catch{if(/^-?\d+$/.test(o.indexExpr))l=Number.parseInt(o.indexExpr,10);else{let u=x(e.state.env,o.indexExpr);l=u?Number.parseInt(u,10):0,Number.isNaN(l)&&(l=0)}}if(o.append){let u=x(e.state.env,`${t}_${l}`,"");y(e.state.env,`${t}_${l}`,u+o.value)}else y(e.state.env,`${t}_${l}`,o.value);a=l+1}else for(let l of o.values)y(e.state.env,`${t}_${a++}`,l)}async function Oa(e,t,s,n,r){let i=[];for(let o of s){let l=await Ve(e,o);i.push(...l.values)}let a=0;if(n){let o=De(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 r();for(let o=0;o<i.length;o++)y(e.state.env,`${t}_${a+o}`,i[o]);n||y(e.state.env,`${t}__length`,String(i.length))}async function Da(e,t,s,n,r,i,a){let o=s;if(be(e,s)){let f=Fe(e,s);if(f&&f!==s){if(f.includes("["))return{continueToNext:!1,xtraceOutput:"",error:A(`bash: \`${f}': not a valid identifier
|
|
662
|
+
`)};o=f}}if(tt(e,o)){if(t.name)return{continueToNext:!0,xtraceOutput:""};let f=await ue(e,o);if(f)return{continueToNext:!1,xtraceOutput:"",error:f}}let l=e.state.associativeArrays?.has(o),u;if(l)u=await Ui(e,o,n);else{let f=await Ia(e,o,n);if(f.error)return{continueToNext:!1,xtraceOutput:"",error:f.error};u=`${o}_${f.index}`}let c=i?x(e.state.env,u)+r:r;if(t.name)a.set(u,e.state.env.get(u)),y(e.state.env,u,c);else{let f=ht(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))}y(e.state.env,u,c)}return{continueToNext:!0,xtraceOutput:""}}async function Ui(e,t,s){let n;if(s.startsWith("'")&&s.endsWith("'"))n=s.slice(1,-1);else if(s.startsWith('"')&&s.endsWith('"')){let r=s.slice(1,-1),a=new Z().parseWordFromString(r,!0,!1);n=await z(e,a)}else if(s.includes("$")){let i=new Z().parseWordFromString(s,!1,!1);n=await z(e,i)}else n=s;return`${t}_${n}`}async function Ia(e,t,s){let n=s;s.startsWith('"')&&s.endsWith('"')&&s.length>=2&&(n=s.slice(1,-1));let r;if(/^-?\d+$/.test(n))r=Number.parseInt(n,10);else{try{let i=new Z,a=le(i,n);r=await Q(e,a.expression,!1)}catch(i){if(i instanceof Xe){let l=`bash: line ${e.state.currentLine}: ${s}: ${i.message}
|
|
663
|
+
`;if(i.fatal)throw await U(e,2,l,!0),new q(1);return{index:0,error:A(l)}}let a=x(e.state.env,s);r=a?Number.parseInt(a,10):0}Number.isNaN(r)&&(r=0)}if(r<0){let i=De(e,t);if(i.length===0){let o=e.state.currentLine;return{index:0,error:A(`bash: line ${o}: ${t}[${s}]: bad array subscript
|
|
664
|
+
`)}}if(r=Math.max(...i.map(([o])=>typeof o=="number"?o:0))+1+r,r<0){let o=e.state.currentLine;return{index:0,error:A(`bash: line ${o}: ${t}[${s}]: bad array subscript
|
|
665
|
+
`)}}}return{index:r}}async function Ra(e,t,s,n,r,i,a){let o="",l=s,u=null;if(be(e,s)){let h=pr(e,s,n);if(h===void 0)return{continueToNext:!1,xtraceOutput:"",error:A(`bash: ${s}: circular name reference
|
|
666
|
+
`)};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(tt(e,l)){if(t.name)return o+=`bash: ${l}: readonly variable
|
|
667
|
+
`,{continueToNext:!0,xtraceOutput:o};let h=await ue(e,l);if(h)return{continueToNext:!1,xtraceOutput:"",error:h}}let c,f=!!a&&!r&&!u;if(Dt(e,l)){f=!1;try{let h=new Z;if(r){let S=`(${x(e.state.env,l,"0")}) + (${n})`,$=le(h,S);c=String(await Q(e,$.expression))}else{let b=le(h,n);c=String(await Q(e,b.expression))}}catch{c="0"}}else{let{isArray:h}=await import("./chunks/expansion-IB7ZIBIF.js"),b=h(e,l);b&&(f=!1);let S=b?`${l}_0`:l;c=r?x(e.state.env,S)+n:n}let d=gt(e,l,c);d!==c&&(f=!1),c=d,o+=await Li(e,l,c);let p=l;if(u)p=await La(e,u);else{let{isArray:h}=await import("./chunks/expansion-IB7ZIBIF.js");h(e,l)&&(p=`${l}_0`,f=!1)}let m=f?()=>e.state.env.set(p,a):()=>y(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 La(e,t){let{arrayName:s,subscriptExpr:n}=t;if(e.state.associativeArrays?.has(s))return Ui(e,s,n);let i;if(/^-?\d+$/.test(n))i=Number.parseInt(n,10);else{try{let a=new Z,o=le(a,n);i=await Q(e,o.expression,!1)}catch{let a=x(e.state.env,n);i=a?Number.parseInt(a,10):0}Number.isNaN(i)&&(i=0)}if(i<0){let a=De(e,s);a.length>0&&(i=Math.max(...a.map(l=>l[0]))+1+i)}return`${s}_${i}`}async function Gi(e,t,s,n){let r=et(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 S=e.state.lastArg,$=e.state.bashPid;e.state.bashPid=e.state.nextVirtualPid++;let g=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=g,e.state.bashPid=$,e.state.lastArg=S};try{let C=t.redirections.length===0?{channels:r,legacyRedirections:[]}:await Ne(e,r,t.redirections);return C.error?await K(e,C.channels,()=>te(e,()=>Promise.resolve(C.error))):await K(e,C.channels,async()=>{let N=I=>W(E(),E(),I);try{let I=await ie(s);I.length>0&&(e.state.groupStdin=he(I));let P=0;for(let k of t.body){let O=await n(k);P=(await te(e,()=>Promise.resolve(O))).exitCode}return await N(P)}catch(I){let{diagnosticWritten:P,writeFailure:k}=await Ze(e,I);if(k)return k;if(I instanceof oe)throw I;return I instanceof Be||I instanceof Ae||I instanceof Ce?await N(0):I instanceof q||I instanceof we||I instanceof ke||I instanceof ve?await N(I.exitCode):(P||await te(e,()=>Promise.resolve(A(`${Oe(I)}
|
|
668
|
+
`))),await N(1))}})}catch(C){throw await K(e,r,()=>ee(e,C)),C}finally{v()}}async function qi(e,t,s,n){let r=t.redirections.length===0?{channels:e.outputChannels,legacyRedirections:[]}:await Ne(e,e.outputChannels,t.redirections);return r.error?K(e,r.channels,()=>te(e,()=>Promise.resolve(r.error))):K(e,r.channels,async()=>{let i=e.state.groupStdin;try{let a=await pt(e,r.legacyRedirections);if(a)return await te(e,()=>Promise.resolve(a));let o=await ie(s),l=he(o),u=!1;for(let f of r.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(`
|
|
669
|
+
`).map(h=>h.replace(/^\t+/,"")).join(`
|
|
670
|
+
`));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)}
|
|
671
|
+
`),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 te(e,()=>Promise.resolve(A(`bash: ${d}: No such file or directory
|
|
672
|
+
`)))}}}(u||o.length>0)&&(e.state.groupStdin=l);let c=0;for(let f of t.body){let d=await n(f);c=(await te(e,()=>Promise.resolve(d))).exitCode}return W(E(),E(),c)}catch(a){let{diagnosticWritten:o,writeFailure:l}=await Ze(e,a);if(l)return l;if(qt(a)||a instanceof ke||a instanceof q||a instanceof ve||a instanceof Be||a instanceof oe)throw a;return o||await te(e,()=>Promise.resolve(A(`${Oe(a)}
|
|
673
|
+
`))),W(E(),E(),1)}finally{e.state.groupStdin=i}})}async function Zi(e,t,s,n,r){let i;try{i=await e.fs.readFileText(t)}catch{return A(`bash: ${t}: No such file or directory
|
|
674
|
+
`,127)}if(i.startsWith("#!")){let b=i.indexOf(`
|
|
675
|
+
`);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 ie(n);b.length>0&&(e.state.groupStdin=he(b)),e.state.currentSource=t,y(e.state.env,"0",t),y(e.state.env,"#",String(s.length)),y(e.state.env,"@",s.join(" ")),y(e.state.env,"*",s.join(" "));for(let v=0;v<s.length&&v<9;v++)y(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 Z().parse(i),g=await r($);return await te(e,()=>Promise.resolve(g))}catch(b){let{writeFailure:S}=await Ze(e,b);if(S)return S;if(b instanceof q||b instanceof oe)throw b;if(b.name==="ParseException")return A(`bash: ${t}: ${b.message}
|
|
676
|
+
`);throw b}finally{h()}}function Ma(e,t){for(let s of t.parts)switch(s.type){case"Bytes":case"Literal":case"SingleQuoted":case"Escaped":continue;case"DoubleQuoted":for(let n of s.parts)switch(n.type){case"Bytes":case"Literal":case"SingleQuoted":case"Escaped":continue;case"ParameterExpansion":if(n.operation||n.parameter==="@"||n.parameter==="*"||n.parameter.endsWith("[@]")||n.parameter.endsWith("[*]"))return!1;if(be(e,n.parameter)){let r=Fe(e,n.parameter);if(r&&(r.endsWith("[@]")||r.endsWith("[*]")))return!1}continue;case"CommandSubstitution":continue;default:return!1}continue;case"ParameterExpansion":return!1;default:return!1}return t.parts.length>0}var Wt=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,n=new Set;if(t)for(let i of t)n.add(i);if(s)for(let i of s)n.add(i);if(n.size===0)return Object.create(null);let r=Object.create(null);for(let i of n)this.ctx.state.env.has(i)&&(r[i]=x(this.ctx.state.env,i));return r}async executeRootScript(t){let s=await this.executeScript(t);return Qe(this.ctx.signal),Y(this.ctx,s)}async executeScript(t){let s=0;for(let n of t.statements)try{let r=await this.executeStatement(n),i=this.ctx.signal?.aborted===!0&&r.exitCode===new me(this.ctx.signal.reason).exitCode;await Y(this.ctx,r,!i),s=r.exitCode,this.ctx.state.lastExitCode=s,y(this.ctx.state.env,"?",String(s))}catch(r){if(await ee(this.ctx,r),r instanceof q)throw r;if(r instanceof ve)return s=r.exitCode,this.ctx.state.lastExitCode=s,y(this.ctx.state.env,"?",String(s)),{stdout:E(),stderr:E(),exitCode:s,env:qe(this.ctx.state.env)};if(r instanceof oe)throw r;if(r instanceof ke)return s=r.exitCode,this.ctx.state.lastExitCode=s,y(this.ctx.state.env,"?",String(s)),{stdout:E(),stderr:E(),exitCode:s,env:qe(this.ctx.state.env)};if(r instanceof sr)return s=1,this.ctx.state.lastExitCode=s,y(this.ctx.state.env,"?",String(s)),{stdout:E(),stderr:E(),exitCode:s,env:qe(this.ctx.state.env)};if(r instanceof $t)return s=1,this.ctx.state.lastExitCode=s,y(this.ctx.state.env,"?",String(s)),{stdout:E(),stderr:E(),exitCode:s,env:qe(this.ctx.state.env)};if(r instanceof Xe){s=1,this.ctx.state.lastExitCode=s,y(this.ctx.state.env,"?",String(s));continue}if(r instanceof nr){s=1,this.ctx.state.lastExitCode=s,y(this.ctx.state.env,"?",String(s));continue}if(r instanceof Ae||r instanceof Ce){if(this.ctx.state.loopDepth>0)throw r;continue}throw r instanceof we,r}return{stdout:E(),stderr:E(),exitCode:s,env:qe(this.ctx.state.env)}}async executeUserScript(t,s,n=E()){return Zi(this.ctx,t,bt(s),n,r=>this.executeScript(r))}async executeStatement(t){if(Qe(this.ctx.signal),this.ctx.state.commandCount++,this.ctx.state.commandCount>this.ctx.limits.maxCommandCount&&Re(`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)),Qe(this.ctx.signal)),t.deferredError)throw new Zt(t.deferredError.message,t.line??1,1);if(this.ctx.state.options.noexec)return B();if(this.ctx.state.errexitSafe=!1,this.ctx.state.options.verbose&&!this.ctx.state.suppressVerbose&&t.sourceText&&await U(this.ctx,2,`${t.sourceText}
|
|
677
|
+
`),t.background){if(this.ctx.processes.runningCount>=this.ctx.limits.maxConcurrentJobs)return this.ctx.jobTracker.limitExceeded=!0,await U(this.ctx,2,`bash: maximum concurrent jobs (${this.ctx.limits.maxConcurrentJobs}) exceeded
|
|
678
|
+
`),A("",oe.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=>et(c,(h,b)=>u.observesOutput?_e({write(S){return u.observeOutput(m,h,S),b.write(S)}},!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 S=Ct(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:(g,v)=>this.ctx.execFn(g,{...v,signal:Ct(S,v?.signal)}),fetch:this.ctx.fetch,sleep:this.ctx.sleep,trace:this.ctx.trace,coverage:this.ctx.coverage,signal:S},l);try{return(await $.executeRootScript({type:"Script",statements:[{...t,background:!1,sourceText:void 0}]})).exitCode}catch(g){if(g instanceof me||g instanceof q)return g.exitCode;if(g instanceof oe)return this.ctx.jobTracker.limitExceeded=!0,oe.EXIT_CODE;throw g}},this.ctx.lineageId),this.ctx.jobTracker.started=!0}catch(m){return await U(this.ctx,2,`bash: ${m instanceof Error?m.message:String(m)}
|
|
679
|
+
`),A("",1)}return this.ctx.state.lastBackgroundPid=p,B()}let s=0,n=-1,r=!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,n=o,r=l.negated,this.ctx.state.lastExitCode=s,y(this.ctx.state.env,"?",String(s))}let i=n<t.pipelines.length-1,a=this.ctx.state.errexitSafe;if(this.ctx.state.errexitSafe=i||r||a,this.ctx.state.options.errexit&&s!==0&&n===t.pipelines.length-1&&!r&&!this.ctx.state.inCondition&&!a)throw new ke(s);return{stdout:E(),stderr:E(),exitCode:s}}async executePipeline(t){return Bi(this.ctx,t,(s,n)=>this.executeCommand(s,n))}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 Mi(this.ctx,t);case"For":return Wi(this.ctx,t);case"CStyleFor":return Fi(this.ctx,t);case"While":return Vi(this.ctx,t,s);case"Until":return zi(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 si(this.ctx,t);case"ArithmeticCommand":return this.executeArithmeticCommand(t);case"ConditionalCommand":return this.executeConditionalCommand(t);default:return B()}}async executeSimpleCommand(t,s){this.ctx.reportedDiagnostics=new WeakSet;try{return await this.executeSimpleCommandInner(t,s)}catch(n){if(n instanceof Gt)return await ee(this.ctx,n),{stdout:E(),stderr:E(),exitCode:1};throw n}}async executeSimpleCommandInner(t,s){if(t.line!==void 0&&(this.ctx.state.currentLine=t.line),this.ctx.state.shoptOptions.expand_aliases&&t.name){let P=t,k=100;for(;k>0;){let O=this.expandAlias(P);if(O===P)break;P=O,k--}this.aliasExpansionStack.clear(),P!==t&&(t=P)}let n=await Hi(this.ctx,t);if(n.error)return n.error;let r=n.tempAssignments,i=n.xtraceOutput;if(!t.name){if(await U(this.ctx,2,i),t.redirections.length>0){let P=this.ctx.outputChannels,k=await Ne(this.ctx,P,t.redirections);if(k.error)return await K(this.ctx,k.channels,()=>te(this.ctx,()=>Promise.resolve(k.error)));let O={stdout:E(),stderr:E(),exitCode:0},R=[1,2].filter(_=>{let T=P.bindings.get(_),w=k.channels.bindings.get(_);return T?.sink!==w?.sink||Me(P,_)!==Me(k.channels,_)});return await K(this.ctx,k.channels,()=>te(this.ctx,()=>Promise.resolve(O),R))}return this.ctx.state.lastArg=F(""),{stdout:E(),stderr:E(),exitCode:this.ctx.state.lastExitCode}}let a=t.name&&Ot(t.name,["local","declare","typeset","export","readonly"]),o=Array.from(r.keys());if(o.length>0&&!a){this.ctx.state.tempExportedVars=this.ctx.state.tempExportedVars||new Set;for(let P of o)this.ctx.state.tempExportedVars.add(P)}let l=-1,u=Ot(t.name,["exec"])&&(t.args.length===0||t.args.length===1&&Ot(t.args[0],["--"])),c=await z(this.ctx,t.name),f=[],d=[];if(Ot(t.name,["local","declare","typeset","export","readonly"])&&(c==="local"||c==="declare"||c==="typeset"||c==="export"||c==="readonly"))for(let P of t.args){let k=await Lr(this.ctx,P);if(k)f.push(F(k)),d.push(!0);else{let O=await Mr(this.ctx,P);if(O!==null)f.push(F(O)),d.push(!0);else{let R=await Ve(this.ctx,P);for(let _ of R.values)f.push(F(_)),d.push(R.quoted)}}}else for(let P of t.args)if(Ma(this.ctx,P))f.push(await ot(this.ctx,P)),d.push(!0);else{let k=await Ve(this.ctx,P);for(let O of k.values)f.push(F(O)),d.push(k.quoted)}let m=this.ctx.outputChannels,h=!u&&t.redirections.length>0?await Ne(this.ctx,m,t.redirections,{persistMovedSource:Ge.has(c)}):void 0;if(h?.error){await U(this.ctx,2,i);for(let[P,k]of r)k===void 0?this.ctx.state.env.delete(P):this.ctx.state.env.set(P,k);return await K(this.ctx,h.channels,()=>te(this.ctx,()=>Promise.resolve(h.error)))}let b=t.redirections.some(P=>{if(u&&(P.operator==="<"||P.operator==="<&")||P.fdVariable)return!1;if(P.operator==="<<"||P.operator==="<<-"||P.operator==="<<<")return!0;let k=P.fd??0;return(P.operator==="<"||P.operator==="<&")&&k===0}),S=null,$=L;b?$=await ie(s):S=s;let g=h?.legacyRedirections??t.redirections;for(let P of g)if(!(P.fdVariable||u&&(P.operator==="<"||P.operator==="<&"))){if((P.operator==="<<"||P.operator==="<<-")&&P.target.type==="HereDoc"){let k=P.target,O=P.fd??0;if(O===0&&!k.stripTabs)$=await ot(this.ctx,k.content);else{let R=await z(this.ctx,k.content);k.stripTabs&&(R=R.split(`
|
|
680
|
+
`).map(_=>_.replace(/^\t+/,"")).join(`
|
|
681
|
+
`)),O!==0?(this.ctx.state.fileDescriptors||(this.ctx.state.fileDescriptors=new Map),this.ctx.state.fileDescriptors.set(O,R)):$=F(R)}continue}if(P.operator==="<<<"&&P.target.type==="Word"){let k=await ot(this.ctx,P.target);$=er(k,F(`
|
|
682
|
+
`));continue}if(P.operator==="<"&&P.target.type==="Word")try{let k=await z(this.ctx,P.target),O=this.ctx.fs.resolvePath(this.ctx.state.cwd,k);$=await ie(await this.ctx.fs.readFile(O))}catch{let k=await z(this.ctx,P.target);for(let[O,R]of r)R===void 0?this.ctx.state.env.delete(O):this.ctx.state.env.set(O,R);return A(`bash: ${k}: No such file or directory
|
|
683
|
+
`)}if(P.operator==="<&"&&(P.fd??0)===0&&P.target.type==="Word"){let k=await z(this.ctx,P.target),O=k.startsWith("&")?k.slice(1):k;if(O!=="-"&&!/^\d+-?$/.test(O)){for(let[_,T]of r)T===void 0?this.ctx.state.env.delete(_):this.ctx.state.env.set(_,T);return A(`bash: ${k}: ambiguous redirect
|
|
684
|
+
`)}let R=Number.parseInt(O,10);if(!Number.isNaN(R)&&Me(this.ctx.outputChannels,R)){for(let[_,T]of r)T===void 0?this.ctx.state.env.delete(_):this.ctx.state.env.set(_,T);return A(je(R))}if(!Number.isNaN(R)&&this.ctx.state.fileDescriptors){let _=this.ctx.state.fileDescriptors.get(R);if(_!==void 0)if(_.startsWith("__rw__:")){let T=ms(_);T&&($=F(T.content.slice(T.position)),l=R)}else _.startsWith("__file__:")||_.startsWith("__file_append__:")||($=F(_));else if(R>=3&&!this.ctx.outputChannels.bindings.get(R)?.sink){for(let[T,w]of r)w===void 0?this.ctx.state.env.delete(T):this.ctx.state.env.set(T,w);return A(je(R))}}else if(!Number.isNaN(R)&&R>=3&&!this.ctx.outputChannels.bindings.get(R)?.sink){for(let[_,T]of r)T===void 0?this.ctx.state.env.delete(_):this.ctx.state.env.set(_,T);return A(je(R))}}}if(!c){if(t.name.parts.every(k=>k.type==="CommandSubstitution"||k.type==="ParameterExpansion"||k.type==="ArithmeticExpansion")){if(f.length>0){let k=H(f.shift());return d.shift(),await this.runCommand(k,f,d,S??he($),!1,!1,l)}return{stdout:E(),stderr:E(),exitCode:this.ctx.state.lastExitCode}}return A(`bash: : command not found
|
|
685
|
+
`,127)}await U(this.ctx,2,i);let v=await xs(this.ctx,c,f.map(P=>H(P)));if(await U(this.ctx,2,v),c==="exec"&&(f.length===0||H(f[0])==="--")){let P=[],k=this.ctx.outputChannels;for(;k;)P.push([k,new Map(k.bindings)]),k=k.parent;let O=this.ctx.state.fileDescriptors?new Map(this.ctx.state.fileDescriptors):void 0,R=this.ctx.state.nextFd,_=new Map;for(let w of t.redirections)w.fdVariable&&!_.has(w.fdVariable)&&_.set(w.fdVariable,this.ctx.state.env.get(w.fdVariable));let T=await ti(this.ctx,t.redirections);if(T.error){let w;try{w=await K(this.ctx,T.channels,()=>te(this.ctx,()=>Promise.resolve(T.error)))}finally{for(let[D,M]of P)D.bindings=new Map(M);this.ctx.state.fileDescriptors=O,this.ctx.state.nextFd=R;for(let[D,M]of _)M===void 0?this.ctx.state.env.delete(D):this.ctx.state.env.set(D,M)}return w}for(let w of T.legacyRedirections){if(w.target.type==="HereDoc"||w.fdVariable)continue;let D=await z(this.ctx,w.target),M=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(M,j)}catch{let j;try{j=await te(this.ctx,()=>Promise.resolve(A(`bash: ${D}: No such file or directory
|
|
686
|
+
`)))}finally{for(let[X,re]of P)X.bindings=new Map(re);this.ctx.state.fileDescriptors=O,this.ctx.state.nextFd=R;for(let[X,re]of _)re===void 0?this.ctx.state.env.delete(X):this.ctx.state.env.set(X,re)}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(M,`__rw__:${J.length}:${J}:0:${j}`)}catch{await this.ctx.fs.writeFile(J,"","utf8"),this.ctx.state.fileDescriptors.set(M,`__rw__:${J.length}:${J}:0:`)}}else if(w.operator==="<&")if(D==="-")this.ctx.state.fileDescriptors.delete(M);else{let J=D.endsWith("-"),j=Number.parseInt(J?D.slice(0,-1):D,10);if(!Number.isNaN(j)){let X=this.ctx.state.fileDescriptors.get(j)??`__dupin__:${j}`;this.ctx.state.fileDescriptors.set(M,X),J&&this.ctx.state.fileDescriptors.delete(j)}}}for(let[w,D]of r)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 r.keys())this.ctx.state.tempExportedVars.delete(w);return B()}r.size>0&&(this.ctx.state.tempEnvBindings=this.ctx.state.tempEnvBindings||[],this.ctx.state.tempEnvBindings.push(new Map(r)));let C,N=null,I=h?[1,2].filter(P=>{let k=m.bindings.get(P),O=h.channels.bindings.get(P);return k?.sink!==O?.sink||Me(m,P)!==Me(h.channels,P)}):[];try{try{let P=()=>this.runCommand(c,f,d,S??he($),!1,!1,l);C=h?await K(this.ctx,h.channels,P):await P()}catch(P){let k=null;if(h&&(k=(await K(this.ctx,h.channels,()=>Ze(this.ctx,P,I))).writeFailure,k&&(C=k)),!k)if(P instanceof Ae||P instanceof Ce)N=P,C=B();else throw P}if(C.exitCode===127&&Ge.has(c)&&h?.channels.bindings.get(1)?.descriptor==="__file__:/dev/full"&&(C=G(`
|
|
687
|
+
`)),h&&I.length>0&&(C=await K(this.ctx,h.channels,()=>te(this.ctx,()=>Promise.resolve(C),I))),N)throw N;if(f.length>0){let P=H(f[f.length-1]);if((c==="declare"||c==="local"||c==="typeset")&&/^[a-zA-Z_][a-zA-Z0-9_]*=\(/.test(P)){let k=P.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\(/);k&&(P=k[1])}this.ctx.state.lastArg=F(P)}else this.ctx.state.lastArg=F(c)}finally{let P=Yr(c)&&c!=="unset"&&c!=="eval";if(!this.ctx.state.options.posix||!P)for(let[O,R]of r)this.ctx.state.fullyUnsetLocals?.has(O)||(R===void 0?this.ctx.state.env.delete(O):this.ctx.state.env.set(O,R));if(this.ctx.state.tempExportedVars)for(let O of r.keys())this.ctx.state.tempExportedVars.delete(O);r.size>0&&this.ctx.state.tempEnvBindings&&this.ctx.state.tempEnvBindings.pop()}return C}async runCommand(t,s,n,r,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??E())},u=await Di(l,t,s,n,r,i,a,o);return u!==null?u:Ii(l,t,s,r,a)}aliasExpansionStack=new Set;expandAlias(t){return Js(this.ctx.state,t,this.aliasExpansionStack)}async findCommandInPath(t){return Ps(this.ctx,t)}async executeSubshell(t,s=E()){return Gi(this.ctx,t,s,n=>this.executeStatement(n))}async executeGroup(t,s=E()){return qi(this.ctx,t,s,n=>this.executeStatement(n))}async executeArithmeticCommand(t){t.line!==void 0&&(this.ctx.state.currentLine=t.line);let s=this.ctx.outputChannels,n=await Ne(this.ctx,s,t.redirections);if(n.error)return K(this.ctx,n.channels,()=>te(this.ctx,()=>Promise.resolve(n.error)));let r=[1,2].filter(i=>{let a=s.bindings.get(i),o=n.channels.bindings.get(i);return a?.sink!==o?.sink||Me(s,i)!==Me(n.channels,i)});return K(this.ctx,n.channels,async()=>{let i;try{let a=await Q(this.ctx,t.expression.expression);i=ae(a!==0)}catch(a){i=A(`bash: arithmetic expression: ${a.message}
|
|
688
|
+
`)}return r.length>0?te(this.ctx,()=>Promise.resolve(i),r):i})}async executeConditionalCommand(t){t.line!==void 0&&(this.ctx.state.currentLine=t.line);let s=this.ctx.outputChannels,n=await Ne(this.ctx,s,t.redirections);if(n.error)return K(this.ctx,n.channels,()=>te(this.ctx,()=>Promise.resolve(n.error)));let r=[1,2].filter(i=>{let a=s.bindings.get(i),o=n.channels.bindings.get(i);return a?.sink!==o?.sink||Me(s,i)!==Me(n.channels,i)});return K(this.ctx,n.channels,async()=>{let i;try{let a=await Ke(this.ctx,t.expression);i=ae(a)}catch(a){let o=a instanceof Xe?1:2;i=A(`bash: conditional expression: ${a.message}
|
|
689
|
+
`,o)}return r.length>0?te(this.ctx,()=>Promise.resolve(i),r):i})}};var ye={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 Ji(e){return e?{maxCallDepth:e.maxCallDepth??ye.maxCallDepth,maxCommandCount:e.maxCommandCount??ye.maxCommandCount,maxLoopIterations:e.maxLoopIterations??ye.maxLoopIterations,maxAwkIterations:e.maxAwkIterations??ye.maxAwkIterations,maxSedIterations:e.maxSedIterations??ye.maxSedIterations,maxJqIterations:e.maxJqIterations??ye.maxJqIterations,maxSqliteTimeoutMs:e.maxSqliteTimeoutMs??ye.maxSqliteTimeoutMs,maxPythonTimeoutMs:e.maxPythonTimeoutMs??ye.maxPythonTimeoutMs,maxGlobOperations:e.maxGlobOperations??ye.maxGlobOperations,maxStringLength:e.maxStringLength??ye.maxStringLength,maxArrayElements:e.maxArrayElements??ye.maxArrayElements,maxHeredocSize:e.maxHeredocSize??ye.maxHeredocSize,maxSubstitutionDepth:e.maxSubstitutionDepth??ye.maxSubstitutionDepth,maxConcurrentJobs:e.maxConcurrentJobs??ye.maxConcurrentJobs}:{...ye}}function Ki(e){try{let t=new URL(e);return{origin:t.origin,pathname:t.pathname,href:t.href}}catch{return null}}function Wa(e){let t=Ki(e);return t?{origin:t.origin,pathPrefix:t.pathname}:null}function Fa(e,t){let s=Ki(e);if(!s)return!1;let n=Wa(t);return!n||s.origin!==n.origin?!1:n.pathPrefix==="/"||n.pathPrefix===""?!0:s.pathname.startsWith(n.pathPrefix)}function Jn(e,t){return!t||t.length===0?!1:t.some(s=>Fa(e,s))}var Ft=class extends Error{constructor(t){super(`Network access denied: URL not in allow-list: ${t}`),this.name="NetworkAccessDeniedError"}},Vt=class extends Error{constructor(t){super(`Too many redirects (max: ${t})`),this.name="TooManyRedirectsError"}},zt=class extends Error{constructor(t){super(`Redirect target not in allow-list: ${t}`),this.name="RedirectNotAllowedError"}},Ns=class extends Error{constructor(t,s){super(`HTTP method '${t}' not allowed. Allowed methods: ${s.join(", ")}`),this.name="MethodNotAllowedError"}},jt=class extends Error{constructor(t){super(`Response body too large (max: ${t} bytes)`),this.name="ResponseTooLargeError"}};var Va=20,za=3e4,ja=10485760,Ba=["GET","HEAD"],Ha=new Set(["GET","HEAD","OPTIONS"]),Ua=new Set([301,302,303,307,308]);function Kn(e){let t=e.maxRedirects??Va,s=e.timeoutMs??za,n=e.maxResponseSize??ja,r=e.dangerouslyAllowFullInternetAccess?["GET","HEAD","POST","PUT","DELETE","PATCH","OPTIONS"]:e.allowedMethods??Ba;function i(l){if(!e.dangerouslyAllowFullInternetAccess&&!Jn(l,e.allowedUrlPrefixes??[]))throw new Ft(l)}function a(l){if(e.dangerouslyAllowFullInternetAccess)return;let u=l.toUpperCase();if(!r.includes(u))throw new Ns(u,r)}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 S={method:c,headers:u.headers,signal:h.signal,redirect:"manual"};u.body&&!Ha.has(c)&&(S.body=u.body);let $=await fetch(f,S);if(Ua.has($.status)&&p){let g=$.headers.get("location");if(!g)return await Yi($,f,n);let v=new URL(g,f).href;if(!e.dangerouslyAllowFullInternetAccess&&!Jn(v,e.allowedUrlPrefixes??[]))throw new zt(v);if(d++,d>t)throw new Vt(t);f=v;continue}return await Yi($,f,n)}finally{clearTimeout(b)}}}return o}async function Yi(e,t,s){let n=Object.create(null);if(e.headers.forEach((i,a)=>{n[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 jt(s)}}let r;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 jt(s);o.push(a.decode(c,{stream:!0}))}o.push(a.decode()),r=o.join("")}else r=await e.text();return{status:e.status,statusText:e.statusText,headers:n,body:r,url:t}}var Ga=1e3,qa=64,Za=globalThis.setTimeout.bind(globalThis),Ja=globalThis.clearTimeout.bind(globalThis),Os=class{jobs=new Map;reapedWaitStatuses=new Map;reapedWaitLineages=new Map;options;nextPid=Ga;nextLineageId=1;highestJobNumber=0;runningJobs=0;disposed=!1;disposePromise;constructor(t={}){this.options=t}start(t,s,n){if(this.disposed)throw new Error("Cannot start a job on a disposed ProcessTable");let r=this.nextPid++,i=new AbortController,a=this.highestJobNumber+1,o={info:{pid:r,command:t,startedAt:Date.now(),state:"running"},jobNumber:a,lineageId:n,controller:i,promise:Promise.resolve(0)};return this.jobs.set(r,o),this.highestJobNumber=a,this.runningJobs++,o.promise=Promise.resolve().then(()=>s(r,i.signal)).catch(()=>i.signal.aborted?rr(i.signal.reason):1).then(l=>{this.jobs.get(r)===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?.(r,l)).catch(()=>{})}catch{}return l}),r}list(){return[...this.jobs.values()].sort((t,s)=>t.jobNumber-s.jobNumber).map(t=>({...t.info}))}listJobs(t,s={}){let n=[...this.jobs.values()].sort((l,u)=>l.jobNumber-u.jobNumber),r=n.at(-1)?.info.pid,i=n.at(-2)?.info.pid,a=[],o=[];for(let l of n)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===r?"+":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,n){let r=this.jobs.get(t);return!r||r.info.state==="done"?!1:(s!=="SIGSTOP"&&s!=="SIGCONT"&&r.controller?.abort(n??s),!0)}async wait(t){if(t!==void 0){let r=this.jobs.get(t);if(!r)return this.reapedWaitStatuses.get(t)??127;let i=r.info.state==="done"?r.info.exitCode??1:await(r.promise??Promise.resolve(1));return this.jobs.get(t)===r&&(this.rememberWaitStatus(t,i,r.lineageId),this.deleteJobs([t])),i}let s=[...this.jobs.values()],n=new Set([...this.reapedWaitStatuses.keys(),...s.map(r=>r.info.pid)]);s.length>0&&(await Promise.all(s.map(r=>r.promise??Promise.resolve(r.info.exitCode??1))),this.deleteJobs(s.map(r=>r.info.pid)));for(let r of n)this.reapedWaitStatuses.delete(r),this.reapedWaitLineages.delete(r);return 0}async waitForLineage(t){let s=[...this.jobs.values()].filter(r=>r.lineageId===t),n=[...this.reapedWaitLineages.entries()].flatMap(([r,i])=>i===t?[r]:[]);s.length>0&&(await Promise.all(s.map(r=>r.promise??Promise.resolve(r.info.exitCode??1))),this.deleteJobs(s.map(r=>r.info.pid)));for(let r of[...n,...s.map(i=>i.info.pid)])this.reapedWaitStatuses.delete(r),this.reapedWaitLineages.delete(r);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(r=>{s=r}),this.abortAll("SIGKILL"),this.jobs.clear(),this.reapedWaitStatuses.clear(),this.reapedWaitLineages.clear(),this.highestJobNumber=0,this.runningJobs=0;let n=Za(s,this.options.disposeTimeoutMs??1e3);return Promise.allSettled(t.flatMap(r=>r.promise?[r.promise]:[])).then(()=>{Ja(n),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 n=/^%(\d+)$/.exec(t);if(!n)return;let r=Number.parseInt(n[1],10);return s.find(i=>i.jobNumber===r)?.info.pid}get observesOutput(){return this.options.onJobOutput!==void 0}observeOutput(t,s,n){try{Promise.resolve(this.options.onJobOutput?.(t,s,n)).catch(()=>{})}catch{}}rememberWaitStatus(t,s,n){if(this.reapedWaitStatuses.delete(t),this.reapedWaitLineages.delete(t),this.reapedWaitStatuses.set(t,s),this.reapedWaitLineages.set(t,n),this.reapedWaitStatuses.size>qa){let r=this.reapedWaitStatuses.keys().next().value;r!==void 0&&(this.reapedWaitStatuses.delete(r),this.reapedWaitLineages.delete(r))}}deleteJobs(t){let s=!1;for(let n of t){let r=this.jobs.get(n);r&&(this.jobs.delete(n),s||=r.jobNumber===this.highestJobNumber)}if(s){this.highestJobNumber=0;for(let n of this.jobs.values())this.highestJobNumber=Math.max(this.highestJobNumber,n.jobNumber)}}};function Xi(){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 Bt=typeof __BROWSER__<"u"&&__BROWSER__;function Qi(){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 Xn=null;if(!Bt)try{let e="node:module",{createRequire:t}=await import(e);Xn=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 Ka=`
|
|
690
|
+
|
|
691
|
+
This is a defense-in-depth measure and indicates a bug in just-bash. Please report this at security@vercel.com`,ge=class extends Error{violation;constructor(t,s){super(t+Ka),this.violation=s,this.name="SecurityViolationError"}},Ee=!Bt&&Xn?new Xn:null,Ya=1e3,Yn={enabled:!0,auditMode:!1};function Xa(e){return e===void 0?{...Yn,enabled:!1}:typeof e=="boolean"?{...Yn,enabled:e}:{...Yn,...e}}var Ds=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(Xa(t))),e.instance}static resetInstance(){e.instance&&(e.instance.forceDeactivate(),e.instance=null)}static isInSandboxedContext(){return Ee?Ee?.getStore()?.sandboxActive===!0:!1}static getCurrentExecutionId(){if(Ee)return Ee?.getStore()?.executionId}updateConfig(t){this.config={...this.config,...t}}activate(){if(Bt||!this.config.enabled){let s=Qi();return{run:n=>n(),deactivate:()=>{},executionId:s}}this.refCount++,this.refCount===1&&(this.applyPatches(),this.activationTime=Date.now());let t=Qi();return{run:s=>Ee.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 Bt||this.config.auditMode||!Ee?!1:Ee?.getStore()?.sandboxActive===!0}recordViolation(t,s,n){let r={timestamp:Date.now(),type:t,message:n,path:s,stack:new Error().stack,executionId:Ee?.getStore()?.executionId};if(this.violations.length<Ya&&this.violations.push(r),this.config.onViolation)try{this.config.onViolation(r)}catch(i){console.debug("[DefenseInDepthBox] onViolation callback threw:",i instanceof Error?i.message:i)}return r}createBlockingProxy(t,s,n){let r=this;return new Proxy(t,{apply(i,a,o){if(r.shouldBlock()){let l=`${s} is blocked during script execution`,u=r.recordViolation(n,s,l);throw new ge(l,u)}return r.config.auditMode&&Ee?.getStore()?.sandboxActive===!0&&r.recordViolation(n,s,`${s} called (audit mode)`),Reflect.apply(i,a,o)},construct(i,a,o){if(r.shouldBlock()){let l=`${s} constructor is blocked during script execution`,u=r.recordViolation(n,s,l);throw new ge(l,u)}return r.config.auditMode&&Ee?.getStore()?.sandboxActive===!0&&r.recordViolation(n,s,`${s} constructor called (audit mode)`),Reflect.construct(i,a,o)}})}createBlockingObjectProxy(t,s,n){let r=this;return new Proxy(t,{get(i,a,o){if(r.shouldBlock()){let l=`${s}.${String(a)}`,u=`${l} is blocked during script execution`,c=r.recordViolation(n,l,u);throw new ge(u,c)}if(r.config.auditMode&&Ee?.getStore()?.sandboxActive===!0){let l=`${s}.${String(a)}`;r.recordViolation(n,l,`${l} accessed (audit mode)`)}return Reflect.get(i,a,o)},set(i,a,o,l){if(r.shouldBlock()){let u=`${s}.${String(a)}`,c=`${u} modification is blocked during script execution`,f=r.recordViolation(n,u,c);throw new ge(c,f)}return Reflect.set(i,a,o,l)},ownKeys(i){if(r.shouldBlock()){let a=`${s} enumeration is blocked during script execution`,o=r.recordViolation(n,s,a);throw new ge(a,o)}return Reflect.ownKeys(i)},getOwnPropertyDescriptor(i,a){if(r.shouldBlock()){let o=`${s}.${String(a)}`,l=`${o} descriptor access is blocked during script execution`,u=r.recordViolation(n,o,l);throw new ge(l,u)}return Reflect.getOwnPropertyDescriptor(i,a)},has(i,a){if(r.shouldBlock()){let o=`${s}.${String(a)}`,l=`${o} existence check is blocked during script execution`,u=r.recordViolation(n,o,l);throw new ge(l,u)}return Reflect.has(i,a)}})}applyPatches(){let t=Xi();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 n=s?.value;Object.defineProperty(Error,"prepareStackTrace",{get(){return n},set(r){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 ge(i,a)}t.config.auditMode&&Ee?.getStore()?.sandboxActive===!0&&t.recordViolation("error_prepare_stack_trace","Error.prepareStackTrace","Error.prepareStackTrace set (audit mode)"),n=r},configurable:!0})}catch(s){console.debug("[DefenseInDepthBox] Could not protect Error.prepareStackTrace:",s instanceof Error?s.message:s)}}patchPrototypeConstructor(t,s,n){let r=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(r.shouldBlock()){let o=`${s} access is blocked during script execution`,l=r.recordViolation(n,s,o);throw new ge(o,l)}return r.config.auditMode&&Ee?.getStore()?.sandboxActive===!0&&r.recordViolation(n,s,`${s} accessed (audit mode)`),a},set(o){if(r.shouldBlock()){let l=`${s} modification is blocked during script execution`,u=r.recordViolation(n,s,l);throw new ge(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 n=s?.value;n!==void 0&&Object.defineProperty(process,"mainModule",{get(){if(t.shouldBlock()){let r="process.mainModule access is blocked during script execution",i=t.recordViolation("process_main_module","process.mainModule",r);throw new ge(r,i)}return t.config.auditMode&&Ee?.getStore()?.sandboxActive===!0&&t.recordViolation("process_main_module","process.mainModule","process.mainModule accessed (audit mode)"),n},set(r){if(t.shouldBlock()){let i="process.mainModule modification is blocked during script execution",a=t.recordViolation("process_main_module","process.mainModule",i);throw new ge(i,a)}Object.defineProperty(process,"mainModule",{value:r,writable:!0,configurable:!0})},configurable:!0})}catch(s){console.debug("[DefenseInDepthBox] Could not protect process.mainModule:",s instanceof Error?s.message:s)}}protectModuleLoad(){if(!Bt)try{let t=null;if(typeof process<"u"){let a=process.mainModule;a&&typeof a=="object"&&(t=a.constructor)}if(!t&&typeof Ht<"u"&&typeof Ht.main<"u"&&(t=Ht.main.constructor),!t||typeof t._load!="function")return;let s=t._load,n=Object.getOwnPropertyDescriptor(t,"_load");this.originalDescriptors.push({target:t,prop:"_load",descriptor:n});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:n,violationType:r,strategy:i}=t;try{let a=s[n];if(a===void 0)return;let o=Object.getOwnPropertyDescriptor(s,n);if(this.originalDescriptors.push({target:s,prop:n,descriptor:o}),i==="freeze")typeof a=="object"&&a!==null&&Object.freeze(a);else{let l=this.getPathForTarget(s,n),u=typeof a=="function"?this.createBlockingProxy(a,l,r):this.createBlockingObjectProxy(a,l,r);Object.defineProperty(s,n,{value:u,writable:!0,configurable:!0})}}catch(a){let o=this.getPathForTarget(s,n);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:n,descriptor:r}=this.originalDescriptors[t];try{r?Object.defineProperty(s,n,r):delete s[n]}catch(i){let a=this.getPathForTarget(s,n);console.debug(`[DefenseInDepthBox] Could not restore ${a}:`,i instanceof Error?i.message:i)}}this.originalDescriptors=[]}};var Qa=globalThis.setTimeout.bind(globalThis),Is=class{fs;processes;commands=new Map;useDefaultLayout=!1;limits;secureFetch;sleepFn;traceFn;logger;defenseInDepthConfig;coverageWriter;state;constructor(t={}){let s=t.fs??new Tt(t.files);this.fs=s,this.processes=t.processes??new Os,this.useDefaultLayout=!t.cwd&&!t.files;let n=t.cwd||(this.useDefaultLayout?"/home/user":"/"),r=new Map,i=[["HOME",this.useDefaultLayout?"/home/user":"/"],["PATH","/usr/bin:/bin"],["IFS",`
|
|
692
|
+
`],["OSTYPE","linux-gnu"],["MACHTYPE","x86_64-pc-linux-gnu"],["HOSTTYPE","x86_64"],["HOSTNAME","localhost"],["PWD",n],["OLDPWD",n],["OPTIND","1"]];for(let[a,o]of i)y(r,a,o);for(let[a,o]of Object.entries(t.env??{}))y(r,a,o);if(this.limits=Ji({...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=Kn(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:r,cwd:n,previousDir:"/home/user",functions:new Map,localScopes:[],callDepth:0,sourceDepth:0,commandCount:0,lastExitCode:0,lastArg:L,startTime:Date.now(),lastBackgroundPid:0,bashPid:Ls().pid,nextVirtualPid:Ls().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},y(this.state.env,"SHELLOPTS",Gs(this.state.options)),y(this.state.env,"BASHOPTS",qs(this.state.shoptOptions)),xr(s,this.useDefaultLayout),n!=="/"&&s instanceof Tt)try{s.mkdirSync(n,{recursive:!0})}catch{}for(let a of $r(t.commands))this.registerCommand(a);if(t.network)for(let a of Ar())this.registerCommand(a);if(t.python)for(let a of Cr())this.registerCommand(a);if(t.customCommands)for(let a of t.customCommands)kr(a)?this.registerCommand(Pr(a)):this.registerCommand(a)}registerCommand(t){this.commands.set(t.name,t);let s=this.fs;if(typeof s.writeFileSync=="function"){let n=`#!/bin/bash
|
|
677
693
|
# Built-in command: ${t.name}
|
|
678
|
-
`;try{s.writeFileSync(`/bin/${t.name}`,
|
|
679
|
-
`),exitCode:1,env:
|
|
680
|
-
`),exitCode:1,env:
|
|
681
|
-
`),exitCode:
|
|
682
|
-
`),exitCode:2,env:
|
|
683
|
-
`),exitCode:
|
|
684
|
-
`),s
|
|
685
|
-
`)}import*as J from"node:fs";import*as it from"node:path";var ra="/home/user/project";function ae(e,t){if(e.includes("\0"))throw new Error(`ENOENT: path contains null byte, ${t} '${e}'`)}var ls=class{root;mountPoint;readOnly;maxFileReadSize;memory=new Map;deleted=new Set;constructor(t){this.root=it.resolve(t.root);let s=t.mountPoint??ra;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,!J.existsSync(this.root))throw new Error(`OverlayFs root does not exist: ${this.root}`);if(!J.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}=Xe(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=it.join(this.root,r),i=it.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 J.promises.access(r),!0}catch{return!1}}async readFile(t){let s=await this.readFileChunks(t);return he(s)}async readRange(t,s,r){It(s,r);let n=await this.resolveForRead(t);if(n.kind==="memory")return Rt(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 J.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){ae(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 J.promises.lstat(i);if(o.isSymbolicLink()){let a=await J.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=Me(s);return Dt(r,n)}async readFileChunks(t,s=new Set){ae(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 J.promises.lstat(i);if(o.isSymbolicLink()){let c=await J.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 J.promises.readFile(i),l=new Uint8Array(a.buffer,a.byteOffset,a.byteLength),{chunks:u}=Xe(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){ae(t,"write"),this.assertWritable(`write '${t}'`);let n=this.normalizePath(t);this.ensureParentDirs(n);let i=Me(r),{chunks:o,size:a}=await Ke(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){ae(t,"append"),this.assertWritable(`append '${t}'`);let n=this.normalizePath(t),i=Me(r),{chunks:o,size:a}=await Ke(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){ae(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 J.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){ae(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 J.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){ae(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 J.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 J.promises.lstat(l)).isSymbolicLink()){let c=await J.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){ae(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){ae(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){ae(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){ae(t,"cp"),ae(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=J.readdirSync(r);for(let i of n){let o=t==="/"?`/${i}`:`${t}/${i}`;if(this.deleted.has(o))continue;s.add(o);let a=it.join(r,i);J.statSync(a).isDirectory()&&this.scanRealFs(o,s)}}catch{}}async chmod(t,s){ae(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){ae(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){ae(t,"link"),ae(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){ae(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 J.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){ae(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 J.promises.lstat(m)).isSymbolicLink()){let v=await J.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){ae(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})}};var le={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",cyan:"\x1B[36m"},wr=class{env;rl;running=!0;history=[];isInteractive;constructor(t={}){let s=process.cwd(),r=new ls({root:s,mountPoint:"/"});this.env=new as({fs:r,cwd:t.cwd||"/",env:{HOME:"/",USER:"user",SHELL:"/bin/bash",TERM:"xterm-256color",...t.env},network:t.network!==!1?{dangerouslyAllowFullInternetAccess:!0}:void 0}),this.isInteractive=process.stdin.isTTY===!0,this.rl=yi.createInterface({input:process.stdin,output:process.stdout,terminal:this.isInteractive}),this.rl.on("SIGINT",()=>{process.stdout.write(`^C
|
|
694
|
+
`;try{s.writeFileSync(`/bin/${t.name}`,n)}catch{}try{s.writeFileSync(`/usr/bin/${t.name}`,n)}catch{}}}logResult(t,s,n){try{let r=this.logger;if(r){let i=s.text(),a=n.text();i.length>0&&r.debug("stdout",{output:i}),a.length>0&&r.info("stderr",{output:a}),r.info("exit",{exitCode:t.exitCode})}return{...t,stdout:s.stream(),stderr:n.stream()}}finally{s.seal(),n.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:E(),stderr:V(`bash: maximum command count (${this.limits.maxCommandCount}) exceeded (possible infinite loop). Increase with executionLimits.maxCommandCount option.
|
|
695
|
+
`),exitCode:1,env:Pe(this.state.env,s?.env)};if(!t.trim())return{stdout:E(),stderr:E(),exitCode:0,env:Pe(this.state.env,s?.env)};if(s?.signal?.aborted)return{stdout:E(),stderr:E(),exitCode:new me(s.signal.reason).exitCode,env:Pe(this.state.env,s?.env)};let n=new Set,r=g=>{if(g)return{async write(v){try{await g.write(v)}catch(C){throw n.add(C),C}}}},i=_e(r(s?.stdoutSink)),a=_e(r(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[g,v]of Object.entries(s.env))y(p,g,v);f!==void 0&&y(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=el(t));let S=(this.defenseInDepthConfig?Ds.getInstance(this.defenseInDepthConfig):null)?.activate(),$=!1;try{let g=async()=>{let v=Le(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:(P,k)=>this.exec(P,{...k,jobTracker:u,processes:o,lineageId:l,signal:Ct(s?.signal,k?.signal)}),fetch:this.secureFetch,sleep:this.sleepFn,trace:this.traceFn,coverage:this.coverageWriter,signal:s?.signal},I=await new Wt(C,m).executeRootScript(v);return u.started&&(await new Promise(P=>Qa(P,0)),u.limitExceeded&&(I={...I,exitCode:oe.EXIT_CODE})),this.logResult(I,i,a)};return S?await S.run(g):await g()}catch(g){if(n.has(g))throw g;if(g instanceof q)return this.logResult({exitCode:g.exitCode,env:Pe(this.state.env,s?.env)},i,a);if(g instanceof ve)return this.logResult({exitCode:g.exitCode,env:Pe(this.state.env,s?.env)},i,a);if(g instanceof Xe)return $||await a.write(F(`bash: ${g.message}
|
|
696
|
+
`)),this.logResult({exitCode:1,env:Pe(this.state.env,s?.env)},i,a);if(g instanceof me)return this.logResult({exitCode:g.exitCode,env:Pe(this.state.env,s?.env)},i,a);if(g instanceof oe)return this.logResult({exitCode:oe.EXIT_CODE,env:Pe(this.state.env,s?.env)},i,a);if(g instanceof ge)return await a.write(F(`bash: security violation: ${g.message}
|
|
697
|
+
`)),this.logResult({exitCode:1,env:Pe(this.state.env,s?.env)},i,a);if(g.name==="ParseException")return await a.write(F(`bash: syntax error: ${g.message}
|
|
698
|
+
`)),this.logResult({exitCode:2,env:Pe(this.state.env,s?.env)},i,a);if(g instanceof lr)return await a.write(F(`bash: ${g.message}
|
|
699
|
+
`)),this.logResult({exitCode:2,env:Pe(this.state.env,s?.env)},i,a);if(g instanceof RangeError)return await a.write(F(`bash: ${g.message}
|
|
700
|
+
`)),this.logResult({exitCode:1,env:Pe(this.state.env,s?.env)},i,a);throw g}finally{S?.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 qe(this.state.env)}};function el(e){let t=e.split(`
|
|
701
|
+
`),s=[],n=[];for(let r=0;r<t.length;r++){let i=t[r];if(n.length>0){let l=n[n.length-1];if((l.stripTabs?i.replace(/^\t+/,""):i)===l.delimiter){s.push(i.trimStart()),n.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];n.push({delimiter:c,stripTabs:u})}}return s.join(`
|
|
702
|
+
`)}import*as ne from"node:fs";import*as wt from"node:path";var tl="/home/user/project";function fe(e,t){if(e.includes("\0"))throw new Error(`ENOENT: path contains null byte, ${t} '${e}'`)}var Rs=class{root;mountPoint;readOnly;maxFileReadSize;memory=new Map;deleted=new Set;constructor(t){this.root=wt.resolve(t.root);let s=t.mountPoint??tl;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,!ne.existsSync(this.root))throw new Error(`OverlayFs root does not exist: ${this.root}`);if(!ne.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 n of t)s+=`/${n}`,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 r=this.normalizePath(t).split("/").filter(Boolean),i="";for(let a of r)i+=`/${a}`,this.memory.has(i)||this.memory.set(i,{type:"directory",mode:493,mtime:new Date})}writeFileSync(t,s){let n=this.normalizePath(t),r=this.getDirname(n);r!=="/"&&this.mkdirSync(r);let{chunks:i,size:a}=lt(s);this.memory.set(n,{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 n=s.split("/").filter(i=>i&&i!=="."),r=[];for(let i of n)i===".."?r.pop():r.push(i);return`/${r.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),n=this.getRelativeToMount(s);if(n===null)return null;let r=wt.join(this.root,n),i=wt.resolve(r);return!i.startsWith(this.root)&&i!==this.root.replace(/\/$/,"")?null:i}dirname(t){let s=this.normalizePath(t);if(s==="/")return"/";let n=s.lastIndexOf("/");return n===0?"/":s.slice(0,n)}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 n=this.toRealPath(s);if(!n)return!1;try{return await ne.promises.access(n),!0}catch{return!1}}async readFile(t){let s=await this.readFileChunks(t);return Et(s)}async readRange(t,s,n){Qt(s,n);let r=await this.resolveForRead(t);if(r.kind==="memory")return es(r.chunks,r.size,s,n);if(n===0||s>=r.size)return new Uint8Array(0);let i=Math.min(n,r.size-s),a=new Uint8Array(i),o=await ne.promises.open(r.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){fe(t,"open");let n=this.normalizePath(t);if(s.has(n))throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`);if(s.add(n),this.deleted.has(n))throw new Error(`ENOENT: no such file or directory, open '${t}'`);let r=this.memory.get(n);if(r){if(r.type==="symlink"){let a=this.resolveSymlink(n,r.target);return this.resolveForRead(a,s)}if(r.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);return{kind:"memory",chunks:r.chunks,size:r.size}}let i=this.toRealPath(n);if(!i)throw new Error(`ENOENT: no such file or directory, open '${t}'`);try{let a=await ne.promises.lstat(i);if(a.isSymbolicLink()){let o=await ne.promises.readlink(i),l=this.resolveSymlink(n,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 n=await this.readFileChunks(t),r=Ue(s);return Xt(n,r)}async readFileChunks(t,s=new Set){fe(t,"open");let n=this.normalizePath(t);if(s.has(n))throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`);if(s.add(n),this.deleted.has(n))throw new Error(`ENOENT: no such file or directory, open '${t}'`);let r=this.memory.get(n);if(r){if(r.type==="symlink"){let a=this.resolveSymlink(n,r.target);return this.readFileChunks(a,s)}if(r.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);return r.chunks}let i=this.toRealPath(n);if(!i)throw new Error(`ENOENT: no such file or directory, open '${t}'`);try{let a=await ne.promises.lstat(i);if(a.isSymbolicLink()){let c=await ne.promises.readlink(i),f=this.resolveSymlink(n,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 ne.promises.readFile(i),l=new Uint8Array(o.buffer,o.byteOffset,o.byteLength),{chunks:u}=lt(l);return u}catch(a){throw a.code==="ENOENT"?new Error(`ENOENT: no such file or directory, open '${t}'`):a}}async writeFile(t,s,n){fe(t,"write"),this.assertWritable(`write '${t}'`);let r=this.normalizePath(t);this.ensureParentDirs(r);let i=Ue(n),{chunks:a,size:o}=await ct(s,i);this.memory.set(r,{type:"file",chunks:a,size:o,mode:420,mtime:new Date}),this.deleted.delete(r)}async appendFile(t,s,n){fe(t,"append"),this.assertWritable(`append '${t}'`);let r=this.normalizePath(t),i=Ue(n),{chunks:a,size:o}=await ct(s,i),l=[],u=0;try{l=await this.readFileChunks(r);for(let c of l)u+=c.length}catch{}this.ensureParentDirs(r),this.memory.set(r,{type:"file",chunks:[...l,...a],size:u+o,mode:420,mtime:new Date}),this.deleted.delete(r)}async exists(t){return t.includes("\0")?!1:this.existsInOverlay(t)}async stat(t,s=new Set){fe(t,"stat");let n=this.normalizePath(t);if(s.has(n))throw new Error(`ELOOP: too many levels of symbolic links, stat '${t}'`);if(s.add(n),this.deleted.has(n))throw new Error(`ENOENT: no such file or directory, stat '${t}'`);let r=this.memory.get(n);if(r){if(r.type==="symlink"){let o=this.resolveSymlink(n,r.target);return this.stat(o,s)}let a=0;return r.type==="file"&&(a=r.size),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:a,mtime:r.mtime}}let i=this.toRealPath(n);if(!i)throw new Error(`ENOENT: no such file or directory, stat '${t}'`);try{let a=await ne.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){fe(t,"lstat");let s=this.normalizePath(t);if(this.deleted.has(s))throw new Error(`ENOENT: no such file or directory, lstat '${t}'`);let n=this.memory.get(s);if(n){if(n.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:n.mode,size:n.target.length,mtime:n.mtime};let i=0;return n.type==="file"&&(i=n.size),{isFile:n.type==="file",isDirectory:n.type==="directory",isSymbolicLink:!1,mode:n.mode,size:i,mtime:n.mtime}}let r=this.toRealPath(s);if(!r)throw new Error(`ENOENT: no such file or directory, lstat '${t}'`);try{let i=await ne.promises.lstat(r);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 n=this.dirname(t);return this.normalizePath(n==="/"?`/${s}`:`${n}/${s}`)}async mkdir(t,s){fe(t,"mkdir"),this.assertWritable(`mkdir '${t}'`);let n=this.normalizePath(t);if(await this.existsInOverlay(n)){if(!s?.recursive)throw new Error(`EEXIST: file already exists, mkdir '${t}'`);return}let i=this.dirname(n);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(n,{type:"directory",mode:493,mtime:new Date}),this.deleted.delete(n)}async readdirCore(t,s){if(this.deleted.has(s))throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);let n=new Map,r=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)&&r.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&&!r.has(c)&&!u.includes("/",1)&&n.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 ne.promises.readdir(a,{withFileTypes:!0});for(let l of o)!r.has(l.name)&&!n.has(l.name)&&n.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 n}async resolveForReaddir(t,s=!1){let n=this.normalizePath(t),r=new Set,i=s,a=this.memory.get(n);for(;a&&a.type==="symlink";){if(r.has(n))throw new Error(`ELOOP: too many levels of symbolic links, scandir '${t}'`);r.add(n),i=!0,n=this.resolveSymlink(n,a.target),a=this.memory.get(n)}if(a)return{normalized:n,outsideOverlay:!1};if(this.getRelativeToMount(n)===null)return{normalized:n,outsideOverlay:!0};let l=this.toRealPath(n);if(!l)return{normalized:n,outsideOverlay:!0};try{if((await ne.promises.lstat(l)).isSymbolicLink()){let c=await ne.promises.readlink(l),f=this.resolveSymlink(n,c);return this.resolveForReaddir(f,!0)}return{normalized:n,outsideOverlay:!1}}catch{return i?{normalized:n,outsideOverlay:!0}:{normalized:n,outsideOverlay:!1}}}async readdir(t){fe(t,"scandir");let{normalized:s,outsideOverlay:n}=await this.resolveForReaddir(t);if(n)return[];let r=await this.readdirCore(t,s);return Array.from(r.keys()).sort((i,a)=>i<a?-1:i>a?1:0)}async readdirWithFileTypes(t){fe(t,"scandir");let{normalized:s,outsideOverlay:n}=await this.resolveForReaddir(t);if(n)return[];let r=await this.readdirCore(t,s);return Array.from(r.values()).sort((i,a)=>i.name<a.name?-1:i.name>a.name?1:0)}async rm(t,s){fe(t,"rm"),this.assertWritable(`rm '${t}'`);let n=this.normalizePath(t);if(!await this.existsInOverlay(n)){if(s?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${t}'`)}try{if((await this.stat(n)).isDirectory){let a=await this.readdir(n);if(a.length>0){if(!s?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${t}'`);for(let o of a){let l=n==="/"?`/${o}`:`${n}/${o}`;await this.rm(l,s)}}}}catch{}this.deleted.add(n),this.memory.delete(n)}async cp(t,s,n){fe(t,"cp"),fe(s,"cp"),this.assertWritable(`cp '${s}'`);let r=this.normalizePath(t),i=this.normalizePath(s);if(!await this.existsInOverlay(r))throw new Error(`ENOENT: no such file or directory, cp '${t}'`);let o=await this.stat(r);if(o.isFile){let l=await this.readFileChunks(r);await this.writeFile(i,Et(l))}else if(o.isDirectory){if(!n?.recursive)throw new Error(`EISDIR: is a directory, cp '${t}'`);await this.mkdir(i,{recursive:!0});let l=await this.readdir(r);for(let u of l){let c=r==="/"?`/${u}`:`${r}/${u}`,f=i==="/"?`/${u}`:`${i}/${u}`;await this.cp(c,f,n)}}}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 n=t==="/"?`/${s}`:`${t}/${s}`;return this.normalizePath(n)}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 n=this.toRealPath(t);if(n)try{let r=ne.readdirSync(n);for(let i of r){let a=t==="/"?`/${i}`:`${t}/${i}`;if(this.deleted.has(a))continue;s.add(a);let o=wt.join(n,i);ne.statSync(o).isDirectory()&&this.scanRealFs(a,s)}}catch{}}async chmod(t,s){fe(t,"chmod"),this.assertWritable(`chmod '${t}'`);let n=this.normalizePath(t);if(!await this.existsInOverlay(n))throw new Error(`ENOENT: no such file or directory, chmod '${t}'`);let i=this.memory.get(n);if(i){i.mode=s;return}let a=await this.stat(n);if(a.isFile){let o=await this.readFileChunks(n),l=0;for(let u of o)l+=u.length;this.memory.set(n,{type:"file",chunks:o,size:l,mode:s,mtime:new Date})}else a.isDirectory&&this.memory.set(n,{type:"directory",mode:s,mtime:new Date})}async symlink(t,s){fe(s,"symlink"),this.assertWritable(`symlink '${s}'`);let n=this.normalizePath(s);if(await this.existsInOverlay(n))throw new Error(`EEXIST: file already exists, symlink '${s}'`);this.ensureParentDirs(n),this.memory.set(n,{type:"symlink",target:t,mode:511,mtime:new Date}),this.deleted.delete(n)}async link(t,s){fe(t,"link"),fe(s,"link"),this.assertWritable(`link '${s}'`);let n=this.normalizePath(t),r=this.normalizePath(s);if(!await this.existsInOverlay(n))throw new Error(`ENOENT: no such file or directory, link '${t}'`);let a=await this.stat(n);if(!a.isFile)throw new Error(`EPERM: operation not permitted, link '${t}'`);if(await this.existsInOverlay(r))throw new Error(`EEXIST: file already exists, link '${s}'`);let l=await this.readFileChunks(n),u=0;for(let c of l)u+=c.length;this.ensureParentDirs(r),this.memory.set(r,{type:"file",chunks:l,size:u,mode:a.mode,mtime:new Date}),this.deleted.delete(r)}async readlink(t){fe(t,"readlink");let s=this.normalizePath(t);if(this.deleted.has(s))throw new Error(`ENOENT: no such file or directory, readlink '${t}'`);let n=this.memory.get(s);if(n){if(n.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${t}'`);return n.target}let r=this.toRealPath(s);if(!r)throw new Error(`ENOENT: no such file or directory, readlink '${t}'`);try{return await ne.promises.readlink(r)}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){fe(t,"realpath");let s=this.normalizePath(t),n=new Set,r=async o=>{let l=o==="/"?[]:o.slice(1).split("/"),u="";for(let c of l){if(u=`${u}/${c}`,n.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(n.add(u),u=this.resolveSymlink(u,f.target),d++,n.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 ne.promises.lstat(m)).isSymbolicLink()){let b=await ne.promises.readlink(m);return n.add(u),u=this.resolveSymlink(u,b),r(u)}}catch(h){throw h.code==="ENOENT"?new Error(`ENOENT: no such file or directory, realpath '${t}'`):h}}}return u||"/"},i=await r(s);if(!await this.existsInOverlay(i))throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);return i}async utimes(t,s,n){fe(t,"utimes"),this.assertWritable(`utimes '${t}'`);let r=this.normalizePath(t);if(!await this.existsInOverlay(r))throw new Error(`ENOENT: no such file or directory, utimes '${t}'`);let a=this.memory.get(r);if(a){a.mtime=n;return}let o=await this.stat(r);if(o.isFile){let l=await this.readFileChunks(r),u=0;for(let c of l)u+=c.length;this.memory.set(r,{type:"file",chunks:l,size:u,mode:o.mode,mtime:n})}else o.isDirectory&&this.memory.set(r,{type:"directory",mode:o.mode,mtime:n})}};var de={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",cyan:"\x1B[36m"},Qn=class{env;rl;running=!0;history=[];isInteractive;constructor(t={}){let s=process.cwd(),n=new Rs({root:s,mountPoint:"/"});this.env=new Is({fs:n,cwd:t.cwd||"/",env:{HOME:"/",USER:"user",SHELL:"/bin/bash",TERM:"xterm-256color",...t.env},network:t.network!==!1?{dangerouslyAllowFullInternetAccess:!0}:void 0}),this.isInteractive=process.stdin.isTTY===!0,this.rl=to.createInterface({input:process.stdin,output:process.stdout,terminal:this.isInteractive}),this.rl.on("SIGINT",()=>{process.stdout.write(`^C
|
|
686
703
|
`),this.prompt()}),process.stdin.isTTY&&this.rl.on("close",()=>{this.running=!1,console.log(`
|
|
687
|
-
Goodbye!`),process.exit(0)})}syncHistory(){let t=this.env.getEnv();t.BASH_HISTORY=JSON.stringify(this.history)}getPrompt(){let t=this.env.getCwd(),s=this.env.getEnv().HOME||"/home/user",
|
|
688
|
-
${
|
|
704
|
+
Goodbye!`),process.exit(0)})}syncHistory(){let t=this.env.getEnv();t.BASH_HISTORY=JSON.stringify(this.history)}getPrompt(){let t=this.env.getCwd(),s=this.env.getEnv().HOME||"/home/user",n=t;return t===s?n="~":t.startsWith(`${s}/`)&&(n=`~${t.slice(s.length)}`),`${de.green}${de.bold}user@virtual${de.reset}:${de.blue}${de.bold}${n}${de.reset}$ `}async executeCommand(t){let s=t.trim();if(s){if(this.history.push(s),s==="exit"||s.startsWith("exit ")){let n=s.split(/\s+/),r=n[1]?parseInt(n[1],10):0;console.log("exit"),process.exit(r)}this.syncHistory();try{let n=await this.env.exec(s);for await(let i of Ut(n.stdout))process.stdout.write(i);let r=await tr(n.stderr);r.length>0&&process.stderr.write(`${de.red}${r}${de.reset}`)}catch(n){console.error(`${de.red}Error: ${Oe(n)}${de.reset}`)}}}printWelcome(){console.log(`
|
|
705
|
+
${de.cyan}${de.bold}\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557
|
|
689
706
|
\u2551 Virtual Shell v1.0 \u2551
|
|
690
707
|
\u2551 A simulated bash environment in TypeScript \u2551
|
|
691
|
-
\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D${
|
|
708
|
+
\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D${de.reset}
|
|
692
709
|
|
|
693
|
-
${
|
|
710
|
+
${de.dim}Exploring: ${process.cwd()}${de.reset}
|
|
694
711
|
|
|
695
|
-
Type ${
|
|
712
|
+
Type ${de.green}help${de.reset} for available commands, ${de.green}exit${de.reset} to quit.
|
|
696
713
|
Reads from real filesystem, writes stay in memory (OverlayFs).
|
|
697
|
-
`)}prompt(){this.rl.question(this.getPrompt(),async t=>{this.running&&(await this.executeCommand(t),this.prompt())})}async run(){if(this.isInteractive)this.printWelcome(),this.prompt();else{let t=[];this.rl.on("line",s=>{t.push(s)}),await new Promise(s=>{this.rl.on("close",s)});for(let s of t)await this.executeCommand(s)}}};function
|
|
714
|
+
`)}prompt(){this.rl.question(this.getPrompt(),async t=>{this.running&&(await this.executeCommand(t),this.prompt())})}async run(){if(this.isInteractive)this.printWelcome(),this.prompt();else{let t=[];this.rl.on("line",s=>{t.push(s)}),await new Promise(s=>{this.rl.on("close",s)});for(let s of t)await this.executeCommand(s)}}};function sl(){let e=process.argv.slice(2),t={network:!0};for(let s=0;s<e.length;s++)if(e[s]==="--cwd"&&e[s+1])t.cwd=e[++s];else if(e[s]==="--files"&&e[s+1]){let n=e[++s];try{let r=eo.readFileSync(n,"utf-8");t.files=JSON.parse(r)}catch(r){console.error(`Error reading files from ${n}:`,r),process.exit(1)}}else e[s]==="--no-network"?t.network=!1:(e[s]==="--help"||e[s]==="-h")&&(console.log(`
|
|
698
715
|
Usage: pnpm shell [options]
|
|
699
716
|
|
|
700
717
|
Interactive shell using OverlayFs - reads from the current directory,
|
|
@@ -708,4 +725,4 @@ Options:
|
|
|
708
725
|
Example:
|
|
709
726
|
pnpm shell
|
|
710
727
|
pnpm shell --no-network
|
|
711
|
-
`),process.exit(0));return t}var
|
|
728
|
+
`),process.exit(0));return t}var nl=sl(),rl=new Qn(nl);rl.run();
|