just-binary 2.9.8 → 3.0.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 +12 -3
- package/dist/Bash.d.ts +5 -2
- package/dist/bin/chunks/alias-DRSSCAUM.js +2 -0
- package/dist/bin/chunks/awk2-GM5WBRLU.js +2 -0
- package/dist/bin/chunks/base64-KLZ4B6VS.js +2 -0
- package/dist/bin/chunks/basename-XCXGYZPS.js +2 -0
- package/dist/bin/chunks/bash-U2E2FSIE.js +2 -0
- package/dist/bin/chunks/bytes-C34BYEMS.js +2 -0
- package/dist/bin/chunks/cat-D4E4FTXJ.js +2 -0
- package/dist/bin/chunks/chmod-OY5CP5QF.js +2 -0
- package/dist/bin/chunks/chunk-23CC4423.js +287 -0
- package/dist/bin/chunks/chunk-23EV7RYO.js +10 -0
- package/dist/bin/chunks/chunk-2IOUIOWE.js +12 -0
- package/dist/bin/chunks/chunk-3VDZW42W.js +5 -0
- package/dist/bin/chunks/chunk-444WPTN5.js +8 -0
- package/dist/bin/chunks/chunk-446TXLPR.js +9 -0
- package/dist/bin/chunks/chunk-44ROJVH3.js +6 -0
- package/dist/bin/chunks/chunk-463VWH7H.js +2 -0
- package/dist/bin/chunks/chunk-4VVLCPRH.js +8 -0
- package/dist/bin/chunks/chunk-4W52T6KS.js +63 -0
- package/dist/bin/chunks/chunk-5IL5CXJC.js +3 -0
- package/dist/bin/chunks/chunk-5KQNIOZS.js +84 -0
- package/dist/bin/chunks/chunk-66PXNTAV.js +2 -0
- package/dist/bin/chunks/chunk-67SBKZZD.js +9 -0
- package/dist/bin/chunks/chunk-6U6CK6V4.js +16 -0
- package/dist/bin/chunks/chunk-7J7OY2YE.js +12 -0
- package/dist/bin/chunks/chunk-7VWUKGDV.js +4 -0
- package/dist/bin/chunks/chunk-7YOACDUK.js +140 -0
- package/dist/bin/chunks/chunk-AN2KBMAK.js +12 -0
- package/dist/bin/chunks/chunk-AZQ66C5R.js +14 -0
- package/dist/bin/chunks/chunk-B4GXMUCA.js +20 -0
- package/dist/bin/chunks/chunk-BXOX2H2G.js +22 -0
- package/dist/bin/chunks/chunk-CAXM2HMK.js +2 -0
- package/dist/bin/chunks/chunk-CD3NCHIB.js +7 -0
- package/dist/bin/chunks/chunk-CE2ILL65.js +9 -0
- package/dist/bin/chunks/chunk-D34QBGQ3.js +7 -0
- package/dist/bin/chunks/chunk-D44C6YVE.js +6 -0
- package/dist/bin/chunks/chunk-DFAHK2EQ.js +23 -0
- package/dist/bin/chunks/chunk-DMTOGHTU.js +6 -0
- package/dist/bin/chunks/chunk-ECBMSCPX.js +5 -0
- package/dist/bin/chunks/chunk-EHJW6FCX.js +36 -0
- package/dist/bin/chunks/chunk-EXCMJ23H.js +100 -0
- package/dist/bin/chunks/chunk-FVFLR7NF.js +21 -0
- package/dist/bin/chunks/chunk-FZXGAGSU.js +33 -0
- package/dist/bin/chunks/chunk-GIVPKQT5.js +16 -0
- package/dist/bin/chunks/chunk-GUZJZK5O.js +2 -0
- package/dist/bin/chunks/chunk-HEO6EBJ2.js +14 -0
- package/dist/bin/chunks/chunk-HT4IVOYZ.js +7 -0
- package/dist/bin/chunks/chunk-HY6WUGWS.js +10 -0
- package/dist/bin/chunks/chunk-HZM5PBQF.js +8 -0
- package/dist/bin/chunks/chunk-I2N72LXH.js +9 -0
- package/dist/bin/chunks/chunk-IAUA3FL7.js +8 -0
- package/dist/bin/chunks/chunk-IPWJZ22H.js +14 -0
- package/dist/bin/chunks/chunk-IQY3I4OH.js +2 -0
- package/dist/bin/chunks/chunk-JU5KTPFP.js +17 -0
- package/dist/bin/chunks/chunk-KAWPUEQM.js +3 -0
- package/dist/bin/chunks/chunk-L2KFCEBW.js +13 -0
- package/dist/bin/chunks/chunk-LVSKOXVG.js +5 -0
- package/dist/bin/chunks/chunk-MPX22C7Y.js +5 -0
- package/dist/bin/chunks/chunk-N7P3SUNH.js +6 -0
- package/dist/bin/chunks/chunk-NNVWOCET.js +2 -0
- package/dist/bin/chunks/chunk-NSSLXYEG.js +8 -0
- package/dist/bin/chunks/chunk-OH3VVXF7.js +3 -0
- package/dist/bin/chunks/chunk-PKKBPSVJ.js +7 -0
- package/dist/bin/chunks/chunk-PRQYRYWV.js +3 -0
- package/dist/bin/chunks/chunk-PYIWPSII.js +32 -0
- package/dist/bin/chunks/chunk-PZ46XEZ4.js +2 -0
- package/dist/bin/chunks/chunk-Q2BKN6MV.js +11 -0
- package/dist/bin/chunks/chunk-QFPJQSDK.js +7 -0
- package/dist/bin/chunks/chunk-QKQUVK53.js +10 -0
- package/dist/bin/chunks/chunk-QXOUI5BS.js +11 -0
- package/dist/bin/chunks/chunk-RAL2LVDX.js +7 -0
- package/dist/bin/chunks/chunk-RAUBS6MJ.js +2 -0
- package/dist/bin/chunks/chunk-RFIBBYTO.js +6 -0
- package/dist/bin/chunks/chunk-RIV3HSPK.js +19 -0
- package/dist/bin/chunks/chunk-RMG637UR.js +26 -0
- package/dist/bin/chunks/chunk-RUESYAVK.js +2 -0
- package/dist/bin/chunks/chunk-RUNWFUUE.js +7 -0
- package/dist/bin/chunks/chunk-RX4PT2U7.js +9 -0
- package/dist/bin/chunks/chunk-RZ6FAJ25.js +18 -0
- package/dist/bin/chunks/chunk-SDTTNNEH.js +23 -0
- package/dist/bin/chunks/chunk-SL4D2YES.js +4 -0
- package/dist/bin/chunks/chunk-SZM4GZ4H.js +2 -0
- package/dist/bin/chunks/chunk-TACNCKUC.js +21 -0
- package/dist/bin/chunks/chunk-U4LP6WPJ.js +11 -0
- package/dist/bin/chunks/chunk-UAZICDKU.js +5 -0
- package/dist/bin/chunks/chunk-V3N6H3L5.js +9 -0
- package/dist/bin/chunks/chunk-VWJBSJYM.js +2 -0
- package/dist/bin/chunks/chunk-WXI44VNZ.js +5 -0
- package/dist/bin/chunks/chunk-X7PEK6W7.js +13 -0
- package/dist/bin/chunks/chunk-XB426ZI7.js +3 -0
- package/dist/bin/chunks/chunk-XILOLP4K.js +8 -0
- package/dist/bin/chunks/chunk-XRZNW2KP.js +7 -0
- package/dist/bin/chunks/chunk-YER5PEKD.js +2 -0
- package/dist/bin/chunks/chunk-YG67AAKF.js +5 -0
- package/dist/bin/chunks/chunk-YGAHXCGB.js +13 -0
- package/dist/bin/chunks/chunk-YJFLWG5Q.js +73 -0
- package/dist/bin/chunks/chunk-Z72PSRMX.js +3 -0
- package/dist/bin/chunks/chunk-Z73LISDU.js +16 -0
- package/dist/bin/chunks/chunk-ZZPPBMHW.js +14 -0
- package/dist/bin/chunks/clear-P5EG7Z6I.js +2 -0
- package/dist/bin/chunks/column-5CUPANJY.js +2 -0
- package/dist/bin/chunks/comm-LMDA7QZC.js +2 -0
- package/dist/bin/chunks/cp-7TMSGOID.js +2 -0
- package/dist/bin/chunks/curl-P6DHVAKR.js +26 -0
- package/dist/bin/chunks/cut-P6LPALWP.js +2 -0
- package/dist/bin/chunks/date-KYJ2OPHH.js +2 -0
- package/dist/bin/chunks/diff-SGBANTKE.js +2 -0
- package/dist/bin/chunks/dirname-3LHNBKNB.js +2 -0
- package/dist/bin/chunks/du-DEYTW2KI.js +2 -0
- package/dist/bin/chunks/echo-5EBIR54T.js +2 -0
- package/dist/bin/chunks/env-PWRJFDWL.js +2 -0
- package/dist/bin/chunks/expand-672ZQYZF.js +2 -0
- package/dist/bin/chunks/expansion-OPTOOC4Q.js +2 -0
- package/dist/bin/chunks/expr-SWYNZXDP.js +2 -0
- package/dist/bin/chunks/file-MIXTZ4NP.js +2 -0
- package/dist/bin/chunks/find-BXGQE44U.js +2 -0
- package/dist/bin/chunks/flag-coverage-7AQE3UPG.js +2 -0
- package/dist/bin/chunks/fold-SK55D7OX.js +2 -0
- package/dist/bin/chunks/grep-6OXCYWRV.js +2 -0
- package/dist/bin/chunks/gzip-PT23FGTW.js +2 -0
- package/dist/bin/chunks/head-YZQN4BHR.js +2 -0
- package/dist/bin/chunks/help-R7JNUPU2.js +2 -0
- package/dist/bin/chunks/history-W57S3E3C.js +2 -0
- package/dist/bin/chunks/hostname-NPAYFT3O.js +2 -0
- package/dist/bin/chunks/html-to-markdown-2AHE4ET2.js +2 -0
- package/dist/bin/chunks/join-ZK67SMQ3.js +2 -0
- package/dist/bin/chunks/jq-2BGA6KZ3.js +2 -0
- package/dist/bin/chunks/ln-PZ7JHGH2.js +2 -0
- package/dist/bin/chunks/ls-SLO257WP.js +2 -0
- package/dist/bin/chunks/md5sum-WYOOUOWI.js +2 -0
- package/dist/bin/chunks/mkdir-EOATYYLD.js +2 -0
- package/dist/bin/chunks/mv-QUAFQDCT.js +2 -0
- package/dist/bin/chunks/nl-WZC4GKMG.js +2 -0
- package/dist/bin/chunks/od-IMVAQQIR.js +2 -0
- package/dist/bin/chunks/paste-6XYPZQXQ.js +2 -0
- package/dist/bin/chunks/printf-OCMANWQ5.js +2 -0
- package/dist/bin/chunks/pwd-PQGDLYLZ.js +2 -0
- package/dist/bin/chunks/python3-HNLPOBYQ.js +14 -0
- package/dist/bin/chunks/readlink-F66ORZVY.js +2 -0
- package/dist/bin/chunks/rev-67WGH7WN.js +2 -0
- package/dist/bin/chunks/rg-D5WXPSFJ.js +2 -0
- package/dist/bin/chunks/rm-BZWDOVUX.js +2 -0
- package/dist/bin/chunks/rmdir-5MNK2AUK.js +2 -0
- package/dist/bin/chunks/sed-HN3E3YFB.js +2 -0
- package/dist/bin/chunks/seq-6C6VEGIG.js +2 -0
- package/dist/bin/chunks/sha1sum-Y2J25KOM.js +2 -0
- package/dist/bin/chunks/sha256sum-NFAAGL44.js +2 -0
- package/dist/bin/chunks/sleep-CPJ3WJE7.js +2 -0
- package/dist/bin/chunks/sort-FT4OVPSS.js +2 -0
- package/dist/bin/chunks/split-AXXLODUK.js +2 -0
- package/dist/bin/chunks/sqlite3-DUARNSNG.js +2 -0
- package/dist/bin/chunks/stat-6QXPS4BF.js +2 -0
- package/dist/bin/chunks/strings-7CJI5ESD.js +2 -0
- package/dist/bin/chunks/tac-Q5VNKVXE.js +2 -0
- package/dist/bin/chunks/tail-EI24LQBP.js +2 -0
- package/dist/bin/chunks/tar-M7QCUJ4B.js +2 -0
- package/dist/bin/chunks/tee-6TEQ3DXN.js +2 -0
- package/dist/bin/chunks/time-GJWZLHLN.js +2 -0
- package/dist/bin/chunks/timeout-LPVVIBNB.js +2 -0
- package/dist/bin/chunks/touch-J6X4OW3P.js +2 -0
- package/dist/bin/chunks/tr-2C3Q77EZ.js +2 -0
- package/dist/bin/chunks/tree-RLXLQJVI.js +2 -0
- package/dist/bin/chunks/true-ZPDUMWHQ.js +2 -0
- package/dist/bin/chunks/unexpand-AUQHJMGI.js +2 -0
- package/dist/bin/chunks/uniq-C3ZUQTF4.js +2 -0
- package/dist/bin/chunks/wc-NNQHXBLM.js +2 -0
- package/dist/bin/chunks/which-QKNHOQPQ.js +2 -0
- package/dist/bin/chunks/whoami-KIB3RVBF.js +2 -0
- package/dist/bin/chunks/xan-BGDVQKRZ.js +2 -0
- package/dist/bin/chunks/xan-view-GTANKIPW.js +2 -0
- package/dist/bin/chunks/xargs-I7QRUR36.js +2 -0
- package/dist/bin/chunks/yq-W7OKSS7Z.js +2 -0
- package/dist/bin/just-bash.js +290 -290
- package/dist/bin/shell/chunks/alias-DRSSCAUM.js +2 -0
- package/dist/bin/shell/chunks/awk2-GM5WBRLU.js +2 -0
- package/dist/bin/shell/chunks/base64-KLZ4B6VS.js +2 -0
- package/dist/bin/shell/chunks/basename-XCXGYZPS.js +2 -0
- package/dist/bin/shell/chunks/bash-U2E2FSIE.js +2 -0
- package/dist/bin/shell/chunks/bytes-C34BYEMS.js +2 -0
- package/dist/bin/shell/chunks/cat-D4E4FTXJ.js +2 -0
- package/dist/bin/shell/chunks/chmod-OY5CP5QF.js +2 -0
- package/dist/bin/shell/chunks/chunk-23CC4423.js +287 -0
- package/dist/bin/shell/chunks/chunk-23EV7RYO.js +10 -0
- package/dist/bin/shell/chunks/chunk-2IOUIOWE.js +12 -0
- package/dist/bin/shell/chunks/chunk-3VDZW42W.js +5 -0
- package/dist/bin/shell/chunks/chunk-444WPTN5.js +8 -0
- package/dist/bin/shell/chunks/chunk-446TXLPR.js +9 -0
- package/dist/bin/shell/chunks/chunk-44ROJVH3.js +6 -0
- package/dist/bin/shell/chunks/chunk-463VWH7H.js +2 -0
- package/dist/bin/shell/chunks/chunk-4VVLCPRH.js +8 -0
- package/dist/bin/shell/chunks/chunk-4W52T6KS.js +63 -0
- package/dist/bin/shell/chunks/chunk-5IL5CXJC.js +3 -0
- package/dist/bin/shell/chunks/chunk-5KQNIOZS.js +84 -0
- package/dist/bin/shell/chunks/chunk-66PXNTAV.js +2 -0
- package/dist/bin/shell/chunks/chunk-67SBKZZD.js +9 -0
- package/dist/bin/shell/chunks/chunk-6U6CK6V4.js +16 -0
- package/dist/bin/shell/chunks/chunk-7J7OY2YE.js +12 -0
- package/dist/bin/shell/chunks/chunk-7VWUKGDV.js +4 -0
- package/dist/bin/shell/chunks/chunk-7YOACDUK.js +140 -0
- package/dist/bin/shell/chunks/chunk-AN2KBMAK.js +12 -0
- package/dist/bin/shell/chunks/chunk-AZQ66C5R.js +14 -0
- package/dist/bin/shell/chunks/chunk-B4GXMUCA.js +20 -0
- package/dist/bin/shell/chunks/chunk-BXOX2H2G.js +22 -0
- package/dist/bin/shell/chunks/chunk-CAXM2HMK.js +2 -0
- package/dist/bin/shell/chunks/chunk-CD3NCHIB.js +7 -0
- package/dist/bin/shell/chunks/chunk-CE2ILL65.js +9 -0
- package/dist/bin/shell/chunks/chunk-D34QBGQ3.js +7 -0
- package/dist/bin/shell/chunks/chunk-D44C6YVE.js +6 -0
- package/dist/bin/shell/chunks/chunk-DFAHK2EQ.js +23 -0
- package/dist/bin/shell/chunks/chunk-DMTOGHTU.js +6 -0
- package/dist/bin/shell/chunks/chunk-ECBMSCPX.js +5 -0
- package/dist/bin/shell/chunks/chunk-EHJW6FCX.js +36 -0
- package/dist/bin/shell/chunks/chunk-EXCMJ23H.js +100 -0
- package/dist/bin/shell/chunks/chunk-FVFLR7NF.js +21 -0
- package/dist/bin/shell/chunks/chunk-FZXGAGSU.js +33 -0
- package/dist/bin/shell/chunks/chunk-GIVPKQT5.js +16 -0
- package/dist/bin/shell/chunks/chunk-GUZJZK5O.js +2 -0
- package/dist/bin/shell/chunks/chunk-HEO6EBJ2.js +14 -0
- package/dist/bin/shell/chunks/chunk-HT4IVOYZ.js +7 -0
- package/dist/bin/shell/chunks/chunk-HY6WUGWS.js +10 -0
- package/dist/bin/shell/chunks/chunk-HZM5PBQF.js +8 -0
- package/dist/bin/shell/chunks/chunk-I2N72LXH.js +9 -0
- package/dist/bin/shell/chunks/chunk-IAUA3FL7.js +8 -0
- package/dist/bin/shell/chunks/chunk-IPWJZ22H.js +14 -0
- package/dist/bin/shell/chunks/chunk-IQY3I4OH.js +2 -0
- package/dist/bin/shell/chunks/chunk-JU5KTPFP.js +17 -0
- package/dist/bin/shell/chunks/chunk-KAWPUEQM.js +3 -0
- package/dist/bin/shell/chunks/chunk-L2KFCEBW.js +13 -0
- package/dist/bin/shell/chunks/chunk-LVSKOXVG.js +5 -0
- package/dist/bin/shell/chunks/chunk-MPX22C7Y.js +5 -0
- package/dist/bin/shell/chunks/chunk-N7P3SUNH.js +6 -0
- package/dist/bin/shell/chunks/chunk-NNVWOCET.js +2 -0
- package/dist/bin/shell/chunks/chunk-NSSLXYEG.js +8 -0
- package/dist/bin/shell/chunks/chunk-OH3VVXF7.js +3 -0
- package/dist/bin/shell/chunks/chunk-PKKBPSVJ.js +7 -0
- package/dist/bin/shell/chunks/chunk-PRQYRYWV.js +3 -0
- package/dist/bin/shell/chunks/chunk-PYIWPSII.js +32 -0
- package/dist/bin/shell/chunks/chunk-PZ46XEZ4.js +2 -0
- package/dist/bin/shell/chunks/chunk-Q2BKN6MV.js +11 -0
- package/dist/bin/shell/chunks/chunk-QFPJQSDK.js +7 -0
- package/dist/bin/shell/chunks/chunk-QKQUVK53.js +10 -0
- package/dist/bin/shell/chunks/chunk-QXOUI5BS.js +11 -0
- package/dist/bin/shell/chunks/chunk-RAL2LVDX.js +7 -0
- package/dist/bin/shell/chunks/chunk-RAUBS6MJ.js +2 -0
- package/dist/bin/shell/chunks/chunk-RFIBBYTO.js +6 -0
- package/dist/bin/shell/chunks/chunk-RIV3HSPK.js +19 -0
- package/dist/bin/shell/chunks/chunk-RMG637UR.js +26 -0
- package/dist/bin/shell/chunks/chunk-RUESYAVK.js +2 -0
- package/dist/bin/shell/chunks/chunk-RUNWFUUE.js +7 -0
- package/dist/bin/shell/chunks/chunk-RX4PT2U7.js +9 -0
- package/dist/bin/shell/chunks/chunk-RZ6FAJ25.js +18 -0
- package/dist/bin/shell/chunks/chunk-SDTTNNEH.js +23 -0
- package/dist/bin/shell/chunks/chunk-SL4D2YES.js +4 -0
- package/dist/bin/shell/chunks/chunk-SZM4GZ4H.js +2 -0
- package/dist/bin/shell/chunks/chunk-TACNCKUC.js +21 -0
- package/dist/bin/shell/chunks/chunk-U4LP6WPJ.js +11 -0
- package/dist/bin/shell/chunks/chunk-UAZICDKU.js +5 -0
- package/dist/bin/shell/chunks/chunk-V3N6H3L5.js +9 -0
- package/dist/bin/shell/chunks/chunk-VWJBSJYM.js +2 -0
- package/dist/bin/shell/chunks/chunk-WXI44VNZ.js +5 -0
- package/dist/bin/shell/chunks/chunk-X7PEK6W7.js +13 -0
- package/dist/bin/shell/chunks/chunk-XB426ZI7.js +3 -0
- package/dist/bin/shell/chunks/chunk-XILOLP4K.js +8 -0
- package/dist/bin/shell/chunks/chunk-XRZNW2KP.js +7 -0
- package/dist/bin/shell/chunks/chunk-YER5PEKD.js +2 -0
- package/dist/bin/shell/chunks/chunk-YG67AAKF.js +5 -0
- package/dist/bin/shell/chunks/chunk-YGAHXCGB.js +13 -0
- package/dist/bin/shell/chunks/chunk-YJFLWG5Q.js +73 -0
- package/dist/bin/shell/chunks/chunk-Z72PSRMX.js +3 -0
- package/dist/bin/shell/chunks/chunk-Z73LISDU.js +16 -0
- package/dist/bin/shell/chunks/chunk-ZZPPBMHW.js +14 -0
- package/dist/bin/shell/chunks/clear-P5EG7Z6I.js +2 -0
- package/dist/bin/shell/chunks/column-5CUPANJY.js +2 -0
- package/dist/bin/shell/chunks/comm-LMDA7QZC.js +2 -0
- package/dist/bin/shell/chunks/cp-7TMSGOID.js +2 -0
- package/dist/bin/shell/chunks/curl-P6DHVAKR.js +26 -0
- package/dist/bin/shell/chunks/cut-P6LPALWP.js +2 -0
- package/dist/bin/shell/chunks/date-KYJ2OPHH.js +2 -0
- package/dist/bin/shell/chunks/diff-SGBANTKE.js +2 -0
- package/dist/bin/shell/chunks/dirname-3LHNBKNB.js +2 -0
- package/dist/bin/shell/chunks/du-DEYTW2KI.js +2 -0
- package/dist/bin/shell/chunks/echo-5EBIR54T.js +2 -0
- package/dist/bin/shell/chunks/env-PWRJFDWL.js +2 -0
- package/dist/bin/shell/chunks/expand-672ZQYZF.js +2 -0
- package/dist/bin/shell/chunks/expansion-OPTOOC4Q.js +2 -0
- package/dist/bin/shell/chunks/expr-SWYNZXDP.js +2 -0
- package/dist/bin/shell/chunks/file-MIXTZ4NP.js +2 -0
- package/dist/bin/shell/chunks/find-BXGQE44U.js +2 -0
- package/dist/bin/shell/chunks/flag-coverage-7AQE3UPG.js +2 -0
- package/dist/bin/shell/chunks/fold-SK55D7OX.js +2 -0
- package/dist/bin/shell/chunks/grep-6OXCYWRV.js +2 -0
- package/dist/bin/shell/chunks/gzip-PT23FGTW.js +2 -0
- package/dist/bin/shell/chunks/head-YZQN4BHR.js +2 -0
- package/dist/bin/shell/chunks/help-R7JNUPU2.js +2 -0
- package/dist/bin/shell/chunks/history-W57S3E3C.js +2 -0
- package/dist/bin/shell/chunks/hostname-NPAYFT3O.js +2 -0
- package/dist/bin/shell/chunks/html-to-markdown-2AHE4ET2.js +2 -0
- package/dist/bin/shell/chunks/join-ZK67SMQ3.js +2 -0
- package/dist/bin/shell/chunks/jq-2BGA6KZ3.js +2 -0
- package/dist/bin/shell/chunks/ln-PZ7JHGH2.js +2 -0
- package/dist/bin/shell/chunks/ls-SLO257WP.js +2 -0
- package/dist/bin/shell/chunks/md5sum-WYOOUOWI.js +2 -0
- package/dist/bin/shell/chunks/mkdir-EOATYYLD.js +2 -0
- package/dist/bin/shell/chunks/mv-QUAFQDCT.js +2 -0
- package/dist/bin/shell/chunks/nl-WZC4GKMG.js +2 -0
- package/dist/bin/shell/chunks/od-IMVAQQIR.js +2 -0
- package/dist/bin/shell/chunks/paste-6XYPZQXQ.js +2 -0
- package/dist/bin/shell/chunks/printf-OCMANWQ5.js +2 -0
- package/dist/bin/shell/chunks/pwd-PQGDLYLZ.js +2 -0
- package/dist/bin/shell/chunks/python3-HNLPOBYQ.js +14 -0
- package/dist/bin/shell/chunks/readlink-F66ORZVY.js +2 -0
- package/dist/bin/shell/chunks/rev-67WGH7WN.js +2 -0
- package/dist/bin/shell/chunks/rg-D5WXPSFJ.js +2 -0
- package/dist/bin/shell/chunks/rm-BZWDOVUX.js +2 -0
- package/dist/bin/shell/chunks/rmdir-5MNK2AUK.js +2 -0
- package/dist/bin/shell/chunks/sed-HN3E3YFB.js +2 -0
- package/dist/bin/shell/chunks/seq-6C6VEGIG.js +2 -0
- package/dist/bin/shell/chunks/sha1sum-Y2J25KOM.js +2 -0
- package/dist/bin/shell/chunks/sha256sum-NFAAGL44.js +2 -0
- package/dist/bin/shell/chunks/sleep-CPJ3WJE7.js +2 -0
- package/dist/bin/shell/chunks/sort-FT4OVPSS.js +2 -0
- package/dist/bin/shell/chunks/split-AXXLODUK.js +2 -0
- package/dist/bin/shell/chunks/sqlite3-DUARNSNG.js +2 -0
- package/dist/bin/shell/chunks/stat-6QXPS4BF.js +2 -0
- package/dist/bin/shell/chunks/strings-7CJI5ESD.js +2 -0
- package/dist/bin/shell/chunks/tac-Q5VNKVXE.js +2 -0
- package/dist/bin/shell/chunks/tail-EI24LQBP.js +2 -0
- package/dist/bin/shell/chunks/tar-M7QCUJ4B.js +2 -0
- package/dist/bin/shell/chunks/tee-6TEQ3DXN.js +2 -0
- package/dist/bin/shell/chunks/time-GJWZLHLN.js +2 -0
- package/dist/bin/shell/chunks/timeout-LPVVIBNB.js +2 -0
- package/dist/bin/shell/chunks/touch-J6X4OW3P.js +2 -0
- package/dist/bin/shell/chunks/tr-2C3Q77EZ.js +2 -0
- package/dist/bin/shell/chunks/tree-RLXLQJVI.js +2 -0
- package/dist/bin/shell/chunks/true-ZPDUMWHQ.js +2 -0
- package/dist/bin/shell/chunks/unexpand-AUQHJMGI.js +2 -0
- package/dist/bin/shell/chunks/uniq-C3ZUQTF4.js +2 -0
- package/dist/bin/shell/chunks/wc-NNQHXBLM.js +2 -0
- package/dist/bin/shell/chunks/which-QKNHOQPQ.js +2 -0
- package/dist/bin/shell/chunks/whoami-KIB3RVBF.js +2 -0
- package/dist/bin/shell/chunks/xan-BGDVQKRZ.js +2 -0
- package/dist/bin/shell/chunks/xan-view-GTANKIPW.js +2 -0
- package/dist/bin/shell/chunks/xargs-I7QRUR36.js +2 -0
- package/dist/bin/shell/chunks/yq-W7OKSS7Z.js +2 -0
- package/dist/bin/shell/shell.js +303 -303
- package/dist/bundle/browser.js +841 -833
- package/dist/bundle/chunks/alias-JHV3WNPA.js +1 -0
- package/dist/bundle/chunks/awk2-LA5EZ6UJ.js +1 -0
- package/dist/bundle/chunks/base64-DP3BVL7J.js +1 -0
- package/dist/bundle/chunks/basename-NCIQLNXY.js +1 -0
- package/dist/bundle/chunks/bash-CN3UUJ3N.js +1 -0
- package/dist/bundle/chunks/bytes-JUNATFIO.js +1 -0
- package/dist/bundle/chunks/cat-KHANCARN.js +1 -0
- package/dist/bundle/chunks/chmod-A3HCFC4L.js +1 -0
- package/dist/bundle/chunks/chunk-26DNZXYZ.js +23 -0
- package/dist/bundle/chunks/chunk-26VNLF3H.js +6 -0
- package/dist/bundle/chunks/chunk-2AMXQD57.js +11 -0
- package/dist/bundle/chunks/chunk-2OIUNVMP.js +10 -0
- package/dist/bundle/chunks/chunk-2V4QPJXQ.js +19 -0
- package/dist/bundle/chunks/chunk-2WN53CVO.js +15 -0
- package/dist/bundle/chunks/chunk-3ANOKDIL.js +5 -0
- package/dist/bundle/chunks/chunk-3P5XOPF6.js +1 -0
- package/dist/bundle/chunks/chunk-4PFDHMBC.js +8 -0
- package/dist/bundle/chunks/chunk-53I2XH4A.js +9 -0
- package/dist/bundle/chunks/chunk-5BF5Z7CI.js +1 -0
- package/dist/bundle/chunks/chunk-5J57FRET.js +4 -0
- package/dist/bundle/chunks/chunk-5PIFIDMP.js +13 -0
- package/dist/bundle/chunks/chunk-5PV2QBWC.js +5 -0
- package/dist/bundle/chunks/chunk-6V537K6X.js +1 -0
- package/dist/bundle/chunks/chunk-72YPFG2Z.js +5 -0
- package/dist/bundle/chunks/chunk-7USKQKOT.js +1 -0
- package/dist/bundle/chunks/chunk-ATPJVO6F.js +8 -0
- package/dist/bundle/chunks/chunk-BJQMZYH3.js +22 -0
- package/dist/bundle/chunks/chunk-BQFHZOZH.js +99 -0
- package/dist/bundle/chunks/chunk-BTTTDUMD.js +1 -0
- package/dist/bundle/chunks/chunk-BXVXYDEI.js +286 -0
- package/dist/bundle/chunks/chunk-C325X4RB.js +7 -0
- package/dist/bundle/chunks/chunk-C44B5265.js +2 -0
- package/dist/bundle/chunks/chunk-D3IE6KOV.js +21 -0
- package/dist/bundle/chunks/chunk-D4LWWAJ2.js +6 -0
- package/dist/bundle/chunks/chunk-DEQBZDPB.js +1 -0
- package/dist/bundle/chunks/chunk-DNPCEBCN.js +2 -0
- package/dist/bundle/chunks/chunk-E7BAZEZG.js +32 -0
- package/dist/bundle/chunks/chunk-EHRCEDXN.js +13 -0
- package/dist/bundle/chunks/chunk-EHY6GWKP.js +8 -0
- package/dist/bundle/chunks/chunk-F77E6PCM.js +7 -0
- package/dist/bundle/chunks/chunk-GET3OC3O.js +8 -0
- package/dist/bundle/chunks/chunk-GMCBEP44.js +16 -0
- package/dist/bundle/chunks/chunk-GNXHG75U.js +1 -0
- package/dist/bundle/chunks/chunk-GQSJJXDG.js +3 -0
- package/dist/bundle/chunks/chunk-H5X25CTO.js +6 -0
- package/dist/bundle/chunks/chunk-IAFRFK2O.js +9 -0
- package/dist/bundle/chunks/chunk-INJTM5VR.js +5 -0
- package/dist/bundle/chunks/chunk-J7YL5K5B.js +2 -0
- package/dist/bundle/chunks/chunk-JJ5E4XJI.js +13 -0
- package/dist/bundle/chunks/chunk-JMFP263D.js +1 -0
- package/dist/bundle/chunks/chunk-JSLN56GJ.js +7 -0
- package/dist/bundle/chunks/chunk-K374E7Q4.js +8 -0
- package/dist/bundle/chunks/chunk-K7ZRPFN6.js +6 -0
- package/dist/bundle/chunks/chunk-KBCEHRTU.js +4 -0
- package/dist/bundle/chunks/chunk-KM46TYGR.js +4 -0
- package/dist/bundle/chunks/chunk-KRXVUD4L.js +4 -0
- package/dist/bundle/chunks/chunk-LBJIRX7Z.js +6 -0
- package/dist/bundle/chunks/chunk-MIFIRXNI.js +1 -0
- package/dist/bundle/chunks/chunk-MOCB6GPI.js +62 -0
- package/dist/bundle/chunks/chunk-OYIATQ5V.js +6 -0
- package/dist/bundle/chunks/chunk-OZ76IUC5.js +10 -0
- package/dist/bundle/chunks/chunk-PEPBD26Q.js +2 -0
- package/dist/bundle/chunks/chunk-PES2WOIM.js +15 -0
- package/dist/bundle/chunks/chunk-PLMPLLOW.js +12 -0
- package/dist/bundle/chunks/chunk-PQPG4QOY.js +22 -0
- package/dist/bundle/chunks/chunk-PUUP54QP.js +9 -0
- package/dist/bundle/chunks/chunk-Q5XZ24VX.js +6 -0
- package/dist/bundle/chunks/chunk-QOFUETQV.js +4 -0
- package/dist/bundle/chunks/chunk-QPHABKP3.js +11 -0
- package/dist/bundle/chunks/chunk-RTGKIAVM.js +6 -0
- package/dist/bundle/chunks/chunk-RZ4GSKWY.js +7 -0
- package/dist/bundle/chunks/chunk-SF2462OV.js +3 -0
- package/dist/bundle/chunks/chunk-SJ7F47VW.js +6 -0
- package/dist/bundle/chunks/chunk-SMOO4IXI.js +1 -0
- package/dist/bundle/chunks/chunk-SPETXYUM.js +20 -0
- package/dist/bundle/chunks/chunk-SYTEZ2Y4.js +5 -0
- package/dist/bundle/chunks/chunk-TOK4OQFP.js +13 -0
- package/dist/bundle/chunks/chunk-U5Z7TJRO.js +11 -0
- package/dist/bundle/chunks/chunk-U6GF4IJH.js +72 -0
- package/dist/bundle/chunks/chunk-UBLR5ACC.js +1 -0
- package/dist/bundle/chunks/chunk-ULK572PS.js +7 -0
- package/dist/bundle/chunks/chunk-URMOT4S7.js +4 -0
- package/dist/bundle/chunks/chunk-USGCTFXK.js +2 -0
- package/dist/bundle/chunks/chunk-VKPVP3LD.js +4 -0
- package/dist/bundle/chunks/chunk-W4YQKIRV.js +35 -0
- package/dist/bundle/chunks/chunk-WMCZEPWH.js +8 -0
- package/dist/bundle/chunks/chunk-WTT2UCIA.js +20 -0
- package/dist/bundle/chunks/chunk-WVUVOYGQ.js +10 -0
- package/dist/bundle/chunks/chunk-XXS34VJC.js +12 -0
- package/dist/bundle/chunks/chunk-XZMBEDQL.js +7 -0
- package/dist/bundle/chunks/chunk-XZZ3XIZH.js +15 -0
- package/dist/bundle/chunks/chunk-YANZPHZ3.js +31 -0
- package/dist/bundle/chunks/chunk-YJHMB6QD.js +17 -0
- package/dist/bundle/chunks/chunk-YR4NQYT4.js +1 -0
- package/dist/bundle/chunks/chunk-YZPQ2W3A.js +139 -0
- package/dist/bundle/chunks/chunk-Z6DABRIE.js +12 -0
- package/dist/bundle/chunks/chunk-ZEHOKNGQ.js +2 -0
- package/dist/bundle/chunks/chunk-ZILSBZZ6.js +4 -0
- package/dist/bundle/chunks/clear-7SIFUXVD.js +1 -0
- package/dist/bundle/chunks/column-OUJRIWLX.js +1 -0
- package/dist/bundle/chunks/comm-47FVEMHB.js +1 -0
- package/dist/bundle/chunks/cp-FD6I3O6B.js +1 -0
- package/dist/bundle/chunks/curl-3MHMRKXA.js +25 -0
- package/dist/bundle/chunks/cut-LQZW2NZP.js +1 -0
- package/dist/bundle/chunks/date-MHLQVLQZ.js +1 -0
- package/dist/bundle/chunks/diff-7ZYMEVUP.js +1 -0
- package/dist/bundle/chunks/dirname-IVA4YYRE.js +1 -0
- package/dist/bundle/chunks/du-H4GJHM4R.js +1 -0
- package/dist/bundle/chunks/echo-ZPFMTGPQ.js +1 -0
- package/dist/bundle/chunks/env-ZCKP6263.js +1 -0
- package/dist/bundle/chunks/expand-Y7EMR5BJ.js +1 -0
- package/dist/bundle/chunks/expansion-GYIQOAHW.js +1 -0
- package/dist/bundle/chunks/expr-WDFXVU43.js +1 -0
- package/dist/bundle/chunks/file-7WSECN2B.js +1 -0
- package/dist/bundle/chunks/find-BYG3GTNV.js +1 -0
- package/dist/bundle/chunks/flag-coverage-VMMEL7EH.js +1 -0
- package/dist/bundle/chunks/fold-6O4H3AW4.js +1 -0
- package/dist/bundle/chunks/grep-KLQ4A2OH.js +1 -0
- package/dist/bundle/chunks/gzip-OUHELY5D.js +1 -0
- package/dist/bundle/chunks/head-CIKXFGO5.js +1 -0
- package/dist/bundle/chunks/help-B2UCSYQN.js +1 -0
- package/dist/bundle/chunks/history-N2VRLHEO.js +1 -0
- package/dist/bundle/chunks/hostname-W7U3GOEK.js +1 -0
- package/dist/bundle/chunks/html-to-markdown-ZDG5GHHM.js +1 -0
- package/dist/bundle/chunks/join-CFMKSF44.js +1 -0
- package/dist/bundle/chunks/jq-BE76GAFF.js +1 -0
- package/dist/bundle/chunks/ln-N3OWFM3J.js +1 -0
- package/dist/bundle/chunks/ls-JAO4QNWZ.js +1 -0
- package/dist/bundle/chunks/md5sum-ZK2D5HMO.js +1 -0
- package/dist/bundle/chunks/mkdir-O74MZREV.js +1 -0
- package/dist/bundle/chunks/mv-66ALAQRO.js +1 -0
- package/dist/bundle/chunks/nl-JSPXHHOM.js +1 -0
- package/dist/bundle/chunks/od-NUINXLUX.js +1 -0
- package/dist/bundle/chunks/paste-Y7CG4TKC.js +1 -0
- package/dist/bundle/chunks/printf-223LFYZL.js +1 -0
- package/dist/bundle/chunks/pwd-BP6H5JPD.js +1 -0
- package/dist/bundle/chunks/python3-2KEMASKS.js +13 -0
- package/dist/bundle/chunks/readlink-JL7TKP5U.js +1 -0
- package/dist/bundle/chunks/rev-UN4ZHPP5.js +1 -0
- package/dist/bundle/chunks/rg-PML6WNNK.js +1 -0
- package/dist/bundle/chunks/rm-NIZVTCU7.js +1 -0
- package/dist/bundle/chunks/rmdir-LGJXG7S3.js +1 -0
- package/dist/bundle/chunks/sed-JJ3WRWYT.js +1 -0
- package/dist/bundle/chunks/seq-UCWX6HDA.js +1 -0
- package/dist/bundle/chunks/sha1sum-BB464H3H.js +1 -0
- package/dist/bundle/chunks/sha256sum-PPJUHZ6A.js +1 -0
- package/dist/bundle/chunks/sleep-YQMDXMVK.js +1 -0
- package/dist/bundle/chunks/sort-BNPU2P3T.js +1 -0
- package/dist/bundle/chunks/split-SVMZIFGF.js +1 -0
- package/dist/bundle/chunks/sqlite3-PZGLI6XB.js +1 -0
- package/dist/bundle/chunks/stat-2CKLARLN.js +1 -0
- package/dist/bundle/chunks/strings-LG7URPXR.js +1 -0
- package/dist/bundle/chunks/tac-NXGTFB5T.js +1 -0
- package/dist/bundle/chunks/tail-GJ536HFQ.js +1 -0
- package/dist/bundle/chunks/tar-3KCFO6WZ.js +1 -0
- package/dist/bundle/chunks/tee-PJ6B6JJF.js +1 -0
- package/dist/bundle/chunks/time-IENYNVU4.js +1 -0
- package/dist/bundle/chunks/timeout-SXUKTL7R.js +1 -0
- package/dist/bundle/chunks/touch-7BNOFP74.js +1 -0
- package/dist/bundle/chunks/tr-TB6CSIUV.js +1 -0
- package/dist/bundle/chunks/tree-4XRVONUX.js +1 -0
- package/dist/bundle/chunks/true-4UI5ZW75.js +1 -0
- package/dist/bundle/chunks/unexpand-LDC3OTY4.js +1 -0
- package/dist/bundle/chunks/uniq-ZHYLWEFM.js +1 -0
- package/dist/bundle/chunks/wc-PWYVRT3X.js +1 -0
- package/dist/bundle/chunks/which-EIT2IJGG.js +1 -0
- package/dist/bundle/chunks/whoami-QZJHAL2R.js +1 -0
- package/dist/bundle/chunks/xan-JDD2TEQH.js +1 -0
- package/dist/bundle/chunks/xan-view-WKPGEZFG.js +1 -0
- package/dist/bundle/chunks/xargs-CB3LOKW5.js +1 -0
- package/dist/bundle/chunks/yq-JFXSVU6G.js +1 -0
- package/dist/bundle/index.js +289 -289
- package/dist/commands/head/head-tail-shared.d.ts +4 -3
- package/dist/commands/search-engine/index.d.ts +1 -0
- package/dist/commands/search-engine/stream-matcher.d.ts +31 -0
- package/dist/fs/encoding.d.ts +23 -7
- package/dist/fs/in-memory-fs/in-memory-fs.d.ts +9 -25
- package/dist/fs/interface.d.ts +24 -117
- package/dist/fs/mountable-fs/mountable-fs.d.ts +3 -2
- package/dist/fs/overlay-fs/overlay-fs.d.ts +10 -4
- package/dist/fs/read-write-fs/read-write-fs.d.ts +4 -4
- package/dist/index.d.ts +2 -0
- package/dist/interpreter/builtin-dispatch.d.ts +5 -4
- package/dist/interpreter/builtins/eval.d.ts +2 -1
- package/dist/interpreter/builtins/mapfile.d.ts +1 -1
- package/dist/interpreter/builtins/read.d.ts +1 -1
- package/dist/interpreter/control-flow.d.ts +2 -1
- package/dist/interpreter/errors.d.ts +20 -25
- package/dist/interpreter/functions.d.ts +2 -1
- package/dist/interpreter/helpers/loop.d.ts +4 -3
- package/dist/interpreter/helpers/result.d.ts +18 -32
- package/dist/interpreter/helpers/statements.d.ts +4 -3
- package/dist/interpreter/interpreter.d.ts +2 -4
- package/dist/interpreter/pipeline-execution.d.ts +2 -1
- package/dist/interpreter/subshell-group.d.ts +4 -3
- package/dist/interpreter/types.d.ts +4 -3
- package/dist/test-utils.d.ts +2 -3
- package/dist/types.d.ts +19 -91
- package/dist/utils/binary-string.d.ts +1 -0
- package/dist/utils/bytes.d.ts +0 -2
- package/dist/utils/stream.d.ts +65 -0
- package/package.json +31 -29
- package/dist/bin/chunks/alias-23G4Q2RS.js +0 -2
- package/dist/bin/chunks/awk2-Z6VRXKAK.js +0 -2
- package/dist/bin/chunks/base64-DNX4WCIO.js +0 -2
- package/dist/bin/chunks/basename-MPQ7M4RF.js +0 -2
- package/dist/bin/chunks/bash-OQ32Y5I6.js +0 -2
- package/dist/bin/chunks/bytes-6YUZMX3P.js +0 -2
- package/dist/bin/chunks/cat-CL5ISR5P.js +0 -2
- package/dist/bin/chunks/chmod-R6IWRSKZ.js +0 -2
- package/dist/bin/chunks/chunk-227L3ACM.js +0 -23
- package/dist/bin/chunks/chunk-2QA4P6HI.js +0 -12
- package/dist/bin/chunks/chunk-3MFM4GSH.js +0 -36
- package/dist/bin/chunks/chunk-3UP5LXDO.js +0 -3
- package/dist/bin/chunks/chunk-47P7JSQI.js +0 -2
- package/dist/bin/chunks/chunk-4KBTPDQB.js +0 -3
- package/dist/bin/chunks/chunk-4UK2MV3F.js +0 -13
- package/dist/bin/chunks/chunk-563AO4OL.js +0 -7
- package/dist/bin/chunks/chunk-5HDWUXRX.js +0 -7
- package/dist/bin/chunks/chunk-5MCFI6LE.js +0 -5
- package/dist/bin/chunks/chunk-6CZOPIZD.js +0 -6
- package/dist/bin/chunks/chunk-6FNFX5GG.js +0 -5
- package/dist/bin/chunks/chunk-6NYIHYDY.js +0 -7
- package/dist/bin/chunks/chunk-6Y4TKR73.js +0 -16
- package/dist/bin/chunks/chunk-7C7WEK46.js +0 -23
- package/dist/bin/chunks/chunk-7TNGQWY6.js +0 -6
- package/dist/bin/chunks/chunk-7UAWRBQS.js +0 -9
- package/dist/bin/chunks/chunk-ARGU3OIG.js +0 -17
- package/dist/bin/chunks/chunk-BA3A5BYZ.js +0 -3
- package/dist/bin/chunks/chunk-BB7T22CF.js +0 -140
- package/dist/bin/chunks/chunk-BY24LKGP.js +0 -8
- package/dist/bin/chunks/chunk-CRHN4WNQ.js +0 -63
- package/dist/bin/chunks/chunk-ELZHJGI7.js +0 -10
- package/dist/bin/chunks/chunk-F46CSMUF.js +0 -2
- package/dist/bin/chunks/chunk-FQX4G5RH.js +0 -7
- package/dist/bin/chunks/chunk-G43H2WGH.js +0 -17
- package/dist/bin/chunks/chunk-GMJWC3MC.js +0 -12
- package/dist/bin/chunks/chunk-HVDU57EV.js +0 -16
- package/dist/bin/chunks/chunk-HWGK3XW7.js +0 -6
- package/dist/bin/chunks/chunk-HYR7G7KS.js +0 -3
- package/dist/bin/chunks/chunk-I2225JSU.js +0 -14
- package/dist/bin/chunks/chunk-I2FUQZXU.js +0 -11
- package/dist/bin/chunks/chunk-IBHPKKIT.js +0 -10
- package/dist/bin/chunks/chunk-IKNNFJNZ.js +0 -14
- package/dist/bin/chunks/chunk-INPUJM7Y.js +0 -8
- package/dist/bin/chunks/chunk-IOBKPMWJ.js +0 -9
- package/dist/bin/chunks/chunk-IYSA2L6A.js +0 -13
- package/dist/bin/chunks/chunk-JMLNX7GE.js +0 -287
- package/dist/bin/chunks/chunk-K6DD7NH3.js +0 -9
- package/dist/bin/chunks/chunk-KFLJ4EMB.js +0 -4
- package/dist/bin/chunks/chunk-KOMDAXHM.js +0 -7
- package/dist/bin/chunks/chunk-KV7ZTM2R.js +0 -11
- package/dist/bin/chunks/chunk-LCCVVEJA.js +0 -10
- package/dist/bin/chunks/chunk-LUPJK5US.js +0 -84
- package/dist/bin/chunks/chunk-LWF3XDOC.js +0 -32
- package/dist/bin/chunks/chunk-LXNARM2C.js +0 -9
- package/dist/bin/chunks/chunk-LXZS3X5T.js +0 -9
- package/dist/bin/chunks/chunk-M4ICSCXT.js +0 -100
- package/dist/bin/chunks/chunk-MEBZXRGE.js +0 -5
- package/dist/bin/chunks/chunk-MSPSS36S.js +0 -16
- package/dist/bin/chunks/chunk-N335RIGZ.js +0 -20
- package/dist/bin/chunks/chunk-N5KGQWJH.js +0 -5
- package/dist/bin/chunks/chunk-NDHTQE5T.js +0 -8
- package/dist/bin/chunks/chunk-NF5G7X3O.js +0 -7
- package/dist/bin/chunks/chunk-NGKNJ6V2.js +0 -11
- package/dist/bin/chunks/chunk-OKQ6RACF.js +0 -73
- package/dist/bin/chunks/chunk-PBY7XGZ6.js +0 -8
- package/dist/bin/chunks/chunk-PHHNNFRS.js +0 -6
- package/dist/bin/chunks/chunk-PO6Y7TWQ.js +0 -6
- package/dist/bin/chunks/chunk-Q4TLKLIZ.js +0 -12
- package/dist/bin/chunks/chunk-QS6LP3E3.js +0 -6
- package/dist/bin/chunks/chunk-QT2GMJRJ.js +0 -8
- package/dist/bin/chunks/chunk-QUVW3R4I.js +0 -5
- package/dist/bin/chunks/chunk-QUYWT2TY.js +0 -21
- package/dist/bin/chunks/chunk-QWUII542.js +0 -2
- package/dist/bin/chunks/chunk-R5EQDD5Y.js +0 -13
- package/dist/bin/chunks/chunk-RQSPCXDR.js +0 -2
- package/dist/bin/chunks/chunk-RTC6C5QW.js +0 -2
- package/dist/bin/chunks/chunk-S5W2KVHC.js +0 -2
- package/dist/bin/chunks/chunk-SDXDICI4.js +0 -2
- package/dist/bin/chunks/chunk-SX7TI7Q2.js +0 -3
- package/dist/bin/chunks/chunk-TDJ55L4A.js +0 -16
- package/dist/bin/chunks/chunk-TNPUAMV3.js +0 -8
- package/dist/bin/chunks/chunk-TSGSFBQI.js +0 -14
- package/dist/bin/chunks/chunk-U5ZE562V.js +0 -2
- package/dist/bin/chunks/chunk-UIMH6I3G.js +0 -33
- package/dist/bin/chunks/chunk-UXPY5T2P.js +0 -9
- package/dist/bin/chunks/chunk-V5I6PHN2.js +0 -14
- package/dist/bin/chunks/chunk-VOTJNR36.js +0 -5
- package/dist/bin/chunks/chunk-W5XFREQC.js +0 -3
- package/dist/bin/chunks/chunk-X2MOXVGO.js +0 -26
- package/dist/bin/chunks/chunk-XOGQUO62.js +0 -2
- package/dist/bin/chunks/chunk-Y57BDPQ5.js +0 -6
- package/dist/bin/chunks/chunk-YE6KXFFU.js +0 -2
- package/dist/bin/chunks/chunk-YEPWKN4F.js +0 -3
- package/dist/bin/chunks/chunk-ZEDWVSUZ.js +0 -19
- package/dist/bin/chunks/chunk-ZI4TTZL5.js +0 -21
- package/dist/bin/chunks/chunk-ZZVIGHYS.js +0 -7
- package/dist/bin/chunks/clear-27OP2FQZ.js +0 -2
- package/dist/bin/chunks/column-FJNKONCJ.js +0 -2
- package/dist/bin/chunks/comm-5FNEJE7X.js +0 -2
- package/dist/bin/chunks/cp-LVKHKFHQ.js +0 -2
- package/dist/bin/chunks/curl-S4FJSZA5.js +0 -26
- package/dist/bin/chunks/cut-UXU6PNTT.js +0 -2
- package/dist/bin/chunks/date-GGPTXVUT.js +0 -2
- package/dist/bin/chunks/diff-3V3FOITV.js +0 -2
- package/dist/bin/chunks/dirname-455JDV2M.js +0 -2
- package/dist/bin/chunks/du-WUEAQO2W.js +0 -2
- package/dist/bin/chunks/echo-HBXOI5TQ.js +0 -2
- package/dist/bin/chunks/env-MXFHTVHS.js +0 -2
- package/dist/bin/chunks/expand-F4FM4ML2.js +0 -2
- package/dist/bin/chunks/expansion-7AYBVOIQ.js +0 -2
- package/dist/bin/chunks/expr-5ZKR5ER5.js +0 -2
- package/dist/bin/chunks/file-BFN7BKUR.js +0 -2
- package/dist/bin/chunks/find-W4BCEJEC.js +0 -2
- package/dist/bin/chunks/flag-coverage-DBKGNLJO.js +0 -2
- package/dist/bin/chunks/fold-AE57YLOS.js +0 -2
- package/dist/bin/chunks/grep-I63BWUKL.js +0 -2
- package/dist/bin/chunks/gzip-X5IDXWZE.js +0 -2
- package/dist/bin/chunks/head-TBQETLQX.js +0 -2
- package/dist/bin/chunks/help-HGMKZ2GW.js +0 -2
- package/dist/bin/chunks/history-2DYRIL3U.js +0 -2
- package/dist/bin/chunks/hostname-RWEPTCXH.js +0 -2
- package/dist/bin/chunks/html-to-markdown-2VQWCEKU.js +0 -2
- package/dist/bin/chunks/join-TRRWQBEU.js +0 -2
- package/dist/bin/chunks/jq-NFKKH27D.js +0 -2
- package/dist/bin/chunks/ln-BSEVUP2J.js +0 -2
- package/dist/bin/chunks/ls-IJLTWVOI.js +0 -2
- package/dist/bin/chunks/md5sum-ZIQHOC4K.js +0 -2
- package/dist/bin/chunks/mkdir-KYFAO2SF.js +0 -2
- package/dist/bin/chunks/mv-TWM2PA7Q.js +0 -2
- package/dist/bin/chunks/nl-XLF2HFST.js +0 -2
- package/dist/bin/chunks/od-BOM6JPTH.js +0 -2
- package/dist/bin/chunks/paste-FUGXVGJX.js +0 -2
- package/dist/bin/chunks/printf-XUGNJ3QM.js +0 -2
- package/dist/bin/chunks/pwd-RZG6GZEU.js +0 -2
- package/dist/bin/chunks/python3-PIXJS3YM.js +0 -14
- package/dist/bin/chunks/readlink-4SOSIDHE.js +0 -2
- package/dist/bin/chunks/rev-5E5UGSUZ.js +0 -2
- package/dist/bin/chunks/rg-4YJSQZN7.js +0 -2
- package/dist/bin/chunks/rm-3PFOF4E3.js +0 -2
- package/dist/bin/chunks/rmdir-CSK7CGH5.js +0 -2
- package/dist/bin/chunks/sed-XBCUZMEP.js +0 -2
- package/dist/bin/chunks/seq-H7ID4VMK.js +0 -2
- package/dist/bin/chunks/sha1sum-EDQNYXXH.js +0 -2
- package/dist/bin/chunks/sha256sum-APTG6DO2.js +0 -2
- package/dist/bin/chunks/sleep-PNT7KILS.js +0 -2
- package/dist/bin/chunks/sort-ELAGZUES.js +0 -2
- package/dist/bin/chunks/split-QGXYUWBC.js +0 -2
- package/dist/bin/chunks/sqlite3-ELLMKNNJ.js +0 -2
- package/dist/bin/chunks/stat-Q2TZRKO3.js +0 -2
- package/dist/bin/chunks/strings-IGEGP5QX.js +0 -2
- package/dist/bin/chunks/tac-VOEDJLLG.js +0 -2
- package/dist/bin/chunks/tail-JOQASWMV.js +0 -2
- package/dist/bin/chunks/tar-2UVSVD3P.js +0 -2
- package/dist/bin/chunks/tee-IQLEDZOQ.js +0 -2
- package/dist/bin/chunks/time-VRCJK2LI.js +0 -2
- package/dist/bin/chunks/timeout-A36YWZWR.js +0 -2
- package/dist/bin/chunks/touch-5ECNQNBP.js +0 -2
- package/dist/bin/chunks/tr-AVALLN54.js +0 -2
- package/dist/bin/chunks/tree-UFM5EDXS.js +0 -2
- package/dist/bin/chunks/true-BU5JSAAW.js +0 -2
- package/dist/bin/chunks/unexpand-TDRWZW5F.js +0 -2
- package/dist/bin/chunks/uniq-IKBUNAMN.js +0 -2
- package/dist/bin/chunks/wc-2R4RS2SX.js +0 -2
- package/dist/bin/chunks/which-6UVGMXDF.js +0 -2
- package/dist/bin/chunks/whoami-N6TLTETT.js +0 -2
- package/dist/bin/chunks/xan-JX5QUK32.js +0 -2
- package/dist/bin/chunks/xan-view-NFMUMJ7Z.js +0 -2
- package/dist/bin/chunks/xargs-4MYN4U3C.js +0 -2
- package/dist/bin/chunks/yq-EHDQVD7S.js +0 -2
- package/dist/bin/shell/chunks/alias-23G4Q2RS.js +0 -2
- package/dist/bin/shell/chunks/awk2-Z6VRXKAK.js +0 -2
- package/dist/bin/shell/chunks/base64-DNX4WCIO.js +0 -2
- package/dist/bin/shell/chunks/basename-MPQ7M4RF.js +0 -2
- package/dist/bin/shell/chunks/bash-OQ32Y5I6.js +0 -2
- package/dist/bin/shell/chunks/bytes-6YUZMX3P.js +0 -2
- package/dist/bin/shell/chunks/cat-CL5ISR5P.js +0 -2
- package/dist/bin/shell/chunks/chmod-R6IWRSKZ.js +0 -2
- package/dist/bin/shell/chunks/chunk-227L3ACM.js +0 -23
- package/dist/bin/shell/chunks/chunk-2QA4P6HI.js +0 -12
- package/dist/bin/shell/chunks/chunk-3MFM4GSH.js +0 -36
- package/dist/bin/shell/chunks/chunk-3UP5LXDO.js +0 -3
- package/dist/bin/shell/chunks/chunk-47P7JSQI.js +0 -2
- package/dist/bin/shell/chunks/chunk-4KBTPDQB.js +0 -3
- package/dist/bin/shell/chunks/chunk-4UK2MV3F.js +0 -13
- package/dist/bin/shell/chunks/chunk-563AO4OL.js +0 -7
- package/dist/bin/shell/chunks/chunk-5HDWUXRX.js +0 -7
- package/dist/bin/shell/chunks/chunk-5MCFI6LE.js +0 -5
- package/dist/bin/shell/chunks/chunk-6CZOPIZD.js +0 -6
- package/dist/bin/shell/chunks/chunk-6FNFX5GG.js +0 -5
- package/dist/bin/shell/chunks/chunk-6NYIHYDY.js +0 -7
- package/dist/bin/shell/chunks/chunk-6Y4TKR73.js +0 -16
- package/dist/bin/shell/chunks/chunk-7C7WEK46.js +0 -23
- package/dist/bin/shell/chunks/chunk-7TNGQWY6.js +0 -6
- package/dist/bin/shell/chunks/chunk-7UAWRBQS.js +0 -9
- package/dist/bin/shell/chunks/chunk-ARGU3OIG.js +0 -17
- package/dist/bin/shell/chunks/chunk-BA3A5BYZ.js +0 -3
- package/dist/bin/shell/chunks/chunk-BB7T22CF.js +0 -140
- package/dist/bin/shell/chunks/chunk-BY24LKGP.js +0 -8
- package/dist/bin/shell/chunks/chunk-CRHN4WNQ.js +0 -63
- package/dist/bin/shell/chunks/chunk-ELZHJGI7.js +0 -10
- package/dist/bin/shell/chunks/chunk-F46CSMUF.js +0 -2
- package/dist/bin/shell/chunks/chunk-FQX4G5RH.js +0 -7
- package/dist/bin/shell/chunks/chunk-G43H2WGH.js +0 -17
- package/dist/bin/shell/chunks/chunk-GMJWC3MC.js +0 -12
- package/dist/bin/shell/chunks/chunk-HVDU57EV.js +0 -16
- package/dist/bin/shell/chunks/chunk-HWGK3XW7.js +0 -6
- package/dist/bin/shell/chunks/chunk-HYR7G7KS.js +0 -3
- package/dist/bin/shell/chunks/chunk-I2225JSU.js +0 -14
- package/dist/bin/shell/chunks/chunk-I2FUQZXU.js +0 -11
- package/dist/bin/shell/chunks/chunk-IBHPKKIT.js +0 -10
- package/dist/bin/shell/chunks/chunk-IKNNFJNZ.js +0 -14
- package/dist/bin/shell/chunks/chunk-INPUJM7Y.js +0 -8
- package/dist/bin/shell/chunks/chunk-IOBKPMWJ.js +0 -9
- package/dist/bin/shell/chunks/chunk-IYSA2L6A.js +0 -13
- package/dist/bin/shell/chunks/chunk-JMLNX7GE.js +0 -287
- package/dist/bin/shell/chunks/chunk-K6DD7NH3.js +0 -9
- package/dist/bin/shell/chunks/chunk-KFLJ4EMB.js +0 -4
- package/dist/bin/shell/chunks/chunk-KOMDAXHM.js +0 -7
- package/dist/bin/shell/chunks/chunk-KV7ZTM2R.js +0 -11
- package/dist/bin/shell/chunks/chunk-LCCVVEJA.js +0 -10
- package/dist/bin/shell/chunks/chunk-LUPJK5US.js +0 -84
- package/dist/bin/shell/chunks/chunk-LWF3XDOC.js +0 -32
- package/dist/bin/shell/chunks/chunk-LXNARM2C.js +0 -9
- package/dist/bin/shell/chunks/chunk-LXZS3X5T.js +0 -9
- package/dist/bin/shell/chunks/chunk-M4ICSCXT.js +0 -100
- package/dist/bin/shell/chunks/chunk-MEBZXRGE.js +0 -5
- package/dist/bin/shell/chunks/chunk-MSPSS36S.js +0 -16
- package/dist/bin/shell/chunks/chunk-N335RIGZ.js +0 -20
- package/dist/bin/shell/chunks/chunk-N5KGQWJH.js +0 -5
- package/dist/bin/shell/chunks/chunk-NDHTQE5T.js +0 -8
- package/dist/bin/shell/chunks/chunk-NF5G7X3O.js +0 -7
- package/dist/bin/shell/chunks/chunk-NGKNJ6V2.js +0 -11
- package/dist/bin/shell/chunks/chunk-OKQ6RACF.js +0 -73
- package/dist/bin/shell/chunks/chunk-PBY7XGZ6.js +0 -8
- package/dist/bin/shell/chunks/chunk-PHHNNFRS.js +0 -6
- package/dist/bin/shell/chunks/chunk-PO6Y7TWQ.js +0 -6
- package/dist/bin/shell/chunks/chunk-Q4TLKLIZ.js +0 -12
- package/dist/bin/shell/chunks/chunk-QS6LP3E3.js +0 -6
- package/dist/bin/shell/chunks/chunk-QT2GMJRJ.js +0 -8
- package/dist/bin/shell/chunks/chunk-QUVW3R4I.js +0 -5
- package/dist/bin/shell/chunks/chunk-QUYWT2TY.js +0 -21
- package/dist/bin/shell/chunks/chunk-QWUII542.js +0 -2
- package/dist/bin/shell/chunks/chunk-R5EQDD5Y.js +0 -13
- package/dist/bin/shell/chunks/chunk-RQSPCXDR.js +0 -2
- package/dist/bin/shell/chunks/chunk-RTC6C5QW.js +0 -2
- package/dist/bin/shell/chunks/chunk-S5W2KVHC.js +0 -2
- package/dist/bin/shell/chunks/chunk-SDXDICI4.js +0 -2
- package/dist/bin/shell/chunks/chunk-SX7TI7Q2.js +0 -3
- package/dist/bin/shell/chunks/chunk-TDJ55L4A.js +0 -16
- package/dist/bin/shell/chunks/chunk-TNPUAMV3.js +0 -8
- package/dist/bin/shell/chunks/chunk-TSGSFBQI.js +0 -14
- package/dist/bin/shell/chunks/chunk-U5ZE562V.js +0 -2
- package/dist/bin/shell/chunks/chunk-UIMH6I3G.js +0 -33
- package/dist/bin/shell/chunks/chunk-UXPY5T2P.js +0 -9
- package/dist/bin/shell/chunks/chunk-V5I6PHN2.js +0 -14
- package/dist/bin/shell/chunks/chunk-VOTJNR36.js +0 -5
- package/dist/bin/shell/chunks/chunk-W5XFREQC.js +0 -3
- package/dist/bin/shell/chunks/chunk-X2MOXVGO.js +0 -26
- package/dist/bin/shell/chunks/chunk-XOGQUO62.js +0 -2
- package/dist/bin/shell/chunks/chunk-Y57BDPQ5.js +0 -6
- package/dist/bin/shell/chunks/chunk-YE6KXFFU.js +0 -2
- package/dist/bin/shell/chunks/chunk-YEPWKN4F.js +0 -3
- package/dist/bin/shell/chunks/chunk-ZEDWVSUZ.js +0 -19
- package/dist/bin/shell/chunks/chunk-ZI4TTZL5.js +0 -21
- package/dist/bin/shell/chunks/chunk-ZZVIGHYS.js +0 -7
- package/dist/bin/shell/chunks/clear-27OP2FQZ.js +0 -2
- package/dist/bin/shell/chunks/column-FJNKONCJ.js +0 -2
- package/dist/bin/shell/chunks/comm-5FNEJE7X.js +0 -2
- package/dist/bin/shell/chunks/cp-LVKHKFHQ.js +0 -2
- package/dist/bin/shell/chunks/curl-S4FJSZA5.js +0 -26
- package/dist/bin/shell/chunks/cut-UXU6PNTT.js +0 -2
- package/dist/bin/shell/chunks/date-GGPTXVUT.js +0 -2
- package/dist/bin/shell/chunks/diff-3V3FOITV.js +0 -2
- package/dist/bin/shell/chunks/dirname-455JDV2M.js +0 -2
- package/dist/bin/shell/chunks/du-WUEAQO2W.js +0 -2
- package/dist/bin/shell/chunks/echo-HBXOI5TQ.js +0 -2
- package/dist/bin/shell/chunks/env-MXFHTVHS.js +0 -2
- package/dist/bin/shell/chunks/expand-F4FM4ML2.js +0 -2
- package/dist/bin/shell/chunks/expansion-7AYBVOIQ.js +0 -2
- package/dist/bin/shell/chunks/expr-5ZKR5ER5.js +0 -2
- package/dist/bin/shell/chunks/file-BFN7BKUR.js +0 -2
- package/dist/bin/shell/chunks/find-W4BCEJEC.js +0 -2
- package/dist/bin/shell/chunks/flag-coverage-DBKGNLJO.js +0 -2
- package/dist/bin/shell/chunks/fold-AE57YLOS.js +0 -2
- package/dist/bin/shell/chunks/grep-I63BWUKL.js +0 -2
- package/dist/bin/shell/chunks/gzip-X5IDXWZE.js +0 -2
- package/dist/bin/shell/chunks/head-TBQETLQX.js +0 -2
- package/dist/bin/shell/chunks/help-HGMKZ2GW.js +0 -2
- package/dist/bin/shell/chunks/history-2DYRIL3U.js +0 -2
- package/dist/bin/shell/chunks/hostname-RWEPTCXH.js +0 -2
- package/dist/bin/shell/chunks/html-to-markdown-2VQWCEKU.js +0 -2
- package/dist/bin/shell/chunks/join-TRRWQBEU.js +0 -2
- package/dist/bin/shell/chunks/jq-NFKKH27D.js +0 -2
- package/dist/bin/shell/chunks/ln-BSEVUP2J.js +0 -2
- package/dist/bin/shell/chunks/ls-IJLTWVOI.js +0 -2
- package/dist/bin/shell/chunks/md5sum-ZIQHOC4K.js +0 -2
- package/dist/bin/shell/chunks/mkdir-KYFAO2SF.js +0 -2
- package/dist/bin/shell/chunks/mv-TWM2PA7Q.js +0 -2
- package/dist/bin/shell/chunks/nl-XLF2HFST.js +0 -2
- package/dist/bin/shell/chunks/od-BOM6JPTH.js +0 -2
- package/dist/bin/shell/chunks/paste-FUGXVGJX.js +0 -2
- package/dist/bin/shell/chunks/printf-XUGNJ3QM.js +0 -2
- package/dist/bin/shell/chunks/pwd-RZG6GZEU.js +0 -2
- package/dist/bin/shell/chunks/python3-PIXJS3YM.js +0 -14
- package/dist/bin/shell/chunks/readlink-4SOSIDHE.js +0 -2
- package/dist/bin/shell/chunks/rev-5E5UGSUZ.js +0 -2
- package/dist/bin/shell/chunks/rg-4YJSQZN7.js +0 -2
- package/dist/bin/shell/chunks/rm-3PFOF4E3.js +0 -2
- package/dist/bin/shell/chunks/rmdir-CSK7CGH5.js +0 -2
- package/dist/bin/shell/chunks/sed-XBCUZMEP.js +0 -2
- package/dist/bin/shell/chunks/seq-H7ID4VMK.js +0 -2
- package/dist/bin/shell/chunks/sha1sum-EDQNYXXH.js +0 -2
- package/dist/bin/shell/chunks/sha256sum-APTG6DO2.js +0 -2
- package/dist/bin/shell/chunks/sleep-PNT7KILS.js +0 -2
- package/dist/bin/shell/chunks/sort-ELAGZUES.js +0 -2
- package/dist/bin/shell/chunks/split-QGXYUWBC.js +0 -2
- package/dist/bin/shell/chunks/sqlite3-ELLMKNNJ.js +0 -2
- package/dist/bin/shell/chunks/stat-Q2TZRKO3.js +0 -2
- package/dist/bin/shell/chunks/strings-IGEGP5QX.js +0 -2
- package/dist/bin/shell/chunks/tac-VOEDJLLG.js +0 -2
- package/dist/bin/shell/chunks/tail-JOQASWMV.js +0 -2
- package/dist/bin/shell/chunks/tar-2UVSVD3P.js +0 -2
- package/dist/bin/shell/chunks/tee-IQLEDZOQ.js +0 -2
- package/dist/bin/shell/chunks/time-VRCJK2LI.js +0 -2
- package/dist/bin/shell/chunks/timeout-A36YWZWR.js +0 -2
- package/dist/bin/shell/chunks/touch-5ECNQNBP.js +0 -2
- package/dist/bin/shell/chunks/tr-AVALLN54.js +0 -2
- package/dist/bin/shell/chunks/tree-UFM5EDXS.js +0 -2
- package/dist/bin/shell/chunks/true-BU5JSAAW.js +0 -2
- package/dist/bin/shell/chunks/unexpand-TDRWZW5F.js +0 -2
- package/dist/bin/shell/chunks/uniq-IKBUNAMN.js +0 -2
- package/dist/bin/shell/chunks/wc-2R4RS2SX.js +0 -2
- package/dist/bin/shell/chunks/which-6UVGMXDF.js +0 -2
- package/dist/bin/shell/chunks/whoami-N6TLTETT.js +0 -2
- package/dist/bin/shell/chunks/xan-JX5QUK32.js +0 -2
- package/dist/bin/shell/chunks/xan-view-NFMUMJ7Z.js +0 -2
- package/dist/bin/shell/chunks/xargs-4MYN4U3C.js +0 -2
- package/dist/bin/shell/chunks/yq-EHDQVD7S.js +0 -2
- package/dist/bundle/chunks/alias-T2KDAHDL.js +0 -1
- package/dist/bundle/chunks/awk2-UIH6CPHX.js +0 -1
- package/dist/bundle/chunks/base64-RY5JPAQL.js +0 -1
- package/dist/bundle/chunks/basename-QT55QR7O.js +0 -1
- package/dist/bundle/chunks/bash-BZZ6TUGW.js +0 -1
- package/dist/bundle/chunks/bytes-W6ESHQ7F.js +0 -1
- package/dist/bundle/chunks/cat-WUR2OJUG.js +0 -1
- package/dist/bundle/chunks/chmod-LTQYKUUW.js +0 -1
- package/dist/bundle/chunks/chunk-24BT6QUB.js +0 -11
- package/dist/bundle/chunks/chunk-274QVGRQ.js +0 -2
- package/dist/bundle/chunks/chunk-2IKXAFP4.js +0 -11
- package/dist/bundle/chunks/chunk-2IO54DPD.js +0 -1
- package/dist/bundle/chunks/chunk-2VAJD54D.js +0 -13
- package/dist/bundle/chunks/chunk-34P4G5H7.js +0 -5
- package/dist/bundle/chunks/chunk-3OY3UJDR.js +0 -62
- package/dist/bundle/chunks/chunk-3R6EWKMD.js +0 -13
- package/dist/bundle/chunks/chunk-3SPSXVPQ.js +0 -2
- package/dist/bundle/chunks/chunk-43RXAZRC.js +0 -7
- package/dist/bundle/chunks/chunk-47LWQIG6.js +0 -15
- package/dist/bundle/chunks/chunk-4L3Y4LKT.js +0 -5
- package/dist/bundle/chunks/chunk-4LYDOEQ6.js +0 -4
- package/dist/bundle/chunks/chunk-4Q5DFBVQ.js +0 -6
- package/dist/bundle/chunks/chunk-4R5AUIZ4.js +0 -6
- package/dist/bundle/chunks/chunk-4UTZCT3W.js +0 -2
- package/dist/bundle/chunks/chunk-5FDLF2FN.js +0 -5
- package/dist/bundle/chunks/chunk-5HJSZMTG.js +0 -1
- package/dist/bundle/chunks/chunk-5NR6JZM4.js +0 -12
- package/dist/bundle/chunks/chunk-5PL72KVW.js +0 -7
- package/dist/bundle/chunks/chunk-6BM2WKUH.js +0 -23
- package/dist/bundle/chunks/chunk-6HLDZZOT.js +0 -4
- package/dist/bundle/chunks/chunk-7VHVF5PX.js +0 -20
- package/dist/bundle/chunks/chunk-A3YV3X3J.js +0 -6
- package/dist/bundle/chunks/chunk-AJNR4FJT.js +0 -8
- package/dist/bundle/chunks/chunk-AMQM5ZPF.js +0 -1
- package/dist/bundle/chunks/chunk-BCDE2QUY.js +0 -1
- package/dist/bundle/chunks/chunk-BVFIC7R6.js +0 -4
- package/dist/bundle/chunks/chunk-CC4HUWHZ.js +0 -4
- package/dist/bundle/chunks/chunk-CNCKROJZ.js +0 -10
- package/dist/bundle/chunks/chunk-CSFZQCAK.js +0 -139
- package/dist/bundle/chunks/chunk-CU7G2LMR.js +0 -1
- package/dist/bundle/chunks/chunk-CZP7PMAG.js +0 -4
- package/dist/bundle/chunks/chunk-D2OUCFAU.js +0 -8
- package/dist/bundle/chunks/chunk-DQXLKPVQ.js +0 -7
- package/dist/bundle/chunks/chunk-E6IR6BWV.js +0 -286
- package/dist/bundle/chunks/chunk-ELZ2RVIZ.js +0 -11
- package/dist/bundle/chunks/chunk-EVNUXIEZ.js +0 -2
- package/dist/bundle/chunks/chunk-F6FQRFZU.js +0 -6
- package/dist/bundle/chunks/chunk-FAECBHMR.js +0 -2
- package/dist/bundle/chunks/chunk-FBOLGXN4.js +0 -16
- package/dist/bundle/chunks/chunk-FNIOXBJW.js +0 -9
- package/dist/bundle/chunks/chunk-GD5SDRL7.js +0 -5
- package/dist/bundle/chunks/chunk-GEAGCSIY.js +0 -31
- package/dist/bundle/chunks/chunk-GI2KN5IL.js +0 -22
- package/dist/bundle/chunks/chunk-GOG2LNAH.js +0 -9
- package/dist/bundle/chunks/chunk-H2ENJVUI.js +0 -10
- package/dist/bundle/chunks/chunk-HDNR2KMO.js +0 -13
- package/dist/bundle/chunks/chunk-HJ37IXKX.js +0 -12
- package/dist/bundle/chunks/chunk-I36BZMR3.js +0 -1
- package/dist/bundle/chunks/chunk-I6YSZMB6.js +0 -15
- package/dist/bundle/chunks/chunk-IXD4Z54Z.js +0 -8
- package/dist/bundle/chunks/chunk-J44PYBAW.js +0 -2
- package/dist/bundle/chunks/chunk-JDREUEBG.js +0 -9
- package/dist/bundle/chunks/chunk-KA244HSE.js +0 -5
- package/dist/bundle/chunks/chunk-KKZJ6K7R.js +0 -8
- package/dist/bundle/chunks/chunk-KZ3P3SVS.js +0 -22
- package/dist/bundle/chunks/chunk-LIVSDOY2.js +0 -1
- package/dist/bundle/chunks/chunk-LX7SQKLW.js +0 -15
- package/dist/bundle/chunks/chunk-M5O5DYR7.js +0 -1
- package/dist/bundle/chunks/chunk-MML7K3J2.js +0 -6
- package/dist/bundle/chunks/chunk-N4GRDEVJ.js +0 -5
- package/dist/bundle/chunks/chunk-NPZMNEW5.js +0 -6
- package/dist/bundle/chunks/chunk-O7N2RCS7.js +0 -1
- package/dist/bundle/chunks/chunk-OSYLT4VG.js +0 -4
- package/dist/bundle/chunks/chunk-OXRHP7HO.js +0 -3
- package/dist/bundle/chunks/chunk-OZOS3R6K.js +0 -99
- package/dist/bundle/chunks/chunk-OZQ4AW5X.js +0 -8
- package/dist/bundle/chunks/chunk-PNGAWBIZ.js +0 -10
- package/dist/bundle/chunks/chunk-PPUKM2B7.js +0 -13
- package/dist/bundle/chunks/chunk-PTELGM2J.js +0 -7
- package/dist/bundle/chunks/chunk-Q3TLRYBC.js +0 -72
- package/dist/bundle/chunks/chunk-Q5AOYNOX.js +0 -6
- package/dist/bundle/chunks/chunk-QEKGAAIL.js +0 -1
- package/dist/bundle/chunks/chunk-QIL3FXIC.js +0 -6
- package/dist/bundle/chunks/chunk-QNZEO23C.js +0 -8
- package/dist/bundle/chunks/chunk-R4IVADTA.js +0 -7
- package/dist/bundle/chunks/chunk-RK57WTFF.js +0 -12
- package/dist/bundle/chunks/chunk-RU5M6ZRS.js +0 -4
- package/dist/bundle/chunks/chunk-SBVBPPEQ.js +0 -5
- package/dist/bundle/chunks/chunk-SP22LBKJ.js +0 -20
- package/dist/bundle/chunks/chunk-UKS3AEEA.js +0 -32
- package/dist/bundle/chunks/chunk-UYR5HJI6.js +0 -7
- package/dist/bundle/chunks/chunk-V6ANTLBA.js +0 -15
- package/dist/bundle/chunks/chunk-VLGZJRPG.js +0 -16
- package/dist/bundle/chunks/chunk-VZUQMDOT.js +0 -2
- package/dist/bundle/chunks/chunk-XDQU6V6S.js +0 -19
- package/dist/bundle/chunks/chunk-XRVUJRYI.js +0 -35
- package/dist/bundle/chunks/clear-NLKZY76S.js +0 -1
- package/dist/bundle/chunks/column-S7P64XRJ.js +0 -1
- package/dist/bundle/chunks/comm-FPLN4BYY.js +0 -1
- package/dist/bundle/chunks/cp-W5HXJH5J.js +0 -1
- package/dist/bundle/chunks/curl-UFR6W4B6.js +0 -25
- package/dist/bundle/chunks/cut-VNFQFCA7.js +0 -1
- package/dist/bundle/chunks/date-EDSSFONA.js +0 -1
- package/dist/bundle/chunks/diff-RR5VJXIT.js +0 -1
- package/dist/bundle/chunks/dirname-V7Z24BGZ.js +0 -1
- package/dist/bundle/chunks/du-QKRPQIMY.js +0 -1
- package/dist/bundle/chunks/echo-TR3BM2AJ.js +0 -1
- package/dist/bundle/chunks/env-SVQBHVZF.js +0 -1
- package/dist/bundle/chunks/expand-ZVCJ72RF.js +0 -1
- package/dist/bundle/chunks/expansion-OBOJBZTH.js +0 -1
- package/dist/bundle/chunks/expr-QRA5KFYV.js +0 -1
- package/dist/bundle/chunks/file-TORG4IVZ.js +0 -1
- package/dist/bundle/chunks/find-NAGPRRQ7.js +0 -1
- package/dist/bundle/chunks/flag-coverage-FMTW4YWD.js +0 -1
- package/dist/bundle/chunks/fold-L4U6GS2N.js +0 -1
- package/dist/bundle/chunks/grep-D6AI423Z.js +0 -1
- package/dist/bundle/chunks/gzip-4EFUBHN7.js +0 -1
- package/dist/bundle/chunks/head-KBQT2JAC.js +0 -1
- package/dist/bundle/chunks/help-F3TJS3LS.js +0 -1
- package/dist/bundle/chunks/history-OKEAINJD.js +0 -1
- package/dist/bundle/chunks/hostname-AGIPNJOC.js +0 -1
- package/dist/bundle/chunks/html-to-markdown-P2LSCPVF.js +0 -1
- package/dist/bundle/chunks/join-FTSZAZYU.js +0 -1
- package/dist/bundle/chunks/jq-TNIKCGGT.js +0 -1
- package/dist/bundle/chunks/ln-BWYUCELO.js +0 -1
- package/dist/bundle/chunks/ls-6BM6G675.js +0 -1
- package/dist/bundle/chunks/md5sum-ALFVDB3W.js +0 -1
- package/dist/bundle/chunks/mkdir-I3BZBLTZ.js +0 -1
- package/dist/bundle/chunks/mv-76WRD5SE.js +0 -1
- package/dist/bundle/chunks/nl-77Q7V2GV.js +0 -1
- package/dist/bundle/chunks/od-AA6TIC6A.js +0 -1
- package/dist/bundle/chunks/paste-C6JKQOHO.js +0 -1
- package/dist/bundle/chunks/printf-WOYMDX2I.js +0 -1
- package/dist/bundle/chunks/pwd-BE3B3ZPG.js +0 -1
- package/dist/bundle/chunks/python3-QFUFNW7I.js +0 -13
- package/dist/bundle/chunks/readlink-QI6K7ZZX.js +0 -1
- package/dist/bundle/chunks/rev-2FZQEIQG.js +0 -1
- package/dist/bundle/chunks/rg-CNS6SD3V.js +0 -1
- package/dist/bundle/chunks/rm-JMWEKCU4.js +0 -1
- package/dist/bundle/chunks/rmdir-5HDB4IQ7.js +0 -1
- package/dist/bundle/chunks/sed-CSUGXVBJ.js +0 -1
- package/dist/bundle/chunks/seq-UP62NDEL.js +0 -1
- package/dist/bundle/chunks/sha1sum-XXYTWQIW.js +0 -1
- package/dist/bundle/chunks/sha256sum-GD6AFWG3.js +0 -1
- package/dist/bundle/chunks/sleep-225KIGXI.js +0 -1
- package/dist/bundle/chunks/sort-BIWEEIVX.js +0 -1
- package/dist/bundle/chunks/split-QUFGLTTX.js +0 -1
- package/dist/bundle/chunks/sqlite3-3ZFEGTQ7.js +0 -1
- package/dist/bundle/chunks/stat-DIMPSC6S.js +0 -1
- package/dist/bundle/chunks/strings-LECMRXOT.js +0 -1
- package/dist/bundle/chunks/tac-A6JKZKWL.js +0 -1
- package/dist/bundle/chunks/tail-YGDXZZGG.js +0 -1
- package/dist/bundle/chunks/tar-7KN7KZ6S.js +0 -1
- package/dist/bundle/chunks/tee-J4MBDQJZ.js +0 -1
- package/dist/bundle/chunks/time-CVS7ESWV.js +0 -1
- package/dist/bundle/chunks/timeout-UX2PSLYJ.js +0 -1
- package/dist/bundle/chunks/touch-ATQADRUQ.js +0 -1
- package/dist/bundle/chunks/tr-QVFN4YWH.js +0 -1
- package/dist/bundle/chunks/tree-IY7WNFVF.js +0 -1
- package/dist/bundle/chunks/true-AKKYE7WM.js +0 -1
- package/dist/bundle/chunks/unexpand-2WTX7UPB.js +0 -1
- package/dist/bundle/chunks/uniq-XS6VGRO2.js +0 -1
- package/dist/bundle/chunks/wc-22EISCPD.js +0 -1
- package/dist/bundle/chunks/which-IWHCX6SW.js +0 -1
- package/dist/bundle/chunks/whoami-HCON4D7C.js +0 -1
- package/dist/bundle/chunks/xan-XDECJHII.js +0 -1
- package/dist/bundle/chunks/xan-view-IJ4EABH7.js +0 -1
- package/dist/bundle/chunks/xargs-5MMN7C6P.js +0 -1
- package/dist/bundle/chunks/yq-LQX5YIGM.js +0 -1
package/dist/bin/shell/shell.js
CHANGED
|
@@ -1,158 +1,158 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{A as rs,C as bn,D as En,E as fe,F as We,G as te,H as $e,I as St,J as Sn,K as F,L as $n,M as An,N as Ce,O as is,P as $t,Q as He,R as q,a as fn,b as Jt,c as dn,d as hn,e as bt,f as Q,g as H,h as Ae,i as ne,j as _e,k as Ie,l as es,m as Et,n as pn,o as ts,p as mn,q as ue,r as Oe,s as yn,t as gn,u as ss,v as ns,w as Pe,x as vn,y as wn,z as Se}from"./chunks/chunk-OKQ6RACF.js";import{a as De,b as Ee}from"./chunks/chunk-F46CSMUF.js";import{a as st}from"./chunks/chunk-SE4C7FJY.js";import{a as me,b as ye,c as ce,d as ve,e as cn,f as G,g as Fe,h as gt,i as vt,j as un,k as oe,l as Te,m as wt,n as we}from"./chunks/chunk-QT2GMJRJ.js";import"./chunks/chunk-OBH7XN5N.js";import{a as be}from"./chunks/chunk-4VDEBYW7.js";import{a as yt,g as p,h as E,i as z,j as N,k as je,l as tt,m as O,n as v}from"./chunks/chunk-RQSPCXDR.js";import*as ei from"node:fs";import*as ti from"node:readline";var Ue=[{name:"echo",load:async()=>(await import("./chunks/echo-HBXOI5TQ.js")).echoCommand},{name:"cat",load:async()=>(await import("./chunks/cat-CL5ISR5P.js")).catCommand},{name:"printf",load:async()=>(await import("./chunks/printf-XUGNJ3QM.js")).printfCommand},{name:"ls",load:async()=>(await import("./chunks/ls-IJLTWVOI.js")).lsCommand},{name:"mkdir",load:async()=>(await import("./chunks/mkdir-KYFAO2SF.js")).mkdirCommand},{name:"rmdir",load:async()=>(await import("./chunks/rmdir-CSK7CGH5.js")).rmdirCommand},{name:"touch",load:async()=>(await import("./chunks/touch-5ECNQNBP.js")).touchCommand},{name:"rm",load:async()=>(await import("./chunks/rm-3PFOF4E3.js")).rmCommand},{name:"cp",load:async()=>(await import("./chunks/cp-LVKHKFHQ.js")).cpCommand},{name:"mv",load:async()=>(await import("./chunks/mv-TWM2PA7Q.js")).mvCommand},{name:"ln",load:async()=>(await import("./chunks/ln-BSEVUP2J.js")).lnCommand},{name:"chmod",load:async()=>(await import("./chunks/chmod-R6IWRSKZ.js")).chmodCommand},{name:"pwd",load:async()=>(await import("./chunks/pwd-RZG6GZEU.js")).pwdCommand},{name:"readlink",load:async()=>(await import("./chunks/readlink-4SOSIDHE.js")).readlinkCommand},{name:"head",load:async()=>(await import("./chunks/head-TBQETLQX.js")).headCommand},{name:"tail",load:async()=>(await import("./chunks/tail-JOQASWMV.js")).tailCommand},{name:"wc",load:async()=>(await import("./chunks/wc-2R4RS2SX.js")).wcCommand},{name:"stat",load:async()=>(await import("./chunks/stat-Q2TZRKO3.js")).statCommand},{name:"grep",load:async()=>(await import("./chunks/grep-I63BWUKL.js")).grepCommand},{name:"fgrep",load:async()=>(await import("./chunks/grep-I63BWUKL.js")).fgrepCommand},{name:"egrep",load:async()=>(await import("./chunks/grep-I63BWUKL.js")).egrepCommand},{name:"rg",load:async()=>(await import("./chunks/rg-4YJSQZN7.js")).rgCommand},{name:"sed",load:async()=>(await import("./chunks/sed-XBCUZMEP.js")).sedCommand},{name:"awk",load:async()=>(await import("./chunks/awk2-Z6VRXKAK.js")).awkCommand2},{name:"sort",load:async()=>(await import("./chunks/sort-ELAGZUES.js")).sortCommand},{name:"uniq",load:async()=>(await import("./chunks/uniq-IKBUNAMN.js")).uniqCommand},{name:"comm",load:async()=>(await import("./chunks/comm-5FNEJE7X.js")).commCommand},{name:"cut",load:async()=>(await import("./chunks/cut-UXU6PNTT.js")).cutCommand},{name:"paste",load:async()=>(await import("./chunks/paste-FUGXVGJX.js")).pasteCommand},{name:"tr",load:async()=>(await import("./chunks/tr-AVALLN54.js")).trCommand},{name:"rev",load:async()=>(await import("./chunks/rev-5E5UGSUZ.js")).rev},{name:"nl",load:async()=>(await import("./chunks/nl-XLF2HFST.js")).nl},{name:"fold",load:async()=>(await import("./chunks/fold-AE57YLOS.js")).fold},{name:"expand",load:async()=>(await import("./chunks/expand-F4FM4ML2.js")).expand},{name:"unexpand",load:async()=>(await import("./chunks/unexpand-TDRWZW5F.js")).unexpand},{name:"strings",load:async()=>(await import("./chunks/strings-IGEGP5QX.js")).strings},{name:"split",load:async()=>(await import("./chunks/split-QGXYUWBC.js")).split},{name:"column",load:async()=>(await import("./chunks/column-FJNKONCJ.js")).column},{name:"join",load:async()=>(await import("./chunks/join-TRRWQBEU.js")).join},{name:"tee",load:async()=>(await import("./chunks/tee-IQLEDZOQ.js")).teeCommand},{name:"find",load:async()=>(await import("./chunks/find-W4BCEJEC.js")).findCommand},{name:"basename",load:async()=>(await import("./chunks/basename-MPQ7M4RF.js")).basenameCommand},{name:"dirname",load:async()=>(await import("./chunks/dirname-455JDV2M.js")).dirnameCommand},{name:"tree",load:async()=>(await import("./chunks/tree-UFM5EDXS.js")).treeCommand},{name:"du",load:async()=>(await import("./chunks/du-WUEAQO2W.js")).duCommand},{name:"env",load:async()=>(await import("./chunks/env-MXFHTVHS.js")).envCommand},{name:"printenv",load:async()=>(await import("./chunks/env-MXFHTVHS.js")).printenvCommand},{name:"alias",load:async()=>(await import("./chunks/alias-23G4Q2RS.js")).aliasCommand},{name:"unalias",load:async()=>(await import("./chunks/alias-23G4Q2RS.js")).unaliasCommand},{name:"history",load:async()=>(await import("./chunks/history-2DYRIL3U.js")).historyCommand},{name:"xargs",load:async()=>(await import("./chunks/xargs-4MYN4U3C.js")).xargsCommand},{name:"true",load:async()=>(await import("./chunks/true-BU5JSAAW.js")).trueCommand},{name:"false",load:async()=>(await import("./chunks/true-BU5JSAAW.js")).falseCommand},{name:"clear",load:async()=>(await import("./chunks/clear-27OP2FQZ.js")).clearCommand},{name:"bash",load:async()=>(await import("./chunks/bash-OQ32Y5I6.js")).bashCommand},{name:"sh",load:async()=>(await import("./chunks/bash-OQ32Y5I6.js")).shCommand},{name:"jq",load:async()=>(await import("./chunks/jq-NFKKH27D.js")).jqCommand},{name:"base64",load:async()=>(await import("./chunks/base64-DNX4WCIO.js")).base64Command},{name:"diff",load:async()=>(await import("./chunks/diff-3V3FOITV.js")).diffCommand},{name:"date",load:async()=>(await import("./chunks/date-GGPTXVUT.js")).dateCommand},{name:"sleep",load:async()=>(await import("./chunks/sleep-PNT7KILS.js")).sleepCommand},{name:"timeout",load:async()=>(await import("./chunks/timeout-A36YWZWR.js")).timeoutCommand},{name:"time",load:async()=>(await import("./chunks/time-VRCJK2LI.js")).timeCommand},{name:"seq",load:async()=>(await import("./chunks/seq-H7ID4VMK.js")).seqCommand},{name:"expr",load:async()=>(await import("./chunks/expr-5ZKR5ER5.js")).exprCommand},{name:"md5sum",load:async()=>(await import("./chunks/md5sum-ZIQHOC4K.js")).md5sumCommand},{name:"sha1sum",load:async()=>(await import("./chunks/sha1sum-EDQNYXXH.js")).sha1sumCommand},{name:"sha256sum",load:async()=>(await import("./chunks/sha256sum-APTG6DO2.js")).sha256sumCommand},{name:"file",load:async()=>(await import("./chunks/file-BFN7BKUR.js")).fileCommand},{name:"html-to-markdown",load:async()=>(await import("./chunks/html-to-markdown-2VQWCEKU.js")).htmlToMarkdownCommand},{name:"help",load:async()=>(await import("./chunks/help-HGMKZ2GW.js")).helpCommand},{name:"which",load:async()=>(await import("./chunks/which-6UVGMXDF.js")).whichCommand},{name:"tac",load:async()=>(await import("./chunks/tac-VOEDJLLG.js")).tac},{name:"hostname",load:async()=>(await import("./chunks/hostname-RWEPTCXH.js")).hostname},{name:"whoami",load:async()=>(await import("./chunks/whoami-N6TLTETT.js")).whoami},{name:"od",load:async()=>(await import("./chunks/od-BOM6JPTH.js")).od},{name:"gzip",load:async()=>(await import("./chunks/gzip-X5IDXWZE.js")).gzipCommand},{name:"gunzip",load:async()=>(await import("./chunks/gzip-X5IDXWZE.js")).gunzipCommand},{name:"zcat",load:async()=>(await import("./chunks/gzip-X5IDXWZE.js")).zcatCommand}];(typeof __BROWSER__>"u"||!__BROWSER__)&&(Ue.push({name:"tar",load:async()=>(await import("./chunks/tar-2UVSVD3P.js")).tarCommand}),Ue.push({name:"yq",load:async()=>(await import("./chunks/yq-EHDQVD7S.js")).yqCommand}),Ue.push({name:"xan",load:async()=>(await import("./chunks/xan-JX5QUK32.js")).xanCommand}),Ue.push({name:"sqlite3",load:async()=>(await import("./chunks/sqlite3-ELLMKNNJ.js")).sqlite3Command}));var os=[];(typeof __BROWSER__>"u"||!__BROWSER__)&&(os.push({name:"python3",load:async()=>(await import("./chunks/python3-PIXJS3YM.js")).python3Command}),os.push({name:"python",load:async()=>(await import("./chunks/python3-PIXJS3YM.js")).pythonCommand}));var ii=[{name:"curl",load:async()=>(await import("./chunks/curl-S4FJSZA5.js")).curlCommand}],_n=new Map;function as(e){return{name:e.name,async execute(t,s){let n=_n.get(e.name);if(n||(n=await e.load(),_n.set(e.name,n)),s.coverage&&(typeof __BROWSER__>"u"||!__BROWSER__)){let{emitFlagCoverage:r}=await import("./chunks/flag-coverage-DBKGNLJO.js"),{decodeArgs:i}=await import("./chunks/bytes-6YUZMX3P.js");r(s.coverage,e.name,i(t))}return n.execute(t,s)}}}function Pn(e){return(e?Ue.filter(s=>e.includes(s.name)):Ue).map(as)}function Cn(){return ii.map(as)}function kn(){return os.map(as)}function Nn(e){return"load"in e&&typeof e.load=="function"}function On(e){let t=null;return{name:e.name,async execute(s,n){return t||(t=await e.load()),t.execute(s,n)}}}var oi=new TextEncoder,ai=new TextDecoder;function Ge(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 oi.encode(e)}function At(e,t){if(t==="base64")return btoa(String.fromCharCode(...e));if(t==="hex")return Array.from(e).map(s=>s.toString(16).padStart(2,"0")).join("");if(t==="binary"||t==="latin1"){if(typeof Buffer<"u")return Buffer.from(e).toString(t);let s=65536;if(e.length<=s)return String.fromCharCode(...e);let n="";for(let r=0;r<e.length;r+=s){let i=e.subarray(r,r+s);n+=String.fromCharCode(...i)}return n}return ai.decode(e)}function Re(e){if(e!=null)return typeof e=="string"?e:e.encoding??void 0}var _t=new TextEncoder;function li(e){return typeof e=="object"&&e!==null&&!(e instanceof Uint8Array)&&"content"in e}function ae(e,t){if(e.includes("\0"))throw new Error(`ENOENT: path contains null byte, ${t} '${e}'`)}var nt=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))li(n)?this.writeFileSync(s,n.content,void 0,{mode:n.mode,mtime:n.mtime}):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){ae(t,"write");let i=this.normalizePath(t);this.ensureParentDirs(i);let o=Re(n),a=Ge(s,o);this.data.set(i,{type:"file",content:a,mode:r?.mode??420,mtime:r?.mtime??new Date})}async readFile(t,s){let n=await this.readFileBuffer(t),r=Re(s);return At(n,r)}async readFileBuffer(t){ae(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 n.content instanceof Uint8Array?n.content:_t.encode(n.content)}async writeFile(t,s,n){this.writeFileSync(t,s,n)}async appendFile(t,s,n){ae(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 o=Re(n),a=Ge(s,o);if(i?.type==="file"){let c=i.content instanceof Uint8Array?i.content:_t.encode(i.content),u=new Uint8Array(c.length+a.length);u.set(c),u.set(a,c.length),this.data.set(r,{type:"file",content:u,mode:i.mode,mtime:new Date})}else this.writeFileSync(t,s,n)}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){ae(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"&&n.content&&(n.content instanceof Uint8Array?r=n.content.length:r=_t.encode(n.content).length),{isFile:n.type==="file",isDirectory:n.type==="directory",isSymbolicLink:!1,mode:n.mode,size:r,mtime:n.mtime||new Date}}async lstat(t){ae(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"&&n.content&&(n.content instanceof Uint8Array?r=n.content.length:r=_t.encode(n.content).length),{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 o=0;o<n.length-1;o++){let a=n[o];r=`${r}/${a}`;let c=this.data.get(r),u=0,l=40;for(;c&&c.type==="symlink"&&u<l;){if(i.has(r))throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`);i.add(r),r=this.resolveSymlink(r,c.target),c=this.data.get(r),u++}if(u>=l)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 o of n){r=`${r}/${o}`;let a=this.data.get(r),c=0,u=40;for(;a&&a.type==="symlink"&&c<u;){if(i.has(r))throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`);i.add(r),r=this.resolveSymlink(r,a.target),a=this.data.get(r),c++}if(c>=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){ae(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){ae(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}/`,o=new Map;for(let[a,c]of this.data.entries())if(a!==s&&a.startsWith(i)){let u=a.slice(i.length),l=u.split("/")[0];l&&!u.includes("/",l.length)&&!o.has(l)&&o.set(l,{name:l,isFile:c.type==="file",isDirectory:c.type==="directory",isSymbolicLink:c.type==="symlink"})}return Array.from(o.values()).sort((a,c)=>a.name<c.name?-1:a.name>c.name?1:0)}async rm(t,s){ae(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 o of i){let a=n==="/"?`/${o}`:`${n}/${o}`;await this.rm(a,s)}}}this.data.delete(n)}async cp(t,s,n){ae(t,"cp"),ae(s,"cp");let r=this.normalizePath(t),i=this.normalizePath(s),o=this.data.get(r);if(!o)throw new Error(`ENOENT: no such file or directory, cp '${t}'`);if(o.type==="file")this.ensureParentDirs(i),this.data.set(i,{...o});else if(o.type==="directory"){if(!n?.recursive)throw new Error(`EISDIR: is a directory, cp '${t}'`);await this.mkdir(i,{recursive:!0});let a=await this.readdir(r);for(let c of a){let u=r==="/"?`/${c}`:`${r}/${c}`,l=i==="/"?`/${c}`:`${i}/${c}`;await this.cp(u,l,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){ae(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){ae(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){ae(t,"link"),ae(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",content:i.content,mode:i.mode,mtime:i.mtime})}async readlink(t){ae(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){ae(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){ae(t,"utimes");let r=this.normalizePath(t),i=this.resolvePathWithSymlinks(r),o=this.data.get(i);if(!o)throw new Error(`ENOENT: no such file or directory, utimes '${t}'`);o.mtime=n}};function ci(e){let t=e;return typeof t.mkdirSync=="function"&&typeof t.writeFileSync=="function"}function ui(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 fi(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 di(e){e.mkdirSync("/proc/self/fd",{recursive:!0}),e.writeFileSync("/proc/version",`${fn}
|
|
2
|
+
import{A as hs,C as xr,D as Tr,E as ye,F as He,G as ie,H as Pe,I as Tt,J as Or,K as V,L as Dr,M as Ir,N as De,O as ps,P as Ot,Q as Ze,R as X,a as Sr,b as ls,c as Er,d as $r,e as Nt,f as se,g as G,h as xe,i as le,j as Te,k as ze,l as cs,m as xt,n as Ar,o as us,p as _r,q as me,r as Le,s as Cr,t as kr,u as fs,v as ds,w as Oe,x as Pr,y as Nr,z as ke}from"./chunks/chunk-YJFLWG5Q.js";import{a as br}from"./chunks/chunk-RUESYAVK.js";import{a as We,b as Ce}from"./chunks/chunk-CAXM2HMK.js";import{a as ut}from"./chunks/chunk-SE4C7FJY.js";import{a as be,b as Se,c as pe,d as $e,e as wr,f as Z,g as je,h as Ct,i as kt,j as vr,k as fe,l as Fe,m as Pt,n as Ae}from"./chunks/chunk-XILOLP4K.js";import"./chunks/chunk-OBH7XN5N.js";import{a as _e}from"./chunks/chunk-4VDEBYW7.js";import{a as lt,b as w,c as te,d as he,e as N,f as Y,g as ct,h as D,i as as,j as _t}from"./chunks/chunk-RAUBS6MJ.js";import{a as At,g as M,h as B,i as H,j as gr,k as at,l as T,m as g}from"./chunks/chunk-463VWH7H.js";import*as hi from"node:fs";import*as pi from"node:readline";var Ye=[{name:"echo",load:async()=>(await import("./chunks/echo-5EBIR54T.js")).echoCommand},{name:"cat",load:async()=>(await import("./chunks/cat-D4E4FTXJ.js")).catCommand},{name:"printf",load:async()=>(await import("./chunks/printf-OCMANWQ5.js")).printfCommand},{name:"ls",load:async()=>(await import("./chunks/ls-SLO257WP.js")).lsCommand},{name:"mkdir",load:async()=>(await import("./chunks/mkdir-EOATYYLD.js")).mkdirCommand},{name:"rmdir",load:async()=>(await import("./chunks/rmdir-5MNK2AUK.js")).rmdirCommand},{name:"touch",load:async()=>(await import("./chunks/touch-J6X4OW3P.js")).touchCommand},{name:"rm",load:async()=>(await import("./chunks/rm-BZWDOVUX.js")).rmCommand},{name:"cp",load:async()=>(await import("./chunks/cp-7TMSGOID.js")).cpCommand},{name:"mv",load:async()=>(await import("./chunks/mv-QUAFQDCT.js")).mvCommand},{name:"ln",load:async()=>(await import("./chunks/ln-PZ7JHGH2.js")).lnCommand},{name:"chmod",load:async()=>(await import("./chunks/chmod-OY5CP5QF.js")).chmodCommand},{name:"pwd",load:async()=>(await import("./chunks/pwd-PQGDLYLZ.js")).pwdCommand},{name:"readlink",load:async()=>(await import("./chunks/readlink-F66ORZVY.js")).readlinkCommand},{name:"head",load:async()=>(await import("./chunks/head-YZQN4BHR.js")).headCommand},{name:"tail",load:async()=>(await import("./chunks/tail-EI24LQBP.js")).tailCommand},{name:"wc",load:async()=>(await import("./chunks/wc-NNQHXBLM.js")).wcCommand},{name:"stat",load:async()=>(await import("./chunks/stat-6QXPS4BF.js")).statCommand},{name:"grep",load:async()=>(await import("./chunks/grep-6OXCYWRV.js")).grepCommand},{name:"fgrep",load:async()=>(await import("./chunks/grep-6OXCYWRV.js")).fgrepCommand},{name:"egrep",load:async()=>(await import("./chunks/grep-6OXCYWRV.js")).egrepCommand},{name:"rg",load:async()=>(await import("./chunks/rg-D5WXPSFJ.js")).rgCommand},{name:"sed",load:async()=>(await import("./chunks/sed-HN3E3YFB.js")).sedCommand},{name:"awk",load:async()=>(await import("./chunks/awk2-GM5WBRLU.js")).awkCommand2},{name:"sort",load:async()=>(await import("./chunks/sort-FT4OVPSS.js")).sortCommand},{name:"uniq",load:async()=>(await import("./chunks/uniq-C3ZUQTF4.js")).uniqCommand},{name:"comm",load:async()=>(await import("./chunks/comm-LMDA7QZC.js")).commCommand},{name:"cut",load:async()=>(await import("./chunks/cut-P6LPALWP.js")).cutCommand},{name:"paste",load:async()=>(await import("./chunks/paste-6XYPZQXQ.js")).pasteCommand},{name:"tr",load:async()=>(await import("./chunks/tr-2C3Q77EZ.js")).trCommand},{name:"rev",load:async()=>(await import("./chunks/rev-67WGH7WN.js")).rev},{name:"nl",load:async()=>(await import("./chunks/nl-WZC4GKMG.js")).nl},{name:"fold",load:async()=>(await import("./chunks/fold-SK55D7OX.js")).fold},{name:"expand",load:async()=>(await import("./chunks/expand-672ZQYZF.js")).expand},{name:"unexpand",load:async()=>(await import("./chunks/unexpand-AUQHJMGI.js")).unexpand},{name:"strings",load:async()=>(await import("./chunks/strings-7CJI5ESD.js")).strings},{name:"split",load:async()=>(await import("./chunks/split-AXXLODUK.js")).split},{name:"column",load:async()=>(await import("./chunks/column-5CUPANJY.js")).column},{name:"join",load:async()=>(await import("./chunks/join-ZK67SMQ3.js")).join},{name:"tee",load:async()=>(await import("./chunks/tee-6TEQ3DXN.js")).teeCommand},{name:"find",load:async()=>(await import("./chunks/find-BXGQE44U.js")).findCommand},{name:"basename",load:async()=>(await import("./chunks/basename-XCXGYZPS.js")).basenameCommand},{name:"dirname",load:async()=>(await import("./chunks/dirname-3LHNBKNB.js")).dirnameCommand},{name:"tree",load:async()=>(await import("./chunks/tree-RLXLQJVI.js")).treeCommand},{name:"du",load:async()=>(await import("./chunks/du-DEYTW2KI.js")).duCommand},{name:"env",load:async()=>(await import("./chunks/env-PWRJFDWL.js")).envCommand},{name:"printenv",load:async()=>(await import("./chunks/env-PWRJFDWL.js")).printenvCommand},{name:"alias",load:async()=>(await import("./chunks/alias-DRSSCAUM.js")).aliasCommand},{name:"unalias",load:async()=>(await import("./chunks/alias-DRSSCAUM.js")).unaliasCommand},{name:"history",load:async()=>(await import("./chunks/history-W57S3E3C.js")).historyCommand},{name:"xargs",load:async()=>(await import("./chunks/xargs-I7QRUR36.js")).xargsCommand},{name:"true",load:async()=>(await import("./chunks/true-ZPDUMWHQ.js")).trueCommand},{name:"false",load:async()=>(await import("./chunks/true-ZPDUMWHQ.js")).falseCommand},{name:"clear",load:async()=>(await import("./chunks/clear-P5EG7Z6I.js")).clearCommand},{name:"bash",load:async()=>(await import("./chunks/bash-U2E2FSIE.js")).bashCommand},{name:"sh",load:async()=>(await import("./chunks/bash-U2E2FSIE.js")).shCommand},{name:"jq",load:async()=>(await import("./chunks/jq-2BGA6KZ3.js")).jqCommand},{name:"base64",load:async()=>(await import("./chunks/base64-KLZ4B6VS.js")).base64Command},{name:"diff",load:async()=>(await import("./chunks/diff-SGBANTKE.js")).diffCommand},{name:"date",load:async()=>(await import("./chunks/date-KYJ2OPHH.js")).dateCommand},{name:"sleep",load:async()=>(await import("./chunks/sleep-CPJ3WJE7.js")).sleepCommand},{name:"timeout",load:async()=>(await import("./chunks/timeout-LPVVIBNB.js")).timeoutCommand},{name:"time",load:async()=>(await import("./chunks/time-GJWZLHLN.js")).timeCommand},{name:"seq",load:async()=>(await import("./chunks/seq-6C6VEGIG.js")).seqCommand},{name:"expr",load:async()=>(await import("./chunks/expr-SWYNZXDP.js")).exprCommand},{name:"md5sum",load:async()=>(await import("./chunks/md5sum-WYOOUOWI.js")).md5sumCommand},{name:"sha1sum",load:async()=>(await import("./chunks/sha1sum-Y2J25KOM.js")).sha1sumCommand},{name:"sha256sum",load:async()=>(await import("./chunks/sha256sum-NFAAGL44.js")).sha256sumCommand},{name:"file",load:async()=>(await import("./chunks/file-MIXTZ4NP.js")).fileCommand},{name:"html-to-markdown",load:async()=>(await import("./chunks/html-to-markdown-2AHE4ET2.js")).htmlToMarkdownCommand},{name:"help",load:async()=>(await import("./chunks/help-R7JNUPU2.js")).helpCommand},{name:"which",load:async()=>(await import("./chunks/which-QKNHOQPQ.js")).whichCommand},{name:"tac",load:async()=>(await import("./chunks/tac-Q5VNKVXE.js")).tac},{name:"hostname",load:async()=>(await import("./chunks/hostname-NPAYFT3O.js")).hostname},{name:"whoami",load:async()=>(await import("./chunks/whoami-KIB3RVBF.js")).whoami},{name:"od",load:async()=>(await import("./chunks/od-IMVAQQIR.js")).od},{name:"gzip",load:async()=>(await import("./chunks/gzip-PT23FGTW.js")).gzipCommand},{name:"gunzip",load:async()=>(await import("./chunks/gzip-PT23FGTW.js")).gunzipCommand},{name:"zcat",load:async()=>(await import("./chunks/gzip-PT23FGTW.js")).zcatCommand}];(typeof __BROWSER__>"u"||!__BROWSER__)&&(Ye.push({name:"tar",load:async()=>(await import("./chunks/tar-M7QCUJ4B.js")).tarCommand}),Ye.push({name:"yq",load:async()=>(await import("./chunks/yq-W7OKSS7Z.js")).yqCommand}),Ye.push({name:"xan",load:async()=>(await import("./chunks/xan-BGDVQKRZ.js")).xanCommand}),Ye.push({name:"sqlite3",load:async()=>(await import("./chunks/sqlite3-DUARNSNG.js")).sqlite3Command}));var ms=[];(typeof __BROWSER__>"u"||!__BROWSER__)&&(ms.push({name:"python3",load:async()=>(await import("./chunks/python3-HNLPOBYQ.js")).python3Command}),ms.push({name:"python",load:async()=>(await import("./chunks/python3-HNLPOBYQ.js")).pythonCommand}));var wi=[{name:"curl",load:async()=>(await import("./chunks/curl-P6DHVAKR.js")).curlCommand}],Rr=new Map;function ys(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-7AQE3UPG.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(ys)}function Mr(){return wi.map(ys)}function Fr(){return ms.map(ys)}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<=lt)return[e];let t=[];for(let s=0;s<e.length;s+=lt)t.push(e.subarray(s,Math.min(s+lt,e.length)));return t}function Xe(e,t){let s=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 _t(e))if(n.length<=lt)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 c=o.subarray(a,a+n);i+=String.fromCharCode(...c)}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 Me(e){if(e!=null)return typeof e=="string"?e:e.encoding??void 0}function Ei(e){return typeof e=="object"&&e!==null&&!(e instanceof Uint8Array)&&!(e instanceof ReadableStream)&&"content"in e}function oe(e,t){if(e.includes("\0"))throw new Error(`ENOENT: path contains null byte, ${t} '${e}'`)}var ft=class{data=new Map;constructor(t){if(this.data.set("/",{type:"directory",mode:493,mtime:new Date}),t)for(let[s,r]of Object.entries(t))if(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){oe(t,"write");let i=this.normalizePath(t);this.ensureParentDirs(i);let o=Me(r),{chunks:a,size:c}=Xe(s,o);this.data.set(i,{type:"file",chunks:a,size:c,mode:n?.mode??420,mtime:n?.mtime??new Date})}async readFile(t){oe(t,"open");let s=this.resolvePathWithSymlinks(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, open '${t}'`);if(r.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);return he(r.chunks)}async readFileText(t,s){oe(t,"open");let r=this.resolvePathWithSymlinks(t),n=this.data.get(r);if(!n)throw new Error(`ENOENT: no such file or directory, open '${t}'`);if(n.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);let i=Me(s);return Dt(n.chunks,i)}async writeFile(t,s,r){oe(t,"write");let n=this.normalizePath(t);this.ensureParentDirs(n);let i=Me(r),{chunks:o,size:a}=await Ke(s,i);this.data.set(n,{type:"file",chunks:o,size:a,mode:420,mtime:new Date})}async appendFile(t,s,r){oe(t,"append");let n=this.normalizePath(t),i=this.data.get(n);if(i&&i.type==="directory")throw new Error(`EISDIR: illegal operation on a directory, write '${t}'`);let o=Me(r),{chunks:a,size:c}=await Ke(s,o);i?.type==="file"?this.data.set(n,{type:"file",chunks:[...i.chunks,...a],size:i.size+c,mode:i.mode,mtime:new Date}):(this.ensureParentDirs(n),this.data.set(n,{type:"file",chunks:a,size:c,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){oe(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){oe(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 c=this.data.get(n),u=0,l=40;for(;c&&c.type==="symlink"&&u<l;){if(i.has(n))throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`);i.add(n),n=this.resolveSymlink(n,c.target),c=this.data.get(n),u++}if(u>=l)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),c=0,u=40;for(;a&&a.type==="symlink"&&c<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),c++}if(c>=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){oe(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){oe(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,c]of this.data.entries())if(a!==s&&a.startsWith(i)){let u=a.slice(i.length),l=u.split("/")[0];l&&!u.includes("/",l.length)&&!o.has(l)&&o.set(l,{name:l,isFile:c.type==="file",isDirectory:c.type==="directory",isSymbolicLink:c.type==="symlink"})}return Array.from(o.values()).sort((a,c)=>a.name<c.name?-1:a.name>c.name?1:0)}async rm(t,s){oe(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){oe(t,"cp"),oe(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 c of a){let u=n==="/"?`/${c}`:`${n}/${c}`,l=i==="/"?`/${c}`:`${i}/${c}`;await this.cp(u,l,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){oe(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){oe(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){oe(t,"link"),oe(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){oe(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){oe(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){oe(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 Ci(e){e.mkdirSync("/proc/self/fd",{recursive:!0}),e.writeFileSync("/proc/version",`${Sr}
|
|
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
|
-
`));let s=1;if(t.length>0){let
|
|
6
|
-
`));s=
|
|
7
|
-
`)}catch{return
|
|
8
|
-
`)}}let l=u||"/";if(
|
|
9
|
-
`):
|
|
10
|
-
`,!1;if(o=Math.max(...a)+1+o,o<0)return e.state.expansionStderr=(e.state.expansionStderr||"")+`bash: line ${c}: ${
|
|
11
|
-
`,!1}return e.state.env.has(`${
|
|
12
|
-
`,2):
|
|
13
|
-
`,2):
|
|
14
|
-
`,2):
|
|
15
|
-
`)&&!n
|
|
16
|
-
`;if(
|
|
17
|
-
`}catch{}return null}function
|
|
18
|
-
`};s.set(
|
|
19
|
-
`);else if(s.operator==="<"||s.operator==="<>")try{let i=e.fs.resolvePath(e.state.cwd,
|
|
20
|
-
`),1)}}}return null}async function
|
|
21
|
-
`),1);try{let a=await e.fs.stat(i);if(a.isDirectory)return
|
|
22
|
-
`),1);if(e.state.options.noclobber&&!o&&!a.isDirectory&&
|
|
23
|
-
`),1)}catch{}if(
|
|
24
|
-
`),1)}return null}async function
|
|
25
|
-
`)),o=1,
|
|
26
|
-
`)),o=1,
|
|
27
|
-
`)),o=1,
|
|
28
|
-
`)),o=1;break}if(f==="/dev/null")i=
|
|
29
|
-
`)),o=1,
|
|
30
|
-
`)),o=1;break}let
|
|
31
|
-
`)),o=1)}break}if(f==="2"||f==="&2")
|
|
32
|
-
`)),o=1,
|
|
33
|
-
`)),o=1,
|
|
34
|
-
`),o=1,
|
|
35
|
-
`),o=1,
|
|
36
|
-
`;throw new
|
|
37
|
-
`).map(
|
|
38
|
-
`)),(n.fd??0)===0&&(s=
|
|
39
|
-
`);else if(n.operator==="<"&&n.target.type==="Word"){let
|
|
40
|
-
`,2);let
|
|
41
|
-
`,2);s.push(
|
|
42
|
-
`,2);
|
|
43
|
-
`,2);
|
|
44
|
-
`,2);i=t[
|
|
45
|
-
`,2);let
|
|
46
|
-
`,2)}else if(
|
|
47
|
-
`,2);f=t[
|
|
48
|
-
`,2);
|
|
49
|
-
`,2);l=t[
|
|
50
|
-
`,2)}else if(
|
|
51
|
-
`);for(let A of
|
|
52
|
-
`,2);throw
|
|
53
|
-
`),
|
|
54
|
-
`:"");return
|
|
55
|
-
`);if(s.length===0)return[t];let
|
|
56
|
-
`,2);i=t[f]}else if(
|
|
57
|
-
`,2);o=t[f]}else if(
|
|
58
|
-
`,2);let
|
|
59
|
-
`,2);c.push(
|
|
60
|
-
`,2);u.push(t[f])}else if(
|
|
61
|
-
`,2);a=t[f]}else if(
|
|
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 a="complete";if(o.options)for(let c of o.options)a+=` -o ${c}`;if(o.actions)for(let c of o.actions)a+=` -A ${c}`;o.wordlist!==void 0&&(o.wordlist.includes(" ")||o.wordlist.includes("'")?a+=` -W '${o.wordlist}'`:a+=` -W ${o.wordlist}`),o.function!==void 0&&(a+=` -F ${o.function}`),o.isDefault&&(a+=" -D"),a+=` ${i}`,
|
|
4
|
+
`),e.writeFileSync("/proc/self/status",Er()),e.writeFileSync("/proc/self/fd/0","/dev/stdin"),e.writeFileSync("/proc/self/fd/1","/dev/stdout"),e.writeFileSync("/proc/self/fd/2","/dev/stderr")}function jr(e,t){$i(e)&&(Ai(e,t),_i(e),Ci(e))}var ki=["allexport","errexit","noglob","noclobber","noexec","nounset","pipefail","posix","verbose","xtrace"],Pi=["braceexpand","hashall","interactive-comments"];function gs(e){let t=[],s=[...Pi.map(r=>({name:r,enabled:!0})),...ki.map(r=>({name:r,enabled:e[r]}))].sort((r,n)=>r.name.localeCompare(n.name));for(let r of s)r.enabled&&t.push(r.name);return t.join(":")}function Qe(e){g(e.state.env,"SHELLOPTS",gs(e.state.options))}var Ni=["dotglob","expand_aliases","extglob","failglob","globskipdots","globstar","lastpipe","nocaseglob","nocasematch","nullglob","xpg_echo"];function ws(e){let t=[];for(let s of Ni)e[s]&&t.push(s);return t.join(":")}function vs(e){g(e.state.env,"BASHOPTS",ws(e.state.shoptOptions))}var xi="BASH_ALIAS_";function Hr(e){return e.parts.length!==1?!1:e.parts[0].type==="Literal"}function Ur(e){if(e.parts.length!==1)return null;let t=e.parts[0];return t.type==="Literal"?t.value:null}function Gr(e,t){let s=e.env.get(`${xi}${t}`);return s!==void 0?H(s):void 0}function bs(e,t,s){if(!t.name||!Hr(t.name))return t;let r=Ur(t.name);if(!r)return t;let n=Gr(e,r);if(!n||s.has(r))return t;try{s.add(r);let i=new G,o=n,a=n.endsWith(" ");if(!a)for(let f of t.args){let h=Zr(f);o+=` ${h}`}let c;try{c=i.parse(o)}catch(f){if(f instanceof Nt)throw f;return t}if(c.statements.length!==1||c.statements[0].pipelines.length!==1||c.statements[0].pipelines[0].commands.length!==1)return qr(t,n);let u=c.statements[0].pipelines[0].commands[0];if(u.type!=="SimpleCommand")return qr(t,n);let l={...u,assignments:[...t.assignments,...u.assignments],redirections:[...u.redirections,...t.redirections],line:t.line};if(a&&t.args.length>0&&(l={...l,args:[...l.args,...t.args]},l.args.length>0)){let f=l.args[0];if(Hr(f)){let h=Ur(f);if(h&&Gr(e,h)){let d={type:"SimpleCommand",name:f,args:l.args.slice(1),assignments:[],redirections:[]},m=bs(e,d,s);m!==d&&(l={...l,name:m.name,args:[...m.args]})}}}return l}catch(i){throw s.delete(r),i}}function qr(e,t){let s=t;for(let o of e.args){let a=Zr(o);s+=` ${a}`}let r=new G,n=r.parseWordFromString("eval",!1,!1),i=r.parseWordFromString(`'${s.replace(/'/g,"'\\''")}'`,!1,!1);return{type:"SimpleCommand",name:n,args:[i],assignments:e.assignments,redirections:e.redirections,line:e.line}}function Zr(e){let t="";for(let s of e.parts)switch(s.type){case"Literal":t+=s.value.replace(/([\s"'$`\\*?[\]{}()<>|&;#!])/g,"\\$1");break;case"SingleQuoted":t+=`'${s.value}'`;break;case"DoubleQuoted":t+=`"${s.parts.map(r=>r.type==="Literal"?r.value:`$${r.type}`).join("")}"`;break;case"ParameterExpansion":t+=`\${${s.parameter}}`;break;case"CommandSubstitution":t+="$(...)";break;case"ArithmeticExpansion":t+=`$((${s.expression}))`;break;case"Glob":t+=s.pattern;break;default:break}return t}async function Yr(e,t){let s=t.parts.map(l=>l.type==="Literal"?l.value:"\0").join(""),r=s.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\(/);if(!r||!s.endsWith(")"))return null;let n=r[1],i=[],o=!1,a="",c=!1;for(let l of t.parts)if(l.type==="Literal"){let f=l.value;if(!o){let h=f.indexOf("=(");h!==-1&&(o=!0,f=f.slice(h+2))}if(o){f.endsWith(")")&&(f=f.slice(0,-1));let h=f.split(/(\s+)/);for(let d of h)/^\s+$/.test(d)?(a||c)&&(i.push(a),a="",c=!1):d&&(a+=d)}}else if(o)if(l.type==="BraceExpansion")if(/^\[.+\]=/.test(a))a+=xt({type:"Word",parts:[l]});else{(a||c)&&(i.push(a),a="",c=!1);let h=await De(e,{type:"Word",parts:[l]});i.push(...h.values)}else{(l.type==="SingleQuoted"||l.type==="DoubleQuoted"||l.type==="Escaped")&&(c=!0);let f=await V(e,{type:"Word",parts:[l]});a+=f}(a||c)&&i.push(a);let u=i.map(l=>/^\[.+\]=/.test(l)?l:l===""?"''":/[\s"'\\$`!*?[\]{}|&;<>()]/.test(l)&&!l.startsWith("'")&&!l.startsWith('"')?`'${l.replace(/'/g,"'\\''")}'`:l);return`${n}=(${u.join(" ")})`}async function Xr(e,t){let s=-1,r=-1,n=!1;for(let p=0;p<t.parts.length;p++){let v=t.parts[p];if(v.type==="Literal"){let y=v.value.indexOf("+=");if(y!==-1){let _=v.value.slice(0,y);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(_)){s=p,r=y,n=!0;break}if(/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(_)){s=p,r=y,n=!0;break}}let E=v.value.indexOf("=");if(E!==-1&&(E===0||v.value[E-1]!=="+")){let _=v.value.slice(0,E);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(_)||/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(_)){s=p,r=E;break}}}}if(s===-1)return null;let i=t.parts.slice(0,s),o=t.parts[s];if(o.type!=="Literal")return null;let a=n?2:1,c=o.value.slice(0,r),u=o.value.slice(r+a),l=t.parts.slice(s+1),f="";for(let p of i)f+=await V(e,{type:"Word",parts:[p]});f+=c;let h={type:"Word",parts:u!==""?[{type:"Literal",value:u},...l]:l},d=h.parts.length>0?await V(e,h):"";return`${f}${n?"+=":"="}${d}`}var Ti=["tar","yq","xan","sqlite3","python3","python"];function Kr(e){return Ti.includes(e)}function j(){return{stdout:w(),stderr:w(),exitCode:0}}var Je={get stdout(){return w()},get stderr(){return w()},exitCode:0};function Ee(e=w()){return{stdout:e,stderr:w(),exitCode:0}}function q(e){return{stdout:N(e),stderr:w(),exitCode:0}}function C(e,t=1){return{stdout:w(),stderr:N(e),exitCode:t}}function R(e,t,s){return{stdout:e instanceof Uint8Array?te(e):e,stderr:t instanceof Uint8Array?te(t):t,exitCode:s}}function ee(e){return{stdout:w(),stderr:w(),exitCode:e?0:1}}function Ne(e,t,s,r){let n=s===void 0?w():s instanceof Uint8Array?te(s):s,i=r===void 0?void 0:r instanceof Uint8Array?te(r):r;throw new fe(e,t,n,i)}function Ss(e,t){if(e.state.loopDepth===0){if(e.state.parentHasLoopContext)throw new Fe;return j()}if(t.length>1)throw new Z(1,w(),N(`bash: break: too many arguments
|
|
5
|
+
`));let s=1;if(t.length>0){let r=Number.parseInt(t[0],10);if(Number.isNaN(r)||r<1)throw new Z(128,w(),N(`bash: break: ${t[0]}: numeric argument required
|
|
6
|
+
`));s=r}throw new be(s)}async function Es(e,t){let s,r=!1,n=!1,i=0;for(;i<t.length;)if(t[i]==="--"){i++;break}else if(t[i]==="-L")n=!1,i++;else if(t[i]==="-P")n=!0,i++;else if(t[i].startsWith("-")&&t[i]!=="-")i++;else break;let o=t.slice(i);if(o.length===0?s=T(e.state.env,"HOME","/"):o[0]==="~"?s=T(e.state.env,"HOME","/"):o[0]==="-"?(s=e.state.previousDir,r=!0):s=o[0],!s.startsWith("/")&&!s.startsWith("./")&&!s.startsWith("../")&&s!=="."&&s!==".."){let f=e.state.env.get("CDPATH");if(f){let h=H(f??M).split(":").filter(d=>d);for(let d of h){let m=d.startsWith("/")?`${d}/${s}`:`${e.state.cwd}/${d}/${s}`;try{if((await e.fs.stat(m)).isDirectory){s=m,r=!0;break}}catch{}}}}let c=(s.startsWith("/")?s:`${e.state.cwd}/${s}`).split("/").filter(f=>f&&f!=="."),u="";for(let f of c)if(f==="..")u=u.split("/").slice(0,-1).join("/")||"/";else{u=u?`${u}/${f}`:`/${f}`;try{if(!(await e.fs.stat(u)).isDirectory)return C(`bash: cd: ${s}: Not a directory
|
|
7
|
+
`)}catch{return C(`bash: cd: ${s}: No such file or directory
|
|
8
|
+
`)}}let l=u||"/";if(n)try{l=await e.fs.realpath(l)}catch{}return e.state.previousDir=e.state.cwd,e.state.cwd=l,g(e.state.env,"PWD",e.state.cwd),g(e.state.env,"OLDPWD",e.state.previousDir),r?q(`${l}
|
|
9
|
+
`):Ee()}function $s(e,t){return e.fs.resolvePath(e.state.cwd,t)}var Oi=["-e","-a","-f","-d","-r","-w","-x","-s","-L","-h","-k","-g","-u","-G","-O","-b","-c","-p","-S","-t","-N"];function It(e){return Oi.includes(e)}async function Rt(e,t,s){let r=$s(e,s);switch(t){case"-e":case"-a":return e.fs.exists(r);case"-f":return await e.fs.exists(r)?(await e.fs.stat(r)).isFile:!1;case"-d":return await e.fs.exists(r)?(await e.fs.stat(r)).isDirectory:!1;case"-r":return await e.fs.exists(r)?((await e.fs.stat(r)).mode&256)!==0:!1;case"-w":return await e.fs.exists(r)?((await e.fs.stat(r)).mode&128)!==0:!1;case"-x":return await e.fs.exists(r)?((await e.fs.stat(r)).mode&64)!==0:!1;case"-s":return await e.fs.exists(r)?(await e.fs.stat(r)).size>0:!1;case"-L":case"-h":try{return(await e.fs.lstat(r)).isSymbolicLink}catch{return!1}case"-k":return await e.fs.exists(r)?((await e.fs.stat(r)).mode&512)!==0:!1;case"-g":return await e.fs.exists(r)?((await e.fs.stat(r)).mode&1024)!==0:!1;case"-u":return await e.fs.exists(r)?((await e.fs.stat(r)).mode&2048)!==0:!1;case"-G":case"-O":return e.fs.exists(r);case"-b":return!1;case"-c":return["/dev/null","/dev/zero","/dev/random","/dev/urandom","/dev/tty","/dev/stdin","/dev/stdout","/dev/stderr"].some(i=>r===i||r.endsWith(i));case"-p":return!1;case"-S":return!1;case"-t":return!1;case"-N":return e.fs.exists(r);default:return!1}}var Di=["-nt","-ot","-ef"];function Lt(e){return Di.includes(e)}async function Mt(e,t,s,r){let n=$s(e,s),i=$s(e,r);switch(t){case"-nt":try{let o=await e.fs.stat(n),a=await e.fs.stat(i);return o.mtime>a.mtime}catch{return!1}case"-ot":try{let o=await e.fs.stat(n),a=await e.fs.stat(i);return o.mtime<a.mtime}catch{return!1}case"-ef":try{if(!await e.fs.exists(n)||!await e.fs.exists(i))return!1;let o=e.fs.resolvePath(e.state.cwd,n),a=e.fs.resolvePath(e.state.cwd,i);return o===a}catch{return!1}default:return!1}}var Ii=new Set(["-eq","-ne","-lt","-le","-gt","-ge"]);function Ft(e){return Ii.has(e)}function Wt(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 dt(e){return e==="="||e==="=="||e==="!="}function zt(e,t,s,r=!1,n=!1,i=!1){if(r){let a=et(t,s,n,i);return e==="!="?!a:a}if(n){let a=t.toLowerCase()===s.toLowerCase();return e==="!="?!a:a}let o=t===s;return e==="!="?!o:o}var Ri=new Set(["-z","-n"]);function Vt(e){return Ri.has(e)}function Bt(e,t){switch(e){case"-z":return t==="";case"-n":return t!==""}}async function jt(e,t){let s=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(s){let r=s[1],n=s[2];if(e.state.associativeArrays?.has(r)){let a=n;return(a.startsWith("'")&&a.endsWith("'")||a.startsWith('"')&&a.endsWith('"'))&&(a=a.slice(1,-1)),a=a.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)/g,(c,u)=>T(e.state.env,u)),e.state.env.has(`${r}_${a}`)}let o;try{let a=new G,c=se(a,n);o=await X(e,c.expression)}catch{if(/^-?\d+$/.test(n))o=Number.parseInt(n,10);else{let a=T(e.state.env,n);o=a?Number.parseInt(a,10):0}}if(o<0){let a=le(e,r),c=e.state.currentLine;if(a.length===0)return e.state.expansionStderr=(e.state.expansionStderr||"")+`bash: line ${c}: ${r}: bad array subscript
|
|
10
|
+
`,!1;if(o=Math.max(...a)+1+o,o<0)return e.state.expansionStderr=(e.state.expansionStderr||"")+`bash: line ${c}: ${r}: bad array subscript
|
|
11
|
+
`,!1}return e.state.env.has(`${r}_${o}`)}return e.state.env.has(t)?!0:e.state.associativeArrays?.has(t)?ze(e,t).length>0:le(e,t).length>0}async function Ve(e,t){switch(t.type){case"CondBinary":{let s=await V(e,t.left),r=t.right.parts.length>0&&t.right.parts.every(i=>i.type==="SingleQuoted"||i.type==="DoubleQuoted"||i.type==="Escaped"&&t.operator!=="=~"),n;if(t.operator==="=~")if(r){let i=await V(e,t.right);n=Tr(i)}else n=await Dr(e,t.right);else dt(t.operator)&&!r?n=await Ir(e,t.right):n=await V(e,t.right);if(dt(t.operator)){let i=e.state.shoptOptions.nocasematch;return zt(t.operator,s,n,!r,i,!0)}if(Ft(t.operator))return Wt(t.operator,await Jr(e,s),await Jr(e,n));if(Lt(t.operator))return Mt(e,t.operator,s,n);switch(t.operator){case"=~":try{let i=e.state.shoptOptions.nocasematch,o=Wi(n),c=ut(o,i?"i":"").match(s);if(Te(e,"BASH_REMATCH"),c)for(let u=0;u<c.length;u++)g(e.state.env,`BASH_REMATCH_${u}`,c[u]||"");return c!==null}catch{throw new Error("syntax error in regular expression")}case"<":return s<n;case">":return s>n;default:return!1}}case"CondUnary":{let s=await V(e,t.operand);return It(t.operator)?Rt(e,t.operator,s):Vt(t.operator)?Bt(t.operator,s):t.operator==="-v"?await jt(e,s):t.operator==="-o"?_s(e,s):!1}case"CondNot":return e.state.shoptOptions.extglob&&t.operand.type==="CondGroup"&&t.operand.expression.type==="CondWord"?`!(${await V(e,t.operand.expression.word)})`!=="":!await Ve(e,t.operand);case"CondAnd":return await Ve(e,t.left)?await Ve(e,t.right):!1;case"CondOr":return await Ve(e,t.left)?!0:await Ve(e,t.right);case"CondGroup":return await Ve(e,t.expression);case"CondWord":return await V(e,t.word)!=="";default:return!1}}async function ht(e,t){if(t.length===0)return R(M,M,1);if(t.length===1)return ee(!!t[0]);if(t.length===2){let r=t[0],n=t[1];return r==="("?C(`test: '(' without matching ')'
|
|
12
|
+
`,2):It(r)?ee(await Rt(e,r,n)):Vt(r)?ee(Bt(r,n)):r==="!"?ee(!n):r==="-v"?ee(await jt(e,n)):r==="-o"?ee(_s(e,n)):r==="="||r==="=="||r==="!="||r==="<"||r===">"||r==="-eq"||r==="-ne"||r==="-lt"||r==="-le"||r==="-gt"||r==="-ge"||r==="-nt"||r==="-ot"||r==="-ef"?C(`test: ${r}: unary operator expected
|
|
13
|
+
`,2):R(M,M,1)}if(t.length===3){let r=t[0],n=t[1],i=t[2];if(dt(n))return ee(zt(n,r,i));if(Ft(n)){let o=Ht(r),a=Ht(i);return!o.valid||!a.valid?R(M,M,2):ee(Wt(n,o.value,a.value))}if(Lt(n))return ee(await Mt(e,n,r,i));switch(n){case"-a":return ee(r!==""&&i!=="");case"-o":return ee(r!==""||i!=="");case">":return ee(r>i);case"<":return ee(r<i)}if(r==="!"){let o=await ht(e,[n,i]);return R(M,o.stderr,o.exitCode===0?1:o.exitCode===1?0:o.exitCode)}if(r==="("&&i===")")return ee(n!=="")}if(t.length===4){if(t[0]==="!"){let r=await ht(e,t.slice(1));return R(M,r.stderr,r.exitCode===0?1:r.exitCode===1?0:r.exitCode)}if(t[0]==="("&&t[3]===")")return ht(e,[t[1],t[2]])}let s=await tn(e,t,0);return s.pos<t.length?C(`test: too many arguments
|
|
14
|
+
`,2):ee(s.value)}async function tn(e,t,s){return Li(e,t,s)}async function Li(e,t,s){let{value:r,pos:n}=await Qr(e,t,s);for(;t[n]==="-o";){let i=await Qr(e,t,n+1);r=r||i.value,n=i.pos}return{value:r,pos:n}}async function Qr(e,t,s){let{value:r,pos:n}=await As(e,t,s);for(;t[n]==="-a";){let i=await As(e,t,n+1);r=r&&i.value,n=i.pos}return{value:r,pos:n}}async function As(e,t,s){if(t[s]==="!"){let{value:r,pos:n}=await As(e,t,s+1);return{value:!r,pos:n}}return Mi(e,t,s)}async function Mi(e,t,s){let r=t[s];if(r==="("){let{value:i,pos:o}=await tn(e,t,s+1);return{value:i,pos:t[o]===")"?o+1:o}}let n=t[s+1];if(dt(n)){let i=r,o=t[s+2]??"";return{value:zt(n,i,o),pos:s+3}}if(Ft(n)){let i=Ht(r),o=Ht(t[s+2]??"0");return!i.valid||!o.valid?{value:!1,pos:s+3}:{value:Wt(n,i.value,o.value),pos:s+3}}if(Lt(n)){let i=r,o=t[s+2]??"";return{value:await Mt(e,n,i,o),pos:s+3}}if(It(r)){let i=t[s+1]??"";return{value:await Rt(e,r,i),pos:s+2}}if(Vt(r)){let i=t[s+1]??"";return{value:Bt(r,i),pos:s+2}}if(r==="-v"){let i=t[s+1]??"";return{value:await jt(e,i),pos:s+2}}if(r==="-o"){let i=t[s+1]??"";return{value:_s(e,i),pos:s+2}}return{value:r!==void 0&&r!=="",pos:s+1}}function et(e,t,s=!1,r=!1){let n=`^${sn(t,r)}$`;return ut(n,s?"is":"s").test(e)}function sn(e,t){let s="";for(let r=0;r<e.length;r++){let n=e[r];if(t&&(n==="@"||n==="*"||n==="+"||n==="?"||n==="!")&&r+1<e.length&&e[r+1]==="("){let i=rn(e,r+1);if(i!==-1){let o=e.slice(r+2,i),a=nn(o),c=a.map(l=>sn(l,t)),u=c.length>0?c.join("|"):"(?:)";if(n==="@")s+=`(?:${u})`;else if(n==="*")s+=`(?:${u})*`;else if(n==="+")s+=`(?:${u})+`;else if(n==="?")s+=`(?:${u})?`;else if(n==="!")if(i<e.length-1){let f=a.map(d=>on(d,t));if(f.every(d=>d!==null)&&f.every(d=>d===f[0])&&f[0]!==null){let d=f[0];if(d===0)s+="(?:.+)";else{let m=[];d>0&&m.push(`.{0,${d-1}}`),m.push(`.{${d+1},}`),m.push(`(?!(?:${u})).{${d}}`),s+=`(?:${m.join("|")})`}}else s+=`(?:(?!(?:${u})).)*?`}else s+=`(?!(?:${u})$).*`;r=i;continue}}if(n==="\\")if(r+1<e.length){let i=e[r+1];/[\\^$.|+(){}[\]*?]/.test(i)?s+=`\\${i}`:s+=i,r++}else s+="\\\\";else if(n==="*")s+=".*";else if(n==="?")s+=".";else if(n==="["){let i=e.indexOf("]",r+1);i!==-1?(s+=e.slice(r,i+1),r=i):s+="\\["}else/[\\^$.|+(){}]/.test(n)?s+=`\\${n}`:s+=n}return s}function rn(e,t){let s=1,r=t+1;for(;r<e.length&&s>0;){let n=e[r];if(n==="\\"){r+=2;continue}if(n==="(")s++;else if(n===")"&&(s--,s===0))return r;r++}return-1}function nn(e){let t=[],s="",r=0,n=0;for(;n<e.length;){let i=e[n];if(i==="\\"){s+=i,n+1<e.length?(s+=e[n+1],n+=2):n++;continue}i==="("?(r++,s+=i):i===")"?(r--,s+=i):i==="|"&&r===0?(t.push(s),s=""):s+=i,n++}return t.push(s),t}function on(e,t){let s=0,r=0;for(;r<e.length;){let n=e[r];if(t&&(n==="@"||n==="*"||n==="+"||n==="?"||n==="!")&&r+1<e.length&&e[r+1]==="("){let i=rn(e,r+1);if(i!==-1){if(n==="@"){let o=e.slice(r+2,i),c=nn(o).map(u=>on(u,t));if(c.every(u=>u!==null)&&c.every(u=>u===c[0])){s+=c[0],r=i+1;continue}return null}return null}}if(n==="*")return null;if(n==="?"){s+=1,r++;continue}if(n==="["){let i=e.indexOf("]",r+1);if(i!==-1){s+=1,r=i+1;continue}s+=1,r++;continue}if(n==="\\"){s+=1,r+=2;continue}s+=1,r++}return s}function _s(e,t){let r=new Map([["errexit",()=>e.state.options.errexit===!0],["nounset",()=>e.state.options.nounset===!0],["pipefail",()=>e.state.options.pipefail===!0],["xtrace",()=>e.state.options.xtrace===!0],["e",()=>e.state.options.errexit===!0],["u",()=>e.state.options.nounset===!0],["x",()=>e.state.options.xtrace===!0]]).get(t);return r?r():!1}async function Jr(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 en(t);try{let s=new G,r=se(s,t);return await X(e,r.expression)}catch{return en(t)}}function Fi(e,t){let s=0;for(let r of e){let n;if(r>="0"&&r<="9")n=r.charCodeAt(0)-48;else if(r>="a"&&r<="z")n=r.charCodeAt(0)-97+10;else if(r>="A"&&r<="Z")n=r.charCodeAt(0)-65+36;else if(r==="@")n=62;else if(r==="_")n=63;else return Number.NaN;if(n>=t)return Number.NaN;s=s*t+n}return s}function en(e){if(e=e.trim(),e==="")return 0;let t=!1;e.startsWith("-")?(t=!0,e=e.slice(1)):e.startsWith("+")&&(e=e.slice(1));let s,r=e.match(/^(\d+)#([a-zA-Z0-9@_]+)$/);if(r){let n=Number.parseInt(r[1],10);n>=2&&n<=64?s=Fi(r[2],n):s=0}else/^0[xX][0-9a-fA-F]+$/.test(e)?s=Number.parseInt(e,16):/^0[0-7]+$/.test(e)?s=Number.parseInt(e,8):s=Number.parseInt(e,10);return Number.isNaN(s)&&(s=0),t?-s:s}function Ht(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 Wi(e){let t="",s=0;for(;s<e.length;)if(e[s]==="\\"&&s+1<e.length)t+=e[s]+e[s+1],s+=2;else if(e[s]==="["){let r=zi(e,s);t+=r.converted,s=r.endIndex}else t+=e[s],s++;return t}function zi(e,t){let s=t+1,r="[";s<e.length&&(e[s]==="^"||e[s]==="!")&&(r+="^",s++);let n=!1;s<e.length&&e[s]==="]"&&(n=!0,s++);let i=!1;s<e.length&&e[s]==="["&&s+1<e.length&&e[s+1]!==":"&&(i=!0,s++);let o="",a=!1;for(;s<e.length;){let c=e[s];if(c==="]"){a=!0,s++;break}if(c==="["&&s+1<e.length&&e[s+1]===":"){let u=e.indexOf(":]",s+2);if(u!==-1){let l=e.slice(s+2,u);o+=Vi(l),s=u+2;continue}}if(c==="["&&s+1<e.length){let u=e[s+1];if(u==="."||u==="="){let l=`${u}]`,f=e.indexOf(l,s+2);if(f!==-1){let h=e.slice(s+2,f);o+=h,s=f+2;continue}}}if(c==="\\"&&s+1<e.length){o+=c+e[s+1],s+=2;continue}o+=c,s++}return a?(n&&(r+="\\]"),i&&(r+="\\["),r+=o,r+="]",{converted:r,endIndex:s}):{converted:"\\[",endIndex:t+1}}function Vi(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 Ie(e){let t=[],s="",r=!1,n=!1,i=!1,o=!1;for(let a of e){if(i){s+=a,i=!1,o=!0;continue}if(a==="\\"){i=!0;continue}if(a==="'"&&!n){r||(o=!0),r=!r;continue}if(a==='"'&&!r){n||(o=!0),n=!n;continue}if((a===" "||a===" "||a===`
|
|
15
|
+
`)&&!r&&!n){o&&(t.push(s),s="",o=!1);continue}s+=a,o=!0}return o&&t.push(s),t}function Ut(e){let t=[],s=0;for(;s<e.length;){for(;s<e.length&&/\s/.test(e[s]);)s++;if(s>=e.length)break;if(e[s]!=="["){s++;continue}s++;let r="";if(e[s]==="'"||e[s]==='"'){let i=e[s];for(s++;s<e.length&&e[s]!==i;)r+=e[s],s++;e[s]===i&&s++}else for(;s<e.length&&e[s]!=="]"&&e[s]!=="=";)r+=e[s],s++;for(;s<e.length&&e[s]!=="]";)s++;if(e[s]==="]"&&s++,e[s]!=="=")continue;s++;let n="";if(e[s]==="'"||e[s]==='"'){let i=e[s];for(s++;s<e.length&&e[s]!==i;)e[s]==="\\"&&s+1<e.length&&s++,n+=e[s],s++;e[s]===i&&s++}else for(;s<e.length&&!/\s/.test(e[s]);)n+=e[s],s++;t.push([r,n])}return t}function an(e){let t=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(t)return{name:t[1],isArray:!0,arrayElements:Ie(t[2])};let s=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([^\]]+)\]=(.*)$/s);if(s)return{name:s[1],isArray:!1,arrayIndex:s[2],value:s[3]};if(e.includes("=")){let r=e.indexOf("=");return{name:e.slice(0,r),isArray:!1,value:e.slice(r+1)}}return{name:e,isArray:!1}}async function Bi(e,t){try{let s=new G,r=se(s,t);return await X(e,r.expression)}catch{let s=parseInt(t,10);return Number.isNaN(s)?0:s}}async function ln(e,t,s={}){let{name:r,isArray:n,arrayElements:i,value:o,arrayIndex:a}=t,{makeReadonly:c=!1,checkReadonly:u=!0}=s;if(u){let l=ie(e,r);if(l)return l}if(n&&i){for(let l=0;l<i.length;l++)g(e.state.env,`${r}_${l}`,i[l]);g(e.state.env,`${r}__length`,String(i.length))}else if(a!==void 0&&o!==void 0){let l=await Bi(e,a);g(e.state.env,`${r}_${l}`,o);let f=parseInt(T(e.state.env,`${r}__length`,"0"),10);l>=f&&g(e.state.env,`${r}__length`,String(l+1))}else o!==void 0&&g(e.state.env,r,o);return c&&ye(e,r),null}function Be(e,t){e.state.localVarDepth=e.state.localVarDepth||new Map,e.state.localVarDepth.set(t,e.state.callDepth)}function tt(e,t){return e.state.localVarDepth?.get(t)}function Gt(e,t){e.state.localVarDepth?.delete(t)}function cn(e,t,s){e.state.localVarStack=e.state.localVarStack||new Map;let r=e.state.localVarStack.get(t)||[];r.push({value:s,scopeIndex:e.state.localScopes.length-1}),e.state.localVarStack.set(t,r)}function qt(e,t){let s=e.state.localVarStack?.get(t);if(!(!s||s.length===0))return s.pop()}function un(e,t){if(e.state.localVarStack)for(let[s,r]of e.state.localVarStack.entries()){for(;r.length>0&&r[r.length-1].scopeIndex===t;)r.pop();r.length===0&&e.state.localVarStack.delete(s)}}var Cs=new Set([":",".","break","continue","eval","exec","exit","export","readonly","return","set","shift","trap","unset"]);function fn(e){return Cs.has(e)}var ks=new Set(["if","then","else","elif","fi","case","esac","for","select","while","until","do","done","in","function","{","}","time","[[","]]","!"]),st=new Set([":","true","false","cd","export","unset","exit","local","set","break","continue","return","eval","shift","getopts","compgen","complete","compopt","pushd","popd","dirs","source",".","read","mapfile","readarray","declare","typeset","readonly","let","command","shopt","exec","test","[","echo","printf","pwd","alias","unalias","type","hash","ulimit","umask","trap","times","wait","kill","jobs","fg","bg","disown","suspend","fc","history","help","enable","builtin","caller"]);async function Ue(e,t,s,r){try{if((await e.fs.stat(t)).isDirectory)return`bash: ${s}: Is a directory
|
|
16
|
+
`;if(r.checkNoclobber&&e.state.options.noclobber&&!r.isClobber&&s!=="/dev/null")return`bash: ${s}: cannot overwrite existing file
|
|
17
|
+
`}catch{}return null}function ji(e){if(!e.startsWith("__rw__:"))return null;let t=e.slice(7),s=t.indexOf(":");if(s===-1)return null;let r=Number.parseInt(t.slice(0,s),10);if(Number.isNaN(r)||r<0)return null;let n=s+1,i=t.slice(n,n+r),o=n+r+1,a=t.slice(o),c=a.indexOf(":");if(c===-1)return null;let u=Number.parseInt(a.slice(0,c),10);if(Number.isNaN(u)||u<0)return null;let l=a.slice(c+1);return{path:i,position:u,content:l}}async function dn(e,t){let s=new Map;for(let r=0;r<t.length;r++){let n=t[r];if(n.target.type==="HereDoc")continue;if(n.operator===">&"||n.operator==="<&"){if(ps(e,n.target))return{targets:s,error:`bash: $@: ambiguous redirect
|
|
18
|
+
`};s.set(r,await V(e,n.target))}else{let o=await Ot(e,n.target);if("error"in o)return{targets:s,error:o.error};s.set(r,o.target)}}return{targets:s}}function Hi(e){e.state.nextFd===void 0&&(e.state.nextFd=10);let t=e.state.nextFd;return e.state.nextFd++,t}async function Zt(e,t){for(let s of t){if(!s.fdVariable)continue;if(e.state.fileDescriptors||(e.state.fileDescriptors=new Map),(s.operator===">&"||s.operator==="<&")&&s.target.type==="Word"&&await V(e,s.target)==="-"){if(e.state.env.has(s.fdVariable)){let i=Number.parseInt(T(e.state.env,s.fdVariable),10);Number.isNaN(i)||e.state.fileDescriptors.delete(i)}continue}let r=Hi(e);if(g(e.state.env,s.fdVariable,String(r)),s.target.type==="Word"){let n=await V(e,s.target);if(s.operator===">&"||s.operator==="<&"){let i=Number.parseInt(n,10);if(!Number.isNaN(i)){let o=e.state.fileDescriptors.get(i);o!==void 0&&e.state.fileDescriptors.set(r,o);continue}}if(s.operator===">"||s.operator===">>"||s.operator===">|"||s.operator==="&>"||s.operator==="&>>"){let i=e.fs.resolvePath(e.state.cwd,n);(s.operator===">"||s.operator===">|"||s.operator==="&>")&&await e.fs.writeFile(i,""),e.state.fileDescriptors.set(r,`__file__:${i}`)}else if(s.operator==="<<<")e.state.fileDescriptors.set(r,`${n}
|
|
19
|
+
`);else if(s.operator==="<"||s.operator==="<>")try{let i=e.fs.resolvePath(e.state.cwd,n),o=await e.fs.readFileText(i);e.state.fileDescriptors.set(r,o)}catch{return R(w(),N(`bash: ${n}: No such file or directory
|
|
20
|
+
`),1)}}}return null}async function Re(e,t){for(let s of t){if(s.target.type==="HereDoc")continue;let r=s.operator===">&";if(s.operator!==">"&&s.operator!==">|"&&s.operator!=="&>"&&!r)continue;let n;if(r){if(n=await V(e,s.target),n==="-"||!Number.isNaN(Number.parseInt(n,10))||s.fd!=null)continue}else{let a=await Ot(e,s.target);if("error"in a)return R(w(),N(a.error),1);n=a.target}let i=e.fs.resolvePath(e.state.cwd,n),o=s.operator===">|";if(i.includes("\0"))return R(w(),N(`bash: ${n}: No such file or directory
|
|
21
|
+
`),1);try{let a=await e.fs.stat(i);if(a.isDirectory)return R(w(),N(`bash: ${n}: Is a directory
|
|
22
|
+
`),1);if(e.state.options.noclobber&&!o&&!a.isDirectory&&n!=="/dev/null")return R(w(),N(`bash: ${n}: cannot overwrite existing file
|
|
23
|
+
`),1)}catch{}if(n!=="/dev/null"&&n!=="/dev/stdout"&&n!=="/dev/stderr"&&n!=="/dev/full"&&await e.fs.writeFile(i,""),n==="/dev/full")return R(w(),N(`bash: /dev/full: No space left on device
|
|
24
|
+
`),1)}return null}async function K(e,t,s,r){let n=t.stdout,i=t.stderr,o=t.exitCode;for(let u=0;u<s.length;u++){let l=s[u];if(l.target.type==="HereDoc")continue;let f,h=r?.get(u);if(h!==void 0)f=h;else if(l.operator===">&"||l.operator==="<&"){if(ps(e,l.target)){i=D(i,N(`bash: $@: ambiguous redirect
|
|
25
|
+
`)),o=1,n=w();continue}f=await V(e,l.target)}else{let m=await Ot(e,l.target);if("error"in m){i=D(i,N(m.error)),o=1,n=w();continue}f=m.target}if(!l.fdVariable){if(f.includes("\0")){i=D(i,N(`bash: ${f.replace(/\0/g,"")}: No such file or directory
|
|
26
|
+
`)),o=1,n=w();continue}switch(l.operator){case">":case">|":{let d=l.fd??1,m=l.operator===">|";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
|
|
27
|
+
`)),o=1,n=w();break}let p=e.fs.resolvePath(e.state.cwd,f),v=await Ue(e,p,f,{checkNoclobber:!0,isClobber:m});if(v){i=D(i,N(v)),o=1,n=w();break}await e.fs.writeFile(p,n),n=w()}else if(d===2){if(f==="/dev/stderr")break;if(f==="/dev/stdout"){n=D(n,i),i=w();break}if(f==="/dev/full"){i=D(i,N(`bash: echo: write error: No space left on device
|
|
28
|
+
`)),o=1;break}if(f==="/dev/null")i=w();else{let p=e.fs.resolvePath(e.state.cwd,f),v=await Ue(e,p,f,{checkNoclobber:!0,isClobber:m});if(v){i=D(i,N(v)),o=1;break}await e.fs.writeFile(p,i),i=w()}}break}case">>":{let d=l.fd??1;if(d===1){if(f==="/dev/stdout")break;if(f==="/dev/stderr"){i=D(i,n),n=w();break}if(f==="/dev/full"){i=D(i,N(`bash: echo: write error: No space left on device
|
|
29
|
+
`)),o=1,n=w();break}let m=e.fs.resolvePath(e.state.cwd,f),p=await Ue(e,m,f,{});if(p){i=D(i,N(p)),o=1,n=w();break}await e.fs.appendFile(m,n),n=w()}else if(d===2){if(f==="/dev/stderr")break;if(f==="/dev/stdout"){n=D(n,i),i=w();break}if(f==="/dev/full"){i=D(i,N(`bash: echo: write error: No space left on device
|
|
30
|
+
`)),o=1;break}let m=e.fs.resolvePath(e.state.cwd,f),p=await Ue(e,m,f,{});if(p){i=D(i,N(p)),o=1;break}await e.fs.appendFile(m,i),i=w()}break}case">&":case"<&":{let d=l.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(l.operator===">&"){let p=e.fs.resolvePath(e.state.cwd,f),v=await Ue(e,p,f,{checkNoclobber:!0});if(v){i=N(v),o=1,n=w();break}if(l.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 Ue(e,d,f,{checkNoclobber:!0});if(m){i=N(m),o=1,n=w();break}let p=await Y(n),v=await Y(i);await e.fs.writeFile(d,p),await e.fs.appendFile(d,v),n=w(),i=w();break}case"&>>":{if(f==="/dev/full"){i=N(`bash: echo: write error: No space left on device
|
|
35
|
+
`),o=1,n=w();break}let d=e.fs.resolvePath(e.state.cwd,f),m=await Ue(e,d,f,{});if(m){i=N(m),o=1,n=w();break}await e.fs.appendFile(d,n),await e.fs.appendFile(d,i),n=w(),i=w();break}}}}let a=e.state.fileDescriptors?.get(1);if(a){if(a==="__dupout__:2")i=D(i,n),n=w();else if(a.startsWith("__file__:")){let u=a.slice(9);await e.fs.appendFile(u,n),n=w()}else if(a.startsWith("__file_append__:")){let u=a.slice(16);await e.fs.appendFile(u,n),n=w()}}let c=e.state.fileDescriptors?.get(2);if(c){if(c==="__dupout__:1")n=D(n,i),i=w();else if(c.startsWith("__file__:")){let u=c.slice(9);await e.fs.appendFile(u,i),i=w()}else if(c.startsWith("__file_append__:")){let u=c.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(`
|
|
37
|
+
`).map(c=>c.replace(/^\t+/,"")).join(`
|
|
38
|
+
`)),(n.fd??0)===0&&(s=N(o),r=!0)}else if(n.operator==="<<<"&&n.target.type==="Word")s=N(`${await V(e,n.target)}
|
|
39
|
+
`),r=!0;else if(n.operator==="<"&&n.target.type==="Word"){let i=await V(e,n.target),o=e.fs.resolvePath(e.state.cwd,i);try{s=await e.fs.readFile(o),r=!0}catch{}}return s}async function Yt(e,t,s,r=w(),n){e.state.callDepth++,e.state.callDepth>e.limits.maxCallDepth&&(e.state.callDepth--,Ne(`${t.name}: maximum recursion depth (${e.limits.maxCallDepth}) exceeded, increase executionLimits.maxCallDepth`,"recursion")),e.state.funcNameStack||(e.state.funcNameStack=[]),e.state.callLineStack||(e.state.callLineStack=[]),e.state.sourceStack||(e.state.sourceStack=[]),e.state.funcNameStack.unshift(t.name),e.state.callLineStack.unshift(n??e.state.currentLine),e.state.sourceStack.unshift(t.sourceFile??"main"),e.state.localScopes.push(new Map),e.state.localExportedVars||(e.state.localExportedVars=[]),e.state.localExportedVars.push(new Set);let i=new Map;for(let u=0;u<s.length;u++)i.set(String(u+1),T(e.state.env,String(u+1))),g(e.state.env,String(u+1),s[u]);i.set("@",T(e.state.env,"@")),i.set("#",T(e.state.env,"#")),g(e.state.env,"@",s.join(" ")),g(e.state.env,"#",String(s.length));let o=()=>{let u=e.state.localScopes.length-1,l=e.state.localScopes.pop();if(l)for(let[f,h]of l)h===void 0?e.state.env.delete(f):e.state.env.set(f,h);if(un(e,u),e.state.fullyUnsetLocals)for(let[f,h]of e.state.fullyUnsetLocals.entries())h===u&&e.state.fullyUnsetLocals.delete(f);if(e.state.localExportedVars&&e.state.localExportedVars.length>0){let f=e.state.localExportedVars.pop();if(f)for(let h of f)e.state.exportedVars?.delete(h)}for(let[f,h]of i)h===void 0?e.state.env.delete(f):g(e.state.env,f,h);e.state.funcNameStack?.shift(),e.state.callLineStack?.shift(),e.state.sourceStack?.shift(),e.state.callDepth--},{targets:a,error:c}=await dn(e,t.redirections);if(c)return o(),R(w(),N(c),1);try{let u=await Y(r),l;u.length>0?l=te(u):l=await Ui(e,t.redirections);let f=await e.executeCommand(t.body,l);return o(),K(e,f,t.redirections,a)}catch(u){if(o(),u instanceof pe){let l=R(u.stdout,u.stderr,u.exitCode);return K(e,l,t.redirections,a)}throw u}}var mn=["!","[[","]]","case","do","done","elif","else","esac","fi","for","function","if","in","then","time","until","while","{","}"],Ns=[".",":","[","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"],Gi=["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"],qi=Ns;async function xs(e,t){let s=[],r=null,n="",i="",o=null,a=!1,c=!1,u=!1,l=null,f=null,h=null,d=[],m=["alias","arrayvar","binding","builtin","command","directory","disabled","enabled","export","file","function","group","helptopic","hostname","job","keyword","running","service","setopt","shopt","signal","stopped","user","variable"];for(let b=0;b<t.length;b++){let k=t[b];if(k==="-v")s.push("variable");else if(k==="-e")s.push("export");else if(k==="-f")s.push("file");else if(k==="-d")s.push("directory");else if(k==="-k")s.push("keyword");else if(k==="-A"){if(b++,b>=t.length)return C(`compgen: -A: option requires an argument
|
|
40
|
+
`,2);let L=t[b];if(!m.includes(L))return C(`compgen: ${L}: invalid action name
|
|
41
|
+
`,2);s.push(L)}else if(k==="-W"){if(b++,b>=t.length)return C(`compgen: -W: option requires an argument
|
|
42
|
+
`,2);r=t[b]}else if(k==="-P"){if(b++,b>=t.length)return C(`compgen: -P: option requires an argument
|
|
43
|
+
`,2);n=t[b]}else if(k==="-S"){if(b++,b>=t.length)return C(`compgen: -S: option requires an argument
|
|
44
|
+
`,2);i=t[b]}else if(k==="-o"){if(b++,b>=t.length)return C(`compgen: -o: option requires an argument
|
|
45
|
+
`,2);let L=t[b];if(L==="plusdirs")a=!0;else if(L==="dirnames")c=!0;else if(L==="default")u=!0;else if(!(L==="filenames"||L==="nospace"||L==="bashdefault"||L==="noquote"))return C(`compgen: ${L}: invalid option name
|
|
46
|
+
`,2)}else if(k==="-F"){if(b++,b>=t.length)return C(`compgen: -F: option requires an argument
|
|
47
|
+
`,2);f=t[b]}else if(k==="-C"){if(b++,b>=t.length)return C(`compgen: -C: option requires an argument
|
|
48
|
+
`,2);h=t[b]}else if(k==="-X"){if(b++,b>=t.length)return C(`compgen: -X: option requires an argument
|
|
49
|
+
`,2);l=t[b]}else if(k==="-G"){if(b++,b>=t.length)return C(`compgen: -G: option requires an argument
|
|
50
|
+
`,2)}else if(k==="--"){d.push(...t.slice(b+1));break}else k.startsWith("-")||d.push(k)}o=d[0]??null;let p=[];if(c){let b=await Ps(e,o);p.push(...b)}if(u){let b=await pn(e,o);p.push(...b)}for(let b of s)if(b==="variable"){let k=Zi(e,o);p.push(...k)}else if(b==="export"){let k=Yi(e,o);p.push(...k)}else if(b==="function"){let k=Xi(e,o);p.push(...k)}else if(b==="builtin"){let k=Ki(o);p.push(...k)}else if(b==="keyword"){let k=Qi(o);p.push(...k)}else if(b==="alias"){let k=Ji(e,o);p.push(...k)}else if(b==="shopt"){let k=eo(o);p.push(...k)}else if(b==="helptopic"){let k=to(o);p.push(...k)}else if(b==="directory"){let k=await Ps(e,o);p.push(...k)}else if(b==="file"){let k=await pn(e,o);p.push(...k)}else if(b==="user"){let k=so(o);p.push(...k)}else if(b==="command"){let k=await ro(e,o);p.push(...k)}if(r!==null)try{let b=await no(e,r),k=io(e,b);for(let L of k)(o===null||L.startsWith(o))&&p.push(L)}catch{return R(M,M,1)}if(a){let b=await Ps(e,o);for(let k of b)p.includes(k)||p.push(k)}let v="";if(f!==null){let b=e.state.functions.get(f);if(b){let k=new Map;k.set("COMP_WORDS__length",T(e.state.env,"COMP_WORDS__length")),g(e.state.env,"COMP_WORDS__length","0"),k.set("COMP_CWORD",T(e.state.env,"COMP_CWORD")),g(e.state.env,"COMP_CWORD","-1"),k.set("COMP_LINE",T(e.state.env,"COMP_LINE")),g(e.state.env,"COMP_LINE",""),k.set("COMP_POINT",T(e.state.env,"COMP_POINT")),g(e.state.env,"COMP_POINT","0");let L=new Map;for(let A of e.state.env.keys())(A==="COMPREPLY"||A.startsWith("COMPREPLY_")||A==="COMPREPLY__length")&&(L.set(A,T(e.state.env,A)),e.state.env.delete(A));let $=["compgen",d[0]??"",""];try{let A=await Yt(e,b,$,w());if(A.exitCode!==0)return rt(e,k),rt(e,L),R(M,A.stderr,1);v=H(await Y(A.stdout));let x=oo(e);p.push(...x)}catch{return rt(e,k),rt(e,L),R(M,M,1)}rt(e,k),rt(e,L)}}if(h!==null)try{let b=xe(h),k=await e.executeScript(b);if(k.exitCode!==0)return R(M,k.stderr,k.exitCode);let L=await Y(k.stdout);if(L.length>0){let $=H(L).split(`
|
|
51
|
+
`);for(let A of $)A.length>0&&p.push(A)}}catch(b){if(b.name==="ParseException")return C(`compgen: -C: ${b.message}
|
|
52
|
+
`,2);throw b}let y=p;if(l!==null){let b=l.startsWith("!"),k=b?l.slice(1):l;y=p.filter(L=>{let $=et(L,k,!1,!0);return b?$:!$})}if(y.length===0&&o!==null)return R(B(v),M,1);let E=y.map(b=>`${n}${b}${i}`).join(`
|
|
53
|
+
`),_=v+(E?`${E}
|
|
54
|
+
`:"");return q(_)}function Zi(e,t){let s=new Set;for(let n of e.state.env.keys()){if(n.includes("_")&&/^[a-zA-Z_][a-zA-Z0-9_]*_\d+$/.test(n)||n.endsWith("__length"))continue;let i=n.split("_")[0];/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)?s.add(n):i&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i)&&e.state.env.has(`${i}__length`)&&s.add(i)}let r=Array.from(s);return t!==null&&(r=r.filter(n=>n.startsWith(t))),r.sort()}function Yi(e,t){let s=e.state.exportedVars??new Set,r=Array.from(s);return t!==null&&(r=r.filter(n=>n.startsWith(t))),r=r.filter(n=>n.includes("_")&&/^[a-zA-Z_][a-zA-Z0-9_]*_\d+$/.test(n)||n.endsWith("__length")?!1:e.state.env.has(n)),r.sort()}function Xi(e,t){let s=Array.from(e.state.functions.keys());return t!==null&&(s=s.filter(r=>r.startsWith(t))),s.sort()}function Ki(e){let t=[...Ns];return e!==null&&(t=t.filter(s=>s.startsWith(e))),t.sort()}function Qi(e){let t=[...mn];return e!==null&&(t=t.filter(s=>s.startsWith(e))),t.sort()}function Ji(e,t){let s=[];for(let n of e.state.env.keys())if(n.startsWith("BASH_ALIAS_")){let i=n.slice(11);s.push(i)}let r=s;return t!==null&&(r=r.filter(n=>n.startsWith(t))),r.sort()}function eo(e){let t=[...Gi];return e!==null&&(t=t.filter(s=>s.startsWith(e))),t.sort()}function to(e){let t=[...qi];return e!==null&&(t=t.filter(s=>s.startsWith(e))),t.sort()}async function Ps(e,t){let s=[];try{let r=e.state.cwd,n=t??"";if(t){let o=t.lastIndexOf("/");if(o!==-1){let a=t.slice(0,o)||"/";n=t.slice(o+1),a.startsWith("/")?r=a:r=`${e.state.cwd}/${a}`}}let i=await e.fs.readdir(r);for(let o of i){let a=`${r}/${o}`;try{if((await e.fs.stat(a)).isDirectory&&(!n||o.startsWith(n)))if(t?.includes("/")){let u=t.lastIndexOf("/"),l=t.slice(0,u+1);s.push(l+o)}else s.push(o)}catch{}}}catch{}return s.sort()}async function pn(e,t){let s=[];try{let r=e.state.cwd,n=t??"";if(t){let o=t.lastIndexOf("/");if(o!==-1){let a=t.slice(0,o)||"/";n=t.slice(o+1),a.startsWith("/")?r=a:r=`${e.state.cwd}/${a}`}}let i=await e.fs.readdir(r);for(let o of i)if(!n||o.startsWith(n))if(t?.includes("/")){let a=t.lastIndexOf("/"),c=t.slice(0,a+1);s.push(c+o)}else s.push(o)}catch{}return s.sort()}function so(e){return["root","nobody"]}async function ro(e,t){let s=new Set;for(let i of Ns)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 mn)s.add(i);let r=T(e.state.env,"PATH","/usr/bin:/bin");for(let i of r.split(":"))if(i)try{let o=await e.fs.readdir(i);for(let a of o)s.add(a)}catch{}let n=Array.from(s);return t!==null&&(n=n.filter(i=>i.startsWith(t))),n.sort()}async function no(e,t){let r=new G().parseWordFromString(t,!1,!1);return await V(e,r)}function io(e,t){let s=T(e.state.env,"IFS",`
|
|
55
|
+
`);if(s.length===0)return[t];let r=new Set(s.split("")),n=[],i="",o=0;for(;o<t.length;){let a=t[o];if(a==="\\"&&o+1<t.length){let c=t[o+1];i+=c,o+=2}else r.has(a)?(i.length>0&&(n.push(i),i=""),o++):(i+=a,o++)}return i.length>0&&n.push(i),n}function rt(e,t){for(let[s,r]of t)r===void 0?e.state.env.delete(s):g(e.state.env,s,r)}function oo(e){let t=[];if(e.state.env.get("COMPREPLY__length")!==void 0){let n=ke(e,"COMPREPLY");for(let[,i]of n)t.push(i)}else e.state.env.has("COMPREPLY")&&t.push(T(e.state.env,"COMPREPLY"));return t}var ao=["bashdefault","default","dirnames","filenames","noquote","nosort","nospace","plusdirs"];function Os(e,t){e.state.completionSpecs||(e.state.completionSpecs=new Map);let s=!1,r=!1,n=!1,i,o,a,c=[],u=[],l=[];for(let f=0;f<t.length;f++){let h=t[f];if(h==="-p")s=!0;else if(h==="-r")r=!0;else if(h==="-D")n=!0;else if(h==="-W"){if(f++,f>=t.length)return C(`complete: -W: option requires an argument
|
|
56
|
+
`,2);i=t[f]}else if(h==="-F"){if(f++,f>=t.length)return C(`complete: -F: option requires an argument
|
|
57
|
+
`,2);o=t[f]}else if(h==="-o"){if(f++,f>=t.length)return C(`complete: -o: option requires an argument
|
|
58
|
+
`,2);let d=t[f];if(!ao.includes(d))return C(`complete: ${d}: invalid option name
|
|
59
|
+
`,2);c.push(d)}else if(h==="-A"){if(f++,f>=t.length)return C(`complete: -A: option requires an argument
|
|
60
|
+
`,2);u.push(t[f])}else if(h==="-C"){if(f++,f>=t.length)return C(`complete: -C: option requires an argument
|
|
61
|
+
`,2);a=t[f]}else if(h==="-G"){if(f++,f>=t.length)return C(`complete: -G: option requires an argument
|
|
62
|
+
`,2)}else if(h==="-P"){if(f++,f>=t.length)return C(`complete: -P: option requires an argument
|
|
63
|
+
`,2)}else if(h==="-S"){if(f++,f>=t.length)return C(`complete: -S: option requires an argument
|
|
64
|
+
`,2)}else if(h==="-X"){if(f++,f>=t.length)return C(`complete: -X: option requires an argument
|
|
65
|
+
`,2)}else if(h==="--"){l.push(...t.slice(f+1));break}else h.startsWith("-")||l.push(h)}if(r){if(l.length===0)return e.state.completionSpecs.clear(),Ee();for(let f of l)e.state.completionSpecs.delete(f);return Ee()}if(s)return l.length===0?Ts(e):Ts(e,l);if(t.length===0||l.length===0&&!i&&!o&&!a&&c.length===0&&u.length===0&&!n)return Ts(e);if(o&&l.length===0&&!n)return C(`complete: -F: option requires a command name
|
|
66
|
+
`,2);if(n){let f={isDefault:!0};return i!==void 0&&(f.wordlist=i),o!==void 0&&(f.function=o),a!==void 0&&(f.command=a),c.length>0&&(f.options=c),u.length>0&&(f.actions=u),e.state.completionSpecs.set("__default__",f),Ee()}for(let f of l){let h=Object.create(null);i!==void 0&&(h.wordlist=i),o!==void 0&&(h.function=o),a!==void 0&&(h.command=a),c.length>0&&(h.options=c),u.length>0&&(h.actions=u),e.state.completionSpecs.set(f,h)}return Ee()}function Ts(e,t){let s=e.state.completionSpecs;if(!s||s.size===0){if(t&&t.length>0){let i="";for(let o of t)i+=`complete: ${o}: no completion specification
|
|
67
|
+
`;return R(M,B(i),1)}return Ee()}let r=[],n=t||Array.from(s.keys());for(let i of n){if(i==="__default__")continue;let o=s.get(i);if(!o){if(t)return R(B(r.join(`
|
|
68
|
+
`)+(r.length>0?`
|
|
69
|
+
`:"")),B(`complete: ${i}: no completion specification
|
|
70
|
+
`),1);continue}let a="complete";if(o.options)for(let c of o.options)a+=` -o ${c}`;if(o.actions)for(let c of o.actions)a+=` -A ${c}`;o.wordlist!==void 0&&(o.wordlist.includes(" ")||o.wordlist.includes("'")?a+=` -W '${o.wordlist}'`:a+=` -W ${o.wordlist}`),o.function!==void 0&&(a+=` -F ${o.function}`),o.isDefault&&(a+=" -D"),a+=` ${i}`,r.push(a)}return r.length===0?Ee():q(`${r.join(`
|
|
71
71
|
`)}
|
|
72
|
-
`)}var
|
|
73
|
-
`,2);let u=t[a];if(!
|
|
74
|
-
`,2);
|
|
75
|
-
`,2);let u=t[a];if(!
|
|
76
|
-
`,2);i.push(u)}else if(c==="--"){o.push(...t.slice(a+1));break}else!c.startsWith("-")&&!c.startsWith("+")&&o.push(c)}if(s){let a=e.state.completionSpecs.get("__default__")??{isDefault:!0},c=new Set(a.options??[]);for(let u of
|
|
77
|
-
`,1)}function
|
|
78
|
-
`));let s=1;if(t.length>0){let
|
|
79
|
-
`));s=
|
|
80
|
-
`;else{let l=u.map(f=>{let
|
|
81
|
-
`}continue}let c=
|
|
72
|
+
`)}var yn=["bashdefault","default","dirnames","filenames","noquote","nosort","nospace","plusdirs"];function Ds(e,t){e.state.completionSpecs||(e.state.completionSpecs=new Map);let s=!1,r=!1,n=[],i=[],o=[];for(let a=0;a<t.length;a++){let c=t[a];if(c==="-D")s=!0;else if(c==="-E")r=!0;else if(c==="-o"){if(a++,a>=t.length)return C(`compopt: -o: option requires an argument
|
|
73
|
+
`,2);let u=t[a];if(!yn.includes(u))return C(`compopt: ${u}: invalid option name
|
|
74
|
+
`,2);n.push(u)}else if(c==="+o"){if(a++,a>=t.length)return C(`compopt: +o: option requires an argument
|
|
75
|
+
`,2);let u=t[a];if(!yn.includes(u))return C(`compopt: ${u}: invalid option name
|
|
76
|
+
`,2);i.push(u)}else if(c==="--"){o.push(...t.slice(a+1));break}else!c.startsWith("-")&&!c.startsWith("+")&&o.push(c)}if(s){let a=e.state.completionSpecs.get("__default__")??{isDefault:!0},c=new Set(a.options??[]);for(let u of n)c.add(u);for(let u of i)c.delete(u);return a.options=c.size>0?Array.from(c):void 0,e.state.completionSpecs.set("__default__",a),Ee()}if(r){let a=e.state.completionSpecs.get("__empty__")??{},c=new Set(a.options??[]);for(let u of n)c.add(u);for(let u of i)c.delete(u);return a.options=c.size>0?Array.from(c):void 0,e.state.completionSpecs.set("__empty__",a),Ee()}if(o.length>0){for(let a of o){let c=e.state.completionSpecs.get(a)??{},u=new Set(c.options??[]);for(let l of n)u.add(l);for(let l of i)u.delete(l);c.options=u.size>0?Array.from(u):void 0,e.state.completionSpecs.set(a,c)}return Ee()}return C(`compopt: not currently executing completion function
|
|
77
|
+
`,1)}function Is(e,t){if(e.state.loopDepth===0){if(e.state.parentHasLoopContext)throw new Fe;return j()}if(t.length>1)throw new Z(1,w(),N(`bash: continue: too many arguments
|
|
78
|
+
`));let s=1;if(t.length>0){let r=Number.parseInt(t[0],10);if(Number.isNaN(r)||r<1)throw new Z(1,w(),N(`bash: continue: ${t[0]}: numeric argument required
|
|
79
|
+
`));s=r}throw new Se(s)}function Q(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 Rs(e){for(let t=0;t<e.length;t++){let s=e.charCodeAt(t);if(s<32||s===127)return!0}return!1}function Ls(e){let t="$'";for(let s=0;s<e.length;s++){let r=e[s],n=e.charCodeAt(s);n===7?t+="\\a":n===8?t+="\\b":n===9?t+="\\t":n===10?t+="\\n":n===11?t+="\\v":n===12?t+="\\f":n===13?t+="\\r":n===27?t+="\\e":n===39?t+="\\'":n===92?t+="\\\\":n<32||n===127?t+=`\\${n.toString(8).padStart(3,"0")}`:t+=r}return t+="'",t}function Xt(e){return Rs(e)?Ls(e):/^[a-zA-Z0-9_/.:\-@%+,=]*$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}function Ge(e){return Rs(e)?Ls(e):`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function Ms(e){return Rs(e)?Ls(e):`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function gn(e,t){let s="";return e.state.integerVars?.has(t)&&(s+="i"),e.state.lowercaseVars?.has(t)&&(s+="l"),me(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 Fs(e){return e===""?"''":/[\s'\\]/.test(e)?`'${e.replace(/'/g,"'\\''")}'`:e}function wn(e,t){let s="",r="",n=!1;for(let i of t){let o=gn(e,i);if(e.state.associativeArrays?.has(i)){let u=ze(e,i);if(u.length===0)s+=`declare -A ${i}=()
|
|
80
|
+
`;else{let l=u.map(f=>{let h=T(e.state.env,`${i}_${f}`,""),d=Fs(h);return`['${f}']=${d}`});s+=`declare -A ${i}=(${l.join(" ")})
|
|
81
|
+
`}continue}let c=le(e,i);if(c.length>0){let u=c.map(l=>{let f=T(e.state.env,`${i}_${l}`,"");return`[${l}]=${Ge(f)}`});s+=`declare -a ${i}=(${u.join(" ")})
|
|
82
82
|
`;continue}if(e.state.env.has(`${i}__length`)){s+=`declare -a ${i}=()
|
|
83
|
-
`;continue}if(e.state.env.has(i)){let u=
|
|
83
|
+
`;continue}if(e.state.env.has(i)){let u=T(e.state.env,i);s+=`declare ${o} ${i}=${Ms(u)}
|
|
84
84
|
`}else{let u=e.state.declaredVars?.has(i),l=e.state.localVarDepth?.has(i);u||l?s+=`declare ${o} ${i}
|
|
85
|
-
`:(
|
|
86
|
-
`,
|
|
87
|
-
`;else{let
|
|
88
|
-
`}continue}if(
|
|
85
|
+
`:(r+=`bash: declare: ${i}: not found
|
|
86
|
+
`,n=!0)}}return R(B(s),B(r),n?1:0)}function vn(e,t){let{filterExport:s,filterReadonly:r,filterNameref:n,filterIndexedArray:i,filterAssocArray:o}=t,a=s||r||n||i||o,c="",u=new Set;for(let f of e.state.env.keys()){if(f.startsWith("BASH_"))continue;if(f.endsWith("__length")){let d=f.slice(0,-8);u.add(d);continue}let h=f.lastIndexOf("_");if(h>0){let d=f.slice(0,h),m=f.slice(h+1);if(/^\d+$/.test(m)||e.state.associativeArrays?.has(d)){u.add(d);continue}}u.add(f)}if(e.state.localVarDepth)for(let f of e.state.localVarDepth.keys())u.add(f);if(e.state.associativeArrays)for(let f of e.state.associativeArrays)u.add(f);let l=Array.from(u).sort();for(let f of l){let h=gn(e,f),d=e.state.associativeArrays?.has(f),m=le(e,f),p=!d&&(m.length>0||e.state.env.has(`${f}__length`));if(!(a&&(o&&!d||i&&!p||s&&!e.state.exportedVars?.has(f)||r&&!e.state.readonlyVars?.has(f)||n&&!me(e,f)))){if(d){let v=ze(e,f);if(v.length===0)c+=`declare -A ${f}=()
|
|
87
|
+
`;else{let y=v.map(E=>{let _=T(e.state.env,`${f}_${E}`,""),b=Fs(_);return`['${E}']=${b}`});c+=`declare -A ${f}=(${y.join(" ")})
|
|
88
|
+
`}continue}if(m.length>0){let v=m.map(y=>{let E=T(e.state.env,`${f}_${y}`,"");return`[${y}]=${Ge(E)}`});c+=`declare -a ${f}=(${v.join(" ")})
|
|
89
89
|
`;continue}if(e.state.env.has(`${f}__length`)){c+=`declare -a ${f}=()
|
|
90
|
-
`;continue}if(e.state.env.has(f)){let
|
|
91
|
-
`}}}return
|
|
92
|
-
`;else{let i=
|
|
93
|
-
`}}return
|
|
94
|
-
`;else{let o=i.map(a=>{let c=
|
|
95
|
-
`}}return
|
|
96
|
-
`);return
|
|
97
|
-
`),2)}}}else if(
|
|
98
|
-
`),2);else
|
|
99
|
-
`;return
|
|
100
|
-
`:
|
|
90
|
+
`;continue}if(e.state.env.has(f)){let v=T(e.state.env,f);c+=`declare ${h} ${f}=${Ms(v)}
|
|
91
|
+
`}}}return q(c)}function bn(e){let t="",s=Array.from(e.state.associativeArrays??[]).sort();for(let r of s){let n=ze(e,r);if(n.length===0)t+=`declare -A ${r}=()
|
|
92
|
+
`;else{let i=n.map(o=>{let a=T(e.state.env,`${r}_${o}`,""),c=Fs(a);return`['${o}']=${c}`});t+=`declare -A ${r}=(${i.join(" ")})
|
|
93
|
+
`}}return q(t)}function Sn(e){let t="",s=new Set;for(let n of e.state.env.keys()){if(n.startsWith("BASH_"))continue;if(n.endsWith("__length")){let o=n.slice(0,-8);e.state.associativeArrays?.has(o)||s.add(o);continue}let i=n.lastIndexOf("_");if(i>0){let o=n.slice(0,i),a=n.slice(i+1);/^\d+$/.test(a)&&(e.state.associativeArrays?.has(o)||s.add(o))}}let r=Array.from(s).sort();for(let n of r){let i=le(e,n);if(i.length===0)t+=`declare -a ${n}=()
|
|
94
|
+
`;else{let o=i.map(a=>{let c=T(e.state.env,`${n}_${a}`,"");return`[${a}]=${Ge(c)}`});t+=`declare -a ${n}=(${o.join(" ")})
|
|
95
|
+
`}}return q(t)}function En(e){let t="",s=new Set;for(let n of e.state.env.keys()){if(n.startsWith("BASH_"))continue;if(n.endsWith("__length")){let o=n.slice(0,-8);s.add(o);continue}let i=n.lastIndexOf("_");if(i>0){let o=n.slice(0,i),a=n.slice(i+1);if(/^\d+$/.test(a)||e.state.associativeArrays?.has(o)){s.add(o);continue}}s.add(n)}let r=Array.from(s).sort();for(let n of r)e.state.associativeArrays?.has(n)||le(e,n).length>0||e.state.env.has(`${n}__length`)||e.state.env.has(n)&&(t+=`${n}=${Xt(T(e.state.env,n))}
|
|
96
|
+
`);return q(t)}function Ws(e,t){e.state.integerVars??=new Set,e.state.integerVars.add(t)}function pt(e,t){return e.state.integerVars?.has(t)??!1}function zs(e,t){e.state.lowercaseVars??=new Set,e.state.lowercaseVars.add(t),e.state.uppercaseVars?.delete(t)}function lo(e,t){return e.state.lowercaseVars?.has(t)??!1}function Vs(e,t){e.state.uppercaseVars??=new Set,e.state.uppercaseVars.add(t),e.state.lowercaseVars?.delete(t)}function co(e,t){return e.state.uppercaseVars?.has(t)??!1}function nt(e,t,s){return lo(e,t)?s.toLowerCase():co(e,t)?s.toUpperCase():s}async function $n(e,t){try{let s=new G,r=se(s,t),n=await X(e,r.expression);return String(n)}catch{return"0"}}function uo(e){let t=e.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);if(!t)return null;let s=t[0],r=s.length;if(e[r]!=="[")return null;let n=0,i=r+1;for(;r<e.length;r++)if(e[r]==="[")n++;else if(e[r]==="]"&&(n--,n===0))break;if(n!==0)return null;let o=e.slice(i,r);if(r++,e[r]!=="=")return null;r++;let a=e.slice(r);return{name:s,indexExpr:o,value:a}}async function Bs(e,t){let s=!1,r=!1,n=!1,i=!1,o=!1,a=!1,c=!1,u=!1,l=!1,f=!1,h=!1,d=!1,m=!1,p=!1,v=!1,y=[];for(let x=0;x<t.length;x++){let P=t[x];if(P==="-a")s=!0;else if(P==="-A")r=!0;else if(P==="-r")n=!0;else if(P==="-x")i=!0;else if(P==="-p")o=!0;else if(P==="-n")a=!0;else if(P==="+n")c=!0;else if(P==="+a")u=!0;else if(P==="+x")l=!0;else if(P==="--"){y.push(...t.slice(x+1));break}else if(P.startsWith("+")){for(let W of P.slice(1))if(W==="n")c=!0;else if(W==="a")u=!0;else if(W==="x")l=!0;else if(W!=="r"){if(W!=="i"){if(!(W==="f"||W==="F"))return R(M,B(`bash: typeset: +${W}: invalid option
|
|
97
|
+
`),2)}}}else if(P==="-i")f=!0;else if(P==="-l")h=!0;else if(P==="-u")d=!0;else if(P==="-f")m=!0;else if(P==="-F")p=!0;else if(P==="-g")v=!0;else if(P.startsWith("-"))for(let W of P.slice(1))if(W==="a")s=!0;else if(W==="A")r=!0;else if(W==="r")n=!0;else if(W==="x")i=!0;else if(W==="p")o=!0;else if(W==="n")a=!0;else if(W==="i")f=!0;else if(W==="l")h=!0;else if(W==="u")d=!0;else if(W==="f")m=!0;else if(W==="F")p=!0;else if(W==="g")v=!0;else return R(M,B(`bash: typeset: -${W}: invalid option
|
|
98
|
+
`),2);else y.push(P)}let _=e.state.localScopes.length>0&&!v,b=x=>{if(!_)return;let P=e.state.localScopes[e.state.localScopes.length-1];P.has(x)||P.set(x,e.state.env.get(x))},k=x=>{if(!_)return;let P=e.state.localScopes[e.state.localScopes.length-1];P.has(x)||P.set(x,e.state.env.get(x));let W=`${x}_`;for(let O of e.state.env.keys())O.startsWith(W)&&!O.includes("__")&&(P.has(O)||P.set(O,e.state.env.get(O)));let I=`${x}__length`;e.state.env.has(I)&&!P.has(I)&&P.set(I,e.state.env.get(I))},L=x=>{_&&Be(e,x)};if(p){if(y.length===0){let W=Array.from(e.state.functions.keys()).sort(),I="";for(let O of W)I+=`declare -f ${O}
|
|
99
|
+
`;return q(I)}let x=!0,P="";for(let W of y)e.state.functions.has(W)?P+=`${W}
|
|
100
|
+
`:x=!1;return R(B(P),M,x?0:1)}if(m){if(y.length===0){let P="",W=Array.from(e.state.functions.keys()).sort();for(let I of W)P+=`${I} ()
|
|
101
101
|
{
|
|
102
102
|
# function body
|
|
103
103
|
}
|
|
104
|
-
`;return
|
|
105
|
-
`,
|
|
106
|
-
`,
|
|
107
|
-
`,
|
|
108
|
-
`,
|
|
109
|
-
`,
|
|
110
|
-
`,
|
|
111
|
-
`}}return
|
|
112
|
-
`,2);
|
|
113
|
-
`,2);if(
|
|
114
|
-
`,2);
|
|
115
|
-
`,1);let a=s[0];s[0]=s[1],s[1]=a,
|
|
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(
|
|
104
|
+
`;return q(P)}let x=!0;for(let P of y)e.state.functions.has(P)||(x=!1);return R(M,M,x?0:1)}if(o&&y.length>0)return wn(e,y);if(o&&y.length===0)return vn(e,{filterExport:i,filterReadonly:n,filterNameref:a,filterIndexedArray:s,filterAssocArray:r});if(y.length===0&&r&&!o)return bn(e);if(y.length===0&&s&&!o)return Sn(e);if(y.length===0&&!o)return En(e);let $="",A=0;for(let x of y){let P=x.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(P&&!u){let S=P[1],F=P[2];if(r&&le(e,S).length>0){$+=`bash: declare: ${S}: cannot convert indexed to associative array
|
|
105
|
+
`,A=1;continue}if((s||!r&&!s)&&e.state.associativeArrays?.has(S)){$+=`bash: declare: ${S}: cannot convert associative to indexed array
|
|
106
|
+
`,A=1;continue}if(k(S),r&&(e.state.associativeArrays??=new Set,e.state.associativeArrays.add(S)),Te(e,S),e.state.env.delete(S),e.state.env.delete(`${S}__length`),r&&F.includes("[")){let z=Ut(F);for(let[ne,U]of z){let J=Q(e,U);g(e.state.env,`${S}_${ne}`,J)}}else if(r){let z=Ie(F);for(let ne=0;ne<z.length;ne+=2){let U=z[ne],J=ne+1<z.length?Q(e,z[ne+1]):"";g(e.state.env,`${S}_${U}`,J)}}else{let z=Ie(F);if(z.some(U=>/^\[[^\]]+\]=/.test(U))){let U=0;for(let J of z){let ue=J.match(/^\[([^\]]+)\]=(.*)$/);if(ue){let ve=ue[1],qe=ue[2],mi=Q(e,qe),ot;if(/^-?\d+$/.test(ve))ot=Number.parseInt(ve,10);else try{let yi=new G,gi=se(yi,ve);ot=await X(e,gi.expression)}catch{ot=0}g(e.state.env,`${S}_${ot}`,mi),U=ot+1}else{let ve=Q(e,J);g(e.state.env,`${S}_${U}`,ve),U++}}}else{for(let U=0;U<z.length;U++)g(e.state.env,`${S}_${U}`,z[U]);g(e.state.env,`${S}__length`,String(z.length))}}L(S),n&&ye(e,S),i&&Pe(e,S);continue}if(c){let S=x.includes("=")?x.slice(0,x.indexOf("=")):x;if(Cr(e,S),!x.includes("="))continue}if(l){let S=x.includes("=")?x.slice(0,x.indexOf("=")):x;if(Tt(e,S),!x.includes("="))continue}let W=uo(x);if(W){let{name:S,indexExpr:F,value:z}=W,ne=ie(e,S);if(ne)return ne;k(S);let U;try{let ue=new G,ve=se(ue,F);U=await X(e,ve.expression)}catch{let ue=parseInt(F,10);U=Number.isNaN(ue)?0:ue}g(e.state.env,`${S}_${U}`,z);let J=parseInt(T(e.state.env,`${S}__length`,"0"),10);U>=J&&g(e.state.env,`${S}__length`,String(U+1)),L(S),n&&ye(e,S),i&&Pe(e,S);continue}let I=x.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=\((.*)\)$/s);if(I&&!u){let S=I[1],F=I[2],z=ie(e,S);if(z)return z;k(S);let ne=Ie(F);if(e.state.associativeArrays?.has(S)){let U=Ut(F);for(let[J,ue]of U){let ve=Q(e,ue);g(e.state.env,`${S}_${J}`,ve)}}else{let U=le(e,S),J=0,ue=e.state.env.get(S);U.length===0&&ue!==void 0?(e.state.env.set(`${S}_0`,ue),e.state.env.delete(S),J=1):U.length>0&&(J=Math.max(...U)+1);for(let qe=0;qe<ne.length;qe++)g(e.state.env,`${S}_${J+qe}`,Q(e,ne[qe]));let ve=J+ne.length;g(e.state.env,`${S}__length`,String(ve))}L(S),n&&ye(e,S),i&&Pe(e,S);continue}let O=x.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(O){let S=O[1],F=Q(e,O[2]),z=ie(e,S);if(z)return z;b(S),f&&Ws(e,S),h&&zs(e,S),d&&Vs(e,S);let U=le(e,S).length>0||e.state.associativeArrays?.has(S);if(pt(e,S)){let J=T(e.state.env,S,"0"),ue=parseInt(J,10)||0,ve=parseInt(await $n(e,F),10)||0;F=String(ue+ve),g(e.state.env,S,F)}else if(U){F=nt(e,S,F);let J=`${S}_0`,ue=T(e.state.env,J);g(e.state.env,J,ue+F)}else{F=nt(e,S,F);let J=T(e.state.env,S);g(e.state.env,S,J+F)}L(S),n&&ye(e,S),i&&Pe(e,S),e.state.options.allexport&&!l&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(S));continue}if(x.includes("=")){let S=x.indexOf("="),F=x.slice(0,S),z=x.slice(S+1);if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(F)){$+=`bash: typeset: \`${F}': not a valid identifier
|
|
107
|
+
`,A=1;continue}let ne=ie(e,F);if(ne)return ne;if(b(F),a){if(z!==""&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(z)){$+=`bash: declare: \`${z}': invalid variable name for name reference
|
|
108
|
+
`,A=1;continue}g(e.state.env,F,z),Le(e,F),z!==""&&ds(e,z)&&fs(e,F),L(F),n&&ye(e,F),i&&Pe(e,F);continue}if(f&&Ws(e,F),h&&zs(e,F),d&&Vs(e,F),pt(e,F)&&(z=await $n(e,z)),z=nt(e,F,z),me(e,F)){let U=Oe(e,F);U&&U!==F?g(e.state.env,U,z):g(e.state.env,F,z)}else g(e.state.env,F,z);L(F),n&&ye(e,F),i&&Pe(e,F),e.state.options.allexport&&!l&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(F))}else{let S=x;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(S)){$+=`bash: typeset: \`${S}': not a valid identifier
|
|
109
|
+
`,A=1;continue}if(s||r?k(S):b(S),a){Le(e,S);let z=T(e.state.env,S);z!==""&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(z)?kr(e,S):z&&ds(e,z)&&fs(e,S),L(S),n&&ye(e,S),i&&Pe(e,S);continue}if(f&&Ws(e,S),h&&zs(e,S),d&&Vs(e,S),r){if(le(e,S).length>0){$+=`bash: declare: ${S}: cannot convert indexed to associative array
|
|
110
|
+
`,A=1;continue}e.state.associativeArrays??=new Set,e.state.associativeArrays.add(S)}let F=Array.from(e.state.env.keys()).some(z=>z.startsWith(`${S}_`)&&!z.startsWith(`${S}__length`));!e.state.env.has(S)&&!F&&(s||r?g(e.state.env,`${S}__length`,"0"):(e.state.declaredVars??=new Set,e.state.declaredVars.add(S))),L(S),n&&ye(e,S),i&&Pe(e,S)}}return R(M,B($),A)}async function js(e,t){let s=!1,r=!1,n=!1,i=[];for(let o=0;o<t.length;o++){let a=t[o];if(a==="-a")s=!0;else if(a==="-A")r=!0;else if(a==="-p")n=!0;else if(a==="--"){i.push(...t.slice(o+1));break}else a.startsWith("-")||i.push(a)}if(i.length===0){let o="",a=Array.from(e.state.readonlyVars||[]).sort();for(let c of a){let u=e.state.env.get(c);if(u!==void 0){let l=H(u??M).replace(/\\/g,"\\\\").replace(/"/g,'\\"');o+=`declare -r ${c}="${l}"
|
|
111
|
+
`}}return q(o)}for(let o of i){let a=o.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=\((.*)\)$/s);if(a){let f=a[1],h=a[2],d=ie(e,f);if(d)return d;let m=Ie(h);if(e.state.associativeArrays?.has(f)){let p=Ut(h);for(let[v,y]of p){let E=Q(e,y);g(e.state.env,`${f}_${v}`,E)}}else{let p=le(e,f),v=0,y=e.state.env.get(f);p.length===0&&y!==void 0?(e.state.env.set(`${f}_0`,y),e.state.env.delete(f),v=1):p.length>0&&(v=Math.max(...p)+1);for(let _=0;_<m.length;_++)g(e.state.env,`${f}_${v+_}`,Q(e,m[_]));let E=v+m.length;g(e.state.env,`${f}__length`,String(E))}ye(e,f);continue}let c=o.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(c){let f=c[1],h=Q(e,c[2]),d=ie(e,f);if(d)return d;let m=T(e.state.env,f);g(e.state.env,f,m+h),ye(e,f);continue}let u=an(o);if(u.value===void 0&&!u.isArray){ye(e,u.name);continue}let l=await ln(e,u,{makeReadonly:!0});if(l)return l}return Je}function Hs(e){return e.state.directoryStack??=[],e.state.directoryStack}function mt(e,t){return t&&e===t?"~":t&&e.startsWith(`${t}/`)?`~${e.slice(t.length)}`:e}function fo(e){let t=e.split("/").filter(r=>r&&r!=="."),s=[];for(let r of t)r===".."?s.pop():s.push(r);return`/${s.join("/")}`}async function Us(e,t){let s=Hs(e),r;for(let a=0;a<t.length;a++){let c=t[a];if(c==="--"){if(a+1<t.length){if(r!==void 0)return C(`bash: pushd: too many arguments
|
|
112
|
+
`,2);r=t[a+1],a++}}else{if(c.startsWith("-")&&c!=="-")return C(`bash: pushd: ${c}: invalid option
|
|
113
|
+
`,2);if(r!==void 0)return C(`bash: pushd: too many arguments
|
|
114
|
+
`,2);r=c}}if(r===void 0){if(s.length<2)return C(`bash: pushd: no other directory
|
|
115
|
+
`,1);let a=s[0];s[0]=s[1],s[1]=a,r=s[0]}let n;if(r.startsWith("/"))n=r;else if(r===".."){let a=e.state.cwd.split("/").filter(c=>c);a.pop(),n=`/${a.join("/")}`}else r==="."?n=e.state.cwd:r.startsWith("~")?n=T(e.state.env,"HOME","/")+r.slice(1):n=`${e.state.cwd}/${r}`;n=fo(n);try{if(!(await e.fs.stat(n)).isDirectory)return C(`bash: pushd: ${r}: Not a directory
|
|
116
|
+
`,1)}catch{return C(`bash: pushd: ${r}: No such file or directory
|
|
117
|
+
`,1)}s.unshift(e.state.cwd),e.state.previousDir=e.state.cwd,e.state.cwd=n,g(e.state.env,"PWD",n),g(e.state.env,"OLDPWD",e.state.previousDir);let i=T(e.state.env,"HOME",""),o=`${[n,...s].map(a=>mt(a,i)).join(" ")}
|
|
118
|
+
`;return q(o)}function Gs(e,t){let s=Hs(e);for(let o of t)if(o!=="--")return o.startsWith("-")&&o!=="-"?C(`bash: popd: ${o}: invalid option
|
|
119
|
+
`,2):C(`bash: popd: too many arguments
|
|
120
|
+
`,2);if(s.length===0)return C(`bash: popd: directory stack empty
|
|
121
|
+
`,1);let r=s.shift();if(!r)return C(`bash: popd: directory stack empty
|
|
122
|
+
`,1);e.state.previousDir=e.state.cwd,e.state.cwd=r,g(e.state.env,"PWD",r),g(e.state.env,"OLDPWD",e.state.previousDir);let n=T(e.state.env,"HOME",""),i=`${[r,...s].map(o=>mt(o,n)).join(" ")}
|
|
123
|
+
`;return q(i)}function qs(e,t){let s=Hs(e),r=!1,n=!1,i=!1,o=!1;for(let l of t)if(l!=="--")if(l.startsWith("-"))for(let f of l.slice(1))if(f==="c")r=!0;else if(f==="l")n=!0;else if(f==="p")i=!0;else if(f==="v")i=!0,o=!0;else return C(`bash: dirs: -${f}: invalid option
|
|
124
|
+
`,2);else return C(`bash: dirs: too many arguments
|
|
125
|
+
`,1);if(r)return e.state.directoryStack=[],Je;let a=[e.state.cwd,...s],c=T(e.state.env,"HOME",""),u;return o?(u=a.map((l,f)=>{let h=n?l:mt(l,c);return` ${f} ${h}`}).join(`
|
|
126
126
|
`),u+=`
|
|
127
|
-
`):i?u=a.map(l=>
|
|
127
|
+
`):i?u=a.map(l=>n?l:mt(l,c)).join(`
|
|
128
128
|
`)+`
|
|
129
|
-
`:u=a.map(l=>
|
|
130
|
-
`,
|
|
129
|
+
`:u=a.map(l=>n?l:mt(l,c)).join(" ")+`
|
|
130
|
+
`,q(u)}async function Kt(e,t,s){let r=t;if(r.length>0){let a=r[0];if(a==="--")r=r.slice(1);else if(a.startsWith("-")&&a!=="-"&&a.length>1)return C(`bash: eval: ${a}: invalid option
|
|
131
131
|
eval: usage: eval [arg ...]
|
|
132
|
-
`,2)}if(
|
|
133
|
-
`);throw a}finally{e.state.groupStdin=i}}function
|
|
134
|
-
`),s=2):s=(i%256+256)%256}throw new
|
|
135
|
-
`}}return
|
|
136
|
-
`,i=1;continue}if(c!==void 0)if(u){let f=
|
|
137
|
-
`);let s=t[0],
|
|
138
|
-
`,
|
|
139
|
-
`,
|
|
140
|
-
`,1);a=t[u],u++}else if(
|
|
141
|
-
`,1):
|
|
142
|
-
`,1);u++}else c.push(
|
|
143
|
-
`,1);let
|
|
144
|
-
`,
|
|
145
|
-
`,1);let
|
|
146
|
-
`:
|
|
147
|
-
`:(
|
|
148
|
-
`,
|
|
149
|
-
`,1);let
|
|
150
|
-
`);let
|
|
151
|
-
`;else{
|
|
152
|
-
`;for(let[,
|
|
153
|
-
`}return
|
|
154
|
-
`,l=!0;continue}let
|
|
155
|
-
`,l=!0)}return l?
|
|
132
|
+
`,2)}if(r.length===0)return j();let n=r.join(" ");if(n.trim()==="")return j();let i=e.state.groupStdin,o=s??e.state.groupStdin;o!==void 0&&(e.state.groupStdin=o);try{let a=xe(n);return await e.executeScript(a)}catch(a){if(a instanceof be||a instanceof Se||a instanceof pe||a instanceof Z)throw a;if(a.name==="ParseException")return C(`bash: eval: ${a.message}
|
|
133
|
+
`);throw a}finally{e.state.groupStdin=i}}function Zs(e,t){let s,r=w();if(t.length===0)s=e.state.lastExitCode;else{let n=t[0],i=Number.parseInt(n,10);n===""||Number.isNaN(i)||!/^-?\d+$/.test(n)?(r=N(`bash: exit: ${n}: numeric argument required
|
|
134
|
+
`),s=2):s=(i%256+256)%256}throw new Z(s,w(),r)}function Ys(e,t){let s=!1,r=[];for(let o of t)o==="-n"?s=!0:o==="-p"||o==="--"||r.push(o);if(r.length===0&&!s){let o="",a=e.state.exportedVars??new Set,c=Array.from(a).sort();for(let u of c){let l=e.state.env.get(u);if(l!==void 0){let f=H(l??M).replace(/\\/g,"\\\\").replace(/"/g,'\\"');o+=`declare -x ${u}="${f}"
|
|
135
|
+
`}}return q(o)}if(s){for(let o of r){let a,c;if(o.includes("=")){let u=o.indexOf("=");a=o.slice(0,u),c=Q(e,o.slice(u+1)),g(e.state.env,a,c)}else a=o;Tt(e,a)}return Je}let n="",i=0;for(let o of r){let a,c,u=!1,l=o.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(l)a=l[1],c=Q(e,l[2]),u=!0;else if(o.includes("=")){let f=o.indexOf("=");a=o.slice(0,f),c=Q(e,o.slice(f+1))}else a=o;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(a)){n+=`bash: export: \`${o}': not a valid identifier
|
|
136
|
+
`,i=1;continue}if(c!==void 0)if(u){let f=T(e.state.env,a);g(e.state.env,a,f+c)}else g(e.state.env,a,c);else e.state.env.has(a)||g(e.state.env,a,"");Pe(e,a)}return R(M,B(n),i)}function Qt(e,t){if(t.length<2)return C(`bash: getopts: usage: getopts optstring name [arg ...]
|
|
137
|
+
`);let s=t[0],r=t[1],n=!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r),i=s.startsWith(":"),o=i?s.slice(1):s,a;if(t.length>2)a=t.slice(2);else{let p=Number.parseInt(T(e.state.env,"#","0"),10);a=[];for(let v=1;v<=p;v++)a.push(T(e.state.env,String(v))||"")}let c=Number.parseInt(T(e.state.env,"OPTIND","1"),10);c<1&&(c=1);let u=Number.parseInt(T(e.state.env,"__GETOPTS_CHARINDEX","0"),10);if(g(e.state.env,"OPTARG",""),c>a.length)return n||g(e.state.env,r,"?"),g(e.state.env,"OPTIND",String(a.length+1)),g(e.state.env,"__GETOPTS_CHARINDEX","0"),{exitCode:n?2:1,stdout:w(),stderr:w()};let l=a[c-1];if(!l||l==="-"||!l.startsWith("-"))return n||g(e.state.env,r,"?"),{exitCode:n?2:1,stdout:w(),stderr:w()};if(l==="--")return g(e.state.env,"OPTIND",String(c+1)),g(e.state.env,"__GETOPTS_CHARINDEX","0"),n||g(e.state.env,r,"?"),{exitCode:n?2:1,stdout:w(),stderr:w()};let f=u===0?1:u,h=l[f];if(!h)return g(e.state.env,"OPTIND",String(c+1)),g(e.state.env,"__GETOPTS_CHARINDEX","0"),Qt(e,t);let d=o.indexOf(h);if(d===-1){let p="";return i?g(e.state.env,"OPTARG",h):p=`bash: illegal option -- ${h}
|
|
138
|
+
`,n||g(e.state.env,r,"?"),f+1<l.length?(g(e.state.env,"__GETOPTS_CHARINDEX",String(f+1)),g(e.state.env,"OPTIND",String(c))):(g(e.state.env,"OPTIND",String(c+1)),g(e.state.env,"__GETOPTS_CHARINDEX","0")),{exitCode:n?2:0,stdout:w(),stderr:N(p)}}if(d+1<o.length&&o[d+1]===":")if(f+1<l.length)g(e.state.env,"OPTARG",l.slice(f+1)),g(e.state.env,"OPTIND",String(c+1)),g(e.state.env,"__GETOPTS_CHARINDEX","0");else{if(c>=a.length){let p="";return i?(g(e.state.env,"OPTARG",h),n||g(e.state.env,r,":")):(p=`bash: option requires an argument -- ${h}
|
|
139
|
+
`,n||g(e.state.env,r,"?")),g(e.state.env,"OPTIND",String(c+1)),g(e.state.env,"__GETOPTS_CHARINDEX","0"),{exitCode:n?2:0,stdout:w(),stderr:N(p)}}g(e.state.env,"OPTARG",a[c]),g(e.state.env,"OPTIND",String(c+2)),g(e.state.env,"__GETOPTS_CHARINDEX","0")}else f+1<l.length?(g(e.state.env,"__GETOPTS_CHARINDEX",String(f+1)),g(e.state.env,"OPTIND",String(c))):(g(e.state.env,"OPTIND",String(c+1)),g(e.state.env,"__GETOPTS_CHARINDEX","0"));return n||g(e.state.env,r,h),{exitCode:n?2:0,stdout:w(),stderr:w()}}async function Xs(e,t){e.state.hashTable||(e.state.hashTable=new Map);let s=!1,r=!1,n=!1,i=!1,o=!1,a="",c=[],u=0;for(;u<t.length;){let m=t[u];if(m==="--"){u++,c.push(...t.slice(u));break}if(m==="-r")s=!0,u++;else if(m==="-d")r=!0,u++;else if(m==="-l")n=!0,u++;else if(m==="-t")o=!0,u++;else if(m==="-p"){if(i=!0,u++,u>=t.length)return C(`bash: hash: -p: option requires an argument
|
|
140
|
+
`,1);a=t[u],u++}else if(m.startsWith("-")&&m.length>1){for(let p of m.slice(1))if(p==="r")s=!0;else if(p==="d")r=!0;else if(p==="l")n=!0;else if(p==="t")o=!0;else return p==="p"?C(`bash: hash: -p: option requires an argument
|
|
141
|
+
`,1):C(`bash: hash: -${p}: invalid option
|
|
142
|
+
`,1);u++}else c.push(m),u++}if(s)return e.state.hashTable.clear(),j();if(r){if(c.length===0)return C(`bash: hash: -d: option requires an argument
|
|
143
|
+
`,1);let m=!1,p="";for(let v of c)e.state.hashTable.has(v)?e.state.hashTable.delete(v):(p+=`bash: hash: ${v}: not found
|
|
144
|
+
`,m=!0);return m?C(p,1):j()}if(o){if(c.length===0)return C(`bash: hash: -t: option requires an argument
|
|
145
|
+
`,1);let m="",p=!1,v="";for(let y of c){let E=e.state.hashTable.get(y);E?c.length>1?m+=`${y} ${E}
|
|
146
|
+
`:m+=`${E}
|
|
147
|
+
`:(v+=`bash: hash: ${y}: not found
|
|
148
|
+
`,p=!0)}return p?{exitCode:1,stdout:N(m),stderr:N(v)}:q(m)}if(i){if(c.length===0)return C(`bash: hash: usage: hash [-lr] [-p pathname] [-dt] [name ...]
|
|
149
|
+
`,1);let m=c[0];return e.state.hashTable.set(m,a),j()}if(c.length===0){if(e.state.hashTable.size===0)return q(`hash: hash table empty
|
|
150
|
+
`);let m="";if(n)for(let[p,v]of e.state.hashTable)m+=`builtin hash -p ${v} ${p}
|
|
151
|
+
`;else{m=`hits command
|
|
152
|
+
`;for(let[,p]of e.state.hashTable)m+=` 1 ${p}
|
|
153
|
+
`}return q(m)}let l=!1,f="",d=T(e.state.env,"PATH","/usr/bin:/bin").split(":");for(let m of c){if(m.includes("/")){f+=`bash: hash: ${m}: cannot use / in name
|
|
154
|
+
`,l=!0;continue}let p=!1;for(let v of d){if(!v)continue;let y=`${v}/${m}`;if(await e.fs.exists(y)){e.state.hashTable.set(m,y),p=!0;break}}p||(f+=`bash: hash: ${m}: not found
|
|
155
|
+
`,l=!0)}return l?C(f,1):j()}var An=new Map([[":",[": [arguments]",`Null command.
|
|
156
156
|
No effect; the command does nothing.
|
|
157
157
|
Exit Status:
|
|
158
158
|
Always succeeds.`]],[".",[". filename [arguments]",`Execute commands from a file in the current shell.
|
|
@@ -497,32 +497,32 @@ eval: usage: eval [arg ...]
|
|
|
497
497
|
job specification, and reports its termination status.
|
|
498
498
|
Exit Status:
|
|
499
499
|
Returns the status of the last ID; fails if ID is invalid or an invalid
|
|
500
|
-
option is given.`]]]),
|
|
501
|
-
`,2)}
|
|
502
|
-
`,o=!0;continue}for(let l of u){let f=
|
|
503
|
-
`:i+=`${l}: ${
|
|
504
|
-
${
|
|
505
|
-
`}}return{exitCode:o?1:0,stdout:
|
|
500
|
+
option is given.`]]]),_n=[...An.keys()].sort();function Ks(e,t){let s=!1,r=[],n=0;for(;n<t.length;){let c=t[n];if(c==="--"){for(n++;n<t.length;)r.push(t[n]),n++;break}if(c.startsWith("-")&&c.length>1){for(let u=1;u<c.length;u++){let l=c[u];if(l==="s")s=!0;else return C(`bash: help: -${l}: invalid option
|
|
501
|
+
`,2)}n++}else r.push(c),n++}if(r.length===0)return po();let i="",o=!1,a="";for(let c of r){let u=ho(c);if(u.length===0){a+=`bash: help: no help topics match \`${c}'. Try \`help help' or \`man -k ${c}' or \`info ${c}'.
|
|
502
|
+
`,o=!0;continue}for(let l of u){let f=An.get(l);if(!f)continue;let[h,d]=f;s?i+=`${l}: ${h}
|
|
503
|
+
`:i+=`${l}: ${h}
|
|
504
|
+
${d}
|
|
505
|
+
`}}return{exitCode:o?1:0,stdout:N(i),stderr:N(a)}}function ho(e){let t=e.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,"."),s=ut(`^${t}$`);return _n.filter(r=>s.test(r))}function po(){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=_n.slice(),r=Math.ceil(s.length/2);for(let n=0;n<r;n++){let i=s[n]||"",o=s[n+r]||"",a=i.padEnd(t);e.push(o?`${a}${o}`:i)}return q(`${e.join(`
|
|
506
506
|
`)}
|
|
507
|
-
`)}function
|
|
508
|
-
`);let s=
|
|
509
|
-
`)}return
|
|
510
|
-
`);let s=e.state.localScopes[e.state.localScopes.length-1],
|
|
511
|
-
`}}return
|
|
512
|
-
`,
|
|
513
|
-
`,
|
|
514
|
-
`,
|
|
515
|
-
`,i=0,o=0,a=0,c=!1,u="MAPFILE",l=0;for(;l<t.length;){let
|
|
516
|
-
`,l+=2):
|
|
517
|
-
`),1);let
|
|
518
|
-
`),1);
|
|
519
|
-
`,a="",c=-1,u=-1,l=null,f=-1,
|
|
520
|
-
`){
|
|
521
|
-
`){
|
|
522
|
-
`&&
|
|
523
|
-
`)&&(
|
|
524
|
-
`),1);
|
|
525
|
-
`,2);s=(
|
|
507
|
+
`)}function mo(e){let t=[],s="",r=0;for(let n of e){for(let i of n)i==="("?r++:i===")"&&r--;s?s+=` ${n}`:s=n,r===0&&(t.push(s),s="")}return s&&t.push(s),t}async function Qs(e,t){if(t.length===0)return C(`bash: let: expression expected
|
|
508
|
+
`);let s=mo(t),r=0;for(let n of s)try{let o=xe(`(( ${n} ))`).statements[0];if(o&&o.pipelines.length>0&&o.pipelines[0].commands.length>0){let a=o.pipelines[0].commands[0];a.type==="ArithmeticCommand"&&(r=await X(e,a.expression.expression))}}catch(i){return C(`bash: let: ${n}: ${i.message}
|
|
509
|
+
`)}return R(M,M,r===0?1:0)}async function Js(e,t){if(e.state.localScopes.length===0)return C(`bash: local: can only be used in a function
|
|
510
|
+
`);let s=e.state.localScopes[e.state.localScopes.length-1],r="",n=0,i=!1,o=!1,a=!1,c=[];for(let u of t)if(u==="-n")i=!0;else if(u==="-a")o=!0;else if(u==="-p")a=!0;else if(u.startsWith("-")&&!u.includes("="))for(let l of u.slice(1))l==="n"?i=!0:l==="a"?o=!0:l==="p"&&(a=!0);else c.push(u);if(c.length===0){let u="",l=Array.from(s.keys()).filter(f=>!f.includes("_")||!f.match(/_\d+$/)).filter(f=>!f.includes("__length")).sort();for(let f of l){let h=e.state.env.get(f);if(h!==void 0){let d=H(h);u+=`${f}=${d}
|
|
511
|
+
`}}return R(B(u),M,0)}for(let u of c){let l,f,h=u.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(h){l=h[1];let y=h[2];if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(l)){r+=`bash: local: \`${u}': not a valid identifier
|
|
512
|
+
`,n=1;continue}if(ie(e,l,"bash"),!s.has(l)){s.set(l,e.state.env.get(l));let b=`${l}_`;for(let k of e.state.env.keys())k.startsWith(b)&&!k.includes("__")&&(s.has(k)||s.set(k,e.state.env.get(k)))}let E=`${l}_`;for(let b of e.state.env.keys())b.startsWith(E)&&!b.includes("__")&&e.state.env.delete(b);let _=Ie(y);for(let b=0;b<_.length;b++)g(e.state.env,`${l}_${b}`,_[b]);g(e.state.env,`${l}__length`,String(_.length)),Be(e,l),i&&Le(e,l);continue}let d=u.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=\((.*)\)$/s);if(d){l=d[1];let y=d[2];if(ie(e,l,"bash"),!s.has(l)){s.set(l,e.state.env.get(l));let $=`${l}_`;for(let x of e.state.env.keys())x.startsWith($)&&!x.includes("__")&&(s.has(x)||s.set(x,e.state.env.get(x)));let A=`${l}__length`;e.state.env.has(A)&&!s.has(A)&&s.set(A,e.state.env.get(A))}let E=Ie(y),_=le(e,l),b=0,k=e.state.env.get(l);_.length===0&&k!==void 0?(e.state.env.set(`${l}_0`,k),e.state.env.delete(l),b=1):_.length>0&&(b=Math.max(..._)+1);for(let $=0;$<E.length;$++)g(e.state.env,`${l}_${b+$}`,Q(e,E[$]));let L=b+E.length;g(e.state.env,`${l}__length`,String(L)),Be(e,l),i&&Le(e,l);continue}let m=u.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(m){l=m[1];let y=Q(e,m[2]);ie(e,l,"bash"),s.has(l)||s.set(l,e.state.env.get(l));let E=T(e.state.env,l);g(e.state.env,l,E+y),Be(e,l),i&&Le(e,l);continue}let p=u.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([^\]]+)\]=(.*)$/s);if(p){l=p[1];let y=p[2],E=Q(e,p[3]);if(ie(e,l,"bash"),!s.has(l)){s.set(l,e.state.env.get(l));let k=`${l}_`;for(let $ of e.state.env.keys())$.startsWith(k)&&!$.includes("__")&&(s.has($)||s.set($,e.state.env.get($)));let L=`${l}__length`;e.state.env.has(L)&&!s.has(L)&&s.set(L,e.state.env.get(L))}let _;try{let k=new G,L=se(k,y);_=await X(e,L.expression)}catch{let k=parseInt(y,10);_=Number.isNaN(k)?0:k}g(e.state.env,`${l}_${_}`,E);let b=parseInt(T(e.state.env,`${l}__length`,"0"),10);_>=b&&g(e.state.env,`${l}__length`,String(_+1)),Be(e,l),i&&Le(e,l);continue}if(u.includes("=")){let y=u.indexOf("=");l=u.slice(0,y),f=Q(e,u.slice(y+1))}else l=u;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(l)){r+=`bash: local: \`${u}': not a valid identifier
|
|
513
|
+
`,n=1;continue}let v=s.has(l);if(f!==void 0){let y=e.state.env.get(l);if(e.state.tempEnvBindings){let E=e.state.accessedTempEnvVars?.has(l),_=e.state.mutatedTempEnvVars?.has(l);if(!E&&!_)for(let b=e.state.tempEnvBindings.length-1;b>=0;b--){let k=e.state.tempEnvBindings[b];if(k.has(l)){y=k.get(l);break}}}cn(e,l,y)}if(!v){let y=e.state.env.get(l);if(e.state.tempEnvBindings)for(let E=e.state.tempEnvBindings.length-1;E>=0;E--){let _=e.state.tempEnvBindings[E];if(_.has(l)){y=_.get(l);break}}if(s.set(l,y),o){let E=`${l}_`;for(let b of e.state.env.keys())b.startsWith(E)&&!b.includes("__")&&(s.has(b)||s.set(b,e.state.env.get(b)));let _=`${l}__length`;e.state.env.has(_)&&!s.has(_)&&s.set(_,e.state.env.get(_))}}if(o&&f===void 0){let y=`${l}_`;for(let E of e.state.env.keys())E.startsWith(y)&&!E.includes("__")&&e.state.env.delete(E);g(e.state.env,`${l}__length`,"0")}else if(f!==void 0){if(ie(e,l,"bash"),i&&f!==""&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(f)){r+=`bash: local: \`${f}': invalid variable name for name reference
|
|
514
|
+
`,n=1;continue}g(e.state.env,l,f),e.state.options.allexport&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(l))}else{let y=e.state.tempEnvBindings?.some(E=>E.has(l));!v&&!y&&e.state.env.delete(l)}Be(e,l),i&&Le(e,l)}return R(M,B(r),n)}async function er(e,t,s){let r=H(s),n=`
|
|
515
|
+
`,i=0,o=0,a=0,c=!1,u="MAPFILE",l=0;for(;l<t.length;){let _=t[l];_==="-d"&&l+1<t.length?(n=t[l+1]===""?"\0":t[l+1]||`
|
|
516
|
+
`,l+=2):_==="-n"&&l+1<t.length?(i=Number.parseInt(t[l+1],10)||0,l+=2):_==="-O"&&l+1<t.length?(o=Number.parseInt(t[l+1],10)||0,l+=2):_==="-s"&&l+1<t.length?(a=Number.parseInt(t[l+1],10)||0,l+=2):_==="-t"?(c=!0,l++):_==="-u"||_==="-C"||_==="-c"?l+=2:(_.startsWith("-")||(u=_),l++)}let f=r;!f&&e.state.groupStdin!==void 0&&(f=H(await Y(e.state.groupStdin)));let h=[],d=f,m=0,p=0,v=e.limits?.maxArrayElements??1e5;for(;d.length>0;){let _=d.indexOf(n);if(_===-1){if(d.length>0){if(p<a)p++;else if(i===0||m<i){if(o+m>=v)return R(M,B(`mapfile: array element limit exceeded (${v})
|
|
517
|
+
`),1);let L=d,$=L.indexOf("\0");$!==-1&&(L=L.substring(0,$)),h.push(L),m++}}break}let b=d.substring(0,_),k=b.indexOf("\0");if(k!==-1&&(b=b.substring(0,k)),!c&&n!=="\0"&&(b+=n),d=d.substring(_+n.length),p<a){p++;continue}if(i>0&&m>=i)break;if(o+m>=v)return R(M,B(`mapfile: array element limit exceeded (${v})
|
|
518
|
+
`),1);h.push(b),m++}o===0&&Te(e,u);for(let _=0;_<h.length;_++)g(e.state.env,`${u}_${o+_}`,h[_]);let y=parseInt(T(e.state.env,`${u}__length`,"0"),10),E=o+h.length;return g(e.state.env,`${u}__length`,String(Math.max(y,E))),e.state.groupStdin!==void 0&&!r&&(e.state.groupStdin=w()),R(M,M,0)}function yo(e){if(!e.startsWith("__rw__:"))return null;let t=e.slice(7),s=t.indexOf(":");if(s===-1)return null;let r=Number.parseInt(t.slice(0,s),10);if(Number.isNaN(r)||r<0)return null;let n=s+1,i=t.slice(n,n+r),o=n+r+1,a=t.slice(o),c=a.indexOf(":");if(c===-1)return null;let u=Number.parseInt(a.slice(0,c),10);if(Number.isNaN(u)||u<0)return null;let l=a.slice(c+1);return{path:i,position:u,content:l}}function go(e,t,s){return`__rw__:${e.length}:${e}:${t}:${s}`}async function tr(e,t,s,r=-1){let n=H(s),i=!1,o=`
|
|
519
|
+
`,a="",c=-1,u=-1,l=null,f=-1,h=-1,d=[],m=0,p=!1,v=(I,O)=>{let S=1;for(;S<I.length;){let F=I[S];if(F==="r")i=!0,S++;else if(F==="s")S++;else{if(F==="d")return S+1<I.length?(o=I.substring(S+1),{nextArgIndex:O+1}):O+1<t.length?(o=t[O+1],{nextArgIndex:O+2}):{nextArgIndex:O+1};if(F==="n"){if(S+1<I.length){let z=I.substring(S+1);return c=Number.parseInt(z,10),(Number.isNaN(c)||c<0)&&(p=!0,c=0),{nextArgIndex:O+1}}else if(O+1<t.length)return c=Number.parseInt(t[O+1],10),(Number.isNaN(c)||c<0)&&(p=!0,c=0),{nextArgIndex:O+2};return{nextArgIndex:O+1}}else if(F==="N"){if(S+1<I.length){let z=I.substring(S+1);return u=Number.parseInt(z,10),(Number.isNaN(u)||u<0)&&(p=!0,u=0),{nextArgIndex:O+1}}else if(O+1<t.length)return u=Number.parseInt(t[O+1],10),(Number.isNaN(u)||u<0)&&(p=!0,u=0),{nextArgIndex:O+2};return{nextArgIndex:O+1}}else{if(F==="a")return S+1<I.length?(l=I.substring(S+1),{nextArgIndex:O+1}):O+1<t.length?(l=t[O+1],{nextArgIndex:O+2}):{nextArgIndex:O+1};if(F==="p")return S+1<I.length?(a=I.substring(S+1),{nextArgIndex:O+1}):O+1<t.length?(a=t[O+1],{nextArgIndex:O+2}):{nextArgIndex:O+1};if(F==="u"){if(S+1<I.length){let z=I.substring(S+1);return f=Number.parseInt(z,10),Number.isNaN(f)||f<0?{nextArgIndex:-2}:{nextArgIndex:O+1}}else if(O+1<t.length)return f=Number.parseInt(t[O+1],10),Number.isNaN(f)||f<0?{nextArgIndex:-2}:{nextArgIndex:O+2};return{nextArgIndex:O+1}}else if(F==="t"){if(S+1<I.length){let z=I.substring(S+1);return h=Number.parseFloat(z),Number.isNaN(h)&&(h=0),{nextArgIndex:O+1}}else if(O+1<t.length)return h=Number.parseFloat(t[O+1]),Number.isNaN(h)&&(h=0),{nextArgIndex:O+2};return{nextArgIndex:O+1}}else if(F==="e"||F==="i"||F==="P"){if(F==="i"&&O+1<t.length)return{nextArgIndex:O+2};S++}else S++}}}return{nextArgIndex:O+1}};for(;m<t.length;){let I=t[m];if(I.startsWith("-")&&I.length>1&&I!=="--"){let O=v(I,m);if(O.nextArgIndex===-1)return{stdout:w(),stderr:w(),exitCode:2};if(O.nextArgIndex===-2)return{stdout:w(),stderr:w(),exitCode:1};m=O.nextArgIndex}else if(I==="--")for(m++;m<t.length;)d.push(t[m]),m++;else d.push(I),m++}if(p)return R(M,M,1);if(d.length===0&&l===null&&d.push("REPLY"),h===0){if(l)Te(e,l);else{for(let I of d)g(e.state.env,I,"");d.length===0&&g(e.state.env,"REPLY","")}return R(M,M,0)}if(h<0&&h!==-1)return R(M,M,1);let y=n;f>=0?e.state.fileDescriptors?y=e.state.fileDescriptors.get(f)||"":y="":!y&&e.state.groupStdin!==void 0&&(y=H(await Y(e.state.groupStdin)));let E=o===""?"\0":o,_="",b=0,k=!0,L=I=>{if(f>=0&&e.state.fileDescriptors)e.state.fileDescriptors.set(f,y.substring(I));else if(r>=0&&e.state.fileDescriptors){let O=e.state.fileDescriptors.get(r);if(O?.startsWith("__rw__:")){let S=yo(O);if(S){let F=S.position+I;e.state.fileDescriptors.set(r,go(S.path,F,S.content))}}}else e.state.groupStdin!==void 0&&!n&&(e.state.groupStdin=te(B(y.substring(I))))};if(u>=0){let I=Math.min(u,y.length);_=y.substring(0,I),b=I,k=I>=u,L(b);let O=d[0]||"REPLY";g(e.state.env,O,_);for(let S=1;S<d.length;S++)g(e.state.env,d[S],"");return R(M,M,k?0:1)}else if(c>=0){let I=0,O=0,S=!1;for(;O<y.length&&I<c;){let F=y[O];if(F===E){b=O+1,S=!0;break}if(!i&&F==="\\"&&O+1<y.length){let z=y[O+1];if(z===E&&E===`
|
|
520
|
+
`){O+=2,b=O;continue}if(z===E){O+=2,I++,_+=z,b=O;continue}_+=z,O+=2,I++,b=O}else _+=F,O++,I++,b=O}k=I>=c||S,L(b)}else{b=0;let I=0;for(;I<y.length;){let O=y[I];if(O===E){b=I+E.length,k=!0;break}if(!i&&O==="\\"&&I+1<y.length){let S=y[I+1];if(S===`
|
|
521
|
+
`){I+=2;continue}if(S===E){_+=S,I+=2;continue}_+=O,_+=S,I+=2;continue}_+=O,I++}if(I>=y.length&&(k=!1,b=I,_.length===0&&y.length===0)){for(let O of d)g(e.state.env,O,"");return l&&Te(e,l),R(M,M,1)}L(b)}E===`
|
|
522
|
+
`&&_.endsWith(`
|
|
523
|
+
`)&&(_=_.slice(0,-1));let $=I=>i?I:I.replace(/\\(.)/g,"$1");if(d.length===1&&d[0]==="REPLY")return g(e.state.env,"REPLY",$(_)),R(M,M,k?0:1);let A=Ar(e.state.env);if(l){let{words:I}=us(_,A,void 0,i),O=e.limits?.maxArrayElements??1e5;if(I.length>O)return R(M,B(`read: array element limit exceeded (${O})
|
|
524
|
+
`),1);Te(e,l);for(let S=0;S<I.length;S++)g(e.state.env,`${l}_${S}`,$(I[S]));return R(M,M,k?0:1)}let x=d.length,{words:P,wordStarts:W}=us(_,A,x,i);for(let I=0;I<d.length;I++){let O=d[I];if(I<d.length-1)g(e.state.env,O,$(P[I]??""));else if(I<W.length){let S=_.substring(W[I]);S=_r(S,A,i),S=$(S),g(e.state.env,O,S)}else g(e.state.env,O,"")}return R(M,M,k?0:1)}function sr(e,t){if(e.state.callDepth===0&&e.state.sourceDepth===0)return C("bash: return: can only `return' from a function or sourced script\n");let s=e.state.lastExitCode;if(t.length>0){let r=t[0],n=Number.parseInt(r,10);if(r===""||Number.isNaN(n)||!/^-?\d+$/.test(r))return C(`bash: return: ${r}: numeric argument required
|
|
525
|
+
`,2);s=(n%256+256)%256}throw new pe(s)}var Jt=`set: usage: set [-eux] [+eux] [-o option] [+o option]
|
|
526
526
|
Options:
|
|
527
527
|
-e Exit immediately if a command exits with non-zero status
|
|
528
528
|
+e Disable -e
|
|
@@ -538,163 +538,163 @@ Options:
|
|
|
538
538
|
+o pipefail Disable pipefail
|
|
539
539
|
-o xtrace Same as -x
|
|
540
540
|
+o xtrace Disable xtrace
|
|
541
|
-
`,
|
|
541
|
+
`,Cn=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]]),kn=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]]),Pn=["errexit","nounset","pipefail","verbose","xtrace","posix","allexport","noclobber","noglob","noexec","vi","emacs"],Nn=["braceexpand","errtrace","functrace","hashall","histexpand","history","ignoreeof","interactive-comments","keyword","monitor","nolog","notify","onecmd","physical","privileged"];function xn(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,Qe(e))}function wo(e,t){return t+1<e.length&&!e[t+1].startsWith("-")&&!e[t+1].startsWith("+")}function vo(e,t){let s=le(e,t);if(s.length===0)return`${t}=()`;let r=s.map(n=>{let i=T(e.state.env,`${t}_${n}`,"");return`[${n}]=${Ge(i)}`});return`${t}=(${r.join(" ")})`}function bo(e){return/^[a-zA-Z0-9_]+$/.test(e)?e:`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function So(e,t){let s=ze(e,t);if(s.length===0)return`${t}=()`;let r=s.map(n=>{let i=T(e.state.env,`${t}_${n}`,"");return`[${bo(n)}]=${Ge(i)}`});return`${t}=(${r.join(" ")} )`}function Eo(e){let t=new Set,s=e.state.associativeArrays??new Set;for(let r of e.state.env.keys()){let n=r.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_(\d+)$/);if(n){let i=n[1];s.has(i)||t.add(i)}}return t}function $o(e){return e.state.associativeArrays??new Set}function nr(e,t){if(t.includes("--help"))return q(Jt);if(t.length===0){let r=Eo(e),n=$o(e),i=c=>{for(let u of n){let l=`${u}_`,f=`${u}__length`;if(c!==f&&c.startsWith(l)){if(c.slice(l.length).startsWith("_length"))continue;return!0}}return!1},o=[];for(let[c,u]of e.state.env){if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(c)||r.has(c)||n.has(c))continue;let l=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_(\d+)$/);if(l&&r.has(l[1]))continue;let f=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)__length$/);f&&r.has(f[1])||i(c)||f&&n.has(f[1])||o.push([c,H(u)])}let a=[];for(let[c,u]of o.sort(([l],[f])=>l<f?-1:l>f?1:0))a.push(`${c}=${Xt(u)}`);for(let c of[...r].sort((u,l)=>u<l?-1:u>l?1:0))a.push(vo(e,c));for(let c of[...n].sort((u,l)=>u<l?-1:u>l?1:0))a.push(So(e,c));return a.sort((c,u)=>{let l=c.split("=")[0],f=u.split("=")[0];return l<f?-1:l>f?1:0}),q(a.length>0?`${a.join(`
|
|
542
542
|
`)}
|
|
543
|
-
`:"")}let s=0;for(;s<t.length;){let
|
|
544
|
-
${
|
|
543
|
+
`:"")}let s=0;for(;s<t.length;){let r=t[s];if((r==="-o"||r==="+o")&&wo(t,s)){let n=t[s+1];if(!kn.has(n)){let i=`bash: set: ${n}: invalid option name
|
|
544
|
+
${Jt}`;if(e.state.options.posix)throw new Ae(1,w(),N(i));return C(i)}xn(e,kn.get(n)??null,r==="-o"),s+=2;continue}if(r==="-o"){let n=Pn.map(a=>`${a.padEnd(16)}${e.state.options[a]?"on":"off"}`),i=Nn.map(a=>`${a.padEnd(16)}off`),o=[...n,...i].sort();return q(`${o.join(`
|
|
545
545
|
`)}
|
|
546
|
-
`)}if(
|
|
546
|
+
`)}if(r==="+o"){let n=Pn.map(a=>`set ${e.state.options[a]?"-o":"+o"} ${a}`),i=Nn.map(a=>`set +o ${a}`),o=[...n,...i].sort();return q(`${o.join(`
|
|
547
547
|
`)}
|
|
548
|
-
`)}if(
|
|
549
|
-
${
|
|
550
|
-
${
|
|
551
|
-
`;if(e.state.options.posix)throw new
|
|
552
|
-
`;if(e.state.options.posix)throw new
|
|
553
|
-
`),2);let
|
|
554
|
-
`);let o=new Map;if(s.length>1){for(let l=1;l<=9;l++)o.set(String(l),
|
|
555
|
-
`);throw u}}function
|
|
556
|
-
`,
|
|
557
|
-
`,
|
|
558
|
-
`,
|
|
559
|
-
`,
|
|
560
|
-
`,
|
|
561
|
-
`,
|
|
562
|
-
`,
|
|
563
|
-
`,
|
|
564
|
-
`,
|
|
565
|
-
`,
|
|
566
|
-
`,
|
|
567
|
-
`,
|
|
568
|
-
`)}}}c++}else break}for(;c<t.length;)a.push(t[c]),c++;if(o)return
|
|
569
|
-
`)};if(a.length===0){if(s||
|
|
548
|
+
`)}if(r.length>1&&(r[0]==="-"||r[0]==="+")&&r[1]!=="-"){let n=r[0]==="-";for(let i=1;i<r.length;i++){let o=r[i];if(!Cn.has(o)){let a=`bash: set: ${r[0]}${o}: invalid option
|
|
549
|
+
${Jt}`;if(e.state.options.posix)throw new Ae(1,w(),N(a));return C(a)}xn(e,Cn.get(o)??null,n)}s++;continue}if(r==="--")return rr(e,t.slice(s+1)),j();if(r==="-"){if(e.state.options.xtrace=!1,e.state.options.verbose=!1,Qe(e),s+1<t.length)return rr(e,t.slice(s+1)),j();s++;continue}if(r==="+"){s++;continue}if(r.startsWith("-")||r.startsWith("+")){let n=`bash: set: ${r}: invalid option
|
|
550
|
+
${Jt}`;if(e.state.options.posix)throw new Ae(1,w(),N(n));return C(n)}return rr(e,t.slice(s)),j()}return j()}function rr(e,t){let s=1;for(;e.state.env.has(String(s));)e.state.env.delete(String(s)),s++;for(let r=0;r<t.length;r++)g(e.state.env,String(r+1),t[r]);g(e.state.env,"#",String(t.length)),g(e.state.env,"@",t.join(" ")),g(e.state.env,"*",t.join(" "))}function ir(e,t){let s=1;if(t.length>0){let o=Number.parseInt(t[0],10);if(Number.isNaN(o)||o<0){let a=`bash: shift: ${t[0]}: numeric argument required
|
|
551
|
+
`;if(e.state.options.posix)throw new Ae(1,w(),N(a));return C(a)}s=o}let r=Number.parseInt(T(e.state.env,"#","0"),10);if(s>r){let o=`bash: shift: shift count out of range
|
|
552
|
+
`;if(e.state.options.posix)throw new Ae(1,w(),N(o));return C(o)}if(s===0)return j();let n=[];for(let o=1;o<=r;o++)n.push(T(e.state.env,String(o))||"");let i=n.slice(s);for(let o=1;o<=r;o++)e.state.env.delete(String(o));for(let o=0;o<i.length;o++)g(e.state.env,String(o+1),i[o]);return g(e.state.env,"#",String(i.length)),g(e.state.env,"@",i.join(" ")),j()}async function or(e,t){let s=t;if(s.length>0&&s[0]==="--"&&(s=s.slice(1)),s.length===0)return R(M,B(`bash: source: filename argument required
|
|
553
|
+
`),2);let r=s[0],n=null,i=null;if(r.includes("/")){let u=e.fs.resolvePath(e.state.cwd,r);try{i=await e.fs.readFileText(u),n=u}catch{}}else{let l=T(e.state.env,"PATH","").split(":").filter(f=>f);for(let f of l){let h=e.fs.resolvePath(e.state.cwd,`${f}/${r}`);try{if((await e.fs.stat(h)).isDirectory)continue;i=await e.fs.readFileText(h),n=h;break}catch{}}if(i===null){let f=e.fs.resolvePath(e.state.cwd,r);try{i=await e.fs.readFileText(f),n=f}catch{}}}if(i===null)return C(`bash: ${r}: No such file or directory
|
|
554
|
+
`);let o=new Map;if(s.length>1){for(let l=1;l<=9;l++)o.set(String(l),T(e.state.env,String(l)));o.set("#",T(e.state.env,"#")),o.set("@",T(e.state.env,"@"));let u=s.slice(1);g(e.state.env,"#",String(u.length)),g(e.state.env,"@",u.join(" "));for(let l=0;l<u.length&&l<9;l++)g(e.state.env,String(l+1),u[l]);for(let l=u.length+1;l<=9;l++)e.state.env.delete(String(l))}let a=e.state.currentSource,c=()=>{if(e.state.sourceDepth--,e.state.currentSource=a,s.length>1)for(let[u,l]of o)l===void 0?e.state.env.delete(u):g(e.state.env,u,l)};e.state.sourceDepth++,e.state.currentSource=r;try{let u=xe(i),l=await e.executeScript(u);return c(),l}catch(u){if(c(),u instanceof Z)throw u;if(u instanceof pe)return R(u.stdout,u.stderr,u.exitCode);if(u.name==="ParseException")return C(`bash: ${r}: ${u.message}
|
|
555
|
+
`);throw u}}function Tn(e){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)}function Ao(e){return e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"')}async function On(e,t){if(Ao(t))return null;try{let s=new G,r=se(s,t);return await X(e,r.expression)}catch{let s=parseInt(t,10);return Number.isNaN(s)?0:s}}function Dn(e,t){if(e.state.localVarStack?.has(t)){let r=qt(e,t);if(r){r.value===void 0?e.state.env.delete(t):e.state.env.set(t,r.value);let n=e.state.localVarStack?.get(t);if(!n||n.length===0)Gt(e,t),e.state.localVarStack?.delete(t),e.state.fullyUnsetLocals=e.state.fullyUnsetLocals||new Map,e.state.fullyUnsetLocals.set(t,r.scopeIndex),ar(e,t);else{let i=n[n.length-1];e.state.localVarDepth=e.state.localVarDepth||new Map,e.state.localVarDepth.set(t,i.scopeIndex+1)}return!0}return e.state.env.delete(t),Gt(e,t),e.state.localVarStack?.delete(t),e.state.fullyUnsetLocals=e.state.fullyUnsetLocals||new Map,e.state.fullyUnsetLocals.set(t,0),!0}for(let r=e.state.localScopes.length-1;r>=0;r--){let n=e.state.localScopes[r];if(n.has(t)){let i=n.get(t);i===void 0?e.state.env.delete(t):e.state.env.set(t,i),n.delete(t);let o=!1;for(let a=r-1;a>=0;a--)if(e.state.localScopes[a].has(t)){e.state.localVarDepth&&e.state.localVarDepth.set(t,a+1),o=!0;break}return o||Gt(e,t),!0}}return!1}function ar(e,t){if(!e.state.tempEnvBindings||e.state.tempEnvBindings.length===0)return!1;for(let s=e.state.tempEnvBindings.length-1;s>=0;s--){let r=e.state.tempEnvBindings[s];if(r.has(t)){let n=r.get(t);return n===void 0?e.state.env.delete(t):e.state.env.set(t,n),r.delete(t),!0}}return!1}async function In(e,t){if(t.startsWith("'")&&t.endsWith("'"))return t.slice(1,-1);if(t.startsWith('"')&&t.endsWith('"')){let s=t.slice(1,-1),n=new G().parseWordFromString(s,!0,!1);return V(e,n)}if(t.includes("$")){let r=new G().parseWordFromString(t,!1,!1);return V(e,r)}return t}async function lr(e,t){let s="both",r="",n=0;for(let i of t){if(i==="-v"){s="variable";continue}if(i==="-f"){s="function";continue}if(s==="function"){e.state.functions.delete(i);continue}if(s==="variable"){let u=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(u){let h=u[1],d=u[2];if(d==="@"||d==="*"){let _=ke(e,h);for(let[b]of _)e.state.env.delete(`${h}_${b}`);e.state.env.delete(h);continue}let m=e.state.associativeArrays?.has(h);if(m){let _=await In(e,d);e.state.env.delete(`${h}_${_}`);continue}let p=hs(e,h),v=e.state.declaredVars?.has(h);if((e.state.env.has(h)||v)&&!p&&!m){r+=`bash: unset: ${h}: not an array variable
|
|
556
|
+
`,n=1;continue}let E=await On(e,d);if(E===null&&p){r+=`bash: unset: ${d}: not a valid identifier
|
|
557
|
+
`,n=1;continue}if(E===null)continue;if(E<0){let _=ke(e,h),b=_.length,k=e.state.currentLine;if(b===0){r+=`bash: line ${k}: unset: [${E}]: bad array subscript
|
|
558
|
+
`,n=1;continue}let L=b+E;if(L<0){r+=`bash: line ${k}: unset: [${E}]: bad array subscript
|
|
559
|
+
`,n=1;continue}let $=_[L][0];e.state.env.delete(`${h}_${$}`);continue}e.state.env.delete(`${h}_${E}`);continue}if(!Tn(i)){r+=`bash: unset: \`${i}': not a valid identifier
|
|
560
|
+
`,n=1;continue}let l=i;if(me(e,i)){let h=Oe(e,i);h&&h!==i&&(l=h)}if(He(e,l)){r+=`bash: unset: ${l}: cannot unset: readonly variable
|
|
561
|
+
`,n=1;continue}let f=tt(e,l);if(f!==void 0&&f!==e.state.callDepth)Dn(e,l);else if(e.state.fullyUnsetLocals?.has(l))e.state.env.delete(l);else if(f!==void 0){let h=e.state.accessedTempEnvVars?.has(l),d=e.state.mutatedTempEnvVars?.has(l);if((h||d)&&e.state.localVarStack?.has(l)){let m=qt(e,l);m?m.value===void 0?e.state.env.delete(l):e.state.env.set(l,m.value):e.state.env.delete(l)}else e.state.env.delete(l)}else ar(e,l)||e.state.env.delete(l);e.state.exportedVars?.delete(l);continue}let o=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(o){let u=o[1],l=o[2];if(l==="@"||l==="*"){let p=ke(e,u);for(let[v]of p)e.state.env.delete(`${u}_${v}`);e.state.env.delete(u);continue}let f=e.state.associativeArrays?.has(u);if(f){let p=await In(e,l);e.state.env.delete(`${u}_${p}`);continue}let h=hs(e,u);if(e.state.env.has(u)&&!h&&!f){r+=`bash: unset: ${u}: not an array variable
|
|
562
|
+
`,n=1;continue}let m=await On(e,l);if(m===null&&h){r+=`bash: unset: ${l}: not a valid identifier
|
|
563
|
+
`,n=1;continue}if(m===null)continue;if(m<0){let p=ke(e,u),v=p.length,y=e.state.currentLine;if(v===0){r+=`bash: line ${y}: unset: [${m}]: bad array subscript
|
|
564
|
+
`,n=1;continue}let E=v+m;if(E<0){r+=`bash: line ${y}: unset: [${m}]: bad array subscript
|
|
565
|
+
`,n=1;continue}let _=p[E][0];e.state.env.delete(`${u}_${_}`);continue}e.state.env.delete(`${u}_${m}`);continue}if(!Tn(i)){r+=`bash: unset: \`${i}': not a valid identifier
|
|
566
|
+
`,n=1;continue}let a=i;if(me(e,i)){let u=Oe(e,i);u&&u!==i&&(a=u)}if(He(e,a)){r+=`bash: unset: ${a}: cannot unset: readonly variable
|
|
567
|
+
`,n=1;continue}let c=tt(e,a);if(c!==void 0&&c!==e.state.callDepth)Dn(e,a);else if(e.state.fullyUnsetLocals?.has(a))e.state.env.delete(a);else if(c!==void 0){let u=e.state.accessedTempEnvVars?.has(a),l=e.state.mutatedTempEnvVars?.has(a);if((u||l)&&e.state.localVarStack?.has(a)){let f=qt(e,a);f?f.value===void 0?e.state.env.delete(a):e.state.env.set(a,f.value):e.state.env.delete(a)}else e.state.env.delete(a)}else ar(e,a)||e.state.env.delete(a);e.state.exportedVars?.delete(a),e.state.functions.delete(i)}return R(M,B(r),n)}var cr=["extglob","dotglob","nullglob","failglob","globstar","globskipdots","nocaseglob","nocasematch","expand_aliases","lastpipe","xpg_echo"],_o=["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 es(e){return cr.includes(e)}function Co(e){return _o.includes(e)}function Rn(e,t){let s=!1,r=!1,n=!1,i=!1,o=!1,a=[],c=0;for(;c<t.length;){let h=t[c];if(h==="--"){c++;break}if(h.startsWith("-")&&h.length>1){for(let d=1;d<h.length;d++){let m=h[d];switch(m){case"s":s=!0;break;case"u":r=!0;break;case"p":n=!0;break;case"q":i=!0;break;case"o":o=!0;break;default:return{exitCode:2,stdout:w(),stderr:N(`shopt: -${m}: invalid option
|
|
568
|
+
`)}}}c++}else break}for(;c<t.length;)a.push(t[c]),c++;if(o)return ko(e,a,s,r,n,i);if(s&&r)return{exitCode:1,stdout:w(),stderr:N(`shopt: cannot set and unset shell options simultaneously
|
|
569
|
+
`)};if(a.length===0){if(s||r){let d=[];for(let m of cr){let p=e.state.shoptOptions[m];s&&p?d.push(n?`shopt -s ${m}`:`${m} on`):r&&!p&&d.push(n?`shopt -u ${m}`:`${m} off`)}return{exitCode:0,stdout:d.length>0?N(`${d.join(`
|
|
570
570
|
`)}
|
|
571
|
-
`):
|
|
571
|
+
`):w(),stderr:w()}}let h=[];for(let d of cr){let m=e.state.shoptOptions[d];h.push(n?`shopt ${m?"-s":"-u"} ${d}`:`${d} ${m?"on":"off"}`)}return{exitCode:0,stdout:N(`${h.join(`
|
|
572
572
|
`)}
|
|
573
|
-
`),stderr:
|
|
574
|
-
`,u=!0;continue}if(s)
|
|
573
|
+
`),stderr:w()}}let u=!1,l="",f=[];for(let h of a){if(!es(h)&&!Co(h)){l+=`shopt: ${h}: invalid shell option name
|
|
574
|
+
`,u=!0;continue}if(s)es(h)&&(e.state.shoptOptions[h]=!0,vs(e));else if(r)es(h)&&(e.state.shoptOptions[h]=!1,vs(e));else if(es(h)){let d=e.state.shoptOptions[h];i?d||(u=!0):n?(f.push(`shopt ${d?"-s":"-u"} ${h}`),d||(u=!0)):(f.push(`${h} ${d?"on":"off"}`),d||(u=!0))}else i?u=!0:n?(f.push(`shopt -u ${h}`),u=!0):(f.push(`${h} off`),u=!0)}return{exitCode:u?1:0,stdout:f.length>0?N(`${f.join(`
|
|
575
575
|
`)}
|
|
576
|
-
`):
|
|
576
|
+
`):w(),stderr:N(l)}}function ko(e,t,s,r,n,i){let o=new Map([["errexit","errexit"],["pipefail","pipefail"],["nounset","nounset"],["xtrace","xtrace"],["verbose","verbose"],["posix","posix"],["allexport","allexport"],["noclobber","noclobber"],["noglob","noglob"],["noexec","noexec"],["vi","vi"],["emacs","emacs"]]),a=["braceexpand","errtrace","functrace","hashall","histexpand","history","ignoreeof","interactive-comments","keyword","monitor","nolog","notify","onecmd","physical","privileged"],c=[...o.keys(),...a].sort();if(t.length===0){let h=[];for(let d of c){let m=a.includes(d),p=o.get(d),v=m||!p?!1:e.state.options[p];s&&!v||r&&v||h.push(n?`set ${v?"-o":"+o"} ${d}`:`${d} ${v?"on":"off"}`)}return{exitCode:0,stdout:h.length>0?N(`${h.join(`
|
|
577
577
|
`)}
|
|
578
|
-
`):
|
|
579
|
-
`,u=!0;continue}if(
|
|
578
|
+
`):w(),stderr:w()}}let u=!1,l="",f=[];for(let h of t){let d=o.has(h),m=a.includes(h);if(!d&&!m){l+=`shopt: ${h}: invalid option name
|
|
579
|
+
`,u=!0;continue}if(m){s||r||(i?u=!0:n?(f.push(`set +o ${h}`),u=!0):(f.push(`${h} off`),u=!0));continue}let p=o.get(h);if(p)if(s)p==="vi"?e.state.options.emacs=!1:p==="emacs"&&(e.state.options.vi=!1),e.state.options[p]=!0,Qe(e);else if(r)e.state.options[p]=!1,Qe(e);else{let v=e.state.options[p];i?v||(u=!0):n?(f.push(`set ${v?"-o":"+o"} ${h}`),v||(u=!0)):(f.push(`${h} ${v?"on":"off"}`),v||(u=!0))}}return{exitCode:u?1:0,stdout:f.length>0?N(`${f.join(`
|
|
580
580
|
`)}
|
|
581
|
-
`):
|
|
582
|
-
`;
|
|
583
|
-
`,
|
|
584
|
-
`;else{let
|
|
585
|
-
`;l
|
|
586
|
-
`:l+=`${
|
|
587
|
-
`),
|
|
588
|
-
`:l+=`${
|
|
589
|
-
`),
|
|
590
|
-
`;else{let
|
|
591
|
-
`;l
|
|
592
|
-
`:l+=`${
|
|
593
|
-
`),
|
|
594
|
-
`:
|
|
595
|
-
`:l+=`${
|
|
596
|
-
`,
|
|
597
|
-
`:
|
|
598
|
-
`:l+=`${
|
|
599
|
-
`,
|
|
600
|
-
`)}}}return i?
|
|
581
|
+
`):w(),stderr:N(l)}}async function Ln(e,t,s){if(t.includes("/")){let o=e.fs.resolvePath(e.state.cwd,t);if(!await e.fs.exists(o))return{error:"not_found",path:o};let a=o.split("/").pop()||t,c=e.commands.get(a);try{let u=await e.fs.stat(o);return u.isDirectory?{error:"permission_denied",path:o}:c?{cmd:c,path:o}:(u.mode&73)!==0?{script:!0,path:o}:{error:"permission_denied",path:o}}catch{return{error:"not_found",path:o}}}if(!s&&e.state.hashTable){let o=e.state.hashTable.get(t);if(o)if(await e.fs.exists(o)){let a=e.commands.get(t);if(a)return{cmd:a,path:o};try{let c=await e.fs.stat(o);if(!c.isDirectory&&(c.mode&73)!==0)return{script:!0,path:o}}catch{}}else e.state.hashTable.delete(t)}let n=(s??T(e.state.env,"PATH","/usr/bin:/bin")).split(":");for(let o of n){if(!o)continue;let c=`${o.startsWith("/")?o:e.fs.resolvePath(e.state.cwd,o)}/${t}`;if(await e.fs.exists(c))try{let u=await e.fs.stat(c);if(u.isDirectory)continue;let l=(u.mode&73)!==0,f=e.commands.get(t),h=o==="/bin"||o==="/usr/bin";if(f&&h)return{cmd:f,path:c};if(l){if(f&&!h)return{script:!0,path:c};if(!f)return{script:!0,path:c}}}catch{}}if(!await e.fs.exists("/usr/bin")){let o=e.commands.get(t);if(o)return{cmd:o,path:`/usr/bin/${t}`}}return null}async function ts(e,t){let s=[];if(t.includes("/")){let i=e.fs.resolvePath(e.state.cwd,t);if(await e.fs.exists(i))try{let o=await e.fs.stat(i);o.isDirectory||(o.mode&73)!==0&&s.push(t)}catch{}return s}let n=T(e.state.env,"PATH","/usr/bin:/bin").split(":");for(let i of n){if(!i)continue;let a=`${i.startsWith("/")?i:e.fs.resolvePath(e.state.cwd,i)}/${t}`;if(await e.fs.exists(a)){try{if((await e.fs.stat(a)).isDirectory)continue}catch{continue}s.push(i.startsWith("/")?a:`${i}/${t}`)}}return s}async function zn(e,t,s,r){let n=!1,i=!1,o=!1,a=!1,c=!1,u=[];for(let p of t)if(p.startsWith("-")&&p.length>1)for(let v of p.slice(1))v==="t"?n=!0:v==="p"?i=!0:v==="P"?o=!0:v==="a"?a=!0:v==="f"&&(c=!0);else u.push(p);let l="",f="",h=0,d=!1,m=!1;for(let p of u){let v=!1;if(o){if(a){let L=await r(p);if(L.length>0){for(let $ of L)l+=`${$}
|
|
582
|
+
`;d=!0,v=!0}}else{let L=await s(p);L&&(l+=`${L}
|
|
583
|
+
`,d=!0,v=!0)}v||(m=!0);continue}let y=!c&&e.state.functions.has(p);if(a&&y){if(!i)if(n)l+=`function
|
|
584
|
+
`;else{let L=e.state.functions.get(p),$=L?Mn(p,L):`${p} is a function
|
|
585
|
+
`;l+=$}v=!0}let E=e.state.env.get(`BASH_ALIAS_${p}`);if(E!==void 0&&(a||!v)&&(i||(n?l+=`alias
|
|
586
|
+
`:l+=`${p} is aliased to \`${H(E)}'
|
|
587
|
+
`),v=!0,!a)||ks.has(p)&&(a||!v)&&(i||(n?l+=`keyword
|
|
588
|
+
`:l+=`${p} is a shell keyword
|
|
589
|
+
`),v=!0,!a))continue;if(!a&&y&&!v){if(!i)if(n)l+=`function
|
|
590
|
+
`;else{let L=e.state.functions.get(p),$=L?Mn(p,L):`${p} is a function
|
|
591
|
+
`;l+=$}v=!0;continue}if(!(st.has(p)&&(a||!v)&&(i||(n?l+=`builtin
|
|
592
|
+
`:l+=`${p} is a shell builtin
|
|
593
|
+
`),v=!0,!a))){if(a){let L=await r(p);for(let $ of L)i?l+=`${$}
|
|
594
|
+
`:n?l+=`file
|
|
595
|
+
`:l+=`${p} is ${$}
|
|
596
|
+
`,d=!0,v=!0}else if(!v){let L=await s(p);L&&(i?l+=`${L}
|
|
597
|
+
`:n?l+=`file
|
|
598
|
+
`:l+=`${p} is ${L}
|
|
599
|
+
`,d=!0,v=!0)}if(!v&&(m=!0,!n&&!i)){let L=!0;if(p.includes("/")){let $=e.fs.resolvePath(e.state.cwd,p);await e.fs.exists($)&&(L=!1)}L&&(f+=`bash: type: ${p}: not found
|
|
600
|
+
`)}}}return i?h=m&&!d?1:0:h=m?1:0,R(B(l),B(f),h)}function Mn(e,t){let s;return t.body.type==="Group"?s=t.body.body.map(n=>yt(n)).join("; "):s=yt(t.body),`${e} is a function
|
|
601
601
|
${e} ()
|
|
602
602
|
{
|
|
603
603
|
${s}
|
|
604
604
|
}
|
|
605
|
-
`}function
|
|
606
|
-
`:
|
|
607
|
-
`;else if(
|
|
608
|
-
`:
|
|
609
|
-
`;else if(
|
|
610
|
-
`:
|
|
611
|
-
`;else if(e.state.functions.has(a))n
|
|
612
|
-
`:
|
|
613
|
-
`;else if(a.includes("/")){let u=e.fs.resolvePath(e.state.cwd,a),l=!1;if(await e.fs.exists(u))try{let f=await e.fs.stat(u);f.isDirectory||(f.mode&73)!==0&&(n
|
|
614
|
-
`:
|
|
615
|
-
`,l=!0)}catch{}l||(
|
|
616
|
-
`),o=1)}else if(e.commands.has(a)){let l=
|
|
617
|
-
`:
|
|
618
|
-
`}else
|
|
619
|
-
`),o=1}return
|
|
620
|
-
`);let[,...o]=
|
|
621
|
-
`,127):
|
|
622
|
-
`,127);if("error"in u)return u.error==="permission_denied"?
|
|
623
|
-
`,126):
|
|
624
|
-
`,127);if("script"in u)return t.includes("/")||(i.state.hashTable||(i.state.hashTable=new Map),i.state.hashTable.set(t,u.path)),await a(u.path,s,
|
|
625
|
-
`)}}async function
|
|
626
|
-
`)),exitCode:1}}async function
|
|
627
|
-
`)),exitCode:1}}return{stdout:
|
|
628
|
-
`);let
|
|
629
|
-
`).map(
|
|
630
|
-
`)),
|
|
631
|
-
`);else if(
|
|
632
|
-
`)}let
|
|
633
|
-
`,s||
|
|
634
|
-
`),
|
|
635
|
-
`?c+="\\n":u===" "?c+="\\t":u==="\\"?c+="\\\\":u==="'"?c+="'":u==='"'?c+='"':l<32||l===127?l<256?c+=`\\x${l.toString(16).padStart(2,"0")}`:c+=`\\u${l.toString(16).padStart(4,"0")}`:c+=u}return`$'${c}'`}return o?`"${e.replace(/([\\$`"])/g,"\\$1")}"`:`'${e}'`}async function
|
|
636
|
-
`}async function
|
|
637
|
-
`:""}async function
|
|
605
|
+
`}function yt(e){if(Array.isArray(e))return e.map(t=>yt(t)).join("; ");if(e.type==="Statement"){let t=[];for(let s=0;s<e.pipelines.length;s++){let r=e.pipelines[s];t.push(Po(r)),e.operators[s]&&t.push(e.operators[s])}return t.join(" ")}if(e.type==="SimpleCommand"){let t=e,s=[];t.name&&s.push(Fn(t.name));for(let r of t.args)s.push(Fn(r));return s.join(" ")}return e.type==="Group"?`{ ${e.body.map(r=>yt(r)).join("; ")}; }`:"..."}function Po(e){let t=e.commands.map(s=>yt(s));return(e.negated?"! ":"")+t.join(" | ")}function Fn(e){let t="";for(let s of e.parts)s.type==="Literal"?t+=s.value:s.type==="DoubleQuoted"?t+=`"${s.parts.map(r=>Wn(r)).join("")}"`:s.type==="SingleQuoted"?t+=`'${s.value}'`:t+=Wn(s);return t}function Wn(e){let t=e;return t.type==="Literal"?t.value??"":t.type==="Variable"?`$${t.name}`:""}async function Vn(e,t,s,r){let n="",i="",o=0;for(let a of t){if(!a){o=1;continue}let c=e.state.env.get(`BASH_ALIAS_${a}`);if(c!==void 0)r?n+=`${a} is an alias for "${H(c)}"
|
|
606
|
+
`:n+=`alias ${a}='${H(c)}'
|
|
607
|
+
`;else if(ks.has(a))r?n+=`${a} is a shell keyword
|
|
608
|
+
`:n+=`${a}
|
|
609
|
+
`;else if(st.has(a))r?n+=`${a} is a shell builtin
|
|
610
|
+
`:n+=`${a}
|
|
611
|
+
`;else if(e.state.functions.has(a))r?n+=`${a} is a function
|
|
612
|
+
`:n+=`${a}
|
|
613
|
+
`;else if(a.includes("/")){let u=e.fs.resolvePath(e.state.cwd,a),l=!1;if(await e.fs.exists(u))try{let f=await e.fs.stat(u);f.isDirectory||(f.mode&73)!==0&&(r?n+=`${a} is ${a}
|
|
614
|
+
`:n+=`${a}
|
|
615
|
+
`,l=!0)}catch{}l||(r&&(i+=`${a}: not found
|
|
616
|
+
`),o=1)}else if(e.commands.has(a)){let l=T(e.state.env,"PATH","/usr/bin:/bin").split(":"),f=null;for(let h of l){if(!h)continue;let d=`${h}/${a}`;try{let m=await e.fs.stat(d);if(!m.isDirectory&&(m.mode&73)!==0){f=d;break}}catch{}}f||(f=`/usr/bin/${a}`),r?n+=`${a} is ${f}
|
|
617
|
+
`:n+=`${f}
|
|
618
|
+
`}else r&&(i+=`${a}: not found
|
|
619
|
+
`),o=1}return R(B(n),B(i),o)}async function Bn(e,t){if(t.includes("/")){let n=e.fs.resolvePath(e.state.cwd,t);if(await e.fs.exists(n)){try{let i=await e.fs.stat(n);if(i.isDirectory||!((i.mode&73)!==0))return null}catch{return null}return t}return null}let r=T(e.state.env,"PATH","/usr/bin:/bin").split(":");for(let n of r){if(!n)continue;let o=`${n.startsWith("/")?n:e.fs.resolvePath(e.state.cwd,n)}/${t}`;if(await e.fs.exists(o)){try{if((await e.fs.stat(o)).isDirectory)continue}catch{continue}return`${n}/${t}`}}if(e.commands.has(t)){for(let n of r)if(n==="/usr/bin"||n==="/bin")return`${n}/${t}`;return`/usr/bin/${t}`}return null}async function jn(e,t,s,r,n,i,o,a){let{ctx:c,runCommand:u}=e,l=at(s);if(c.coverage&&st.has(t)&&c.coverage.hit(`bash:builtin:${t}`),t==="export")return Ys(c,l);if(t==="unset")return lr(c,l);if(t==="exit")return Zs(c,l);if(t==="local")return Js(c,l);if(t==="set")return nr(c,l);if(t==="break")return Ss(c,l);if(t==="continue")return Is(c,l);if(t==="return")return sr(c,l);if(t==="eval"&&c.state.options.posix)return Kt(c,l,n);if(t==="shift")return ir(c,l);if(t==="getopts")return Qt(c,l);if(t==="compgen")return xs(c,l);if(t==="complete")return Os(c,l);if(t==="compopt")return Ds(c,l);if(t==="pushd")return await Us(c,l);if(t==="popd")return Gs(c,l);if(t==="dirs")return qs(c,l);if(t==="source"||t===".")return or(c,l);if(t==="read")return await tr(c,l,await Y(n),a);if(t==="mapfile"||t==="readarray")return await er(c,l,await Y(n));if(t==="declare"||t==="typeset")return Bs(c,l);if(t==="readonly")return js(c,l);if(!i){let f=c.state.functions.get(t);if(f)return Yt(c,f,l,n)}if(t==="eval")return Kt(c,l,n);if(t==="cd")return await Es(c,l);if(t===":"||t==="true")return j();if(t==="false")return ee(!1);if(t==="let")return Qs(c,l);if(t==="command")return No(e,l,n);if(t==="builtin")return xo(e,l,n);if(t==="shopt")return Rn(c,l);if(t==="exec"){if(s.length===0)return j();let[f,...h]=s;return u(H(f),h,[],n,!1,!1,-1)}if(t==="wait")return j();if(t==="type")return await zn(c,l,f=>Bn(c,f),f=>ts(c,f));if(t==="hash")return Xs(c,l);if(t==="help")return Ks(c,l);if(t==="["||t==="test"){let f=l;if(t==="["){if(l[l.length-1]!=="]")return C("[: missing `]'\n",2);f=l.slice(0,-1)}return ht(c,f)}return null}async function No(e,t,s){let{ctx:r,runCommand:n}=e;if(t.length===0)return j();let i=!1,o=!1,a=!1,c=t;for(;c.length>0&&c[0].startsWith("-");){let f=c[0];if(f==="--"){c=c.slice(1);break}for(let h of f.slice(1))h==="p"?i=!0:h==="V"?o=!0:h==="v"&&(a=!0);c=c.slice(1)}if(c.length===0)return j();if(a||o)return await Vn(r,c,a,o);let[u,...l]=c;return n(u,l.map(f=>B(f)),[],s,!0,i,-1)}async function xo(e,t,s){let{runCommand:r}=e;if(t.length===0)return j();let n=t;if(n[0]==="--"&&(n=n.slice(1),n.length===0))return j();let i=n[0];if(!st.has(i))return C(`bash: builtin: ${i}: not a shell builtin
|
|
620
|
+
`);let[,...o]=n;return r(i,o.map(a=>B(a)),[],s,!0,!1,-1)}async function Hn(e,t,s,r,n){let{ctx:i,buildExportedEnv:o,executeUserScript:a}=e,u=await Ln(i,t,n?"/usr/bin:/bin":void 0);if(!u)return Kr(t)?C(`bash: ${t}: command not available in browser environments. Exclude '${t}' from your commands or use the Node.js bundle.
|
|
621
|
+
`,127):C(`bash: ${t}: command not found
|
|
622
|
+
`,127);if("error"in u)return u.error==="permission_denied"?C(`bash: ${t}: Permission denied
|
|
623
|
+
`,126):C(`bash: ${t}: No such file or directory
|
|
624
|
+
`,127);if("script"in u)return t.includes("/")||(i.state.hashTable||(i.state.hashTable=new Map),i.state.hashTable.set(t,u.path)),await a(u.path,s,r);let{cmd:l,path:f}=u;t.includes("/")||(i.state.hashTable||(i.state.hashTable=new Map),i.state.hashTable.set(t,f));let h,d=r.getReader(),m=await d.read();d.releaseLock(),m.done||!m.value||m.value.length===0?i.state.groupStdin?h=i.state.groupStdin:h=w():h=D(te(m.value),r);let p=o(),v={fs:i.fs,cwd:i.state.cwd,env:i.state.env,exportedEnv:p,stdin:h,limits:i.limits,exec:i.execFn,fetch:i.fetch,getRegisteredCommands:()=>Array.from(i.commands.keys()),sleep:i.sleep,trace:i.trace,fileDescriptors:i.state.fileDescriptors,xpgEcho:i.state.shoptOptions.xpg_echo,coverage:i.coverage};try{return await l.execute(s,v)}catch(y){if(y instanceof fe)throw y;return C(`${t}: ${_e(y)}
|
|
625
|
+
`)}}async function ur(e,t){let s=e.state.inCondition;e.state.inCondition=!0;let r=w(),n=w(),i=0;try{for(let o of t){let a=await e.executeStatement(o);r=D(r,a.stdout),n=D(n,a.stderr),i=a.exitCode}}finally{e.state.inCondition=s}return{stdout:r,stderr:n,exitCode:i}}function gt(e,t,s,r){if(e instanceof be)return t=D(t,e.stdout),s=D(s,e.stderr),e.levels>1&&r>1?(e.levels--,e.stdout=t,e.stderr=s,{action:"rethrow",stdout:t,stderr:s,error:e}):{action:"break",stdout:t,stderr:s};if(e instanceof Se)return t=D(t,e.stdout),s=D(s,e.stderr),e.levels>1&&r>1?(e.levels--,e.stdout=t,e.stderr=s,{action:"rethrow",stdout:t,stderr:s,error:e}):{action:"continue",stdout:t,stderr:s};if(e instanceof pe||e instanceof $e||e instanceof Z||e instanceof fe)return e.prependOutput(t,s),{action:"rethrow",stdout:t,stderr:s,error:e};let n=_e(e);return{action:"error",stdout:t,stderr:D(s,N(`${n}
|
|
626
|
+
`)),exitCode:1}}async function ss(e,t,s=w(),r=w()){let n=s,i=r,o=0;try{for(let a of t){let c=await e.executeStatement(a);n=D(n,c.stdout),i=D(i,c.stderr),o=c.exitCode}}catch(a){if(Pt(a)||a instanceof $e||a instanceof Z||a instanceof fe||a instanceof Fe)throw a.prependOutput(n,i),a;return{stdout:n,stderr:D(i,N(`${_e(a)}
|
|
627
|
+
`)),exitCode:1}}return{stdout:n,stderr:i,exitCode:o}}async function Un(e,t){let s=w(),r=w();for(let n of t.clauses){let i=await ur(e,n.condition);if(s=D(s,i.stdout),r=D(r,i.stderr),i.exitCode===0)return ss(e,n.body,s,r)}return t.elseBody?ss(e,t.elseBody,s,r):{stdout:s,stderr:r,exitCode:0}}async function Gn(e,t){let s=await Re(e,t.redirections);if(s)return s;let r=[],n=[],i=async(h,d)=>{let m=await Y(d);m.length>0&&h.push(m)},o=()=>he(r),a=()=>he(n),c=0,u=0;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t.variable))return C(`bash: \`${t.variable}': not a valid identifier
|
|
628
|
+
`);let l=[];if(t.words===null)l=T(e.state.env,"@","").split(" ").filter(Boolean);else if(t.words.length===0)l=[];else try{for(let h of t.words){let d=await De(e,h);l.push(...d.values)}}catch(h){if(h instanceof kt)return{stdout:w(),stderr:h.stderr,exitCode:1};throw h}e.state.loopDepth++;try{for(let h of l){u++,u>e.limits.maxLoopIterations&&Ne(`for loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",o(),a()),g(e.state.env,t.variable,h);try{for(let d of t.body){let m=await e.executeStatement(d);await i(r,m.stdout),await i(n,m.stderr),c=m.exitCode}}catch(d){let m=gt(d,o(),a(),e.state.loopDepth);if(r.length=0,n.length=0,m.action==="break"){await i(r,m.stdout),await i(n,m.stderr);break}if(m.action==="continue"){await i(r,m.stdout),await i(n,m.stderr);continue}if(m.action==="error"){let p=R(m.stdout,m.stderr,m.exitCode??1);return K(e,p,t.redirections)}throw m.error}}}finally{e.state.loopDepth--}let f=R(o(),a(),c);return K(e,f,t.redirections)}async function qn(e,t){let s=await Re(e,t.redirections);if(s)return s;let r=t.line;r!==void 0&&(e.state.currentLine=r);let n=[],i=[],o=async(h,d)=>{let m=await Y(d);m.length>0&&h.push(m)},a=()=>he(n),c=()=>he(i),u=0,l=0;t.init&&await X(e,t.init.expression),e.state.loopDepth++;try{for(;l++,l>e.limits.maxLoopIterations&&Ne(`for loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",a(),c()),!(t.condition&&(r!==void 0&&(e.state.currentLine=r),await X(e,t.condition.expression)===0));){try{for(let h of t.body){let d=await e.executeStatement(h);await o(n,d.stdout),await o(i,d.stderr),u=d.exitCode}}catch(h){let d=gt(h,a(),c(),e.state.loopDepth);if(n.length=0,i.length=0,d.action==="break"){await o(n,d.stdout),await o(i,d.stderr);break}if(d.action==="continue"){await o(n,d.stdout),await o(i,d.stderr),t.update&&await X(e,t.update.expression);continue}if(d.action==="error"){let m=R(d.stdout,d.stderr,d.exitCode??1);return K(e,m,t.redirections)}throw d.error}t.update&&await X(e,t.update.expression)}}finally{e.state.loopDepth--}let f=R(a(),c(),u);return K(e,f,t.redirections)}async function Zn(e,t,s=w()){let r=[],n=[],i=async(d,m)=>{let p=await Y(m);p.length>0&&d.push(p)},o=()=>he(r),a=()=>he(n),c=0,u=0,l=s,f=!1;for(let d of t.redirections)if((d.operator==="<<"||d.operator==="<<-")&&d.target.type==="HereDoc"){let m=d.target,p=await V(e,m.content);m.stripTabs&&(p=p.split(`
|
|
629
|
+
`).map(v=>v.replace(/^\t+/,"")).join(`
|
|
630
|
+
`)),l=N(p),f=!0}else if(d.operator==="<<<"&&d.target.type==="Word")l=N(`${await V(e,d.target)}
|
|
631
|
+
`),f=!0;else if(d.operator==="<"&&d.target.type==="Word")try{let m=await V(e,d.target),p=e.fs.resolvePath(e.state.cwd,m);l=await e.fs.readFile(p),f=!0}catch{let m=await V(e,d.target);return C(`bash: ${m}: No such file or directory
|
|
632
|
+
`)}let h=e.state.groupStdin;if(f)e.state.groupStdin=l;else{let d=await Y(s);d.length>0&&(e.state.groupStdin=te(d))}e.state.loopDepth++;try{for(;;){u++,u>e.limits.maxLoopIterations&&Ne(`while loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",o(),a());let d=0,m=!1,p=!1,v=e.state.inCondition;e.state.inCondition=!0;try{for(let y of t.condition){let E=await e.executeStatement(y);await i(r,E.stdout),await i(n,E.stderr),d=E.exitCode}}catch(y){if(y instanceof be){if(await i(r,y.stdout),await i(n,y.stderr),y.levels>1&&e.state.loopDepth>1)throw y.levels--,y.stdout=o(),y.stderr=a(),e.state.inCondition=v,y;m=!0}else if(y instanceof Se){if(await i(r,y.stdout),await i(n,y.stderr),y.levels>1&&e.state.loopDepth>1)throw y.levels--,y.stdout=o(),y.stderr=a(),e.state.inCondition=v,y;p=!0}else throw e.state.inCondition=v,y}finally{e.state.inCondition=v}if(m)break;if(!p){if(d!==0)break;try{for(let y of t.body){let E=await e.executeStatement(y);await i(r,E.stdout),await i(n,E.stderr),c=E.exitCode}}catch(y){let E=gt(y,o(),a(),e.state.loopDepth);if(r.length=0,n.length=0,E.action==="break"){await i(r,E.stdout),await i(n,E.stderr);break}if(E.action==="continue"){await i(r,E.stdout),await i(n,E.stderr);continue}if(E.action==="error")return R(E.stdout,E.stderr,E.exitCode??1);throw E.error}}}}finally{e.state.loopDepth--,e.state.groupStdin=h}return R(o(),a(),c)}async function Yn(e,t){let s=[],r=[],n=async(u,l)=>{let f=await Y(l);f.length>0&&u.push(f)},i=()=>he(s),o=()=>he(r),a=0,c=0;e.state.loopDepth++;try{for(;;){c++,c>e.limits.maxLoopIterations&&Ne(`until loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",i(),o());let u=await ur(e,t.condition);if(await n(s,u.stdout),await n(r,u.stderr),u.exitCode===0)break;try{for(let l of t.body){let f=await e.executeStatement(l);await n(s,f.stdout),await n(r,f.stderr),a=f.exitCode}}catch(l){let f=gt(l,i(),o(),e.state.loopDepth);if(s.length=0,r.length=0,f.action==="break"){await n(s,f.stdout),await n(r,f.stderr);break}if(f.action==="continue"){await n(s,f.stdout),await n(r,f.stderr);continue}if(f.action==="error")return R(f.stdout,f.stderr,f.exitCode??1);throw f.error}}}finally{e.state.loopDepth--}return R(i(),o(),a)}async function Xn(e,t){let s=await Re(e,t.redirections);if(s)return s;let r=w(),n=w(),i=0,o=await V(e,t.word),a=!1;for(let u=0;u<t.items.length;u++){let l=t.items[u],f=a;if(!a)for(let h of l.patterns){let d=await V(e,h);Or(h)&&(d=xr(d));let m=e.state.shoptOptions.nocasematch,p=e.state.shoptOptions.extglob;if(et(o,d,m,p)){f=!0;break}}if(f){let h=await ss(e,l.body,r,n);if(r=h.stdout,n=h.stderr,i=h.exitCode,l.terminator===";;")break;l.terminator===";&"?a=!0:a=!1}else a=!1}let c=R(r,n,i);return K(e,c,t.redirections)}function fr(e,t){if(e.parts.length!==1)return!1;let s=e.parts[0];return s.type!=="Literal"?!1:t.includes(s.value)}function Kn(e){if(!e.startsWith("__rw__:"))return null;let t=e.slice(7),s=t.indexOf(":");if(s===-1)return null;let r=Number.parseInt(t.slice(0,s),10);if(Number.isNaN(r)||r<0)return null;let n=s+1,i=t.slice(n,n+r),o=n+r+1,a=t.slice(o),c=a.indexOf(":");if(c===-1)return null;let u=Number.parseInt(a.slice(0,c),10);if(Number.isNaN(u)||u<0)return null;let l=a.slice(c+1);return{path:i,position:u,content:l}}var Qn="+ ";async function Jn(e){let t=e.state.env.get("PS4");if(t===void 0)return Qn;let s=H(t);if(s==="")return"";try{let n=new G().parseWordFromString(s,!1,!1);return await V(e,n)}catch{return e.state.expansionStderr=`${e.state.expansionStderr||""}bash: ${s}: bad substitution
|
|
633
|
+
`,s||Qn}}function To(e){return e.map(t=>Oo(t)).join(" ")}function Oo(e){if(e==="")return"''";if(!/[\s'"\\$`!*?[\]{}|&;<>()~#\n\t]/.test(e))return e;let s=/[\x00-\x1f\x7f]/.test(e),r=e.includes(`
|
|
634
|
+
`),n=e.includes(" "),i=e.includes("\\"),o=e.includes("'");if(s||r||n||i){let c="";for(let u of e){let l=u.charCodeAt(0);u===`
|
|
635
|
+
`?c+="\\n":u===" "?c+="\\t":u==="\\"?c+="\\\\":u==="'"?c+="'":u==='"'?c+='"':l<32||l===127?l<256?c+=`\\x${l.toString(16).padStart(2,"0")}`:c+=`\\u${l.toString(16).padStart(4,"0")}`:c+=u}return`$'${c}'`}return o?`"${e.replace(/([\\$`"])/g,"\\$1")}"`:`'${e}'`}async function ei(e,t,s){if(!e.state.options.xtrace)return"";let r=await Jn(e),n=[t,...s],i=To(n);return`${r}${i}
|
|
636
|
+
`}async function ti(e,t,s){return e.state.options.xtrace?`${await Jn(e)}${t}=${s}
|
|
637
|
+
`:""}async function si(e,t,s){let r=t.timed?performance.now():0,n=w(),i=j(),o=0,a=[],c=t.commands.length>1,u=e.state.lastArg;for(let f=0;f<t.commands.length;f++){let h=t.commands[f],d=f===t.commands.length-1,m=f===0;c&&(e.state.lastArg=B(""),m||(e.state.groupStdin=void 0));let v=c&&(!d||!e.state.shoptOptions.lastpipe)?new Map(e.state.env):null,y;try{y=await s(h,n)}catch(E){if(E instanceof Ct)y={stdout:E.stdout,stderr:E.stderr,exitCode:1};else if(E instanceof Z&&t.commands.length>1)y={stdout:E.stdout,stderr:E.stderr,exitCode:E.exitCode};else if(E instanceof $e&&t.commands.length>1)y={stdout:E.stdout,stderr:E.stderr,exitCode:E.exitCode};else throw v&&(e.state.env=v),E}v&&(e.state.env=v),a.push(y.exitCode),y.exitCode!==0&&(o=y.exitCode),d?i=y:t.pipeStderr?.[f]??!1?(n=D(y.stderr,y.stdout),i={stdout:w(),stderr:w(),exitCode:y.exitCode}):(n=y.stdout,i={stdout:w(),stderr:y.stderr,exitCode:y.exitCode})}if(t.commands.length>1||t.commands.length===1&&t.commands[0].type==="SimpleCommand"){for(let f of e.state.env.keys())f.startsWith("PIPESTATUS_")&&e.state.env.delete(f);for(let f=0;f<a.length;f++)g(e.state.env,`PIPESTATUS_${f}`,String(a[f]));g(e.state.env,"PIPESTATUS__length",String(a.length))}if(e.state.options.pipefail&&o!==0&&(i={...i,exitCode:o}),t.negated&&(i={...i,exitCode:i.exitCode===0?1:0}),t.timed){let h=(performance.now()-r)/1e3,d=Math.floor(h/60),m=h%60,p;t.timePosix?p=`real ${h.toFixed(2)}
|
|
638
638
|
user 0.00
|
|
639
639
|
sys 0.00
|
|
640
|
-
`:
|
|
641
|
-
real ${`${
|
|
640
|
+
`:p=`
|
|
641
|
+
real ${`${d}m${m.toFixed(3)}s`}
|
|
642
642
|
user 0m0.000s
|
|
643
643
|
sys 0m0.000s
|
|
644
|
-
`,i={...i,stderr:
|
|
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:o};let l=
|
|
649
|
-
`)}}async function
|
|
650
|
-
`)};a=f}}if(
|
|
651
|
-
`;if(i.fatal)throw new
|
|
652
|
-
`)}}if(
|
|
653
|
-
`)}}}return{index:
|
|
654
|
-
`)};if(
|
|
655
|
-
`,{continueToNext:!0,xtraceOutput:a};let
|
|
656
|
-
`)),1);return
|
|
657
|
-
`).map(
|
|
658
|
-
`));let
|
|
659
|
-
`);else if(
|
|
660
|
-
`)}let
|
|
661
|
-
`)),1)}e.state.groupStdin=
|
|
662
|
-
`,127)}if(i.startsWith("#!")){let
|
|
663
|
-
`);
|
|
664
|
-
`);throw
|
|
665
|
-
`)));let
|
|
666
|
-
`).map(
|
|
667
|
-
`)),
|
|
668
|
-
`));continue}if(
|
|
669
|
-
`)}if(
|
|
670
|
-
`,127)}if(
|
|
671
|
-
`)}break}case"<>":{let
|
|
672
|
-
`);return
|
|
673
|
-
`,
|
|
674
|
-
|
|
675
|
-
This is a defense-in-depth measure and indicates a bug in just-bash. Please report this at security@vercel.com`,le=class extends Error{violation;constructor(t,s){super(t+Mo),this.violation=s,this.name="SecurityViolationError"}},he=!mt&&an?new an:null,Fo=1e3,on={enabled:!0,auditMode:!1};function Wo(e){return e===void 0?{...on,enabled:!1}:typeof e=="boolean"?{...on,enabled:e}:{...on,...e}}var Kt=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(Wo(t))),e.instance}static resetInstance(){e.instance&&(e.instance.forceDeactivate(),e.instance=null)}static isInSandboxedContext(){return he?he?.getStore()?.sandboxActive===!0:!1}static getCurrentExecutionId(){if(he)return he?.getStore()?.executionId}updateConfig(t){this.config={...this.config,...t}}activate(){if(mt||!this.config.enabled){let s=Jr();return{run:n=>n(),deactivate:()=>{},executionId:s}}this.refCount++,this.refCount===1&&(this.applyPatches(),this.activationTime=Date.now());let t=Jr();return{run:s=>he.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 mt||this.config.auditMode||!he?!1:he?.getStore()?.sandboxActive===!0}recordViolation(t,s,n){let r={timestamp:Date.now(),type:t,message:n,path:s,stack:new Error().stack,executionId:he?.getStore()?.executionId};if(this.violations.length<Fo&&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,o,a){if(r.shouldBlock()){let c=`${s} is blocked during script execution`,u=r.recordViolation(n,s,c);throw new le(c,u)}return r.config.auditMode&&he?.getStore()?.sandboxActive===!0&&r.recordViolation(n,s,`${s} called (audit mode)`),Reflect.apply(i,o,a)},construct(i,o,a){if(r.shouldBlock()){let c=`${s} constructor is blocked during script execution`,u=r.recordViolation(n,s,c);throw new le(c,u)}return r.config.auditMode&&he?.getStore()?.sandboxActive===!0&&r.recordViolation(n,s,`${s} constructor called (audit mode)`),Reflect.construct(i,o,a)}})}createBlockingObjectProxy(t,s,n){let r=this;return new Proxy(t,{get(i,o,a){if(r.shouldBlock()){let c=`${s}.${String(o)}`,u=`${c} is blocked during script execution`,l=r.recordViolation(n,c,u);throw new le(u,l)}if(r.config.auditMode&&he?.getStore()?.sandboxActive===!0){let c=`${s}.${String(o)}`;r.recordViolation(n,c,`${c} accessed (audit mode)`)}return Reflect.get(i,o,a)},set(i,o,a,c){if(r.shouldBlock()){let u=`${s}.${String(o)}`,l=`${u} modification is blocked during script execution`,f=r.recordViolation(n,u,l);throw new le(l,f)}return Reflect.set(i,o,a,c)},ownKeys(i){if(r.shouldBlock()){let o=`${s} enumeration is blocked during script execution`,a=r.recordViolation(n,s,o);throw new le(o,a)}return Reflect.ownKeys(i)},getOwnPropertyDescriptor(i,o){if(r.shouldBlock()){let a=`${s}.${String(o)}`,c=`${a} descriptor access is blocked during script execution`,u=r.recordViolation(n,a,c);throw new le(c,u)}return Reflect.getOwnPropertyDescriptor(i,o)},has(i,o){if(r.shouldBlock()){let a=`${s}.${String(o)}`,c=`${a} existence check is blocked during script execution`,u=r.recordViolation(n,a,c);throw new le(c,u)}return Reflect.has(i,o)}})}applyPatches(){let t=Qr();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",o=t.recordViolation("error_prepare_stack_trace","Error.prepareStackTrace",i);throw new le(i,o)}t.config.auditMode&&he?.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 o=i?.value;Object.defineProperty(t,"constructor",{get(){if(r.shouldBlock()){let a=`${s} access is blocked during script execution`,c=r.recordViolation(n,s,a);throw new le(a,c)}return r.config.auditMode&&he?.getStore()?.sandboxActive===!0&&r.recordViolation(n,s,`${s} accessed (audit mode)`),o},set(a){if(r.shouldBlock()){let c=`${s} modification is blocked during script execution`,u=r.recordViolation(n,s,c);throw new le(c,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 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 le(r,i)}return t.config.auditMode&&he?.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",o=t.recordViolation("process_main_module","process.mainModule",i);throw new le(i,o)}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(!mt)try{let t=null;if(typeof process<"u"){let o=process.mainModule;o&&typeof o=="object"&&(t=o.constructor)}if(!t&&typeof yt<"u"&&typeof yt.main<"u"&&(t=yt.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 o=s[n];if(o===void 0)return;let a=Object.getOwnPropertyDescriptor(s,n);if(this.originalDescriptors.push({target:s,prop:n,descriptor:a}),i==="freeze")typeof o=="object"&&o!==null&&Object.freeze(o);else{let c=this.getPathForTarget(s,n),u=typeof o=="function"?this.createBlockingProxy(o,c,r):this.createBlockingObjectProxy(o,c,r);Object.defineProperty(s,n,{value:u,writable:!0,configurable:!0})}}catch(o){let a=this.getPathForTarget(s,n);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:n,descriptor:r}=this.originalDescriptors[t];try{r?Object.defineProperty(s,n,r):delete s[n]}catch(i){let o=this.getPathForTarget(s,n);console.debug(`[DefenseInDepthBox] Could not restore ${o}:`,i instanceof Error?i.message:i)}}this.originalDescriptors=[]}};var Xt=class{fs;commands=new Map;useDefaultLayout=!1;limits;secureFetch;sleepFn;traceFn;logger;defenseInDepthConfig;coverageWriter;state;constructor(t={}){let s=t.fs??new nt(t.files);this.fs=s,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",`
|
|
676
|
-
`],["OSTYPE","linux-gnu"],["MACHTYPE","x86_64-pc-linux-gnu"],["HOSTTYPE","x86_64"],["HOSTNAME","localhost"],["PWD",
|
|
644
|
+
`,i={...i,stderr:D(i.stderr,N(p))}}return c&&!e.state.shoptOptions.lastpipe&&(e.state.lastArg=u),i}async function ri(e,t){let s=new Map,r="";for(let n of t.assignments){let i=n.name;if(n.array){let f=await Do(e,t,i,n.array,n.append,s);if(f.error)return{continueToNext:!1,xtraceOutput:r,tempAssignments:s,error:f.error};if(r+=f.xtraceOutput,f.continueToNext)continue}let o=n.value?await Ze(e,n.value):M,a=n.value?H(o):"";if(a.length>e.limits.maxStringLength&&Ne(`word expansion: string length limit exceeded (${e.limits.maxStringLength} bytes)`,"iterations"),i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[\]$/))return{continueToNext:!1,xtraceOutput:r,tempAssignments:s,error:C(`bash: ${i}: bad array subscript
|
|
645
|
+
`)};let u=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(u){let f=await Fo(e,t,u[1],u[2],a,n.append,s);if(f.error)return{continueToNext:!1,xtraceOutput:r,tempAssignments:s,error:f.error};if(f.continueToNext)continue}let l=await zo(e,t,i,a,n.append,s,o);if(l.error)return{continueToNext:!1,xtraceOutput:r,tempAssignments:s,error:l.error};r+=l.xtraceOutput,l.continueToNext}return{continueToNext:!1,xtraceOutput:r,tempAssignments:s}}async function Do(e,t,s,r,n,i){let o="";if(/\[.+\]$/.test(s))return{continueToNext:!1,xtraceOutput:"",error:C(`bash: ${s}: cannot assign list to array member
|
|
646
|
+
`)};if(me(e,s)){let l=Pr(e,s);if(l===void 0||l==="")throw new Z(1,w(),w());let f=Oe(e,s);if(f&&/^[a-zA-Z_][a-zA-Z0-9_]*\[@\]$/.test(f))return{continueToNext:!1,xtraceOutput:"",error:C(`bash: ${s}: cannot assign list to array member
|
|
647
|
+
`)}}if(He(e,s)){if(t.name)return o+=`bash: ${s}: readonly variable
|
|
648
|
+
`,{continueToNext:!0,xtraceOutput:o};let l=ie(e,s);if(l)return{continueToNext:!1,xtraceOutput:"",error:l}}let a=e.state.associativeArrays?.has(s),c=Io(r),u=()=>{let l=`${s}_`;for(let f of e.state.env.keys())f.startsWith(l)&&!f.includes("__")&&e.state.env.delete(f);e.state.env.delete(s)};if(a&&c?await Ro(e,t,s,r,n,u,l=>{o+=l}):c?await Lo(e,s,r,n,u):await Mo(e,s,r,n,u),t.name){i.set(s,e.state.env.get(s));let f=`(${r.map(h=>xt(h)).join(" ")})`;g(e.state.env,s,f)}return{continueToNext:!0,xtraceOutput:o}}function Io(e){return e.some(t=>{if(t.parts.length>=2){let s=t.parts[0],r=t.parts[1];if(s.type!=="Glob"||!s.pattern.startsWith("["))return!1;if(s.pattern==="["&&(r.type==="DoubleQuoted"||r.type==="SingleQuoted")){if(t.parts.length<3)return!1;let n=t.parts[2];return n.type!=="Literal"?!1:n.value.startsWith("]=")||n.value.startsWith("]+=")}return r.type!=="Literal"?!1:r.value.startsWith("]")?r.value.startsWith("]=")||r.value.startsWith("]+="):s.pattern.endsWith("]")?r.value.startsWith("=")||r.value.startsWith("+="):!1}return!1})}async function Ro(e,t,s,r,n,i,o){let a=[];for(let c of r){let u=cs(c);if(u){let{key:l,valueParts:f,append:h}=u,d;f.length>0?d=await V(e,{type:"Word",parts:f}):d="",d=Q(e,d),a.push({type:"keyed",key:l,value:d,append:h})}else{let l=await V(e,c);a.push({type:"invalid",expandedValue:l})}}n||i();for(let c of a)if(c.type==="keyed")if(c.append){let u=T(e.state.env,`${s}_${c.key}`,"");g(e.state.env,`${s}_${c.key}`,u+c.value)}else g(e.state.env,`${s}_${c.key}`,c.value);else{let u=t.line??e.state.currentLine??1;o(`bash: line ${u}: ${s}: ${c.expandedValue}: must use subscript when assigning associative array
|
|
649
|
+
`)}}async function Lo(e,t,s,r,n){let i=[];for(let a of s){let c=cs(a);if(c){let{key:u,valueParts:l,append:f}=c,h;l.length>0?h=await V(e,{type:"Word",parts:l}):h="",h=Q(e,h),i.push({type:"keyed",indexExpr:u,value:h,append:f})}else{let u=await De(e,a);i.push({type:"non-keyed",values:u.values})}}r||n();let o=0;for(let a of i)if(a.type==="keyed"){let c;try{let u=new G,l=se(u,a.indexExpr);c=await X(e,l.expression,!1)}catch{if(/^-?\d+$/.test(a.indexExpr))c=Number.parseInt(a.indexExpr,10);else{let u=T(e.state.env,a.indexExpr);c=u?Number.parseInt(u,10):0,Number.isNaN(c)&&(c=0)}}if(a.append){let u=T(e.state.env,`${t}_${c}`,"");g(e.state.env,`${t}_${c}`,u+a.value)}else g(e.state.env,`${t}_${c}`,a.value);o=c+1}else for(let c of a.values)g(e.state.env,`${t}_${o++}`,c)}async function Mo(e,t,s,r,n){let i=[];for(let a of s){let c=await De(e,a);i.push(...c.values)}let o=0;if(r){let a=ke(e,t);if(a.length>0)o=Math.max(...a.map(([u])=>typeof u=="number"?u:0))+1;else{let c=e.state.env.get(t);c!==void 0&&(e.state.env.set(`${t}_0`,c),e.state.env.delete(t),o=1)}}else n();for(let a=0;a<i.length;a++)g(e.state.env,`${t}_${o+a}`,i[a]);r||g(e.state.env,`${t}__length`,String(i.length))}async function Fo(e,t,s,r,n,i,o){let a=s;if(me(e,s)){let f=Oe(e,s);if(f&&f!==s){if(f.includes("["))return{continueToNext:!1,xtraceOutput:"",error:C(`bash: \`${f}': not a valid identifier
|
|
650
|
+
`)};a=f}}if(He(e,a)){if(t.name)return{continueToNext:!0,xtraceOutput:""};let f=ie(e,a);if(f)return{continueToNext:!1,xtraceOutput:"",error:f}}let c=e.state.associativeArrays?.has(a),u;if(c)u=await ni(e,a,r);else{let f=await Wo(e,a,r);if(f.error)return{continueToNext:!1,xtraceOutput:"",error:f.error};u=`${a}_${f.index}`}let l=i?T(e.state.env,u)+n:n;if(t.name)o.set(u,e.state.env.get(u)),g(e.state.env,u,l);else{let f=tt(e,a);if(f!==void 0&&f===e.state.callDepth&&e.state.localScopes.length>0){let h=e.state.localScopes[e.state.localScopes.length-1];h.has(u)||h.set(u,e.state.env.get(u))}g(e.state.env,u,l)}return{continueToNext:!0,xtraceOutput:""}}async function ni(e,t,s){let r;if(s.startsWith("'")&&s.endsWith("'"))r=s.slice(1,-1);else if(s.startsWith('"')&&s.endsWith('"')){let n=s.slice(1,-1),o=new G().parseWordFromString(n,!0,!1);r=await V(e,o)}else if(s.includes("$")){let i=new G().parseWordFromString(s,!1,!1);r=await V(e,i)}else r=s;return`${t}_${r}`}async function Wo(e,t,s){let r=s;s.startsWith('"')&&s.endsWith('"')&&s.length>=2&&(r=s.slice(1,-1));let n;if(/^-?\d+$/.test(r))n=Number.parseInt(r,10);else{try{let i=new G,o=se(i,r);n=await X(e,o.expression,!1)}catch(i){if(i instanceof je){let c=`bash: line ${e.state.currentLine}: ${s}: ${i.message}
|
|
651
|
+
`;if(i.fatal)throw new Z(1,w(),N(c));return{index:0,error:C(c)}}let o=T(e.state.env,s);n=o?Number.parseInt(o,10):0}Number.isNaN(n)&&(n=0)}if(n<0){let i=ke(e,t);if(i.length===0){let a=e.state.currentLine;return{index:0,error:C(`bash: line ${a}: ${t}[${s}]: bad array subscript
|
|
652
|
+
`)}}if(n=Math.max(...i.map(([a])=>typeof a=="number"?a:0))+1+n,n<0){let a=e.state.currentLine;return{index:0,error:C(`bash: line ${a}: ${t}[${s}]: bad array subscript
|
|
653
|
+
`)}}}return{index:n}}async function zo(e,t,s,r,n,i,o){let a="",c=s,u=null;if(me(e,s)){let p=Nr(e,s,r);if(p===void 0)return{continueToNext:!1,xtraceOutput:"",error:C(`bash: ${s}: circular name reference
|
|
654
|
+
`)};if(p===null)return{continueToNext:!0,xtraceOutput:""};c=p;let v=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);v&&(u={arrayName:v[1],subscriptExpr:v[2]},c=v[1])}if(He(e,c)){if(t.name)return a+=`bash: ${c}: readonly variable
|
|
655
|
+
`,{continueToNext:!0,xtraceOutput:a};let p=ie(e,c);if(p)return{continueToNext:!1,xtraceOutput:"",error:p}}let l,f=!!o&&!n&&!u;if(pt(e,c)){f=!1;try{let p=new G;if(n){let y=`(${T(e.state.env,c,"0")}) + (${r})`,E=se(p,y);l=String(await X(e,E.expression))}else{let v=se(p,r);l=String(await X(e,v.expression))}}catch{l="0"}}else{let{isArray:p}=await import("./chunks/expansion-OPTOOC4Q.js"),v=p(e,c);v&&(f=!1);let y=v?`${c}_0`:c;l=n?T(e.state.env,y)+r:r}let h=nt(e,c,l);h!==l&&(f=!1),l=h,a+=await ti(e,c,l);let d=c;if(u)d=await Vo(e,u);else{let{isArray:p}=await import("./chunks/expansion-OPTOOC4Q.js");p(e,c)&&(d=`${c}_0`,f=!1)}let m=f?()=>e.state.env.set(d,o):()=>g(e.state.env,d,l);return t.name?(i.set(d,e.state.env.get(d)),m()):(m(),e.state.options.allexport&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(c)),e.state.tempEnvBindings?.some(p=>p.has(c))&&(e.state.mutatedTempEnvVars=e.state.mutatedTempEnvVars||new Set,e.state.mutatedTempEnvVars.add(c))),{continueToNext:!1,xtraceOutput:a}}async function Vo(e,t){let{arrayName:s,subscriptExpr:r}=t;if(e.state.associativeArrays?.has(s))return ni(e,s,r);let i;if(/^-?\d+$/.test(r))i=Number.parseInt(r,10);else{try{let o=new G,a=se(o,r);i=await X(e,a.expression,!1)}catch{let o=T(e.state.env,r);i=o?Number.parseInt(o,10):0}Number.isNaN(i)&&(i=0)}if(i<0){let o=ke(e,s);o.length>0&&(i=Math.max(...o.map(c=>c[0]))+1+i)}return`${s}_${i}`}async function ii(e,t,s,r){let n=await Re(e,t.redirections);if(n)return n;let i=new Map(e.state.env),o=e.state.cwd,a={...e.state.options},c=new Map(e.state.functions),u=e.state.localScopes,l=e.state.localVarStack,f=e.state.localVarDepth,h=e.state.fullyUnsetLocals;if(e.state.localScopes=u.map(A=>new Map(A)),l){e.state.localVarStack=new Map;for(let[A,x]of l.entries())e.state.localVarStack.set(A,x.map(P=>({...P})))}f&&(e.state.localVarDepth=new Map(f)),h&&(e.state.fullyUnsetLocals=new Map(h));let d=e.state.loopDepth,m=e.state.parentHasLoopContext;e.state.parentHasLoopContext=d>0,e.state.loopDepth=0;let p=e.state.lastArg,v=e.state.bashPid;e.state.bashPid=e.state.nextVirtualPid++;let y=e.state.groupStdin,E=await Y(s);E.length>0&&(e.state.groupStdin=te(E));let _=w(),b=w(),k=0,L=()=>{e.state.env=i,e.state.cwd=o,e.state.options=a,e.state.functions=c,e.state.localScopes=u,e.state.localVarStack=l,e.state.localVarDepth=f,e.state.fullyUnsetLocals=h,e.state.loopDepth=d,e.state.parentHasLoopContext=m,e.state.groupStdin=y,e.state.bashPid=v,e.state.lastArg=p};try{for(let A of t.body){let x=await r(A);_=D(_,x.stdout),b=D(b,x.stderr),k=x.exitCode}}catch(A){if(L(),A instanceof fe)throw A;if(A instanceof Fe){_=D(_,A.stdout),b=D(b,A.stderr);let P=R(_,b,0);return K(e,P,t.redirections)}if(A instanceof be||A instanceof Se){_=D(_,A.stdout),b=D(b,A.stderr);let P=R(_,b,0);return K(e,P,t.redirections)}if(A instanceof Z){_=D(_,A.stdout),b=D(b,A.stderr);let P=R(_,b,A.exitCode);return K(e,P,t.redirections)}if(A instanceof pe){_=D(_,A.stdout),b=D(b,A.stderr);let P=R(_,b,A.exitCode);return K(e,P,t.redirections)}if(A instanceof $e){let P=R(D(_,A.stdout),D(b,A.stderr),A.exitCode);return K(e,P,t.redirections)}let x=R(_,D(b,N(`${_e(A)}
|
|
656
|
+
`)),1);return K(e,x,t.redirections)}L();let $=R(_,b,k);return K(e,$,t.redirections)}async function oi(e,t,s,r){let n=w(),i=w(),o=0,a=await Zt(e,t.redirections);if(a)return a;let c=await Y(s),u=te(c),l=!1;for(let d of t.redirections)if((d.operator==="<<"||d.operator==="<<-")&&d.target.type==="HereDoc"){let m=d.target,p=await V(e,m.content);m.stripTabs&&(p=p.split(`
|
|
657
|
+
`).map(y=>y.replace(/^\t+/,"")).join(`
|
|
658
|
+
`));let v=d.fd??0;v!==0?(e.state.fileDescriptors||(e.state.fileDescriptors=new Map),e.state.fileDescriptors.set(v,p)):(u=N(p),l=!0)}else if(d.operator==="<<<"&&d.target.type==="Word")u=N(`${await V(e,d.target)}
|
|
659
|
+
`),l=!0;else if(d.operator==="<"&&d.target.type==="Word")try{let m=await V(e,d.target),p=e.fs.resolvePath(e.state.cwd,m);u=await e.fs.readFile(p),l=!0}catch{let m=await V(e,d.target);return C(`bash: ${m}: No such file or directory
|
|
660
|
+
`)}let f=e.state.groupStdin;(l||c.length>0)&&(e.state.groupStdin=u);try{for(let d of t.body){let m=await r(d);n=D(n,m.stdout),i=D(i,m.stderr),o=m.exitCode}}catch(d){if(e.state.groupStdin=f,d instanceof fe)throw d;if(Pt(d)||d instanceof $e||d instanceof Z)throw d.prependOutput(n,i),d;return R(n,D(i,N(`${_e(d)}
|
|
661
|
+
`)),1)}e.state.groupStdin=f;let h=R(n,i,o);return K(e,h,t.redirections)}async function ai(e,t,s,r,n){let i;try{i=await e.fs.readFileText(t)}catch{return C(`bash: ${t}: No such file or directory
|
|
662
|
+
`,127)}if(i.startsWith("#!")){let y=i.indexOf(`
|
|
663
|
+
`);y!==-1&&(i=i.slice(y+1))}let o=new Map(e.state.env),a=e.state.cwd,c={...e.state.options},u=e.state.loopDepth,l=e.state.parentHasLoopContext,f=e.state.lastArg,h=e.state.bashPid,d=e.state.groupStdin,m=e.state.currentSource;e.state.parentHasLoopContext=u>0,e.state.loopDepth=0,e.state.bashPid=e.state.nextVirtualPid++;let p=await Y(r);p.length>0&&(e.state.groupStdin=te(p)),e.state.currentSource=t,g(e.state.env,"0",t),g(e.state.env,"#",String(s.length)),g(e.state.env,"@",s.join(" ")),g(e.state.env,"*",s.join(" "));for(let y=0;y<s.length&&y<9;y++)g(e.state.env,String(y+1),s[y]);for(let y=s.length+1;y<=9;y++)e.state.env.delete(String(y));let v=()=>{e.state.env=o,e.state.cwd=a,e.state.options=c,e.state.loopDepth=u,e.state.parentHasLoopContext=l,e.state.lastArg=f,e.state.bashPid=h,e.state.groupStdin=d,e.state.currentSource=m};try{let E=new G().parse(i),_=await n(E);return v(),_}catch(y){if(v(),y instanceof Z||y instanceof fe)throw y;if(y.name==="ParseException")return C(`bash: ${t}: ${y.message}
|
|
664
|
+
`);throw y}}function Bo(e,t){for(let s of t.parts)switch(s.type){case"Bytes":case"Literal":case"SingleQuoted":case"Escaped":continue;case"DoubleQuoted":for(let r of s.parts)switch(r.type){case"Bytes":case"Literal":case"SingleQuoted":case"Escaped":continue;case"ParameterExpansion":if(r.operation||r.parameter==="@"||r.parameter==="*"||r.parameter.endsWith("[@]")||r.parameter.endsWith("[*]"))return!1;if(me(e,r.parameter)){let n=Oe(e,r.parameter);if(n&&(n.endsWith("[@]")||n.endsWith("[*]")))return!1}continue;case"CommandSubstitution":continue;default:return!1}continue;case"ParameterExpansion":return!1;default:return!1}return t.parts.length>0}var wt=class{ctx;constructor(t,s){this.ctx={state:s,fs:t.fs,commands:t.commands,limits:t.limits,execFn:t.exec,executeScript:this.executeScript.bind(this),executeStatement:this.executeStatement.bind(this),executeCommand:this.executeCommand.bind(this),fetch:t.fetch,sleep:t.sleep,trace:t.trace,coverage:t.coverage}}buildExportedEnv(){let t=this.ctx.state.exportedVars,s=this.ctx.state.tempExportedVars,r=new Set;if(t)for(let i of t)r.add(i);if(s)for(let i of s)r.add(i);if(r.size===0)return Object.create(null);let n=Object.create(null);for(let i of r)this.ctx.state.env.has(i)&&(n[i]=T(this.ctx.state.env,i));return n}async executeScript(t){let s=w(),r=w(),n=0;for(let i of t.statements)try{let o=await this.executeStatement(i);s=D(s,o.stdout),r=D(r,o.stderr),n=o.exitCode,this.ctx.state.lastExitCode=n,g(this.ctx.state.env,"?",String(n))}catch(o){if(o instanceof Z)throw o.prependOutput(s,r),o;if(o instanceof Ae)return s=D(s,o.stdout),r=D(r,o.stderr),n=o.exitCode,this.ctx.state.lastExitCode=n,g(this.ctx.state.env,"?",String(n)),{stdout:s,stderr:r,exitCode:n,env:We(this.ctx.state.env)};if(o instanceof fe)throw o;if(o instanceof $e)return s=D(s,o.stdout),r=D(r,o.stderr),n=o.exitCode,this.ctx.state.lastExitCode=n,g(this.ctx.state.env,"?",String(n)),{stdout:s,stderr:r,exitCode:n,env:We(this.ctx.state.env)};if(o instanceof wr)return s=D(s,o.stdout),r=D(r,o.stderr),n=1,this.ctx.state.lastExitCode=n,g(this.ctx.state.env,"?",String(n)),{stdout:s,stderr:r,exitCode:n,env:We(this.ctx.state.env)};if(o instanceof Ct)return s=D(s,o.stdout),r=D(r,o.stderr),n=1,this.ctx.state.lastExitCode=n,g(this.ctx.state.env,"?",String(n)),{stdout:s,stderr:r,exitCode:n,env:We(this.ctx.state.env)};if(o instanceof je){s=D(s,o.stdout),r=D(r,o.stderr),n=1,this.ctx.state.lastExitCode=n,g(this.ctx.state.env,"?",String(n));continue}if(o instanceof vr){s=D(s,o.stdout),r=D(r,o.stderr),n=1,this.ctx.state.lastExitCode=n,g(this.ctx.state.env,"?",String(n));continue}if(o instanceof be||o instanceof Se){if(this.ctx.state.loopDepth>0)throw o.prependOutput(s,r),o;s=D(s,o.stdout),r=D(r,o.stderr);continue}throw o instanceof pe&&o.prependOutput(s,r),o}return{stdout:s,stderr:r,exitCode:n,env:We(this.ctx.state.env)}}async executeUserScript(t,s,r=w()){return ai(this.ctx,t,at(s),r,n=>this.executeScript(n))}async executeStatement(t){if(this.ctx.state.commandCount++,this.ctx.state.commandCount>this.ctx.limits.maxCommandCount&&Ne(`too many commands executed (>${this.ctx.limits.maxCommandCount}), increase executionLimits.maxCommandCount`,"commands"),t.deferredError)throw new Nt(t.deferredError.message,t.line??1,1);if(this.ctx.state.options.noexec)return j();this.ctx.state.errexitSafe=!1;let s=w(),r=w();this.ctx.state.options.verbose&&!this.ctx.state.suppressVerbose&&t.sourceText&&(r=D(r,N(`${t.sourceText}
|
|
665
|
+
`)));let n=0,i=-1,o=!1;for(let u=0;u<t.pipelines.length;u++){let l=t.pipelines[u],f=u>0?t.operators[u-1]:null;if(f==="&&"&&n!==0||f==="||"&&n===0)continue;let h=await this.executePipeline(l);s=D(s,h.stdout),r=D(r,h.stderr),n=h.exitCode,i=u,o=l.negated,this.ctx.state.lastExitCode=n,g(this.ctx.state.env,"?",String(n))}let a=i<t.pipelines.length-1,c=this.ctx.state.errexitSafe;if(this.ctx.state.errexitSafe=a||o||c,this.ctx.state.options.errexit&&n!==0&&i===t.pipelines.length-1&&!o&&!this.ctx.state.inCondition&&!c)throw new $e(n,s,r);return{stdout:s,stderr:r,exitCode:n}}async executePipeline(t){return si(this.ctx,t,(s,r)=>this.executeCommand(s,r))}async executeCommand(t,s){switch(this.ctx.coverage?.hit(`bash:cmd:${t.type}`),t.type){case"SimpleCommand":return this.executeSimpleCommand(t,s);case"If":return Un(this.ctx,t);case"For":return Gn(this.ctx,t);case"CStyleFor":return qn(this.ctx,t);case"While":return Zn(this.ctx,t,s);case"Until":return Yn(this.ctx,t);case"Case":return Xn(this.ctx,t);case"Subshell":return this.executeSubshell(t,s);case"Group":return this.executeGroup(t,s);case"FunctionDef":return hn(this.ctx,t);case"ArithmeticCommand":return this.executeArithmeticCommand(t);case"ConditionalCommand":return this.executeConditionalCommand(t);default:return j()}}async executeSimpleCommand(t,s){try{return await this.executeSimpleCommandInner(t,s)}catch(r){if(r instanceof kt)return{stdout:w(),stderr:r.stderr,exitCode:1};throw r}}async executeSimpleCommandInner(t,s){if(t.line!==void 0&&(this.ctx.state.currentLine=t.line),this.ctx.state.shoptOptions.expand_aliases&&t.name){let $=t,A=100;for(;A>0;){let x=this.expandAlias($);if(x===$)break;$=x,A--}this.aliasExpansionStack.clear(),$!==t&&(t=$)}this.ctx.state.expansionStderr="";let r=await ri(this.ctx,t);if(r.error)return r.error;let n=r.tempAssignments,i=r.xtraceOutput;if(!t.name){if(t.redirections.length>0){let A=await Re(this.ctx,t.redirections);if(A)return A;let x={stdout:w(),stderr:N(i),exitCode:0};return K(this.ctx,x,t.redirections)}this.ctx.state.lastArg=B("");let $=(this.ctx.state.expansionStderr||"")+i;return this.ctx.state.expansionStderr="",{stdout:w(),stderr:N($),exitCode:this.ctx.state.lastExitCode}}let o=t.name&&fr(t.name,["local","declare","typeset","export","readonly"]),a=Array.from(n.keys());if(a.length>0&&!o){this.ctx.state.tempExportedVars=this.ctx.state.tempExportedVars||new Set;for(let $ of a)this.ctx.state.tempExportedVars.add($)}let c=await Zt(this.ctx,t.redirections);if(c){for(let[$,A]of n)A===void 0?this.ctx.state.env.delete($):this.ctx.state.env.set($,A);return c}let u=-1,l=t.redirections.some($=>{if($.operator==="<<"||$.operator==="<<-"||$.operator==="<<<")return!0;let A=$.fd??0;return($.operator==="<"||$.operator==="<&")&&A===0}),f=null,h=M;l?h=await Y(s):f=s;for(let $ of t.redirections){if(($.operator==="<<"||$.operator==="<<-")&&$.target.type==="HereDoc"){let A=$.target,x=$.fd??0;if(x===0&&!A.stripTabs)h=await Ze(this.ctx,A.content);else{let P=await V(this.ctx,A.content);A.stripTabs&&(P=P.split(`
|
|
666
|
+
`).map(W=>W.replace(/^\t+/,"")).join(`
|
|
667
|
+
`)),x!==0?(this.ctx.state.fileDescriptors||(this.ctx.state.fileDescriptors=new Map),this.ctx.state.fileDescriptors.set(x,P)):h=B(P)}continue}if($.operator==="<<<"&&$.target.type==="Word"){let A=await Ze(this.ctx,$.target);h=gr(A,B(`
|
|
668
|
+
`));continue}if($.operator==="<"&&$.target.type==="Word")try{let A=await V(this.ctx,$.target),x=this.ctx.fs.resolvePath(this.ctx.state.cwd,A);h=await Y(await this.ctx.fs.readFile(x))}catch{let A=await V(this.ctx,$.target);for(let[x,P]of n)P===void 0?this.ctx.state.env.delete(x):this.ctx.state.env.set(x,P);return C(`bash: ${A}: No such file or directory
|
|
669
|
+
`)}if($.operator==="<&"&&$.target.type==="Word"){let A=await V(this.ctx,$.target),x=Number.parseInt(A,10);if(!Number.isNaN(x)&&this.ctx.state.fileDescriptors){let P=this.ctx.state.fileDescriptors.get(x);if(P!==void 0)if(P.startsWith("__rw__:")){let W=Kn(P);W&&(h=B(W.content.slice(W.position)),u=x)}else P.startsWith("__file__:")||P.startsWith("__file_append__:")||(h=B(P))}}}let d=await V(this.ctx,t.name),m=[],p=[];if(fr(t.name,["local","declare","typeset","export","readonly"])&&(d==="local"||d==="declare"||d==="typeset"||d==="export"||d==="readonly"))for(let $ of t.args){let A=await Yr(this.ctx,$);if(A)m.push(B(A)),p.push(!0);else{let x=await Xr(this.ctx,$);if(x!==null)m.push(B(x)),p.push(!0);else{let P=await De(this.ctx,$);for(let W of P.values)m.push(B(W)),p.push(P.quoted)}}}else for(let $ of t.args)if(Bo(this.ctx,$))m.push(await Ze(this.ctx,$)),p.push(!0);else{let A=await De(this.ctx,$);for(let x of A.values)m.push(B(x)),p.push(A.quoted)}if(!d){if(t.name.parts.every(A=>A.type==="CommandSubstitution"||A.type==="ParameterExpansion"||A.type==="ArithmeticExpansion")){if(m.length>0){let A=H(m.shift());return p.shift(),await this.runCommand(A,m,p,f??te(h),!1,!1,u)}return{stdout:w(),stderr:w(),exitCode:this.ctx.state.lastExitCode}}return C(`bash: : command not found
|
|
670
|
+
`,127)}if(d==="exec"&&(m.length===0||H(m[0])==="--")){for(let $ of t.redirections){if($.target.type==="HereDoc"||$.fdVariable)continue;let A=await V(this.ctx,$.target),x=$.fd??($.operator==="<"||$.operator==="<>"?0:1);switch(this.ctx.state.fileDescriptors||(this.ctx.state.fileDescriptors=new Map),$.operator){case">":case">|":{let P=this.ctx.fs.resolvePath(this.ctx.state.cwd,A);await this.ctx.fs.writeFile(P,"","utf8"),this.ctx.state.fileDescriptors.set(x,`__file__:${P}`);break}case">>":{let P=this.ctx.fs.resolvePath(this.ctx.state.cwd,A);this.ctx.state.fileDescriptors.set(x,`__file_append__:${P}`);break}case"<":{let P=this.ctx.fs.resolvePath(this.ctx.state.cwd,A);try{let W=await this.ctx.fs.readFileText(P);this.ctx.state.fileDescriptors.set(x,W)}catch{return C(`bash: ${A}: No such file or directory
|
|
671
|
+
`)}break}case"<>":{let P=this.ctx.fs.resolvePath(this.ctx.state.cwd,A);try{let W=await this.ctx.fs.readFileText(P);this.ctx.state.fileDescriptors.set(x,`__rw__:${P.length}:${P}:0:${W}`)}catch{await this.ctx.fs.writeFile(P,"","utf8"),this.ctx.state.fileDescriptors.set(x,`__rw__:${P.length}:${P}:0:`)}break}case">&":{if(A==="-")this.ctx.state.fileDescriptors.delete(x);else if(A.endsWith("-")){let P=A.slice(0,-1),W=Number.parseInt(P,10);if(!Number.isNaN(W)){let I=this.ctx.state.fileDescriptors.get(W);I!==void 0?this.ctx.state.fileDescriptors.set(x,I):this.ctx.state.fileDescriptors.set(x,`__dupout__:${W}`),this.ctx.state.fileDescriptors.delete(W)}}else{let P=Number.parseInt(A,10);Number.isNaN(P)||this.ctx.state.fileDescriptors.set(x,`__dupout__:${P}`)}break}case"<&":{if(A==="-")this.ctx.state.fileDescriptors.delete(x);else if(A.endsWith("-")){let P=A.slice(0,-1),W=Number.parseInt(P,10);if(!Number.isNaN(W)){let I=this.ctx.state.fileDescriptors.get(W);I!==void 0?this.ctx.state.fileDescriptors.set(x,I):this.ctx.state.fileDescriptors.set(x,`__dupin__:${W}`),this.ctx.state.fileDescriptors.delete(W)}}else{let P=Number.parseInt(A,10);Number.isNaN(P)||this.ctx.state.fileDescriptors.set(x,`__dupin__:${P}`)}break}}}for(let[$,A]of n)A===void 0?this.ctx.state.env.delete($):this.ctx.state.env.set($,A);if(this.ctx.state.tempExportedVars)for(let $ of n.keys())this.ctx.state.tempExportedVars.delete($);return j()}let y=await ei(this.ctx,d,m.map($=>H($)));n.size>0&&(this.ctx.state.tempEnvBindings=this.ctx.state.tempEnvBindings||[],this.ctx.state.tempEnvBindings.push(new Map(n)));let E,_=null;try{E=await this.runCommand(d,m,p,f??te(h),!1,!1,u)}catch($){if($ instanceof be||$ instanceof Se)_=$,E=j();else throw $}let b=i+y;if(b&&(E={...E,stderr:D(N(b),E.stderr)}),E=await K(this.ctx,E,t.redirections),_)throw _;if(m.length>0){let $=H(m[m.length-1]);if((d==="declare"||d==="local"||d==="typeset")&&/^[a-zA-Z_][a-zA-Z0-9_]*=\(/.test($)){let A=$.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\(/);A&&($=A[1])}this.ctx.state.lastArg=B($)}else this.ctx.state.lastArg=B(d);let k=fn(d)&&d!=="unset"&&d!=="eval";if(!this.ctx.state.options.posix||!k)for(let[$,A]of n)this.ctx.state.fullyUnsetLocals?.has($)||(A===void 0?this.ctx.state.env.delete($):this.ctx.state.env.set($,A));if(this.ctx.state.tempExportedVars)for(let $ of n.keys())this.ctx.state.tempExportedVars.delete($);return n.size>0&&this.ctx.state.tempEnvBindings&&this.ctx.state.tempEnvBindings.pop(),this.ctx.state.expansionStderr&&(E={...E,stderr:D(N(this.ctx.state.expansionStderr),E.stderr)},this.ctx.state.expansionStderr=""),E}async runCommand(t,s,r,n,i=!1,o=!1,a=-1){let c={ctx:this.ctx,runCommand:(l,f,h,d,m,p,v)=>this.runCommand(l,f,h,d,m,p,v),buildExportedEnv:()=>this.buildExportedEnv(),executeUserScript:(l,f,h)=>this.executeUserScript(l,f,h??w())},u=await jn(c,t,s,r,n,i,o,a);return u!==null?u:Hn(c,t,s,n,o)}aliasExpansionStack=new Set;expandAlias(t){return bs(this.ctx.state,t,this.aliasExpansionStack)}async findCommandInPath(t){return ts(this.ctx,t)}async executeSubshell(t,s=w()){return ii(this.ctx,t,s,r=>this.executeStatement(r))}async executeGroup(t,s=w()){return oi(this.ctx,t,s,r=>this.executeStatement(r))}async executeArithmeticCommand(t){t.line!==void 0&&(this.ctx.state.currentLine=t.line);let s=await Re(this.ctx,t.redirections);if(s)return s;try{let r=await X(this.ctx,t.expression.expression),n=ee(r!==0);return this.ctx.state.expansionStderr&&(n={...n,stderr:D(N(this.ctx.state.expansionStderr),n.stderr)},this.ctx.state.expansionStderr=""),K(this.ctx,n,t.redirections)}catch(r){let n=C(`bash: arithmetic expression: ${r.message}
|
|
672
|
+
`);return K(this.ctx,n,t.redirections)}}async executeConditionalCommand(t){t.line!==void 0&&(this.ctx.state.currentLine=t.line);let s=await Re(this.ctx,t.redirections);if(s)return s;try{let r=await Ve(this.ctx,t.expression),n=ee(r);return this.ctx.state.expansionStderr&&(n={...n,stderr:D(N(this.ctx.state.expansionStderr),n.stderr)},this.ctx.state.expansionStderr=""),K(this.ctx,n,t.redirections)}catch(r){let n=r instanceof je?1:2,i=C(`bash: conditional expression: ${r.message}
|
|
673
|
+
`,n);return K(this.ctx,i,t.redirections)}}};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};function li(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}:{...ge}}function ci(e){try{let t=new URL(e);return{origin:t.origin,pathname:t.pathname,href:t.href}}catch{return null}}function jo(e){let t=ci(e);return t?{origin:t.origin,pathPrefix:t.pathname}:null}function Ho(e,t){let s=ci(e);if(!s)return!1;let r=jo(t);return!r||s.origin!==r.origin?!1:r.pathPrefix==="/"||r.pathPrefix===""?!0:s.pathname.startsWith(r.pathPrefix)}function dr(e,t){return!t||t.length===0?!1:t.some(s=>Ho(e,s))}var vt=class extends Error{constructor(t){super(`Network access denied: URL not in allow-list: ${t}`),this.name="NetworkAccessDeniedError"}},bt=class extends Error{constructor(t){super(`Too many redirects (max: ${t})`),this.name="TooManyRedirectsError"}},St=class extends Error{constructor(t){super(`Redirect target not in allow-list: ${t}`),this.name="RedirectNotAllowedError"}},rs=class extends Error{constructor(t,s){super(`HTTP method '${t}' not allowed. Allowed methods: ${s.join(", ")}`),this.name="MethodNotAllowedError"}},Et=class extends Error{constructor(t){super(`Response body too large (max: ${t} bytes)`),this.name="ResponseTooLargeError"}};var Uo=20,Go=3e4,qo=10485760,Zo=["GET","HEAD"],Yo=new Set(["GET","HEAD","OPTIONS"]),Xo=new Set([301,302,303,307,308]);function hr(e){let t=e.maxRedirects??Uo,s=e.timeoutMs??Go,r=e.maxResponseSize??qo,n=e.dangerouslyAllowFullInternetAccess?["GET","HEAD","POST","PUT","DELETE","PATCH","OPTIONS"]:e.allowedMethods??Zo;function i(c){if(!e.dangerouslyAllowFullInternetAccess&&!dr(c,e.allowedUrlPrefixes??[]))throw new vt(c)}function o(c){if(e.dangerouslyAllowFullInternetAccess)return;let u=c.toUpperCase();if(!n.includes(u))throw new rs(u,n)}async function a(c,u={}){let l=u.method?.toUpperCase()??"GET";i(c),o(l);let f=c,h=0,d=u.followRedirects??!0,m=u.timeoutMs!==void 0?Math.min(u.timeoutMs,s):s;for(;;){let p=new AbortController,v=setTimeout(()=>p.abort(),m);try{let y={method:l,headers:u.headers,signal:p.signal,redirect:"manual"};u.body&&!Yo.has(l)&&(y.body=u.body);let E=await fetch(f,y);if(Xo.has(E.status)&&d){let _=E.headers.get("location");if(!_)return await ui(E,f,r);let b=new URL(_,f).href;if(!e.dangerouslyAllowFullInternetAccess&&!dr(b,e.allowedUrlPrefixes??[]))throw new St(b);if(h++,h>t)throw new bt(t);f=b;continue}return await ui(E,f,r)}finally{clearTimeout(v)}}}return a}async function ui(e,t,s){let r=Object.create(null);if(e.headers.forEach((i,o)=>{r[o.toLowerCase()]=i}),s>0){let i=e.headers.get("content-length");if(i){let o=parseInt(i,10);if(!Number.isNaN(o)&&o>s)throw new Et(s)}}let n;if(s>0&&e.body){let i=e.body.getReader(),o=new TextDecoder,a=[],c=0;for(;;){let{done:u,value:l}=await i.read();if(u)break;if(c+=l.byteLength,c>s)throw i.cancel(),new Et(s);a.push(o.decode(l,{stream:!0}))}a.push(o.decode()),n=a.join("")}else n=await e.text();return{status:e.status,statusText:e.statusText,headers:r,body:n,url:t}}function fi(){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 $t=typeof __BROWSER__<"u"&&__BROWSER__;function di(){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 mr=null;if(!$t)try{let{createRequire:e}=await import("node:module");mr=e(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 Ko=`
|
|
674
|
+
|
|
675
|
+
This is a defense-in-depth measure and indicates a bug in just-bash. Please report this at security@vercel.com`,de=class extends Error{violation;constructor(t,s){super(t+Ko),this.violation=s,this.name="SecurityViolationError"}},we=!$t&&mr?new mr:null,Qo=1e3,pr={enabled:!0,auditMode:!1};function Jo(e){return e===void 0?{...pr,enabled:!1}:typeof e=="boolean"?{...pr,enabled:e}:{...pr,...e}}var ns=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 we?we?.getStore()?.sandboxActive===!0:!1}static getCurrentExecutionId(){if(we)return we?.getStore()?.executionId}updateConfig(t){this.config={...this.config,...t}}activate(){if($t||!this.config.enabled){let s=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=>we.run({sandboxActive:!0,executionId:t},s),deactivate:()=>{this.refCount--,this.refCount===0&&(this.restorePatches(),this.totalActiveTimeMs+=Date.now()-this.activationTime),this.refCount<0&&(this.refCount=0)},executionId:t}}forceDeactivate(){this.refCount>0&&(this.restorePatches(),this.totalActiveTimeMs+=Date.now()-this.activationTime),this.refCount=0}isActive(){return this.refCount>0}getStats(){return{violationsBlocked:this.violations.length,violations:[...this.violations],activeTimeMs:this.totalActiveTimeMs+(this.refCount>0?Date.now()-this.activationTime:0),refCount:this.refCount}}clearViolations(){this.violations=[]}getPathForTarget(t,s){return t===globalThis?`globalThis.${s}`:t===process?`process.${s}`:t===Error?`Error.${s}`:t===Function.prototype?`Function.prototype.${s}`:t===Object.prototype?`Object.prototype.${s}`:`<object>.${s}`}shouldBlock(){return $t||this.config.auditMode||!we?!1:we?.getStore()?.sandboxActive===!0}recordViolation(t,s,r){let n={timestamp:Date.now(),type:t,message:r,path:s,stack:new Error().stack,executionId:we?.getStore()?.executionId};if(this.violations.length<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 c=`${s} is blocked during script execution`,u=n.recordViolation(r,s,c);throw new de(c,u)}return n.config.auditMode&&we?.getStore()?.sandboxActive===!0&&n.recordViolation(r,s,`${s} called (audit mode)`),Reflect.apply(i,o,a)},construct(i,o,a){if(n.shouldBlock()){let c=`${s} constructor is blocked during script execution`,u=n.recordViolation(r,s,c);throw new de(c,u)}return n.config.auditMode&&we?.getStore()?.sandboxActive===!0&&n.recordViolation(r,s,`${s} constructor called (audit mode)`),Reflect.construct(i,o,a)}})}createBlockingObjectProxy(t,s,r){let n=this;return new Proxy(t,{get(i,o,a){if(n.shouldBlock()){let c=`${s}.${String(o)}`,u=`${c} is blocked during script execution`,l=n.recordViolation(r,c,u);throw new de(u,l)}if(n.config.auditMode&&we?.getStore()?.sandboxActive===!0){let c=`${s}.${String(o)}`;n.recordViolation(r,c,`${c} accessed (audit mode)`)}return Reflect.get(i,o,a)},set(i,o,a,c){if(n.shouldBlock()){let u=`${s}.${String(o)}`,l=`${u} modification is blocked during script execution`,f=n.recordViolation(r,u,l);throw new de(l,f)}return Reflect.set(i,o,a,c)},ownKeys(i){if(n.shouldBlock()){let o=`${s} enumeration is blocked during script execution`,a=n.recordViolation(r,s,o);throw new de(o,a)}return Reflect.ownKeys(i)},getOwnPropertyDescriptor(i,o){if(n.shouldBlock()){let a=`${s}.${String(o)}`,c=`${a} descriptor access is blocked during script execution`,u=n.recordViolation(r,a,c);throw new de(c,u)}return Reflect.getOwnPropertyDescriptor(i,o)},has(i,o){if(n.shouldBlock()){let a=`${s}.${String(o)}`,c=`${a} existence check is blocked during script execution`,u=n.recordViolation(r,a,c);throw new de(c,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 de(i,o)}t.config.auditMode&&we?.getStore()?.sandboxActive===!0&&t.recordViolation("error_prepare_stack_trace","Error.prepareStackTrace","Error.prepareStackTrace set (audit mode)"),r=n},configurable:!0})}catch(s){console.debug("[DefenseInDepthBox] Could not protect Error.prepareStackTrace:",s instanceof Error?s.message:s)}}patchPrototypeConstructor(t,s,r){let n=this;try{let i=Object.getOwnPropertyDescriptor(t,"constructor");this.originalDescriptors.push({target:t,prop:"constructor",descriptor:i});let o=i?.value;Object.defineProperty(t,"constructor",{get(){if(n.shouldBlock()){let a=`${s} access is blocked during script execution`,c=n.recordViolation(r,s,a);throw new de(a,c)}return n.config.auditMode&&we?.getStore()?.sandboxActive===!0&&n.recordViolation(r,s,`${s} accessed (audit mode)`),o},set(a){if(n.shouldBlock()){let c=`${s} modification is blocked during script execution`,u=n.recordViolation(r,s,c);throw new de(c,u)}Object.defineProperty(this,"constructor",{value:a,writable:!0,configurable:!0})},configurable:!0})}catch(i){console.debug(`[DefenseInDepthBox] Could not patch ${s}:`,i instanceof Error?i.message:i)}}protectProcessMainModule(){if(typeof process>"u")return;let t=this;try{let s=Object.getOwnPropertyDescriptor(process,"mainModule");this.originalDescriptors.push({target:process,prop:"mainModule",descriptor:s});let r=s?.value;r!==void 0&&Object.defineProperty(process,"mainModule",{get(){if(t.shouldBlock()){let n="process.mainModule access is blocked during script execution",i=t.recordViolation("process_main_module","process.mainModule",n);throw new de(n,i)}return t.config.auditMode&&we?.getStore()?.sandboxActive===!0&&t.recordViolation("process_main_module","process.mainModule","process.mainModule accessed (audit mode)"),r},set(n){if(t.shouldBlock()){let i="process.mainModule modification is blocked during script execution",o=t.recordViolation("process_main_module","process.mainModule",i);throw new de(i,o)}Object.defineProperty(process,"mainModule",{value:n,writable:!0,configurable:!0})},configurable:!0})}catch(s){console.debug("[DefenseInDepthBox] Could not protect process.mainModule:",s instanceof Error?s.message:s)}}protectModuleLoad(){if(!$t)try{let t=null;if(typeof process<"u"){let o=process.mainModule;o&&typeof o=="object"&&(t=o.constructor)}if(!t&&typeof At<"u"&&typeof At.main<"u"&&(t=At.main.constructor),!t||typeof t._load!="function")return;let s=t._load,r=Object.getOwnPropertyDescriptor(t,"_load");this.originalDescriptors.push({target:t,prop:"_load",descriptor:r});let i=this.createBlockingProxy(s,"Module._load","module_load");Object.defineProperty(t,"_load",{value:i,writable:!0,configurable:!0})}catch(t){console.debug("[DefenseInDepthBox] Could not protect Module._load:",t instanceof Error?t.message:t)}}applyPatch(t){let{target:s,prop:r,violationType:n,strategy:i}=t;try{let o=s[r];if(o===void 0)return;let a=Object.getOwnPropertyDescriptor(s,r);if(this.originalDescriptors.push({target:s,prop:r,descriptor:a}),i==="freeze")typeof o=="object"&&o!==null&&Object.freeze(o);else{let c=this.getPathForTarget(s,r),u=typeof o=="function"?this.createBlockingProxy(o,c,n):this.createBlockingObjectProxy(o,c,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 is=class{fs;commands=new Map;useDefaultLayout=!1;limits;secureFetch;sleepFn;traceFn;logger;defenseInDepthConfig;coverageWriter;state;constructor(t={}){let s=t.fs??new ft(t.files);this.fs=s,this.useDefaultLayout=!t.cwd&&!t.files;let r=t.cwd||(this.useDefaultLayout?"/home/user":"/"),n=new Map,i=[["HOME",this.useDefaultLayout?"/home/user":"/"],["PATH","/usr/bin:/bin"],["IFS",`
|
|
676
|
+
`],["OSTYPE","linux-gnu"],["MACHTYPE","x86_64-pc-linux-gnu"],["HOSTTYPE","x86_64"],["HOSTNAME","localhost"],["PWD",r],["OLDPWD",r],["OPTIND","1"]];for(let[o,a]of i)g(n,o,a);for(let[o,a]of Object.entries(t.env??{}))g(n,o,a);if(this.limits=li({...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=hr(t.network)),this.sleepFn=t.sleep,this.traceFn=t.trace,this.logger=t.logger,this.defenseInDepthConfig=t.defenseInDepth,this.coverageWriter=t.coverage,this.state={env:n,cwd:r,previousDir:"/home/user",functions:new Map,localScopes:[],callDepth:0,sourceDepth:0,commandCount:0,lastExitCode:0,lastArg:M,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},g(this.state.env,"SHELLOPTS",gs(this.state.options)),g(this.state.env,"BASHOPTS",ws(this.state.shoptOptions)),jr(s,this.useDefaultLayout),r!=="/"&&s instanceof ft)try{s.mkdirSync(r,{recursive:!0})}catch{}for(let o of Lr(t.commands))this.registerCommand(o);if(t.network)for(let o of Mr())this.registerCommand(o);if(t.python)for(let o of Fr())this.registerCommand(o);if(t.customCommands)for(let o of t.customCommands)Wr(o)?this.registerCommand(zr(o)):this.registerCommand(o)}registerCommand(t){this.commands.set(t.name,t);let s=this.fs;if(typeof s.writeFileSync=="function"){let r=`#!/bin/bash
|
|
677
677
|
# Built-in command: ${t.name}
|
|
678
|
-
`;try{s.writeFileSync(`/bin/${t.name}`,
|
|
679
|
-
`),exitCode:1,env:
|
|
680
|
-
`),exitCode:1,env:
|
|
681
|
-
`),exitCode:2,env:
|
|
682
|
-
`),exitCode:2,env:
|
|
683
|
-
`),exitCode:1,env:
|
|
684
|
-
`),s=[],
|
|
685
|
-
`)}import*as J from"node:fs";import*as Je from"node:path";var zo="/home/user/project";function re(e,t){if(e.includes("\0"))throw new Error(`ENOENT: path contains null byte, ${t} '${e}'`)}var Qt=class{root;mountPoint;readOnly;maxFileReadSize;memory=new Map;deleted=new Set;constructor(t){this.root=Je.resolve(t.root);let s=t.mountPoint??zo;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 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 o of r)i+=`/${o}`,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 i=s instanceof Uint8Array?s:new TextEncoder().encode(s);this.memory.set(n,{type:"file",content:i,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=Je.join(this.root,n),i=Je.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 J.promises.access(n),!0}catch{return!1}}async readFile(t,s){let n=await this.readFileBuffer(t),r=Re(s);return At(n,r)}async readFileBuffer(t,s=new Set){re(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 o=this.resolveSymlink(n,r.target);return this.readFileBuffer(o,s)}if(r.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);return r.content}let i=this.toRealPath(n);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),u=this.resolveSymlink(n,c);return this.readFileBuffer(u,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);return new Uint8Array(a)}catch(o){throw o.code==="ENOENT"?new Error(`ENOENT: no such file or directory, open '${t}'`):o}}async writeFile(t,s,n){re(t,"write"),this.assertWritable(`write '${t}'`);let r=this.normalizePath(t);this.ensureParentDirs(r);let i=Re(n),o=Ge(s,i);this.memory.set(r,{type:"file",content:o,mode:420,mtime:new Date}),this.deleted.delete(r)}async appendFile(t,s,n){re(t,"append"),this.assertWritable(`append '${t}'`);let r=this.normalizePath(t),i=Re(n),o=Ge(s,i),a;try{a=await this.readFileBuffer(r)}catch{a=new Uint8Array(0)}let c=new Uint8Array(a.length+o.length);c.set(a),c.set(o,a.length),this.ensureParentDirs(r),this.memory.set(r,{type:"file",content:c,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){re(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 a=this.resolveSymlink(n,r.target);return this.stat(a,s)}let o=0;return r.type==="file"&&(o=r.content.length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:o,mtime:r.mtime}}let i=this.toRealPath(n);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){re(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.content.length),{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 J.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){re(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 a of this.deleted)if(a.startsWith(i)){let c=a.slice(i.length),u=c.split("/")[0];u&&!c.includes("/",u.length)&&r.add(u)}for(let[a,c]of this.memory)if(a!==s&&a.startsWith(i)){let u=a.slice(i.length),l=u.split("/")[0];l&&!r.has(l)&&!u.includes("/",1)&&n.set(l,{name:l,isFile:c.type==="file",isDirectory:c.type==="directory",isSymbolicLink:c.type==="symlink"})}let o=this.toRealPath(s);if(o)try{let a=await J.promises.readdir(o,{withFileTypes:!0});for(let c of a)!r.has(c.name)&&!n.has(c.name)&&n.set(c.name,{name:c.name,isFile:c.isFile(),isDirectory:c.isDirectory(),isSymbolicLink:c.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 n}async resolveForReaddir(t,s=!1){let n=this.normalizePath(t),r=new Set,i=s,o=this.memory.get(n);for(;o&&o.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,o.target),o=this.memory.get(n)}if(o)return{normalized:n,outsideOverlay:!1};if(this.getRelativeToMount(n)===null)return{normalized:n,outsideOverlay:!0};let c=this.toRealPath(n);if(!c)return{normalized:n,outsideOverlay:!0};try{if((await J.promises.lstat(c)).isSymbolicLink()){let l=await J.promises.readlink(c),f=this.resolveSymlink(n,l);return this.resolveForReaddir(f,!0)}return{normalized:n,outsideOverlay:!1}}catch{return i?{normalized:n,outsideOverlay:!0}:{normalized:n,outsideOverlay:!1}}}async readdir(t){re(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,o)=>i<o?-1:i>o?1:0)}async readdirWithFileTypes(t){re(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,o)=>i.name<o.name?-1:i.name>o.name?1:0)}async rm(t,s){re(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 o=await this.readdir(n);if(o.length>0){if(!s?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${t}'`);for(let a of o){let c=n==="/"?`/${a}`:`${n}/${a}`;await this.rm(c,s)}}}}catch{}this.deleted.add(n),this.memory.delete(n)}async cp(t,s,n){re(t,"cp"),re(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 a=await this.stat(r);if(a.isFile){let c=await this.readFileBuffer(r);await this.writeFile(i,c)}else if(a.isDirectory){if(!n?.recursive)throw new Error(`EISDIR: is a directory, cp '${t}'`);await this.mkdir(i,{recursive:!0});let c=await this.readdir(r);for(let u of c){let l=r==="/"?`/${u}`:`${r}/${u}`,f=i==="/"?`/${u}`:`${i}/${u}`;await this.cp(l,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=J.readdirSync(n);for(let i of r){let o=t==="/"?`/${i}`:`${t}/${i}`;if(this.deleted.has(o))continue;s.add(o);let a=Je.join(n,i);J.statSync(a).isDirectory()&&this.scanRealFs(o,s)}}catch{}}async chmod(t,s){re(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 o=await this.stat(n);if(o.isFile){let a=await this.readFileBuffer(n);this.memory.set(n,{type:"file",content:a,mode:s,mtime:new Date})}else o.isDirectory&&this.memory.set(n,{type:"directory",mode:s,mtime:new Date})}async symlink(t,s){re(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){re(t,"link"),re(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 o=await this.stat(n);if(!o.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 c=await this.readFileBuffer(n);this.ensureParentDirs(r),this.memory.set(r,{type:"file",content:c,mode:o.mode,mtime:new Date}),this.deleted.delete(r)}async readlink(t){re(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 J.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){re(t,"realpath");let s=this.normalizePath(t),n=new Set,r=async a=>{let c=a==="/"?[]:a.slice(1).split("/"),u="";for(let l of c){if(u=`${u}/${l}`,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,h=40;for(;f&&f.type==="symlink"&&d<h;){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>=h)throw new Error(`ELOOP: too many levels of symbolic links, realpath '${t}'`);if(!f){let g=this.toRealPath(u);if(g)try{if((await J.promises.lstat(g)).isSymbolicLink()){let w=await J.promises.readlink(g);return n.add(u),u=this.resolveSymlink(u,w),r(u)}}catch(m){throw m.code==="ENOENT"?new Error(`ENOENT: no such file or directory, realpath '${t}'`):m}}}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){re(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 o=this.memory.get(r);if(o){o.mtime=n;return}let a=await this.stat(r);if(a.isFile){let c=await this.readFileBuffer(r);this.memory.set(r,{type:"file",content:c,mode:a.mode,mtime:n})}else a.isDirectory&&this.memory.set(r,{type:"directory",mode:a.mode,mtime:n})}};var se={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",cyan:"\x1B[36m"},ln=class{env;rl;running=!0;history=[];isInteractive;constructor(t={}){let s=process.cwd(),n=new Qt({root:s,mountPoint:"/"});this.env=new Xt({fs:n,cwd:t.cwd||"/",env:{HOME:"/",USER:"user",SHELL:"/bin/bash",TERM:"xterm-256color",...t.env},network:t.network!==!1?{dangerouslyAllowFullInternetAccess:!0}:void 0}),this.isInteractive=process.stdin.isTTY===!0,this.rl=ti.createInterface({input:process.stdin,output:process.stdout,terminal:this.isInteractive}),this.rl.on("SIGINT",()=>{process.stdout.write(`^C
|
|
678
|
+
`;try{s.writeFileSync(`/bin/${t.name}`,r)}catch{}try{s.writeFileSync(`/usr/bin/${t.name}`,r)}catch{}}}async logResult(t){if(!this.logger)return t;let s=this.logger,[r,n]=as(t.stdout),[i,o]=as(t.stderr),[a,c]=await Promise.all([ct(n),ct(o)]);return a.length>0&&s.debug("stdout",{output:a}),c.length>0&&s.info("stderr",{output:c}),s.info("exit",{exitCode:t.exitCode}),{...t,stdout:r,stderr:i}}async exec(t,s){if(this.state.callDepth===0&&(this.state.commandCount=0),this.state.commandCount++,this.state.commandCount>this.limits.maxCommandCount)return{stdout:w(),stderr:N(`bash: maximum command count (${this.limits.maxCommandCount}) exceeded (possible infinite loop). Increase with executionLimits.maxCommandCount option.
|
|
679
|
+
`),exitCode:1,env:Ce(this.state.env,s?.env)};if(!t.trim())return{stdout:w(),stderr:w(),exitCode:0,env:Ce(this.state.env,s?.env)};this.logger?.info("exec",{command:t});let r=s?.cwd??this.state.cwd,n,i=r;if(s?.cwd)if(s.env&&"PWD"in s.env)n=s.env.PWD;else if(s?.env&&!("PWD"in s.env))try{n=await this.fs.realpath(r),i=n}catch{n=r}else n=r;let o=new Map(this.state.env);if(s?.env)for(let[f,h]of Object.entries(s.env))g(o,f,h);n!==void 0&&g(o,"PWD",n);let a={...this.state,env:o,cwd:i,functions:new Map(this.state.functions),localScopes:[...this.state.localScopes],options:{...this.state.options},hashTable:this.state.hashTable,groupStdin:s?.stdin||void 0},c=t;s?.rawScript||(c=ea(t));let l=(this.defenseInDepthConfig?ns.getInstance(this.defenseInDepthConfig):null)?.activate();try{let f=async()=>{let h=xe(c),d={fs:this.fs,commands:this.commands,limits:this.limits,exec:this.exec.bind(this),fetch:this.secureFetch,sleep:this.sleepFn,trace:this.traceFn,coverage:this.coverageWriter},p=await new wt(d,a).executeScript(h);return this.logResult(p)};return l?await l.run(f):await f()}catch(f){if(f instanceof Z)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:Ce(this.state.env,s?.env)});if(f instanceof Ae)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:Ce(this.state.env,s?.env)});if(f instanceof je)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:1,env:Ce(this.state.env,s?.env)});if(f instanceof fe)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:fe.EXIT_CODE,env:Ce(this.state.env,s?.env)});if(f instanceof de)return this.logResult({stdout:w(),stderr:N(`bash: security violation: ${f.message}
|
|
680
|
+
`),exitCode:1,env:Ce(this.state.env,s?.env)});if(f.name==="ParseException")return this.logResult({stdout:w(),stderr:N(`bash: syntax error: ${f.message}
|
|
681
|
+
`),exitCode:2,env:Ce(this.state.env,s?.env)});if(f instanceof $r)return this.logResult({stdout:w(),stderr:N(`bash: ${f.message}
|
|
682
|
+
`),exitCode:2,env:Ce(this.state.env,s?.env)});if(f instanceof RangeError)return this.logResult({stdout:w(),stderr:N(`bash: ${f.message}
|
|
683
|
+
`),exitCode:1,env:Ce(this.state.env,s?.env)});throw f}finally{l?.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 We(this.state.env)}};function ea(e){let t=e.split(`
|
|
684
|
+
`),s=[],r=[];for(let n=0;n<t.length;n++){let i=t[n];if(r.length>0){let c=r[r.length-1];if((c.stripTabs?i.replace(/^\t+/,""):i)===c.delimiter){s.push(i.trimStart()),r.pop();continue}s.push(i);continue}let o=i.trimStart();s.push(o);let a=/<<(-?)\s*(['"]?)([\w-]+)\2/g;for(let c of o.matchAll(a)){let u=c[1]==="-",l=c[3];r.push({delimiter:l,stripTabs:u})}}return s.join(`
|
|
685
|
+
`)}import*as re from"node:fs";import*as it from"node:path";var ta="/home/user/project";function ce(e,t){if(e.includes("\0"))throw new Error(`ENOENT: path contains null byte, ${t} '${e}'`)}var os=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,!re.existsSync(this.root))throw new Error(`OverlayFs root does not exist: ${this.root}`);if(!re.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 re.promises.access(r),!0}catch{return!1}}async readFile(t){let s=await this.readFileChunks(t);return he(s)}async readFileText(t,s){let r=await this.readFileChunks(t),n=Me(s);return Dt(r,n)}async readFileChunks(t,s=new Set){ce(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 re.promises.lstat(i);if(o.isSymbolicLink()){let l=await re.promises.readlink(i),f=this.resolveSymlink(r,l);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 re.promises.readFile(i),c=new Uint8Array(a.buffer,a.byteOffset,a.byteLength),{chunks:u}=Xe(c);return u}catch(o){throw o.code==="ENOENT"?new Error(`ENOENT: no such file or directory, open '${t}'`):o}}async writeFile(t,s,r){ce(t,"write"),this.assertWritable(`write '${t}'`);let n=this.normalizePath(t);this.ensureParentDirs(n);let i=Me(r),{chunks:o,size:a}=await Ke(s,i);this.memory.set(n,{type:"file",chunks:o,size:a,mode:420,mtime:new Date}),this.deleted.delete(n)}async appendFile(t,s,r){ce(t,"append"),this.assertWritable(`append '${t}'`);let n=this.normalizePath(t),i=Me(r),{chunks:o,size:a}=await Ke(s,i),c=[],u=0;try{c=await this.readFileChunks(n);for(let l of c)u+=l.length}catch{}this.ensureParentDirs(n),this.memory.set(n,{type:"file",chunks:[...c,...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){ce(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 re.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){ce(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 re.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){ce(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 c=a.slice(i.length),u=c.split("/")[0];u&&!c.includes("/",u.length)&&n.add(u)}for(let[a,c]of this.memory)if(a!==s&&a.startsWith(i)){let u=a.slice(i.length),l=u.split("/")[0];l&&!n.has(l)&&!u.includes("/",1)&&r.set(l,{name:l,isFile:c.type==="file",isDirectory:c.type==="directory",isSymbolicLink:c.type==="symlink"})}let o=this.toRealPath(s);if(o)try{let a=await re.promises.readdir(o,{withFileTypes:!0});for(let c of a)!n.has(c.name)&&!r.has(c.name)&&r.set(c.name,{name:c.name,isFile:c.isFile(),isDirectory:c.isDirectory(),isSymbolicLink:c.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 c=this.toRealPath(r);if(!c)return{normalized:r,outsideOverlay:!0};try{if((await re.promises.lstat(c)).isSymbolicLink()){let l=await re.promises.readlink(c),f=this.resolveSymlink(r,l);return this.resolveForReaddir(f,!0)}return{normalized:r,outsideOverlay:!1}}catch{return i?{normalized:r,outsideOverlay:!0}:{normalized:r,outsideOverlay:!1}}}async readdir(t){ce(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){ce(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){ce(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 c=r==="/"?`/${a}`:`${r}/${a}`;await this.rm(c,s)}}}}catch{}this.deleted.add(r),this.memory.delete(r)}async cp(t,s,r){ce(t,"cp"),ce(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 c=await this.readFileChunks(n);await this.writeFile(i,he(c))}else if(a.isDirectory){if(!r?.recursive)throw new Error(`EISDIR: is a directory, cp '${t}'`);await this.mkdir(i,{recursive:!0});let c=await this.readdir(n);for(let u of c){let l=n==="/"?`/${u}`:`${n}/${u}`,f=i==="/"?`/${u}`:`${i}/${u}`;await this.cp(l,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=re.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);re.statSync(a).isDirectory()&&this.scanRealFs(o,s)}}catch{}}async chmod(t,s){ce(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),c=0;for(let u of a)c+=u.length;this.memory.set(r,{type:"file",chunks:a,size:c,mode:s,mtime:new Date})}else o.isDirectory&&this.memory.set(r,{type:"directory",mode:s,mtime:new Date})}async symlink(t,s){ce(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){ce(t,"link"),ce(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 c=await this.readFileChunks(r),u=0;for(let l of c)u+=l.length;this.ensureParentDirs(n),this.memory.set(n,{type:"file",chunks:c,size:u,mode:o.mode,mtime:new Date}),this.deleted.delete(n)}async readlink(t){ce(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 re.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){ce(t,"realpath");let s=this.normalizePath(t),r=new Set,n=async a=>{let c=a==="/"?[]:a.slice(1).split("/"),u="";for(let l of c){if(u=`${u}/${l}`,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 re.promises.lstat(m)).isSymbolicLink()){let v=await re.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){ce(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 c=await this.readFileChunks(n),u=0;for(let l of c)u+=l.length;this.memory.set(n,{type:"file",chunks:c,size:u,mode:a.mode,mtime:r})}else a.isDirectory&&this.memory.set(n,{type:"directory",mode:a.mode,mtime:r})}};var ae={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",cyan:"\x1B[36m"},yr=class{env;rl;running=!0;history=[];isInteractive;constructor(t={}){let s=process.cwd(),r=new os({root:s,mountPoint:"/"});this.env=new is({fs:r,cwd:t.cwd||"/",env:{HOME:"/",USER:"user",SHELL:"/bin/bash",TERM:"xterm-256color",...t.env},network:t.network!==!1?{dangerouslyAllowFullInternetAccess:!0}:void 0}),this.isInteractive=process.stdin.isTTY===!0,this.rl=pi.createInterface({input:process.stdin,output:process.stdout,terminal:this.isInteractive}),this.rl.on("SIGINT",()=>{process.stdout.write(`^C
|
|
686
686
|
`),this.prompt()}),process.stdin.isTTY&&this.rl.on("close",()=>{this.running=!1,console.log(`
|
|
687
|
-
Goodbye!`),process.exit(0)})}syncHistory(){let t=this.env.getEnv();t.BASH_HISTORY=JSON.stringify(this.history)}getPrompt(){let t=this.env.getCwd(),s=this.env.getEnv().HOME||"/home/user",
|
|
688
|
-
${
|
|
687
|
+
Goodbye!`),process.exit(0)})}syncHistory(){let t=this.env.getEnv();t.BASH_HISTORY=JSON.stringify(this.history)}getPrompt(){let t=this.env.getCwd(),s=this.env.getEnv().HOME||"/home/user",r=t;return t===s?r="~":t.startsWith(`${s}/`)&&(r=`~${t.slice(s.length)}`),`${ae.green}${ae.bold}user@virtual${ae.reset}:${ae.blue}${ae.bold}${r}${ae.reset}$ `}async executeCommand(t){let s=t.trim();if(s){if(this.history.push(s),s==="exit"||s.startsWith("exit ")){let r=s.split(/\s+/),n=r[1]?parseInt(r[1],10):0;console.log("exit"),process.exit(n)}this.syncHistory();try{let r=await this.env.exec(s);for await(let i of _t(r.stdout))process.stdout.write(i);let n=await ct(r.stderr);n.length>0&&process.stderr.write(`${ae.red}${n}${ae.reset}`)}catch(r){console.error(`${ae.red}Error: ${_e(r)}${ae.reset}`)}}}printWelcome(){console.log(`
|
|
688
|
+
${ae.cyan}${ae.bold}\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557
|
|
689
689
|
\u2551 Virtual Shell v1.0 \u2551
|
|
690
690
|
\u2551 A simulated bash environment in TypeScript \u2551
|
|
691
|
-
\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D${
|
|
691
|
+
\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D${ae.reset}
|
|
692
692
|
|
|
693
|
-
${
|
|
693
|
+
${ae.dim}Exploring: ${process.cwd()}${ae.reset}
|
|
694
694
|
|
|
695
|
-
Type ${
|
|
695
|
+
Type ${ae.green}help${ae.reset} for available commands, ${ae.green}exit${ae.reset} to quit.
|
|
696
696
|
Reads from real filesystem, writes stay in memory (OverlayFs).
|
|
697
|
-
`)}prompt(){this.rl.question(this.getPrompt(),async t=>{this.running&&(await this.executeCommand(t),this.prompt())})}async run(){if(this.isInteractive)this.printWelcome(),this.prompt();else{let t=[];this.rl.on("line",s=>{t.push(s)}),await new Promise(s=>{this.rl.on("close",s)});for(let s of t)await this.executeCommand(s)}}};function
|
|
697
|
+
`)}prompt(){this.rl.question(this.getPrompt(),async t=>{this.running&&(await this.executeCommand(t),this.prompt())})}async run(){if(this.isInteractive)this.printWelcome(),this.prompt();else{let t=[];this.rl.on("line",s=>{t.push(s)}),await new Promise(s=>{this.rl.on("close",s)});for(let s of t)await this.executeCommand(s)}}};function sa(){let e=process.argv.slice(2),t={network:!0};for(let s=0;s<e.length;s++)if(e[s]==="--cwd"&&e[s+1])t.cwd=e[++s];else if(e[s]==="--files"&&e[s+1]){let r=e[++s];try{let n=hi.readFileSync(r,"utf-8");t.files=JSON.parse(n)}catch(n){console.error(`Error reading files from ${r}:`,n),process.exit(1)}}else e[s]==="--no-network"?t.network=!1:(e[s]==="--help"||e[s]==="-h")&&(console.log(`
|
|
698
698
|
Usage: pnpm shell [options]
|
|
699
699
|
|
|
700
700
|
Interactive shell using OverlayFs - reads from the current directory,
|
|
@@ -708,4 +708,4 @@ Options:
|
|
|
708
708
|
Example:
|
|
709
709
|
pnpm shell
|
|
710
710
|
pnpm shell --no-network
|
|
711
|
-
`),process.exit(0));return t}var
|
|
711
|
+
`),process.exit(0));return t}var ra=sa(),na=new yr(ra);na.run();
|