just-binary 2.9.8
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/LICENSE +201 -0
- package/README.md +458 -0
- package/dist/AGENTS.md +323 -0
- package/dist/Bash.d.ts +179 -0
- package/dist/ast/types.d.ts +615 -0
- package/dist/banned-patterns-test.d.ts +8 -0
- package/dist/bin/chunks/alias-23G4Q2RS.js +2 -0
- package/dist/bin/chunks/awk2-Z6VRXKAK.js +2 -0
- package/dist/bin/chunks/base64-DNX4WCIO.js +2 -0
- package/dist/bin/chunks/basename-MPQ7M4RF.js +2 -0
- package/dist/bin/chunks/bash-OQ32Y5I6.js +2 -0
- package/dist/bin/chunks/bytes-6YUZMX3P.js +2 -0
- package/dist/bin/chunks/cat-CL5ISR5P.js +2 -0
- package/dist/bin/chunks/chmod-R6IWRSKZ.js +2 -0
- package/dist/bin/chunks/chunk-227L3ACM.js +23 -0
- package/dist/bin/chunks/chunk-2QA4P6HI.js +12 -0
- package/dist/bin/chunks/chunk-3MFM4GSH.js +36 -0
- package/dist/bin/chunks/chunk-3UP5LXDO.js +3 -0
- package/dist/bin/chunks/chunk-47P7JSQI.js +2 -0
- package/dist/bin/chunks/chunk-4KBTPDQB.js +3 -0
- package/dist/bin/chunks/chunk-4UK2MV3F.js +13 -0
- package/dist/bin/chunks/chunk-4VDEBYW7.js +2 -0
- package/dist/bin/chunks/chunk-563AO4OL.js +7 -0
- package/dist/bin/chunks/chunk-5HDWUXRX.js +7 -0
- package/dist/bin/chunks/chunk-5MCFI6LE.js +5 -0
- package/dist/bin/chunks/chunk-6CZOPIZD.js +6 -0
- package/dist/bin/chunks/chunk-6FNFX5GG.js +5 -0
- package/dist/bin/chunks/chunk-6NYIHYDY.js +7 -0
- package/dist/bin/chunks/chunk-6Y4TKR73.js +16 -0
- package/dist/bin/chunks/chunk-7C7WEK46.js +23 -0
- package/dist/bin/chunks/chunk-7TNGQWY6.js +6 -0
- package/dist/bin/chunks/chunk-7UAWRBQS.js +9 -0
- package/dist/bin/chunks/chunk-ARGU3OIG.js +17 -0
- package/dist/bin/chunks/chunk-BA3A5BYZ.js +3 -0
- package/dist/bin/chunks/chunk-BB7T22CF.js +140 -0
- package/dist/bin/chunks/chunk-BY24LKGP.js +8 -0
- package/dist/bin/chunks/chunk-CRHN4WNQ.js +63 -0
- package/dist/bin/chunks/chunk-ELZHJGI7.js +10 -0
- package/dist/bin/chunks/chunk-F46CSMUF.js +2 -0
- package/dist/bin/chunks/chunk-FQX4G5RH.js +7 -0
- package/dist/bin/chunks/chunk-G43H2WGH.js +17 -0
- package/dist/bin/chunks/chunk-GIFF636B.js +2 -0
- package/dist/bin/chunks/chunk-GMJWC3MC.js +12 -0
- package/dist/bin/chunks/chunk-HVDU57EV.js +16 -0
- package/dist/bin/chunks/chunk-HWGK3XW7.js +6 -0
- package/dist/bin/chunks/chunk-HYR7G7KS.js +3 -0
- package/dist/bin/chunks/chunk-I2225JSU.js +14 -0
- package/dist/bin/chunks/chunk-I2FUQZXU.js +11 -0
- package/dist/bin/chunks/chunk-IBHPKKIT.js +10 -0
- package/dist/bin/chunks/chunk-IKNNFJNZ.js +14 -0
- package/dist/bin/chunks/chunk-INPUJM7Y.js +8 -0
- package/dist/bin/chunks/chunk-IOBKPMWJ.js +9 -0
- package/dist/bin/chunks/chunk-IYSA2L6A.js +13 -0
- package/dist/bin/chunks/chunk-JMLNX7GE.js +287 -0
- package/dist/bin/chunks/chunk-K2K4KPOQ.js +3 -0
- package/dist/bin/chunks/chunk-K6DD7NH3.js +9 -0
- package/dist/bin/chunks/chunk-KFLJ4EMB.js +4 -0
- package/dist/bin/chunks/chunk-KOMDAXHM.js +7 -0
- package/dist/bin/chunks/chunk-KV7ZTM2R.js +11 -0
- package/dist/bin/chunks/chunk-LCCVVEJA.js +10 -0
- package/dist/bin/chunks/chunk-LUPJK5US.js +84 -0
- package/dist/bin/chunks/chunk-LWF3XDOC.js +32 -0
- package/dist/bin/chunks/chunk-LXNARM2C.js +9 -0
- package/dist/bin/chunks/chunk-LXZS3X5T.js +9 -0
- package/dist/bin/chunks/chunk-M4ICSCXT.js +100 -0
- package/dist/bin/chunks/chunk-MEBZXRGE.js +5 -0
- package/dist/bin/chunks/chunk-MSPSS36S.js +16 -0
- package/dist/bin/chunks/chunk-N335RIGZ.js +20 -0
- package/dist/bin/chunks/chunk-N5KGQWJH.js +5 -0
- package/dist/bin/chunks/chunk-NDHTQE5T.js +8 -0
- package/dist/bin/chunks/chunk-NF5G7X3O.js +7 -0
- package/dist/bin/chunks/chunk-NGKNJ6V2.js +11 -0
- package/dist/bin/chunks/chunk-OBH7XN5N.js +1 -0
- package/dist/bin/chunks/chunk-OKQ6RACF.js +73 -0
- package/dist/bin/chunks/chunk-PBY7XGZ6.js +8 -0
- package/dist/bin/chunks/chunk-PHHNNFRS.js +6 -0
- package/dist/bin/chunks/chunk-PO6Y7TWQ.js +6 -0
- package/dist/bin/chunks/chunk-Q4TLKLIZ.js +12 -0
- package/dist/bin/chunks/chunk-QS6LP3E3.js +6 -0
- package/dist/bin/chunks/chunk-QT2GMJRJ.js +8 -0
- package/dist/bin/chunks/chunk-QUVW3R4I.js +5 -0
- package/dist/bin/chunks/chunk-QUYWT2TY.js +21 -0
- package/dist/bin/chunks/chunk-QWUII542.js +2 -0
- package/dist/bin/chunks/chunk-R5EQDD5Y.js +13 -0
- package/dist/bin/chunks/chunk-RQSPCXDR.js +2 -0
- package/dist/bin/chunks/chunk-RTC6C5QW.js +2 -0
- package/dist/bin/chunks/chunk-S5W2KVHC.js +2 -0
- package/dist/bin/chunks/chunk-SDXDICI4.js +2 -0
- package/dist/bin/chunks/chunk-SE4C7FJY.js +33 -0
- package/dist/bin/chunks/chunk-SX7TI7Q2.js +3 -0
- package/dist/bin/chunks/chunk-TDJ55L4A.js +16 -0
- package/dist/bin/chunks/chunk-TNPUAMV3.js +8 -0
- package/dist/bin/chunks/chunk-TSGSFBQI.js +14 -0
- package/dist/bin/chunks/chunk-U5ZE562V.js +2 -0
- package/dist/bin/chunks/chunk-UIMH6I3G.js +33 -0
- package/dist/bin/chunks/chunk-UXPY5T2P.js +9 -0
- package/dist/bin/chunks/chunk-UYBH3FNE.js +2 -0
- package/dist/bin/chunks/chunk-V5I6PHN2.js +14 -0
- package/dist/bin/chunks/chunk-VOTJNR36.js +5 -0
- package/dist/bin/chunks/chunk-W5XFREQC.js +3 -0
- package/dist/bin/chunks/chunk-X2MOXVGO.js +26 -0
- package/dist/bin/chunks/chunk-XOGQUO62.js +2 -0
- package/dist/bin/chunks/chunk-Y57BDPQ5.js +6 -0
- package/dist/bin/chunks/chunk-YE6KXFFU.js +2 -0
- package/dist/bin/chunks/chunk-YEPWKN4F.js +3 -0
- package/dist/bin/chunks/chunk-ZEDWVSUZ.js +19 -0
- package/dist/bin/chunks/chunk-ZI4TTZL5.js +21 -0
- package/dist/bin/chunks/chunk-ZZVIGHYS.js +7 -0
- package/dist/bin/chunks/clear-27OP2FQZ.js +2 -0
- package/dist/bin/chunks/column-FJNKONCJ.js +2 -0
- package/dist/bin/chunks/comm-5FNEJE7X.js +2 -0
- package/dist/bin/chunks/cp-LVKHKFHQ.js +2 -0
- package/dist/bin/chunks/curl-S4FJSZA5.js +26 -0
- package/dist/bin/chunks/cut-UXU6PNTT.js +2 -0
- package/dist/bin/chunks/date-GGPTXVUT.js +2 -0
- package/dist/bin/chunks/diff-3V3FOITV.js +2 -0
- package/dist/bin/chunks/dirname-455JDV2M.js +2 -0
- package/dist/bin/chunks/du-WUEAQO2W.js +2 -0
- package/dist/bin/chunks/echo-HBXOI5TQ.js +2 -0
- package/dist/bin/chunks/env-MXFHTVHS.js +2 -0
- package/dist/bin/chunks/expand-F4FM4ML2.js +2 -0
- package/dist/bin/chunks/expansion-7AYBVOIQ.js +2 -0
- package/dist/bin/chunks/expr-5ZKR5ER5.js +2 -0
- package/dist/bin/chunks/file-BFN7BKUR.js +2 -0
- package/dist/bin/chunks/find-W4BCEJEC.js +2 -0
- package/dist/bin/chunks/flag-coverage-DBKGNLJO.js +2 -0
- package/dist/bin/chunks/fold-AE57YLOS.js +2 -0
- package/dist/bin/chunks/grep-I63BWUKL.js +2 -0
- package/dist/bin/chunks/gzip-X5IDXWZE.js +2 -0
- package/dist/bin/chunks/head-TBQETLQX.js +2 -0
- package/dist/bin/chunks/help-HGMKZ2GW.js +2 -0
- package/dist/bin/chunks/history-2DYRIL3U.js +2 -0
- package/dist/bin/chunks/hostname-RWEPTCXH.js +2 -0
- package/dist/bin/chunks/html-to-markdown-2VQWCEKU.js +2 -0
- package/dist/bin/chunks/join-TRRWQBEU.js +2 -0
- package/dist/bin/chunks/jq-NFKKH27D.js +2 -0
- package/dist/bin/chunks/ln-BSEVUP2J.js +2 -0
- package/dist/bin/chunks/ls-IJLTWVOI.js +2 -0
- package/dist/bin/chunks/md5sum-ZIQHOC4K.js +2 -0
- package/dist/bin/chunks/mkdir-KYFAO2SF.js +2 -0
- package/dist/bin/chunks/mv-TWM2PA7Q.js +2 -0
- package/dist/bin/chunks/nl-XLF2HFST.js +2 -0
- package/dist/bin/chunks/od-BOM6JPTH.js +2 -0
- package/dist/bin/chunks/paste-FUGXVGJX.js +2 -0
- package/dist/bin/chunks/printf-XUGNJ3QM.js +2 -0
- package/dist/bin/chunks/pwd-RZG6GZEU.js +2 -0
- package/dist/bin/chunks/python3-PIXJS3YM.js +14 -0
- package/dist/bin/chunks/readlink-4SOSIDHE.js +2 -0
- package/dist/bin/chunks/rev-5E5UGSUZ.js +2 -0
- package/dist/bin/chunks/rg-4YJSQZN7.js +2 -0
- package/dist/bin/chunks/rm-3PFOF4E3.js +2 -0
- package/dist/bin/chunks/rmdir-CSK7CGH5.js +2 -0
- package/dist/bin/chunks/sed-XBCUZMEP.js +2 -0
- package/dist/bin/chunks/seq-H7ID4VMK.js +2 -0
- package/dist/bin/chunks/sha1sum-EDQNYXXH.js +2 -0
- package/dist/bin/chunks/sha256sum-APTG6DO2.js +2 -0
- package/dist/bin/chunks/sleep-PNT7KILS.js +2 -0
- package/dist/bin/chunks/sort-ELAGZUES.js +2 -0
- package/dist/bin/chunks/split-QGXYUWBC.js +2 -0
- package/dist/bin/chunks/sqlite3-ELLMKNNJ.js +2 -0
- package/dist/bin/chunks/stat-Q2TZRKO3.js +2 -0
- package/dist/bin/chunks/strings-IGEGP5QX.js +2 -0
- package/dist/bin/chunks/tac-VOEDJLLG.js +2 -0
- package/dist/bin/chunks/tail-JOQASWMV.js +2 -0
- package/dist/bin/chunks/tar-2UVSVD3P.js +2 -0
- package/dist/bin/chunks/tee-IQLEDZOQ.js +2 -0
- package/dist/bin/chunks/time-VRCJK2LI.js +2 -0
- package/dist/bin/chunks/timeout-A36YWZWR.js +2 -0
- package/dist/bin/chunks/touch-5ECNQNBP.js +2 -0
- package/dist/bin/chunks/tr-AVALLN54.js +2 -0
- package/dist/bin/chunks/tree-UFM5EDXS.js +2 -0
- package/dist/bin/chunks/true-BU5JSAAW.js +2 -0
- package/dist/bin/chunks/unexpand-TDRWZW5F.js +2 -0
- package/dist/bin/chunks/uniq-IKBUNAMN.js +2 -0
- package/dist/bin/chunks/wc-2R4RS2SX.js +2 -0
- package/dist/bin/chunks/which-6UVGMXDF.js +2 -0
- package/dist/bin/chunks/whoami-N6TLTETT.js +2 -0
- package/dist/bin/chunks/worker.js +2260 -0
- package/dist/bin/chunks/xan-JX5QUK32.js +2 -0
- package/dist/bin/chunks/xan-view-NFMUMJ7Z.js +2 -0
- package/dist/bin/chunks/xargs-4MYN4U3C.js +2 -0
- package/dist/bin/chunks/yq-EHDQVD7S.js +2 -0
- package/dist/bin/just-bash.js +732 -0
- package/dist/bin/shell/chunks/alias-23G4Q2RS.js +2 -0
- package/dist/bin/shell/chunks/awk2-Z6VRXKAK.js +2 -0
- package/dist/bin/shell/chunks/base64-DNX4WCIO.js +2 -0
- package/dist/bin/shell/chunks/basename-MPQ7M4RF.js +2 -0
- package/dist/bin/shell/chunks/bash-OQ32Y5I6.js +2 -0
- package/dist/bin/shell/chunks/bytes-6YUZMX3P.js +2 -0
- package/dist/bin/shell/chunks/cat-CL5ISR5P.js +2 -0
- package/dist/bin/shell/chunks/chmod-R6IWRSKZ.js +2 -0
- package/dist/bin/shell/chunks/chunk-227L3ACM.js +23 -0
- package/dist/bin/shell/chunks/chunk-2QA4P6HI.js +12 -0
- package/dist/bin/shell/chunks/chunk-3MFM4GSH.js +36 -0
- package/dist/bin/shell/chunks/chunk-3UP5LXDO.js +3 -0
- package/dist/bin/shell/chunks/chunk-47P7JSQI.js +2 -0
- package/dist/bin/shell/chunks/chunk-4KBTPDQB.js +3 -0
- package/dist/bin/shell/chunks/chunk-4UK2MV3F.js +13 -0
- package/dist/bin/shell/chunks/chunk-4VDEBYW7.js +2 -0
- package/dist/bin/shell/chunks/chunk-563AO4OL.js +7 -0
- package/dist/bin/shell/chunks/chunk-5HDWUXRX.js +7 -0
- package/dist/bin/shell/chunks/chunk-5MCFI6LE.js +5 -0
- package/dist/bin/shell/chunks/chunk-6CZOPIZD.js +6 -0
- package/dist/bin/shell/chunks/chunk-6FNFX5GG.js +5 -0
- package/dist/bin/shell/chunks/chunk-6NYIHYDY.js +7 -0
- package/dist/bin/shell/chunks/chunk-6Y4TKR73.js +16 -0
- package/dist/bin/shell/chunks/chunk-7C7WEK46.js +23 -0
- package/dist/bin/shell/chunks/chunk-7TNGQWY6.js +6 -0
- package/dist/bin/shell/chunks/chunk-7UAWRBQS.js +9 -0
- package/dist/bin/shell/chunks/chunk-ARGU3OIG.js +17 -0
- package/dist/bin/shell/chunks/chunk-BA3A5BYZ.js +3 -0
- package/dist/bin/shell/chunks/chunk-BB7T22CF.js +140 -0
- package/dist/bin/shell/chunks/chunk-BY24LKGP.js +8 -0
- package/dist/bin/shell/chunks/chunk-CRHN4WNQ.js +63 -0
- package/dist/bin/shell/chunks/chunk-ELZHJGI7.js +10 -0
- package/dist/bin/shell/chunks/chunk-F46CSMUF.js +2 -0
- package/dist/bin/shell/chunks/chunk-FQX4G5RH.js +7 -0
- package/dist/bin/shell/chunks/chunk-G43H2WGH.js +17 -0
- package/dist/bin/shell/chunks/chunk-GIFF636B.js +2 -0
- package/dist/bin/shell/chunks/chunk-GMJWC3MC.js +12 -0
- package/dist/bin/shell/chunks/chunk-HVDU57EV.js +16 -0
- package/dist/bin/shell/chunks/chunk-HWGK3XW7.js +6 -0
- package/dist/bin/shell/chunks/chunk-HYR7G7KS.js +3 -0
- package/dist/bin/shell/chunks/chunk-I2225JSU.js +14 -0
- package/dist/bin/shell/chunks/chunk-I2FUQZXU.js +11 -0
- package/dist/bin/shell/chunks/chunk-IBHPKKIT.js +10 -0
- package/dist/bin/shell/chunks/chunk-IKNNFJNZ.js +14 -0
- package/dist/bin/shell/chunks/chunk-INPUJM7Y.js +8 -0
- package/dist/bin/shell/chunks/chunk-IOBKPMWJ.js +9 -0
- package/dist/bin/shell/chunks/chunk-IYSA2L6A.js +13 -0
- package/dist/bin/shell/chunks/chunk-JMLNX7GE.js +287 -0
- package/dist/bin/shell/chunks/chunk-K2K4KPOQ.js +3 -0
- package/dist/bin/shell/chunks/chunk-K6DD7NH3.js +9 -0
- package/dist/bin/shell/chunks/chunk-KFLJ4EMB.js +4 -0
- package/dist/bin/shell/chunks/chunk-KOMDAXHM.js +7 -0
- package/dist/bin/shell/chunks/chunk-KV7ZTM2R.js +11 -0
- package/dist/bin/shell/chunks/chunk-LCCVVEJA.js +10 -0
- package/dist/bin/shell/chunks/chunk-LUPJK5US.js +84 -0
- package/dist/bin/shell/chunks/chunk-LWF3XDOC.js +32 -0
- package/dist/bin/shell/chunks/chunk-LXNARM2C.js +9 -0
- package/dist/bin/shell/chunks/chunk-LXZS3X5T.js +9 -0
- package/dist/bin/shell/chunks/chunk-M4ICSCXT.js +100 -0
- package/dist/bin/shell/chunks/chunk-MEBZXRGE.js +5 -0
- package/dist/bin/shell/chunks/chunk-MSPSS36S.js +16 -0
- package/dist/bin/shell/chunks/chunk-N335RIGZ.js +20 -0
- package/dist/bin/shell/chunks/chunk-N5KGQWJH.js +5 -0
- package/dist/bin/shell/chunks/chunk-NDHTQE5T.js +8 -0
- package/dist/bin/shell/chunks/chunk-NF5G7X3O.js +7 -0
- package/dist/bin/shell/chunks/chunk-NGKNJ6V2.js +11 -0
- package/dist/bin/shell/chunks/chunk-OBH7XN5N.js +1 -0
- package/dist/bin/shell/chunks/chunk-OKQ6RACF.js +73 -0
- package/dist/bin/shell/chunks/chunk-PBY7XGZ6.js +8 -0
- package/dist/bin/shell/chunks/chunk-PHHNNFRS.js +6 -0
- package/dist/bin/shell/chunks/chunk-PO6Y7TWQ.js +6 -0
- package/dist/bin/shell/chunks/chunk-Q4TLKLIZ.js +12 -0
- package/dist/bin/shell/chunks/chunk-QS6LP3E3.js +6 -0
- package/dist/bin/shell/chunks/chunk-QT2GMJRJ.js +8 -0
- package/dist/bin/shell/chunks/chunk-QUVW3R4I.js +5 -0
- package/dist/bin/shell/chunks/chunk-QUYWT2TY.js +21 -0
- package/dist/bin/shell/chunks/chunk-QWUII542.js +2 -0
- package/dist/bin/shell/chunks/chunk-R5EQDD5Y.js +13 -0
- package/dist/bin/shell/chunks/chunk-RQSPCXDR.js +2 -0
- package/dist/bin/shell/chunks/chunk-RTC6C5QW.js +2 -0
- package/dist/bin/shell/chunks/chunk-S5W2KVHC.js +2 -0
- package/dist/bin/shell/chunks/chunk-SDXDICI4.js +2 -0
- package/dist/bin/shell/chunks/chunk-SE4C7FJY.js +33 -0
- package/dist/bin/shell/chunks/chunk-SX7TI7Q2.js +3 -0
- package/dist/bin/shell/chunks/chunk-TDJ55L4A.js +16 -0
- package/dist/bin/shell/chunks/chunk-TNPUAMV3.js +8 -0
- package/dist/bin/shell/chunks/chunk-TSGSFBQI.js +14 -0
- package/dist/bin/shell/chunks/chunk-U5ZE562V.js +2 -0
- package/dist/bin/shell/chunks/chunk-UIMH6I3G.js +33 -0
- package/dist/bin/shell/chunks/chunk-UXPY5T2P.js +9 -0
- package/dist/bin/shell/chunks/chunk-UYBH3FNE.js +2 -0
- package/dist/bin/shell/chunks/chunk-V5I6PHN2.js +14 -0
- package/dist/bin/shell/chunks/chunk-VOTJNR36.js +5 -0
- package/dist/bin/shell/chunks/chunk-W5XFREQC.js +3 -0
- package/dist/bin/shell/chunks/chunk-X2MOXVGO.js +26 -0
- package/dist/bin/shell/chunks/chunk-XOGQUO62.js +2 -0
- package/dist/bin/shell/chunks/chunk-Y57BDPQ5.js +6 -0
- package/dist/bin/shell/chunks/chunk-YE6KXFFU.js +2 -0
- package/dist/bin/shell/chunks/chunk-YEPWKN4F.js +3 -0
- package/dist/bin/shell/chunks/chunk-ZEDWVSUZ.js +19 -0
- package/dist/bin/shell/chunks/chunk-ZI4TTZL5.js +21 -0
- package/dist/bin/shell/chunks/chunk-ZZVIGHYS.js +7 -0
- package/dist/bin/shell/chunks/clear-27OP2FQZ.js +2 -0
- package/dist/bin/shell/chunks/column-FJNKONCJ.js +2 -0
- package/dist/bin/shell/chunks/comm-5FNEJE7X.js +2 -0
- package/dist/bin/shell/chunks/cp-LVKHKFHQ.js +2 -0
- package/dist/bin/shell/chunks/curl-S4FJSZA5.js +26 -0
- package/dist/bin/shell/chunks/cut-UXU6PNTT.js +2 -0
- package/dist/bin/shell/chunks/date-GGPTXVUT.js +2 -0
- package/dist/bin/shell/chunks/diff-3V3FOITV.js +2 -0
- package/dist/bin/shell/chunks/dirname-455JDV2M.js +2 -0
- package/dist/bin/shell/chunks/du-WUEAQO2W.js +2 -0
- package/dist/bin/shell/chunks/echo-HBXOI5TQ.js +2 -0
- package/dist/bin/shell/chunks/env-MXFHTVHS.js +2 -0
- package/dist/bin/shell/chunks/expand-F4FM4ML2.js +2 -0
- package/dist/bin/shell/chunks/expansion-7AYBVOIQ.js +2 -0
- package/dist/bin/shell/chunks/expr-5ZKR5ER5.js +2 -0
- package/dist/bin/shell/chunks/file-BFN7BKUR.js +2 -0
- package/dist/bin/shell/chunks/find-W4BCEJEC.js +2 -0
- package/dist/bin/shell/chunks/flag-coverage-DBKGNLJO.js +2 -0
- package/dist/bin/shell/chunks/fold-AE57YLOS.js +2 -0
- package/dist/bin/shell/chunks/grep-I63BWUKL.js +2 -0
- package/dist/bin/shell/chunks/gzip-X5IDXWZE.js +2 -0
- package/dist/bin/shell/chunks/head-TBQETLQX.js +2 -0
- package/dist/bin/shell/chunks/help-HGMKZ2GW.js +2 -0
- package/dist/bin/shell/chunks/history-2DYRIL3U.js +2 -0
- package/dist/bin/shell/chunks/hostname-RWEPTCXH.js +2 -0
- package/dist/bin/shell/chunks/html-to-markdown-2VQWCEKU.js +2 -0
- package/dist/bin/shell/chunks/join-TRRWQBEU.js +2 -0
- package/dist/bin/shell/chunks/jq-NFKKH27D.js +2 -0
- package/dist/bin/shell/chunks/ln-BSEVUP2J.js +2 -0
- package/dist/bin/shell/chunks/ls-IJLTWVOI.js +2 -0
- package/dist/bin/shell/chunks/md5sum-ZIQHOC4K.js +2 -0
- package/dist/bin/shell/chunks/mkdir-KYFAO2SF.js +2 -0
- package/dist/bin/shell/chunks/mv-TWM2PA7Q.js +2 -0
- package/dist/bin/shell/chunks/nl-XLF2HFST.js +2 -0
- package/dist/bin/shell/chunks/od-BOM6JPTH.js +2 -0
- package/dist/bin/shell/chunks/paste-FUGXVGJX.js +2 -0
- package/dist/bin/shell/chunks/printf-XUGNJ3QM.js +2 -0
- package/dist/bin/shell/chunks/pwd-RZG6GZEU.js +2 -0
- package/dist/bin/shell/chunks/python3-PIXJS3YM.js +14 -0
- package/dist/bin/shell/chunks/readlink-4SOSIDHE.js +2 -0
- package/dist/bin/shell/chunks/rev-5E5UGSUZ.js +2 -0
- package/dist/bin/shell/chunks/rg-4YJSQZN7.js +2 -0
- package/dist/bin/shell/chunks/rm-3PFOF4E3.js +2 -0
- package/dist/bin/shell/chunks/rmdir-CSK7CGH5.js +2 -0
- package/dist/bin/shell/chunks/sed-XBCUZMEP.js +2 -0
- package/dist/bin/shell/chunks/seq-H7ID4VMK.js +2 -0
- package/dist/bin/shell/chunks/sha1sum-EDQNYXXH.js +2 -0
- package/dist/bin/shell/chunks/sha256sum-APTG6DO2.js +2 -0
- package/dist/bin/shell/chunks/sleep-PNT7KILS.js +2 -0
- package/dist/bin/shell/chunks/sort-ELAGZUES.js +2 -0
- package/dist/bin/shell/chunks/split-QGXYUWBC.js +2 -0
- package/dist/bin/shell/chunks/sqlite3-ELLMKNNJ.js +2 -0
- package/dist/bin/shell/chunks/stat-Q2TZRKO3.js +2 -0
- package/dist/bin/shell/chunks/strings-IGEGP5QX.js +2 -0
- package/dist/bin/shell/chunks/tac-VOEDJLLG.js +2 -0
- package/dist/bin/shell/chunks/tail-JOQASWMV.js +2 -0
- package/dist/bin/shell/chunks/tar-2UVSVD3P.js +2 -0
- package/dist/bin/shell/chunks/tee-IQLEDZOQ.js +2 -0
- package/dist/bin/shell/chunks/time-VRCJK2LI.js +2 -0
- package/dist/bin/shell/chunks/timeout-A36YWZWR.js +2 -0
- package/dist/bin/shell/chunks/touch-5ECNQNBP.js +2 -0
- package/dist/bin/shell/chunks/tr-AVALLN54.js +2 -0
- package/dist/bin/shell/chunks/tree-UFM5EDXS.js +2 -0
- package/dist/bin/shell/chunks/true-BU5JSAAW.js +2 -0
- package/dist/bin/shell/chunks/unexpand-TDRWZW5F.js +2 -0
- package/dist/bin/shell/chunks/uniq-IKBUNAMN.js +2 -0
- package/dist/bin/shell/chunks/wc-2R4RS2SX.js +2 -0
- package/dist/bin/shell/chunks/which-6UVGMXDF.js +2 -0
- package/dist/bin/shell/chunks/whoami-N6TLTETT.js +2 -0
- package/dist/bin/shell/chunks/xan-JX5QUK32.js +2 -0
- package/dist/bin/shell/chunks/xan-view-NFMUMJ7Z.js +2 -0
- package/dist/bin/shell/chunks/xargs-4MYN4U3C.js +2 -0
- package/dist/bin/shell/chunks/yq-EHDQVD7S.js +2 -0
- package/dist/bin/shell/shell.js +711 -0
- package/dist/browser.d.ts +22 -0
- package/dist/bundle/browser.js +1481 -0
- package/dist/bundle/chunks/alias-T2KDAHDL.js +1 -0
- package/dist/bundle/chunks/awk2-UIH6CPHX.js +1 -0
- package/dist/bundle/chunks/base64-RY5JPAQL.js +1 -0
- package/dist/bundle/chunks/basename-QT55QR7O.js +1 -0
- package/dist/bundle/chunks/bash-BZZ6TUGW.js +1 -0
- package/dist/bundle/chunks/bytes-W6ESHQ7F.js +1 -0
- package/dist/bundle/chunks/cat-WUR2OJUG.js +1 -0
- package/dist/bundle/chunks/chmod-LTQYKUUW.js +1 -0
- package/dist/bundle/chunks/chunk-24BT6QUB.js +11 -0
- package/dist/bundle/chunks/chunk-274QVGRQ.js +2 -0
- package/dist/bundle/chunks/chunk-2IKXAFP4.js +11 -0
- package/dist/bundle/chunks/chunk-2IO54DPD.js +1 -0
- package/dist/bundle/chunks/chunk-2VAJD54D.js +13 -0
- package/dist/bundle/chunks/chunk-34P4G5H7.js +5 -0
- package/dist/bundle/chunks/chunk-3OY3UJDR.js +62 -0
- package/dist/bundle/chunks/chunk-3R6EWKMD.js +13 -0
- package/dist/bundle/chunks/chunk-3SPSXVPQ.js +2 -0
- package/dist/bundle/chunks/chunk-43RXAZRC.js +7 -0
- package/dist/bundle/chunks/chunk-44UOCSGV.js +1 -0
- package/dist/bundle/chunks/chunk-47LWQIG6.js +15 -0
- package/dist/bundle/chunks/chunk-4L3Y4LKT.js +5 -0
- package/dist/bundle/chunks/chunk-4LYDOEQ6.js +4 -0
- package/dist/bundle/chunks/chunk-4Q5DFBVQ.js +6 -0
- package/dist/bundle/chunks/chunk-4R5AUIZ4.js +6 -0
- package/dist/bundle/chunks/chunk-4UTZCT3W.js +2 -0
- package/dist/bundle/chunks/chunk-5FDLF2FN.js +5 -0
- package/dist/bundle/chunks/chunk-5HJSZMTG.js +1 -0
- package/dist/bundle/chunks/chunk-5NR6JZM4.js +12 -0
- package/dist/bundle/chunks/chunk-5PL72KVW.js +7 -0
- package/dist/bundle/chunks/chunk-6BM2WKUH.js +23 -0
- package/dist/bundle/chunks/chunk-6HLDZZOT.js +4 -0
- package/dist/bundle/chunks/chunk-7MKBHGLS.js +1 -0
- package/dist/bundle/chunks/chunk-7VHVF5PX.js +20 -0
- package/dist/bundle/chunks/chunk-A3YV3X3J.js +6 -0
- package/dist/bundle/chunks/chunk-AJNR4FJT.js +8 -0
- package/dist/bundle/chunks/chunk-AMQM5ZPF.js +1 -0
- package/dist/bundle/chunks/chunk-BCDE2QUY.js +1 -0
- package/dist/bundle/chunks/chunk-BMKJMOWP.js +2 -0
- package/dist/bundle/chunks/chunk-BVFIC7R6.js +4 -0
- package/dist/bundle/chunks/chunk-CC4HUWHZ.js +4 -0
- package/dist/bundle/chunks/chunk-CNCKROJZ.js +10 -0
- package/dist/bundle/chunks/chunk-CSFZQCAK.js +139 -0
- package/dist/bundle/chunks/chunk-CU7G2LMR.js +1 -0
- package/dist/bundle/chunks/chunk-CZP7PMAG.js +4 -0
- package/dist/bundle/chunks/chunk-D2OUCFAU.js +8 -0
- package/dist/bundle/chunks/chunk-DQXLKPVQ.js +7 -0
- package/dist/bundle/chunks/chunk-E6IR6BWV.js +286 -0
- package/dist/bundle/chunks/chunk-ELZ2RVIZ.js +11 -0
- package/dist/bundle/chunks/chunk-EVNUXIEZ.js +2 -0
- package/dist/bundle/chunks/chunk-F6FQRFZU.js +6 -0
- package/dist/bundle/chunks/chunk-FAECBHMR.js +2 -0
- package/dist/bundle/chunks/chunk-FBOLGXN4.js +16 -0
- package/dist/bundle/chunks/chunk-FNIOXBJW.js +9 -0
- package/dist/bundle/chunks/chunk-GD5SDRL7.js +5 -0
- package/dist/bundle/chunks/chunk-GEAGCSIY.js +31 -0
- package/dist/bundle/chunks/chunk-GI2KN5IL.js +22 -0
- package/dist/bundle/chunks/chunk-GOG2LNAH.js +9 -0
- package/dist/bundle/chunks/chunk-H2ENJVUI.js +10 -0
- package/dist/bundle/chunks/chunk-HDNR2KMO.js +13 -0
- package/dist/bundle/chunks/chunk-HJ37IXKX.js +12 -0
- package/dist/bundle/chunks/chunk-I36BZMR3.js +1 -0
- package/dist/bundle/chunks/chunk-I6YSZMB6.js +15 -0
- package/dist/bundle/chunks/chunk-IJXFPKNC.js +1 -0
- package/dist/bundle/chunks/chunk-IXD4Z54Z.js +8 -0
- package/dist/bundle/chunks/chunk-J44PYBAW.js +2 -0
- package/dist/bundle/chunks/chunk-JDREUEBG.js +9 -0
- package/dist/bundle/chunks/chunk-KA244HSE.js +5 -0
- package/dist/bundle/chunks/chunk-KKZJ6K7R.js +8 -0
- package/dist/bundle/chunks/chunk-KZ3P3SVS.js +22 -0
- package/dist/bundle/chunks/chunk-LIVSDOY2.js +1 -0
- package/dist/bundle/chunks/chunk-LX7SQKLW.js +15 -0
- package/dist/bundle/chunks/chunk-M5O5DYR7.js +1 -0
- package/dist/bundle/chunks/chunk-MML7K3J2.js +6 -0
- package/dist/bundle/chunks/chunk-N4GRDEVJ.js +5 -0
- package/dist/bundle/chunks/chunk-NPZMNEW5.js +6 -0
- package/dist/bundle/chunks/chunk-NUFRM6SI.js +0 -0
- package/dist/bundle/chunks/chunk-O7N2RCS7.js +1 -0
- package/dist/bundle/chunks/chunk-OSYLT4VG.js +4 -0
- package/dist/bundle/chunks/chunk-OXRHP7HO.js +3 -0
- package/dist/bundle/chunks/chunk-OZOS3R6K.js +99 -0
- package/dist/bundle/chunks/chunk-OZQ4AW5X.js +8 -0
- package/dist/bundle/chunks/chunk-PNGAWBIZ.js +10 -0
- package/dist/bundle/chunks/chunk-PPUKM2B7.js +13 -0
- package/dist/bundle/chunks/chunk-PTELGM2J.js +7 -0
- package/dist/bundle/chunks/chunk-Q3TLRYBC.js +72 -0
- package/dist/bundle/chunks/chunk-Q5AOYNOX.js +6 -0
- package/dist/bundle/chunks/chunk-QEKGAAIL.js +1 -0
- package/dist/bundle/chunks/chunk-QIL3FXIC.js +6 -0
- package/dist/bundle/chunks/chunk-QNZEO23C.js +8 -0
- package/dist/bundle/chunks/chunk-R4IVADTA.js +7 -0
- package/dist/bundle/chunks/chunk-RK57WTFF.js +12 -0
- package/dist/bundle/chunks/chunk-RU5M6ZRS.js +4 -0
- package/dist/bundle/chunks/chunk-SBVBPPEQ.js +5 -0
- package/dist/bundle/chunks/chunk-SP22LBKJ.js +20 -0
- package/dist/bundle/chunks/chunk-UKS3AEEA.js +32 -0
- package/dist/bundle/chunks/chunk-UYR5HJI6.js +7 -0
- package/dist/bundle/chunks/chunk-V6ANTLBA.js +15 -0
- package/dist/bundle/chunks/chunk-VLGZJRPG.js +16 -0
- package/dist/bundle/chunks/chunk-VZUQMDOT.js +2 -0
- package/dist/bundle/chunks/chunk-XDQU6V6S.js +19 -0
- package/dist/bundle/chunks/chunk-XRVUJRYI.js +35 -0
- package/dist/bundle/chunks/chunk-YNYSPYQ5.js +32 -0
- package/dist/bundle/chunks/clear-NLKZY76S.js +1 -0
- package/dist/bundle/chunks/column-S7P64XRJ.js +1 -0
- package/dist/bundle/chunks/comm-FPLN4BYY.js +1 -0
- package/dist/bundle/chunks/cp-W5HXJH5J.js +1 -0
- package/dist/bundle/chunks/curl-UFR6W4B6.js +25 -0
- package/dist/bundle/chunks/cut-VNFQFCA7.js +1 -0
- package/dist/bundle/chunks/date-EDSSFONA.js +1 -0
- package/dist/bundle/chunks/diff-RR5VJXIT.js +1 -0
- package/dist/bundle/chunks/dirname-V7Z24BGZ.js +1 -0
- package/dist/bundle/chunks/du-QKRPQIMY.js +1 -0
- package/dist/bundle/chunks/echo-TR3BM2AJ.js +1 -0
- package/dist/bundle/chunks/env-SVQBHVZF.js +1 -0
- package/dist/bundle/chunks/expand-ZVCJ72RF.js +1 -0
- package/dist/bundle/chunks/expansion-OBOJBZTH.js +1 -0
- package/dist/bundle/chunks/expr-QRA5KFYV.js +1 -0
- package/dist/bundle/chunks/file-TORG4IVZ.js +1 -0
- package/dist/bundle/chunks/find-NAGPRRQ7.js +1 -0
- package/dist/bundle/chunks/flag-coverage-FMTW4YWD.js +1 -0
- package/dist/bundle/chunks/fold-L4U6GS2N.js +1 -0
- package/dist/bundle/chunks/grep-D6AI423Z.js +1 -0
- package/dist/bundle/chunks/gzip-4EFUBHN7.js +1 -0
- package/dist/bundle/chunks/head-KBQT2JAC.js +1 -0
- package/dist/bundle/chunks/help-F3TJS3LS.js +1 -0
- package/dist/bundle/chunks/history-OKEAINJD.js +1 -0
- package/dist/bundle/chunks/hostname-AGIPNJOC.js +1 -0
- package/dist/bundle/chunks/html-to-markdown-P2LSCPVF.js +1 -0
- package/dist/bundle/chunks/join-FTSZAZYU.js +1 -0
- package/dist/bundle/chunks/jq-TNIKCGGT.js +1 -0
- package/dist/bundle/chunks/ln-BWYUCELO.js +1 -0
- package/dist/bundle/chunks/ls-6BM6G675.js +1 -0
- package/dist/bundle/chunks/md5sum-ALFVDB3W.js +1 -0
- package/dist/bundle/chunks/mkdir-I3BZBLTZ.js +1 -0
- package/dist/bundle/chunks/mv-76WRD5SE.js +1 -0
- package/dist/bundle/chunks/nl-77Q7V2GV.js +1 -0
- package/dist/bundle/chunks/od-AA6TIC6A.js +1 -0
- package/dist/bundle/chunks/paste-C6JKQOHO.js +1 -0
- package/dist/bundle/chunks/printf-WOYMDX2I.js +1 -0
- package/dist/bundle/chunks/pwd-BE3B3ZPG.js +1 -0
- package/dist/bundle/chunks/python3-QFUFNW7I.js +13 -0
- package/dist/bundle/chunks/readlink-QI6K7ZZX.js +1 -0
- package/dist/bundle/chunks/rev-2FZQEIQG.js +1 -0
- package/dist/bundle/chunks/rg-CNS6SD3V.js +1 -0
- package/dist/bundle/chunks/rm-JMWEKCU4.js +1 -0
- package/dist/bundle/chunks/rmdir-5HDB4IQ7.js +1 -0
- package/dist/bundle/chunks/sed-CSUGXVBJ.js +1 -0
- package/dist/bundle/chunks/seq-UP62NDEL.js +1 -0
- package/dist/bundle/chunks/sha1sum-XXYTWQIW.js +1 -0
- package/dist/bundle/chunks/sha256sum-GD6AFWG3.js +1 -0
- package/dist/bundle/chunks/sleep-225KIGXI.js +1 -0
- package/dist/bundle/chunks/sort-BIWEEIVX.js +1 -0
- package/dist/bundle/chunks/split-QUFGLTTX.js +1 -0
- package/dist/bundle/chunks/sqlite3-3ZFEGTQ7.js +1 -0
- package/dist/bundle/chunks/stat-DIMPSC6S.js +1 -0
- package/dist/bundle/chunks/strings-LECMRXOT.js +1 -0
- package/dist/bundle/chunks/tac-A6JKZKWL.js +1 -0
- package/dist/bundle/chunks/tail-YGDXZZGG.js +1 -0
- package/dist/bundle/chunks/tar-7KN7KZ6S.js +1 -0
- package/dist/bundle/chunks/tee-J4MBDQJZ.js +1 -0
- package/dist/bundle/chunks/time-CVS7ESWV.js +1 -0
- package/dist/bundle/chunks/timeout-UX2PSLYJ.js +1 -0
- package/dist/bundle/chunks/touch-ATQADRUQ.js +1 -0
- package/dist/bundle/chunks/tr-QVFN4YWH.js +1 -0
- package/dist/bundle/chunks/tree-IY7WNFVF.js +1 -0
- package/dist/bundle/chunks/true-AKKYE7WM.js +1 -0
- package/dist/bundle/chunks/unexpand-2WTX7UPB.js +1 -0
- package/dist/bundle/chunks/uniq-XS6VGRO2.js +1 -0
- package/dist/bundle/chunks/wc-22EISCPD.js +1 -0
- package/dist/bundle/chunks/which-IWHCX6SW.js +1 -0
- package/dist/bundle/chunks/whoami-HCON4D7C.js +1 -0
- package/dist/bundle/chunks/worker.js +2260 -0
- package/dist/bundle/chunks/xan-XDECJHII.js +1 -0
- package/dist/bundle/chunks/xan-view-IJ4EABH7.js +1 -0
- package/dist/bundle/chunks/xargs-5MMN7C6P.js +1 -0
- package/dist/bundle/chunks/yq-LQX5YIGM.js +1 -0
- package/dist/bundle/index.js +688 -0
- package/dist/commands/alias/alias.d.ts +6 -0
- package/dist/commands/awk/ast.d.ts +202 -0
- package/dist/commands/awk/awk2.d.ts +9 -0
- package/dist/commands/awk/builtins.d.ts +17 -0
- package/dist/commands/awk/interpreter/context.d.ts +73 -0
- package/dist/commands/awk/interpreter/expressions.d.ts +17 -0
- package/dist/commands/awk/interpreter/fields.d.ts +25 -0
- package/dist/commands/awk/interpreter/index.d.ts +8 -0
- package/dist/commands/awk/interpreter/interpreter.d.ts +52 -0
- package/dist/commands/awk/interpreter/statements.d.ts +11 -0
- package/dist/commands/awk/interpreter/type-coercion.d.ts +32 -0
- package/dist/commands/awk/interpreter/types.d.ts +13 -0
- package/dist/commands/awk/interpreter/variables.d.ts +35 -0
- package/dist/commands/awk/lexer.d.ts +100 -0
- package/dist/commands/awk/parser2-print.d.ts +35 -0
- package/dist/commands/awk/parser2.d.ts +81 -0
- package/dist/commands/base64/base64.d.ts +7 -0
- package/dist/commands/basename/basename.d.ts +4 -0
- package/dist/commands/bash/bash.d.ts +6 -0
- package/dist/commands/browser-excluded.d.ts +16 -0
- package/dist/commands/cat/cat.d.ts +4 -0
- package/dist/commands/chmod/chmod.d.ts +4 -0
- package/dist/commands/clear/clear.d.ts +4 -0
- package/dist/commands/column/column.d.ts +11 -0
- package/dist/commands/comm/comm.d.ts +12 -0
- package/dist/commands/cp/cp.d.ts +4 -0
- package/dist/commands/curl/curl.d.ts +8 -0
- package/dist/commands/curl/form.d.ts +21 -0
- package/dist/commands/curl/help.d.ts +9 -0
- package/dist/commands/curl/parse.d.ts +9 -0
- package/dist/commands/curl/response-formatting.d.ts +20 -0
- package/dist/commands/curl/types.d.ts +31 -0
- package/dist/commands/cut/cut.d.ts +4 -0
- package/dist/commands/date/date.d.ts +7 -0
- package/dist/commands/diff/diff.d.ts +7 -0
- package/dist/commands/dirname/dirname.d.ts +4 -0
- package/dist/commands/du/du.d.ts +4 -0
- package/dist/commands/echo/echo.d.ts +4 -0
- package/dist/commands/env/env.d.ts +6 -0
- package/dist/commands/expand/expand.d.ts +12 -0
- package/dist/commands/expand/unexpand.d.ts +12 -0
- package/dist/commands/expr/expr.d.ts +9 -0
- package/dist/commands/file/file.d.ts +9 -0
- package/dist/commands/find/find.d.ts +4 -0
- package/dist/commands/find/matcher.d.ts +69 -0
- package/dist/commands/find/parser.d.ts +2 -0
- package/dist/commands/find/types.d.ts +88 -0
- package/dist/commands/flag-coverage.d.ts +2 -0
- package/dist/commands/fold/fold.d.ts +12 -0
- package/dist/commands/fuzz-flags-types.d.ts +17 -0
- package/dist/commands/fuzz-flags.d.ts +8 -0
- package/dist/commands/grep/grep.d.ts +8 -0
- package/dist/commands/gzip/gzip.d.ts +13 -0
- package/dist/commands/head/head-tail-shared.d.ts +38 -0
- package/dist/commands/head/head.d.ts +4 -0
- package/dist/commands/help/help.d.ts +4 -0
- package/dist/commands/help.d.ts +16 -0
- package/dist/commands/history/history.d.ts +4 -0
- package/dist/commands/hostname/hostname.d.ts +11 -0
- package/dist/commands/html-to-markdown/html-to-markdown.d.ts +9 -0
- package/dist/commands/join/join.d.ts +12 -0
- package/dist/commands/jq/jq.d.ts +9 -0
- package/dist/commands/ln/ln.d.ts +4 -0
- package/dist/commands/ls/ls.d.ts +4 -0
- package/dist/commands/md5sum/checksum.d.ts +7 -0
- package/dist/commands/md5sum/md5sum.d.ts +4 -0
- package/dist/commands/md5sum/sha1sum.d.ts +4 -0
- package/dist/commands/md5sum/sha256sum.d.ts +4 -0
- package/dist/commands/mkdir/mkdir.d.ts +4 -0
- package/dist/commands/mv/mv.d.ts +4 -0
- package/dist/commands/nl/nl.d.ts +12 -0
- package/dist/commands/od/od.d.ts +12 -0
- package/dist/commands/paste/paste.d.ts +4 -0
- package/dist/commands/printf/escapes.d.ts +31 -0
- package/dist/commands/printf/printf.d.ts +4 -0
- package/dist/commands/printf/strftime.d.ts +9 -0
- package/dist/commands/pwd/pwd.d.ts +4 -0
- package/dist/commands/python3/fs-bridge-handler.d.ts +50 -0
- package/dist/commands/python3/protocol.d.ts +138 -0
- package/dist/commands/python3/python3.d.ts +11 -0
- package/dist/commands/python3/sync-fs-backend.d.ts +59 -0
- package/dist/commands/python3/worker.d.ts +22 -0
- package/dist/commands/query-engine/builtins/array-builtins.d.ts +20 -0
- package/dist/commands/query-engine/builtins/control-builtins.d.ts +18 -0
- package/dist/commands/query-engine/builtins/date-builtins.d.ts +15 -0
- package/dist/commands/query-engine/builtins/format-builtins.d.ts +11 -0
- package/dist/commands/query-engine/builtins/index-builtins.d.ts +16 -0
- package/dist/commands/query-engine/builtins/index.d.ts +17 -0
- package/dist/commands/query-engine/builtins/math-builtins.d.ts +15 -0
- package/dist/commands/query-engine/builtins/navigation-builtins.d.ts +18 -0
- package/dist/commands/query-engine/builtins/object-builtins.d.ts +15 -0
- package/dist/commands/query-engine/builtins/path-builtins.d.ts +20 -0
- package/dist/commands/query-engine/builtins/sql-builtins.d.ts +16 -0
- package/dist/commands/query-engine/builtins/string-builtins.d.ts +15 -0
- package/dist/commands/query-engine/builtins/type-builtins.d.ts +11 -0
- package/dist/commands/query-engine/evaluator.d.ts +37 -0
- package/dist/commands/query-engine/index.d.ts +8 -0
- package/dist/commands/query-engine/parser-types.d.ts +171 -0
- package/dist/commands/query-engine/parser.d.ts +9 -0
- package/dist/commands/query-engine/path-operations.d.ts +15 -0
- package/dist/commands/query-engine/safe-object.d.ts +59 -0
- package/dist/commands/query-engine/value-operations.d.ts +41 -0
- package/dist/commands/readlink/readlink.d.ts +4 -0
- package/dist/commands/registry.d.ts +45 -0
- package/dist/commands/rev/rev.d.ts +13 -0
- package/dist/commands/rg/file-types.d.ts +49 -0
- package/dist/commands/rg/gitignore.d.ts +98 -0
- package/dist/commands/rg/rg-options.d.ts +61 -0
- package/dist/commands/rg/rg-parser.d.ts +20 -0
- package/dist/commands/rg/rg-search.d.ts +15 -0
- package/dist/commands/rg/rg.d.ts +14 -0
- package/dist/commands/rm/rm.d.ts +4 -0
- package/dist/commands/rmdir/rmdir.d.ts +4 -0
- package/dist/commands/search-engine/index.d.ts +10 -0
- package/dist/commands/search-engine/matcher.d.ts +60 -0
- package/dist/commands/search-engine/regex.d.ts +33 -0
- package/dist/commands/sed/executor.d.ts +7 -0
- package/dist/commands/sed/lexer.d.ts +86 -0
- package/dist/commands/sed/parser.d.ts +18 -0
- package/dist/commands/sed/sed-regex.d.ts +23 -0
- package/dist/commands/sed/sed.d.ts +4 -0
- package/dist/commands/sed/types.d.ts +219 -0
- package/dist/commands/seq/seq.d.ts +16 -0
- package/dist/commands/sleep/sleep.d.ts +4 -0
- package/dist/commands/sort/comparator.d.ts +9 -0
- package/dist/commands/sort/parser.d.ts +11 -0
- package/dist/commands/sort/sort.d.ts +4 -0
- package/dist/commands/sort/types.d.ts +30 -0
- package/dist/commands/split/split.d.ts +12 -0
- package/dist/commands/sqlite3/formatters.d.ts +15 -0
- package/dist/commands/sqlite3/sqlite3.d.ts +16 -0
- package/dist/commands/sqlite3/worker.d.ts +44 -0
- package/dist/commands/stat/stat.d.ts +4 -0
- package/dist/commands/strings/strings.d.ts +12 -0
- package/dist/commands/tac/tac.d.ts +11 -0
- package/dist/commands/tail/tail.d.ts +4 -0
- package/dist/commands/tar/archive.d.ts +107 -0
- package/dist/commands/tar/tar-options.d.ts +36 -0
- package/dist/commands/tar/tar.d.ts +10 -0
- package/dist/commands/tee/tee.d.ts +4 -0
- package/dist/commands/time/time.d.ts +27 -0
- package/dist/commands/timeout/timeout.d.ts +4 -0
- package/dist/commands/touch/touch.d.ts +4 -0
- package/dist/commands/tr/tr.d.ts +4 -0
- package/dist/commands/tree/tree.d.ts +4 -0
- package/dist/commands/true/true.d.ts +6 -0
- package/dist/commands/uniq/uniq.d.ts +4 -0
- package/dist/commands/wc/wc.d.ts +4 -0
- package/dist/commands/which/which.d.ts +4 -0
- package/dist/commands/whoami/whoami.d.ts +11 -0
- package/dist/commands/xan/aggregation.d.ts +20 -0
- package/dist/commands/xan/column-selection.d.ts +19 -0
- package/dist/commands/xan/csv.d.ts +37 -0
- package/dist/commands/xan/moonblade-parser.d.ts +80 -0
- package/dist/commands/xan/moonblade-to-jq.d.ts +12 -0
- package/dist/commands/xan/moonblade-tokenizer.d.ts +25 -0
- package/dist/commands/xan/subcommands.d.ts +15 -0
- package/dist/commands/xan/xan-agg.d.ts +8 -0
- package/dist/commands/xan/xan-columns.d.ts +8 -0
- package/dist/commands/xan/xan-core.d.ts +10 -0
- package/dist/commands/xan/xan-data.d.ts +52 -0
- package/dist/commands/xan/xan-filter.d.ts +8 -0
- package/dist/commands/xan/xan-map.d.ts +11 -0
- package/dist/commands/xan/xan-reshape.d.ts +40 -0
- package/dist/commands/xan/xan-simple.d.ts +40 -0
- package/dist/commands/xan/xan-view.d.ts +12 -0
- package/dist/commands/xan/xan.d.ts +10 -0
- package/dist/commands/xargs/xargs.d.ts +4 -0
- package/dist/commands/yq/formats.d.ts +64 -0
- package/dist/commands/yq/yq.d.ts +13 -0
- package/dist/custom-commands.d.ts +61 -0
- package/dist/fs/encoding.d.ts +17 -0
- package/dist/fs/in-memory-fs/in-memory-fs.d.ts +63 -0
- package/dist/fs/in-memory-fs/index.d.ts +1 -0
- package/dist/fs/init.d.ts +12 -0
- package/dist/fs/interface.d.ts +219 -0
- package/dist/fs/mountable-fs/index.d.ts +1 -0
- package/dist/fs/mountable-fs/mountable-fs.d.ts +120 -0
- package/dist/fs/overlay-fs/index.d.ts +1 -0
- package/dist/fs/overlay-fs/overlay-fs.d.ts +126 -0
- package/dist/fs/read-write-fs/index.d.ts +1 -0
- package/dist/fs/read-write-fs/read-write-fs.d.ts +69 -0
- package/dist/index.d.ts +19 -0
- package/dist/interpreter/alias-expansion.d.ts +23 -0
- package/dist/interpreter/arithmetic.d.ts +24 -0
- package/dist/interpreter/assignment-expansion.d.ts +24 -0
- package/dist/interpreter/builtin-dispatch.d.ts +39 -0
- package/dist/interpreter/builtins/break.d.ts +6 -0
- package/dist/interpreter/builtins/cd.d.ts +6 -0
- package/dist/interpreter/builtins/compgen.d.ts +26 -0
- package/dist/interpreter/builtins/complete.d.ts +17 -0
- package/dist/interpreter/builtins/compopt.d.ts +28 -0
- package/dist/interpreter/builtins/continue.d.ts +6 -0
- package/dist/interpreter/builtins/declare-array-parsing.d.ts +14 -0
- package/dist/interpreter/builtins/declare-print.d.ts +39 -0
- package/dist/interpreter/builtins/declare.d.ts +35 -0
- package/dist/interpreter/builtins/dirs.d.ts +29 -0
- package/dist/interpreter/builtins/eval.d.ts +9 -0
- package/dist/interpreter/builtins/exit.d.ts +5 -0
- package/dist/interpreter/builtins/export.d.ts +14 -0
- package/dist/interpreter/builtins/getopts.d.ts +18 -0
- package/dist/interpreter/builtins/hash.d.ts +19 -0
- package/dist/interpreter/builtins/help.d.ts +12 -0
- package/dist/interpreter/builtins/index.d.ts +45 -0
- package/dist/interpreter/builtins/let.d.ts +18 -0
- package/dist/interpreter/builtins/local.d.ts +6 -0
- package/dist/interpreter/builtins/mapfile.d.ts +17 -0
- package/dist/interpreter/builtins/read.d.ts +6 -0
- package/dist/interpreter/builtins/return.d.ts +6 -0
- package/dist/interpreter/builtins/set.d.ts +9 -0
- package/dist/interpreter/builtins/shift.d.ts +15 -0
- package/dist/interpreter/builtins/shopt.d.ts +7 -0
- package/dist/interpreter/builtins/source.d.ts +6 -0
- package/dist/interpreter/builtins/unset.d.ts +16 -0
- package/dist/interpreter/builtins/variable-assignment.d.ts +66 -0
- package/dist/interpreter/command-resolution.d.ts +43 -0
- package/dist/interpreter/conditionals.d.ts +17 -0
- package/dist/interpreter/control-flow.d.ts +21 -0
- package/dist/interpreter/errors.d.ts +150 -0
- package/dist/interpreter/expansion/analysis.d.ts +37 -0
- package/dist/interpreter/expansion/arith-text-expansion.d.ts +20 -0
- package/dist/interpreter/expansion/array-pattern-ops.d.ts +21 -0
- package/dist/interpreter/expansion/array-prefix-suffix.d.ts +46 -0
- package/dist/interpreter/expansion/array-slice-transform.d.ts +36 -0
- package/dist/interpreter/expansion/array-word-expansion.d.ts +39 -0
- package/dist/interpreter/expansion/brace-range.d.ts +20 -0
- package/dist/interpreter/expansion/command-substitution.d.ts +23 -0
- package/dist/interpreter/expansion/glob-escape.d.ts +32 -0
- package/dist/interpreter/expansion/indirect-expansion.d.ts +42 -0
- package/dist/interpreter/expansion/parameter-ops.d.ts +113 -0
- package/dist/interpreter/expansion/pattern-expansion.d.ts +23 -0
- package/dist/interpreter/expansion/pattern-removal.d.ts +18 -0
- package/dist/interpreter/expansion/pattern.d.ts +23 -0
- package/dist/interpreter/expansion/positional-params.d.ts +59 -0
- package/dist/interpreter/expansion/prompt.d.ts +39 -0
- package/dist/interpreter/expansion/quoting.d.ts +13 -0
- package/dist/interpreter/expansion/tilde.d.ts +12 -0
- package/dist/interpreter/expansion/unquoted-expansion.d.ts +76 -0
- package/dist/interpreter/expansion/variable-attrs.d.ts +19 -0
- package/dist/interpreter/expansion/variable.d.ts +43 -0
- package/dist/interpreter/expansion/word-glob-expansion.d.ts +33 -0
- package/dist/interpreter/expansion/word-split.d.ts +29 -0
- package/dist/interpreter/expansion.d.ts +57 -0
- package/dist/interpreter/functions.d.ts +12 -0
- package/dist/interpreter/helpers/array.d.ts +43 -0
- package/dist/interpreter/helpers/condition.d.ts +18 -0
- package/dist/interpreter/helpers/errors.d.ts +8 -0
- package/dist/interpreter/helpers/file-tests.d.ts +33 -0
- package/dist/interpreter/helpers/ifs.d.ts +104 -0
- package/dist/interpreter/helpers/loop.d.ts +24 -0
- package/dist/interpreter/helpers/nameref.d.ts +65 -0
- package/dist/interpreter/helpers/numeric-compare.d.ts +13 -0
- package/dist/interpreter/helpers/quoting.d.ts +24 -0
- package/dist/interpreter/helpers/readonly.d.ts +45 -0
- package/dist/interpreter/helpers/regex.d.ts +8 -0
- package/dist/interpreter/helpers/result.d.ts +62 -0
- package/dist/interpreter/helpers/shell-constants.d.ts +25 -0
- package/dist/interpreter/helpers/shellopts.d.ts +28 -0
- package/dist/interpreter/helpers/statements.d.ts +20 -0
- package/dist/interpreter/helpers/string-compare.d.ts +24 -0
- package/dist/interpreter/helpers/string-tests.d.ts +13 -0
- package/dist/interpreter/helpers/tilde.d.ts +13 -0
- package/dist/interpreter/helpers/variable-tests.d.ts +9 -0
- package/dist/interpreter/helpers/word-matching.d.ts +26 -0
- package/dist/interpreter/helpers/word-parts.d.ts +29 -0
- package/dist/interpreter/helpers/xtrace.d.ts +18 -0
- package/dist/interpreter/index.d.ts +3 -0
- package/dist/interpreter/interpreter.d.ts +65 -0
- package/dist/interpreter/pipeline-execution.d.ts +16 -0
- package/dist/interpreter/redirections.d.ts +51 -0
- package/dist/interpreter/simple-command-assignments.d.ts +29 -0
- package/dist/interpreter/subshell-group.d.ts +32 -0
- package/dist/interpreter/type-command.d.ts +37 -0
- package/dist/interpreter/types.d.ts +317 -0
- package/dist/limits.d.ts +42 -0
- package/dist/network/allow-list/shared.d.ts +45 -0
- package/dist/network/allow-list.d.ts +51 -0
- package/dist/network/fetch.d.ts +25 -0
- package/dist/network/index.d.ts +7 -0
- package/dist/network/types.d.ts +96 -0
- package/dist/parser/arithmetic-parser.d.ts +23 -0
- package/dist/parser/arithmetic-primaries.d.ts +45 -0
- package/dist/parser/command-parser.d.ts +10 -0
- package/dist/parser/compound-parser.d.ts +28 -0
- package/dist/parser/conditional-parser.d.ts +8 -0
- package/dist/parser/expansion-parser.d.ts +16 -0
- package/dist/parser/lexer.d.ts +192 -0
- package/dist/parser/parser-substitution.d.ts +62 -0
- package/dist/parser/parser.d.ts +135 -0
- package/dist/parser/types.d.ts +25 -0
- package/dist/parser/word-parser.d.ts +33 -0
- package/dist/sandbox/Command.d.ts +28 -0
- package/dist/sandbox/Sandbox.d.ts +60 -0
- package/dist/sandbox/index.d.ts +2 -0
- package/dist/shell-metadata.d.ts +28 -0
- package/dist/test-utils.d.ts +15 -0
- package/dist/types.d.ts +148 -0
- package/dist/utils/args.d.ts +55 -0
- package/dist/utils/bytes.d.ts +39 -0
- package/dist/utils/constants.d.ts +15 -0
- package/dist/utils/file-reader.d.ts +67 -0
- package/dist/utils/glob.d.ts +25 -0
- package/package.json +115 -0
|
@@ -0,0 +1,732 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{A as rs,C as gr,D as wr,E as ue,F as Fe,G as te,H as Ee,I as St,J as vr,K as F,L as br,M as Er,N as _e,O as ns,P as $t,Q as je,R as q,a as lr,b as Qt,c as cr,d as ur,e as bt,f as Q,g as H,h as Se,i as se,j as $e,k as De,l as Jt,m as Et,n as fr,o as es,p as dr,q as ce,r as Ne,s as hr,t as pr,u as ts,v as ss,w as Ae,x as mr,y as yr,z as be}from"./chunks/chunk-OKQ6RACF.js";import{a as Te,b as ve}from"./chunks/chunk-F46CSMUF.js";import{a as st}from"./chunks/chunk-SE4C7FJY.js";import{a as pe,b as me,c as le,d as ge,e as or,f as G,g as Me,h as gt,i as wt,j as ar,k as ie,l as Oe,m as vt,n as we}from"./chunks/chunk-QT2GMJRJ.js";import"./chunks/chunk-OBH7XN5N.js";import{a as ke}from"./chunks/chunk-4VDEBYW7.js";import{a as yt,g as p,h as E,i as z,j as N,k as Be,l as tt,m as x,n as w}from"./chunks/chunk-RQSPCXDR.js";import{resolve as Qn}from"node:path";var He=[{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__)&&(He.push({name:"tar",load:async()=>(await import("./chunks/tar-2UVSVD3P.js")).tarCommand}),He.push({name:"yq",load:async()=>(await import("./chunks/yq-EHDQVD7S.js")).yqCommand}),He.push({name:"xan",load:async()=>(await import("./chunks/xan-JX5QUK32.js")).xanCommand}),He.push({name:"sqlite3",load:async()=>(await import("./chunks/sqlite3-ELLMKNNJ.js")).sqlite3Command}));var is=[];(typeof __BROWSER__>"u"||!__BROWSER__)&&(is.push({name:"python3",load:async()=>(await import("./chunks/python3-PIXJS3YM.js")).python3Command}),is.push({name:"python",load:async()=>(await import("./chunks/python3-PIXJS3YM.js")).pythonCommand}));var ri=[{name:"curl",load:async()=>(await import("./chunks/curl-S4FJSZA5.js")).curlCommand}],Sr=new Map;function os(e){return{name:e.name,async execute(t,s){let r=Sr.get(e.name);if(r||(r=await e.load(),Sr.set(e.name,r)),s.coverage&&(typeof __BROWSER__>"u"||!__BROWSER__)){let{emitFlagCoverage:n}=await import("./chunks/flag-coverage-DBKGNLJO.js"),{decodeArgs:i}=await import("./chunks/bytes-6YUZMX3P.js");n(s.coverage,e.name,i(t))}return r.execute(t,s)}}}function $r(e){return(e?He.filter(s=>e.includes(s.name)):He).map(os)}function Ar(){return ri.map(os)}function _r(){return is.map(os)}function Pr(e){return"load"in e&&typeof e.load=="function"}function Cr(e){let t=null;return{name:e.name,async execute(s,r){return t||(t=await e.load()),t.execute(s,r)}}}var ni=new TextEncoder,ii=new TextDecoder;function Ue(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 ni.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 r="";for(let n=0;n<e.length;n+=s){let i=e.subarray(n,n+s);r+=String.fromCharCode(...i)}return r}return ii.decode(e)}function Ie(e){if(e!=null)return typeof e=="string"?e:e.encoding??void 0}var _t=new TextEncoder;function oi(e){return typeof e=="object"&&e!==null&&!(e instanceof Uint8Array)&&"content"in e}function oe(e,t){if(e.includes("\0"))throw new Error(`ENOENT: path contains null byte, ${t} '${e}'`)}var rt=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))oi(r)?this.writeFileSync(s,r.content,void 0,{mode:r.mode,mtime:r.mtime}):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=Ie(r),a=Ue(s,o);this.data.set(i,{type:"file",content:a,mode:n?.mode??420,mtime:n?.mtime??new Date})}async readFile(t,s){let r=await this.readFileBuffer(t),n=Ie(s);return At(r,n)}async readFileBuffer(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 r.content instanceof Uint8Array?r.content:_t.encode(r.content)}async writeFile(t,s,r){this.writeFileSync(t,s,r)}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=Ie(r),a=Ue(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(n,{type:"file",content:u,mode:i.mode,mtime:new Date})}else this.writeFileSync(t,s,r)}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"&&r.content&&(r.content instanceof Uint8Array?n=r.content.length:n=_t.encode(r.content).length),{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"&&r.content&&(r.content instanceof Uint8Array?n=r.content.length:n=_t.encode(r.content).length),{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,{...o});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",content:i.content,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 ai(e){let t=e;return typeof t.mkdirSync=="function"&&typeof t.writeFileSync=="function"}function li(e,t){e.mkdirSync("/bin",{recursive:!0}),e.mkdirSync("/usr/bin",{recursive:!0}),t&&(e.mkdirSync("/home/user",{recursive:!0}),e.mkdirSync("/tmp",{recursive:!0}))}function ci(e){e.mkdirSync("/dev",{recursive:!0}),e.writeFileSync("/dev/null",""),e.writeFileSync("/dev/zero",new Uint8Array(0)),e.writeFileSync("/dev/stdin",""),e.writeFileSync("/dev/stdout",""),e.writeFileSync("/dev/stderr","")}function ui(e){e.mkdirSync("/proc/self/fd",{recursive:!0}),e.writeFileSync("/proc/version",`${lr}
|
|
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",cr()),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 kr(e,t){ai(e)&&(li(e,t),ci(e),ui(e))}var fi=["allexport","errexit","noglob","noclobber","noexec","nounset","pipefail","posix","verbose","xtrace"],di=["braceexpand","hashall","interactive-comments"];function as(e){let t=[],s=[...di.map(r=>({name:r,enabled:!0})),...fi.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 Ge(e){w(e.state.env,"SHELLOPTS",as(e.state.options))}var hi=["dotglob","expand_aliases","extglob","failglob","globskipdots","globstar","lastpipe","nocaseglob","nocasematch","nullglob","xpg_echo"];function ls(e){let t=[];for(let s of hi)e[s]&&t.push(s);return t.join(":")}function cs(e){w(e.state.env,"BASHOPTS",ls(e.state.shoptOptions))}var pi="BASH_ALIAS_";function Nr(e){return e.parts.length!==1?!1:e.parts[0].type==="Literal"}function xr(e){if(e.parts.length!==1)return null;let t=e.parts[0];return t.type==="Literal"?t.value:null}function Or(e,t){let s=e.env.get(`${pi}${t}`);return s!==void 0?z(s):void 0}function us(e,t,s){if(!t.name||!Nr(t.name))return t;let r=xr(t.name);if(!r)return t;let n=Or(e,r);if(!n||s.has(r))return t;try{s.add(r);let i=new H,o=n,a=n.endsWith(" ");if(!a)for(let f of t.args){let d=Dr(f);o+=` ${d}`}let c;try{c=i.parse(o)}catch(f){if(f instanceof bt)throw f;return t}if(c.statements.length!==1||c.statements[0].pipelines.length!==1||c.statements[0].pipelines[0].commands.length!==1)return Tr(t,n);let u=c.statements[0].pipelines[0].commands[0];if(u.type!=="SimpleCommand")return Tr(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(Nr(f)){let d=xr(f);if(d&&Or(e,d)){let h={type:"SimpleCommand",name:f,args:l.args.slice(1),assignments:[],redirections:[]},g=us(e,h,s);g!==h&&(l={...l,name:g.name,args:[...g.args]})}}}return l}catch(i){throw s.delete(r),i}}function Tr(e,t){let s=t;for(let o of e.args){let a=Dr(o);s+=` ${a}`}let r=new H,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 Dr(e){let t="";for(let s of e.parts)switch(s.type){case"Literal":t+=s.value.replace(/([\s"'$`\\*?[\]{}()<>|&;#!])/g,"\\$1");break;case"SingleQuoted":t+=`'${s.value}'`;break;case"DoubleQuoted":t+=`"${s.parts.map(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 Ir(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 d=f.indexOf("=(");d!==-1&&(o=!0,f=f.slice(d+2))}if(o){f.endsWith(")")&&(f=f.slice(0,-1));let d=f.split(/(\s+)/);for(let h of d)/^\s+$/.test(h)?(a||c)&&(i.push(a),a="",c=!1):h&&(a+=h)}}else if(o)if(l.type==="BraceExpansion")if(/^\[.+\]=/.test(a))a+=Et({type:"Word",parts:[l]});else{(a||c)&&(i.push(a),a="",c=!1);let d=await _e(e,{type:"Word",parts:[l]});i.push(...d.values)}else{(l.type==="SingleQuoted"||l.type==="DoubleQuoted"||l.type==="Escaped")&&(c=!0);let f=await F(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 Rr(e,t){let s=-1,r=-1,n=!1;for(let m=0;m<t.parts.length;m++){let v=t.parts[m];if(v.type==="Literal"){let $=v.value.indexOf("+=");if($!==-1){let k=v.value.slice(0,$);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(k)){s=m,r=$,n=!0;break}if(/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(k)){s=m,r=$,n=!0;break}}let _=v.value.indexOf("=");if(_!==-1&&(_===0||v.value[_-1]!=="+")){let k=v.value.slice(0,_);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(k)||/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(k)){s=m,r=_;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 m of i)f+=await F(e,{type:"Word",parts:[m]});f+=c;let d={type:"Word",parts:u!==""?[{type:"Literal",value:u},...l]:l},h=d.parts.length>0?await F(e,d):"";return`${f}${n?"+=":"="}${h}`}var mi=["tar","yq","xan","sqlite3","python3","python"];function Lr(e){return mi.includes(e)}var V=Object.freeze({stdout:p,stderr:p,exitCode:0});function ye(e=p){return{stdout:e,stderr:p,exitCode:0}}function U(e){return{stdout:E(e),stderr:p,exitCode:0}}function P(e,t=1){return{stdout:p,stderr:E(e),exitCode:t}}function T(e,t,s){return{stdout:e,stderr:t,exitCode:s}}function X(e){return{stdout:p,stderr:p,exitCode:e?0:1}}function xe(e,t,s=p,r=p){throw new ie(e,t,s,r)}function fs(e,t){if(e.state.loopDepth===0){if(e.state.parentHasLoopContext)throw new Oe;return V}if(t.length>1)throw new G(1,p,E(`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 G(128,p,E(`bash: break: ${t[0]}: numeric argument required
|
|
6
|
+
`));s=r}throw new pe(s)}async function ds(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=x(e.state.env,"HOME","/"):o[0]==="~"?s=x(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 d=z(f??p).split(":").filter(h=>h);for(let h of d){let g=h.startsWith("/")?`${h}/${s}`:`${e.state.cwd}/${h}/${s}`;try{if((await e.fs.stat(g)).isDirectory){s=g,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 P(`bash: cd: ${s}: Not a directory
|
|
7
|
+
`)}catch{return P(`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,w(e.state.env,"PWD",e.state.cwd),w(e.state.env,"OLDPWD",e.state.previousDir),r?U(`${l}
|
|
9
|
+
`):ye()}function hs(e,t){return e.fs.resolvePath(e.state.cwd,t)}var yi=["-e","-a","-f","-d","-r","-w","-x","-s","-L","-h","-k","-g","-u","-G","-O","-b","-c","-p","-S","-t","-N"];function Pt(e){return yi.includes(e)}async function Ct(e,t,s){let r=hs(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 gi=["-nt","-ot","-ef"];function kt(e){return gi.includes(e)}async function Nt(e,t,s,r){let n=hs(e,s),i=hs(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 wi=new Set(["-eq","-ne","-lt","-le","-gt","-ge"]);function xt(e){return wi.has(e)}function Ot(e,t,s){switch(e){case"-eq":return t===s;case"-ne":return t!==s;case"-lt":return t<s;case"-le":return t<=s;case"-gt":return t>s;case"-ge":return t>=s}}function nt(e){return e==="="||e==="=="||e==="!="}function Tt(e,t,s,r=!1,n=!1,i=!1){if(r){let a=qe(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 vi=new Set(["-z","-n"]);function Dt(e){return vi.has(e)}function It(e,t){switch(e){case"-z":return t==="";case"-n":return t!==""}}async function Rt(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)=>x(e.state.env,u)),e.state.env.has(`${r}_${a}`)}let o;try{let a=new H,c=Q(a,n);o=await q(e,c.expression)}catch{if(/^-?\d+$/.test(n))o=Number.parseInt(n,10);else{let a=x(e.state.env,n);o=a?Number.parseInt(a,10):0}}if(o<0){let a=se(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)?De(e,t).length>0:se(e,t).length>0}async function Re(e,t){switch(t.type){case"CondBinary":{let s=await F(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 F(e,t.right);n=wr(i)}else n=await br(e,t.right);else nt(t.operator)&&!r?n=await Er(e,t.right):n=await F(e,t.right);if(nt(t.operator)){let i=e.state.shoptOptions.nocasematch;return Tt(t.operator,s,n,!r,i,!0)}if(xt(t.operator))return Ot(t.operator,await Fr(e,s),await Fr(e,n));if(kt(t.operator))return Nt(e,t.operator,s,n);switch(t.operator){case"=~":try{let i=e.state.shoptOptions.nocasematch,o=$i(n),c=st(o,i?"i":"").match(s);if($e(e,"BASH_REMATCH"),c)for(let u=0;u<c.length;u++)w(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 F(e,t.operand);return Pt(t.operator)?Ct(e,t.operator,s):Dt(t.operator)?It(t.operator,s):t.operator==="-v"?await Rt(e,s):t.operator==="-o"?ms(e,s):!1}case"CondNot":return e.state.shoptOptions.extglob&&t.operand.type==="CondGroup"&&t.operand.expression.type==="CondWord"?`!(${await F(e,t.operand.expression.word)})`!=="":!await Re(e,t.operand);case"CondAnd":return await Re(e,t.left)?await Re(e,t.right):!1;case"CondOr":return await Re(e,t.left)?!0:await Re(e,t.right);case"CondGroup":return await Re(e,t.expression);case"CondWord":return await F(e,t.word)!=="";default:return!1}}async function it(e,t){if(t.length===0)return T(p,p,1);if(t.length===1)return X(!!t[0]);if(t.length===2){let r=t[0],n=t[1];return r==="("?P(`test: '(' without matching ')'
|
|
12
|
+
`,2):Pt(r)?X(await Ct(e,r,n)):Dt(r)?X(It(r,n)):r==="!"?X(!n):r==="-v"?X(await Rt(e,n)):r==="-o"?X(ms(e,n)):r==="="||r==="=="||r==="!="||r==="<"||r===">"||r==="-eq"||r==="-ne"||r==="-lt"||r==="-le"||r==="-gt"||r==="-ge"||r==="-nt"||r==="-ot"||r==="-ef"?P(`test: ${r}: unary operator expected
|
|
13
|
+
`,2):T(p,p,1)}if(t.length===3){let r=t[0],n=t[1],i=t[2];if(nt(n))return X(Tt(n,r,i));if(xt(n)){let o=Lt(r),a=Lt(i);return!o.valid||!a.valid?T(p,p,2):X(Ot(n,o.value,a.value))}if(kt(n))return X(await Nt(e,n,r,i));switch(n){case"-a":return X(r!==""&&i!=="");case"-o":return X(r!==""||i!=="");case">":return X(r>i);case"<":return X(r<i)}if(r==="!"){let o=await it(e,[n,i]);return T(p,o.stderr,o.exitCode===0?1:o.exitCode===1?0:o.exitCode)}if(r==="("&&i===")")return X(n!=="")}if(t.length===4){if(t[0]==="!"){let r=await it(e,t.slice(1));return T(p,r.stderr,r.exitCode===0?1:r.exitCode===1?0:r.exitCode)}if(t[0]==="("&&t[3]===")")return it(e,[t[1],t[2]])}let s=await Vr(e,t,0);return s.pos<t.length?P(`test: too many arguments
|
|
14
|
+
`,2):X(s.value)}async function Vr(e,t,s){return bi(e,t,s)}async function bi(e,t,s){let{value:r,pos:n}=await Mr(e,t,s);for(;t[n]==="-o";){let i=await Mr(e,t,n+1);r=r||i.value,n=i.pos}return{value:r,pos:n}}async function Mr(e,t,s){let{value:r,pos:n}=await ps(e,t,s);for(;t[n]==="-a";){let i=await ps(e,t,n+1);r=r&&i.value,n=i.pos}return{value:r,pos:n}}async function ps(e,t,s){if(t[s]==="!"){let{value:r,pos:n}=await ps(e,t,s+1);return{value:!r,pos:n}}return Ei(e,t,s)}async function Ei(e,t,s){let r=t[s];if(r==="("){let{value:i,pos:o}=await Vr(e,t,s+1);return{value:i,pos:t[o]===")"?o+1:o}}let n=t[s+1];if(nt(n)){let i=r,o=t[s+2]??"";return{value:Tt(n,i,o),pos:s+3}}if(xt(n)){let i=Lt(r),o=Lt(t[s+2]??"0");return!i.valid||!o.valid?{value:!1,pos:s+3}:{value:Ot(n,i.value,o.value),pos:s+3}}if(kt(n)){let i=r,o=t[s+2]??"";return{value:await Nt(e,n,i,o),pos:s+3}}if(Pt(r)){let i=t[s+1]??"";return{value:await Ct(e,r,i),pos:s+2}}if(Dt(r)){let i=t[s+1]??"";return{value:It(r,i),pos:s+2}}if(r==="-v"){let i=t[s+1]??"";return{value:await Rt(e,i),pos:s+2}}if(r==="-o"){let i=t[s+1]??"";return{value:ms(e,i),pos:s+2}}return{value:r!==void 0&&r!=="",pos:s+1}}function qe(e,t,s=!1,r=!1){let n=`^${zr(t,r)}$`;return st(n,s?"is":"s").test(e)}function zr(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=Br(e,r+1);if(i!==-1){let o=e.slice(r+2,i),a=jr(o),c=a.map(l=>zr(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(h=>Hr(h,t));if(f.every(h=>h!==null)&&f.every(h=>h===f[0])&&f[0]!==null){let h=f[0];if(h===0)s+="(?:.+)";else{let g=[];h>0&&g.push(`.{0,${h-1}}`),g.push(`.{${h+1},}`),g.push(`(?!(?:${u})).{${h}}`),s+=`(?:${g.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 Br(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 jr(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 Hr(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=Br(e,r+1);if(i!==-1){if(n==="@"){let o=e.slice(r+2,i),c=jr(o).map(u=>Hr(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 ms(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 Fr(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 Wr(t);try{let s=new H,r=Q(s,t);return await q(e,r.expression)}catch{return Wr(t)}}function Si(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 Wr(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=Si(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 Lt(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 $i(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=Ai(e,s);t+=r.converted,s=r.endIndex}else t+=e[s],s++;return t}function Ai(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+=_i(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 d=e.slice(s+2,f);o+=d,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 _i(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 Pe(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 Mt(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 Ur(e){let t=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(t)return{name:t[1],isArray:!0,arrayElements:Pe(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 Pi(e,t){try{let s=new H,r=Q(s,t);return await q(e,r.expression)}catch{let s=parseInt(t,10);return Number.isNaN(s)?0:s}}async function Gr(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=te(e,r);if(l)return l}if(n&&i){for(let l=0;l<i.length;l++)w(e.state.env,`${r}_${l}`,i[l]);w(e.state.env,`${r}__length`,String(i.length))}else if(a!==void 0&&o!==void 0){let l=await Pi(e,a);w(e.state.env,`${r}_${l}`,o);let f=parseInt(x(e.state.env,`${r}__length`,"0"),10);l>=f&&w(e.state.env,`${r}__length`,String(l+1))}else o!==void 0&&w(e.state.env,r,o);return c&&ue(e,r),null}function Le(e,t){e.state.localVarDepth=e.state.localVarDepth||new Map,e.state.localVarDepth.set(t,e.state.callDepth)}function Ze(e,t){return e.state.localVarDepth?.get(t)}function Ft(e,t){e.state.localVarDepth?.delete(t)}function qr(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 Wt(e,t){let s=e.state.localVarStack?.get(t);if(!(!s||s.length===0))return s.pop()}function Zr(e,t){if(e.state.localVarStack)for(let[s,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 ys=new Set([":",".","break","continue","eval","exec","exit","export","readonly","return","set","shift","trap","unset"]);function Yr(e){return ys.has(e)}var gs=new Set(["if","then","else","elif","fi","case","esac","for","select","while","until","do","done","in","function","{","}","time","[[","]]","!"]),Ye=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 We(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 Ci(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 Kr(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(ns(e,n.target))return{targets:s,error:`bash: $@: ambiguous redirect
|
|
18
|
+
`};s.set(r,await F(e,n.target))}else{let o=await $t(e,n.target);if("error"in o)return{targets:s,error:o.error};s.set(r,o.target)}}return{targets:s}}function ki(e){e.state.nextFd===void 0&&(e.state.nextFd=10);let t=e.state.nextFd;return e.state.nextFd++,t}async function Vt(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 F(e,s.target)==="-"){if(e.state.env.has(s.fdVariable)){let i=Number.parseInt(x(e.state.env,s.fdVariable),10);Number.isNaN(i)||e.state.fileDescriptors.delete(i)}continue}let r=ki(e);if(w(e.state.env,s.fdVariable,String(r)),s.target.type==="Word"){let n=await F(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,p),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.readFile(i);e.state.fileDescriptors.set(r,o)}catch{return T(p,E(`bash: ${n}: No such file or directory
|
|
20
|
+
`),1)}}}return null}async function Ce(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 F(e,s.target),n==="-"||!Number.isNaN(Number.parseInt(n,10))||s.fd!=null)continue}else{let a=await $t(e,s.target);if("error"in a)return T(p,E(a.error),1);n=a.target}let i=e.fs.resolvePath(e.state.cwd,n),o=s.operator===">|";if(i.includes("\0"))return T(p,E(`bash: ${n}: No such file or directory
|
|
21
|
+
`),1);try{let a=await e.fs.stat(i);if(a.isDirectory)return T(p,E(`bash: ${n}: Is a directory
|
|
22
|
+
`),1);if(e.state.options.noclobber&&!o&&!a.isDirectory&&n!=="/dev/null")return T(p,E(`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 T(p,E(`bash: /dev/full: No space left on device
|
|
24
|
+
`),1)}return null}async function Z(e,t,s,r){let{stdout:n,stderr:i,exitCode:o}=t;for(let u=0;u<s.length;u++){let l=s[u];if(l.target.type==="HereDoc")continue;let f,d=r?.get(u);if(d!==void 0)f=d;else if(l.operator===">&"||l.operator==="<&"){if(ns(e,l.target)){i=N(i,E(`bash: $@: ambiguous redirect
|
|
25
|
+
`)),o=1,n=p;continue}f=await F(e,l.target)}else{let g=await $t(e,l.target);if("error"in g){i=N(i,E(g.error)),o=1,n=p;continue}f=g.target}if(!l.fdVariable){if(f.includes("\0")){i=N(i,E(`bash: ${f.replace(/\0/g,"")}: No such file or directory
|
|
26
|
+
`)),o=1,n=p;continue}switch(l.operator){case">":case">|":{let h=l.fd??1,g=l.operator===">|";if(h===1){if(f==="/dev/stdout")break;if(f==="/dev/stderr"){i=N(i,n),n=p;break}if(f==="/dev/full"){i=N(i,E(`bash: echo: write error: No space left on device
|
|
27
|
+
`)),o=1,n=p;break}let m=e.fs.resolvePath(e.state.cwd,f),v=await We(e,m,f,{checkNoclobber:!0,isClobber:g});if(v){i=N(i,E(v)),o=1,n=p;break}await e.fs.writeFile(m,n),n=p}else if(h===2){if(f==="/dev/stderr")break;if(f==="/dev/stdout"){n=N(n,i),i=p;break}if(f==="/dev/full"){i=N(i,E(`bash: echo: write error: No space left on device
|
|
28
|
+
`)),o=1;break}if(f==="/dev/null")i=p;else{let m=e.fs.resolvePath(e.state.cwd,f),v=await We(e,m,f,{checkNoclobber:!0,isClobber:g});if(v){i=N(i,E(v)),o=1;break}await e.fs.writeFile(m,i),i=p}}break}case">>":{let h=l.fd??1;if(h===1){if(f==="/dev/stdout")break;if(f==="/dev/stderr"){i=N(i,n),n=p;break}if(f==="/dev/full"){i=N(i,E(`bash: echo: write error: No space left on device
|
|
29
|
+
`)),o=1,n=p;break}let g=e.fs.resolvePath(e.state.cwd,f),m=await We(e,g,f,{});if(m){i=N(i,E(m)),o=1,n=p;break}await e.fs.appendFile(g,n),n=p}else if(h===2){if(f==="/dev/stderr")break;if(f==="/dev/stdout"){n=N(n,i),i=p;break}if(f==="/dev/full"){i=N(i,E(`bash: echo: write error: No space left on device
|
|
30
|
+
`)),o=1;break}let g=e.fs.resolvePath(e.state.cwd,f),m=await We(e,g,f,{});if(m){i=N(i,E(m)),o=1;break}await e.fs.appendFile(g,i),i=p}break}case">&":case"<&":{let h=l.fd??1;if(f==="-")break;if(f.endsWith("-")){let g=f.slice(0,-1),m=Number.parseInt(g,10);if(!Number.isNaN(m)){let v=e.state.fileDescriptors?.get(m);v!==void 0?(e.state.fileDescriptors||(e.state.fileDescriptors=new Map),e.state.fileDescriptors.set(h,v),m>=3&&e.state.fileDescriptors?.delete(m)):m===1||m===2?(e.state.fileDescriptors||(e.state.fileDescriptors=new Map),e.state.fileDescriptors.set(h,`__dupout__:${m}`)):m===0?(e.state.fileDescriptors||(e.state.fileDescriptors=new Map),e.state.fileDescriptors.set(h,`__dupin__:${m}`)):m>=3&&(i=N(i,E(`bash: ${m}: Bad file descriptor
|
|
31
|
+
`)),o=1)}break}if(f==="2"||f==="&2")h===1&&(i=N(i,n),n=p);else if(f==="1"||f==="&1")h===2?(n=N(n,i),i=p):(n=N(n,i),i=p);else{let g=Number.parseInt(f,10);if(Number.isNaN(g)){if(l.operator===">&"){let m=e.fs.resolvePath(e.state.cwd,f),v=await We(e,m,f,{checkNoclobber:!0});if(v){i=E(v),o=1,n=p;break}if(l.fd==null){let $=N(n,i);await e.fs.writeFile(m,$),n=p,i=p}else h===1?(await e.fs.writeFile(m,n),n=p):h===2&&(await e.fs.writeFile(m,i),i=p)}}else{let m=e.state.fileDescriptors?.get(g);if(m?.startsWith("__file__:")){let v=m.slice(9);h===1?(await e.fs.appendFile(v,n),n=p):h===2&&(await e.fs.appendFile(v,i),i=p)}else if(m?.startsWith("__rw__:")){let v=Ci(m);v&&(h===1?(await e.fs.appendFile(v.path,n),n=p):h===2&&(await e.fs.appendFile(v.path,i),i=p))}else if(m?.startsWith("__dupout__:")){let v=Number.parseInt(m.slice(11),10);if(v!==1)if(v===2)h===1&&(i=N(i,n),n=p);else{let $=e.state.fileDescriptors?.get(v);if($?.startsWith("__file__:")){let _=$.slice(9);h===1?(await e.fs.appendFile(_,n),n=p):h===2&&(await e.fs.appendFile(_,i),i=p)}}}else m?.startsWith("__dupin__:")?(i=N(i,E(`bash: ${g}: Bad file descriptor
|
|
32
|
+
`)),o=1,n=p):g>=3&&(i=N(i,E(`bash: ${g}: Bad file descriptor
|
|
33
|
+
`)),o=1,n=p)}}break}case"&>":{if(f==="/dev/full"){i=E(`bash: echo: write error: No space left on device
|
|
34
|
+
`),o=1,n=p;break}let h=e.fs.resolvePath(e.state.cwd,f),g=await We(e,h,f,{checkNoclobber:!0});if(g){i=E(g),o=1,n=p;break}let m=N(n,i);await e.fs.writeFile(h,m),n=p,i=p;break}case"&>>":{if(f==="/dev/full"){i=E(`bash: echo: write error: No space left on device
|
|
35
|
+
`),o=1,n=p;break}let h=e.fs.resolvePath(e.state.cwd,f),g=await We(e,h,f,{});if(g){i=E(g),o=1,n=p;break}let m=N(n,i);await e.fs.appendFile(h,m),n=p,i=p;break}}}}let a=e.state.fileDescriptors?.get(1);if(a){if(a==="__dupout__:2")i=N(i,n),n=p;else if(a.startsWith("__file__:")){let u=a.slice(9);await e.fs.appendFile(u,n),n=p}else if(a.startsWith("__file_append__:")){let u=a.slice(16);await e.fs.appendFile(u,n),n=p}}let c=e.state.fileDescriptors?.get(2);if(c){if(c==="__dupout__:1")n=N(n,i),i=p;else if(c.startsWith("__file__:")){let u=c.slice(9);await e.fs.appendFile(u,i),i=p}else if(c.startsWith("__file_append__:")){let u=c.slice(16);await e.fs.appendFile(u,i),i=p}}return T(n,i,o)}function Xr(e,t){if(e.state.options.posix&&ys.has(t.name)){let r=`bash: line ${e.state.currentLine}: \`${t.name}': is a special builtin
|
|
36
|
+
`;throw new G(2,p,E(r))}let s={...t,sourceFile:t.sourceFile??e.state.currentSource??"main"};return e.state.functions.set(t.name,s),V}async function Ni(e,t){let s=p;for(let r of t)if((r.operator==="<<"||r.operator==="<<-")&&r.target.type==="HereDoc"){let n=r.target,i=await F(e,n.content);n.stripTabs&&(i=i.split(`
|
|
37
|
+
`).map(a=>a.replace(/^\t+/,"")).join(`
|
|
38
|
+
`)),(r.fd??0)===0&&(s=E(i))}else if(r.operator==="<<<"&&r.target.type==="Word")s=E(`${await F(e,r.target)}
|
|
39
|
+
`);else if(r.operator==="<"&&r.target.type==="Word"){let n=await F(e,r.target),i=e.fs.resolvePath(e.state.cwd,n);try{s=E(await e.fs.readFile(i))}catch{}}return s}async function zt(e,t,s,r=p,n){e.state.callDepth++,e.state.callDepth>e.limits.maxCallDepth&&(e.state.callDepth--,xe(`${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),x(e.state.env,String(u+1))),w(e.state.env,String(u+1),s[u]);i.set("@",x(e.state.env,"@")),i.set("#",x(e.state.env,"#")),w(e.state.env,"@",s.join(" ")),w(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,d]of l)d===void 0?e.state.env.delete(f):e.state.env.set(f,d);if(Zr(e,u),e.state.fullyUnsetLocals)for(let[f,d]of e.state.fullyUnsetLocals.entries())d===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 d of f)e.state.exportedVars?.delete(d)}for(let[f,d]of i)d===void 0?e.state.env.delete(f):w(e.state.env,f,d);e.state.funcNameStack?.shift(),e.state.callLineStack?.shift(),e.state.sourceStack?.shift(),e.state.callDepth--},{targets:a,error:c}=await Kr(e,t.redirections);if(c)return o(),T(p,E(c),1);try{let u=await Ni(e,t.redirections),l=r.length>0?r:u,f=await e.executeCommand(t.body,l);return o(),Z(e,f,t.redirections,a)}catch(u){if(o(),u instanceof le){let l=T(u.stdout,u.stderr,u.exitCode);return Z(e,l,t.redirections,a)}throw u}}var Jr=["!","[[","]]","case","do","done","elif","else","esac","fi","for","function","if","in","then","time","until","while","{","}"],vs=[".",":","[","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"],xi=["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"],Oi=vs;async function bs(e,t){let s=[],r=null,n="",i="",o=null,a=!1,c=!1,u=!1,l=null,f=null,d=null,h=[],g=["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 y=0;y<t.length;y++){let b=t[y];if(b==="-v")s.push("variable");else if(b==="-e")s.push("export");else if(b==="-f")s.push("file");else if(b==="-d")s.push("directory");else if(b==="-k")s.push("keyword");else if(b==="-A"){if(y++,y>=t.length)return P(`compgen: -A: option requires an argument
|
|
40
|
+
`,2);let C=t[y];if(!g.includes(C))return P(`compgen: ${C}: invalid action name
|
|
41
|
+
`,2);s.push(C)}else if(b==="-W"){if(y++,y>=t.length)return P(`compgen: -W: option requires an argument
|
|
42
|
+
`,2);r=t[y]}else if(b==="-P"){if(y++,y>=t.length)return P(`compgen: -P: option requires an argument
|
|
43
|
+
`,2);n=t[y]}else if(b==="-S"){if(y++,y>=t.length)return P(`compgen: -S: option requires an argument
|
|
44
|
+
`,2);i=t[y]}else if(b==="-o"){if(y++,y>=t.length)return P(`compgen: -o: option requires an argument
|
|
45
|
+
`,2);let C=t[y];if(C==="plusdirs")a=!0;else if(C==="dirnames")c=!0;else if(C==="default")u=!0;else if(!(C==="filenames"||C==="nospace"||C==="bashdefault"||C==="noquote"))return P(`compgen: ${C}: invalid option name
|
|
46
|
+
`,2)}else if(b==="-F"){if(y++,y>=t.length)return P(`compgen: -F: option requires an argument
|
|
47
|
+
`,2);f=t[y]}else if(b==="-C"){if(y++,y>=t.length)return P(`compgen: -C: option requires an argument
|
|
48
|
+
`,2);d=t[y]}else if(b==="-X"){if(y++,y>=t.length)return P(`compgen: -X: option requires an argument
|
|
49
|
+
`,2);l=t[y]}else if(b==="-G"){if(y++,y>=t.length)return P(`compgen: -G: option requires an argument
|
|
50
|
+
`,2)}else if(b==="--"){h.push(...t.slice(y+1));break}else b.startsWith("-")||h.push(b)}o=h[0]??null;let m=[];if(c){let y=await ws(e,o);m.push(...y)}if(u){let y=await Qr(e,o);m.push(...y)}for(let y of s)if(y==="variable"){let b=Ti(e,o);m.push(...b)}else if(y==="export"){let b=Di(e,o);m.push(...b)}else if(y==="function"){let b=Ii(e,o);m.push(...b)}else if(y==="builtin"){let b=Ri(o);m.push(...b)}else if(y==="keyword"){let b=Li(o);m.push(...b)}else if(y==="alias"){let b=Mi(e,o);m.push(...b)}else if(y==="shopt"){let b=Fi(o);m.push(...b)}else if(y==="helptopic"){let b=Wi(o);m.push(...b)}else if(y==="directory"){let b=await ws(e,o);m.push(...b)}else if(y==="file"){let b=await Qr(e,o);m.push(...b)}else if(y==="user"){let b=Vi(o);m.push(...b)}else if(y==="command"){let b=await zi(e,o);m.push(...b)}if(r!==null)try{let y=await Bi(e,r),b=ji(e,y);for(let C of b)(o===null||C.startsWith(o))&&m.push(C)}catch{return T(p,p,1)}if(a){let y=await ws(e,o);for(let b of y)m.includes(b)||m.push(b)}let v="";if(f!==null){let y=e.state.functions.get(f);if(y){let b=new Map;b.set("COMP_WORDS__length",x(e.state.env,"COMP_WORDS__length")),w(e.state.env,"COMP_WORDS__length","0"),b.set("COMP_CWORD",x(e.state.env,"COMP_CWORD")),w(e.state.env,"COMP_CWORD","-1"),b.set("COMP_LINE",x(e.state.env,"COMP_LINE")),w(e.state.env,"COMP_LINE",""),b.set("COMP_POINT",x(e.state.env,"COMP_POINT")),w(e.state.env,"COMP_POINT","0");let C=new Map;for(let L of e.state.env.keys())(L==="COMPREPLY"||L.startsWith("COMPREPLY_")||L==="COMPREPLY__length")&&(C.set(L,x(e.state.env,L)),e.state.env.delete(L));let A=["compgen",h[0]??"",""];try{let L=await zt(e,y,A,p);if(L.exitCode!==0)return Ke(e,b),Ke(e,C),T(p,L.stderr,1);v=z(L.stdout);let I=Hi(e);m.push(...I)}catch{return Ke(e,b),Ke(e,C),T(p,p,1)}Ke(e,b),Ke(e,C)}}if(d!==null)try{let y=Se(d),b=await e.executeScript(y);if(b.exitCode!==0)return T(p,b.stderr,b.exitCode);if(b.stdout.length>0){let C=z(b.stdout).split(`
|
|
51
|
+
`);for(let A of C)A.length>0&&m.push(A)}}catch(y){if(y.name==="ParseException")return P(`compgen: -C: ${y.message}
|
|
52
|
+
`,2);throw y}let $=m;if(l!==null){let y=l.startsWith("!"),b=y?l.slice(1):l;$=m.filter(C=>{let A=qe(C,b,!1,!0);return y?A:!A})}if($.length===0&&o!==null)return T(E(v),p,1);let _=$.map(y=>`${n}${y}${i}`).join(`
|
|
53
|
+
`),k=v+(_?`${_}
|
|
54
|
+
`:"");return U(k)}function Ti(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 Di(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 Ii(e,t){let s=Array.from(e.state.functions.keys());return t!==null&&(s=s.filter(r=>r.startsWith(t))),s.sort()}function Ri(e){let t=[...vs];return e!==null&&(t=t.filter(s=>s.startsWith(e))),t.sort()}function Li(e){let t=[...Jr];return e!==null&&(t=t.filter(s=>s.startsWith(e))),t.sort()}function Mi(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 Fi(e){let t=[...xi];return e!==null&&(t=t.filter(s=>s.startsWith(e))),t.sort()}function Wi(e){let t=[...Oi];return e!==null&&(t=t.filter(s=>s.startsWith(e))),t.sort()}async function ws(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 Qr(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 Vi(e){return["root","nobody"]}async function zi(e,t){let s=new Set;for(let i of vs)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 Jr)s.add(i);let r=x(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 Bi(e,t){let r=new H().parseWordFromString(t,!1,!1);return await F(e,r)}function ji(e,t){let s=x(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 Ke(e,t){for(let[s,r]of t)r===void 0?e.state.env.delete(s):w(e.state.env,s,r)}function Hi(e){let t=[];if(e.state.env.get("COMPREPLY__length")!==void 0){let n=be(e,"COMPREPLY");for(let[,i]of n)t.push(i)}else e.state.env.has("COMPREPLY")&&t.push(x(e.state.env,"COMPREPLY"));return t}var Ui=["bashdefault","default","dirnames","filenames","noquote","nosort","nospace","plusdirs"];function Ss(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 d=t[f];if(d==="-p")s=!0;else if(d==="-r")r=!0;else if(d==="-D")n=!0;else if(d==="-W"){if(f++,f>=t.length)return P(`complete: -W: option requires an argument
|
|
56
|
+
`,2);i=t[f]}else if(d==="-F"){if(f++,f>=t.length)return P(`complete: -F: option requires an argument
|
|
57
|
+
`,2);o=t[f]}else if(d==="-o"){if(f++,f>=t.length)return P(`complete: -o: option requires an argument
|
|
58
|
+
`,2);let h=t[f];if(!Ui.includes(h))return P(`complete: ${h}: invalid option name
|
|
59
|
+
`,2);c.push(h)}else if(d==="-A"){if(f++,f>=t.length)return P(`complete: -A: option requires an argument
|
|
60
|
+
`,2);u.push(t[f])}else if(d==="-C"){if(f++,f>=t.length)return P(`complete: -C: option requires an argument
|
|
61
|
+
`,2);a=t[f]}else if(d==="-G"){if(f++,f>=t.length)return P(`complete: -G: option requires an argument
|
|
62
|
+
`,2)}else if(d==="-P"){if(f++,f>=t.length)return P(`complete: -P: option requires an argument
|
|
63
|
+
`,2)}else if(d==="-S"){if(f++,f>=t.length)return P(`complete: -S: option requires an argument
|
|
64
|
+
`,2)}else if(d==="-X"){if(f++,f>=t.length)return P(`complete: -X: option requires an argument
|
|
65
|
+
`,2)}else if(d==="--"){l.push(...t.slice(f+1));break}else d.startsWith("-")||l.push(d)}if(r){if(l.length===0)return e.state.completionSpecs.clear(),ye();for(let f of l)e.state.completionSpecs.delete(f);return ye()}if(s)return l.length===0?Es(e):Es(e,l);if(t.length===0||l.length===0&&!i&&!o&&!a&&c.length===0&&u.length===0&&!n)return Es(e);if(o&&l.length===0&&!n)return P(`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),ye()}for(let f of l){let d=Object.create(null);i!==void 0&&(d.wordlist=i),o!==void 0&&(d.function=o),a!==void 0&&(d.command=a),c.length>0&&(d.options=c),u.length>0&&(d.actions=u),e.state.completionSpecs.set(f,d)}return ye(p)}function Es(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 T(p,E(i),1)}return ye()}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 T(E(r.join(`
|
|
68
|
+
`)+(r.length>0?`
|
|
69
|
+
`:"")),E(`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?ye():U(`${r.join(`
|
|
71
|
+
`)}
|
|
72
|
+
`)}var en=["bashdefault","default","dirnames","filenames","noquote","nosort","nospace","plusdirs"];function $s(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 P(`compopt: -o: option requires an argument
|
|
73
|
+
`,2);let u=t[a];if(!en.includes(u))return P(`compopt: ${u}: invalid option name
|
|
74
|
+
`,2);n.push(u)}else if(c==="+o"){if(a++,a>=t.length)return P(`compopt: +o: option requires an argument
|
|
75
|
+
`,2);let u=t[a];if(!en.includes(u))return P(`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),ye()}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),ye()}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 ye()}return P(`compopt: not currently executing completion function
|
|
77
|
+
`,1)}function As(e,t){if(e.state.loopDepth===0){if(e.state.parentHasLoopContext)throw new Oe;return V}if(t.length>1)throw new G(1,p,E(`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 G(1,p,E(`bash: continue: ${t[0]}: numeric argument required
|
|
79
|
+
`));s=r}throw new me(s)}function Y(e,t){let s=x(e.state.env,"HOME","/home/user");return t.split(":").map(i=>i==="~"?s:i==="~root"?"/root":i.startsWith("~/")?s+i.slice(1):i.startsWith("~root/")?`/root${i.slice(5)}`:i).join(":")}function _s(e){for(let t=0;t<e.length;t++){let s=e.charCodeAt(t);if(s<32||s===127)return!0}return!1}function Ps(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 Bt(e){return _s(e)?Ps(e):/^[a-zA-Z0-9_/.:\-@%+,=]*$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}function Ve(e){return _s(e)?Ps(e):`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function Cs(e){return _s(e)?Ps(e):`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function tn(e,t){let s="";return e.state.integerVars?.has(t)&&(s+="i"),e.state.lowercaseVars?.has(t)&&(s+="l"),ce(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 ks(e){return e===""?"''":/[\s'\\]/.test(e)?`'${e.replace(/'/g,"'\\''")}'`:e}function sn(e,t){let s="",r="",n=!1;for(let i of t){let o=tn(e,i);if(e.state.associativeArrays?.has(i)){let u=De(e,i);if(u.length===0)s+=`declare -A ${i}=()
|
|
80
|
+
`;else{let l=u.map(f=>{let d=x(e.state.env,`${i}_${f}`,""),h=ks(d);return`['${f}']=${h}`});s+=`declare -A ${i}=(${l.join(" ")})
|
|
81
|
+
`}continue}let c=se(e,i);if(c.length>0){let u=c.map(l=>{let f=x(e.state.env,`${i}_${l}`,"");return`[${l}]=${Ve(f)}`});s+=`declare -a ${i}=(${u.join(" ")})
|
|
82
|
+
`;continue}if(e.state.env.has(`${i}__length`)){s+=`declare -a ${i}=()
|
|
83
|
+
`;continue}if(e.state.env.has(i)){let u=x(e.state.env,i);s+=`declare ${o} ${i}=${Cs(u)}
|
|
84
|
+
`}else{let u=e.state.declaredVars?.has(i),l=e.state.localVarDepth?.has(i);u||l?s+=`declare ${o} ${i}
|
|
85
|
+
`:(r+=`bash: declare: ${i}: not found
|
|
86
|
+
`,n=!0)}}return T(E(s),E(r),n?1:0)}function rn(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 h=f.slice(0,-8);u.add(h);continue}let d=f.lastIndexOf("_");if(d>0){let h=f.slice(0,d),g=f.slice(d+1);if(/^\d+$/.test(g)||e.state.associativeArrays?.has(h)){u.add(h);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 d=tn(e,f),h=e.state.associativeArrays?.has(f),g=se(e,f),m=!h&&(g.length>0||e.state.env.has(`${f}__length`));if(!(a&&(o&&!h||i&&!m||s&&!e.state.exportedVars?.has(f)||r&&!e.state.readonlyVars?.has(f)||n&&!ce(e,f)))){if(h){let v=De(e,f);if(v.length===0)c+=`declare -A ${f}=()
|
|
87
|
+
`;else{let $=v.map(_=>{let k=x(e.state.env,`${f}_${_}`,""),y=ks(k);return`['${_}']=${y}`});c+=`declare -A ${f}=(${$.join(" ")})
|
|
88
|
+
`}continue}if(g.length>0){let v=g.map($=>{let _=x(e.state.env,`${f}_${$}`,"");return`[${$}]=${Ve(_)}`});c+=`declare -a ${f}=(${v.join(" ")})
|
|
89
|
+
`;continue}if(e.state.env.has(`${f}__length`)){c+=`declare -a ${f}=()
|
|
90
|
+
`;continue}if(e.state.env.has(f)){let v=x(e.state.env,f);c+=`declare ${d} ${f}=${Cs(v)}
|
|
91
|
+
`}}}return U(c)}function nn(e){let t="",s=Array.from(e.state.associativeArrays??[]).sort();for(let r of s){let n=De(e,r);if(n.length===0)t+=`declare -A ${r}=()
|
|
92
|
+
`;else{let i=n.map(o=>{let a=x(e.state.env,`${r}_${o}`,""),c=ks(a);return`['${o}']=${c}`});t+=`declare -A ${r}=(${i.join(" ")})
|
|
93
|
+
`}}return U(t)}function on(e){let t="",s=new Set;for(let n of e.state.env.keys()){if(n.startsWith("BASH_"))continue;if(n.endsWith("__length")){let o=n.slice(0,-8);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=se(e,n);if(i.length===0)t+=`declare -a ${n}=()
|
|
94
|
+
`;else{let o=i.map(a=>{let c=x(e.state.env,`${n}_${a}`,"");return`[${a}]=${Ve(c)}`});t+=`declare -a ${n}=(${o.join(" ")})
|
|
95
|
+
`}}return U(t)}function an(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)||se(e,n).length>0||e.state.env.has(`${n}__length`)||e.state.env.has(n)&&(t+=`${n}=${Bt(x(e.state.env,n))}
|
|
96
|
+
`);return U(t)}function Ns(e,t){e.state.integerVars??=new Set,e.state.integerVars.add(t)}function ot(e,t){return e.state.integerVars?.has(t)??!1}function xs(e,t){e.state.lowercaseVars??=new Set,e.state.lowercaseVars.add(t),e.state.uppercaseVars?.delete(t)}function Gi(e,t){return e.state.lowercaseVars?.has(t)??!1}function Os(e,t){e.state.uppercaseVars??=new Set,e.state.uppercaseVars.add(t),e.state.lowercaseVars?.delete(t)}function qi(e,t){return e.state.uppercaseVars?.has(t)??!1}function Xe(e,t,s){return Gi(e,t)?s.toLowerCase():qi(e,t)?s.toUpperCase():s}async function ln(e,t){try{let s=new H,r=Q(s,t),n=await q(e,r.expression);return String(n)}catch{return"0"}}function Zi(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 Ts(e,t){let s=!1,r=!1,n=!1,i=!1,o=!1,a=!1,c=!1,u=!1,l=!1,f=!1,d=!1,h=!1,g=!1,m=!1,v=!1,$=[];for(let I=0;I<t.length;I++){let W=t[I];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==="+n")c=!0;else if(W==="+a")u=!0;else if(W==="+x")l=!0;else if(W==="--"){$.push(...t.slice(I+1));break}else if(W.startsWith("+")){for(let B of W.slice(1))if(B==="n")c=!0;else if(B==="a")u=!0;else if(B==="x")l=!0;else if(B!=="r"){if(B!=="i"){if(!(B==="f"||B==="F"))return T(p,E(`bash: typeset: +${B}: invalid option
|
|
97
|
+
`),2)}}}else if(W==="-i")f=!0;else if(W==="-l")d=!0;else if(W==="-u")h=!0;else if(W==="-f")g=!0;else if(W==="-F")m=!0;else if(W==="-g")v=!0;else if(W.startsWith("-"))for(let B of W.slice(1))if(B==="a")s=!0;else if(B==="A")r=!0;else if(B==="r")n=!0;else if(B==="x")i=!0;else if(B==="p")o=!0;else if(B==="n")a=!0;else if(B==="i")f=!0;else if(B==="l")d=!0;else if(B==="u")h=!0;else if(B==="f")g=!0;else if(B==="F")m=!0;else if(B==="g")v=!0;else return T(p,E(`bash: typeset: -${B}: invalid option
|
|
98
|
+
`),2);else $.push(W)}let k=e.state.localScopes.length>0&&!v,y=I=>{if(!k)return;let W=e.state.localScopes[e.state.localScopes.length-1];W.has(I)||W.set(I,e.state.env.get(I))},b=I=>{if(!k)return;let W=e.state.localScopes[e.state.localScopes.length-1];W.has(I)||W.set(I,e.state.env.get(I));let B=`${I}_`;for(let O of e.state.env.keys())O.startsWith(B)&&!O.includes("__")&&(W.has(O)||W.set(O,e.state.env.get(O)));let D=`${I}__length`;e.state.env.has(D)&&!W.has(D)&&W.set(D,e.state.env.get(D))},C=I=>{k&&Le(e,I)};if(m){if($.length===0){let B=Array.from(e.state.functions.keys()).sort(),D="";for(let O of B)D+=`declare -f ${O}
|
|
99
|
+
`;return U(D)}let I=!0,W="";for(let B of $)e.state.functions.has(B)?W+=`${B}
|
|
100
|
+
`:I=!1;return T(E(W),p,I?0:1)}if(g){if($.length===0){let W="",B=Array.from(e.state.functions.keys()).sort();for(let D of B)W+=`${D} ()
|
|
101
|
+
{
|
|
102
|
+
# function body
|
|
103
|
+
}
|
|
104
|
+
`;return U(W)}let I=!0;for(let W of $)e.state.functions.has(W)||(I=!1);return T(p,p,I?0:1)}if(o&&$.length>0)return sn(e,$);if(o&&$.length===0)return rn(e,{filterExport:i,filterReadonly:n,filterNameref:a,filterIndexedArray:s,filterAssocArray:r});if($.length===0&&r&&!o)return nn(e);if($.length===0&&s&&!o)return on(e);if($.length===0&&!o)return an(e);let A="",L=0;for(let I of $){let W=I.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(W&&!u){let S=W[1],R=W[2];if(r&&se(e,S).length>0){A+=`bash: declare: ${S}: cannot convert indexed to associative array
|
|
105
|
+
`,L=1;continue}if((s||!r&&!s)&&e.state.associativeArrays?.has(S)){A+=`bash: declare: ${S}: cannot convert associative to indexed array
|
|
106
|
+
`,L=1;continue}if(b(S),r&&(e.state.associativeArrays??=new Set,e.state.associativeArrays.add(S)),$e(e,S),e.state.env.delete(S),e.state.env.delete(`${S}__length`),r&&R.includes("[")){let M=Mt(R);for(let[ee,j]of M){let K=Y(e,j);w(e.state.env,`${S}_${ee}`,K)}}else if(r){let M=Pe(R);for(let ee=0;ee<M.length;ee+=2){let j=M[ee],K=ee+1<M.length?Y(e,M[ee+1]):"";w(e.state.env,`${S}_${j}`,K)}}else{let M=Pe(R);if(M.some(j=>/^\[[^\]]+\]=/.test(j))){let j=0;for(let K of M){let ne=K.match(/^\[([^\]]+)\]=(.*)$/);if(ne){let he=ne[1],ze=ne[2],ei=Y(e,ze),et;if(/^-?\d+$/.test(he))et=Number.parseInt(he,10);else try{let ti=new H,si=Q(ti,he);et=await q(e,si.expression)}catch{et=0}w(e.state.env,`${S}_${et}`,ei),j=et+1}else{let he=Y(e,K);w(e.state.env,`${S}_${j}`,he),j++}}}else{for(let j=0;j<M.length;j++)w(e.state.env,`${S}_${j}`,M[j]);w(e.state.env,`${S}__length`,String(M.length))}}C(S),n&&ue(e,S),i&&Ee(e,S);continue}if(c){let S=I.includes("=")?I.slice(0,I.indexOf("=")):I;if(hr(e,S),!I.includes("="))continue}if(l){let S=I.includes("=")?I.slice(0,I.indexOf("=")):I;if(St(e,S),!I.includes("="))continue}let B=Zi(I);if(B){let{name:S,indexExpr:R,value:M}=B,ee=te(e,S);if(ee)return ee;b(S);let j;try{let ne=new H,he=Q(ne,R);j=await q(e,he.expression)}catch{let ne=parseInt(R,10);j=Number.isNaN(ne)?0:ne}w(e.state.env,`${S}_${j}`,M);let K=parseInt(x(e.state.env,`${S}__length`,"0"),10);j>=K&&w(e.state.env,`${S}__length`,String(j+1)),C(S),n&&ue(e,S),i&&Ee(e,S);continue}let D=I.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=\((.*)\)$/s);if(D&&!u){let S=D[1],R=D[2],M=te(e,S);if(M)return M;b(S);let ee=Pe(R);if(e.state.associativeArrays?.has(S)){let j=Mt(R);for(let[K,ne]of j){let he=Y(e,ne);w(e.state.env,`${S}_${K}`,he)}}else{let j=se(e,S),K=0,ne=e.state.env.get(S);j.length===0&&ne!==void 0?(e.state.env.set(`${S}_0`,ne),e.state.env.delete(S),K=1):j.length>0&&(K=Math.max(...j)+1);for(let ze=0;ze<ee.length;ze++)w(e.state.env,`${S}_${K+ze}`,Y(e,ee[ze]));let he=K+ee.length;w(e.state.env,`${S}__length`,String(he))}C(S),n&&ue(e,S),i&&Ee(e,S);continue}let O=I.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(O){let S=O[1],R=Y(e,O[2]),M=te(e,S);if(M)return M;y(S),f&&Ns(e,S),d&&xs(e,S),h&&Os(e,S);let j=se(e,S).length>0||e.state.associativeArrays?.has(S);if(ot(e,S)){let K=x(e.state.env,S,"0"),ne=parseInt(K,10)||0,he=parseInt(await ln(e,R),10)||0;R=String(ne+he),w(e.state.env,S,R)}else if(j){R=Xe(e,S,R);let K=`${S}_0`,ne=x(e.state.env,K);w(e.state.env,K,ne+R)}else{R=Xe(e,S,R);let K=x(e.state.env,S);w(e.state.env,S,K+R)}C(S),n&&ue(e,S),i&&Ee(e,S),e.state.options.allexport&&!l&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(S));continue}if(I.includes("=")){let S=I.indexOf("="),R=I.slice(0,S),M=I.slice(S+1);if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(R)){A+=`bash: typeset: \`${R}': not a valid identifier
|
|
107
|
+
`,L=1;continue}let ee=te(e,R);if(ee)return ee;if(y(R),a){if(M!==""&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(M)){A+=`bash: declare: \`${M}': invalid variable name for name reference
|
|
108
|
+
`,L=1;continue}w(e.state.env,R,M),Ne(e,R),M!==""&&ss(e,M)&&ts(e,R),C(R),n&&ue(e,R),i&&Ee(e,R);continue}if(f&&Ns(e,R),d&&xs(e,R),h&&Os(e,R),ot(e,R)&&(M=await ln(e,M)),M=Xe(e,R,M),ce(e,R)){let j=Ae(e,R);j&&j!==R?w(e.state.env,j,M):w(e.state.env,R,M)}else w(e.state.env,R,M);C(R),n&&ue(e,R),i&&Ee(e,R),e.state.options.allexport&&!l&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(R))}else{let S=I;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(S)){A+=`bash: typeset: \`${S}': not a valid identifier
|
|
109
|
+
`,L=1;continue}if(s||r?b(S):y(S),a){Ne(e,S);let M=x(e.state.env,S);M!==""&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(M)?pr(e,S):M&&ss(e,M)&&ts(e,S),C(S),n&&ue(e,S),i&&Ee(e,S);continue}if(f&&Ns(e,S),d&&xs(e,S),h&&Os(e,S),r){if(se(e,S).length>0){A+=`bash: declare: ${S}: cannot convert indexed to associative array
|
|
110
|
+
`,L=1;continue}e.state.associativeArrays??=new Set,e.state.associativeArrays.add(S)}let R=Array.from(e.state.env.keys()).some(M=>M.startsWith(`${S}_`)&&!M.startsWith(`${S}__length`));!e.state.env.has(S)&&!R&&(s||r?w(e.state.env,`${S}__length`,"0"):(e.state.declaredVars??=new Set,e.state.declaredVars.add(S))),C(S),n&&ue(e,S),i&&Ee(e,S)}}return T(p,E(A),L)}async function Ds(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=z(u??p).replace(/\\/g,"\\\\").replace(/"/g,'\\"');o+=`declare -r ${c}="${l}"
|
|
111
|
+
`}}return U(o)}for(let o of i){let a=o.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=\((.*)\)$/s);if(a){let f=a[1],d=a[2],h=te(e,f);if(h)return h;let g=Pe(d);if(e.state.associativeArrays?.has(f)){let m=Mt(d);for(let[v,$]of m){let _=Y(e,$);w(e.state.env,`${f}_${v}`,_)}}else{let m=se(e,f),v=0,$=e.state.env.get(f);m.length===0&&$!==void 0?(e.state.env.set(`${f}_0`,$),e.state.env.delete(f),v=1):m.length>0&&(v=Math.max(...m)+1);for(let k=0;k<g.length;k++)w(e.state.env,`${f}_${v+k}`,Y(e,g[k]));let _=v+g.length;w(e.state.env,`${f}__length`,String(_))}ue(e,f);continue}let c=o.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(c){let f=c[1],d=Y(e,c[2]),h=te(e,f);if(h)return h;let g=x(e.state.env,f);w(e.state.env,f,g+d),ue(e,f);continue}let u=Ur(o);if(u.value===void 0&&!u.isArray){ue(e,u.name);continue}let l=await Gr(e,u,{makeReadonly:!0});if(l)return l}return V}function Is(e){return e.state.directoryStack??=[],e.state.directoryStack}function at(e,t){return t&&e===t?"~":t&&e.startsWith(`${t}/`)?`~${e.slice(t.length)}`:e}function Yi(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 Rs(e,t){let s=Is(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 P(`bash: pushd: too many arguments
|
|
112
|
+
`,2);r=t[a+1],a++}}else{if(c.startsWith("-")&&c!=="-")return P(`bash: pushd: ${c}: invalid option
|
|
113
|
+
`,2);if(r!==void 0)return P(`bash: pushd: too many arguments
|
|
114
|
+
`,2);r=c}}if(r===void 0){if(s.length<2)return P(`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=x(e.state.env,"HOME","/")+r.slice(1):n=`${e.state.cwd}/${r}`;n=Yi(n);try{if(!(await e.fs.stat(n)).isDirectory)return P(`bash: pushd: ${r}: Not a directory
|
|
116
|
+
`,1)}catch{return P(`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,w(e.state.env,"PWD",n),w(e.state.env,"OLDPWD",e.state.previousDir);let i=x(e.state.env,"HOME",""),o=`${[n,...s].map(a=>at(a,i)).join(" ")}
|
|
118
|
+
`;return U(o)}function Ls(e,t){let s=Is(e);for(let o of t)if(o!=="--")return o.startsWith("-")&&o!=="-"?P(`bash: popd: ${o}: invalid option
|
|
119
|
+
`,2):P(`bash: popd: too many arguments
|
|
120
|
+
`,2);if(s.length===0)return P(`bash: popd: directory stack empty
|
|
121
|
+
`,1);let r=s.shift();if(!r)return P(`bash: popd: directory stack empty
|
|
122
|
+
`,1);e.state.previousDir=e.state.cwd,e.state.cwd=r,w(e.state.env,"PWD",r),w(e.state.env,"OLDPWD",e.state.previousDir);let n=x(e.state.env,"HOME",""),i=`${[r,...s].map(o=>at(o,n)).join(" ")}
|
|
123
|
+
`;return U(i)}function Ms(e,t){let s=Is(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 P(`bash: dirs: -${f}: invalid option
|
|
124
|
+
`,2);else return P(`bash: dirs: too many arguments
|
|
125
|
+
`,1);if(r)return e.state.directoryStack=[],V;let a=[e.state.cwd,...s],c=x(e.state.env,"HOME",""),u;return o?(u=a.map((l,f)=>{let d=n?l:at(l,c);return` ${f} ${d}`}).join(`
|
|
126
|
+
`),u+=`
|
|
127
|
+
`):i?u=a.map(l=>n?l:at(l,c)).join(`
|
|
128
|
+
`)+`
|
|
129
|
+
`:u=a.map(l=>n?l:at(l,c)).join(" ")+`
|
|
130
|
+
`,U(u)}async function jt(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 P(`bash: eval: ${a}: invalid option
|
|
131
|
+
eval: usage: eval [arg ...]
|
|
132
|
+
`,2)}if(r.length===0)return V;let n=r.join(" ");if(n.trim()==="")return V;let i=e.state.groupStdin,o=s??e.state.groupStdin;o!==void 0&&(e.state.groupStdin=o);try{let a=Se(n);return await e.executeScript(a)}catch(a){if(a instanceof pe||a instanceof me||a instanceof le||a instanceof G)throw a;if(a.name==="ParseException")return P(`bash: eval: ${a.message}
|
|
133
|
+
`);throw a}finally{e.state.groupStdin=i}}function Fs(e,t){let s,r=p;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=E(`bash: exit: ${n}: numeric argument required
|
|
134
|
+
`),s=2):s=(i%256+256)%256}throw new G(s,p,r)}function Ws(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=z(l??p).replace(/\\/g,"\\\\").replace(/"/g,'\\"');o+=`declare -x ${u}="${f}"
|
|
135
|
+
`}}return U(o)}if(s){for(let o of r){let a,c;if(o.includes("=")){let u=o.indexOf("=");a=o.slice(0,u),c=Y(e,o.slice(u+1)),w(e.state.env,a,c)}else a=o;St(e,a)}return V}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=Y(e,l[2]),u=!0;else if(o.includes("=")){let f=o.indexOf("=");a=o.slice(0,f),c=Y(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=x(e.state.env,a);w(e.state.env,a,f+c)}else w(e.state.env,a,c);else e.state.env.has(a)||w(e.state.env,a,"");Ee(e,a)}return T(p,E(n),i)}function Ht(e,t){if(t.length<2)return P(`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 m=Number.parseInt(x(e.state.env,"#","0"),10);a=[];for(let v=1;v<=m;v++)a.push(x(e.state.env,String(v))||"")}let c=Number.parseInt(x(e.state.env,"OPTIND","1"),10);c<1&&(c=1);let u=Number.parseInt(x(e.state.env,"__GETOPTS_CHARINDEX","0"),10);if(w(e.state.env,"OPTARG",""),c>a.length)return n||w(e.state.env,r,"?"),w(e.state.env,"OPTIND",String(a.length+1)),w(e.state.env,"__GETOPTS_CHARINDEX","0"),{exitCode:n?2:1,stdout:p,stderr:p};let l=a[c-1];if(!l||l==="-"||!l.startsWith("-"))return n||w(e.state.env,r,"?"),{exitCode:n?2:1,stdout:p,stderr:p};if(l==="--")return w(e.state.env,"OPTIND",String(c+1)),w(e.state.env,"__GETOPTS_CHARINDEX","0"),n||w(e.state.env,r,"?"),{exitCode:n?2:1,stdout:p,stderr:p};let f=u===0?1:u,d=l[f];if(!d)return w(e.state.env,"OPTIND",String(c+1)),w(e.state.env,"__GETOPTS_CHARINDEX","0"),Ht(e,t);let h=o.indexOf(d);if(h===-1){let m="";return i?w(e.state.env,"OPTARG",d):m=`bash: illegal option -- ${d}
|
|
138
|
+
`,n||w(e.state.env,r,"?"),f+1<l.length?(w(e.state.env,"__GETOPTS_CHARINDEX",String(f+1)),w(e.state.env,"OPTIND",String(c))):(w(e.state.env,"OPTIND",String(c+1)),w(e.state.env,"__GETOPTS_CHARINDEX","0")),{exitCode:n?2:0,stdout:p,stderr:E(m)}}if(h+1<o.length&&o[h+1]===":")if(f+1<l.length)w(e.state.env,"OPTARG",l.slice(f+1)),w(e.state.env,"OPTIND",String(c+1)),w(e.state.env,"__GETOPTS_CHARINDEX","0");else{if(c>=a.length){let m="";return i?(w(e.state.env,"OPTARG",d),n||w(e.state.env,r,":")):(m=`bash: option requires an argument -- ${d}
|
|
139
|
+
`,n||w(e.state.env,r,"?")),w(e.state.env,"OPTIND",String(c+1)),w(e.state.env,"__GETOPTS_CHARINDEX","0"),{exitCode:n?2:0,stdout:p,stderr:E(m)}}w(e.state.env,"OPTARG",a[c]),w(e.state.env,"OPTIND",String(c+2)),w(e.state.env,"__GETOPTS_CHARINDEX","0")}else f+1<l.length?(w(e.state.env,"__GETOPTS_CHARINDEX",String(f+1)),w(e.state.env,"OPTIND",String(c))):(w(e.state.env,"OPTIND",String(c+1)),w(e.state.env,"__GETOPTS_CHARINDEX","0"));return n||w(e.state.env,r,d),{exitCode:n?2:0,stdout:p,stderr:p}}async function Vs(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 g=t[u];if(g==="--"){u++,c.push(...t.slice(u));break}if(g==="-r")s=!0,u++;else if(g==="-d")r=!0,u++;else if(g==="-l")n=!0,u++;else if(g==="-t")o=!0,u++;else if(g==="-p"){if(i=!0,u++,u>=t.length)return P(`bash: hash: -p: option requires an argument
|
|
140
|
+
`,1);a=t[u],u++}else if(g.startsWith("-")&&g.length>1){for(let m of g.slice(1))if(m==="r")s=!0;else if(m==="d")r=!0;else if(m==="l")n=!0;else if(m==="t")o=!0;else return m==="p"?P(`bash: hash: -p: option requires an argument
|
|
141
|
+
`,1):P(`bash: hash: -${m}: invalid option
|
|
142
|
+
`,1);u++}else c.push(g),u++}if(s)return e.state.hashTable.clear(),V;if(r){if(c.length===0)return P(`bash: hash: -d: option requires an argument
|
|
143
|
+
`,1);let g=!1,m="";for(let v of c)e.state.hashTable.has(v)?e.state.hashTable.delete(v):(m+=`bash: hash: ${v}: not found
|
|
144
|
+
`,g=!0);return g?P(m,1):V}if(o){if(c.length===0)return P(`bash: hash: -t: option requires an argument
|
|
145
|
+
`,1);let g="",m=!1,v="";for(let $ of c){let _=e.state.hashTable.get($);_?c.length>1?g+=`${$} ${_}
|
|
146
|
+
`:g+=`${_}
|
|
147
|
+
`:(v+=`bash: hash: ${$}: not found
|
|
148
|
+
`,m=!0)}return m?{exitCode:1,stdout:E(g),stderr:E(v)}:U(g)}if(i){if(c.length===0)return P(`bash: hash: usage: hash [-lr] [-p pathname] [-dt] [name ...]
|
|
149
|
+
`,1);let g=c[0];return e.state.hashTable.set(g,a),V}if(c.length===0){if(e.state.hashTable.size===0)return U(`hash: hash table empty
|
|
150
|
+
`);let g="";if(n)for(let[m,v]of e.state.hashTable)g+=`builtin hash -p ${v} ${m}
|
|
151
|
+
`;else{g=`hits command
|
|
152
|
+
`;for(let[,m]of e.state.hashTable)g+=` 1 ${m}
|
|
153
|
+
`}return U(g)}let l=!1,f="",h=x(e.state.env,"PATH","/usr/bin:/bin").split(":");for(let g of c){if(g.includes("/")){f+=`bash: hash: ${g}: cannot use / in name
|
|
154
|
+
`,l=!0;continue}let m=!1;for(let v of h){if(!v)continue;let $=`${v}/${g}`;if(await e.fs.exists($)){e.state.hashTable.set(g,$),m=!0;break}}m||(f+=`bash: hash: ${g}: not found
|
|
155
|
+
`,l=!0)}return l?P(f,1):V}var cn=new Map([[":",[": [arguments]",`Null command.
|
|
156
|
+
No effect; the command does nothing.
|
|
157
|
+
Exit Status:
|
|
158
|
+
Always succeeds.`]],[".",[". filename [arguments]",`Execute commands from a file in the current shell.
|
|
159
|
+
Read and execute commands from FILENAME in the current shell.
|
|
160
|
+
The entries in $PATH are used to find the directory containing FILENAME.
|
|
161
|
+
Exit Status:
|
|
162
|
+
Returns the status of the last command executed in FILENAME.`]],["[",["[ arg... ]",`Evaluate conditional expression.
|
|
163
|
+
This is a synonym for the "test" builtin, but the last argument must
|
|
164
|
+
be a literal \`]', to match the opening \`['.`]],["alias",["alias [-p] [name[=value] ... ]",`Define or display aliases.
|
|
165
|
+
Without arguments, \`alias' prints the list of aliases in the reusable
|
|
166
|
+
form \`alias NAME=VALUE' on standard output.
|
|
167
|
+
Exit Status:
|
|
168
|
+
alias returns true unless a NAME is supplied for which no alias has been
|
|
169
|
+
defined.`]],["bg",["bg [job_spec ...]",`Move jobs to the background.
|
|
170
|
+
Place the jobs identified by each JOB_SPEC in the background, as if they
|
|
171
|
+
had been started with \`&'.`]],["break",["break [n]",`Exit for, while, or until loops.
|
|
172
|
+
Exit a FOR, WHILE or UNTIL loop. If N is specified, break N enclosing
|
|
173
|
+
loops.
|
|
174
|
+
Exit Status:
|
|
175
|
+
The exit status is 0 unless N is not greater than or equal to 1.`]],["builtin",["builtin [shell-builtin [arg ...]]",`Execute shell builtins.
|
|
176
|
+
Execute SHELL-BUILTIN with arguments ARGs without performing command
|
|
177
|
+
lookup. This is useful when you wish to reimplement a shell builtin
|
|
178
|
+
as a shell function, but need to execute the builtin within the function.
|
|
179
|
+
Exit Status:
|
|
180
|
+
Returns the exit status of SHELL-BUILTIN, or false if SHELL-BUILTIN is
|
|
181
|
+
not a shell builtin.`]],["caller",["caller [expr]",`Return the context of the current subroutine call.
|
|
182
|
+
Without EXPR, returns "$line $filename". With EXPR, returns
|
|
183
|
+
"$line $subroutine $filename"; this extra information can be used to
|
|
184
|
+
provide a stack trace.
|
|
185
|
+
Exit Status:
|
|
186
|
+
Returns 0 unless the shell is not executing a subroutine call or
|
|
187
|
+
EXPR is invalid.`]],["cd",["cd [-L|-P] [dir]",`Change the shell working directory.
|
|
188
|
+
Change the current directory to DIR. The default DIR is the value of the
|
|
189
|
+
HOME shell variable.
|
|
190
|
+
|
|
191
|
+
The variable CDPATH defines the search path for the directory containing
|
|
192
|
+
DIR. Alternative directory names in CDPATH are separated by a colon (:).
|
|
193
|
+
A null directory name is the same as the current directory. If DIR begins
|
|
194
|
+
with a slash (/), then CDPATH is not used.
|
|
195
|
+
|
|
196
|
+
If the directory is not found, and the shell option \`cdable_vars' is set,
|
|
197
|
+
the word is assumed to be a variable name. If that variable has a value,
|
|
198
|
+
its value is used for DIR.
|
|
199
|
+
|
|
200
|
+
Options:
|
|
201
|
+
-L force symbolic links to be followed
|
|
202
|
+
-P use the physical directory structure without following symbolic
|
|
203
|
+
links
|
|
204
|
+
|
|
205
|
+
The default is to follow symbolic links, as if \`-L' were specified.
|
|
206
|
+
|
|
207
|
+
Exit Status:
|
|
208
|
+
Returns 0 if the directory is changed; non-zero otherwise.`]],["command",["command [-pVv] command [arg ...]",`Execute a simple command or display information about commands.
|
|
209
|
+
Runs COMMAND with ARGS suppressing shell function lookup, or display
|
|
210
|
+
information about the specified COMMANDs.
|
|
211
|
+
|
|
212
|
+
Options:
|
|
213
|
+
-p use a default value for PATH that is guaranteed to find all of
|
|
214
|
+
the standard utilities
|
|
215
|
+
-v print a description of COMMAND similar to the \`type' builtin
|
|
216
|
+
-V print a more verbose description of each COMMAND
|
|
217
|
+
|
|
218
|
+
Exit Status:
|
|
219
|
+
Returns exit status of COMMAND, or failure if COMMAND is not found.`]],["compgen",["compgen [-abcdefgjksuv] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [word]",`Display possible completions depending on the options.
|
|
220
|
+
Intended to be used from within a shell function generating possible
|
|
221
|
+
completions. If the optional WORD argument is supplied, matches against
|
|
222
|
+
WORD are generated.
|
|
223
|
+
Exit Status:
|
|
224
|
+
Returns success unless an invalid option is supplied or an error occurs.`]],["complete",["complete [-abcdefgjksuv] [-pr] [-DEI] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [name ...]",`Specify how arguments are to be completed.
|
|
225
|
+
For each NAME, specify how arguments are to be completed.
|
|
226
|
+
Exit Status:
|
|
227
|
+
Returns success unless an invalid option is supplied or an error occurs.`]],["continue",["continue [n]",`Resume for, while, or until loops.
|
|
228
|
+
Resumes the next iteration of the enclosing FOR, WHILE or UNTIL loop.
|
|
229
|
+
If N is specified, resumes the Nth enclosing loop.
|
|
230
|
+
Exit Status:
|
|
231
|
+
The exit status is 0 unless N is not greater than or equal to 1.`]],["declare",["declare [-aAfFgilnrtux] [-p] [name[=value] ...]",`Set variable values and attributes.
|
|
232
|
+
Declare variables and give them attributes. If no NAMEs are given,
|
|
233
|
+
display the attributes and values of all variables.
|
|
234
|
+
|
|
235
|
+
Options:
|
|
236
|
+
-a to make NAMEs indexed arrays (if supported)
|
|
237
|
+
-A to make NAMEs associative arrays (if supported)
|
|
238
|
+
-i to make NAMEs have the \`integer' attribute
|
|
239
|
+
-l to convert the value of each NAME to lower case on assignment
|
|
240
|
+
-n make NAME a reference to the variable named by its value
|
|
241
|
+
-r to make NAMEs readonly
|
|
242
|
+
-t to make NAMEs have the \`trace' attribute
|
|
243
|
+
-u to convert the value of each NAME to upper case on assignment
|
|
244
|
+
-x to make NAMEs export
|
|
245
|
+
|
|
246
|
+
Exit Status:
|
|
247
|
+
Returns success unless an invalid option is supplied or a variable
|
|
248
|
+
assignment error occurs.`]],["dirs",["dirs [-clpv] [+N] [-N]",`Display directory stack.
|
|
249
|
+
Display the list of currently remembered directories. Directories
|
|
250
|
+
find their way onto the list with the \`pushd' command; you can get
|
|
251
|
+
back up through the list with the \`popd' command.
|
|
252
|
+
Exit Status:
|
|
253
|
+
Returns success unless an invalid option is supplied or an error occurs.`]],["disown",["disown [-h] [-ar] [jobspec ...]",`Remove jobs from current shell.
|
|
254
|
+
Without any JOBSPECs, remove the current job.`]],["echo",["echo [-neE] [arg ...]",`Write arguments to the standard output.
|
|
255
|
+
Display the ARGs, separated by a single space character and followed by a
|
|
256
|
+
newline, on the standard output.
|
|
257
|
+
|
|
258
|
+
Options:
|
|
259
|
+
-n do not append a newline
|
|
260
|
+
-e enable interpretation of the following backslash escapes
|
|
261
|
+
-E explicitly suppress interpretation of backslash escapes
|
|
262
|
+
|
|
263
|
+
Exit Status:
|
|
264
|
+
Returns success unless a write error occurs.`]],["enable",["enable [-a] [-dnps] [-f filename] [name ...]",`Enable and disable shell builtins.
|
|
265
|
+
Enables and disables builtin shell commands.
|
|
266
|
+
Exit Status:
|
|
267
|
+
Returns success unless NAME is not a shell builtin or an error occurs.`]],["eval",["eval [arg ...]",`Execute arguments as a shell command.
|
|
268
|
+
Combine ARGs into a single string, use the result as input to the shell,
|
|
269
|
+
and execute the resulting commands.
|
|
270
|
+
Exit Status:
|
|
271
|
+
Returns exit status of command or success if command is null.`]],["exec",["exec [-cl] [-a name] [command [arguments ...]] [redirection ...]",`Replace the shell with the given command.
|
|
272
|
+
Execute COMMAND, replacing this shell with the specified program.
|
|
273
|
+
ARGUMENTS become the arguments to COMMAND. If COMMAND is not specified,
|
|
274
|
+
any redirections take effect in the current shell.
|
|
275
|
+
Exit Status:
|
|
276
|
+
Returns success unless COMMAND is not found or a redirection error occurs.`]],["exit",["exit [n]",`Exit the shell.
|
|
277
|
+
Exits the shell with a status of N. If N is omitted, the exit status
|
|
278
|
+
is that of the last command executed.`]],["export",["export [-fn] [name[=value] ...] or export -p",`Set export attribute for shell variables.
|
|
279
|
+
Marks each NAME for automatic export to the environment of subsequently
|
|
280
|
+
executed commands. If VALUE is supplied, assign VALUE before exporting.
|
|
281
|
+
|
|
282
|
+
Options:
|
|
283
|
+
-f refer to shell functions
|
|
284
|
+
-n remove the export property from each NAME
|
|
285
|
+
-p display a list of all exported variables and functions
|
|
286
|
+
|
|
287
|
+
Exit Status:
|
|
288
|
+
Returns success unless an invalid option is given or NAME is invalid.`]],["false",["false",`Return an unsuccessful result.
|
|
289
|
+
Exit Status:
|
|
290
|
+
Always fails.`]],["fc",["fc [-e ename] [-lnr] [first] [last] or fc -s [pat=rep] [command]",`Display or execute commands from the history list.
|
|
291
|
+
Exit Status:
|
|
292
|
+
Returns success or status of executed command.`]],["fg",["fg [job_spec]",`Move job to the foreground.
|
|
293
|
+
Place the job identified by JOB_SPEC in the foreground, making it the
|
|
294
|
+
current job.`]],["getopts",["getopts optstring name [arg]",`Parse option arguments.
|
|
295
|
+
Getopts is used by shell procedures to parse positional parameters
|
|
296
|
+
as options.
|
|
297
|
+
|
|
298
|
+
OPTSTRING contains the option letters to be recognized; if a letter
|
|
299
|
+
is followed by a colon, the option is expected to have an argument,
|
|
300
|
+
which should be separated from it by white space.
|
|
301
|
+
Exit Status:
|
|
302
|
+
Returns success if an option is found; fails if the end of options is
|
|
303
|
+
encountered or an error occurs.`]],["hash",["hash [-lr] [-p pathname] [-dt] [name ...]",`Remember or display program locations.
|
|
304
|
+
Determine and remember the full pathname of each command NAME.
|
|
305
|
+
Exit Status:
|
|
306
|
+
Returns success unless NAME is not found or an invalid option is given.`]],["help",["help [-s] [pattern ...]",`Display information about builtin commands.
|
|
307
|
+
Displays brief summaries of builtin commands. If PATTERN is
|
|
308
|
+
specified, gives detailed help on all commands matching PATTERN,
|
|
309
|
+
otherwise the list of help topics is printed.
|
|
310
|
+
|
|
311
|
+
Options:
|
|
312
|
+
-s output only a short usage synopsis for each topic matching
|
|
313
|
+
PATTERN
|
|
314
|
+
|
|
315
|
+
Exit Status:
|
|
316
|
+
Returns success unless PATTERN is not found.`]],["history",["history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg...]",`Display or manipulate the history list.
|
|
317
|
+
Display the history list with line numbers, prefixing each modified
|
|
318
|
+
entry with a \`*'.
|
|
319
|
+
Exit Status:
|
|
320
|
+
Returns success unless an invalid option is given or an error occurs.`]],["jobs",["jobs [-lnprs] [jobspec ...] or jobs -x command [args]",`Display status of jobs.
|
|
321
|
+
Lists the active jobs.
|
|
322
|
+
Exit Status:
|
|
323
|
+
Returns success unless an invalid option is given or an error occurs.`]],["kill",["kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]",`Send a signal to a job.
|
|
324
|
+
Send the processes identified by PID or JOBSPEC the signal named by
|
|
325
|
+
SIGSPEC or SIGNUM.
|
|
326
|
+
Exit Status:
|
|
327
|
+
Returns success unless an invalid option is given or an error occurs.`]],["let",["let arg [arg ...]",`Evaluate arithmetic expressions.
|
|
328
|
+
Evaluate each ARG as an arithmetic expression. Evaluation is done in
|
|
329
|
+
fixed-width integers with no check for overflow, though division by 0
|
|
330
|
+
is trapped and flagged as an error.
|
|
331
|
+
Exit Status:
|
|
332
|
+
If the last ARG evaluates to 0, let returns 1; 0 is returned otherwise.`]],["local",["local [option] name[=value] ...",`Define local variables.
|
|
333
|
+
Create a local variable called NAME, and give it VALUE. OPTION can
|
|
334
|
+
be any option accepted by \`declare'.
|
|
335
|
+
|
|
336
|
+
Local can only be used within a function; it makes the variable NAME
|
|
337
|
+
have a visible scope restricted to that function and its children.
|
|
338
|
+
Exit Status:
|
|
339
|
+
Returns success unless an invalid option is supplied, a variable
|
|
340
|
+
assignment error occurs, or the shell is not executing a function.`]],["logout",["logout [n]",`Exit a login shell.
|
|
341
|
+
Exits a login shell with exit status N. Returns an error if not executed
|
|
342
|
+
in a login shell.`]],["mapfile",["mapfile [-d delim] [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]",`Read lines from the standard input into an indexed array variable.
|
|
343
|
+
Read lines from the standard input into the indexed array variable ARRAY,
|
|
344
|
+
or from file descriptor FD if the -u option is supplied.
|
|
345
|
+
|
|
346
|
+
Options:
|
|
347
|
+
-d delim Use DELIM to terminate lines, instead of newline
|
|
348
|
+
-n count Copy at most COUNT lines
|
|
349
|
+
-O origin Begin assigning to ARRAY at index ORIGIN
|
|
350
|
+
-s count Discard the first COUNT lines read
|
|
351
|
+
-t Remove a trailing DELIM from each line read (default newline)
|
|
352
|
+
-u fd Read lines from file descriptor FD instead of standard input
|
|
353
|
+
|
|
354
|
+
Exit Status:
|
|
355
|
+
Returns success unless an invalid option is given or ARRAY is readonly.`]],["popd",["popd [-n] [+N | -N]",`Remove directories from stack.
|
|
356
|
+
Removes entries from the directory stack.
|
|
357
|
+
Exit Status:
|
|
358
|
+
Returns success unless an invalid argument is supplied or the directory
|
|
359
|
+
change fails.`]],["printf",["printf [-v var] format [arguments]",`Formats and prints ARGUMENTS under control of the FORMAT.
|
|
360
|
+
|
|
361
|
+
Options:
|
|
362
|
+
-v var assign the output to shell variable VAR rather than
|
|
363
|
+
display it on the standard output
|
|
364
|
+
|
|
365
|
+
FORMAT is a character string which contains three types of objects: plain
|
|
366
|
+
characters, which are simply copied to standard output; character escape
|
|
367
|
+
sequences, which are converted and copied to the standard output; and
|
|
368
|
+
format specifications, each of which causes printing of the next successive
|
|
369
|
+
argument.
|
|
370
|
+
Exit Status:
|
|
371
|
+
Returns success unless an invalid option is given or a write or assignment
|
|
372
|
+
error occurs.`]],["pushd",["pushd [-n] [+N | -N | dir]",`Add directories to stack.
|
|
373
|
+
Adds a directory to the top of the directory stack, or rotates
|
|
374
|
+
the stack, making the new top of the stack the current working
|
|
375
|
+
directory.
|
|
376
|
+
Exit Status:
|
|
377
|
+
Returns success unless an invalid argument is supplied or the directory
|
|
378
|
+
change fails.`]],["pwd",["pwd [-LP]",`Print the name of the current working directory.
|
|
379
|
+
|
|
380
|
+
Options:
|
|
381
|
+
-L print the value of $PWD if it names the current working
|
|
382
|
+
directory
|
|
383
|
+
-P print the physical directory, without any symbolic links
|
|
384
|
+
|
|
385
|
+
By default, \`pwd' behaves as if \`-L' were specified.
|
|
386
|
+
Exit Status:
|
|
387
|
+
Returns 0 unless an invalid option is given or the current directory
|
|
388
|
+
cannot be read.`]],["read",["read [-ers] [-a array] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name ...]",`Read a line from the standard input and split it into fields.
|
|
389
|
+
Reads a single line from the standard input, or from file descriptor FD
|
|
390
|
+
if the -u option is supplied. The line is split into fields as with word
|
|
391
|
+
splitting, and the first word is assigned to the first NAME, the second
|
|
392
|
+
word to the second NAME, and so on, with any leftover words assigned to
|
|
393
|
+
the last NAME.
|
|
394
|
+
Exit Status:
|
|
395
|
+
The return code is zero, unless end-of-file is encountered, read times out,
|
|
396
|
+
or an invalid file descriptor is supplied as the argument to -u.`]],["readarray",["readarray [-d delim] [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]","Read lines from a file into an array variable.\n A synonym for `mapfile'."]],["readonly",["readonly [-aAf] [name[=value] ...] or readonly -p",`Mark shell variables as unchangeable.
|
|
397
|
+
Mark each NAME as read-only; the values of these NAMEs may not be
|
|
398
|
+
changed by subsequent assignment.
|
|
399
|
+
Exit Status:
|
|
400
|
+
Returns success unless an invalid option is given or NAME is invalid.`]],["return",["return [n]",`Return from a shell function.
|
|
401
|
+
Causes a function or sourced script to exit with the return value
|
|
402
|
+
specified by N. If N is omitted, the return status is that of the
|
|
403
|
+
last command executed within the function or script.
|
|
404
|
+
Exit Status:
|
|
405
|
+
Returns N, or failure if the shell is not executing a function or script.`]],["set",["set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]",`Set or unset values of shell options and positional parameters.
|
|
406
|
+
Change the value of shell attributes and positional parameters, or
|
|
407
|
+
display the names and values of shell variables.
|
|
408
|
+
|
|
409
|
+
Options:
|
|
410
|
+
-e Exit immediately if a command exits with a non-zero status.
|
|
411
|
+
-u Treat unset variables as an error when substituting.
|
|
412
|
+
-x Print commands and their arguments as they are executed.
|
|
413
|
+
-o option-name
|
|
414
|
+
Set the variable corresponding to option-name
|
|
415
|
+
|
|
416
|
+
Exit Status:
|
|
417
|
+
Returns success unless an invalid option is given.`]],["shift",["shift [n]",`Shift positional parameters.
|
|
418
|
+
Rename the positional parameters $N+1,$N+2 ... to $1,$2 ... If N is
|
|
419
|
+
not given, it is assumed to be 1.
|
|
420
|
+
Exit Status:
|
|
421
|
+
Returns success unless N is negative or greater than $#.`]],["shopt",["shopt [-pqsu] [-o] [optname ...]",`Set and unset shell options.
|
|
422
|
+
Change the setting of each shell option OPTNAME. Without any option
|
|
423
|
+
arguments, list each supplied OPTNAME, or all shell options if no
|
|
424
|
+
OPTNAMEs are given, with an indication of whether or not each is set.
|
|
425
|
+
|
|
426
|
+
Options:
|
|
427
|
+
-o restrict OPTNAMEs to those defined for use with \`set -o'
|
|
428
|
+
-p print each shell option with an indication of its status
|
|
429
|
+
-q suppress output
|
|
430
|
+
-s enable (set) each OPTNAME
|
|
431
|
+
-u disable (unset) each OPTNAME
|
|
432
|
+
|
|
433
|
+
Exit Status:
|
|
434
|
+
Returns success if OPTNAME is enabled; fails if an invalid option is
|
|
435
|
+
given or OPTNAME is disabled.`]],["source",["source filename [arguments]",`Execute commands from a file in the current shell.
|
|
436
|
+
Read and execute commands from FILENAME in the current shell.
|
|
437
|
+
The entries in $PATH are used to find the directory containing FILENAME.
|
|
438
|
+
Exit Status:
|
|
439
|
+
Returns the status of the last command executed in FILENAME.`]],["suspend",["suspend [-f]",`Suspend shell execution.
|
|
440
|
+
Suspend the execution of this shell until it receives a SIGCONT signal.`]],["test",["test [expr]",`Evaluate conditional expression.
|
|
441
|
+
Exits with a status of 0 (true) or 1 (false) depending on
|
|
442
|
+
the evaluation of EXPR. Expressions may be unary or binary.
|
|
443
|
+
Exit Status:
|
|
444
|
+
Returns success if EXPR evaluates to true; fails if EXPR evaluates to
|
|
445
|
+
false or an invalid argument is given.`]],["times",["times",`Display process times.
|
|
446
|
+
Prints the accumulated user and system times for the shell and all of its
|
|
447
|
+
child processes.
|
|
448
|
+
Exit Status:
|
|
449
|
+
Always succeeds.`]],["trap",["trap [-lp] [[arg] signal_spec ...]",`Trap signals and other events.
|
|
450
|
+
Defines and activates handlers to be run when the shell receives signals
|
|
451
|
+
or other conditions.
|
|
452
|
+
Exit Status:
|
|
453
|
+
Returns success unless a SIGSPEC is invalid or an invalid option is given.`]],["true",["true",`Return a successful result.
|
|
454
|
+
Exit Status:
|
|
455
|
+
Always succeeds.`]],["type",["type [-afptP] name [name ...]",`Display information about command type.
|
|
456
|
+
For each NAME, indicate how it would be interpreted if used as a
|
|
457
|
+
command name.
|
|
458
|
+
|
|
459
|
+
Options:
|
|
460
|
+
-a display all locations containing an executable named NAME
|
|
461
|
+
-f suppress shell function lookup
|
|
462
|
+
-P force a PATH search for each NAME, even if it is an alias,
|
|
463
|
+
builtin, or function, and returns the name of the disk file
|
|
464
|
+
that would be executed
|
|
465
|
+
-p returns either the name of the disk file that would be executed,
|
|
466
|
+
or nothing if \`type -t NAME' would not return \`file'
|
|
467
|
+
-t output a single word which is one of \`alias', \`keyword',
|
|
468
|
+
\`function', \`builtin', \`file' or \`', if NAME is an alias,
|
|
469
|
+
shell reserved word, shell function, shell builtin, disk file,
|
|
470
|
+
or not found, respectively
|
|
471
|
+
|
|
472
|
+
Exit Status:
|
|
473
|
+
Returns success if all of the NAMEs are found; fails if any are not found.`]],["typeset",["typeset [-aAfFgilnrtux] [-p] name[=value] ...","Set variable values and attributes.\n A synonym for `declare'."]],["ulimit",["ulimit [-SHabcdefiklmnpqrstuvxPT] [limit]",`Modify shell resource limits.
|
|
474
|
+
Provides control over the resources available to the shell and processes
|
|
475
|
+
it creates, on systems that allow such control.
|
|
476
|
+
Exit Status:
|
|
477
|
+
Returns success unless an invalid option is supplied or an error occurs.`]],["umask",["umask [-p] [-S] [mode]",`Display or set file mode mask.
|
|
478
|
+
Sets the user file-creation mask to MODE. If MODE is omitted, prints
|
|
479
|
+
the current value of the mask.
|
|
480
|
+
Exit Status:
|
|
481
|
+
Returns success unless MODE is invalid or an invalid option is given.`]],["unalias",["unalias [-a] name [name ...]",`Remove each NAME from the list of defined aliases.
|
|
482
|
+
Exit Status:
|
|
483
|
+
Returns success unless a NAME is not an existing alias.`]],["unset",["unset [-f] [-v] [-n] [name ...]",`Unset values and attributes of shell variables and functions.
|
|
484
|
+
For each NAME, remove the corresponding variable or function.
|
|
485
|
+
|
|
486
|
+
Options:
|
|
487
|
+
-f treat each NAME as a shell function
|
|
488
|
+
-v treat each NAME as a shell variable
|
|
489
|
+
-n treat each NAME as a name reference and unset the variable itself
|
|
490
|
+
rather than the variable it references
|
|
491
|
+
|
|
492
|
+
Without options, unset first tries to unset a variable, and if that fails,
|
|
493
|
+
tries to unset a function.
|
|
494
|
+
Exit Status:
|
|
495
|
+
Returns success unless an invalid option is given or a NAME is read-only.`]],["wait",["wait [-fn] [id ...]",`Wait for job completion and return exit status.
|
|
496
|
+
Waits for each process identified by an ID, which may be a process ID or a
|
|
497
|
+
job specification, and reports its termination status.
|
|
498
|
+
Exit Status:
|
|
499
|
+
Returns the status of the last ID; fails if ID is invalid or an invalid
|
|
500
|
+
option is given.`]]]),un=[...cn.keys()].sort();function zs(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 P(`bash: help: -${l}: invalid option
|
|
501
|
+
`,2)}n++}else r.push(c),n++}if(r.length===0)return Xi();let i="",o=!1,a="";for(let c of r){let u=Ki(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=cn.get(l);if(!f)continue;let[d,h]=f;s?i+=`${l}: ${d}
|
|
503
|
+
`:i+=`${l}: ${d}
|
|
504
|
+
${h}
|
|
505
|
+
`}}return{exitCode:o?1:0,stdout:E(i),stderr:E(a)}}function Ki(e){let t=e.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,"."),s=st(`^${t}$`);return un.filter(r=>s.test(r))}function Xi(){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=un.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 U(`${e.join(`
|
|
506
|
+
`)}
|
|
507
|
+
`)}function Qi(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 Bs(e,t){if(t.length===0)return P(`bash: let: expression expected
|
|
508
|
+
`);let s=Qi(t),r=0;for(let n of s)try{let o=Se(`(( ${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 q(e,a.expression.expression))}}catch(i){return P(`bash: let: ${n}: ${i.message}
|
|
509
|
+
`)}return T(p,p,r===0?1:0)}async function js(e,t){if(e.state.localScopes.length===0)return P(`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 d=e.state.env.get(f);if(d!==void 0){let h=z(d);u+=`${f}=${h}
|
|
511
|
+
`}}return T(E(u),p,0)}for(let u of c){let l,f,d=u.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(d){l=d[1];let $=d[2];if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(l)){r+=`bash: local: \`${u}': not a valid identifier
|
|
512
|
+
`,n=1;continue}if(te(e,l,"bash"),!s.has(l)){s.set(l,e.state.env.get(l));let y=`${l}_`;for(let b of e.state.env.keys())b.startsWith(y)&&!b.includes("__")&&(s.has(b)||s.set(b,e.state.env.get(b)))}let _=`${l}_`;for(let y of e.state.env.keys())y.startsWith(_)&&!y.includes("__")&&e.state.env.delete(y);let k=Pe($);for(let y=0;y<k.length;y++)w(e.state.env,`${l}_${y}`,k[y]);w(e.state.env,`${l}__length`,String(k.length)),Le(e,l),i&&Ne(e,l);continue}let h=u.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=\((.*)\)$/s);if(h){l=h[1];let $=h[2];if(te(e,l,"bash"),!s.has(l)){s.set(l,e.state.env.get(l));let A=`${l}_`;for(let I of e.state.env.keys())I.startsWith(A)&&!I.includes("__")&&(s.has(I)||s.set(I,e.state.env.get(I)));let L=`${l}__length`;e.state.env.has(L)&&!s.has(L)&&s.set(L,e.state.env.get(L))}let _=Pe($),k=se(e,l),y=0,b=e.state.env.get(l);k.length===0&&b!==void 0?(e.state.env.set(`${l}_0`,b),e.state.env.delete(l),y=1):k.length>0&&(y=Math.max(...k)+1);for(let A=0;A<_.length;A++)w(e.state.env,`${l}_${y+A}`,Y(e,_[A]));let C=y+_.length;w(e.state.env,`${l}__length`,String(C)),Le(e,l),i&&Ne(e,l);continue}let g=u.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(g){l=g[1];let $=Y(e,g[2]);te(e,l,"bash"),s.has(l)||s.set(l,e.state.env.get(l));let _=x(e.state.env,l);w(e.state.env,l,_+$),Le(e,l),i&&Ne(e,l);continue}let m=u.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([^\]]+)\]=(.*)$/s);if(m){l=m[1];let $=m[2],_=Y(e,m[3]);if(te(e,l,"bash"),!s.has(l)){s.set(l,e.state.env.get(l));let b=`${l}_`;for(let A of e.state.env.keys())A.startsWith(b)&&!A.includes("__")&&(s.has(A)||s.set(A,e.state.env.get(A)));let C=`${l}__length`;e.state.env.has(C)&&!s.has(C)&&s.set(C,e.state.env.get(C))}let k;try{let b=new H,C=Q(b,$);k=await q(e,C.expression)}catch{let b=parseInt($,10);k=Number.isNaN(b)?0:b}w(e.state.env,`${l}_${k}`,_);let y=parseInt(x(e.state.env,`${l}__length`,"0"),10);k>=y&&w(e.state.env,`${l}__length`,String(k+1)),Le(e,l),i&&Ne(e,l);continue}if(u.includes("=")){let $=u.indexOf("=");l=u.slice(0,$),f=Y(e,u.slice($+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 $=e.state.env.get(l);if(e.state.tempEnvBindings){let _=e.state.accessedTempEnvVars?.has(l),k=e.state.mutatedTempEnvVars?.has(l);if(!_&&!k)for(let y=e.state.tempEnvBindings.length-1;y>=0;y--){let b=e.state.tempEnvBindings[y];if(b.has(l)){$=b.get(l);break}}}qr(e,l,$)}if(!v){let $=e.state.env.get(l);if(e.state.tempEnvBindings)for(let _=e.state.tempEnvBindings.length-1;_>=0;_--){let k=e.state.tempEnvBindings[_];if(k.has(l)){$=k.get(l);break}}if(s.set(l,$),o){let _=`${l}_`;for(let y of e.state.env.keys())y.startsWith(_)&&!y.includes("__")&&(s.has(y)||s.set(y,e.state.env.get(y)));let k=`${l}__length`;e.state.env.has(k)&&!s.has(k)&&s.set(k,e.state.env.get(k))}}if(o&&f===void 0){let $=`${l}_`;for(let _ of e.state.env.keys())_.startsWith($)&&!_.includes("__")&&e.state.env.delete(_);w(e.state.env,`${l}__length`,"0")}else if(f!==void 0){if(te(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}w(e.state.env,l,f),e.state.options.allexport&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(l))}else{let $=e.state.tempEnvBindings?.some(_=>_.has(l));!v&&!$&&e.state.env.delete(l)}Le(e,l),i&&Ne(e,l)}return T(p,E(r),n)}function Hs(e,t,s){let r=z(s),n=`
|
|
515
|
+
`,i=0,o=0,a=0,c=!1,u="MAPFILE",l=0;for(;l<t.length;){let k=t[l];k==="-d"&&l+1<t.length?(n=t[l+1]===""?"\0":t[l+1]||`
|
|
516
|
+
`,l+=2):k==="-n"&&l+1<t.length?(i=Number.parseInt(t[l+1],10)||0,l+=2):k==="-O"&&l+1<t.length?(o=Number.parseInt(t[l+1],10)||0,l+=2):k==="-s"&&l+1<t.length?(a=Number.parseInt(t[l+1],10)||0,l+=2):k==="-t"?(c=!0,l++):k==="-u"||k==="-C"||k==="-c"?l+=2:(k.startsWith("-")||(u=k),l++)}let f=r;!f&&e.state.groupStdin!==void 0&&(f=z(e.state.groupStdin));let d=[],h=f,g=0,m=0,v=e.limits?.maxArrayElements??1e5;for(;h.length>0;){let k=h.indexOf(n);if(k===-1){if(h.length>0){if(m<a)m++;else if(i===0||g<i){if(o+g>=v)return T(p,E(`mapfile: array element limit exceeded (${v})
|
|
517
|
+
`),1);let C=h,A=C.indexOf("\0");A!==-1&&(C=C.substring(0,A)),d.push(C),g++}}break}let y=h.substring(0,k),b=y.indexOf("\0");if(b!==-1&&(y=y.substring(0,b)),!c&&n!=="\0"&&(y+=n),h=h.substring(k+n.length),m<a){m++;continue}if(i>0&&g>=i)break;if(o+g>=v)return T(p,E(`mapfile: array element limit exceeded (${v})
|
|
518
|
+
`),1);d.push(y),g++}o===0&&$e(e,u);for(let k=0;k<d.length;k++)w(e.state.env,`${u}_${o+k}`,d[k]);let $=parseInt(x(e.state.env,`${u}__length`,"0"),10),_=o+d.length;return w(e.state.env,`${u}__length`,String(Math.max($,_))),e.state.groupStdin!==void 0&&!r&&(e.state.groupStdin=p),T(p,p,0)}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}}function eo(e,t,s){return`__rw__:${e.length}:${e}:${t}:${s}`}function Us(e,t,s,r=-1){let n=z(s),i=!1,o=`
|
|
519
|
+
`,a="",c=-1,u=-1,l=null,f=-1,d=-1,h=[],g=0,m=!1,v=(D,O)=>{let S=1;for(;S<D.length;){let R=D[S];if(R==="r")i=!0,S++;else if(R==="s")S++;else{if(R==="d")return S+1<D.length?(o=D.substring(S+1),{nextArgIndex:O+1}):O+1<t.length?(o=t[O+1],{nextArgIndex:O+2}):{nextArgIndex:O+1};if(R==="n"){if(S+1<D.length){let M=D.substring(S+1);return c=Number.parseInt(M,10),(Number.isNaN(c)||c<0)&&(m=!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)&&(m=!0,c=0),{nextArgIndex:O+2};return{nextArgIndex:O+1}}else if(R==="N"){if(S+1<D.length){let M=D.substring(S+1);return u=Number.parseInt(M,10),(Number.isNaN(u)||u<0)&&(m=!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)&&(m=!0,u=0),{nextArgIndex:O+2};return{nextArgIndex:O+1}}else{if(R==="a")return S+1<D.length?(l=D.substring(S+1),{nextArgIndex:O+1}):O+1<t.length?(l=t[O+1],{nextArgIndex:O+2}):{nextArgIndex:O+1};if(R==="p")return S+1<D.length?(a=D.substring(S+1),{nextArgIndex:O+1}):O+1<t.length?(a=t[O+1],{nextArgIndex:O+2}):{nextArgIndex:O+1};if(R==="u"){if(S+1<D.length){let M=D.substring(S+1);return f=Number.parseInt(M,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(R==="t"){if(S+1<D.length){let M=D.substring(S+1);return d=Number.parseFloat(M),Number.isNaN(d)&&(d=0),{nextArgIndex:O+1}}else if(O+1<t.length)return d=Number.parseFloat(t[O+1]),Number.isNaN(d)&&(d=0),{nextArgIndex:O+2};return{nextArgIndex:O+1}}else if(R==="e"||R==="i"||R==="P"){if(R==="i"&&O+1<t.length)return{nextArgIndex:O+2};S++}else S++}}}return{nextArgIndex:O+1}};for(;g<t.length;){let D=t[g];if(D.startsWith("-")&&D.length>1&&D!=="--"){let O=v(D,g);if(O.nextArgIndex===-1)return{stdout:p,stderr:p,exitCode:2};if(O.nextArgIndex===-2)return{stdout:p,stderr:p,exitCode:1};g=O.nextArgIndex}else if(D==="--")for(g++;g<t.length;)h.push(t[g]),g++;else h.push(D),g++}if(m)return T(p,p,1);if(h.length===0&&l===null&&h.push("REPLY"),d===0){if(l)$e(e,l);else{for(let D of h)w(e.state.env,D,"");h.length===0&&w(e.state.env,"REPLY","")}return T(p,p,0)}if(d<0&&d!==-1)return T(p,p,1);let $=n;f>=0?e.state.fileDescriptors?$=e.state.fileDescriptors.get(f)||"":$="":!$&&e.state.groupStdin!==void 0&&($=z(e.state.groupStdin));let _=o===""?"\0":o,k="",y=0,b=!0,C=D=>{if(f>=0&&e.state.fileDescriptors)e.state.fileDescriptors.set(f,$.substring(D));else if(r>=0&&e.state.fileDescriptors){let O=e.state.fileDescriptors.get(r);if(O?.startsWith("__rw__:")){let S=Ji(O);if(S){let R=S.position+D;e.state.fileDescriptors.set(r,eo(S.path,R,S.content))}}}else e.state.groupStdin!==void 0&&!n&&(e.state.groupStdin=E($.substring(D)))};if(u>=0){let D=Math.min(u,$.length);k=$.substring(0,D),y=D,b=D>=u,C(y);let O=h[0]||"REPLY";w(e.state.env,O,k);for(let S=1;S<h.length;S++)w(e.state.env,h[S],"");return T(p,p,b?0:1)}else if(c>=0){let D=0,O=0,S=!1;for(;O<$.length&&D<c;){let R=$[O];if(R===_){y=O+1,S=!0;break}if(!i&&R==="\\"&&O+1<$.length){let M=$[O+1];if(M===_&&_===`
|
|
520
|
+
`){O+=2,y=O;continue}if(M===_){O+=2,D++,k+=M,y=O;continue}k+=M,O+=2,D++,y=O}else k+=R,O++,D++,y=O}b=D>=c||S,C(y)}else{y=0;let D=0;for(;D<$.length;){let O=$[D];if(O===_){y=D+_.length,b=!0;break}if(!i&&O==="\\"&&D+1<$.length){let S=$[D+1];if(S===`
|
|
521
|
+
`){D+=2;continue}if(S===_){k+=S,D+=2;continue}k+=O,k+=S,D+=2;continue}k+=O,D++}if(D>=$.length&&(b=!1,y=D,k.length===0&&$.length===0)){for(let O of h)w(e.state.env,O,"");return l&&$e(e,l),T(p,p,1)}C(y)}_===`
|
|
522
|
+
`&&k.endsWith(`
|
|
523
|
+
`)&&(k=k.slice(0,-1));let A=D=>i?D:D.replace(/\\(.)/g,"$1");if(h.length===1&&h[0]==="REPLY")return w(e.state.env,"REPLY",A(k)),T(p,p,b?0:1);let L=fr(e.state.env);if(l){let{words:D}=es(k,L,void 0,i),O=e.limits?.maxArrayElements??1e5;if(D.length>O)return T(p,E(`read: array element limit exceeded (${O})
|
|
524
|
+
`),1);$e(e,l);for(let S=0;S<D.length;S++)w(e.state.env,`${l}_${S}`,A(D[S]));return T(p,p,b?0:1)}let I=h.length,{words:W,wordStarts:B}=es(k,L,I,i);for(let D=0;D<h.length;D++){let O=h[D];if(D<h.length-1)w(e.state.env,O,A(W[D]??""));else if(D<B.length){let S=k.substring(B[D]);S=dr(S,L,i),S=A(S),w(e.state.env,O,S)}else w(e.state.env,O,"")}return T(p,p,b?0:1)}function Gs(e,t){if(e.state.callDepth===0&&e.state.sourceDepth===0)return P("bash: return: can only `return' from a function or sourced script\n");let s=e.state.lastExitCode;if(t.length>0){let r=t[0],n=Number.parseInt(r,10);if(r===""||Number.isNaN(n)||!/^-?\d+$/.test(r))return P(`bash: return: ${r}: numeric argument required
|
|
525
|
+
`,2);s=(n%256+256)%256}throw new le(s)}var Ut=`set: usage: set [-eux] [+eux] [-o option] [+o option]
|
|
526
|
+
Options:
|
|
527
|
+
-e Exit immediately if a command exits with non-zero status
|
|
528
|
+
+e Disable -e
|
|
529
|
+
-u Treat unset variables as an error when substituting
|
|
530
|
+
+u Disable -u
|
|
531
|
+
-x Print commands and their arguments as they are executed
|
|
532
|
+
+x Disable -x
|
|
533
|
+
-o errexit Same as -e
|
|
534
|
+
+o errexit Disable errexit
|
|
535
|
+
-o nounset Same as -u
|
|
536
|
+
+o nounset Disable nounset
|
|
537
|
+
-o pipefail Return status of last failing command in pipeline
|
|
538
|
+
+o pipefail Disable pipefail
|
|
539
|
+
-o xtrace Same as -x
|
|
540
|
+
+o xtrace Disable xtrace
|
|
541
|
+
`,fn=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]]),dn=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]]),hn=["errexit","nounset","pipefail","verbose","xtrace","posix","allexport","noclobber","noglob","noexec","vi","emacs"],pn=["braceexpand","errtrace","functrace","hashall","histexpand","history","ignoreeof","interactive-comments","keyword","monitor","nolog","notify","onecmd","physical","privileged"];function mn(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,Ge(e))}function to(e,t){return t+1<e.length&&!e[t+1].startsWith("-")&&!e[t+1].startsWith("+")}function so(e,t){let s=se(e,t);if(s.length===0)return`${t}=()`;let r=s.map(n=>{let i=x(e.state.env,`${t}_${n}`,"");return`[${n}]=${Ve(i)}`});return`${t}=(${r.join(" ")})`}function ro(e){return/^[a-zA-Z0-9_]+$/.test(e)?e:`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function no(e,t){let s=De(e,t);if(s.length===0)return`${t}=()`;let r=s.map(n=>{let i=x(e.state.env,`${t}_${n}`,"");return`[${ro(n)}]=${Ve(i)}`});return`${t}=(${r.join(" ")} )`}function io(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 oo(e){return e.state.associativeArrays??new Set}function Zs(e,t){if(t.includes("--help"))return U(Ut);if(t.length===0){let r=io(e),n=oo(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,z(u)])}let a=[];for(let[c,u]of o.sort(([l],[f])=>l<f?-1:l>f?1:0))a.push(`${c}=${Bt(u)}`);for(let c of[...r].sort((u,l)=>u<l?-1:u>l?1:0))a.push(so(e,c));for(let c of[...n].sort((u,l)=>u<l?-1:u>l?1:0))a.push(no(e,c));return a.sort((c,u)=>{let l=c.split("=")[0],f=u.split("=")[0];return l<f?-1:l>f?1:0}),U(a.length>0?`${a.join(`
|
|
542
|
+
`)}
|
|
543
|
+
`:"")}let s=0;for(;s<t.length;){let r=t[s];if((r==="-o"||r==="+o")&&to(t,s)){let n=t[s+1];if(!dn.has(n)){let i=`bash: set: ${n}: invalid option name
|
|
544
|
+
${Ut}`;if(e.state.options.posix)throw new we(1,p,E(i));return P(i)}mn(e,dn.get(n)??null,r==="-o"),s+=2;continue}if(r==="-o"){let n=hn.map(a=>`${a.padEnd(16)}${e.state.options[a]?"on":"off"}`),i=pn.map(a=>`${a.padEnd(16)}off`),o=[...n,...i].sort();return U(`${o.join(`
|
|
545
|
+
`)}
|
|
546
|
+
`)}if(r==="+o"){let n=hn.map(a=>`set ${e.state.options[a]?"-o":"+o"} ${a}`),i=pn.map(a=>`set +o ${a}`),o=[...n,...i].sort();return U(`${o.join(`
|
|
547
|
+
`)}
|
|
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(!fn.has(o)){let a=`bash: set: ${r[0]}${o}: invalid option
|
|
549
|
+
${Ut}`;if(e.state.options.posix)throw new we(1,p,E(a));return P(a)}mn(e,fn.get(o)??null,n)}s++;continue}if(r==="--")return qs(e,t.slice(s+1)),V;if(r==="-"){if(e.state.options.xtrace=!1,e.state.options.verbose=!1,Ge(e),s+1<t.length)return qs(e,t.slice(s+1)),V;s++;continue}if(r==="+"){s++;continue}if(r.startsWith("-")||r.startsWith("+")){let n=`bash: set: ${r}: invalid option
|
|
550
|
+
${Ut}`;if(e.state.options.posix)throw new we(1,p,E(n));return P(n)}return qs(e,t.slice(s)),V}return V}function qs(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++)w(e.state.env,String(r+1),t[r]);w(e.state.env,"#",String(t.length)),w(e.state.env,"@",t.join(" ")),w(e.state.env,"*",t.join(" "))}function Ys(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 we(1,p,E(a));return P(a)}s=o}let r=Number.parseInt(x(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 we(1,p,E(o));return P(o)}if(s===0)return V;let n=[];for(let o=1;o<=r;o++)n.push(x(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++)w(e.state.env,String(o+1),i[o]);return w(e.state.env,"#",String(i.length)),w(e.state.env,"@",i.join(" ")),V}async function Ks(e,t){let s=t;if(s.length>0&&s[0]==="--"&&(s=s.slice(1)),s.length===0)return T(p,E(`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.readFile(u),n=u}catch{}}else{let l=x(e.state.env,"PATH","").split(":").filter(f=>f);for(let f of l){let d=e.fs.resolvePath(e.state.cwd,`${f}/${r}`);try{if((await e.fs.stat(d)).isDirectory)continue;i=await e.fs.readFile(d),n=d;break}catch{}}if(i===null){let f=e.fs.resolvePath(e.state.cwd,r);try{i=await e.fs.readFile(f),n=f}catch{}}}if(i===null)return P(`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),x(e.state.env,String(l)));o.set("#",x(e.state.env,"#")),o.set("@",x(e.state.env,"@"));let u=s.slice(1);w(e.state.env,"#",String(u.length)),w(e.state.env,"@",u.join(" "));for(let l=0;l<u.length&&l<9;l++)w(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):w(e.state.env,u,l)};e.state.sourceDepth++,e.state.currentSource=r;try{let u=Se(i),l=await e.executeScript(u);return c(),l}catch(u){if(c(),u instanceof G)throw u;if(u instanceof le)return T(u.stdout,u.stderr,u.exitCode);if(u.name==="ParseException")return P(`bash: ${r}: ${u.message}
|
|
555
|
+
`);throw u}}function yn(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 gn(e,t){if(ao(t))return null;try{let s=new H,r=Q(s,t);return await q(e,r.expression)}catch{let s=parseInt(t,10);return Number.isNaN(s)?0:s}}function wn(e,t){if(e.state.localVarStack?.has(t)){let r=Wt(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)Ft(e,t),e.state.localVarStack?.delete(t),e.state.fullyUnsetLocals=e.state.fullyUnsetLocals||new Map,e.state.fullyUnsetLocals.set(t,r.scopeIndex),Xs(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),Ft(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||Ft(e,t),!0}}return!1}function Xs(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 vn(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 H().parseWordFromString(s,!0,!1);return F(e,n)}if(t.includes("$")){let r=new H().parseWordFromString(t,!1,!1);return F(e,r)}return t}async function Qs(e,t){let s="both",r="",n=0;for(let i of t){if(i==="-v"){s="variable";continue}if(i==="-f"){s="function";continue}if(s==="function"){e.state.functions.delete(i);continue}if(s==="variable"){let u=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(u){let d=u[1],h=u[2];if(h==="@"||h==="*"){let k=be(e,d);for(let[y]of k)e.state.env.delete(`${d}_${y}`);e.state.env.delete(d);continue}let g=e.state.associativeArrays?.has(d);if(g){let k=await vn(e,h);e.state.env.delete(`${d}_${k}`);continue}let m=rs(e,d),v=e.state.declaredVars?.has(d);if((e.state.env.has(d)||v)&&!m&&!g){r+=`bash: unset: ${d}: not an array variable
|
|
556
|
+
`,n=1;continue}let _=await gn(e,h);if(_===null&&m){r+=`bash: unset: ${h}: not a valid identifier
|
|
557
|
+
`,n=1;continue}if(_===null)continue;if(_<0){let k=be(e,d),y=k.length,b=e.state.currentLine;if(y===0){r+=`bash: line ${b}: unset: [${_}]: bad array subscript
|
|
558
|
+
`,n=1;continue}let C=y+_;if(C<0){r+=`bash: line ${b}: unset: [${_}]: bad array subscript
|
|
559
|
+
`,n=1;continue}let A=k[C][0];e.state.env.delete(`${d}_${A}`);continue}e.state.env.delete(`${d}_${_}`);continue}if(!yn(i)){r+=`bash: unset: \`${i}': not a valid identifier
|
|
560
|
+
`,n=1;continue}let l=i;if(ce(e,i)){let d=Ae(e,i);d&&d!==i&&(l=d)}if(Fe(e,l)){r+=`bash: unset: ${l}: cannot unset: readonly variable
|
|
561
|
+
`,n=1;continue}let f=Ze(e,l);if(f!==void 0&&f!==e.state.callDepth)wn(e,l);else if(e.state.fullyUnsetLocals?.has(l))e.state.env.delete(l);else if(f!==void 0){let d=e.state.accessedTempEnvVars?.has(l),h=e.state.mutatedTempEnvVars?.has(l);if((d||h)&&e.state.localVarStack?.has(l)){let g=Wt(e,l);g?g.value===void 0?e.state.env.delete(l):e.state.env.set(l,g.value):e.state.env.delete(l)}else e.state.env.delete(l)}else Xs(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 m=be(e,u);for(let[v]of m)e.state.env.delete(`${u}_${v}`);e.state.env.delete(u);continue}let f=e.state.associativeArrays?.has(u);if(f){let m=await vn(e,l);e.state.env.delete(`${u}_${m}`);continue}let d=rs(e,u);if(e.state.env.has(u)&&!d&&!f){r+=`bash: unset: ${u}: not an array variable
|
|
562
|
+
`,n=1;continue}let g=await gn(e,l);if(g===null&&d){r+=`bash: unset: ${l}: not a valid identifier
|
|
563
|
+
`,n=1;continue}if(g===null)continue;if(g<0){let m=be(e,u),v=m.length,$=e.state.currentLine;if(v===0){r+=`bash: line ${$}: unset: [${g}]: bad array subscript
|
|
564
|
+
`,n=1;continue}let _=v+g;if(_<0){r+=`bash: line ${$}: unset: [${g}]: bad array subscript
|
|
565
|
+
`,n=1;continue}let k=m[_][0];e.state.env.delete(`${u}_${k}`);continue}e.state.env.delete(`${u}_${g}`);continue}if(!yn(i)){r+=`bash: unset: \`${i}': not a valid identifier
|
|
566
|
+
`,n=1;continue}let a=i;if(ce(e,i)){let u=Ae(e,i);u&&u!==i&&(a=u)}if(Fe(e,a)){r+=`bash: unset: ${a}: cannot unset: readonly variable
|
|
567
|
+
`,n=1;continue}let c=Ze(e,a);if(c!==void 0&&c!==e.state.callDepth)wn(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=Wt(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 Xs(e,a)||e.state.env.delete(a);e.state.exportedVars?.delete(a),e.state.functions.delete(i)}return T(p,E(r),n)}var Js=["extglob","dotglob","nullglob","failglob","globstar","globskipdots","nocaseglob","nocasematch","expand_aliases","lastpipe","xpg_echo"],lo=["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 Gt(e){return Js.includes(e)}function co(e){return lo.includes(e)}function bn(e,t){let s=!1,r=!1,n=!1,i=!1,o=!1,a=[],c=0;for(;c<t.length;){let d=t[c];if(d==="--"){c++;break}if(d.startsWith("-")&&d.length>1){for(let h=1;h<d.length;h++){let g=d[h];switch(g){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:p,stderr:E(`shopt: -${g}: invalid option
|
|
568
|
+
`)}}}c++}else break}for(;c<t.length;)a.push(t[c]),c++;if(o)return uo(e,a,s,r,n,i);if(s&&r)return{exitCode:1,stdout:p,stderr:E(`shopt: cannot set and unset shell options simultaneously
|
|
569
|
+
`)};if(a.length===0){if(s||r){let h=[];for(let g of Js){let m=e.state.shoptOptions[g];s&&m?h.push(n?`shopt -s ${g}`:`${g} on`):r&&!m&&h.push(n?`shopt -u ${g}`:`${g} off`)}return{exitCode:0,stdout:h.length>0?E(`${h.join(`
|
|
570
|
+
`)}
|
|
571
|
+
`):p,stderr:p}}let d=[];for(let h of Js){let g=e.state.shoptOptions[h];d.push(n?`shopt ${g?"-s":"-u"} ${h}`:`${h} ${g?"on":"off"}`)}return{exitCode:0,stdout:E(`${d.join(`
|
|
572
|
+
`)}
|
|
573
|
+
`),stderr:p}}let u=!1,l="",f=[];for(let d of a){if(!Gt(d)&&!co(d)){l+=`shopt: ${d}: invalid shell option name
|
|
574
|
+
`,u=!0;continue}if(s)Gt(d)&&(e.state.shoptOptions[d]=!0,cs(e));else if(r)Gt(d)&&(e.state.shoptOptions[d]=!1,cs(e));else if(Gt(d)){let h=e.state.shoptOptions[d];i?h||(u=!0):n?(f.push(`shopt ${h?"-s":"-u"} ${d}`),h||(u=!0)):(f.push(`${d} ${h?"on":"off"}`),h||(u=!0))}else i?u=!0:n?(f.push(`shopt -u ${d}`),u=!0):(f.push(`${d} off`),u=!0)}return{exitCode:u?1:0,stdout:f.length>0?E(`${f.join(`
|
|
575
|
+
`)}
|
|
576
|
+
`):p,stderr:E(l)}}function uo(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 d=[];for(let h of c){let g=a.includes(h),m=o.get(h),v=g||!m?!1:e.state.options[m];s&&!v||r&&v||d.push(n?`set ${v?"-o":"+o"} ${h}`:`${h} ${v?"on":"off"}`)}return{exitCode:0,stdout:d.length>0?E(`${d.join(`
|
|
577
|
+
`)}
|
|
578
|
+
`):p,stderr:p}}let u=!1,l="",f=[];for(let d of t){let h=o.has(d),g=a.includes(d);if(!h&&!g){l+=`shopt: ${d}: invalid option name
|
|
579
|
+
`,u=!0;continue}if(g){s||r||(i?u=!0:n?(f.push(`set +o ${d}`),u=!0):(f.push(`${d} off`),u=!0));continue}let m=o.get(d);if(m)if(s)m==="vi"?e.state.options.emacs=!1:m==="emacs"&&(e.state.options.vi=!1),e.state.options[m]=!0,Ge(e);else if(r)e.state.options[m]=!1,Ge(e);else{let v=e.state.options[m];i?v||(u=!0):n?(f.push(`set ${v?"-o":"+o"} ${d}`),v||(u=!0)):(f.push(`${d} ${v?"on":"off"}`),v||(u=!0))}}return{exitCode:u?1:0,stdout:f.length>0?E(`${f.join(`
|
|
580
|
+
`)}
|
|
581
|
+
`):p,stderr:E(l)}}async function En(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??x(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),d=o==="/bin"||o==="/usr/bin";if(f&&d)return{cmd:f,path:c};if(l){if(f&&!d)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 qt(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=x(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 _n(e,t,s,r){let n=!1,i=!1,o=!1,a=!1,c=!1,u=[];for(let m of t)if(m.startsWith("-")&&m.length>1)for(let v of m.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(m);let l="",f="",d=0,h=!1,g=!1;for(let m of u){let v=!1;if(o){if(a){let C=await r(m);if(C.length>0){for(let A of C)l+=`${A}
|
|
582
|
+
`;h=!0,v=!0}}else{let C=await s(m);C&&(l+=`${C}
|
|
583
|
+
`,h=!0,v=!0)}v||(g=!0);continue}let $=!c&&e.state.functions.has(m);if(a&&$){if(!i)if(n)l+=`function
|
|
584
|
+
`;else{let C=e.state.functions.get(m),A=C?Sn(m,C):`${m} is a function
|
|
585
|
+
`;l+=A}v=!0}let _=e.state.env.get(`BASH_ALIAS_${m}`);if(_!==void 0&&(a||!v)&&(i||(n?l+=`alias
|
|
586
|
+
`:l+=`${m} is aliased to \`${z(_)}'
|
|
587
|
+
`),v=!0,!a)||gs.has(m)&&(a||!v)&&(i||(n?l+=`keyword
|
|
588
|
+
`:l+=`${m} is a shell keyword
|
|
589
|
+
`),v=!0,!a))continue;if(!a&&$&&!v){if(!i)if(n)l+=`function
|
|
590
|
+
`;else{let C=e.state.functions.get(m),A=C?Sn(m,C):`${m} is a function
|
|
591
|
+
`;l+=A}v=!0;continue}if(!(Ye.has(m)&&(a||!v)&&(i||(n?l+=`builtin
|
|
592
|
+
`:l+=`${m} is a shell builtin
|
|
593
|
+
`),v=!0,!a))){if(a){let C=await r(m);for(let A of C)i?l+=`${A}
|
|
594
|
+
`:n?l+=`file
|
|
595
|
+
`:l+=`${m} is ${A}
|
|
596
|
+
`,h=!0,v=!0}else if(!v){let C=await s(m);C&&(i?l+=`${C}
|
|
597
|
+
`:n?l+=`file
|
|
598
|
+
`:l+=`${m} is ${C}
|
|
599
|
+
`,h=!0,v=!0)}if(!v&&(g=!0,!n&&!i)){let C=!0;if(m.includes("/")){let A=e.fs.resolvePath(e.state.cwd,m);await e.fs.exists(A)&&(C=!1)}C&&(f+=`bash: type: ${m}: not found
|
|
600
|
+
`)}}}return i?d=g&&!h?1:0:d=g?1:0,T(E(l),E(f),d)}function Sn(e,t){let s;return t.body.type==="Group"?s=t.body.body.map(n=>lt(n)).join("; "):s=lt(t.body),`${e} is a function
|
|
601
|
+
${e} ()
|
|
602
|
+
{
|
|
603
|
+
${s}
|
|
604
|
+
}
|
|
605
|
+
`}function lt(e){if(Array.isArray(e))return e.map(t=>lt(t)).join("; ");if(e.type==="Statement"){let t=[];for(let s=0;s<e.pipelines.length;s++){let r=e.pipelines[s];t.push(fo(r)),e.operators[s]&&t.push(e.operators[s])}return t.join(" ")}if(e.type==="SimpleCommand"){let t=e,s=[];t.name&&s.push($n(t.name));for(let r of t.args)s.push($n(r));return s.join(" ")}return e.type==="Group"?`{ ${e.body.map(r=>lt(r)).join("; ")}; }`:"..."}function fo(e){let t=e.commands.map(s=>lt(s));return(e.negated?"! ":"")+t.join(" | ")}function $n(e){let t="";for(let s of e.parts)s.type==="Literal"?t+=s.value:s.type==="DoubleQuoted"?t+=`"${s.parts.map(r=>An(r)).join("")}"`:s.type==="SingleQuoted"?t+=`'${s.value}'`:t+=An(s);return t}function An(e){let t=e;return t.type==="Literal"?t.value??"":t.type==="Variable"?`$${t.name}`:""}async function Pn(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 "${z(c)}"
|
|
606
|
+
`:n+=`alias ${a}='${z(c)}'
|
|
607
|
+
`;else if(gs.has(a))r?n+=`${a} is a shell keyword
|
|
608
|
+
`:n+=`${a}
|
|
609
|
+
`;else if(Ye.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=x(e.state.env,"PATH","/usr/bin:/bin").split(":"),f=null;for(let d of l){if(!d)continue;let h=`${d}/${a}`;try{let g=await e.fs.stat(h);if(!g.isDirectory&&(g.mode&73)!==0){f=h;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 T(E(n),E(i),o)}async function Cn(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=x(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 kn(e,t,s,r,n,i,o,a){let{ctx:c,runCommand:u}=e,l=tt(s);if(c.coverage&&Ye.has(t)&&c.coverage.hit(`bash:builtin:${t}`),t==="export")return Ws(c,l);if(t==="unset")return Qs(c,l);if(t==="exit")return Fs(c,l);if(t==="local")return js(c,l);if(t==="set")return Zs(c,l);if(t==="break")return fs(c,l);if(t==="continue")return As(c,l);if(t==="return")return Gs(c,l);if(t==="eval"&&c.state.options.posix)return jt(c,l,n);if(t==="shift")return Ys(c,l);if(t==="getopts")return Ht(c,l);if(t==="compgen")return bs(c,l);if(t==="complete")return Ss(c,l);if(t==="compopt")return $s(c,l);if(t==="pushd")return await Rs(c,l);if(t==="popd")return Ls(c,l);if(t==="dirs")return Ms(c,l);if(t==="source"||t===".")return Ks(c,l);if(t==="read")return Us(c,l,n,a);if(t==="mapfile"||t==="readarray")return Hs(c,l,n);if(t==="declare"||t==="typeset")return Ts(c,l);if(t==="readonly")return Ds(c,l);if(!i){let f=c.state.functions.get(t);if(f)return zt(c,f,l,n)}if(t==="eval")return jt(c,l,n);if(t==="cd")return await ds(c,l);if(t===":"||t==="true")return V;if(t==="false")return X(!1);if(t==="let")return Bs(c,l);if(t==="command")return ho(e,l,n);if(t==="builtin")return po(e,l,n);if(t==="shopt")return bn(c,l);if(t==="exec"){if(s.length===0)return V;let[f,...d]=s;return u(z(f),d,[],n,!1,!1,-1)}if(t==="wait")return V;if(t==="type")return await _n(c,l,f=>Cn(c,f),f=>qt(c,f));if(t==="hash")return Vs(c,l);if(t==="help")return zs(c,l);if(t==="["||t==="test"){let f=l;if(t==="["){if(l[l.length-1]!=="]")return P("[: missing `]'\n",2);f=l.slice(0,-1)}return it(c,f)}return null}async function ho(e,t,s){let{ctx:r,runCommand:n}=e;if(t.length===0)return V;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 d of f.slice(1))d==="p"?i=!0:d==="V"?o=!0:d==="v"&&(a=!0);c=c.slice(1)}if(c.length===0)return V;if(a||o)return await Pn(r,c,a,o);let[u,...l]=c;return n(u,l.map(f=>E(f)),[],s,!0,i,-1)}async function po(e,t,s){let{runCommand:r}=e;if(t.length===0)return V;let n=t;if(n[0]==="--"&&(n=n.slice(1),n.length===0))return V;let i=n[0];if(!Ye.has(i))return P(`bash: builtin: ${i}: not a shell builtin
|
|
620
|
+
`);let[,...o]=n;return r(i,o.map(a=>E(a)),[],s,!0,!1,-1)}async function Nn(e,t,s,r,n){let{ctx:i,buildExportedEnv:o,executeUserScript:a}=e,u=await En(i,t,n?"/usr/bin:/bin":void 0);if(!u)return Lr(t)?P(`bash: ${t}: command not available in browser environments. Exclude '${t}' from your commands or use the Node.js bundle.
|
|
621
|
+
`,127):P(`bash: ${t}: command not found
|
|
622
|
+
`,127);if("error"in u)return u.error==="permission_denied"?P(`bash: ${t}: Permission denied
|
|
623
|
+
`,126):P(`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 d=Be(r)?i.state.groupStdin??p:r,h=o(),g={fs:i.fs,cwd:i.state.cwd,env:i.state.env,exportedEnv:h,stdin:d,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,g)}catch(m){if(m instanceof ie)throw m;return P(`${t}: ${ke(m)}
|
|
625
|
+
`)}}async function er(e,t){let s=e.state.inCondition;e.state.inCondition=!0;let r=p,n=p,i=0;try{for(let o of t){let a=await e.executeStatement(o);r=N(r,a.stdout),n=N(n,a.stderr),i=a.exitCode}}finally{e.state.inCondition=s}return{stdout:r,stderr:n,exitCode:i}}function ct(e,t,s,r){if(e instanceof pe)return t=N(t,e.stdout),s=N(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 me)return t=N(t,e.stdout),s=N(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 le||e instanceof ge||e instanceof G||e instanceof ie)return e.prependOutput(t,s),{action:"rethrow",stdout:t,stderr:s,error:e};let n=ke(e);return{action:"error",stdout:t,stderr:N(s,E(`${n}
|
|
626
|
+
`)),exitCode:1}}async function Zt(e,t,s=p,r=p){let n=s,i=r,o=0;try{for(let a of t){let c=await e.executeStatement(a);n=N(n,c.stdout),i=N(i,c.stderr),o=c.exitCode}}catch(a){if(vt(a)||a instanceof ge||a instanceof G||a instanceof ie||a instanceof Oe)throw a.prependOutput(n,i),a;return{stdout:n,stderr:N(i,E(`${ke(a)}
|
|
627
|
+
`)),exitCode:1}}return{stdout:n,stderr:i,exitCode:o}}async function xn(e,t){let s=p,r=p;for(let n of t.clauses){let i=await er(e,n.condition);if(s=N(s,i.stdout),r=N(r,i.stderr),i.exitCode===0)return Zt(e,n.body,s,r)}return t.elseBody?Zt(e,t.elseBody,s,r):{stdout:s,stderr:r,exitCode:0}}async function On(e,t){let s=await Ce(e,t.redirections);if(s)return s;let r=p,n=p,i=0,o=0;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t.variable))return P(`bash: \`${t.variable}': not a valid identifier
|
|
628
|
+
`);let a=[];if(t.words===null)a=x(e.state.env,"@","").split(" ").filter(Boolean);else if(t.words.length===0)a=[];else try{for(let u of t.words){let l=await _e(e,u);a.push(...l.values)}}catch(u){if(u instanceof wt)return{stdout:p,stderr:u.stderr,exitCode:1};throw u}e.state.loopDepth++;try{for(let u of a){o++,o>e.limits.maxLoopIterations&&xe(`for loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",r,n),w(e.state.env,t.variable,u);try{for(let l of t.body){let f=await e.executeStatement(l);r=N(r,f.stdout),n=N(n,f.stderr),i=f.exitCode}}catch(l){let f=ct(l,r,n,e.state.loopDepth);if(r=f.stdout,n=f.stderr,f.action==="break")break;if(f.action==="continue")continue;if(f.action==="error"){let d=T(r,n,f.exitCode??1);return Z(e,d,t.redirections)}throw f.error}}}finally{e.state.loopDepth--}let c=T(r,n,i);return Z(e,c,t.redirections)}async function Tn(e,t){let s=await Ce(e,t.redirections);if(s)return s;let r=t.line;r!==void 0&&(e.state.currentLine=r);let n=p,i=p,o=0,a=0;t.init&&await q(e,t.init.expression),e.state.loopDepth++;try{for(;a++,a>e.limits.maxLoopIterations&&xe(`for loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",n,i),!(t.condition&&(r!==void 0&&(e.state.currentLine=r),await q(e,t.condition.expression)===0));){try{for(let u of t.body){let l=await e.executeStatement(u);n=N(n,l.stdout),i=N(i,l.stderr),o=l.exitCode}}catch(u){let l=ct(u,n,i,e.state.loopDepth);if(n=l.stdout,i=l.stderr,l.action==="break")break;if(l.action==="continue"){t.update&&await q(e,t.update.expression);continue}if(l.action==="error"){let f=T(n,i,l.exitCode??1);return Z(e,f,t.redirections)}throw l.error}t.update&&await q(e,t.update.expression)}}finally{e.state.loopDepth--}let c=T(n,i,o);return Z(e,c,t.redirections)}async function Dn(e,t,s=p){let r=p,n=p,i=0,o=0,a=s;for(let u of t.redirections)if((u.operator==="<<"||u.operator==="<<-")&&u.target.type==="HereDoc"){let l=u.target,f=await F(e,l.content);l.stripTabs&&(f=f.split(`
|
|
629
|
+
`).map(d=>d.replace(/^\t+/,"")).join(`
|
|
630
|
+
`)),a=E(f)}else if(u.operator==="<<<"&&u.target.type==="Word")a=E(`${await F(e,u.target)}
|
|
631
|
+
`);else if(u.operator==="<"&&u.target.type==="Word")try{let l=await F(e,u.target),f=e.fs.resolvePath(e.state.cwd,l);a=E(await e.fs.readFile(f))}catch{let l=await F(e,u.target);return P(`bash: ${l}: No such file or directory
|
|
632
|
+
`)}let c=e.state.groupStdin;a.length>0&&(e.state.groupStdin=a),e.state.loopDepth++;try{for(;;){o++,o>e.limits.maxLoopIterations&&xe(`while loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",r,n);let u=0,l=!1,f=!1,d=e.state.inCondition;e.state.inCondition=!0;try{for(let h of t.condition){let g=await e.executeStatement(h);r=N(r,g.stdout),n=N(n,g.stderr),u=g.exitCode}}catch(h){if(h instanceof pe){if(r=N(r,h.stdout),n=N(n,h.stderr),h.levels>1&&e.state.loopDepth>1)throw h.levels--,h.stdout=r,h.stderr=n,e.state.inCondition=d,h;l=!0}else if(h instanceof me){if(r=N(r,h.stdout),n=N(n,h.stderr),h.levels>1&&e.state.loopDepth>1)throw h.levels--,h.stdout=r,h.stderr=n,e.state.inCondition=d,h;f=!0}else throw e.state.inCondition=d,h}finally{e.state.inCondition=d}if(l)break;if(!f){if(u!==0)break;try{for(let h of t.body){let g=await e.executeStatement(h);r=N(r,g.stdout),n=N(n,g.stderr),i=g.exitCode}}catch(h){let g=ct(h,r,n,e.state.loopDepth);if(r=g.stdout,n=g.stderr,g.action==="break")break;if(g.action==="continue")continue;if(g.action==="error")return T(r,n,g.exitCode??1);throw g.error}}}}finally{e.state.loopDepth--,e.state.groupStdin=c}return T(r,n,i)}async function In(e,t){let s=p,r=p,n=0,i=0;e.state.loopDepth++;try{for(;;){i++,i>e.limits.maxLoopIterations&&xe(`until loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",s,r);let o=await er(e,t.condition);if(s=N(s,o.stdout),r=N(r,o.stderr),o.exitCode===0)break;try{for(let a of t.body){let c=await e.executeStatement(a);s=N(s,c.stdout),r=N(r,c.stderr),n=c.exitCode}}catch(a){let c=ct(a,s,r,e.state.loopDepth);if(s=c.stdout,r=c.stderr,c.action==="break")break;if(c.action==="continue")continue;if(c.action==="error")return T(s,r,c.exitCode??1);throw c.error}}}finally{e.state.loopDepth--}return T(s,r,n)}async function Rn(e,t){let s=await Ce(e,t.redirections);if(s)return s;let r=p,n=p,i=0,o=await F(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 d of l.patterns){let h=await F(e,d);vr(d)&&(h=gr(h));let g=e.state.shoptOptions.nocasematch,m=e.state.shoptOptions.extglob;if(qe(o,h,g,m)){f=!0;break}}if(f){let d=await Zt(e,l.body,r,n);if(r=d.stdout,n=d.stderr,i=d.exitCode,l.terminator===";;")break;l.terminator===";&"?a=!0:a=!1}else a=!1}let c=T(r,n,i);return Z(e,c,t.redirections)}function tr(e,t){if(e.parts.length!==1)return!1;let s=e.parts[0];return s.type!=="Literal"?!1:t.includes(s.value)}function Ln(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 Mn="+ ";async function Fn(e){let t=e.state.env.get("PS4");if(t===void 0)return Mn;let s=z(t);if(s==="")return"";try{let n=new H().parseWordFromString(s,!1,!1);return await F(e,n)}catch{return e.state.expansionStderr=`${e.state.expansionStderr||""}bash: ${s}: bad substitution
|
|
633
|
+
`,s||Mn}}function mo(e){return e.map(t=>yo(t)).join(" ")}function yo(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 Wn(e,t,s){if(!e.state.options.xtrace)return"";let r=await Fn(e),n=[t,...s],i=mo(n);return`${r}${i}
|
|
636
|
+
`}async function Vn(e,t,s){return e.state.options.xtrace?`${await Fn(e)}${t}=${s}
|
|
637
|
+
`:""}async function zn(e,t,s){let r=t.timed?performance.now():0,n=p,i=V,o=0,a=[],c=t.commands.length>1,u=e.state.lastArg;for(let f=0;f<t.commands.length;f++){let d=t.commands[f],h=f===t.commands.length-1,g=f===0;c&&(e.state.lastArg=E(""),g||(e.state.groupStdin=void 0));let v=c&&(!h||!e.state.shoptOptions.lastpipe)?new Map(e.state.env):null,$;try{$=await s(d,n)}catch(_){if(_ instanceof gt)$={stdout:_.stdout,stderr:_.stderr,exitCode:1};else if(_ instanceof G&&t.commands.length>1)$={stdout:_.stdout,stderr:_.stderr,exitCode:_.exitCode};else if(_ instanceof ge&&t.commands.length>1)$={stdout:_.stdout,stderr:_.stderr,exitCode:_.exitCode};else throw v&&(e.state.env=v),_}v&&(e.state.env=v),a.push($.exitCode),$.exitCode!==0&&(o=$.exitCode),h?i=$:t.pipeStderr?.[f]??!1?(n=N($.stderr,$.stdout),i={stdout:p,stderr:p,exitCode:$.exitCode}):(n=$.stdout,i={stdout:p,stderr:$.stderr,exitCode:$.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++)w(e.state.env,`PIPESTATUS_${f}`,String(a[f]));w(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 d=(performance.now()-r)/1e3,h=Math.floor(d/60),g=d%60,m;t.timePosix?m=`real ${d.toFixed(2)}
|
|
638
|
+
user 0.00
|
|
639
|
+
sys 0.00
|
|
640
|
+
`:m=`
|
|
641
|
+
real ${`${h}m${g.toFixed(3)}s`}
|
|
642
|
+
user 0m0.000s
|
|
643
|
+
sys 0m0.000s
|
|
644
|
+
`,i={...i,stderr:N(i.stderr,E(m))}}return c&&!e.state.shoptOptions.lastpipe&&(e.state.lastArg=u),i}async function Bn(e,t){let s=new Map,r="";for(let n of t.assignments){let i=n.name;if(n.array){let f=await go(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 F(e,n.value):"",a=n.value?await je(e,n.value):p;if(i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[\]$/))return{continueToNext:!1,xtraceOutput:r,tempAssignments:s,error:P(`bash: ${i}: bad array subscript
|
|
645
|
+
`)};let u=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(u){let f=await So(e,t,u[1],u[2],o,n.append,s);if(f.error)return{continueToNext:!1,xtraceOutput:r,tempAssignments:s,error:f.error};if(f.continueToNext)continue}let l=await Ao(e,t,i,o,n.append,s,a);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 go(e,t,s,r,n,i){let o="";if(/\[.+\]$/.test(s))return{continueToNext:!1,xtraceOutput:"",error:P(`bash: ${s}: cannot assign list to array member
|
|
646
|
+
`)};if(ce(e,s)){let l=mr(e,s);if(l===void 0||l==="")throw new G(1,p,p);let f=Ae(e,s);if(f&&/^[a-zA-Z_][a-zA-Z0-9_]*\[@\]$/.test(f))return{continueToNext:!1,xtraceOutput:"",error:P(`bash: ${s}: cannot assign list to array member
|
|
647
|
+
`)}}if(Fe(e,s)){if(t.name)return o+=`bash: ${s}: readonly variable
|
|
648
|
+
`,{continueToNext:!0,xtraceOutput:o};let l=te(e,s);if(l)return{continueToNext:!1,xtraceOutput:"",error:l}}let a=e.state.associativeArrays?.has(s),c=wo(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 vo(e,t,s,r,n,u,l=>{o+=l}):c?await bo(e,s,r,n,u):await Eo(e,s,r,n,u),t.name){i.set(s,e.state.env.get(s));let f=`(${r.map(d=>Et(d)).join(" ")})`;w(e.state.env,s,f)}return{continueToNext:!0,xtraceOutput:o}}function wo(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 vo(e,t,s,r,n,i,o){let a=[];for(let c of r){let u=Jt(c);if(u){let{key:l,valueParts:f,append:d}=u,h;f.length>0?h=await F(e,{type:"Word",parts:f}):h="",h=Y(e,h),a.push({type:"keyed",key:l,value:h,append:d})}else{let l=await F(e,c);a.push({type:"invalid",expandedValue:l})}}n||i();for(let c of a)if(c.type==="keyed")if(c.append){let u=x(e.state.env,`${s}_${c.key}`,"");w(e.state.env,`${s}_${c.key}`,u+c.value)}else w(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 bo(e,t,s,r,n){let i=[];for(let a of s){let c=Jt(a);if(c){let{key:u,valueParts:l,append:f}=c,d;l.length>0?d=await F(e,{type:"Word",parts:l}):d="",d=Y(e,d),i.push({type:"keyed",indexExpr:u,value:d,append:f})}else{let u=await _e(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 H,l=Q(u,a.indexExpr);c=await q(e,l.expression,!1)}catch{if(/^-?\d+$/.test(a.indexExpr))c=Number.parseInt(a.indexExpr,10);else{let u=x(e.state.env,a.indexExpr);c=u?Number.parseInt(u,10):0,Number.isNaN(c)&&(c=0)}}if(a.append){let u=x(e.state.env,`${t}_${c}`,"");w(e.state.env,`${t}_${c}`,u+a.value)}else w(e.state.env,`${t}_${c}`,a.value);o=c+1}else for(let c of a.values)w(e.state.env,`${t}_${o++}`,c)}async function Eo(e,t,s,r,n){let i=[];for(let a of s){let c=await _e(e,a);i.push(...c.values)}let o=0;if(r){let a=be(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++)w(e.state.env,`${t}_${o+a}`,i[a]);r||w(e.state.env,`${t}__length`,String(i.length))}async function So(e,t,s,r,n,i,o){let a=s;if(ce(e,s)){let f=Ae(e,s);if(f&&f!==s){if(f.includes("["))return{continueToNext:!1,xtraceOutput:"",error:P(`bash: \`${f}': not a valid identifier
|
|
650
|
+
`)};a=f}}if(Fe(e,a)){if(t.name)return{continueToNext:!0,xtraceOutput:""};let f=te(e,a);if(f)return{continueToNext:!1,xtraceOutput:"",error:f}}let c=e.state.associativeArrays?.has(a),u;if(c)u=await jn(e,a,r);else{let f=await $o(e,a,r);if(f.error)return{continueToNext:!1,xtraceOutput:"",error:f.error};u=`${a}_${f.index}`}let l=i?x(e.state.env,u)+n:n;if(t.name)o.set(u,e.state.env.get(u)),w(e.state.env,u,l);else{let f=Ze(e,a);if(f!==void 0&&f===e.state.callDepth&&e.state.localScopes.length>0){let d=e.state.localScopes[e.state.localScopes.length-1];d.has(u)||d.set(u,e.state.env.get(u))}w(e.state.env,u,l)}return{continueToNext:!0,xtraceOutput:""}}async function jn(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 H().parseWordFromString(n,!0,!1);r=await F(e,o)}else if(s.includes("$")){let i=new H().parseWordFromString(s,!1,!1);r=await F(e,i)}else r=s;return`${t}_${r}`}async function $o(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 H,o=Q(i,r);n=await q(e,o.expression,!1)}catch(i){if(i instanceof Me){let c=`bash: line ${e.state.currentLine}: ${s}: ${i.message}
|
|
651
|
+
`;if(i.fatal)throw new G(1,p,E(c));return{index:0,error:P(c)}}let o=x(e.state.env,s);n=o?Number.parseInt(o,10):0}Number.isNaN(n)&&(n=0)}if(n<0){let i=be(e,t);if(i.length===0){let a=e.state.currentLine;return{index:0,error:P(`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:P(`bash: line ${a}: ${t}[${s}]: bad array subscript
|
|
653
|
+
`)}}}return{index:n}}async function Ao(e,t,s,r,n,i,o){let a="",c=s,u=null;if(ce(e,s)){let m=yr(e,s,r);if(m===void 0)return{continueToNext:!1,xtraceOutput:"",error:P(`bash: ${s}: circular name reference
|
|
654
|
+
`)};if(m===null)return{continueToNext:!0,xtraceOutput:""};c=m;let v=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);v&&(u={arrayName:v[1],subscriptExpr:v[2]},c=v[1])}if(Fe(e,c)){if(t.name)return a+=`bash: ${c}: readonly variable
|
|
655
|
+
`,{continueToNext:!0,xtraceOutput:a};let m=te(e,c);if(m)return{continueToNext:!1,xtraceOutput:"",error:m}}let l,f=!!o&&!n&&!u;if(ot(e,c)){f=!1;try{let m=new H;if(n){let $=`(${x(e.state.env,c,"0")}) + (${r})`,_=Q(m,$);l=String(await q(e,_.expression))}else{let v=Q(m,r);l=String(await q(e,v.expression))}}catch{l="0"}}else{let{isArray:m}=await import("./chunks/expansion-7AYBVOIQ.js"),v=m(e,c);v&&(f=!1);let $=v?`${c}_0`:c;l=n?x(e.state.env,$)+r:r}let d=Xe(e,c,l);d!==l&&(f=!1),l=d,a+=await Vn(e,c,l);let h=c;if(u)h=await _o(e,u);else{let{isArray:m}=await import("./chunks/expansion-7AYBVOIQ.js");m(e,c)&&(h=`${c}_0`,f=!1)}let g=f?()=>e.state.env.set(h,o):()=>w(e.state.env,h,l);return t.name?(i.set(h,e.state.env.get(h)),g()):(g(),e.state.options.allexport&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(c)),e.state.tempEnvBindings?.some(m=>m.has(c))&&(e.state.mutatedTempEnvVars=e.state.mutatedTempEnvVars||new Set,e.state.mutatedTempEnvVars.add(c))),{continueToNext:!1,xtraceOutput:a}}async function _o(e,t){let{arrayName:s,subscriptExpr:r}=t;if(e.state.associativeArrays?.has(s))return jn(e,s,r);let i;if(/^-?\d+$/.test(r))i=Number.parseInt(r,10);else{try{let o=new H,a=Q(o,r);i=await q(e,a.expression,!1)}catch{let o=x(e.state.env,r);i=o?Number.parseInt(o,10):0}Number.isNaN(i)&&(i=0)}if(i<0){let o=be(e,s);o.length>0&&(i=Math.max(...o.map(c=>c[0]))+1+i)}return`${s}_${i}`}async function Hn(e,t,s,r){let n=await Ce(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,d=e.state.fullyUnsetLocals;if(e.state.localScopes=u.map(A=>new Map(A)),l){e.state.localVarStack=new Map;for(let[A,L]of l.entries())e.state.localVarStack.set(A,L.map(I=>({...I})))}f&&(e.state.localVarDepth=new Map(f)),d&&(e.state.fullyUnsetLocals=new Map(d));let h=e.state.loopDepth,g=e.state.parentHasLoopContext;e.state.parentHasLoopContext=h>0,e.state.loopDepth=0;let m=e.state.lastArg,v=e.state.bashPid;e.state.bashPid=e.state.nextVirtualPid++;let $=e.state.groupStdin;Be(s)||(e.state.groupStdin=s);let _=p,k=p,y=0,b=()=>{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=d,e.state.loopDepth=h,e.state.parentHasLoopContext=g,e.state.groupStdin=$,e.state.bashPid=v,e.state.lastArg=m};try{for(let A of t.body){let L=await r(A);_=N(_,L.stdout),k=N(k,L.stderr),y=L.exitCode}}catch(A){if(b(),A instanceof ie)throw A;if(A instanceof Oe){_=N(_,A.stdout),k=N(k,A.stderr);let I=T(_,k,0);return Z(e,I,t.redirections)}if(A instanceof pe||A instanceof me){_=N(_,A.stdout),k=N(k,A.stderr);let I=T(_,k,0);return Z(e,I,t.redirections)}if(A instanceof G){_=N(_,A.stdout),k=N(k,A.stderr);let I=T(_,k,A.exitCode);return Z(e,I,t.redirections)}if(A instanceof le){_=N(_,A.stdout),k=N(k,A.stderr);let I=T(_,k,A.exitCode);return Z(e,I,t.redirections)}if(A instanceof ge){let I=T(N(_,A.stdout),N(k,A.stderr),A.exitCode);return Z(e,I,t.redirections)}let L=T(_,N(k,E(`${ke(A)}
|
|
656
|
+
`)),1);return Z(e,L,t.redirections)}b();let C=T(_,k,y);return Z(e,C,t.redirections)}async function Un(e,t,s,r){let n=p,i=p,o=0,a=await Vt(e,t.redirections);if(a)return a;let c=s;for(let f of t.redirections)if((f.operator==="<<"||f.operator==="<<-")&&f.target.type==="HereDoc"){let d=f.target,h=await F(e,d.content);d.stripTabs&&(h=h.split(`
|
|
657
|
+
`).map(m=>m.replace(/^\t+/,"")).join(`
|
|
658
|
+
`));let g=f.fd??0;g!==0?(e.state.fileDescriptors||(e.state.fileDescriptors=new Map),e.state.fileDescriptors.set(g,h)):c=E(h)}else if(f.operator==="<<<"&&f.target.type==="Word")c=E(`${await F(e,f.target)}
|
|
659
|
+
`);else if(f.operator==="<"&&f.target.type==="Word")try{let d=await F(e,f.target),h=e.fs.resolvePath(e.state.cwd,d);c=E(await e.fs.readFile(h))}catch{let d=await F(e,f.target);return P(`bash: ${d}: No such file or directory
|
|
660
|
+
`)}let u=e.state.groupStdin;Be(c)||(e.state.groupStdin=c);try{for(let f of t.body){let d=await r(f);n=N(n,d.stdout),i=N(i,d.stderr),o=d.exitCode}}catch(f){if(e.state.groupStdin=u,f instanceof ie)throw f;if(vt(f)||f instanceof ge||f instanceof G)throw f.prependOutput(n,i),f;return T(n,N(i,E(`${ke(f)}
|
|
661
|
+
`)),1)}e.state.groupStdin=u;let l=T(n,i,o);return Z(e,l,t.redirections)}async function Gn(e,t,s,r,n){let i;try{i=await e.fs.readFile(t)}catch{return P(`bash: ${t}: No such file or directory
|
|
662
|
+
`,127)}if(i.startsWith("#!")){let v=i.indexOf(`
|
|
663
|
+
`);v!==-1&&(i=i.slice(v+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,d=e.state.bashPid,h=e.state.groupStdin,g=e.state.currentSource;e.state.parentHasLoopContext=u>0,e.state.loopDepth=0,e.state.bashPid=e.state.nextVirtualPid++,Be(r)||(e.state.groupStdin=r),e.state.currentSource=t,w(e.state.env,"0",t),w(e.state.env,"#",String(s.length)),w(e.state.env,"@",s.join(" ")),w(e.state.env,"*",s.join(" "));for(let v=0;v<s.length&&v<9;v++)w(e.state.env,String(v+1),s[v]);for(let v=s.length+1;v<=9;v++)e.state.env.delete(String(v));let m=()=>{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=d,e.state.groupStdin=h,e.state.currentSource=g};try{let $=new H().parse(i),_=await n($);return m(),_}catch(v){if(m(),v instanceof G||v instanceof ie)throw v;if(v.name==="ParseException")return P(`bash: ${t}: ${v.message}
|
|
664
|
+
`);throw v}}function Po(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(ce(e,r.parameter)){let n=Ae(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 ut=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]=x(this.ctx.state.env,i));return n}async executeScript(t){let s=p,r=p,n=0;for(let i of t.statements)try{let o=await this.executeStatement(i);s=N(s,o.stdout),r=N(r,o.stderr),n=o.exitCode,this.ctx.state.lastExitCode=n,w(this.ctx.state.env,"?",String(n))}catch(o){if(o instanceof G)throw o.prependOutput(s,r),o;if(o instanceof we)return s=N(s,o.stdout),r=N(r,o.stderr),n=o.exitCode,this.ctx.state.lastExitCode=n,w(this.ctx.state.env,"?",String(n)),{stdout:s,stderr:r,exitCode:n,env:Te(this.ctx.state.env)};if(o instanceof ie)throw o;if(o instanceof ge)return s=N(s,o.stdout),r=N(r,o.stderr),n=o.exitCode,this.ctx.state.lastExitCode=n,w(this.ctx.state.env,"?",String(n)),{stdout:s,stderr:r,exitCode:n,env:Te(this.ctx.state.env)};if(o instanceof or)return s=N(s,o.stdout),r=N(r,o.stderr),n=1,this.ctx.state.lastExitCode=n,w(this.ctx.state.env,"?",String(n)),{stdout:s,stderr:r,exitCode:n,env:Te(this.ctx.state.env)};if(o instanceof gt)return s=N(s,o.stdout),r=N(r,o.stderr),n=1,this.ctx.state.lastExitCode=n,w(this.ctx.state.env,"?",String(n)),{stdout:s,stderr:r,exitCode:n,env:Te(this.ctx.state.env)};if(o instanceof Me){s=N(s,o.stdout),r=N(r,o.stderr),n=1,this.ctx.state.lastExitCode=n,w(this.ctx.state.env,"?",String(n));continue}if(o instanceof ar){s=N(s,o.stdout),r=N(r,o.stderr),n=1,this.ctx.state.lastExitCode=n,w(this.ctx.state.env,"?",String(n));continue}if(o instanceof pe||o instanceof me){if(this.ctx.state.loopDepth>0)throw o.prependOutput(s,r),o;s=N(s,o.stdout),r=N(r,o.stderr);continue}throw o instanceof le&&o.prependOutput(s,r),o}return{stdout:s,stderr:r,exitCode:n,env:Te(this.ctx.state.env)}}async executeUserScript(t,s,r=p){return Gn(this.ctx,t,tt(s),r,n=>this.executeScript(n))}async executeStatement(t){if(this.ctx.state.commandCount++,this.ctx.state.commandCount>this.ctx.limits.maxCommandCount&&xe(`too many commands executed (>${this.ctx.limits.maxCommandCount}), increase executionLimits.maxCommandCount`,"commands"),t.deferredError)throw new bt(t.deferredError.message,t.line??1,1);if(this.ctx.state.options.noexec)return V;this.ctx.state.errexitSafe=!1;let s=p,r=p;this.ctx.state.options.verbose&&!this.ctx.state.suppressVerbose&&t.sourceText&&(r=N(r,E(`${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 d=await this.executePipeline(l);s=N(s,d.stdout),r=N(r,d.stderr),n=d.exitCode,i=u,o=l.negated,this.ctx.state.lastExitCode=n,w(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 ge(n,s,r);return{stdout:s,stderr:r,exitCode:n}}async executePipeline(t){return zn(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 xn(this.ctx,t);case"For":return On(this.ctx,t);case"CStyleFor":return Tn(this.ctx,t);case"While":return Dn(this.ctx,t,s);case"Until":return In(this.ctx,t);case"Case":return Rn(this.ctx,t);case"Subshell":return this.executeSubshell(t,s);case"Group":return this.executeGroup(t,s);case"FunctionDef":return Xr(this.ctx,t);case"ArithmeticCommand":return this.executeArithmeticCommand(t);case"ConditionalCommand":return this.executeConditionalCommand(t);default:return V}}async executeSimpleCommand(t,s){try{return await this.executeSimpleCommandInner(t,s)}catch(r){if(r instanceof wt)return{stdout:p,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 y=t,b=100;for(;b>0;){let C=this.expandAlias(y);if(C===y)break;y=C,b--}this.aliasExpansionStack.clear(),y!==t&&(t=y)}this.ctx.state.expansionStderr="";let r=await Bn(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 b=await Ce(this.ctx,t.redirections);if(b)return b;let C={stdout:p,stderr:E(i),exitCode:0};return Z(this.ctx,C,t.redirections)}this.ctx.state.lastArg=E("");let y=(this.ctx.state.expansionStderr||"")+i;return this.ctx.state.expansionStderr="",{stdout:p,stderr:E(y),exitCode:this.ctx.state.lastExitCode}}let o=t.name&&tr(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 y of a)this.ctx.state.tempExportedVars.add(y)}let c=await Vt(this.ctx,t.redirections);if(c){for(let[y,b]of n)b===void 0?this.ctx.state.env.delete(y):this.ctx.state.env.set(y,b);return c}let u=-1;for(let y of t.redirections){if((y.operator==="<<"||y.operator==="<<-")&&y.target.type==="HereDoc"){let b=y.target,C=y.fd??0;if(C===0&&!b.stripTabs)s=await je(this.ctx,b.content);else{let A=await F(this.ctx,b.content);b.stripTabs&&(A=A.split(`
|
|
666
|
+
`).map(L=>L.replace(/^\t+/,"")).join(`
|
|
667
|
+
`)),C!==0?(this.ctx.state.fileDescriptors||(this.ctx.state.fileDescriptors=new Map),this.ctx.state.fileDescriptors.set(C,A)):s=E(A)}continue}if(y.operator==="<<<"&&y.target.type==="Word"){let b=await je(this.ctx,y.target);s=N(b,E(`
|
|
668
|
+
`));continue}if(y.operator==="<"&&y.target.type==="Word")try{let b=await F(this.ctx,y.target),C=this.ctx.fs.resolvePath(this.ctx.state.cwd,b);s=await this.ctx.fs.readFileBuffer(C)}catch{let b=await F(this.ctx,y.target);for(let[C,A]of n)A===void 0?this.ctx.state.env.delete(C):this.ctx.state.env.set(C,A);return P(`bash: ${b}: No such file or directory
|
|
669
|
+
`)}if(y.operator==="<&"&&y.target.type==="Word"){let b=await F(this.ctx,y.target),C=Number.parseInt(b,10);if(!Number.isNaN(C)&&this.ctx.state.fileDescriptors){let A=this.ctx.state.fileDescriptors.get(C);if(A!==void 0)if(A.startsWith("__rw__:")){let L=Ln(A);L&&(s=E(L.content.slice(L.position)),u=C)}else A.startsWith("__file__:")||A.startsWith("__file_append__:")||(s=E(A))}}}let l=await F(this.ctx,t.name),f=[],d=[];if(tr(t.name,["local","declare","typeset","export","readonly"])&&(l==="local"||l==="declare"||l==="typeset"||l==="export"||l==="readonly"))for(let y of t.args){let b=await Ir(this.ctx,y);if(b)f.push(E(b)),d.push(!0);else{let C=await Rr(this.ctx,y);if(C!==null)f.push(E(C)),d.push(!0);else{let A=await _e(this.ctx,y);for(let L of A.values)f.push(E(L)),d.push(A.quoted)}}}else for(let y of t.args)if(Po(this.ctx,y))f.push(await je(this.ctx,y)),d.push(!0);else{let b=await _e(this.ctx,y);for(let C of b.values)f.push(E(C)),d.push(b.quoted)}if(!l){if(t.name.parts.every(b=>b.type==="CommandSubstitution"||b.type==="ParameterExpansion"||b.type==="ArithmeticExpansion")){if(f.length>0){let b=z(f.shift());return d.shift(),await this.runCommand(b,f,d,s,!1,!1,u)}return{stdout:p,stderr:p,exitCode:this.ctx.state.lastExitCode}}return P(`bash: : command not found
|
|
670
|
+
`,127)}if(l==="exec"&&(f.length===0||z(f[0])==="--")){for(let y of t.redirections){if(y.target.type==="HereDoc"||y.fdVariable)continue;let b=await F(this.ctx,y.target),C=y.fd??(y.operator==="<"||y.operator==="<>"?0:1);switch(this.ctx.state.fileDescriptors||(this.ctx.state.fileDescriptors=new Map),y.operator){case">":case">|":{let A=this.ctx.fs.resolvePath(this.ctx.state.cwd,b);await this.ctx.fs.writeFile(A,"","utf8"),this.ctx.state.fileDescriptors.set(C,`__file__:${A}`);break}case">>":{let A=this.ctx.fs.resolvePath(this.ctx.state.cwd,b);this.ctx.state.fileDescriptors.set(C,`__file_append__:${A}`);break}case"<":{let A=this.ctx.fs.resolvePath(this.ctx.state.cwd,b);try{let L=await this.ctx.fs.readFile(A);this.ctx.state.fileDescriptors.set(C,L)}catch{return P(`bash: ${b}: No such file or directory
|
|
671
|
+
`)}break}case"<>":{let A=this.ctx.fs.resolvePath(this.ctx.state.cwd,b);try{let L=await this.ctx.fs.readFile(A);this.ctx.state.fileDescriptors.set(C,`__rw__:${A.length}:${A}:0:${L}`)}catch{await this.ctx.fs.writeFile(A,"","utf8"),this.ctx.state.fileDescriptors.set(C,`__rw__:${A.length}:${A}:0:`)}break}case">&":{if(b==="-")this.ctx.state.fileDescriptors.delete(C);else if(b.endsWith("-")){let A=b.slice(0,-1),L=Number.parseInt(A,10);if(!Number.isNaN(L)){let I=this.ctx.state.fileDescriptors.get(L);I!==void 0?this.ctx.state.fileDescriptors.set(C,I):this.ctx.state.fileDescriptors.set(C,`__dupout__:${L}`),this.ctx.state.fileDescriptors.delete(L)}}else{let A=Number.parseInt(b,10);Number.isNaN(A)||this.ctx.state.fileDescriptors.set(C,`__dupout__:${A}`)}break}case"<&":{if(b==="-")this.ctx.state.fileDescriptors.delete(C);else if(b.endsWith("-")){let A=b.slice(0,-1),L=Number.parseInt(A,10);if(!Number.isNaN(L)){let I=this.ctx.state.fileDescriptors.get(L);I!==void 0?this.ctx.state.fileDescriptors.set(C,I):this.ctx.state.fileDescriptors.set(C,`__dupin__:${L}`),this.ctx.state.fileDescriptors.delete(L)}}else{let A=Number.parseInt(b,10);Number.isNaN(A)||this.ctx.state.fileDescriptors.set(C,`__dupin__:${A}`)}break}}}for(let[y,b]of n)b===void 0?this.ctx.state.env.delete(y):this.ctx.state.env.set(y,b);if(this.ctx.state.tempExportedVars)for(let y of n.keys())this.ctx.state.tempExportedVars.delete(y);return V}let g=await Wn(this.ctx,l,f.map(y=>z(y)));n.size>0&&(this.ctx.state.tempEnvBindings=this.ctx.state.tempEnvBindings||[],this.ctx.state.tempEnvBindings.push(new Map(n)));let m,v=null;try{m=await this.runCommand(l,f,d,s,!1,!1,u)}catch(y){if(y instanceof pe||y instanceof me)v=y,m=V;else throw y}let $=i+g;if($&&(m={...m,stderr:N(E($),m.stderr)}),m=await Z(this.ctx,m,t.redirections),v)throw v;if(f.length>0){let y=z(f[f.length-1]);if((l==="declare"||l==="local"||l==="typeset")&&/^[a-zA-Z_][a-zA-Z0-9_]*=\(/.test(y)){let b=y.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\(/);b&&(y=b[1])}this.ctx.state.lastArg=E(y)}else this.ctx.state.lastArg=E(l);let _=Yr(l)&&l!=="unset"&&l!=="eval";if(!this.ctx.state.options.posix||!_)for(let[y,b]of n)this.ctx.state.fullyUnsetLocals?.has(y)||(b===void 0?this.ctx.state.env.delete(y):this.ctx.state.env.set(y,b));if(this.ctx.state.tempExportedVars)for(let y of n.keys())this.ctx.state.tempExportedVars.delete(y);return n.size>0&&this.ctx.state.tempEnvBindings&&this.ctx.state.tempEnvBindings.pop(),this.ctx.state.expansionStderr&&(m={...m,stderr:N(E(this.ctx.state.expansionStderr),m.stderr)},this.ctx.state.expansionStderr=""),m}async runCommand(t,s,r,n,i=!1,o=!1,a=-1){let c={ctx:this.ctx,runCommand:(l,f,d,h,g,m,v)=>this.runCommand(l,f,d,h,g,m,v),buildExportedEnv:()=>this.buildExportedEnv(),executeUserScript:(l,f,d)=>this.executeUserScript(l,f,d)},u=await kn(c,t,s,r,n,i,o,a);return u!==null?u:Nn(c,t,s,n,o)}aliasExpansionStack=new Set;expandAlias(t){return us(this.ctx.state,t,this.aliasExpansionStack)}async findCommandInPath(t){return qt(this.ctx,t)}async executeSubshell(t,s=p){return Hn(this.ctx,t,s,r=>this.executeStatement(r))}async executeGroup(t,s=p){return Un(this.ctx,t,s,r=>this.executeStatement(r))}async executeArithmeticCommand(t){t.line!==void 0&&(this.ctx.state.currentLine=t.line);let s=await Ce(this.ctx,t.redirections);if(s)return s;try{let r=await q(this.ctx,t.expression.expression),n=X(r!==0);return this.ctx.state.expansionStderr&&(n={...n,stderr:N(E(this.ctx.state.expansionStderr),n.stderr)},this.ctx.state.expansionStderr=""),Z(this.ctx,n,t.redirections)}catch(r){let n=P(`bash: arithmetic expression: ${r.message}
|
|
672
|
+
`);return Z(this.ctx,n,t.redirections)}}async executeConditionalCommand(t){t.line!==void 0&&(this.ctx.state.currentLine=t.line);let s=await Ce(this.ctx,t.redirections);if(s)return s;try{let r=await Re(this.ctx,t.expression),n=X(r);return this.ctx.state.expansionStderr&&(n={...n,stderr:N(E(this.ctx.state.expansionStderr),n.stderr)},this.ctx.state.expansionStderr=""),Z(this.ctx,n,t.redirections)}catch(r){let n=r instanceof Me?1:2,i=P(`bash: conditional expression: ${r.message}
|
|
673
|
+
`,n);return Z(this.ctx,i,t.redirections)}}};var fe={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 qn(e){return e?{maxCallDepth:e.maxCallDepth??fe.maxCallDepth,maxCommandCount:e.maxCommandCount??fe.maxCommandCount,maxLoopIterations:e.maxLoopIterations??fe.maxLoopIterations,maxAwkIterations:e.maxAwkIterations??fe.maxAwkIterations,maxSedIterations:e.maxSedIterations??fe.maxSedIterations,maxJqIterations:e.maxJqIterations??fe.maxJqIterations,maxSqliteTimeoutMs:e.maxSqliteTimeoutMs??fe.maxSqliteTimeoutMs,maxPythonTimeoutMs:e.maxPythonTimeoutMs??fe.maxPythonTimeoutMs,maxGlobOperations:e.maxGlobOperations??fe.maxGlobOperations,maxStringLength:e.maxStringLength??fe.maxStringLength,maxArrayElements:e.maxArrayElements??fe.maxArrayElements,maxHeredocSize:e.maxHeredocSize??fe.maxHeredocSize,maxSubstitutionDepth:e.maxSubstitutionDepth??fe.maxSubstitutionDepth}:{...fe}}function Zn(e){try{let t=new URL(e);return{origin:t.origin,pathname:t.pathname,href:t.href}}catch{return null}}function Co(e){let t=Zn(e);return t?{origin:t.origin,pathPrefix:t.pathname}:null}function ko(e,t){let s=Zn(e);if(!s)return!1;let r=Co(t);return!r||s.origin!==r.origin?!1:r.pathPrefix==="/"||r.pathPrefix===""?!0:s.pathname.startsWith(r.pathPrefix)}function sr(e,t){return!t||t.length===0?!1:t.some(s=>ko(e,s))}var ft=class extends Error{constructor(t){super(`Network access denied: URL not in allow-list: ${t}`),this.name="NetworkAccessDeniedError"}},dt=class extends Error{constructor(t){super(`Too many redirects (max: ${t})`),this.name="TooManyRedirectsError"}},ht=class extends Error{constructor(t){super(`Redirect target not in allow-list: ${t}`),this.name="RedirectNotAllowedError"}},Yt=class extends Error{constructor(t,s){super(`HTTP method '${t}' not allowed. Allowed methods: ${s.join(", ")}`),this.name="MethodNotAllowedError"}},pt=class extends Error{constructor(t){super(`Response body too large (max: ${t} bytes)`),this.name="ResponseTooLargeError"}};var No=20,xo=3e4,Oo=10485760,To=["GET","HEAD"],Do=new Set(["GET","HEAD","OPTIONS"]),Io=new Set([301,302,303,307,308]);function rr(e){let t=e.maxRedirects??No,s=e.timeoutMs??xo,r=e.maxResponseSize??Oo,n=e.dangerouslyAllowFullInternetAccess?["GET","HEAD","POST","PUT","DELETE","PATCH","OPTIONS"]:e.allowedMethods??To;function i(c){if(!e.dangerouslyAllowFullInternetAccess&&!sr(c,e.allowedUrlPrefixes??[]))throw new ft(c)}function o(c){if(e.dangerouslyAllowFullInternetAccess)return;let u=c.toUpperCase();if(!n.includes(u))throw new Yt(u,n)}async function a(c,u={}){let l=u.method?.toUpperCase()??"GET";i(c),o(l);let f=c,d=0,h=u.followRedirects??!0,g=u.timeoutMs!==void 0?Math.min(u.timeoutMs,s):s;for(;;){let m=new AbortController,v=setTimeout(()=>m.abort(),g);try{let $={method:l,headers:u.headers,signal:m.signal,redirect:"manual"};u.body&&!Do.has(l)&&($.body=u.body);let _=await fetch(f,$);if(Io.has(_.status)&&h){let k=_.headers.get("location");if(!k)return await Yn(_,f,r);let y=new URL(k,f).href;if(!e.dangerouslyAllowFullInternetAccess&&!sr(y,e.allowedUrlPrefixes??[]))throw new ht(y);if(d++,d>t)throw new dt(t);f=y;continue}return await Yn(_,f,r)}finally{clearTimeout(v)}}}return a}async function Yn(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 pt(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 pt(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 Kn(){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 mt=typeof __BROWSER__<"u"&&__BROWSER__;function Xn(){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 ir=null;if(!mt)try{let{createRequire:e}=await import("node:module");ir=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 Ro=`
|
|
674
|
+
|
|
675
|
+
This is a defense-in-depth measure and indicates a bug in just-bash. Please report this at security@vercel.com`,ae=class extends Error{violation;constructor(t,s){super(t+Ro),this.violation=s,this.name="SecurityViolationError"}},de=!mt&&ir?new ir:null,Lo=1e3,nr={enabled:!0,auditMode:!1};function Mo(e){return e===void 0?{...nr,enabled:!1}:typeof e=="boolean"?{...nr,enabled:e}:{...nr,...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(Mo(t))),e.instance}static resetInstance(){e.instance&&(e.instance.forceDeactivate(),e.instance=null)}static isInSandboxedContext(){return de?de?.getStore()?.sandboxActive===!0:!1}static getCurrentExecutionId(){if(de)return de?.getStore()?.executionId}updateConfig(t){this.config={...this.config,...t}}activate(){if(mt||!this.config.enabled){let s=Xn();return{run:r=>r(),deactivate:()=>{},executionId:s}}this.refCount++,this.refCount===1&&(this.applyPatches(),this.activationTime=Date.now());let t=Xn();return{run:s=>de.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||!de?!1:de?.getStore()?.sandboxActive===!0}recordViolation(t,s,r){let n={timestamp:Date.now(),type:t,message:r,path:s,stack:new Error().stack,executionId:de?.getStore()?.executionId};if(this.violations.length<Lo&&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 ae(c,u)}return n.config.auditMode&&de?.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 ae(c,u)}return n.config.auditMode&&de?.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 ae(u,l)}if(n.config.auditMode&&de?.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 ae(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 ae(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 ae(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 ae(c,u)}return Reflect.has(i,o)}})}applyPatches(){let t=Kn();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 ae(i,o)}t.config.auditMode&&de?.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 ae(a,c)}return n.config.auditMode&&de?.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 ae(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 ae(n,i)}return t.config.auditMode&&de?.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 ae(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(!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,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 Xt=class{fs;commands=new Map;useDefaultLayout=!1;limits;secureFetch;sleepFn;traceFn;logger;defenseInDepthConfig;coverageWriter;state;constructor(t={}){let s=t.fs??new rt(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)w(n,o,a);for(let[o,a]of Object.entries(t.env??{}))w(n,o,a);if(this.limits=qn({...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=rr(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:p,startTime:Date.now(),lastBackgroundPid:0,bashPid:Qt().pid,nextVirtualPid:Qt().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},w(this.state.env,"SHELLOPTS",as(this.state.options)),w(this.state.env,"BASHOPTS",ls(this.state.shoptOptions)),kr(s,this.useDefaultLayout),r!=="/"&&s instanceof rt)try{s.mkdirSync(r,{recursive:!0})}catch{}for(let o of $r(t.commands))this.registerCommand(o);if(t.network)for(let o of Ar())this.registerCommand(o);if(t.python)for(let o of _r())this.registerCommand(o);if(t.customCommands)for(let o of t.customCommands)Pr(o)?this.registerCommand(Cr(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
|
+
# Built-in command: ${t.name}
|
|
678
|
+
`;try{s.writeFileSync(`/bin/${t.name}`,r)}catch{}try{s.writeFileSync(`/usr/bin/${t.name}`,r)}catch{}}}logResult(t){return this.logger&&(t.stdout.length>0&&this.logger.debug("stdout",{output:z(t.stdout)}),t.stderr.length>0&&this.logger.info("stderr",{output:z(t.stderr)}),this.logger.info("exit",{exitCode:t.exitCode})),t}async exec(t,s){if(this.state.callDepth===0&&(this.state.commandCount=0),this.state.commandCount++,this.state.commandCount>this.limits.maxCommandCount)return{stdout:p,stderr:E(`bash: maximum command count (${this.limits.maxCommandCount}) exceeded (possible infinite loop). Increase with executionLimits.maxCommandCount option.
|
|
679
|
+
`),exitCode:1,env:ve(this.state.env,s?.env)};if(!t.trim())return{stdout:p,stderr:p,exitCode:0,env:ve(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,d]of Object.entries(s.env))w(o,f,d);n!==void 0&&w(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=Fo(t));let l=(this.defenseInDepthConfig?Kt.getInstance(this.defenseInDepthConfig):null)?.activate();try{let f=async()=>{let d=Se(c),h={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},m=await new ut(h,a).executeScript(d);return this.logResult(m)};return l?await l.run(f):await f()}catch(f){if(f instanceof G)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:ve(this.state.env,s?.env)});if(f instanceof we)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:ve(this.state.env,s?.env)});if(f instanceof Me)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:1,env:ve(this.state.env,s?.env)});if(f instanceof ie)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:ie.EXIT_CODE,env:ve(this.state.env,s?.env)});if(f instanceof ae)return this.logResult({stdout:p,stderr:E(`bash: security violation: ${f.message}
|
|
680
|
+
`),exitCode:1,env:ve(this.state.env,s?.env)});if(f.name==="ParseException")return this.logResult({stdout:p,stderr:E(`bash: syntax error: ${f.message}
|
|
681
|
+
`),exitCode:2,env:ve(this.state.env,s?.env)});if(f instanceof ur)return this.logResult({stdout:p,stderr:E(`bash: ${f.message}
|
|
682
|
+
`),exitCode:2,env:ve(this.state.env,s?.env)});if(f instanceof RangeError)return this.logResult({stdout:p,stderr:E(`bash: ${f.message}
|
|
683
|
+
`),exitCode:1,env:ve(this.state.env,s?.env)});throw f}finally{l?.deactivate()}}async readFile(t){return this.fs.readFile(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 Te(this.state.env)}};function Fo(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 J from"node:fs";import*as Qe from"node:path";var Wo="/home/user/project";function re(e,t){if(e.includes("\0"))throw new Error(`ENOENT: path contains null byte, ${t} '${e}'`)}var Je=class{root;mountPoint;readOnly;maxFileReadSize;memory=new Map;deleted=new Set;constructor(t){this.root=Qe.resolve(t.root);let s=t.mountPoint??Wo;if(this.mountPoint=s==="/"?"/":s.replace(/\/+$/,""),!this.mountPoint.startsWith("/"))throw new Error(`Mount point must be an absolute path: ${s}`);if(this.readOnly=t.readOnly??!1,this.maxFileReadSize=t.maxFileReadSize??10485760,!J.existsSync(this.root))throw new Error(`OverlayFs root does not exist: ${this.root}`);if(!J.statSync(this.root).isDirectory())throw new Error(`OverlayFs root is not a directory: ${this.root}`);this.createMountPointDirs()}assertWritable(t){if(this.readOnly)throw new Error(`EROFS: read-only file system, ${t}`)}createMountPointDirs(){let t=this.mountPoint.split("/").filter(Boolean),s="";for(let r of t)s+=`/${r}`,this.memory.has(s)||this.memory.set(s,{type:"directory",mode:493,mtime:new Date});this.memory.has("/")||this.memory.set("/",{type:"directory",mode:493,mtime:new Date})}getMountPoint(){return this.mountPoint}mkdirSync(t,s){let n=this.normalizePath(t).split("/").filter(Boolean),i="";for(let o of n)i+=`/${o}`,this.memory.has(i)||this.memory.set(i,{type:"directory",mode:493,mtime:new Date})}writeFileSync(t,s){let r=this.normalizePath(t),n=this.getDirname(r);n!=="/"&&this.mkdirSync(n);let i=s instanceof Uint8Array?s:new TextEncoder().encode(s);this.memory.set(r,{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 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=Qe.join(this.root,r),i=Qe.resolve(n);return!i.startsWith(this.root)&&i!==this.root.replace(/\/$/,"")?null:i}dirname(t){let s=this.normalizePath(t);if(s==="/")return"/";let r=s.lastIndexOf("/");return r===0?"/":s.slice(0,r)}ensureParentDirs(t){let s=this.dirname(t);s!=="/"&&(this.memory.has(s)||(this.ensureParentDirs(s),this.memory.set(s,{type:"directory",mode:493,mtime:new Date})),this.deleted.delete(s))}async existsInOverlay(t){let s=this.normalizePath(t);if(this.deleted.has(s))return!1;if(this.memory.has(s))return!0;let r=this.toRealPath(s);if(!r)return!1;try{return await J.promises.access(r),!0}catch{return!1}}async readFile(t,s){let r=await this.readFileBuffer(t),n=Ie(s);return At(r,n)}async readFileBuffer(t,s=new Set){re(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.readFileBuffer(o,s)}if(n.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);return n.content}let i=this.toRealPath(r);if(!i)throw new Error(`ENOENT: no such file or directory, open '${t}'`);try{let o=await J.promises.lstat(i);if(o.isSymbolicLink()){let c=await J.promises.readlink(i),u=this.resolveSymlink(r,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,r){re(t,"write"),this.assertWritable(`write '${t}'`);let n=this.normalizePath(t);this.ensureParentDirs(n);let i=Ie(r),o=Ue(s,i);this.memory.set(n,{type:"file",content:o,mode:420,mtime:new Date}),this.deleted.delete(n)}async appendFile(t,s,r){re(t,"append"),this.assertWritable(`append '${t}'`);let n=this.normalizePath(t),i=Ie(r),o=Ue(s,i),a;try{a=await this.readFileBuffer(n)}catch{a=new Uint8Array(0)}let c=new Uint8Array(a.length+o.length);c.set(a),c.set(o,a.length),this.ensureParentDirs(n),this.memory.set(n,{type:"file",content:c,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){re(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.content.length),{isFile:n.type==="file",isDirectory:n.type==="directory",isSymbolicLink:!1,mode:n.mode,size:o,mtime:n.mtime}}let i=this.toRealPath(r);if(!i)throw new Error(`ENOENT: no such file or directory, stat '${t}'`);try{let o=await J.promises.stat(i);return{isFile:o.isFile(),isDirectory:o.isDirectory(),isSymbolicLink:!1,mode:o.mode,size:o.size,mtime:o.mtime}}catch(o){throw o.code==="ENOENT"?new Error(`ENOENT: no such file or directory, stat '${t}'`):o}}async lstat(t){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 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.content.length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:i,mtime:r.mtime}}let n=this.toRealPath(s);if(!n)throw new Error(`ENOENT: no such file or directory, lstat '${t}'`);try{let i=await J.promises.lstat(n);return{isFile:i.isFile(),isDirectory:i.isDirectory(),isSymbolicLink:i.isSymbolicLink(),mode:i.mode,size:i.size,mtime:i.mtime}}catch(i){throw i.code==="ENOENT"?new Error(`ENOENT: no such file or directory, lstat '${t}'`):i}}resolveSymlink(t,s){if(s.startsWith("/"))return this.normalizePath(s);let r=this.dirname(t);return this.normalizePath(r==="/"?`/${s}`:`${r}/${s}`)}async mkdir(t,s){re(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 J.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 J.promises.lstat(c)).isSymbolicLink()){let l=await J.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){re(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){re(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){re(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){re(t,"cp"),re(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.readFileBuffer(n);await this.writeFile(i,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=J.readdirSync(r);for(let i of n){let o=t==="/"?`/${i}`:`${t}/${i}`;if(this.deleted.has(o))continue;s.add(o);let a=Qe.join(r,i);J.statSync(a).isDirectory()&&this.scanRealFs(o,s)}}catch{}}async chmod(t,s){re(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.readFileBuffer(r);this.memory.set(r,{type:"file",content:a,mode:s,mtime:new Date})}else o.isDirectory&&this.memory.set(r,{type:"directory",mode:s,mtime:new Date})}async symlink(t,s){re(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){re(t,"link"),re(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.readFileBuffer(r);this.ensureParentDirs(n),this.memory.set(n,{type:"file",content:c,mode:o.mode,mtime:new Date}),this.deleted.delete(n)}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 r=this.memory.get(s);if(r){if(r.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${t}'`);return r.target}let n=this.toRealPath(s);if(!n)throw new Error(`ENOENT: no such file or directory, readlink '${t}'`);try{return await J.promises.readlink(n)}catch(i){throw i.code==="ENOENT"?new Error(`ENOENT: no such file or directory, readlink '${t}'`):i.code==="EINVAL"?new Error(`EINVAL: invalid argument, readlink '${t}'`):i}}async realpath(t){re(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),d=0,h=40;for(;f&&f.type==="symlink"&&d<h;){if(r.add(u),u=this.resolveSymlink(u,f.target),d++,r.has(u))throw new Error(`ELOOP: too many levels of symbolic links, realpath '${t}'`);if(this.deleted.has(u))throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);f=this.memory.get(u)}if(d>=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 v=await J.promises.readlink(g);return r.add(u),u=this.resolveSymlink(u,v),n(u)}}catch(m){throw m.code==="ENOENT"?new Error(`ENOENT: no such file or directory, realpath '${t}'`):m}}}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){re(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.readFileBuffer(n);this.memory.set(n,{type:"file",content:c,mode:a.mode,mtime:r})}else a.isDirectory&&this.memory.set(n,{type:"directory",mode:a.mode,mtime:r})}};function Jn(){console.log(`just-bash - A secure bash environment for AI agents
|
|
686
|
+
|
|
687
|
+
Usage:
|
|
688
|
+
just-bash [options] [script-file]
|
|
689
|
+
just-bash -c 'script' [options]
|
|
690
|
+
echo 'script' | just-bash [options]
|
|
691
|
+
|
|
692
|
+
Options:
|
|
693
|
+
-c <script> Execute the script from command line argument
|
|
694
|
+
-e, --errexit Exit immediately if a command exits with non-zero status
|
|
695
|
+
--root <path> Root directory for OverlayFS (default: current directory)
|
|
696
|
+
--cwd <path> Working directory within the sandbox (default: project mount point)
|
|
697
|
+
--allow-write Allow write operations (default: read-only)
|
|
698
|
+
--python Enable python3/python commands (disabled by default)
|
|
699
|
+
--json Output results as JSON (stdout, stderr, exitCode)
|
|
700
|
+
-h, --help Show this help message
|
|
701
|
+
-v, --version Show version
|
|
702
|
+
|
|
703
|
+
Security:
|
|
704
|
+
- Reads from the real filesystem (read-only via OverlayFS)
|
|
705
|
+
- Write operations are blocked by default (use --allow-write to enable)
|
|
706
|
+
- Cannot escape the root directory
|
|
707
|
+
- No network access
|
|
708
|
+
|
|
709
|
+
Filesystem:
|
|
710
|
+
The root directory is mounted at /home/user/project in the virtual filesystem.
|
|
711
|
+
The working directory starts at this mount point.
|
|
712
|
+
|
|
713
|
+
Examples:
|
|
714
|
+
# List files in current directory
|
|
715
|
+
just-bash -c 'ls -la'
|
|
716
|
+
|
|
717
|
+
# Execute with specific root
|
|
718
|
+
just-bash -c 'cat package.json' --root /path/to/project
|
|
719
|
+
|
|
720
|
+
# Pipe script from stdin
|
|
721
|
+
echo 'find . -name "*.ts" | head -5' | just-bash
|
|
722
|
+
|
|
723
|
+
# Execute a script file
|
|
724
|
+
just-bash ./scripts/build.sh
|
|
725
|
+
|
|
726
|
+
# Get JSON output for programmatic use
|
|
727
|
+
just-bash -c 'echo hello' --json
|
|
728
|
+
|
|
729
|
+
# Allow write operations (writes stay in memory)
|
|
730
|
+
just-bash -c 'echo test > /tmp/file.txt && cat /tmp/file.txt' --allow-write
|
|
731
|
+
`)}function Vo(){console.log("just-bash 1.0.0")}function zo(e){let t={root:process.cwd(),cwd:"/",cwdOverridden:!1,errexit:!1,allowWrite:!1,python:!1,json:!1,help:!1,version:!1},s=0;for(;s<e.length;){let r=e[s];if(r==="-h"||r==="--help")t.help=!0,s++;else if(r==="-v"||r==="--version")t.version=!0,s++;else if(r==="-c")s+1>=e.length&&(console.error("Error: -c requires a script argument"),process.exit(1)),t.script=e[s+1],s+=2;else if(r==="-e"||r==="--errexit")t.errexit=!0,s++;else if(r==="--root")s+1>=e.length&&(console.error("Error: --root requires a path argument"),process.exit(1)),t.root=Qn(e[s+1]),s+=2;else if(r==="--cwd")s+1>=e.length&&(console.error("Error: --cwd requires a path argument"),process.exit(1)),t.cwd=e[s+1],t.cwdOverridden=!0,s+=2;else if(r==="--json")t.json=!0,s++;else if(r==="--allow-write")t.allowWrite=!0,s++;else if(r==="--python")t.python=!0,s++;else if(r.startsWith("-"))if(r.length>2&&!r.startsWith("--")){let n=r.slice(1);for(let i of n)if(i==="e")t.errexit=!0;else if(i==="h")t.help=!0;else if(i==="v")t.version=!0;else if(i==="c"){s+1>=e.length&&(console.error("Error: -c requires a script argument"),process.exit(1)),t.script=e[s+1],s++;break}else console.error(`Error: Unknown option: -${i}`),process.exit(1);s++}else console.error(`Error: Unknown option: ${r}`),process.exit(1);else!t.scriptFile&&!t.script?t.scriptFile=r:t.scriptFile&&t.root===process.cwd()&&(t.root=Qn(r)),s++}return t}function Bo(e){if(!e||e==="/")return"/";let t=e.endsWith("/")&&e!=="/"?e.slice(0,-1):e;t.startsWith("/")||(t=`/${t}`);let s=t.split("/").filter(n=>n&&n!=="."),r=[];for(let n of s)n===".."?r.pop():r.push(n);return`/${r.join("/")}`||"/"}async function jo(){let e=[];for await(let t of process.stdin)e.push(t);return Buffer.concat(e).toString("utf-8")}async function Ho(){let e=process.argv.slice(2),t=zo(e);t.help&&(Jn(),process.exit(0)),t.version&&(Vo(),process.exit(0));let s;if(t.script)s=t.script;else if(t.scriptFile){let a=new Je({root:t.root}),c=a.getMountPoint();try{let u=t.scriptFile.startsWith("/")?t.scriptFile:`${c}/${t.scriptFile}`;s=await a.readFile(u,"utf-8")}catch(u){console.error(`Error: Cannot read script file: ${t.scriptFile}`),console.error(u instanceof Error?u.message:String(u)),process.exit(1)}}else process.stdin.isTTY?(Jn(),process.exit(1)):s=await jo();s.trim()||(t.json&&console.log(JSON.stringify({stdout:"",stderr:"",exitCode:0})),process.exit(0));let r=new Je({root:t.root,readOnly:!t.allowWrite}),n=r.getMountPoint(),i=t.cwdOverridden?Bo(t.cwd):n,o=new Xt({fs:r,cwd:i,python:t.python});t.errexit&&(s=`set -e
|
|
732
|
+
${s}`);try{let a=await o.exec(s);t.json?console.log(JSON.stringify({stdout:z(a.stdout),stderr:z(a.stderr),exitCode:a.exitCode})):(a.stdout.length>0&&process.stdout.write(a.stdout),a.stderr.length>0&&process.stderr.write(a.stderr)),process.exit(a.exitCode)}catch(a){t.json?console.log(JSON.stringify({stdout:"",stderr:a instanceof Error?a.message:String(a),exitCode:1})):console.error(a instanceof Error?a.message:String(a)),process.exit(1)}}Ho().catch(e=>{console.error("Fatal error:",e),process.exit(1)});
|