just-binary 3.2.5 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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-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/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-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/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 +859 -841
- 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-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-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/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-VEEWI66Q.js +0 -2
- package/dist/bin/chunks/awk2-LEBSBFO3.js +0 -2
- package/dist/bin/chunks/base64-Q2G4GF6R.js +0 -2
- package/dist/bin/chunks/basename-TNVKQHP5.js +0 -2
- package/dist/bin/chunks/bash-E26LCUON.js +0 -2
- package/dist/bin/chunks/cat-6WUYWK6Q.js +0 -2
- package/dist/bin/chunks/chmod-YHG2ADMJ.js +0 -2
- package/dist/bin/chunks/chunk-25DBXZPM.js +0 -100
- package/dist/bin/chunks/chunk-272ZYGP4.js +0 -8
- package/dist/bin/chunks/chunk-2KW5JZDM.js +0 -2
- package/dist/bin/chunks/chunk-33EFJFXL.js +0 -10
- package/dist/bin/chunks/chunk-3CCRFBBL.js +0 -23
- package/dist/bin/chunks/chunk-3OP7VRO7.js +0 -6
- package/dist/bin/chunks/chunk-3PIWDQZL.js +0 -19
- package/dist/bin/chunks/chunk-4C26CCJR.js +0 -4
- package/dist/bin/chunks/chunk-4G37X3GZ.js +0 -14
- package/dist/bin/chunks/chunk-4KTWLZ5A.js +0 -8
- package/dist/bin/chunks/chunk-55N7NX6G.js +0 -9
- package/dist/bin/chunks/chunk-5OQOWWIB.js +0 -7
- package/dist/bin/chunks/chunk-5WAR3CU3.js +0 -3
- package/dist/bin/chunks/chunk-63VB22X2.js +0 -33
- package/dist/bin/chunks/chunk-6KVPD5H7.js +0 -13
- package/dist/bin/chunks/chunk-6OVV6A5W.js +0 -3
- package/dist/bin/chunks/chunk-6PU2WD4P.js +0 -7
- package/dist/bin/chunks/chunk-7ICAP454.js +0 -12
- package/dist/bin/chunks/chunk-7QKMCOGE.js +0 -16
- package/dist/bin/chunks/chunk-7SXBGUE4.js +0 -3
- package/dist/bin/chunks/chunk-7VQY35S5.js +0 -8
- package/dist/bin/chunks/chunk-7VVTANT2.js +0 -7
- package/dist/bin/chunks/chunk-7XV5FI5D.js +0 -8
- package/dist/bin/chunks/chunk-7Y5TZ5CE.js +0 -6
- package/dist/bin/chunks/chunk-A2V4EW6Y.js +0 -10
- package/dist/bin/chunks/chunk-ACV764YE.js +0 -5
- package/dist/bin/chunks/chunk-AJBYK52Q.js +0 -36
- package/dist/bin/chunks/chunk-BCE7PDXY.js +0 -32
- package/dist/bin/chunks/chunk-BVWBX3A2.js +0 -9
- package/dist/bin/chunks/chunk-COBNN6FR.js +0 -11
- package/dist/bin/chunks/chunk-CVXSPZVY.js +0 -2
- package/dist/bin/chunks/chunk-CX7XUPMH.js +0 -13
- package/dist/bin/chunks/chunk-D2V2UKR2.js +0 -12
- package/dist/bin/chunks/chunk-DD4R5YY7.js +0 -7
- package/dist/bin/chunks/chunk-DN7JDLUW.js +0 -26
- package/dist/bin/chunks/chunk-DVODFXEH.js +0 -5
- package/dist/bin/chunks/chunk-EC57ABPL.js +0 -9
- package/dist/bin/chunks/chunk-F7RPLNVE.js +0 -11
- package/dist/bin/chunks/chunk-FEA5SLRN.js +0 -6
- package/dist/bin/chunks/chunk-FJTEZ7ZL.js +0 -9
- package/dist/bin/chunks/chunk-FO6UO5LY.js +0 -12
- package/dist/bin/chunks/chunk-FYKWQWLG.js +0 -9
- package/dist/bin/chunks/chunk-GETENI3B.js +0 -18
- package/dist/bin/chunks/chunk-GTLVINNE.js +0 -4
- package/dist/bin/chunks/chunk-H7WPPRUD.js +0 -2
- package/dist/bin/chunks/chunk-HHBZ7ZEV.js +0 -5
- package/dist/bin/chunks/chunk-IGPJA6SA.js +0 -17
- package/dist/bin/chunks/chunk-J7REVEWS.js +0 -14
- package/dist/bin/chunks/chunk-JHKFD4EI.js +0 -24
- package/dist/bin/chunks/chunk-JUQT3ZM5.js +0 -23
- package/dist/bin/chunks/chunk-LXRRE42A.js +0 -5
- package/dist/bin/chunks/chunk-LYTEJIUW.js +0 -14
- package/dist/bin/chunks/chunk-MFXVUOM3.js +0 -2
- package/dist/bin/chunks/chunk-N3IFSXB3.js +0 -8
- package/dist/bin/chunks/chunk-NHZGQ3Y7.js +0 -84
- package/dist/bin/chunks/chunk-NIBKZJZM.js +0 -3
- package/dist/bin/chunks/chunk-NJTMAMPV.js +0 -3
- package/dist/bin/chunks/chunk-NQSOOEX5.js +0 -20
- package/dist/bin/chunks/chunk-NVK6GU4P.js +0 -3
- package/dist/bin/chunks/chunk-O4WYCXT4.js +0 -2
- package/dist/bin/chunks/chunk-OJGWI2DA.js +0 -63
- package/dist/bin/chunks/chunk-OXIM6UEO.js +0 -11
- package/dist/bin/chunks/chunk-PLF6WISW.js +0 -10
- package/dist/bin/chunks/chunk-PVAWMOD4.js +0 -8
- package/dist/bin/chunks/chunk-PXK4KVSW.js +0 -73
- package/dist/bin/chunks/chunk-Q2EFJFW4.js +0 -2
- package/dist/bin/chunks/chunk-Q5UK2Q5U.js +0 -2
- package/dist/bin/chunks/chunk-Q7XQB3YI.js +0 -7
- package/dist/bin/chunks/chunk-RXYSXOZE.js +0 -287
- package/dist/bin/chunks/chunk-SUC7ET2R.js +0 -14
- package/dist/bin/chunks/chunk-SXGBKAL5.js +0 -16
- package/dist/bin/chunks/chunk-T26GDTOU.js +0 -3
- package/dist/bin/chunks/chunk-T67GIEZU.js +0 -2
- package/dist/bin/chunks/chunk-TC7RJRFD.js +0 -16
- package/dist/bin/chunks/chunk-TWWOPYOU.js +0 -5
- package/dist/bin/chunks/chunk-UDJ6HRS4.js +0 -9
- package/dist/bin/chunks/chunk-UQXDPK2T.js +0 -7
- package/dist/bin/chunks/chunk-UREODEQQ.js +0 -21
- package/dist/bin/chunks/chunk-VDS4FNGM.js +0 -7
- package/dist/bin/chunks/chunk-VKE6V3ZO.js +0 -7
- package/dist/bin/chunks/chunk-VTQCQCQO.js +0 -140
- package/dist/bin/chunks/chunk-W4YU2U3A.js +0 -13
- package/dist/bin/chunks/chunk-X4GHJ5JH.js +0 -6
- package/dist/bin/chunks/chunk-XBI3O5AF.js +0 -9
- package/dist/bin/chunks/chunk-XNMKTUHV.js +0 -6
- package/dist/bin/chunks/chunk-ZTU6ENBH.js +0 -2
- package/dist/bin/chunks/chunk-ZVROZHDE.js +0 -5
- package/dist/bin/chunks/clear-Z6NC6SU4.js +0 -2
- package/dist/bin/chunks/column-UMVTEOKJ.js +0 -2
- package/dist/bin/chunks/comm-Q4W6PSZ3.js +0 -2
- package/dist/bin/chunks/cp-CAN7P3HK.js +0 -2
- package/dist/bin/chunks/curl-3PDMZXZI.js +0 -26
- package/dist/bin/chunks/cut-BQM2BHFI.js +0 -2
- package/dist/bin/chunks/date-XUF36E35.js +0 -2
- package/dist/bin/chunks/diff-7GMSJUJG.js +0 -2
- package/dist/bin/chunks/dirname-F7P24OLR.js +0 -2
- package/dist/bin/chunks/du-HDXNSQIT.js +0 -2
- package/dist/bin/chunks/echo-53OGHYIZ.js +0 -2
- package/dist/bin/chunks/env-N4LYWUJ6.js +0 -2
- package/dist/bin/chunks/expand-535WDY3S.js +0 -2
- package/dist/bin/chunks/expansion-GOJYNUQR.js +0 -2
- package/dist/bin/chunks/expr-Q7K5RKW2.js +0 -2
- package/dist/bin/chunks/file-XMHYEYO5.js +0 -2
- package/dist/bin/chunks/find-SJAABILU.js +0 -2
- package/dist/bin/chunks/flag-coverage-TBMB7M2N.js +0 -2
- package/dist/bin/chunks/fold-MAXEXDKA.js +0 -2
- package/dist/bin/chunks/grep-NXW3ZS2T.js +0 -2
- package/dist/bin/chunks/gzip-4TZR4OHX.js +0 -2
- package/dist/bin/chunks/head-BCMKSPGP.js +0 -2
- package/dist/bin/chunks/help-27WXVVW7.js +0 -2
- package/dist/bin/chunks/history-T6LTHEYW.js +0 -2
- package/dist/bin/chunks/hostname-QJD6DLJM.js +0 -2
- package/dist/bin/chunks/html-to-markdown-V7M7ZTGL.js +0 -2
- package/dist/bin/chunks/join-PWZ5VYJD.js +0 -2
- package/dist/bin/chunks/jq-XOCFM26Q.js +0 -2
- package/dist/bin/chunks/ln-X4VQOGPC.js +0 -2
- package/dist/bin/chunks/ls-O4UJCH3R.js +0 -2
- package/dist/bin/chunks/md5sum-2TRYEYPO.js +0 -2
- package/dist/bin/chunks/mkdir-Z65Y7YPB.js +0 -2
- package/dist/bin/chunks/mv-UULWKEXQ.js +0 -2
- package/dist/bin/chunks/nl-SIHFBFWW.js +0 -2
- package/dist/bin/chunks/od-YQTILXPI.js +0 -2
- package/dist/bin/chunks/paste-JA7SPT5I.js +0 -2
- package/dist/bin/chunks/printf-U3BAFNQW.js +0 -2
- package/dist/bin/chunks/pwd-JNTHRUS7.js +0 -2
- package/dist/bin/chunks/python3-BQAB3G6R.js +0 -14
- package/dist/bin/chunks/readlink-KGURBO5B.js +0 -2
- package/dist/bin/chunks/rev-TGHAXMHE.js +0 -2
- package/dist/bin/chunks/rg-PCNNZYUZ.js +0 -2
- package/dist/bin/chunks/rm-6BNEQYJH.js +0 -2
- package/dist/bin/chunks/rmdir-7PTJOZ3J.js +0 -2
- package/dist/bin/chunks/sed-IBSHYX2R.js +0 -2
- package/dist/bin/chunks/seq-WPCW5LYK.js +0 -2
- package/dist/bin/chunks/sha1sum-LHZ223LR.js +0 -2
- package/dist/bin/chunks/sha256sum-BFG6UGEY.js +0 -2
- package/dist/bin/chunks/sleep-HI2AX63U.js +0 -2
- package/dist/bin/chunks/sort-KLSRAA3S.js +0 -2
- package/dist/bin/chunks/split-OXHHEEHV.js +0 -2
- package/dist/bin/chunks/sqlite3-AKDJPDT5.js +0 -2
- package/dist/bin/chunks/stat-T6DAFOAE.js +0 -2
- package/dist/bin/chunks/strings-4AJIU4EW.js +0 -2
- package/dist/bin/chunks/tac-4GAH3XJY.js +0 -2
- package/dist/bin/chunks/tail-G2U2PW6H.js +0 -2
- package/dist/bin/chunks/tar-FYLHDP55.js +0 -2
- package/dist/bin/chunks/tee-T572YIXT.js +0 -2
- package/dist/bin/chunks/time-XSLSFXAR.js +0 -2
- package/dist/bin/chunks/timeout-ZPMBHNEN.js +0 -2
- package/dist/bin/chunks/touch-PKHKB4B2.js +0 -2
- package/dist/bin/chunks/tr-T7NEIDU6.js +0 -2
- package/dist/bin/chunks/tree-K2GININJ.js +0 -2
- package/dist/bin/chunks/true-JKHT73F3.js +0 -2
- package/dist/bin/chunks/unexpand-OAFTIEDP.js +0 -2
- package/dist/bin/chunks/uniq-2HGY5ABO.js +0 -2
- package/dist/bin/chunks/wc-ZTIOZ2H6.js +0 -2
- package/dist/bin/chunks/which-AHZHM3GH.js +0 -2
- package/dist/bin/chunks/whoami-IM7KVJBM.js +0 -2
- package/dist/bin/chunks/xan-EEBMX2PC.js +0 -2
- package/dist/bin/chunks/xan-view-Z7GM75UK.js +0 -2
- package/dist/bin/chunks/xargs-QPWVMTQK.js +0 -2
- package/dist/bin/chunks/yes-CK5F4N34.js +0 -2
- package/dist/bin/chunks/yq-R26WXE6W.js +0 -2
- package/dist/bin/shell/chunks/alias-VEEWI66Q.js +0 -2
- package/dist/bin/shell/chunks/awk2-LEBSBFO3.js +0 -2
- package/dist/bin/shell/chunks/base64-Q2G4GF6R.js +0 -2
- package/dist/bin/shell/chunks/basename-TNVKQHP5.js +0 -2
- package/dist/bin/shell/chunks/bash-E26LCUON.js +0 -2
- package/dist/bin/shell/chunks/cat-6WUYWK6Q.js +0 -2
- package/dist/bin/shell/chunks/chmod-YHG2ADMJ.js +0 -2
- package/dist/bin/shell/chunks/chunk-25DBXZPM.js +0 -100
- package/dist/bin/shell/chunks/chunk-272ZYGP4.js +0 -8
- package/dist/bin/shell/chunks/chunk-2KW5JZDM.js +0 -2
- package/dist/bin/shell/chunks/chunk-33EFJFXL.js +0 -10
- package/dist/bin/shell/chunks/chunk-3CCRFBBL.js +0 -23
- package/dist/bin/shell/chunks/chunk-3OP7VRO7.js +0 -6
- package/dist/bin/shell/chunks/chunk-3PIWDQZL.js +0 -19
- package/dist/bin/shell/chunks/chunk-4C26CCJR.js +0 -4
- package/dist/bin/shell/chunks/chunk-4G37X3GZ.js +0 -14
- package/dist/bin/shell/chunks/chunk-4KTWLZ5A.js +0 -8
- package/dist/bin/shell/chunks/chunk-55N7NX6G.js +0 -9
- package/dist/bin/shell/chunks/chunk-5OQOWWIB.js +0 -7
- package/dist/bin/shell/chunks/chunk-5WAR3CU3.js +0 -3
- package/dist/bin/shell/chunks/chunk-63VB22X2.js +0 -33
- package/dist/bin/shell/chunks/chunk-6KVPD5H7.js +0 -13
- package/dist/bin/shell/chunks/chunk-6OVV6A5W.js +0 -3
- package/dist/bin/shell/chunks/chunk-6PU2WD4P.js +0 -7
- package/dist/bin/shell/chunks/chunk-7ICAP454.js +0 -12
- package/dist/bin/shell/chunks/chunk-7QKMCOGE.js +0 -16
- package/dist/bin/shell/chunks/chunk-7SXBGUE4.js +0 -3
- package/dist/bin/shell/chunks/chunk-7VQY35S5.js +0 -8
- package/dist/bin/shell/chunks/chunk-7VVTANT2.js +0 -7
- package/dist/bin/shell/chunks/chunk-7XV5FI5D.js +0 -8
- package/dist/bin/shell/chunks/chunk-7Y5TZ5CE.js +0 -6
- package/dist/bin/shell/chunks/chunk-A2V4EW6Y.js +0 -10
- package/dist/bin/shell/chunks/chunk-ACV764YE.js +0 -5
- package/dist/bin/shell/chunks/chunk-AJBYK52Q.js +0 -36
- package/dist/bin/shell/chunks/chunk-BCE7PDXY.js +0 -32
- package/dist/bin/shell/chunks/chunk-BVWBX3A2.js +0 -9
- package/dist/bin/shell/chunks/chunk-COBNN6FR.js +0 -11
- package/dist/bin/shell/chunks/chunk-CVXSPZVY.js +0 -2
- package/dist/bin/shell/chunks/chunk-CX7XUPMH.js +0 -13
- package/dist/bin/shell/chunks/chunk-D2V2UKR2.js +0 -12
- package/dist/bin/shell/chunks/chunk-DD4R5YY7.js +0 -7
- package/dist/bin/shell/chunks/chunk-DN7JDLUW.js +0 -26
- package/dist/bin/shell/chunks/chunk-DVODFXEH.js +0 -5
- package/dist/bin/shell/chunks/chunk-EC57ABPL.js +0 -9
- package/dist/bin/shell/chunks/chunk-F7RPLNVE.js +0 -11
- package/dist/bin/shell/chunks/chunk-FEA5SLRN.js +0 -6
- package/dist/bin/shell/chunks/chunk-FJTEZ7ZL.js +0 -9
- package/dist/bin/shell/chunks/chunk-FO6UO5LY.js +0 -12
- package/dist/bin/shell/chunks/chunk-FYKWQWLG.js +0 -9
- package/dist/bin/shell/chunks/chunk-GETENI3B.js +0 -18
- package/dist/bin/shell/chunks/chunk-GTLVINNE.js +0 -4
- package/dist/bin/shell/chunks/chunk-H7WPPRUD.js +0 -2
- package/dist/bin/shell/chunks/chunk-HHBZ7ZEV.js +0 -5
- package/dist/bin/shell/chunks/chunk-IGPJA6SA.js +0 -17
- package/dist/bin/shell/chunks/chunk-J7REVEWS.js +0 -14
- package/dist/bin/shell/chunks/chunk-JHKFD4EI.js +0 -24
- package/dist/bin/shell/chunks/chunk-JUQT3ZM5.js +0 -23
- package/dist/bin/shell/chunks/chunk-LXRRE42A.js +0 -5
- package/dist/bin/shell/chunks/chunk-LYTEJIUW.js +0 -14
- package/dist/bin/shell/chunks/chunk-MFXVUOM3.js +0 -2
- package/dist/bin/shell/chunks/chunk-N3IFSXB3.js +0 -8
- package/dist/bin/shell/chunks/chunk-NHZGQ3Y7.js +0 -84
- package/dist/bin/shell/chunks/chunk-NIBKZJZM.js +0 -3
- package/dist/bin/shell/chunks/chunk-NJTMAMPV.js +0 -3
- package/dist/bin/shell/chunks/chunk-NQSOOEX5.js +0 -20
- package/dist/bin/shell/chunks/chunk-NVK6GU4P.js +0 -3
- package/dist/bin/shell/chunks/chunk-O4WYCXT4.js +0 -2
- package/dist/bin/shell/chunks/chunk-OJGWI2DA.js +0 -63
- package/dist/bin/shell/chunks/chunk-OXIM6UEO.js +0 -11
- package/dist/bin/shell/chunks/chunk-PLF6WISW.js +0 -10
- package/dist/bin/shell/chunks/chunk-PVAWMOD4.js +0 -8
- package/dist/bin/shell/chunks/chunk-PXK4KVSW.js +0 -73
- package/dist/bin/shell/chunks/chunk-Q2EFJFW4.js +0 -2
- package/dist/bin/shell/chunks/chunk-Q5UK2Q5U.js +0 -2
- package/dist/bin/shell/chunks/chunk-Q7XQB3YI.js +0 -7
- package/dist/bin/shell/chunks/chunk-RXYSXOZE.js +0 -287
- package/dist/bin/shell/chunks/chunk-SUC7ET2R.js +0 -14
- package/dist/bin/shell/chunks/chunk-SXGBKAL5.js +0 -16
- package/dist/bin/shell/chunks/chunk-T26GDTOU.js +0 -3
- package/dist/bin/shell/chunks/chunk-T67GIEZU.js +0 -2
- package/dist/bin/shell/chunks/chunk-TC7RJRFD.js +0 -16
- package/dist/bin/shell/chunks/chunk-TWWOPYOU.js +0 -5
- package/dist/bin/shell/chunks/chunk-UDJ6HRS4.js +0 -9
- package/dist/bin/shell/chunks/chunk-UQXDPK2T.js +0 -7
- package/dist/bin/shell/chunks/chunk-UREODEQQ.js +0 -21
- package/dist/bin/shell/chunks/chunk-VDS4FNGM.js +0 -7
- package/dist/bin/shell/chunks/chunk-VKE6V3ZO.js +0 -7
- package/dist/bin/shell/chunks/chunk-VTQCQCQO.js +0 -140
- package/dist/bin/shell/chunks/chunk-W4YU2U3A.js +0 -13
- package/dist/bin/shell/chunks/chunk-X4GHJ5JH.js +0 -6
- package/dist/bin/shell/chunks/chunk-XBI3O5AF.js +0 -9
- package/dist/bin/shell/chunks/chunk-XNMKTUHV.js +0 -6
- package/dist/bin/shell/chunks/chunk-ZTU6ENBH.js +0 -2
- package/dist/bin/shell/chunks/chunk-ZVROZHDE.js +0 -5
- package/dist/bin/shell/chunks/clear-Z6NC6SU4.js +0 -2
- package/dist/bin/shell/chunks/column-UMVTEOKJ.js +0 -2
- package/dist/bin/shell/chunks/comm-Q4W6PSZ3.js +0 -2
- package/dist/bin/shell/chunks/cp-CAN7P3HK.js +0 -2
- package/dist/bin/shell/chunks/curl-3PDMZXZI.js +0 -26
- package/dist/bin/shell/chunks/cut-BQM2BHFI.js +0 -2
- package/dist/bin/shell/chunks/date-XUF36E35.js +0 -2
- package/dist/bin/shell/chunks/diff-7GMSJUJG.js +0 -2
- package/dist/bin/shell/chunks/dirname-F7P24OLR.js +0 -2
- package/dist/bin/shell/chunks/du-HDXNSQIT.js +0 -2
- package/dist/bin/shell/chunks/echo-53OGHYIZ.js +0 -2
- package/dist/bin/shell/chunks/env-N4LYWUJ6.js +0 -2
- package/dist/bin/shell/chunks/expand-535WDY3S.js +0 -2
- package/dist/bin/shell/chunks/expansion-GOJYNUQR.js +0 -2
- package/dist/bin/shell/chunks/expr-Q7K5RKW2.js +0 -2
- package/dist/bin/shell/chunks/file-XMHYEYO5.js +0 -2
- package/dist/bin/shell/chunks/find-SJAABILU.js +0 -2
- package/dist/bin/shell/chunks/flag-coverage-TBMB7M2N.js +0 -2
- package/dist/bin/shell/chunks/fold-MAXEXDKA.js +0 -2
- package/dist/bin/shell/chunks/grep-NXW3ZS2T.js +0 -2
- package/dist/bin/shell/chunks/gzip-4TZR4OHX.js +0 -2
- package/dist/bin/shell/chunks/head-BCMKSPGP.js +0 -2
- package/dist/bin/shell/chunks/help-27WXVVW7.js +0 -2
- package/dist/bin/shell/chunks/history-T6LTHEYW.js +0 -2
- package/dist/bin/shell/chunks/hostname-QJD6DLJM.js +0 -2
- package/dist/bin/shell/chunks/html-to-markdown-V7M7ZTGL.js +0 -2
- package/dist/bin/shell/chunks/join-PWZ5VYJD.js +0 -2
- package/dist/bin/shell/chunks/jq-XOCFM26Q.js +0 -2
- package/dist/bin/shell/chunks/ln-X4VQOGPC.js +0 -2
- package/dist/bin/shell/chunks/ls-O4UJCH3R.js +0 -2
- package/dist/bin/shell/chunks/md5sum-2TRYEYPO.js +0 -2
- package/dist/bin/shell/chunks/mkdir-Z65Y7YPB.js +0 -2
- package/dist/bin/shell/chunks/mv-UULWKEXQ.js +0 -2
- package/dist/bin/shell/chunks/nl-SIHFBFWW.js +0 -2
- package/dist/bin/shell/chunks/od-YQTILXPI.js +0 -2
- package/dist/bin/shell/chunks/paste-JA7SPT5I.js +0 -2
- package/dist/bin/shell/chunks/printf-U3BAFNQW.js +0 -2
- package/dist/bin/shell/chunks/pwd-JNTHRUS7.js +0 -2
- package/dist/bin/shell/chunks/python3-BQAB3G6R.js +0 -14
- package/dist/bin/shell/chunks/readlink-KGURBO5B.js +0 -2
- package/dist/bin/shell/chunks/rev-TGHAXMHE.js +0 -2
- package/dist/bin/shell/chunks/rg-PCNNZYUZ.js +0 -2
- package/dist/bin/shell/chunks/rm-6BNEQYJH.js +0 -2
- package/dist/bin/shell/chunks/rmdir-7PTJOZ3J.js +0 -2
- package/dist/bin/shell/chunks/sed-IBSHYX2R.js +0 -2
- package/dist/bin/shell/chunks/seq-WPCW5LYK.js +0 -2
- package/dist/bin/shell/chunks/sha1sum-LHZ223LR.js +0 -2
- package/dist/bin/shell/chunks/sha256sum-BFG6UGEY.js +0 -2
- package/dist/bin/shell/chunks/sleep-HI2AX63U.js +0 -2
- package/dist/bin/shell/chunks/sort-KLSRAA3S.js +0 -2
- package/dist/bin/shell/chunks/split-OXHHEEHV.js +0 -2
- package/dist/bin/shell/chunks/sqlite3-AKDJPDT5.js +0 -2
- package/dist/bin/shell/chunks/stat-T6DAFOAE.js +0 -2
- package/dist/bin/shell/chunks/strings-4AJIU4EW.js +0 -2
- package/dist/bin/shell/chunks/tac-4GAH3XJY.js +0 -2
- package/dist/bin/shell/chunks/tail-G2U2PW6H.js +0 -2
- package/dist/bin/shell/chunks/tar-FYLHDP55.js +0 -2
- package/dist/bin/shell/chunks/tee-T572YIXT.js +0 -2
- package/dist/bin/shell/chunks/time-XSLSFXAR.js +0 -2
- package/dist/bin/shell/chunks/timeout-ZPMBHNEN.js +0 -2
- package/dist/bin/shell/chunks/touch-PKHKB4B2.js +0 -2
- package/dist/bin/shell/chunks/tr-T7NEIDU6.js +0 -2
- package/dist/bin/shell/chunks/tree-K2GININJ.js +0 -2
- package/dist/bin/shell/chunks/true-JKHT73F3.js +0 -2
- package/dist/bin/shell/chunks/unexpand-OAFTIEDP.js +0 -2
- package/dist/bin/shell/chunks/uniq-2HGY5ABO.js +0 -2
- package/dist/bin/shell/chunks/wc-ZTIOZ2H6.js +0 -2
- package/dist/bin/shell/chunks/which-AHZHM3GH.js +0 -2
- package/dist/bin/shell/chunks/whoami-IM7KVJBM.js +0 -2
- package/dist/bin/shell/chunks/xan-EEBMX2PC.js +0 -2
- package/dist/bin/shell/chunks/xan-view-Z7GM75UK.js +0 -2
- package/dist/bin/shell/chunks/xargs-QPWVMTQK.js +0 -2
- package/dist/bin/shell/chunks/yes-CK5F4N34.js +0 -2
- package/dist/bin/shell/chunks/yq-R26WXE6W.js +0 -2
- package/dist/bundle/chunks/alias-PFS6JBTL.js +0 -1
- package/dist/bundle/chunks/awk2-HG7QFRRO.js +0 -1
- package/dist/bundle/chunks/base64-UOYRM4DO.js +0 -1
- package/dist/bundle/chunks/basename-PRS2OP6R.js +0 -1
- package/dist/bundle/chunks/bash-UQXFZUPD.js +0 -1
- package/dist/bundle/chunks/cat-VI6AVTST.js +0 -1
- package/dist/bundle/chunks/chmod-5F3XJPPG.js +0 -1
- package/dist/bundle/chunks/chunk-2ERMTDAT.js +0 -1
- package/dist/bundle/chunks/chunk-2KW7BHBP.js +0 -5
- package/dist/bundle/chunks/chunk-2LC6GLRD.js +0 -10
- package/dist/bundle/chunks/chunk-2MWUJW7E.js +0 -13
- package/dist/bundle/chunks/chunk-2U6EPFDM.js +0 -4
- package/dist/bundle/chunks/chunk-4ECLUXYK.js +0 -5
- package/dist/bundle/chunks/chunk-4JZXWCPG.js +0 -2
- package/dist/bundle/chunks/chunk-4R3AYXSH.js +0 -6
- package/dist/bundle/chunks/chunk-4RPVMPGO.js +0 -4
- package/dist/bundle/chunks/chunk-4UNYQEQN.js +0 -6
- package/dist/bundle/chunks/chunk-525AJ4MJ.js +0 -9
- package/dist/bundle/chunks/chunk-54Z5HIDC.js +0 -7
- package/dist/bundle/chunks/chunk-5GE72EGR.js +0 -11
- package/dist/bundle/chunks/chunk-5HZ5BSXK.js +0 -1
- package/dist/bundle/chunks/chunk-5IUZJGTB.js +0 -99
- package/dist/bundle/chunks/chunk-5WPVRWBN.js +0 -12
- package/dist/bundle/chunks/chunk-63X77WZM.js +0 -15
- package/dist/bundle/chunks/chunk-6BNDUHW7.js +0 -72
- package/dist/bundle/chunks/chunk-6V3KZ3UR.js +0 -9
- package/dist/bundle/chunks/chunk-77R5SWIQ.js +0 -10
- package/dist/bundle/chunks/chunk-A6JH2Z2E.js +0 -7
- package/dist/bundle/chunks/chunk-AFZSOIRR.js +0 -1
- package/dist/bundle/chunks/chunk-AYQHTCJ6.js +0 -6
- package/dist/bundle/chunks/chunk-BJQSDFGC.js +0 -139
- package/dist/bundle/chunks/chunk-BOWOEGYM.js +0 -7
- package/dist/bundle/chunks/chunk-BXM5UMV3.js +0 -13
- package/dist/bundle/chunks/chunk-CDJANZJX.js +0 -5
- package/dist/bundle/chunks/chunk-CWN6Z4S3.js +0 -22
- package/dist/bundle/chunks/chunk-DGBRICQ7.js +0 -3
- package/dist/bundle/chunks/chunk-DGCTBS7B.js +0 -13
- package/dist/bundle/chunks/chunk-EBRN7NWX.js +0 -8
- package/dist/bundle/chunks/chunk-EHXIMSVW.js +0 -15
- package/dist/bundle/chunks/chunk-F2PTB6MB.js +0 -5
- package/dist/bundle/chunks/chunk-FTXRTVTE.js +0 -4
- package/dist/bundle/chunks/chunk-GNLJZOAK.js +0 -4
- package/dist/bundle/chunks/chunk-HACWJFGU.js +0 -1
- package/dist/bundle/chunks/chunk-HH6GYTGE.js +0 -13
- package/dist/bundle/chunks/chunk-HHGXJW4R.js +0 -6
- package/dist/bundle/chunks/chunk-HKR53LNA.js +0 -2
- package/dist/bundle/chunks/chunk-HZSJHPS7.js +0 -1
- package/dist/bundle/chunks/chunk-I3XSMOC3.js +0 -12
- package/dist/bundle/chunks/chunk-IYJXP33F.js +0 -1
- package/dist/bundle/chunks/chunk-JKPRCVTG.js +0 -6
- package/dist/bundle/chunks/chunk-K5ZCP6UY.js +0 -62
- package/dist/bundle/chunks/chunk-KMP3F7WZ.js +0 -17
- package/dist/bundle/chunks/chunk-KNKWEAIB.js +0 -4
- package/dist/bundle/chunks/chunk-KNU7V7YY.js +0 -8
- package/dist/bundle/chunks/chunk-KY5NMRVZ.js +0 -4
- package/dist/bundle/chunks/chunk-LHCQ2NLV.js +0 -6
- package/dist/bundle/chunks/chunk-M732FP7L.js +0 -2
- package/dist/bundle/chunks/chunk-MWKKYA7N.js +0 -19
- package/dist/bundle/chunks/chunk-MXTZUALD.js +0 -8
- package/dist/bundle/chunks/chunk-N52SZCYB.js +0 -2
- package/dist/bundle/chunks/chunk-N5W4XZNS.js +0 -32
- package/dist/bundle/chunks/chunk-NFM234IX.js +0 -23
- package/dist/bundle/chunks/chunk-NMWKV3TE.js +0 -9
- package/dist/bundle/chunks/chunk-O3BQP2BR.js +0 -7
- package/dist/bundle/chunks/chunk-ODBLLQG2.js +0 -35
- package/dist/bundle/chunks/chunk-OQWK6IJW.js +0 -1
- package/dist/bundle/chunks/chunk-OR2BZKU5.js +0 -31
- package/dist/bundle/chunks/chunk-OSYWE22E.js +0 -6
- package/dist/bundle/chunks/chunk-PJV5BSDQ.js +0 -8
- package/dist/bundle/chunks/chunk-PUYKMBEQ.js +0 -3
- package/dist/bundle/chunks/chunk-PXCZA2UF.js +0 -2
- package/dist/bundle/chunks/chunk-QDJ7TVPH.js +0 -2
- package/dist/bundle/chunks/chunk-QIE3SEPQ.js +0 -12
- package/dist/bundle/chunks/chunk-QIKTQFYF.js +0 -22
- package/dist/bundle/chunks/chunk-RDRBPOO3.js +0 -4
- package/dist/bundle/chunks/chunk-RO3SVOT2.js +0 -16
- package/dist/bundle/chunks/chunk-RQ7EV7AC.js +0 -7
- package/dist/bundle/chunks/chunk-RTIOH4X2.js +0 -1
- package/dist/bundle/chunks/chunk-RX22KJ4J.js +0 -10
- package/dist/bundle/chunks/chunk-SMDXZHIL.js +0 -8
- package/dist/bundle/chunks/chunk-SVBJBJ5T.js +0 -6
- package/dist/bundle/chunks/chunk-SYMUCSH2.js +0 -5
- package/dist/bundle/chunks/chunk-TPMG4TM3.js +0 -286
- package/dist/bundle/chunks/chunk-TYRM7VD4.js +0 -8
- package/dist/bundle/chunks/chunk-UL3YZMPQ.js +0 -8
- package/dist/bundle/chunks/chunk-V2LCHTLH.js +0 -15
- package/dist/bundle/chunks/chunk-V2U6WR7A.js +0 -11
- package/dist/bundle/chunks/chunk-WLD7KZYW.js +0 -6
- package/dist/bundle/chunks/chunk-WTU2M6ZH.js +0 -1
- package/dist/bundle/chunks/chunk-XG2PXUNT.js +0 -7
- package/dist/bundle/chunks/chunk-XREOVOVJ.js +0 -20
- package/dist/bundle/chunks/chunk-Y33UPDYF.js +0 -23
- package/dist/bundle/chunks/chunk-ZMLEPT2B.js +0 -2
- package/dist/bundle/chunks/chunk-ZVA3RKAH.js +0 -11
- package/dist/bundle/chunks/clear-AQF5Q2LP.js +0 -1
- package/dist/bundle/chunks/column-DTV4DT7Z.js +0 -1
- package/dist/bundle/chunks/comm-XNF4ZFIQ.js +0 -1
- package/dist/bundle/chunks/cp-O5R6UUTB.js +0 -1
- package/dist/bundle/chunks/curl-YF5UPZSP.js +0 -25
- package/dist/bundle/chunks/cut-A6AD4XLN.js +0 -1
- package/dist/bundle/chunks/date-5DATBXSY.js +0 -1
- package/dist/bundle/chunks/diff-4RUNUODF.js +0 -1
- package/dist/bundle/chunks/dirname-UXBVN4ZU.js +0 -1
- package/dist/bundle/chunks/du-URMOHN4N.js +0 -1
- package/dist/bundle/chunks/echo-BU4WS5NB.js +0 -1
- package/dist/bundle/chunks/env-PRCSFHFD.js +0 -1
- package/dist/bundle/chunks/expand-RSU7HJNU.js +0 -1
- package/dist/bundle/chunks/expansion-TBT2U5OQ.js +0 -1
- package/dist/bundle/chunks/expr-WHQ3N3VC.js +0 -1
- package/dist/bundle/chunks/file-OCSDEMRX.js +0 -1
- package/dist/bundle/chunks/find-KQBG3YXR.js +0 -1
- package/dist/bundle/chunks/flag-coverage-ZFQWXDD4.js +0 -1
- package/dist/bundle/chunks/fold-4XHCZTIH.js +0 -1
- package/dist/bundle/chunks/grep-MTDYJMIU.js +0 -1
- package/dist/bundle/chunks/gzip-JISR2QXU.js +0 -1
- package/dist/bundle/chunks/head-25BYUDHC.js +0 -1
- package/dist/bundle/chunks/help-A3QG3UR4.js +0 -1
- package/dist/bundle/chunks/history-GTNR2KMK.js +0 -1
- package/dist/bundle/chunks/hostname-4YOTMKM4.js +0 -1
- package/dist/bundle/chunks/html-to-markdown-3JPCPF2J.js +0 -1
- package/dist/bundle/chunks/join-KEFNDBL6.js +0 -1
- package/dist/bundle/chunks/jq-EBNRPZT5.js +0 -1
- package/dist/bundle/chunks/ln-TBYICXCX.js +0 -1
- package/dist/bundle/chunks/ls-C7B2SA5A.js +0 -1
- package/dist/bundle/chunks/md5sum-2VY2ODII.js +0 -1
- package/dist/bundle/chunks/mkdir-ZLWSOZZZ.js +0 -1
- package/dist/bundle/chunks/mv-VA4VIZE2.js +0 -1
- package/dist/bundle/chunks/nl-VNFLBUHM.js +0 -1
- package/dist/bundle/chunks/od-3KUUCW5I.js +0 -1
- package/dist/bundle/chunks/paste-5WOFHNWA.js +0 -1
- package/dist/bundle/chunks/printf-U3U7M7RB.js +0 -1
- package/dist/bundle/chunks/pwd-QYQ4FLB5.js +0 -1
- package/dist/bundle/chunks/python3-NDB2XLKG.js +0 -13
- package/dist/bundle/chunks/readlink-B3Y2BKAH.js +0 -1
- package/dist/bundle/chunks/rev-ROSGTRA6.js +0 -1
- package/dist/bundle/chunks/rg-F5QIE3YM.js +0 -1
- package/dist/bundle/chunks/rm-7JBDYEU5.js +0 -1
- package/dist/bundle/chunks/rmdir-A2RQAESC.js +0 -1
- package/dist/bundle/chunks/sed-T3Z6L6KJ.js +0 -1
- package/dist/bundle/chunks/seq-JDQVNKUK.js +0 -1
- package/dist/bundle/chunks/sha1sum-DQ6NXZL5.js +0 -1
- package/dist/bundle/chunks/sha256sum-OHTALYKZ.js +0 -1
- package/dist/bundle/chunks/sleep-T43AU6EO.js +0 -1
- package/dist/bundle/chunks/sort-NBGMSGSP.js +0 -1
- package/dist/bundle/chunks/split-KHHBFS6N.js +0 -1
- package/dist/bundle/chunks/sqlite3-XSQIVKH7.js +0 -1
- package/dist/bundle/chunks/stat-LL77MZ57.js +0 -1
- package/dist/bundle/chunks/strings-UEBU67ZB.js +0 -1
- package/dist/bundle/chunks/tac-GPG772JP.js +0 -1
- package/dist/bundle/chunks/tail-Z2TRGEQE.js +0 -1
- package/dist/bundle/chunks/tar-3BUIIPMD.js +0 -1
- package/dist/bundle/chunks/tee-ZZKDAZU6.js +0 -1
- package/dist/bundle/chunks/time-66YFGDFJ.js +0 -1
- package/dist/bundle/chunks/timeout-QN47GEC7.js +0 -1
- package/dist/bundle/chunks/touch-BOVDTDEU.js +0 -1
- package/dist/bundle/chunks/tr-LEOUNZSP.js +0 -1
- package/dist/bundle/chunks/tree-OLQFL5TR.js +0 -1
- package/dist/bundle/chunks/true-3GSKFWKO.js +0 -1
- package/dist/bundle/chunks/unexpand-AV4WTA4X.js +0 -1
- package/dist/bundle/chunks/uniq-RBOLK7C3.js +0 -1
- package/dist/bundle/chunks/wc-VYPMUZSO.js +0 -1
- package/dist/bundle/chunks/which-6QROVGQN.js +0 -1
- package/dist/bundle/chunks/whoami-NJ6ZQ54Y.js +0 -1
- package/dist/bundle/chunks/xan-IVSICJOO.js +0 -1
- package/dist/bundle/chunks/xan-view-JIIHMXCO.js +0 -1
- package/dist/bundle/chunks/xargs-QQG6OLB3.js +0 -1
- package/dist/bundle/chunks/yes-JBIBIE7V.js +0 -1
- package/dist/bundle/chunks/yq-RIVAIAQ2.js +0 -1
package/dist/bin/just-bash.js
CHANGED
|
@@ -1,158 +1,149 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{A as ps,C as xr,D as Or,E as me,F as je,G as oe,H as ke,I as Ot,J as Tr,K as V,L as Dr,M as Ir,N as Oe,O as ms,P as Tt,Q as Ze,R as X,a as Sr,b as cs,c as Er,d as $r,e as Nt,f as re,g as G,h as Pe,i as le,j as Ne,k as We,l as us,m as xt,n as Ar,o as fs,p as _r,q as pe,r as Re,s as kr,t as Cr,u as ds,v as hs,w as xe,x as Pr,y as Nr,z as _e}from"./chunks/chunk-PXK4KVSW.js";import{a as br}from"./chunks/chunk-RUESYAVK.js";import{a as Me,b as Ae}from"./chunks/chunk-CAXM2HMK.js";import{a as ft}from"./chunks/chunk-N7YAMUQG.js";import{a as ve,b as be,c as he,d as Ee,e as wr,f as Z,g as Be,h as kt,i as Ct,j as vr,k as ue,l as Fe,m as Pt,n as $e}from"./chunks/chunk-PVAWMOD4.js";import"./chunks/chunk-OBH7XN5N.js";import{a as Ie}from"./chunks/chunk-4VDEBYW7.js";import{a as ct,b as w,c as se,d as de,e as N,f as Y,g as qe,h as D,i as ls,j as ut}from"./chunks/chunk-2KW5JZDM.js";import{a as _t,g as F,h as B,i as H,j as gr,k as lt,l as O,m as g}from"./chunks/chunk-463VWH7H.js";import{resolve as hi}from"node:path";var Ye=[{name:"echo",load:async()=>(await import("./chunks/echo-53OGHYIZ.js")).echoCommand},{name:"cat",load:async()=>(await import("./chunks/cat-6WUYWK6Q.js")).catCommand},{name:"printf",load:async()=>(await import("./chunks/printf-U3BAFNQW.js")).printfCommand},{name:"ls",load:async()=>(await import("./chunks/ls-O4UJCH3R.js")).lsCommand},{name:"mkdir",load:async()=>(await import("./chunks/mkdir-Z65Y7YPB.js")).mkdirCommand},{name:"rmdir",load:async()=>(await import("./chunks/rmdir-7PTJOZ3J.js")).rmdirCommand},{name:"touch",load:async()=>(await import("./chunks/touch-PKHKB4B2.js")).touchCommand},{name:"rm",load:async()=>(await import("./chunks/rm-6BNEQYJH.js")).rmCommand},{name:"cp",load:async()=>(await import("./chunks/cp-CAN7P3HK.js")).cpCommand},{name:"mv",load:async()=>(await import("./chunks/mv-UULWKEXQ.js")).mvCommand},{name:"ln",load:async()=>(await import("./chunks/ln-X4VQOGPC.js")).lnCommand},{name:"chmod",load:async()=>(await import("./chunks/chmod-YHG2ADMJ.js")).chmodCommand},{name:"pwd",load:async()=>(await import("./chunks/pwd-JNTHRUS7.js")).pwdCommand},{name:"readlink",load:async()=>(await import("./chunks/readlink-KGURBO5B.js")).readlinkCommand},{name:"head",load:async()=>(await import("./chunks/head-BCMKSPGP.js")).headCommand},{name:"tail",load:async()=>(await import("./chunks/tail-G2U2PW6H.js")).tailCommand},{name:"wc",load:async()=>(await import("./chunks/wc-ZTIOZ2H6.js")).wcCommand},{name:"stat",load:async()=>(await import("./chunks/stat-T6DAFOAE.js")).statCommand},{name:"grep",load:async()=>(await import("./chunks/grep-NXW3ZS2T.js")).grepCommand},{name:"fgrep",load:async()=>(await import("./chunks/grep-NXW3ZS2T.js")).fgrepCommand},{name:"egrep",load:async()=>(await import("./chunks/grep-NXW3ZS2T.js")).egrepCommand},{name:"rg",load:async()=>(await import("./chunks/rg-PCNNZYUZ.js")).rgCommand},{name:"sed",load:async()=>(await import("./chunks/sed-IBSHYX2R.js")).sedCommand},{name:"awk",load:async()=>(await import("./chunks/awk2-LEBSBFO3.js")).awkCommand2},{name:"sort",load:async()=>(await import("./chunks/sort-KLSRAA3S.js")).sortCommand},{name:"uniq",load:async()=>(await import("./chunks/uniq-2HGY5ABO.js")).uniqCommand},{name:"comm",load:async()=>(await import("./chunks/comm-Q4W6PSZ3.js")).commCommand},{name:"cut",load:async()=>(await import("./chunks/cut-BQM2BHFI.js")).cutCommand},{name:"paste",load:async()=>(await import("./chunks/paste-JA7SPT5I.js")).pasteCommand},{name:"tr",load:async()=>(await import("./chunks/tr-T7NEIDU6.js")).trCommand},{name:"rev",load:async()=>(await import("./chunks/rev-TGHAXMHE.js")).rev},{name:"nl",load:async()=>(await import("./chunks/nl-SIHFBFWW.js")).nl},{name:"fold",load:async()=>(await import("./chunks/fold-MAXEXDKA.js")).fold},{name:"expand",load:async()=>(await import("./chunks/expand-535WDY3S.js")).expand},{name:"unexpand",load:async()=>(await import("./chunks/unexpand-OAFTIEDP.js")).unexpand},{name:"strings",load:async()=>(await import("./chunks/strings-4AJIU4EW.js")).strings},{name:"split",load:async()=>(await import("./chunks/split-OXHHEEHV.js")).split},{name:"column",load:async()=>(await import("./chunks/column-UMVTEOKJ.js")).column},{name:"join",load:async()=>(await import("./chunks/join-PWZ5VYJD.js")).join},{name:"tee",load:async()=>(await import("./chunks/tee-T572YIXT.js")).teeCommand},{name:"find",load:async()=>(await import("./chunks/find-SJAABILU.js")).findCommand},{name:"basename",load:async()=>(await import("./chunks/basename-TNVKQHP5.js")).basenameCommand},{name:"dirname",load:async()=>(await import("./chunks/dirname-F7P24OLR.js")).dirnameCommand},{name:"tree",load:async()=>(await import("./chunks/tree-K2GININJ.js")).treeCommand},{name:"du",load:async()=>(await import("./chunks/du-HDXNSQIT.js")).duCommand},{name:"env",load:async()=>(await import("./chunks/env-N4LYWUJ6.js")).envCommand},{name:"printenv",load:async()=>(await import("./chunks/env-N4LYWUJ6.js")).printenvCommand},{name:"alias",load:async()=>(await import("./chunks/alias-VEEWI66Q.js")).aliasCommand},{name:"unalias",load:async()=>(await import("./chunks/alias-VEEWI66Q.js")).unaliasCommand},{name:"history",load:async()=>(await import("./chunks/history-T6LTHEYW.js")).historyCommand},{name:"xargs",load:async()=>(await import("./chunks/xargs-QPWVMTQK.js")).xargsCommand},{name:"true",load:async()=>(await import("./chunks/true-JKHT73F3.js")).trueCommand},{name:"false",load:async()=>(await import("./chunks/true-JKHT73F3.js")).falseCommand},{name:"clear",load:async()=>(await import("./chunks/clear-Z6NC6SU4.js")).clearCommand},{name:"yes",load:async()=>(await import("./chunks/yes-CK5F4N34.js")).yesCommand},{name:"bash",load:async()=>(await import("./chunks/bash-E26LCUON.js")).bashCommand},{name:"sh",load:async()=>(await import("./chunks/bash-E26LCUON.js")).shCommand},{name:"jq",load:async()=>(await import("./chunks/jq-XOCFM26Q.js")).jqCommand},{name:"base64",load:async()=>(await import("./chunks/base64-Q2G4GF6R.js")).base64Command},{name:"diff",load:async()=>(await import("./chunks/diff-7GMSJUJG.js")).diffCommand},{name:"date",load:async()=>(await import("./chunks/date-XUF36E35.js")).dateCommand},{name:"sleep",load:async()=>(await import("./chunks/sleep-HI2AX63U.js")).sleepCommand},{name:"timeout",load:async()=>(await import("./chunks/timeout-ZPMBHNEN.js")).timeoutCommand},{name:"time",load:async()=>(await import("./chunks/time-XSLSFXAR.js")).timeCommand},{name:"seq",load:async()=>(await import("./chunks/seq-WPCW5LYK.js")).seqCommand},{name:"expr",load:async()=>(await import("./chunks/expr-Q7K5RKW2.js")).exprCommand},{name:"md5sum",load:async()=>(await import("./chunks/md5sum-2TRYEYPO.js")).md5sumCommand},{name:"sha1sum",load:async()=>(await import("./chunks/sha1sum-LHZ223LR.js")).sha1sumCommand},{name:"sha256sum",load:async()=>(await import("./chunks/sha256sum-BFG6UGEY.js")).sha256sumCommand},{name:"file",load:async()=>(await import("./chunks/file-XMHYEYO5.js")).fileCommand},{name:"html-to-markdown",load:async()=>(await import("./chunks/html-to-markdown-V7M7ZTGL.js")).htmlToMarkdownCommand},{name:"help",load:async()=>(await import("./chunks/help-27WXVVW7.js")).helpCommand},{name:"which",load:async()=>(await import("./chunks/which-AHZHM3GH.js")).whichCommand},{name:"tac",load:async()=>(await import("./chunks/tac-4GAH3XJY.js")).tac},{name:"hostname",load:async()=>(await import("./chunks/hostname-QJD6DLJM.js")).hostname},{name:"whoami",load:async()=>(await import("./chunks/whoami-IM7KVJBM.js")).whoami},{name:"od",load:async()=>(await import("./chunks/od-YQTILXPI.js")).od},{name:"gzip",load:async()=>(await import("./chunks/gzip-4TZR4OHX.js")).gzipCommand},{name:"gunzip",load:async()=>(await import("./chunks/gzip-4TZR4OHX.js")).gunzipCommand},{name:"zcat",load:async()=>(await import("./chunks/gzip-4TZR4OHX.js")).zcatCommand}];(typeof __BROWSER__>"u"||!__BROWSER__)&&(Ye.push({name:"tar",load:async()=>(await import("./chunks/tar-FYLHDP55.js")).tarCommand}),Ye.push({name:"yq",load:async()=>(await import("./chunks/yq-R26WXE6W.js")).yqCommand}),Ye.push({name:"xan",load:async()=>(await import("./chunks/xan-EEBMX2PC.js")).xanCommand}),Ye.push({name:"sqlite3",load:async()=>(await import("./chunks/sqlite3-AKDJPDT5.js")).sqlite3Command}));var ys=[];(typeof __BROWSER__>"u"||!__BROWSER__)&&(ys.push({name:"python3",load:async()=>(await import("./chunks/python3-BQAB3G6R.js")).python3Command}),ys.push({name:"python",load:async()=>(await import("./chunks/python3-BQAB3G6R.js")).pythonCommand}));var wi=[{name:"curl",load:async()=>(await import("./chunks/curl-3PDMZXZI.js")).curlCommand}],Rr=new Map;function gs(e){return{name:e.name,async execute(t,s){let r=Rr.get(e.name);if(r||(r=await e.load(),Rr.set(e.name,r)),s.coverage&&(typeof __BROWSER__>"u"||!__BROWSER__)){let{emitFlagCoverage:n}=await import("./chunks/flag-coverage-TBMB7M2N.js"),{decodeArgs:i}=await import("./chunks/bytes-C34BYEMS.js");n(s.coverage,e.name,i(t))}return r.execute(t,s)}}}function Lr(e){return(e?Ye.filter(s=>e.includes(s.name)):Ye).map(gs)}function Fr(){return wi.map(gs)}function Mr(){return ys.map(gs)}function Wr(e){return"load"in e&&typeof e.load=="function"}function zr(e){let t=null;return{name:e.name,async execute(s,r){return t||(t=await e.load()),t.execute(s,r)}}}var vi=new TextEncoder;function bi(e){return typeof e=="object"&&e!==null&&typeof e.getReader=="function"}function Si(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 vi.encode(e)}function Br(e){if(e.length===0)return[];if(e.length<=ct)return[e];let t=[];for(let s=0;s<e.length;s+=ct)t.push(e.subarray(s,Math.min(s+ct,e.length)));return t}function Xe(e,t){let s=Si(e,t);return{chunks:Br(s),size:s.length}}async function Ke(e,t){if(bi(e)){let s=[],r=0;for await(let n of ut(e))if(n.length<=ct)s.push(n),r+=n.length;else for(let i of Br(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(br(Vr(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(Vr(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 Vr(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 Le(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 Ei(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 dt=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(Ei(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=Le(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 de(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=Le(s);return Dt(n.chunks,i)}async writeFile(t,s,r){ne(t,"write");let n=this.normalizePath(t);this.ensureParentDirs(n);let i=Le(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=Le(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 Ai(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 _i(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 ki(e){e.mkdirSync("/proc/self/fd",{recursive:!0}),e.writeFileSync("/proc/version",`${Sr}
|
|
2
|
+
import{$ as yr,A as Fs,B as Kt,C as ar,D as Vs,E as lr,F as ve,G as Be,H as cr,I as ur,J as zs,K as js,L as Me,M as fr,N as dr,O as Ne,P as Bs,R as hr,S as pr,T as be,U as et,V as ue,W as Oe,X as Xt,Y as mr,Z as z,_ as gr,a as rr,aa as We,b as Ls,ba as wr,c as ir,ca as vr,d as or,da as it,e as Zt,ea as Q,f as le,g as Z,h as Ie,i as Jt,j as Qe,k as Ms,l as Ws,m as Re,n as Pt,o as _t,p as U,q as Pe,r as K,s as xt,t as X,u as ee,v as qe,w as te,x as he,y as Le,z as Ze}from"./chunks/chunk-73X3QWRT.js";import{a as kt}from"./chunks/chunk-JGKR7YR7.js";import{a as nr}from"./chunks/chunk-RUESYAVK.js";import{a as Ge,b as ke}from"./chunks/chunk-CAXM2HMK.js";import{a as Ct}from"./chunks/chunk-N7YAMUQG.js";import{a as $e,b as Ae,c as ye,d as Ce,e as er,f as q,g as Xe,h as At,i as Gt,j as tr,k as oe,l as sr,m as pe,n as Ye,o as ze,p as qt,q as we}from"./chunks/chunk-A257OMG4.js";import"./chunks/chunk-OBH7XN5N.js";import{a as je}from"./chunks/chunk-4VDEBYW7.js";import{a as St,b as E,d as de,e as Et,f as V,g as ie,h as Rs,i as rt,j as $t}from"./chunks/chunk-6VQWCKYE.js";import{a as Ut,g as L,h as F,i as H,j as Qn,k as bt,l as T,m as y}from"./chunks/chunk-463VWH7H.js";import{resolve as Yi}from"node:path";var ot=[{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__)&&(ot.push({name:"tar",load:async()=>(await import("./chunks/tar-BAKR5OJO.js")).tarCommand}),ot.push({name:"yq",load:async()=>(await import("./chunks/yq-ZHYSTGN3.js")).yqCommand}),ot.push({name:"xan",load:async()=>(await import("./chunks/xan-STBKXZ5W.js")).xanCommand}),ot.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 no=[{name:"curl",load:async()=>(await import("./chunks/curl-YFYJ2XNC.js")).curlCommand}],br=new Map;function Us(e){return{name:e.name,async execute(t,s){let n=br.get(e.name);if(n||(n=await e.load(),br.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 Sr(e){return(e?ot.filter(s=>e.includes(s.name)):ot).map(Us)}function Er(){return no.map(Us)}function $r(){return Hs.map(Us)}function Ar(e){return"load"in e&&typeof e.load=="function"}function Cr(e){let t=null;return{name:e.name,async execute(s,n){return t||(t=await e.load()),t.execute(s,n)}}}var ro=new TextEncoder;function io(e){return typeof e=="object"&&e!==null&&typeof e.getReader=="function"}function oo(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 ro.encode(e)}function Pr(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 at(e,t){let s=oo(e,t);return{chunks:Pr(s),size:s.length}}async function lt(e,t){if(io(e)){let s=[],n=0;for await(let r of $t(e))if(r.length<=St)s.push(r),n+=r.length;else for(let i of Pr(r))s.push(i),n+=i.length;return{chunks:s,size:n}}return at(e,t)}function Yt(e,t){if(t==="base64")return btoa(nr(kr(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(kr(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 kr(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 He(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 ao(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(ao(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=He(n),{chunks:o,size:l}=at(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=He(s);return Yt(r.chunks,i)}async writeFile(t,s,n){ce(t,"write");let r=this.normalizePath(t);this.ensureParentDirs(r);let i=He(n),{chunks:a,size:o}=await lt(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=He(n),{chunks:o,size:l}=await lt(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 lo(e){let t=e;return typeof t.mkdirSync=="function"&&typeof t.writeFileSync=="function"}function co(e,t){e.mkdirSync("/bin",{recursive:!0}),e.mkdirSync("/usr/bin",{recursive:!0}),t&&(e.mkdirSync("/home/user",{recursive:!0}),e.mkdirSync("/tmp",{recursive:!0}))}function uo(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 fo(e){e.mkdirSync("/proc/self/fd",{recursive:!0}),e.writeFileSync("/proc/version",`${rr}
|
|
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 He(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 He(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 He(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 He(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=ji(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 He(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 He(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 hn(e,t){if(e.state.options.posix&&Cs.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 Ui(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",ir()),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 _r(e,t){lo(e)&&(co(e,t),uo(e),fo(e))}var ho=["allexport","errexit","noglob","noclobber","noexec","nounset","pipefail","posix","verbose","xtrace"],po=["braceexpand","hashall","interactive-comments"];function Gs(e){let t=[],s=[...po.map(n=>({name:n,enabled:!0})),...ho.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 ct(e){y(e.state.env,"SHELLOPTS",Gs(e.state.options))}var mo=["dotglob","expand_aliases","extglob","failglob","globskipdots","globstar","lastpipe","nocaseglob","nocasematch","nullglob","xpg_echo"];function qs(e){let t=[];for(let s of mo)e[s]&&t.push(s);return t.join(":")}function Zs(e){y(e.state.env,"BASHOPTS",qs(e.state.shoptOptions))}var go="BASH_ALIAS_";function xr(e){return e.parts.length!==1?!1:e.parts[0].type==="Literal"}function Tr(e){if(e.parts.length!==1)return null;let t=e.parts[0];return t.type==="Literal"?t.value:null}function Nr(e,t){let s=e.env.get(`${go}${t}`);return s!==void 0?H(s):void 0}function Js(e,t,s){if(!t.name||!xr(t.name))return t;let n=Tr(t.name);if(!n)return t;let r=Nr(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=Dr(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 Or(t,r);let u=l.statements[0].pipelines[0].commands[0];if(u.type!=="SimpleCommand")return Or(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(xr(f)){let d=Tr(f);if(d&&Nr(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 Or(e,t){let s=t;for(let a of e.args){let o=Dr(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 Dr(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 Ir(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 We(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 Rr(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 yo=["tar","yq","xan","sqlite3","python3","python"];function Lr(e){return yo.includes(e)}function B(){return{stdout:E(),stderr:E(),exitCode:0}}var ut={get stdout(){return E()},get stderr(){return E()},exitCode:0};function _e(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?de(e):e,stderr:t instanceof Uint8Array?de(t):t,exitCode:s}}function ae(e){return{stdout:E(),stderr:E(),exitCode:e?0:1}}function De(e,t){throw new oe(e,t)}async function Ks(e,t){if(e.state.loopDepth===0){if(e.state.parentHasLoopContext)throw new ze;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 $e(s)}async function Xs(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=T(e.state.env,"HOME","/"):a[0]==="~"?s=T(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
|
+
`):_e()}function Ys(e,t){return e.fs.resolvePath(e.state.cwd,t)}var wo=["-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 wo.includes(e)}async function ss(e,t,s){let n=Ys(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 vo=["-nt","-ot","-ef"];function ns(e){return vo.includes(e)}async function rs(e,t,s,n){let r=Ys(e,s),i=Ys(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 bo=new Set(["-eq","-ne","-lt","-le","-gt","-ge"]);function is(e){return bo.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 Nt(e){return e==="="||e==="=="||e==="!="}function as(e,t,s,n=!1,r=!1,i=!1){if(n){let o=ft(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 So=new Set(["-z","-n"]);function ls(e){return So.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)=>T(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=T(e.state.env,r);a=o?Number.parseInt(o,10):0}}if(a<0){let o=he(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)?Ze(e,t).length>0:he(e,t).length>0}async function Je(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=pr(i)}else r=await gr(e,t.right);else Nt(t.operator)&&!n?r=await yr(e,t.right):r=await z(e,t.right);if(Nt(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 Wr(e,s),await Wr(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=Co(r),l=Ct(a,i?"i":"").match(s);if(Le(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 Je(e,t.operand);case"CondAnd":return await Je(e,t.left)?await Je(e,t.right):!1;case"CondOr":return await Je(e,t.left)?!0:await Je(e,t.right);case"CondGroup":return await Je(e,t.expression);case"CondWord":return await z(e,t.word)!=="";default:return!1}}async function Ot(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(Nt(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 Ot(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 Ot(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 Ot(e,[t[1],t[2]])}let s=await Vr(e,t,0);return s.pos<t.length?A(`test: too many arguments
|
|
14
|
+
`,2):ae(s.value)}async function Vr(e,t,s){return Eo(e,t,s)}async function Eo(e,t,s){let{value:n,pos:r}=await Mr(e,t,s);for(;t[r]==="-o";){let i=await Mr(e,t,r+1);n=n||i.value,r=i.pos}return{value:n,pos:r}}async function Mr(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 $o(e,t,s)}async function $o(e,t,s){let n=t[s];if(n==="("){let{value:i,pos:a}=await Vr(e,t,s+1);return{value:i,pos:t[a]===")"?a+1:a}}let r=t[s+1];if(Nt(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 ft(e,t,s=!1,n=!1){let r=`^${zr(t,n)}$`;return Ct(r,s?"is":"s").test(e)}function zr(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=jr(e,n+1);if(i!==-1){let a=e.slice(n+2,i),o=Br(a),l=o.map(c=>zr(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=>Hr(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 jr(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 Br(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 Hr(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=jr(e,n+1);if(i!==-1){if(r==="@"){let a=e.slice(n+2,i),l=Br(a).map(u=>Hr(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 Wr(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 Fr(t);try{let s=new Z,n=le(s,t);return await Q(e,n.expression)}catch{return Fr(t)}}function Ao(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 Fr(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=Ao(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 Co(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=ko(e,s);t+=n.converted,s=n.endIndex}else t+=e[s],s++;return t}function ko(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+=Po(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 Po(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 Fe(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 Ur(e){let t=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(t)return{name:t[1],isArray:!0,arrayElements:Fe(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 _o(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 Gr(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 _o(e,o);y(e.state.env,`${n}_${c}`,a);let f=parseInt(T(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&&be(e,n),null}function Ke(e,t){e.state.localVarDepth=e.state.localVarDepth||new Map,e.state.localVarDepth.set(t,e.state.callDepth)}function dt(e,t){return e.state.localVarDepth?.get(t)}function hs(e,t){e.state.localVarDepth?.delete(t)}function qr(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 Zr(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 Jr(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","[[","]]","!"]),Ue=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 Dt(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 Kr(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==="<&"?wr(e,t.target)?{error:`bash: $@: ambiguous redirect
|
|
18
|
+
`}:{target:await z(e,t.target)}:vr(e,t.target)}function nn(e){return e.includes("\0")?`bash: ${e.replace(/\0/g,"")}: No such file or directory
|
|
19
|
+
`:null}function Ve(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 ht(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(T(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(Ve(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 xo={write(){}},To={write(){let e=new Error(`bash: echo: write error: No space left on device
|
|
23
|
+
`);return e.code="ENOSPC",Promise.reject(e)}};function No(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 Yr(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=Yr(e,t,l,n))}return o&&t.bindings.set(s,{...r,sink:o}),o}async function Xr(e,t,s,n,r=!1){if(s==="/dev/null")return{sink:xo,descriptor:"__file__:/dev/null"};if(s==="/dev/full")return{sink:To,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:Ve(o)}}let i=e.fs.resolvePath(e.state.cwd,s),a=await Kr(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 tt(e,t,s){e.state.fileDescriptors||(e.state.fileDescriptors=new Map),e.state.fileDescriptors.set(t,s)}function Oo(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__:")){tt(e,s,`__file__:${n.slice(16)}`);return}tt(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 Te(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(No(o)){if(o.fdVariable&&o.target.type==="Word"){let S=await ht(e,[o],v=>Ws(r,v));if(S)return{channels:r,legacyRedirections:i,error:S};let $=Number.parseInt(T(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(T(e.state.env,o.fdVariable),10);if(!Number.isNaN(S)){let $=r.bindings.get(S)?.descriptor,g=_t(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,Ve(f));if(o.operator===">"||o.operator===">|"||o.operator===">>"||o.operator==="&>"||o.operator==="&>>"){let S=o.operator===">>"||o.operator==="&>>",$=await Xr(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&&(tt(e,1,$.descriptor),tt(e,2,$.descriptor))):(o.fdVariable?Pt(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=Yr(e,r,h);if(!S){let g=r.bindings.get(h)?.descriptor;if(g===Jt)return xe(r,i,Ve(h));if(o.operator==="<&"&&o.fdVariable&&g!==void 0){if(r.bindings.set(f,{descriptor:g}),tt(e,f,g),d){let v=_t(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,Ve(h))}let $=Oo(r,h);if(o.fdVariable?Pt(r,f,S,$):r.bindings.set(f,{sink:S,descriptor:$}),an(e,o,f,$,a),d){let g=!0;o.fdVariable?g=_t(r,h):(r.overrides?.add(h),r.bindings.set(h,{descriptor:Jt}),n.persistMovedSource&&r.parent&&(g=_t(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 Xr(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&&(tt(e,1,b.descriptor),tt(e,2,b.descriptor))):(o.fdVariable?Pt(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 Qr(e,t){let s=e.outputChannels,n=await Te(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&&Pt(s,r,i.sink,i.descriptor)}return{...n,channels:s}}async function ei(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 Do(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--,De(`${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),T(e.state.env,String(o+1))),y(e.state.env,String(o+1),s[o]);i.set("@",T(e.state.env,"@")),i.set("#",T(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(Zr(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 Te(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 ht(e,o.legacyRedirections);if(l)return await te(e,()=>Promise.resolve(l));let u=await ie(n),c=u.length>0?de(u):await Do(e,o.legacyRedirections),f=await e.executeCommand(t.body,c);return await te(e,()=>Promise.resolve(f))}catch(l){let{writeFailure:u}=await qe(e,l);if(u)return u;if(l instanceof ye)return W(E(),E(),l.exitCode);throw l}})}catch(o){throw await ee(e,o),o}finally{a()}}var si=["!","[[","]]","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"],Io=["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"],Ro=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 ti(e,a);h.push(...v)}for(let v of s)if(v==="variable"){let C=Lo(e,a);h.push(...C)}else if(v==="export"){let C=Mo(e,a);h.push(...C)}else if(v==="function"){let C=Wo(e,a);h.push(...C)}else if(v==="builtin"){let C=Fo(a);h.push(...C)}else if(v==="keyword"){let C=Vo(a);h.push(...C)}else if(v==="alias"){let C=zo(e,a);h.push(...C)}else if(v==="shopt"){let C=jo(a);h.push(...C)}else if(v==="helptopic"){let C=Bo(a);h.push(...C)}else if(v==="directory"){let C=await ln(e,a);h.push(...C)}else if(v==="file"){let C=await ti(e,a);h.push(...C)}else if(v==="user"){let C=Ho(a);h.push(...C)}else if(v==="command"){let C=await Uo(e,a);h.push(...C)}if(n!==null)try{let v=await Go(e,n),C=qo(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",T(e.state.env,"COMP_WORDS__length")),y(e.state.env,"COMP_WORDS__length","0"),C.set("COMP_CWORD",T(e.state.env,"COMP_CWORD")),y(e.state.env,"COMP_CWORD","-1"),C.set("COMP_LINE",T(e.state.env,"COMP_LINE")),y(e.state.env,"COMP_LINE",""),C.set("COMP_POINT",T(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,T(e.state.env,P)),e.state.env.delete(P));let I=["compgen",p[0]??"",""];try{let P=Pe(),k=Pe(),O=await K(e,{bindings:new Map([[1,{sink:P}],[2,{sink:k}]])},()=>vs(e,v,I,E()));if(await xt(e,O.stderr,k),O.exitCode!==0)return pt(e,C),pt(e,N),W(L,k.stream(),1);await xt(e,O.stdout,P),b=H(await ie(P.stream()));let R=Zo(e);h.push(...R)}catch{return pt(e,C),pt(e,N),W(L,L,1)}pt(e,C),pt(e,N)}}if(d!==null)try{let v=Ie(d),C=Pe(),N=Pe(),I=await K(e,{bindings:new Map([[1,{sink:C}],[2,{sink:N}]])},()=>e.executeScript(v));if(await xt(e,I.stderr,N),I.exitCode!==0)return W(L,N.stream(),I.exitCode);await xt(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=ft(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 Lo(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 Mo(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 Wo(e,t){let s=Array.from(e.state.functions.keys());return t!==null&&(s=s.filter(n=>n.startsWith(t))),s.sort()}function Fo(e){let t=[...cn];return e!==null&&(t=t.filter(s=>s.startsWith(e))),t.sort()}function Vo(e){let t=[...si];return e!==null&&(t=t.filter(s=>s.startsWith(e))),t.sort()}function zo(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 jo(e){let t=[...Io];return e!==null&&(t=t.filter(s=>s.startsWith(e))),t.sort()}function Bo(e){let t=[...Ro];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 ti(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 Ho(e){return["root","nobody"]}async function Uo(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 si)s.add(i);let n=T(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 Go(e,t){let n=new Z().parseWordFromString(t,!1,!1);return await z(e,n)}function qo(e,t){let s=T(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 pt(e,t){for(let[s,n]of t)n===void 0?e.state.env.delete(s):y(e.state.env,s,n)}function Zo(e){let t=[];if(e.state.env.get("COMPREPLY__length")!==void 0){let r=Ne(e,"COMPREPLY");for(let[,i]of r)t.push(i)}else e.state.env.has("COMPREPLY")&&t.push(T(e.state.env,"COMPREPLY"));return t}var Jo=["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(!Jo.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(),_e();for(let f of c)e.state.completionSpecs.delete(f);return _e()}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),_e()}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 _e()}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 _e()}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?_e():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 ni=["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(!ni.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(!ni.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),_e()}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),_e()}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 _e()}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 ze;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 Ae(s)}function se(e,t){let s=T(e.state.env,"HOME","/home/user");return t.split(":").map(i=>i==="~"?s:i==="~root"?"/root":i.startsWith("~/")?s+i.slice(1):i.startsWith("~root/")?`/root${i.slice(5)}`:i).join(":")}function 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 st(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 ri(e,t){let s="";return e.state.integerVars?.has(t)&&(s+="i"),e.state.lowercaseVars?.has(t)&&(s+="l"),ve(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 ii(e,t){let s="",n="",r=!1;for(let i of t){let a=ri(e,i);if(e.state.associativeArrays?.has(i)){let u=Ze(e,i);if(u.length===0)s+=`declare -A ${i}=()
|
|
71
|
+
`;else{let c=u.map(f=>{let d=T(e.state.env,`${i}_${f}`,""),p=wn(d);return`['${f}']=${p}`});s+=`declare -A ${i}=(${c.join(" ")})
|
|
72
|
+
`}continue}let l=he(e,i);if(l.length>0){let u=l.map(c=>{let f=T(e.state.env,`${i}_${c}`,"");return`[${c}]=${st(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=T(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 oi(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=ri(e,f),p=e.state.associativeArrays?.has(f),m=he(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&&!ve(e,f)))){if(p){let b=Ze(e,f);if(b.length===0)l+=`declare -A ${f}=()
|
|
78
|
+
`;else{let S=b.map($=>{let g=T(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 $=T(e.state.env,`${f}_${S}`,"");return`[${S}]=${st($)}`});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=T(e.state.env,f);l+=`declare ${d} ${f}=${yn(b)}
|
|
82
|
+
`}}}return G(l)}function ai(e){let t="",s=Array.from(e.state.associativeArrays??[]).sort();for(let n of s){let r=Ze(e,n);if(r.length===0)t+=`declare -A ${n}=()
|
|
83
|
+
`;else{let i=r.map(a=>{let o=T(e.state.env,`${n}_${a}`,""),l=wn(o);return`['${a}']=${l}`});t+=`declare -A ${n}=(${i.join(" ")})
|
|
84
|
+
`}}return G(t)}function li(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=he(e,r);if(i.length===0)t+=`declare -a ${r}=()
|
|
85
|
+
`;else{let a=i.map(o=>{let l=T(e.state.env,`${r}_${o}`,"");return`[${o}]=${st(l)}`});t+=`declare -a ${r}=(${a.join(" ")})
|
|
86
|
+
`}}return G(t)}function ci(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)||he(e,r).length>0||e.state.env.has(`${r}__length`)||e.state.env.has(r)&&(t+=`${r}=${bs(T(e.state.env,r))}
|
|
87
|
+
`);return G(t)}function vn(e,t){e.state.integerVars??=new Set,e.state.integerVars.add(t)}function It(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 Ko(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 Xo(e,t){return e.state.uppercaseVars?.has(t)??!1}function mt(e,t,s){return Ko(e,t)?s.toLowerCase():Xo(e,t)?s.toUpperCase():s}async function ui(e,t){try{let s=new Z,n=le(s,t),r=await Q(e,n.expression);return String(r)}catch{return"0"}}function Yo(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 x of e.state.env.keys())x.startsWith(R)&&!x.includes("__")&&(O.has(x)||O.set(x,e.state.env.get(x)));let _=`${k}__length`;e.state.env.has(_)&&!O.has(_)&&O.set(_,e.state.env.get(_))},N=k=>{g&&Ke(e,k)};if(h){if(S.length===0){let R=Array.from(e.state.functions.keys()).sort(),_="";for(let x of R)_+=`declare -f ${x}
|
|
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 ii(e,S);if(a&&S.length===0)return oi(e,{filterExport:i,filterReadonly:r,filterNameref:o,filterIndexedArray:s,filterAssocArray:n});if(S.length===0&&n&&!a)return ai(e);if(S.length===0&&s&&!a)return li(e);if(S.length===0&&!a)return ci(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&&he(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)),Le(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 Y=se(e,j);y(e.state.env,`${w}_${J}`,Y)}}else if(n){let M=Fe(D);for(let J=0;J<M.length;J+=2){let j=M[J],Y=J+1<M.length?se(e,M[J+1]):"";y(e.state.env,`${w}_${j}`,Y)}}else{let M=Fe(D);if(M.some(j=>/^\[[^\]]+\]=/.test(j))){let j=0;for(let Y of M){let re=Y.match(/^\[([^\]]+)\]=(.*)$/);if(re){let Ee=re[1],nt=re[2],eo=se(e,nt),vt;if(/^-?\d+$/.test(Ee))vt=Number.parseInt(Ee,10);else try{let to=new Z,so=le(to,Ee);vt=await Q(e,so.expression)}catch{vt=0}y(e.state.env,`${w}_${vt}`,eo),j=vt+1}else{let Ee=se(e,Y);y(e.state.env,`${w}_${j}`,Ee),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&&be(e,w),i&&Oe(e,w);continue}if(l){let w=k.includes("=")?k.slice(0,k.indexOf("=")):k;if(cr(e,w),!k.includes("="))continue}if(c){let w=k.includes("=")?k.slice(0,k.indexOf("=")):k;if(Xt(e,w),!k.includes("="))continue}let R=Yo(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,Ee=le(re,D);j=await Q(e,Ee.expression)}catch{let re=parseInt(D,10);j=Number.isNaN(re)?0:re}y(e.state.env,`${w}_${j}`,M);let Y=parseInt(T(e.state.env,`${w}__length`,"0"),10);j>=Y&&y(e.state.env,`${w}__length`,String(j+1)),N(w),r&&be(e,w),i&&Oe(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=Fe(D);if(e.state.associativeArrays?.has(w)){let j=ds(D);for(let[Y,re]of j){let Ee=se(e,re);y(e.state.env,`${w}_${Y}`,Ee)}}else{let j=he(e,w),Y=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),Y=1):j.length>0&&(Y=Math.max(...j)+1);for(let nt=0;nt<J.length;nt++)y(e.state.env,`${w}_${Y+nt}`,se(e,J[nt]));let Ee=Y+J.length;y(e.state.env,`${w}__length`,String(Ee))}N(w),r&&be(e,w),i&&Oe(e,w);continue}let x=k.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(x){let w=x[1],D=se(e,x[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=he(e,w).length>0||e.state.associativeArrays?.has(w);if(It(e,w)){let Y=T(e.state.env,w,"0"),re=parseInt(Y,10)||0,Ee=parseInt(await ui(e,D),10)||0;D=String(re+Ee),y(e.state.env,w,D)}else if(j){D=mt(e,w,D);let Y=`${w}_0`,re=T(e.state.env,Y);y(e.state.env,Y,re+D)}else{D=mt(e,w,D);let Y=T(e.state.env,w);y(e.state.env,w,Y+D)}N(w),r&&be(e,w),i&&Oe(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),Be(e,D),M!==""&&js(e,M)&&zs(e,D),N(D),r&&be(e,D),i&&Oe(e,D);continue}if(f&&vn(e,D),d&&bn(e,D),p&&Sn(e,D),It(e,D)&&(M=await ui(e,M)),M=mt(e,D,M),ve(e,D)){let j=Me(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&&be(e,D),i&&Oe(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){Be(e,w);let M=T(e.state.env,w);M!==""&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(M)?ur(e,w):M&&js(e,M)&&zs(e,w),N(w),r&&be(e,w),i&&Oe(e,w);continue}if(f&&vn(e,w),d&&bn(e,w),p&&Sn(e,w),n){if(he(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&&be(e,w),i&&Oe(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=Fe(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=he(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($))}be(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=T(e.state.env,f);y(e.state.env,f,m+d),be(e,f);continue}let u=Ur(a);if(u.value===void 0&&!u.isArray){be(e,u.name);continue}let c=await Gr(e,u,{makeReadonly:!0});if(c)return c}return ut}function An(e){return e.state.directoryStack??=[],e.state.directoryStack}function Rt(e,t){return t&&e===t?"~":t&&e.startsWith(`${t}/`)?`~${e.slice(t.length)}`:e}function Qo(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=T(e.state.env,"HOME","/")+n.slice(1):r=`${e.state.cwd}/${n}`;r=Qo(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=T(e.state.env,"HOME",""),a=`${[r,...s].map(o=>Rt(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=T(e.state.env,"HOME",""),i=`${[n,...s].map(a=>Rt(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=[],ut;let o=[e.state.cwd,...s],l=T(e.state.env,"HOME",""),u;return a?(u=o.map((c,f)=>{let d=r?c:Rt(c,l);return` ${f} ${d}`}).join(`
|
|
126
117
|
`),u+=`
|
|
127
|
-
`):i?u=
|
|
118
|
+
`):i?u=o.map(c=>r?c:Rt(c,l)).join(`
|
|
128
119
|
`)+`
|
|
129
|
-
`:u=
|
|
130
|
-
`,
|
|
120
|
+
`:u=o.map(c=>r?c:Rt(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=Ie(r),l=await e.executeScript(o);return await X(e,l)}catch(o){if(await ee(e,o),o instanceof $e||o instanceof Ae||o instanceof ye||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 xn(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;Xt(e,o)}return ut}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=T(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,"");Oe(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(T(e.state.env,"#","0"),10);o=[];for(let b=1;b<=h;b++)o.push(T(e.state.env,String(b))||"")}let l=Number.parseInt(T(e.state.env,"OPTIND","1"),10);l<1&&(l=1);let u=Number.parseInt(T(e.state.env,"__GETOPTS_CHARINDEX","0"),10);if(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 Tn(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=T(e.state.env,"PATH","/usr/bin:/bin").split(":");for(let m of l){if(m.includes("/")){f+=`bash: hash: ${m}: cannot use / in name
|
|
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 fi=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.`]]]),di=[...fi.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 ta();let i="",a=!1,o="";for(let l of n){let u=ea(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=fi.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 ea(e){let t=e.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,"."),s=Ct(`^${t}$`);return di.filter(n=>s.test(n))}function ta(){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=di.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 sa=`jobs: usage: jobs [-lnprs] [jobspec ...] or jobs -x command [args]
|
|
499
|
+
`;function na(e){return{stdout:E(),stderr:V(`bash: jobs: ${e}: invalid option
|
|
500
|
+
${sa}`),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 na(`-${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 hi=`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 ra(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 ra(t.slice(1));if(t[0]==="-s"||t[0]==="-n"){let o=t[1];if(!o)return{stdout:E(),stderr:V(hi),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(hi),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 ia(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=ia(t),n=0;for(let r of s)try{let a=Ie(`(( ${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=Fe(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)),Ke(e,c),i&&Be(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 $=Fe(S),g=he(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)),Ke(e,c),i&&Be(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 $=T(e.state.env,c);y(e.state.env,c,$+S),Ke(e,c),i&&Be(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(T(e.state.env,`${c}__length`,"0"),10);g>=v&&y(e.state.env,`${c}__length`,String(g+1)),Ke(e,c),i&&Be(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}}}qr(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)}Ke(e,c),i&&Be(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&&Le(e,u);for(let g=0;g<d.length;g++)y(e.state.env,`${u}_${a+g}`,d[g]);let S=parseInt(T(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 oa(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 aa(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=(_,x)=>{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:x+1}):x+1<t.length?(a=t[x+1],{nextArgIndex:x+2}):{nextArgIndex:x+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:x+1}}else if(x+1<t.length)return l=Number.parseInt(t[x+1],10),(Number.isNaN(l)||l<0)&&(h=!0,l=0),{nextArgIndex:x+2};return{nextArgIndex:x+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:x+1}}else if(x+1<t.length)return u=Number.parseInt(t[x+1],10),(Number.isNaN(u)||u<0)&&(h=!0,u=0),{nextArgIndex:x+2};return{nextArgIndex:x+1}}else{if(D==="a")return w+1<_.length?(c=_.substring(w+1),{nextArgIndex:x+1}):x+1<t.length?(c=t[x+1],{nextArgIndex:x+2}):{nextArgIndex:x+1};if(D==="p")return w+1<_.length?(o=_.substring(w+1),{nextArgIndex:x+1}):x+1<t.length?(o=t[x+1],{nextArgIndex:x+2}):{nextArgIndex:x+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:x+1}}else if(x+1<t.length)return f=Number.parseInt(t[x+1],10),Number.isNaN(f)||f<0?{nextArgIndex:-2}:{nextArgIndex:x+2};return{nextArgIndex:x+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:x+1}}else if(x+1<t.length)return d=Number.parseFloat(t[x+1]),Number.isNaN(d)&&(d=0),{nextArgIndex:x+2};return{nextArgIndex:x+1}}else if(D==="e"||D==="i"||D==="P"){if(D==="i"&&x+1<t.length)return{nextArgIndex:x+2};w++}else w++}}}return{nextArgIndex:x+1}};for(;m<t.length;){let _=t[m];if(_.startsWith("-")&&_.length>1&&_!=="--"){let x=b(_,m);if(x.nextArgIndex===-1)return{stdout:E(),stderr:E(),exitCode:2};if(x.nextArgIndex===-2)return{stdout:E(),stderr:E(),exitCode:1};m=x.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)Le(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 x=e.state.fileDescriptors.get(n);if(x?.startsWith("__rw__:")){let w=oa(x);if(w){let D=w.position+_;e.state.fileDescriptors.set(n,aa(w.path,D,w.content))}}}else e.state.groupStdin!==void 0&&!r&&(e.state.groupStdin=de(F(S.substring(_))))};if(u>=0){let _=Math.min(u,S.length);g=S.substring(0,_),v=_,C=_>=u,N(v);let x=p[0]||"REPLY";y(e.state.env,x,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,x=0,w=!1;for(;x<S.length&&_<l;){let D=S[x];if(D===$){v=x+1,w=!0;break}if(!i&&D==="\\"&&x+1<S.length){let M=S[x+1];if(M===$&&$===`
|
|
526
|
+
`){x+=2,v=x;continue}if(M===$){x+=2,_++,g+=M,v=x;continue}g+=M,x+=2,_++,v=x}else g+=D,x++,_++,v=x}C=_>=l||w,N(v)}else{v=0;let _=0;for(;_<S.length;){let x=S[_];if(x===$){v=_+$.length,C=!0;break}if(!i&&x==="\\"&&_+1<S.length){let w=S[_+1];if(w===`
|
|
527
|
+
`){_+=2;continue}if(w===$){g+=w,_+=2;continue}g+=x,g+=w,_+=2;continue}g+=x,_++}if(_>=S.length&&(C=!1,v=_,g.length===0&&S.length===0)){for(let x of p)y(e.state.env,x,"");return c&&Le(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=ar(e.state.env);if(c){let{words:_}=Vs(g,P,void 0,i),x=e.limits?.maxArrayElements??1e5;if(_.length>x)return W(L,F(`read: array element limit exceeded (${x})
|
|
530
|
+
`),1);Le(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 x=p[_];if(_<p.length-1)y(e.state.env,x,I(O[_]??""));else if(_<R.length){let w=g.substring(R[_]);w=lr(w,P,i),w=I(w),y(e.state.env,x,w)}else y(e.state.env,x,"")}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 ye(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,151 +544,162 @@ Options:
|
|
|
538
544
|
+o pipefail Disable pipefail
|
|
539
545
|
-o xtrace Same as -x
|
|
540
546
|
+o xtrace Disable xtrace
|
|
541
|
-
`,
|
|
547
|
+
`,pi=new Map([["e","errexit"],["u","nounset"],["x","xtrace"],["v","verbose"],["f","noglob"],["C","noclobber"],["a","allexport"],["n","noexec"],["h",null],["b",null],["m",null],["B",null],["H",null],["P",null],["T",null],["E",null],["p",null]]),mi=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]]),gi=["errexit","nounset","pipefail","verbose","xtrace","posix","allexport","noclobber","noglob","noexec","vi","emacs"],yi=["braceexpand","errtrace","functrace","hashall","histexpand","history","ignoreeof","interactive-comments","keyword","monitor","nolog","notify","onecmd","physical","privileged"];function wi(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,ct(e))}function la(e,t){return t+1<e.length&&!e[t+1].startsWith("-")&&!e[t+1].startsWith("+")}function ca(e,t){let s=he(e,t);if(s.length===0)return`${t}=()`;let n=s.map(r=>{let i=T(e.state.env,`${t}_${r}`,"");return`[${r}]=${st(i)}`});return`${t}=(${n.join(" ")})`}function ua(e){return/^[a-zA-Z0-9_]+$/.test(e)?e:`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function fa(e,t){let s=Ze(e,t);if(s.length===0)return`${t}=()`;let n=s.map(r=>{let i=T(e.state.env,`${t}_${r}`,"");return`[${ua(r)}]=${st(i)}`});return`${t}=(${n.join(" ")} )`}function da(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 ha(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=da(e),r=ha(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(ca(e,l));for(let l of[...r].sort((u,c)=>u<c?-1:u>c?1:0))o.push(fa(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")&&la(t,s)){let r=t[s+1];if(!mi.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 we(1);return A(i)}wi(e,mi.get(r)??null,n==="-o"),s+=2;continue}if(n==="-o"){let r=gi.map(o=>`${o.padEnd(16)}${e.state.options[o]?"on":"off"}`),i=yi.map(o=>`${o.padEnd(16)}off`),a=[...r,...i].sort();return G(`${a.join(`
|
|
545
551
|
`)}
|
|
546
|
-
`)}if(
|
|
552
|
+
`)}if(n==="+o"){let r=gi.map(o=>`set ${e.state.options[o]?"-o":"+o"} ${o}`),i=yi.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(!pi.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 we(1);return A(o)}wi(e,pi.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,ct(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 we(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 we(1);return A(o)}s=a}let n=Number.parseInt(T(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 we(1);return A(a)}if(s===0)return B();let r=[];for(let a=1;a<=n;a++)r.push(T(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=T(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),T(e.state.env,String(c)));a.set("#",T(e.state.env,"#")),a.set("@",T(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=Ie(i),c=await e.executeScript(u),f=await X(e,c);return l(),f}catch(u){if(l(),await ee(e,u),u instanceof q)throw u;if(u instanceof ye)return W(L,L,u.exitCode);if(u.name==="ParseException")return A(`bash: ${n}: ${u.message}
|
|
561
|
+
`);throw u}}function vi(e){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)}function pa(e){return e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"')}async function bi(e,t){if(pa(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 Si(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 Ei(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=Ne(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 Ei(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 bi(e,p);if($===null&&h){n+=`bash: unset: ${p}: not a valid identifier
|
|
563
|
+
`,r=1;continue}if($===null)continue;if($<0){let g=Ne(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(!vi(i)){n+=`bash: unset: \`${i}': not a valid identifier
|
|
566
|
+
`,r=1;continue}let c=i;if(ve(e,i)){let d=Me(e,i);d&&d!==i&&(c=d)}if(et(e,c)){n+=`bash: unset: ${c}: cannot unset: readonly variable
|
|
567
|
+
`,r=1;continue}let f=dt(e,c);if(f!==void 0&&f!==e.state.callDepth)Si(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=Ne(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 Ei(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 bi(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=Ne(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(!vi(i)){n+=`bash: unset: \`${i}': not a valid identifier
|
|
572
|
+
`,r=1;continue}let o=i;if(ve(e,i)){let u=Me(e,i);u&&u!==i&&(o=u)}if(et(e,o)){n+=`bash: unset: ${o}: cannot unset: readonly variable
|
|
573
|
+
`,r=1;continue}let l=dt(e,o);if(l!==void 0&&l!==e.state.callDepth)Si(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 ma=`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
|
+
${ma}`),exitCode:2};if(Ye(e.signal),t.length===0){let i,a=new Promise((o,l)=>{i=()=>l(new pe(e.signal?.reason)),e.signal?.addEventListener("abort",i,{once:!0})});try{let o=await(e.signal?Promise.race([e.processes.waitForLineage(e.lineageId),a]):e.processes.waitForLineage(e.lineageId));return{stdout:E(),stderr:E(),exitCode:o}}finally{i&&e.signal?.removeEventListener("abort",i)}}let n=0,r="";for(let i of t){Ye(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 pe(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"],ga=["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 ya(e){return ga.includes(e)}function $i(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 wa(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)&&!ya(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 wa(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,ct(e);else if(n)e.state.options[h]=!1,ct(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 Ai(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??T(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=T(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 _i(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?Ci(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?Ci(h,N):`${h} is a function
|
|
601
|
+
`;c+=I}b=!0;continue}if(!(Ue.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 Ci(e,t){let s;return t.body.type==="Group"?s=t.body.body.map(r=>Lt(r)).join("; "):s=Lt(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 Lt(e){if(Array.isArray(e))return e.map(t=>Lt(t)).join("; ");if(e.type==="Statement"){let t=[];for(let s=0;s<e.pipelines.length;s++){let n=e.pipelines[s];t.push(va(n)),e.operators[s]&&t.push(e.operators[s])}return t.join(" ")}if(e.type==="SimpleCommand"){let t=e,s=[];t.name&&s.push(ki(t.name));for(let n of t.args)s.push(ki(n));return s.join(" ")}return e.type==="Group"?`{ ${e.body.map(n=>Lt(n)).join("; ")}; }`:"..."}function va(e){let t=e.commands.map(s=>Lt(s));return(e.negated?"! ":"")+t.join(" | ")}function ki(e){let t="";for(let s of e.parts)s.type==="Literal"?t+=s.value:s.type==="DoubleQuoted"?t+=`"${s.parts.map(n=>Pi(n)).join("")}"`:s.type==="SingleQuoted"?t+=`'${s.value}'`:t+=Pi(s);return t}function Pi(e){let t=e;return t.type==="Literal"?t.value??"":t.type==="Variable"?`$${t.name}`:""}async function xi(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(Ue.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=T(e.state.env,"PATH","/usr/bin:/bin").split(":"),f=null;for(let d of c){if(!d)continue;let p=`${d}/${o}`;try{let m=await e.fs.stat(p);if(!m.isDirectory&&(m.mode&73)!==0){f=p;break}}catch{}}f||(f=`/usr/bin/${o}`),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 Ti(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=T(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 Ni(e,t,s,n,r,i,a,o){let{ctx:l,runCommand:u}=e,c=bt(s);if(l.coverage&&Ue.has(t)&&l.coverage.hit(`bash:builtin:${t}`),t==="export")return xn(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 Xs(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 ba(e,c,r);if(t==="builtin")return Sa(e,c,r);if(t==="shopt")return $i(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 _i(l,c,f=>Ti(l,f),f=>Ps(l,f));if(t==="hash")return Tn(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 Ot(l,f)}return null}async function ba(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 xi(n,l,o,a);let[u,...c]=l;return r(u,c.map(f=>F(f)),[],s,!0,i,-1)}async function Sa(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(!Ue.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 Oi(e,t,s,n,r){let{buildExportedEnv:i,ctx:a,executeUserScript:o}=e,u=await Ai(a,t,r?"/usr/bin:/bin":void 0);if(!u)return Lr(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=rt(de(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}: ${je(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 X(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 Mt(e,t){return e instanceof $e?e.levels>1&&t>1?(e.levels--,{action:"rethrow",error:e}):{action:"break"}:e instanceof Ae?e.levels>1&&t>1?(e.levels--,{action:"rethrow",error:e}):{action:"continue"}:e instanceof ye||e instanceof Ce||e instanceof q||e instanceof oe?{action:"rethrow",error:e}:{action:"error",exitCode:1,error:e}}async function xs(e,t){let s=0;try{for(let n of t){let r=await e.executeStatement(n);await X(e,r),s=r.exitCode}}catch(n){let r=await ee(e,n);if(qt(n)||n instanceof Ce||n instanceof q||n instanceof oe||n instanceof ze)throw n;if(!r){let i=je(n);await X(e,A(i.endsWith(`
|
|
636
|
+
`)?i:`${i}
|
|
637
|
+
`))}return{stdout:E(),stderr:E(),exitCode:1}}return{stdout:E(),stderr:E(),exitCode:s}}var Ea="+ ";async function Di(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||Ea;return s>0&&r.length>0?`${r[0].repeat(s)}${r}`:r}}function $a(e){return e.map(t=>Aa(t)).join(" ")}function Aa(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 Ts(e,t,s){if(!e.state.options.xtrace)return"";let n=await Di(e),r=[t,...s],i=$a(r);return`${n}${i}
|
|
641
|
+
`}async function Ii(e,t,s){return e.state.options.xtrace?`${await Di(e)}${t}=${s}
|
|
642
|
+
`:""}function Wt(e){let t=je(e);return t.endsWith(`
|
|
643
|
+
`)?t:`${t}
|
|
644
|
+
`}async function gt(e,t,s){let n=await Te(e,e.outputChannels,t);return n.error?K(e,n.channels,()=>X(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 X(e,A(Wt(r)));throw r}})}async function Ri(e,t){return gt(e,t.redirections,async()=>{for(let s of t.clauses)if((await _s(e,s.condition)).exitCode===0)return(await xs(e,s.body)).exitCode;return t.elseBody?(await xs(e,t.elseBody)).exitCode:0})}async function Li(e,t){return gt(e,t.redirections,async()=>{let s=0,n=0;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t.variable))return await X(e,A(`bash: \`${t.variable}': not a valid identifier
|
|
645
|
+
`)),1;let r=[];if(t.words===null)r=T(e.state.env,"@","").split(" ").filter(Boolean);else if(t.words.length>0)try{for(let i of t.words){let a=await We(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 pe(e.signal.reason);n>e.limits.maxLoopIterations&&De(`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 Ts(e,"for",[t.variable,"in",...r]));try{for(let a of t.body){let o=await e.executeStatement(a);await X(e,o),s=o.exitCode}}catch(a){let o=await ee(e,a),l=Mt(a,e.state.loopDepth);if(l.action==="break")break;if(l.action==="continue")continue;if(l.action==="error")return o||await X(e,A(Wt(l.error))),l.exitCode??1;throw l.error}}}finally{e.state.loopDepth--}return s})}async function Mi(e,t){return gt(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 pe(e.signal.reason);if(r>e.limits.maxLoopIterations&&De(`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 X(e,a),n=a.exitCode}}catch(i){let a=await ee(e,i),o=Mt(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 X(e,A(Wt(o.error))),o.exitCode??1;throw o.error}t.update&&await Q(e,t.update.expression)}}finally{e.state.loopDepth--}return n})}async function Wi(e,t,s=E()){return gt(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 X(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=de(u))}e.state.loopDepth++;try{for(;;){if(i++,e.signal?.aborted)throw new pe(e.signal.reason);i>e.limits.maxLoopIterations&&De(`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 $e){if(d.levels>1&&e.state.loopDepth>1)throw d.levels--,d;c=!0}else if(d instanceof Ae){if(d.levels>1&&e.state.loopDepth>1)throw d.levels--,d;f=!0}else throw d}if(c)break;if(!f){if(u!==0)break;try{for(let d of t.body){let p=await e.executeStatement(d);await X(e,p),r=p.exitCode}}catch(d){let p=await ee(e,d),m=Mt(d,e.state.loopDepth);if(m.action==="break")break;if(m.action==="continue")continue;if(m.action==="error")return p||await X(e,A(Wt(m.error))),m.exitCode??1;throw m.error}}}}finally{e.state.loopDepth--,e.state.groupStdin=l}return r})}async function Fi(e,t){return gt(e,t.redirections,async()=>{let s=0,n=0;e.state.loopDepth++;try{for(;;){if(n++,e.signal?.aborted)throw new pe(e.signal.reason);if(n>e.limits.maxLoopIterations&&De(`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 X(e,a),s=a.exitCode}}catch(i){let a=await ee(e,i),o=Mt(i,e.state.loopDepth);if(o.action==="break")break;if(o.action==="continue")continue;if(o.action==="error")return a||await X(e,A(Wt(o.error))),o.exitCode??1;throw o.error}}}finally{e.state.loopDepth--}return s})}async function Vi(e,t){return gt(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);mr(l)&&(u=hr(u));let c=e.state.shoptOptions.nocasematch,f=e.state.shoptOptions.extglob;if(ft(n,u,c,f)){o=!0;break}}if(o){if(s=(await xs(e,a.body)).exitCode,a.terminator===";;")break;a.terminator===";&"?r=!0:r=!1}else r=!1}return s})}async function Ca(e,t,s){let n=Pe(),r=s?Pe():void 0,i=Qe(e.outputChannels);Ms(i,1,n),r&&Ms(i,2,r);try{let a=await K(e,i,t);return{...a,stdout:rt(a.stdout,n.stream()),stderr:r?rt(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 At)return{stdout:o,stderr:l,exitCode:1};if(a instanceof q)return{stdout:o,stderr:l,exitCode:a.exitCode};if(a instanceof Ce)return{stdout:o,stderr:l,exitCode:a.exitCode};throw await X(e,{stdout:o,stderr:l,exitCode:1},!1),a}}async function zi(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,Qe(e.outputChannels),v):await v()}else g=await Ca(e,()=>s(p,r),b)}catch(v){if(await ee(e,v),v instanceof At)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 Ce&&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 pe(e.signal.reason).exitCode)throw await X(e,g,!1),new pe(e.signal.reason);if(o.push(g.exitCode),g.exitCode!==0&&(a=g.exitCode),m)i=g;else if(b)r=rt(g.stderr,g.stdout),i={stdout:E(),stderr:E(),exitCode:g.exitCode};else{let v=g.stdout;await X(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 X(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`,fe=class extends Error{violation;constructor(t,s){super(t+Ko),this.violation=s,this.name="SecurityViolationError"}},ge=!At&&yr?new yr:null,Qo=1e3,mr={enabled:!0,auditMode:!1};function Jo(e){return e===void 0?{...mr,enabled:!1}:typeof e=="boolean"?{...mr,enabled:e}:{...mr,...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(Jo(t))),e.instance}static resetInstance(){e.instance&&(e.instance.forceDeactivate(),e.instance=null)}static isInSandboxedContext(){return ge?ge?.getStore()?.sandboxActive===!0:!1}static getCurrentExecutionId(){if(ge)return ge?.getStore()?.executionId}updateConfig(t){this.config={...this.config,...t}}activate(){if(At||!this.config.enabled){let s=di();return{run:r=>r(),deactivate:()=>{},executionId:s}}this.refCount++,this.refCount===1&&(this.applyPatches(),this.activationTime=Date.now());let t=di();return{run:s=>ge.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 At||this.config.auditMode||!ge?!1:ge?.getStore()?.sandboxActive===!0}recordViolation(t,s,r){let n={timestamp:Date.now(),type:t,message:r,path:s,stack:new Error().stack,executionId:ge?.getStore()?.executionId};if(this.violations.length<Qo&&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 fe(l,u)}return n.config.auditMode&&ge?.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 fe(l,u)}return n.config.auditMode&&ge?.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 fe(u,c)}if(n.config.auditMode&&ge?.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 fe(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 fe(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 fe(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 fe(l,u)}return Reflect.has(i,o)}})}applyPatches(){let t=fi();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 fe(i,o)}t.config.auditMode&&ge?.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 fe(a,l)}return n.config.auditMode&&ge?.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 fe(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 fe(n,i)}return t.config.auditMode&&ge?.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 fe(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(!At)try{let t=null;if(typeof process<"u"){let o=process.mainModule;o&&typeof o=="object"&&(t=o.constructor)}if(!t&&typeof _t<"u"&&typeof _t.main<"u"&&(t=_t.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 dt(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 ji(e,t){let s=new Map,n="";for(let r of t.assignments){let i=r.name;if(r.array){let f=await ka(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 it(e,r.value):L,o=r.value?H(a):"";if(o.length>e.limits.maxStringLength&&De(`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 Na(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 Da(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 ka(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(ve(e,s)){let c=fr(e,s);if(c===void 0||c==="")throw new q(1);let f=Me(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(et(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=Pa(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 _a(e,t,s,n,r,u,c=>{a+=c}):l?await xa(e,s,n,r,u):await Ta(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 Pa(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 _a(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=T(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 xa(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 We(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=T(e.state.env,o.indexExpr);l=u?Number.parseInt(u,10):0,Number.isNaN(l)&&(l=0)}}if(o.append){let u=T(e.state.env,`${t}_${l}`,"");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 Ta(e,t,s,n,r){let i=[];for(let o of s){let l=await We(e,o);i.push(...l.values)}let a=0;if(n){let o=Ne(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 Na(e,t,s,n,r,i,a){let o=s;if(ve(e,s)){let f=Me(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(et(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 Bi(e,o,n);else{let f=await Oa(e,o,n);if(f.error)return{continueToNext:!1,xtraceOutput:"",error:f.error};u=`${o}_${f.index}`}let c=i?T(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=dt(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 Bi(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 Oa(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=T(e.state.env,s);r=a?Number.parseInt(a,10):0}Number.isNaN(r)&&(r=0)}if(r<0){let i=Ne(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 Da(e,t,s,n,r,i,a){let o="",l=s,u=null;if(ve(e,s)){let h=dr(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(et(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(It(e,l)){f=!1;try{let h=new Z;if(r){let S=`(${T(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?T(e.state.env,S)+n:n}let d=mt(e,l,c);d!==c&&(f=!1),c=d,o+=await Ii(e,l,c);let p=l;if(u)p=await Ia(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 Ia(e,t){let{arrayName:s,subscriptExpr:n}=t;if(e.state.associativeArrays?.has(s))return Bi(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=T(e.state.env,n);i=a?Number.parseInt(a,10):0}Number.isNaN(i)&&(i=0)}if(i<0){let a=Ne(e,s);a.length>0&&(i=Math.max(...a.map(l=>l[0]))+1+i)}return`${s}_${i}`}async function Hi(e,t,s,n){let r=Qe(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 Te(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=de(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 qe(e,I);if(k)return k;if(I instanceof oe)throw I;return I instanceof ze||I instanceof $e||I instanceof Ae?await N(0):I instanceof q||I instanceof ye||I instanceof Ce||I instanceof we?await N(I.exitCode):(P||await te(e,()=>Promise.resolve(A(`${je(I)}
|
|
668
|
+
`))),await N(1))}})}catch(C){throw await K(e,r,()=>ee(e,C)),C}finally{v()}}async function Ui(e,t,s,n){let r=t.redirections.length===0?{channels:e.outputChannels,legacyRedirections:[]}:await Te(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 ht(e,r.legacyRedirections);if(a)return await te(e,()=>Promise.resolve(a));let o=await ie(s),l=de(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 qe(e,a);if(l)return l;if(qt(a)||a instanceof Ce||a instanceof q||a instanceof we||a instanceof ze||a instanceof oe)throw a;return o||await te(e,()=>Promise.resolve(A(`${je(a)}
|
|
673
|
+
`))),W(E(),E(),1)}finally{e.state.groupStdin=i}})}async function Gi(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=de(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 qe(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 Ra(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(ve(e,n.parameter)){let r=Me(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 Ft=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]=T(this.ctx.state.env,i));return r}async executeRootScript(t){let s=await this.executeScript(t);return Ye(this.ctx.signal),X(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 pe(this.ctx.signal.reason).exitCode;await X(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 we)return s=r.exitCode,this.ctx.state.lastExitCode=s,y(this.ctx.state.env,"?",String(s)),{stdout:E(),stderr:E(),exitCode:s,env:Ge(this.ctx.state.env)};if(r instanceof oe)throw r;if(r instanceof Ce)return s=r.exitCode,this.ctx.state.lastExitCode=s,y(this.ctx.state.env,"?",String(s)),{stdout:E(),stderr:E(),exitCode:s,env:Ge(this.ctx.state.env)};if(r instanceof er)return s=1,this.ctx.state.lastExitCode=s,y(this.ctx.state.env,"?",String(s)),{stdout:E(),stderr:E(),exitCode:s,env:Ge(this.ctx.state.env)};if(r instanceof At)return s=1,this.ctx.state.lastExitCode=s,y(this.ctx.state.env,"?",String(s)),{stdout:E(),stderr:E(),exitCode:s,env:Ge(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 tr){s=1,this.ctx.state.lastExitCode=s,y(this.ctx.state.env,"?",String(s));continue}if(r instanceof $e||r instanceof Ae){if(this.ctx.state.loopDepth>0)throw r;continue}throw r instanceof ye,r}return{stdout:E(),stderr:E(),exitCode:s,env:Ge(this.ctx.state.env)}}async executeUserScript(t,s,n=E()){return Gi(this.ctx,t,bt(s),n,r=>this.executeScript(r))}async executeStatement(t){if(Ye(this.ctx.signal),this.ctx.state.commandCount++,this.ctx.state.commandCount>this.ctx.limits.maxCommandCount&&De(`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)),Ye(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=>Qe(c,(h,b)=>u.observesOutput?Pe({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=kt(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:kt(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 pe||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 Ce(s);return{stdout:E(),stderr:E(),exitCode:s}}async executePipeline(t){return zi(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 Ri(this.ctx,t);case"For":return Li(this.ctx,t);case"CStyleFor":return Mi(this.ctx,t);case"While":return Wi(this.ctx,t,s);case"Until":return Fi(this.ctx,t);case"Case":return Vi(this.ctx,t);case"Subshell":return this.executeSubshell(t,s);case"Group":return this.executeGroup(t,s);case"FunctionDef":return ei(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 ji(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 Te(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 x=P.bindings.get(_),w=k.channels.bindings.get(_);return x?.sink!==w?.sink||Re(P,_)!==Re(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&&Dt(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=Dt(t.name,["exec"])&&(t.args.length===0||t.args.length===1&&Dt(t.args[0],["--"])),c=await z(this.ctx,t.name),f=[],d=[];if(Dt(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 Ir(this.ctx,P);if(k)f.push(F(k)),d.push(!0);else{let O=await Rr(this.ctx,P);if(O!==null)f.push(F(O)),d.push(!0);else{let R=await We(this.ctx,P);for(let _ of R.values)f.push(F(_)),d.push(R.quoted)}}}else for(let P of t.args)if(Ra(this.ctx,P))f.push(await it(this.ctx,P)),d.push(!0);else{let k=await We(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 Te(this.ctx,m,t.redirections,{persistMovedSource:Ue.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 it(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 it(this.ctx,P.target);$=Qn(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[_,x]of r)x===void 0?this.ctx.state.env.delete(_):this.ctx.state.env.set(_,x);return A(`bash: ${k}: ambiguous redirect
|
|
684
|
+
`)}let R=Number.parseInt(O,10);if(!Number.isNaN(R)&&Re(this.ctx.outputChannels,R)){for(let[_,x]of r)x===void 0?this.ctx.state.env.delete(_):this.ctx.state.env.set(_,x);return A(Ve(R))}if(!Number.isNaN(R)&&this.ctx.state.fileDescriptors){let _=this.ctx.state.fileDescriptors.get(R);if(_!==void 0)if(_.startsWith("__rw__:")){let x=ms(_);x&&($=F(x.content.slice(x.position)),l=R)}else _.startsWith("__file__:")||_.startsWith("__file_append__:")||($=F(_));else if(R>=3&&!this.ctx.outputChannels.bindings.get(R)?.sink){for(let[x,w]of r)w===void 0?this.ctx.state.env.delete(x):this.ctx.state.env.set(x,w);return A(Ve(R))}}else if(!Number.isNaN(R)&&R>=3&&!this.ctx.outputChannels.bindings.get(R)?.sink){for(let[_,x]of r)x===void 0?this.ctx.state.env.delete(_):this.ctx.state.env.set(_,x);return A(Ve(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??de($),!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 Ts(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 x=await Qr(this.ctx,t.redirections);if(x.error){let w;try{w=await K(this.ctx,x.channels,()=>te(this.ctx,()=>Promise.resolve(x.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 x.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[Y,re]of P)Y.bindings=new Map(re);this.ctx.state.fileDescriptors=O,this.ctx.state.nextFd=R;for(let[Y,re]of _)re===void 0?this.ctx.state.env.delete(Y):this.ctx.state.env.set(Y,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 Y=this.ctx.state.fileDescriptors.get(j)??`__dupin__:${j}`;this.ctx.state.fileDescriptors.set(M,Y),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||Re(m,P)!==Re(h.channels,P)}):[];try{try{let P=()=>this.runCommand(c,f,d,S??de($),!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,()=>qe(this.ctx,P,I))).writeFailure,k&&(C=k)),!k)if(P instanceof $e||P instanceof Ae)N=P,C=B();else throw P}if(C.exitCode===127&&Ue.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=Jr(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 Ni(l,t,s,n,r,i,a,o);return u!==null?u:Oi(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 Hi(this.ctx,t,s,n=>this.executeStatement(n))}async executeGroup(t,s=E()){return Ui(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 Te(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||Re(s,i)!==Re(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 Te(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||Re(s,i)!==Re(n.channels,i)});return K(this.ctx,n.channels,async()=>{let i;try{let a=await Je(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 ge={maxCallDepth:100,maxCommandCount:1e4,maxLoopIterations:1e4,maxAwkIterations:1e4,maxSedIterations:1e4,maxJqIterations:1e4,maxSqliteTimeoutMs:5e3,maxPythonTimeoutMs:3e4,maxGlobOperations:1e5,maxStringLength:10485760,maxArrayElements:1e5,maxHeredocSize:10485760,maxSubstitutionDepth:50,maxConcurrentJobs:128};function qi(e){return e?{maxCallDepth:e.maxCallDepth??ge.maxCallDepth,maxCommandCount:e.maxCommandCount??ge.maxCommandCount,maxLoopIterations:e.maxLoopIterations??ge.maxLoopIterations,maxAwkIterations:e.maxAwkIterations??ge.maxAwkIterations,maxSedIterations:e.maxSedIterations??ge.maxSedIterations,maxJqIterations:e.maxJqIterations??ge.maxJqIterations,maxSqliteTimeoutMs:e.maxSqliteTimeoutMs??ge.maxSqliteTimeoutMs,maxPythonTimeoutMs:e.maxPythonTimeoutMs??ge.maxPythonTimeoutMs,maxGlobOperations:e.maxGlobOperations??ge.maxGlobOperations,maxStringLength:e.maxStringLength??ge.maxStringLength,maxArrayElements:e.maxArrayElements??ge.maxArrayElements,maxHeredocSize:e.maxHeredocSize??ge.maxHeredocSize,maxSubstitutionDepth:e.maxSubstitutionDepth??ge.maxSubstitutionDepth,maxConcurrentJobs:e.maxConcurrentJobs??ge.maxConcurrentJobs}:{...ge}}function Zi(e){try{let t=new URL(e);return{origin:t.origin,pathname:t.pathname,href:t.href}}catch{return null}}function La(e){let t=Zi(e);return t?{origin:t.origin,pathPrefix:t.pathname}:null}function Ma(e,t){let s=Zi(e);if(!s)return!1;let n=La(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=>Ma(e,s))}var Vt=class extends Error{constructor(t){super(`Network access denied: URL not in allow-list: ${t}`),this.name="NetworkAccessDeniedError"}},zt=class extends Error{constructor(t){super(`Too many redirects (max: ${t})`),this.name="TooManyRedirectsError"}},jt=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"}},Bt=class extends Error{constructor(t){super(`Response body too large (max: ${t} bytes)`),this.name="ResponseTooLargeError"}};var Wa=20,Fa=3e4,Va=10485760,za=["GET","HEAD"],ja=new Set(["GET","HEAD","OPTIONS"]),Ba=new Set([301,302,303,307,308]);function Kn(e){let t=e.maxRedirects??Wa,s=e.timeoutMs??Fa,n=e.maxResponseSize??Va,r=e.dangerouslyAllowFullInternetAccess?["GET","HEAD","POST","PUT","DELETE","PATCH","OPTIONS"]:e.allowedMethods??za;function i(l){if(!e.dangerouslyAllowFullInternetAccess&&!Jn(l,e.allowedUrlPrefixes??[]))throw new Vt(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&&!ja.has(c)&&(S.body=u.body);let $=await fetch(f,S);if(Ba.has($.status)&&p){let g=$.headers.get("location");if(!g)return await Ji($,f,n);let v=new URL(g,f).href;if(!e.dangerouslyAllowFullInternetAccess&&!Jn(v,e.allowedUrlPrefixes??[]))throw new jt(v);if(d++,d>t)throw new zt(t);f=v;continue}return await Ji($,f,n)}finally{clearTimeout(b)}}}return o}async function Ji(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 Bt(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 Bt(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 Ha=1e3,Ua=64,Ga=globalThis.setTimeout.bind(globalThis),qa=globalThis.clearTimeout.bind(globalThis),Os=class{jobs=new Map;reapedWaitStatuses=new Map;reapedWaitLineages=new Map;options;nextPid=Ha;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?sr(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=Ga(s,this.options.disposeTimeoutMs??1e3);return Promise.allSettled(t.flatMap(r=>r.promise?[r.promise]:[])).then(()=>{qa(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>Ua){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 Ki(){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 Ht=typeof __BROWSER__<"u"&&__BROWSER__;function Xi(){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 Yn=null;if(!Ht)try{let e="node:module",{createRequire:t}=await import(e);Yn=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 Za=`
|
|
690
|
+
|
|
691
|
+
This is a defense-in-depth measure and indicates a bug in just-bash. Please report this at security@vercel.com`,me=class extends Error{violation;constructor(t,s){super(t+Za),this.violation=s,this.name="SecurityViolationError"}},Se=!Ht&&Yn?new Yn:null,Ja=1e3,Xn={enabled:!0,auditMode:!1};function Ka(e){return e===void 0?{...Xn,enabled:!1}:typeof e=="boolean"?{...Xn,enabled:e}:{...Xn,...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(Ka(t))),e.instance}static resetInstance(){e.instance&&(e.instance.forceDeactivate(),e.instance=null)}static isInSandboxedContext(){return Se?Se?.getStore()?.sandboxActive===!0:!1}static getCurrentExecutionId(){if(Se)return Se?.getStore()?.executionId}updateConfig(t){this.config={...this.config,...t}}activate(){if(Ht||!this.config.enabled){let s=Xi();return{run:n=>n(),deactivate:()=>{},executionId:s}}this.refCount++,this.refCount===1&&(this.applyPatches(),this.activationTime=Date.now());let t=Xi();return{run:s=>Se.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 Ht||this.config.auditMode||!Se?!1:Se?.getStore()?.sandboxActive===!0}recordViolation(t,s,n){let r={timestamp:Date.now(),type:t,message:n,path:s,stack:new Error().stack,executionId:Se?.getStore()?.executionId};if(this.violations.length<Ja&&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 me(l,u)}return r.config.auditMode&&Se?.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 me(l,u)}return r.config.auditMode&&Se?.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 me(u,c)}if(r.config.auditMode&&Se?.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 me(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 me(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 me(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 me(l,u)}return Reflect.has(i,a)}})}applyPatches(){let t=Ki();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 me(i,a)}t.config.auditMode&&Se?.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 me(o,l)}return r.config.auditMode&&Se?.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 me(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 me(r,i)}return t.config.auditMode&&Se?.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 me(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(!Ht)try{let t=null;if(typeof process<"u"){let a=process.mainModule;a&&typeof a=="object"&&(t=a.constructor)}if(!t&&typeof Ut<"u"&&typeof Ut.main<"u"&&(t=Ut.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 Xa=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=qi({...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)),_r(s,this.useDefaultLayout),n!=="/"&&s instanceof Tt)try{s.mkdirSync(n,{recursive:!0})}catch{}for(let a of Sr(t.commands))this.registerCommand(a);if(t.network)for(let a of Er())this.registerCommand(a);if(t.python)for(let a of $r())this.registerCommand(a);if(t.customCommands)for(let a of t.customCommands)Ar(a)?this.registerCommand(Cr(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 ta="/home/user/project";function ae(e,t){if(e.includes("\0"))throw new Error(`ENOENT: path contains null byte, ${t} '${e}'`)}var ot=class{root;mountPoint;readOnly;maxFileReadSize;memory=new Map;deleted=new Set;constructor(t){this.root=it.resolve(t.root);let s=t.mountPoint??ta;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 de(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=Le(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=Le(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=Le(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,de(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})}};function pi(){console.log(`just-bash - A secure bash environment for AI agents
|
|
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:ke(this.state.env,s?.env)};if(!t.trim())return{stdout:E(),stderr:E(),exitCode:0,env:ke(this.state.env,s?.env)};if(s?.signal?.aborted)return{stdout:E(),stderr:E(),exitCode:new pe(s.signal.reason).exitCode,env:ke(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=Pe(r(s?.stdoutSink)),a=Pe(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=Ya(t));let S=(this.defenseInDepthConfig?Ds.getInstance(this.defenseInDepthConfig):null)?.activate(),$=!1;try{let g=async()=>{let v=Ie(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:kt(s?.signal,k?.signal)}),fetch:this.secureFetch,sleep:this.sleepFn,trace:this.traceFn,coverage:this.coverageWriter,signal:s?.signal},I=await new Ft(C,m).executeRootScript(v);return u.started&&(await new Promise(P=>Xa(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:ke(this.state.env,s?.env)},i,a);if(g instanceof we)return this.logResult({exitCode:g.exitCode,env:ke(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:ke(this.state.env,s?.env)},i,a);if(g instanceof pe)return this.logResult({exitCode:g.exitCode,env:ke(this.state.env,s?.env)},i,a);if(g instanceof oe)return this.logResult({exitCode:oe.EXIT_CODE,env:ke(this.state.env,s?.env)},i,a);if(g instanceof me)return await a.write(F(`bash: security violation: ${g.message}
|
|
697
|
+
`)),this.logResult({exitCode:1,env:ke(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:ke(this.state.env,s?.env)},i,a);if(g instanceof or)return await a.write(F(`bash: ${g.message}
|
|
699
|
+
`)),this.logResult({exitCode:2,env:ke(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:ke(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 Ge(this.state.env)}};function Ya(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 yt from"node:path";var Qa="/home/user/project";function fe(e,t){if(e.includes("\0"))throw new Error(`ENOENT: path contains null byte, ${t} '${e}'`)}var wt=class{root;mountPoint;readOnly;maxFileReadSize;memory=new Map;deleted=new Set;constructor(t){this.root=yt.resolve(t.root);let s=t.mountPoint??Qa;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}=at(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=yt.join(this.root,n),i=yt.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=He(s);return Yt(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}=at(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=He(n),{chunks:a,size:o}=await lt(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=He(n),{chunks:a,size:o}=await lt(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=yt.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})}};function Qi(){console.log(`just-bash - A secure bash environment for AI agents
|
|
686
703
|
|
|
687
704
|
Usage:
|
|
688
705
|
just-bash [options] [script-file]
|
|
@@ -728,5 +745,5 @@ Examples:
|
|
|
728
745
|
|
|
729
746
|
# Allow write operations (writes stay in memory)
|
|
730
747
|
just-bash -c 'echo test > /tmp/file.txt && cat /tmp/file.txt' --allow-write
|
|
731
|
-
`)}function
|
|
732
|
-
${s}`);try{let
|
|
748
|
+
`)}function el(){console.log("just-bash 1.0.0")}function tl(e){let t={root:process.cwd(),cwd:"/",cwdOverridden:!1,errexit:!1,allowWrite:!1,python:!1,json:!1,help:!1,version:!1},s=0;for(;s<e.length;){let n=e[s];if(n==="-h"||n==="--help")t.help=!0,s++;else if(n==="-v"||n==="--version")t.version=!0,s++;else if(n==="-c")s+1>=e.length&&(console.error("Error: -c requires a script argument"),process.exit(1)),t.script=e[s+1],s+=2;else if(n==="-e"||n==="--errexit")t.errexit=!0,s++;else if(n==="--root")s+1>=e.length&&(console.error("Error: --root requires a path argument"),process.exit(1)),t.root=Yi(e[s+1]),s+=2;else if(n==="--cwd")s+1>=e.length&&(console.error("Error: --cwd requires a path argument"),process.exit(1)),t.cwd=e[s+1],t.cwdOverridden=!0,s+=2;else if(n==="--json")t.json=!0,s++;else if(n==="--allow-write")t.allowWrite=!0,s++;else if(n==="--python")t.python=!0,s++;else if(n.startsWith("-"))if(n.length>2&&!n.startsWith("--")){let r=n.slice(1);for(let i of r)if(i==="e")t.errexit=!0;else if(i==="h")t.help=!0;else if(i==="v")t.version=!0;else if(i==="c"){s+1>=e.length&&(console.error("Error: -c requires a script argument"),process.exit(1)),t.script=e[s+1],s++;break}else console.error(`Error: Unknown option: -${i}`),process.exit(1);s++}else console.error(`Error: Unknown option: ${n}`),process.exit(1);else!t.scriptFile&&!t.script?t.scriptFile=n:t.scriptFile&&t.root===process.cwd()&&(t.root=Yi(n)),s++}return t}function sl(e){if(!e||e==="/")return"/";let t=e.endsWith("/")&&e!=="/"?e.slice(0,-1):e;t.startsWith("/")||(t=`/${t}`);let s=t.split("/").filter(r=>r&&r!=="."),n=[];for(let r of s)r===".."?n.pop():n.push(r);return`/${n.join("/")}`||"/"}async function nl(){let e=[];for await(let t of process.stdin)e.push(t);return Buffer.concat(e).toString("utf-8")}async function rl(){let e=process.argv.slice(2),t=tl(e);t.help&&(Qi(),process.exit(0)),t.version&&(el(),process.exit(0));let s;if(t.script)s=t.script;else if(t.scriptFile){let o=new wt({root:t.root}),l=o.getMountPoint();try{let u=t.scriptFile.startsWith("/")?t.scriptFile:`${l}/${t.scriptFile}`;s=await o.readFileText(u,"utf-8")}catch(u){console.error(`Error: Cannot read script file: ${t.scriptFile}`),console.error(u instanceof Error?u.message:String(u)),process.exit(1)}}else process.stdin.isTTY?(Qi(),process.exit(1)):s=await nl();s.trim()||(t.json&&console.log(JSON.stringify({stdout:"",stderr:"",exitCode:0})),process.exit(0));let n=new wt({root:t.root,readOnly:!t.allowWrite}),r=n.getMountPoint(),i=t.cwdOverridden?sl(t.cwd):r,a=new Is({fs:n,cwd:i,python:t.python});t.errexit&&(s=`set -e
|
|
749
|
+
${s}`);try{let o=await a.exec(s);if(t.json){let[l,u]=await Promise.all([Rs(o.stdout),Rs(o.stderr)]);console.log(JSON.stringify({stdout:l,stderr:u,exitCode:o.exitCode}))}else{for await(let l of $t(o.stdout))process.stdout.write(l);for await(let l of $t(o.stderr))process.stderr.write(l)}process.exit(o.exitCode)}catch(o){t.json?console.log(JSON.stringify({stdout:"",stderr:o instanceof Error?o.message:String(o),exitCode:1})):console.error(o instanceof Error?o.message:String(o)),process.exit(1)}}rl().catch(e=>{console.error("Fatal error:",e),process.exit(1)});
|