@poe-platform/safe-bash 0.1.803 → 0.1.804
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -31
- package/dist/image-ast/ast.d.ts +1 -0
- package/dist/image-ast/browser/ast.d.ts +1 -0
- package/dist/image-ast/browser/codecs/jpeg.d.ts +2 -2
- package/dist/image-ast/codecs/jpeg.d.ts +2 -2
- package/dist/image-ast/index.browser.js +692 -8364
- package/dist/image-ast/index.js +692 -8364
- package/dist/mp4-ast/codecs.d.ts +7 -2
- package/dist/safe-bash/chunks/{chunk-CHYGPFVM.js → chunk-22SX3F2R.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-FBUCWVTE.js → chunk-2IVBJTBD.js} +1 -1
- package/dist/safe-bash/chunks/chunk-2POETUMB.js +190 -0
- package/dist/safe-bash/chunks/{chunk-XVOSKJE2.js → chunk-47D7WBJK.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-VKNVHEX3.js → chunk-4ESI236Y.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-74GHTNJA.js → chunk-4KTMKD5W.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-55YJASTN.js → chunk-4T53AERN.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-DQP3VHSB.js → chunk-5XIFJVOO.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-5OHX7C2V.js → chunk-62BOHHJT.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-HZAMGT5I.js → chunk-67WIFM3N.js} +17 -6
- package/dist/safe-bash/chunks/{chunk-4D4N7IU2.js → chunk-6LNFRPW5.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-6O77NL2S.js → chunk-6SMICPI3.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-4BSJLKNM.js → chunk-7O76UFQD.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-PNBBUWSM.js → chunk-AW5KIT6V.js} +3488 -39
- package/dist/safe-bash/chunks/{chunk-JMMEIDPF.js → chunk-B2Z73HTZ.js} +52 -28
- package/dist/safe-bash/chunks/chunk-B3ZMOJVM.js +319 -0
- package/dist/safe-bash/chunks/{chunk-7ZBU7KYV.js → chunk-CFAWS3O4.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-I5HZ4FGE.js → chunk-CL2FCTTO.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-2LSAMQER.js → chunk-CTXNARJH.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-TFIBK2GI.js → chunk-D5Q7NFWI.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-OQRVVGR6.js → chunk-DSOOVZ6Q.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-VTH3MLDU.js → chunk-DUTAG6ZD.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-XAQMU6OY.js → chunk-EE5YGFIZ.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-FZE4HW6G.js → chunk-EJOYT2ME.js} +1 -1
- package/dist/safe-bash/chunks/chunk-FAAIR6EJ.js +887 -0
- package/dist/safe-bash/chunks/{chunk-OV6IHKO6.js → chunk-FOB2FZR4.js} +2 -2
- package/dist/safe-bash/chunks/chunk-G6V4RRSQ.js +14 -0
- package/dist/safe-bash/chunks/{chunk-UTBUUFDM.js → chunk-GGQAGQXQ.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-K6VCD7IY.js → chunk-HIIYIJ5G.js} +2 -4
- package/dist/safe-bash/chunks/{chunk-VBTDHOWC.js → chunk-IOHH2GTI.js} +4 -3
- package/dist/safe-bash/chunks/{chunk-CTVWDACF.js → chunk-IQW34XQT.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-HZ7BWKQ3.js → chunk-IS572AAT.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-AUSNDQTJ.js → chunk-JPSUHHOA.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-ZVD5IS4V.js → chunk-KBZ4UB2O.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-AM5ESLPH.js → chunk-KU5CVWKA.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-RYFQ3LZG.js → chunk-LPOVNKNB.js} +173 -153
- package/dist/safe-bash/chunks/{chunk-46Z5E5EV.js → chunk-MBOC3LZ4.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-6PAVEFT3.js → chunk-N4BQFD3P.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-CS4MNM6I.js → chunk-NGKCVNWS.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-7R5BDCG7.js → chunk-OHML2BEU.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-C5OWC2TL.js → chunk-OQ3AGYCZ.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-B7TAL7S5.js → chunk-PTAEWLSE.js} +0 -2
- package/dist/safe-bash/chunks/{chunk-LVOBFF4D.js → chunk-Q4FNLOTI.js} +1 -1
- package/dist/safe-bash/chunks/chunk-Q5XO3NAS.js +1036 -0
- package/dist/safe-bash/chunks/{chunk-GEG3BWGE.js → chunk-RHFRJIWQ.js} +1 -1
- package/dist/safe-bash/chunks/chunk-RUR6J33T.js +11 -0
- package/dist/safe-bash/chunks/{chunk-EEEWOYEG.js → chunk-S4RFUUXO.js} +839 -24
- package/dist/safe-bash/chunks/{chunk-RRR7AQ24.js → chunk-SD2ISU5L.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-3NDIFSNM.js → chunk-SUJ3NTMH.js} +3 -3
- package/dist/safe-bash/chunks/{chunk-R3NAKOED.js → chunk-SZRUU5HS.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-PH63PLPZ.js → chunk-TC3F4UFF.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-3R3AANOR.js → chunk-TCKYOLUE.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-D3ANYGMC.js → chunk-UV4X32QU.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-E7OYNDGL.js → chunk-V7QT2RWC.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-B7PIL77G.js → chunk-W2IYOVHK.js} +804 -1195
- package/dist/safe-bash/chunks/{chunk-3HQU4OJO.js → chunk-XNGVOSGI.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-J42RIHHJ.js → chunk-XQWCQSRN.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-A7XEHALN.js → chunk-Y7FW6GLT.js} +6 -6
- package/dist/safe-bash/chunks/{chunk-QGUV42T5.js → chunk-YL3GBUG4.js} +1 -1
- package/dist/safe-bash/chunks/chunk-YOXUCJER.js +389 -0
- package/dist/safe-bash/chunks/{chunk-HBCN24ZA.js → chunk-Z2AAYYJN.js} +2 -2
- package/dist/safe-bash/chunks/chunk-ZKYKJCZZ.js +30 -0
- package/dist/safe-bash/chunks/core-IE3AFIDX.js +85806 -0
- package/dist/safe-bash/chunks/{ffmpeg-WTC3TEFI.js → ffmpeg-YANDK6HU.js} +2 -2
- package/dist/safe-bash/chunks/{gh-6WU6PXL4.js → gh-4MBJ2S5V.js} +2 -2
- package/dist/safe-bash/chunks/{git-EFZIGJW4.js → git-2QONJNRQ.js} +2 -2
- package/dist/safe-bash/chunks/{imagemagick-EIEYGWPF.js → imagemagick-JLEHGYSN.js} +2 -2
- package/dist/safe-bash/chunks/{mmdc-ROQJT5HQ.js → mmdc-6LD7A6ND.js} +2 -2
- package/dist/safe-bash/chunks/{pdfimages-DW7LWXFI.js → pdfimages-RSHL7LOP.js} +2 -2
- package/dist/safe-bash/chunks/{pdfinfo-TIP6XLUQ.js → pdfinfo-L3SGWPNG.js} +2 -2
- package/dist/safe-bash/chunks/{pdftk-DMG22ITZ.js → pdftk-LFBJNU5A.js} +2 -2
- package/dist/safe-bash/chunks/{pdftoppm-WNDYR72T.js → pdftoppm-NXXFUIHG.js} +2 -2
- package/dist/safe-bash/chunks/{pdftotext-5IPZ4NI7.js → pdftotext-4IHNWT6F.js} +2 -2
- package/dist/safe-bash/chunks/{qpdf-TTX2DIUA.js → qpdf-ZEIREV63.js} +2 -2
- package/dist/safe-bash/chunks/read-builtin-A4QKAT45.js +9 -0
- package/dist/safe-bash/chunks/{sips-XYS46JPJ.js → sips-D5YBG2V3.js} +2 -2
- package/dist/safe-bash/chunks/{soffice-TU73E5KL.js → soffice-RAJU3JUT.js} +2 -2
- package/dist/safe-bash/chunks/source-files-3XWRRHFA.js +7 -0
- package/dist/safe-bash/chunks/{wkhtmltopdf-FSZ2CHGE.js → wkhtmltopdf-7UE4FORZ.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-7KWZXKY6.js → chunk-26RTBV2I.js} +1 -0
- package/dist/safe-bash/command-chunks/{chunk-AQJ2ROJO.js → chunk-2WYNMZR2.js} +10 -8
- package/dist/safe-bash/command-chunks/{chunk-BDSMROQZ.js → chunk-36GFRF2N.js} +2 -1
- package/dist/safe-bash/command-chunks/{chunk-GC5TJZOF.js → chunk-3VIA2IA7.js} +114 -31
- package/dist/safe-bash/command-chunks/{chunk-NKFYQSES.js → chunk-4CTI3ZTX.js} +1 -0
- package/dist/safe-bash/command-chunks/{chunk-WH627NJL.js → chunk-4MYP2FX4.js} +2 -1
- package/dist/safe-bash/command-chunks/{chunk-ZDN7MJE6.js → chunk-4R5ADJM5.js} +11 -1
- package/dist/safe-bash/command-chunks/{chunk-P2N33UMN.js → chunk-5MIKM54M.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-DB453IE6.js → chunk-6FZQUOSJ.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-PICVQ6B5.js → chunk-6GKYHPJG.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-7K6JYKPJ.js → chunk-6M2ELGEN.js} +17 -15
- package/dist/safe-bash/command-chunks/{chunk-PXEIT2O4.js → chunk-6UR7V3ET.js} +8 -1
- package/dist/safe-bash/command-chunks/{chunk-6KJ3LPI2.js → chunk-6XBS5B46.js} +26 -3
- package/dist/safe-bash/command-chunks/{chunk-5PWJG2UK.js → chunk-6YXLZX7L.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-EK6YNAXT.js → chunk-753YOR54.js} +31 -5
- package/dist/safe-bash/command-chunks/{chunk-RMWQAAO5.js → chunk-7IR4NRNE.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-FZTK4MFI.js → chunk-7NM73SVK.js} +8 -8
- package/dist/safe-bash/command-chunks/{chunk-NXEQ3ESQ.js → chunk-7QD5YY4F.js} +6 -11
- package/dist/safe-bash/command-chunks/{chunk-EMPU65ZK.js → chunk-A5LBSJGH.js} +1 -0
- package/dist/safe-bash/command-chunks/{chunk-4FEVBOL5.js → chunk-ARZMP2L2.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-NKIELG7Y.js → chunk-BAKFZ477.js} +40 -19
- package/dist/safe-bash/command-chunks/{chunk-QRRYN2KO.js → chunk-BC7BK6R6.js} +0 -2424
- package/dist/safe-bash/command-chunks/{chunk-CQHP3I66.js → chunk-BOEOJS2Q.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-XS72HTMA.js → chunk-BWGGLYEB.js} +5 -22
- package/dist/safe-bash/command-chunks/{chunk-PMBFZXTK.js → chunk-C5ZZKP7V.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-LHIOAFWW.js → chunk-C7SEB6WU.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-XPT2UGBF.js → chunk-CHJKFRT7.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-TIOCQVUQ.js → chunk-CON26Q2O.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-E55UKBIE.js → chunk-DBAT3IK2.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-Z45N42QC.js → chunk-DPAYAVMS.js} +15 -1
- package/dist/safe-bash/command-chunks/chunk-DS3NXVUM.js +368 -0
- package/dist/safe-bash/command-chunks/{chunk-5ZMZ573Q.js → chunk-DSJ3VRL3.js} +16 -4
- package/dist/safe-bash/command-chunks/{chunk-K2GDEMEU.js → chunk-EFRCFWVR.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-DZCY63VJ.js → chunk-EV6HIJ5H.js} +6 -5
- package/dist/safe-bash/command-chunks/{chunk-JDYXY44P.js → chunk-FJURV46Y.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-TZZ4WUKH.js → chunk-FZAWGKSE.js} +6 -4
- package/dist/safe-bash/command-chunks/{chunk-YHFXOX6U.js → chunk-GOCFQ6XV.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-QVOS4YXL.js → chunk-HH5O7DJI.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-3HHCU5YU.js → chunk-HK7F5SDC.js} +13 -0
- package/dist/safe-bash/command-chunks/{chunk-JNZ3CVAE.js → chunk-HQBXIZC7.js} +8 -3
- package/dist/safe-bash/command-chunks/{chunk-V4K2JDYU.js → chunk-I63DBZXZ.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-WNE7FPVR.js → chunk-I64TLTIW.js} +24 -16
- package/dist/safe-bash/command-chunks/{chunk-GFC2NTDG.js → chunk-ICANWOXH.js} +5 -29
- package/dist/safe-bash/command-chunks/{chunk-SQRQW3CT.js → chunk-IJ6LGLXM.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-TGSNCQSR.js → chunk-JT4RYCA6.js} +1771 -1663
- package/dist/safe-bash/command-chunks/{chunk-II77KPZN.js → chunk-JWW6FYBN.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-ZYXH3B66.js → chunk-LCJWKTCJ.js} +250 -203
- package/dist/safe-bash/command-chunks/chunk-LU4HBPP2.js +97 -0
- package/dist/safe-bash/command-chunks/{chunk-XJXU3VVH.js → chunk-LWOE65OE.js} +20 -5
- package/dist/safe-bash/command-chunks/{chunk-GMIHJYDG.js → chunk-M32HFSX7.js} +22 -6
- package/dist/safe-bash/command-chunks/{chunk-YG4EPFWC.js → chunk-M3NINRDU.js} +2880 -172
- package/dist/safe-bash/command-chunks/chunk-MQREDAL6.js +164 -0
- package/dist/safe-bash/command-chunks/{chunk-LWS62ISU.js → chunk-N6DIASO2.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-NGL7YK7O.js +188 -0
- package/dist/safe-bash/command-chunks/{chunk-EARHPPPJ.js → chunk-NJYHWKIL.js} +39 -9
- package/dist/safe-bash/command-chunks/{chunk-6JSIFWYT.js → chunk-OJQRSCBP.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-OQU6UT6X.js → chunk-OV3XREFN.js} +11 -0
- package/dist/safe-bash/command-chunks/{chunk-MIXBO6U7.js → chunk-PTZLF456.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-ALDC4XP4.js → chunk-QILLRNES.js} +34 -10
- package/dist/safe-bash/command-chunks/{chunk-L22T3H7L.js → chunk-QR25JLKO.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-NASVPT6F.js → chunk-R7C4MGZ5.js} +17 -224
- package/dist/safe-bash/command-chunks/{chunk-LCF3OB7P.js → chunk-RBME3JEH.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-2KG2QLJE.js → chunk-RFWGYT7G.js} +3 -0
- package/dist/safe-bash/command-chunks/{chunk-5TBUOBDE.js → chunk-RZMVRT26.js} +27 -13
- package/dist/safe-bash/command-chunks/chunk-TFR6B3WB.js +44 -0
- package/dist/safe-bash/command-chunks/chunk-TOH3OF3O.js +179 -0
- package/dist/safe-bash/command-chunks/chunk-TT4DAFBT.js +13621 -0
- package/dist/safe-bash/command-chunks/{chunk-LWSBAWLT.js → chunk-TXI64OAG.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-GIRNFXP3.js → chunk-TZRI7BJZ.js} +45 -15
- package/dist/safe-bash/command-chunks/{chunk-QOKBZFFD.js → chunk-U3MMODA5.js} +2 -7
- package/dist/safe-bash/command-chunks/{chunk-ZYHTWNAE.js → chunk-UAW423ZL.js} +11 -11
- package/dist/safe-bash/command-chunks/{chunk-C5YYCQHW.js → chunk-UXEEUGOV.js} +222 -12
- package/dist/safe-bash/command-chunks/{chunk-GY3BWK7K.js → chunk-VOZPMJRX.js} +87 -80
- package/dist/safe-bash/command-chunks/{chunk-ILX2NOLF.js → chunk-WPANOB4A.js} +20 -20
- package/dist/safe-bash/command-chunks/{chunk-Y2WBSJG6.js → chunk-X4QZQI5Q.js} +65 -64
- package/dist/safe-bash/command-chunks/{chunk-HDCNKOIX.js → chunk-XGI57GCN.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-5UBXNSFZ.js → chunk-XUCU7QQT.js} +1281 -1278
- package/dist/safe-bash/command-chunks/chunk-Y22VXJBD.js +296 -0
- package/dist/safe-bash/command-chunks/{chunk-WVHONVZ4.js → chunk-YMFUUPDX.js} +5 -3
- package/dist/safe-bash/command-chunks/{chunk-IR2BY7EL.js → chunk-YYGIBXFZ.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-MSFXC3OC.js → chunk-Z4FO6OHE.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-WWIBP2ET.js → chunk-Z5ZZVDUD.js} +143 -22
- package/dist/safe-bash/command-chunks/{chunk-LOICUCHG.js → chunk-ZHN3QDCI.js} +1 -1
- package/dist/safe-bash/commands/alias/index.d.ts +2 -0
- package/dist/safe-bash/commands/alias/index.js +2 -0
- package/dist/safe-bash/commands/apply-patch/index.browser.js +2 -3
- package/dist/safe-bash/commands/apply-patch/index.d.ts +0 -1
- package/dist/safe-bash/commands/apply-patch/index.js +0 -1
- package/dist/safe-bash/commands/archive/index.browser.js +2 -3
- package/dist/safe-bash/commands/archive/index.d.ts +0 -1
- package/dist/safe-bash/commands/archive/index.js +0 -1
- package/dist/safe-bash/commands/bytes/index.js +2 -1
- package/dist/safe-bash/commands/chmod/index.browser.js +1 -1
- package/dist/safe-bash/commands/column/index.browser.js +2 -3
- package/dist/safe-bash/commands/column/index.d.ts +0 -1
- package/dist/safe-bash/commands/column/index.js +0 -1
- package/dist/safe-bash/commands/copy-source.js +1 -0
- package/dist/safe-bash/commands/csplit/index.browser.js +2 -2
- package/dist/safe-bash/commands/csvkit/index.browser.js +72 -0
- package/dist/safe-bash/commands/csvkit/index.d.ts +0 -5
- package/dist/safe-bash/commands/csvkit/index.js +0 -50
- package/dist/safe-bash/commands/docx/index.browser.js +5 -7
- package/dist/safe-bash/commands/du/index.browser.js +2 -3
- package/dist/safe-bash/commands/du/index.d.ts +0 -1
- package/dist/safe-bash/commands/du/index.js +0 -1
- package/dist/safe-bash/commands/expr/index.browser.js +2 -3
- package/dist/safe-bash/commands/expr/index.d.ts +0 -1
- package/dist/safe-bash/commands/expr/index.js +0 -1
- package/dist/safe-bash/commands/factor/index.browser.js +2 -2
- package/dist/safe-bash/commands/file/index.browser.js +2 -3
- package/dist/safe-bash/commands/file/index.d.ts +0 -1
- package/dist/safe-bash/commands/file/index.js +0 -1
- package/dist/safe-bash/commands/filesystem.js +1 -1
- package/dist/safe-bash/commands/getopt/index.browser.js +2 -2
- package/dist/safe-bash/commands/grep-aliases/index.browser.js +3 -3
- package/dist/safe-bash/commands/hexdump/index.browser.js +2 -2
- package/dist/safe-bash/commands/html-to-markdown/index.browser.js +2 -3
- package/dist/safe-bash/commands/html-to-markdown/index.d.ts +0 -1
- package/dist/safe-bash/commands/html-to-markdown/index.js +0 -1
- package/dist/safe-bash/commands/htmlq/index.d.ts +1 -5
- package/dist/safe-bash/commands/htmlq/index.js +1 -143
- package/dist/safe-bash/commands/iconv/index.browser.js +2 -2
- package/dist/safe-bash/commands/line-endings/index.browser.js +2 -2
- package/dist/safe-bash/commands/llm/index.browser.js +2 -2
- package/dist/safe-bash/commands/llm/providers/index.browser.js +1 -1
- package/dist/safe-bash/commands/mdq/index.browser.js +3 -3
- package/dist/safe-bash/commands/media/index.browser.js +4 -16314
- package/dist/safe-bash/commands/media/index.d.ts +1 -5
- package/dist/safe-bash/commands/media/index.js +1 -3
- package/dist/safe-bash/commands/media/plugin.d.ts +1 -18
- package/dist/safe-bash/commands/media/plugin.js +1 -90
- package/dist/safe-bash/commands/media/remote.d.ts +1 -63
- package/dist/safe-bash/commands/media/remote.js +1 -405
- package/dist/safe-bash/commands/media/settings.d.ts +1 -4
- package/dist/safe-bash/commands/media/settings.js +1 -26
- package/dist/safe-bash/commands/metadata/index.browser.js +3 -4
- package/dist/safe-bash/commands/metadata/index.d.ts +0 -1
- package/dist/safe-bash/commands/metadata/index.js +2 -2
- package/dist/safe-bash/commands/mktemp/index.browser.js +1 -1
- package/dist/safe-bash/commands/network/curl.js +1 -3
- package/dist/safe-bash/commands/network/index.browser.js +3 -4
- package/dist/safe-bash/commands/network/public.d.ts +0 -1
- package/dist/safe-bash/commands/network/public.js +0 -1
- package/dist/safe-bash/commands/network/transport.js +2 -1
- package/dist/safe-bash/commands/network/wget.js +1 -3
- package/dist/safe-bash/commands/node/browser.d.ts +0 -1
- package/dist/safe-bash/commands/node/browser.js +0 -1
- package/dist/safe-bash/commands/node/default-runtime.d.ts +3 -0
- package/dist/safe-bash/commands/node/default-runtime.js +15 -0
- package/dist/safe-bash/commands/node/index.browser.js +7 -8
- package/dist/safe-bash/commands/node/index.js +3 -3
- package/dist/safe-bash/commands/node/path.js +1 -1
- package/dist/safe-bash/commands/node/preload.d.ts +1 -1
- package/dist/safe-bash/commands/node/preload.js +4 -1
- package/dist/safe-bash/commands/node/quickjs.d.ts +2 -0
- package/dist/safe-bash/commands/node/quickjs.js +2 -0
- package/dist/safe-bash/commands/node/safejs.js +26 -12
- package/dist/safe-bash/commands/op/index.browser.js +2 -3
- package/dist/safe-bash/commands/op/index.d.ts +0 -11
- package/dist/safe-bash/commands/op/index.js +0 -84
- package/dist/safe-bash/commands/pandoc/index.browser.js +44 -0
- package/dist/safe-bash/commands/pandoc/index.d.ts +0 -1
- package/dist/safe-bash/commands/pandoc/index.js +0 -1
- package/dist/safe-bash/commands/pr/index.browser.js +2 -2
- package/dist/safe-bash/commands/python/docker-runner.js +4 -3
- package/dist/safe-bash/commands/python/docker.d.ts +1 -0
- package/dist/safe-bash/commands/python/docker.js +5 -2
- package/dist/safe-bash/commands/python/index.browser.js +17 -13
- package/dist/safe-bash/commands/python/index.d.ts +2 -1
- package/dist/safe-bash/commands/python/index.js +10 -8
- package/dist/safe-bash/commands/python/llm-capability.js +65 -2
- package/dist/safe-bash/commands/python/llm-dependencies.d.ts +27 -0
- package/dist/safe-bash/commands/python/llm-dependencies.js +66 -0
- package/dist/safe-bash/commands/python/llm-module.js +6 -4
- package/dist/safe-bash/commands/python/llm-reference-module.d.ts +3 -0
- package/dist/safe-bash/commands/python/llm-reference-module.js +690 -0
- package/dist/safe-bash/commands/python/worker.browser.js +2 -3
- package/dist/safe-bash/commands/python/worker.d.ts +0 -1
- package/dist/safe-bash/commands/python/worker.js +0 -1
- package/dist/safe-bash/commands/regex-execution/ere/transport/wire-engine.d.ts +1 -1
- package/dist/safe-bash/commands/regex-execution/ere/transport/wire-engine.js +3 -3
- package/dist/safe-bash/commands/regex-execution/public.browser.js +7 -7
- package/dist/safe-bash/commands/safejs/options.js +5 -1
- package/dist/safe-bash/commands/safejs/runtime.d.ts +1 -0
- package/dist/safe-bash/commands/safejs/runtime.js +1 -1
- package/dist/safe-bash/commands/split/index.browser.js +2 -3
- package/dist/safe-bash/commands/split/index.d.ts +0 -1
- package/dist/safe-bash/commands/split/index.js +0 -1
- package/dist/safe-bash/commands/ssconvert/index.browser.js +98 -0
- package/dist/safe-bash/commands/stat/index.browser.js +1 -1
- package/dist/safe-bash/commands/stream-format/index.browser.js +3 -4
- package/dist/safe-bash/commands/stream-format/index.d.ts +0 -1
- package/dist/safe-bash/commands/stream-format/index.js +0 -1
- package/dist/safe-bash/commands/stream-inspection/index.browser.js +3 -4
- package/dist/safe-bash/commands/stream-inspection/index.d.ts +0 -1
- package/dist/safe-bash/commands/stream-inspection/index.js +0 -1
- package/dist/safe-bash/commands/streams.js +2 -1
- package/dist/safe-bash/commands/table-text/index.browser.js +3 -4
- package/dist/safe-bash/commands/table-text/index.d.ts +0 -1
- package/dist/safe-bash/commands/table-text/index.js +0 -1
- package/dist/safe-bash/commands/text.js +28 -24
- package/dist/safe-bash/commands/time-env/index.browser.js +3 -4
- package/dist/safe-bash/commands/time-env/index.d.ts +0 -1
- package/dist/safe-bash/commands/time-env/index.js +0 -1
- package/dist/safe-bash/commands/tree/index.browser.js +2 -3
- package/dist/safe-bash/commands/tree/index.d.ts +0 -1
- package/dist/safe-bash/commands/tree/index.js +0 -1
- package/dist/safe-bash/commands/tsort/index.browser.js +2 -2
- package/dist/safe-bash/commands/unalias/index.d.ts +2 -0
- package/dist/safe-bash/commands/unalias/index.js +2 -0
- package/dist/safe-bash/commands/xml/index.browser.js +2 -2
- package/dist/safe-bash/commands/yq/index.browser.js +2 -2
- package/dist/safe-bash/core.browser.js +2 -2
- package/dist/safe-bash/core.d.ts +7 -1
- package/dist/safe-bash/core.js +7 -1
- package/dist/safe-bash/execution-runtime.js +2 -1
- package/dist/safe-bash/fs/s3/http/index.d.ts +2 -2
- package/dist/safe-bash/fs/s3/http/index.js +1 -1
- package/dist/safe-bash/full-core.browser.js +283 -945
- package/dist/safe-bash/internal/op/types.d.ts +1 -0
- package/dist/safe-bash/jobs.browser.js +5 -5
- package/dist/safe-bash/lazy-optional.d.ts +3 -3
- package/dist/safe-bash/lazy-optional.js +1 -1
- package/dist/safe-bash/opt-in/commands/cmp/index.js +7 -6
- package/dist/safe-bash/opt-in/commands/dd/index.js +1 -1
- package/dist/safe-bash/opt-in/commands/dd/io.js +51 -5
- package/dist/safe-bash/opt-in/commands/truncate/index.js +2 -2
- package/dist/safe-bash/opt-in/commands/yq/native-work.js +2 -0
- package/dist/safe-bash/opt-in/optional/commands/shuf/input.js +2 -1
- package/dist/safe-bash/opt-in/optional/commands/shuf/shuf.js +4 -2
- package/dist/safe-bash/opt-in/optional.d.ts +1 -1
- package/dist/safe-bash/opt-in/optional.js +1 -1
- package/dist/safe-bash/opt-in/shell/extensions/read/index.js +2 -344
- package/dist/safe-bash/optional-host.browser.js +23 -18
- package/dist/safe-bash/optional-host.d.ts +1 -0
- package/dist/safe-bash/optional-host.js +1 -0
- package/dist/safe-bash/playwright/controller.js +41 -3
- package/dist/safe-bash/playwright/native-storage-targets.js +4 -2
- package/dist/safe-bash/plugins/base.d.ts +1 -1
- package/dist/safe-bash/plugins/base.js +3 -3
- package/dist/safe-bash/plugins/composition.d.ts +5 -2
- package/dist/safe-bash/plugins/composition.js +10 -7
- package/dist/safe-bash/plugins/index.browser.js +44 -41
- package/dist/safe-bash/plugins/index.js +3 -2
- package/dist/safe-bash/plugins/portable-commands.d.ts +3 -0
- package/dist/safe-bash/plugins/portable-commands.js +31 -0
- package/dist/safe-bash/registry-entry.browser.js +41 -42
- package/dist/safe-bash/search.browser.js +32 -33
- package/dist/safe-bash/shell/arithmetic.js +19 -6
- package/dist/safe-bash/shell/arrays/state.js +1 -1
- package/dist/safe-bash/shell/arrays/syntax.js +4 -3
- package/dist/safe-bash/shell/index.d.ts +0 -1
- package/dist/safe-bash/shell/index.js +0 -1
- package/dist/safe-bash/shell/parser.d.ts +2 -2
- package/dist/safe-bash/shell/parser.js +268 -64
- package/dist/safe-bash/shell/read-builtin.d.ts +3 -0
- package/dist/safe-bash/shell/read-builtin.js +344 -0
- package/dist/safe-bash/shell/runtime.d.ts +21 -4
- package/dist/safe-bash/shell/runtime.js +373 -412
- package/dist/safe-bash/shell/session-state.js +25 -0
- package/dist/safe-bash/shell/shell.js +76 -154
- package/dist/safe-bash/shell/tilde-expansion.d.ts +1 -1
- package/dist/safe-bash/shell/tilde-expansion.js +2 -2
- package/dist/safe-bash/shell/types.d.ts +5 -0
- package/dist/safe-bash/shell/value-state.js +1 -1
- package/dist/safe-bash/shell-entry.browser.js +32 -33
- package/dist/safe-bash/trap.browser.js +4 -4
- package/dist/safe-bash/yq-browser/index.js +1 -1
- package/dist/safe-bash-calendar-engine/time-env/calendar.d.ts +1 -1
- package/dist/safe-bash-calendar-engine/time-env/calendar.js +1 -1
- package/dist/safe-bash-calendar-engine/time-env/format.js +1 -1
- package/dist/safe-bash-command-alias/index.d.ts +13 -0
- package/dist/safe-bash-command-alias/index.js +88 -0
- package/dist/safe-bash-command-apply-patch/apply.js +3 -3
- package/dist/safe-bash-command-apply-patch/index.js +3 -3
- package/dist/safe-bash-command-apply-patch/matcher.js +1 -1
- package/dist/safe-bash-command-apply-patch/parser.js +1 -1
- package/dist/safe-bash-command-awk/awk-pipes.js +2 -2
- package/dist/safe-bash-command-awk/awk-reader.js +1 -1
- package/dist/safe-bash-command-awk/awk-runtime.js +3 -3
- package/dist/safe-bash-command-awk/awk.js +5 -5
- package/dist/safe-bash-command-awk/index.js +5 -5
- package/dist/safe-bash-command-bc/index.js +206 -60
- package/dist/safe-bash-command-cmp/index.js +7 -6
- package/dist/safe-bash-command-column/column.js +3 -3
- package/dist/safe-bash-command-column/index.js +3 -3
- package/dist/safe-bash-command-column/layout.js +2 -2
- package/dist/safe-bash-command-csvkit/index.d.ts +1 -0
- package/dist/safe-bash-command-csvkit/index.js +1505 -7
- package/dist/safe-bash-command-csvkit/sync-support.js +2 -7
- package/dist/safe-bash-command-curl/curl.js +1 -1
- package/dist/safe-bash-command-curl/index.js +1 -1
- package/dist/safe-bash-command-date/date.js +1 -1
- package/dist/safe-bash-command-date/index.js +1 -1
- package/dist/safe-bash-command-dd/index.js +1 -1
- package/dist/safe-bash-command-dd/io.js +51 -5
- package/dist/safe-bash-command-diff/diff.js +1 -1
- package/dist/safe-bash-command-diff/index.js +1 -1
- package/dist/safe-bash-command-diff3/index.js +10 -13
- package/dist/safe-bash-command-exiftool/index.js +278 -50
- package/dist/safe-bash-command-exiftool/registry.d.ts +4 -2
- package/dist/safe-bash-command-factor/command.js +2 -2
- package/dist/safe-bash-command-factor/index.js +2 -2
- package/dist/safe-bash-command-fd/arguments.d.ts +2 -0
- package/dist/safe-bash-command-fd/index.js +42 -12
- package/dist/safe-bash-command-ffmpeg/index.js +356 -66
- package/dist/safe-bash-command-find/find-format.d.ts +3 -0
- package/dist/safe-bash-command-find/find-format.js +1 -1
- package/dist/safe-bash-command-find/find.js +2 -2
- package/dist/safe-bash-command-find/index.js +2 -2
- package/dist/safe-bash-command-fmt/index.js +1 -4
- package/dist/safe-bash-command-fold/engine.d.ts +1 -1
- package/dist/safe-bash-command-fold/family.js +2 -2
- package/dist/safe-bash-command-fold/index.js +1 -1
- package/dist/safe-bash-command-hexdump/command.js +2 -2
- package/dist/safe-bash-command-hexdump/index.js +2 -2
- package/dist/safe-bash-command-html-to-markdown/entities.js +1 -1
- package/dist/safe-bash-command-html-to-markdown/index.js +4 -4
- package/dist/safe-bash-command-html-to-markdown/input.js +3 -3
- package/dist/safe-bash-command-html-to-markdown/parser.js +2 -2
- package/dist/safe-bash-command-html-to-markdown/render.js +3 -3
- package/dist/safe-bash-command-htmlq/contracts.d.ts +5 -2
- package/dist/safe-bash-command-htmlq/index.d.ts +2 -1
- package/dist/safe-bash-command-htmlq/index.js +175 -49
- package/dist/safe-bash-command-htmlq/sync.d.ts +1 -0
- package/dist/safe-bash-command-imagemagick/index.js +56 -6
- package/dist/safe-bash-command-install/arguments.d.ts +27 -0
- package/dist/safe-bash-command-install/arguments.js +224 -0
- package/dist/safe-bash-command-install/index.d.ts +7 -0
- package/dist/safe-bash-command-install/index.js +942 -0
- package/dist/safe-bash-command-install/mode.d.ts +6 -0
- package/dist/safe-bash-command-install/mode.js +71 -0
- package/dist/safe-bash-command-install/options.d.ts +40 -0
- package/dist/safe-bash-command-install/options.js +27 -0
- package/dist/safe-bash-command-jq/index.js +1 -1
- package/dist/safe-bash-command-jq/jq.js +1 -1
- package/dist/safe-bash-command-less/index.js +37 -61
- package/dist/safe-bash-command-llm/command.js +1 -1
- package/dist/safe-bash-command-llm/elevenlabs.js +2 -2
- package/dist/safe-bash-command-llm/index.js +4 -4
- package/dist/safe-bash-command-llm/openai.js +2 -2
- package/dist/safe-bash-command-llm/providers/elevenlabs.js +2 -2
- package/dist/safe-bash-command-llm/providers/index.js +3 -3
- package/dist/safe-bash-command-llm/providers/openai.js +2 -2
- package/dist/safe-bash-command-llm/providers/shared.js +1 -1
- package/dist/{safe-bash-mcp → safe-bash-command-mcp}/index.browser.d.ts +463 -46
- package/dist/safe-bash-command-mcp/index.browser.js +19308 -0
- package/dist/{safe-bash-mcp → safe-bash-command-mcp}/index.d.ts +15 -6
- package/dist/{safe-bash-mcp → safe-bash-command-mcp}/index.js +2804 -2771
- package/dist/safe-bash-command-media/LICENSE +21 -0
- package/dist/safe-bash-command-media/index.d.ts +6 -0
- package/dist/safe-bash-command-media/index.js +30 -0
- package/dist/safe-bash-command-media/plugin.d.ts +18 -0
- package/dist/safe-bash-command-media/plugin.js +11 -0
- package/dist/safe-bash-command-media/remote.d.ts +63 -0
- package/dist/safe-bash-command-media/remote.js +11 -0
- package/dist/safe-bash-command-media/settings.d.ts +4 -0
- package/dist/safe-bash-command-media/settings.js +41 -0
- package/dist/safe-bash-command-mktemp/command.js +1 -1
- package/dist/safe-bash-command-mktemp/index.js +1 -1
- package/dist/safe-bash-command-mmdc/arguments.d.ts +1 -0
- package/dist/safe-bash-command-mmdc/command.d.ts +2 -0
- package/dist/safe-bash-command-mmdc/contracts.d.ts +8 -1
- package/dist/safe-bash-command-mmdc/index.js +359 -7
- package/dist/safe-bash-command-nl/index.js +1 -1
- package/dist/safe-bash-command-nl/nl.js +1 -1
- package/dist/safe-bash-command-node/LICENSE +21 -0
- package/dist/safe-bash-command-node/index.d.ts +17 -0
- package/dist/safe-bash-command-node/index.js +328 -0
- package/dist/safe-bash-command-numfmt/index.js +1 -0
- package/dist/safe-bash-command-od/index.js +10 -6
- package/dist/safe-bash-command-op/index.js +39 -32
- package/dist/safe-bash-command-op/types.d.ts +1 -0
- package/dist/safe-bash-command-pandoc/command.js +3 -3
- package/dist/safe-bash-command-pandoc/index.d.ts +1 -0
- package/dist/safe-bash-command-pandoc/index.js +5 -3
- package/dist/safe-bash-command-pandoc/sync.d.ts +1 -0
- package/dist/safe-bash-command-patch/index.js +4 -4
- package/dist/safe-bash-command-patch/patch.js +4 -4
- package/dist/safe-bash-command-pdfimages/index.js +1 -1
- package/dist/safe-bash-command-pdfinfo/index.js +30 -5
- package/dist/safe-bash-command-pdftk/index.js +21 -23
- package/dist/safe-bash-command-pdftoppm/index.js +17 -4
- package/dist/safe-bash-command-pdftotext/index.js +11 -14
- package/dist/safe-bash-command-qpdf/index.d.ts +1 -0
- package/dist/safe-bash-command-qpdf/index.js +9 -6
- package/dist/safe-bash-command-rg/index.js +1 -1
- package/dist/safe-bash-command-rg/rg-command.js +1 -1
- package/dist/safe-bash-command-sed/index.js +1 -1
- package/dist/safe-bash-command-sed/sed.js +1 -1
- package/dist/safe-bash-command-shuf/input.d.ts +2 -2
- package/dist/safe-bash-command-shuf/input.js +2 -1
- package/dist/safe-bash-command-shuf/shuf.js +4 -2
- package/dist/safe-bash-command-sips/index.js +2 -2
- package/dist/safe-bash-command-soffice/index.js +97 -12
- package/dist/safe-bash-command-sponge/index.js +4 -1
- package/dist/safe-bash-command-sqlite3/engine.d.ts +1 -0
- package/dist/safe-bash-command-sqlite3/index.js +510 -70
- package/dist/safe-bash-command-ssconvert/formats/xlsx.js +2 -2
- package/dist/safe-bash-command-ssconvert/index.js +44 -22
- package/dist/safe-bash-command-stat/command.js +1 -1
- package/dist/safe-bash-command-stat/index.js +1 -1
- package/dist/safe-bash-command-tar/create.d.ts +1 -0
- package/dist/safe-bash-command-tar/create.js +2 -2
- package/dist/safe-bash-command-tar/extract.js +2 -2
- package/dist/safe-bash-command-tar/index.js +4 -4
- package/dist/safe-bash-command-tar/modes.js +4 -4
- package/dist/safe-bash-command-tar/options.js +1 -1
- package/dist/safe-bash-command-truncate/index.js +2 -2
- package/dist/safe-bash-command-tsort/command.js +2 -2
- package/dist/safe-bash-command-tsort/index.js +2 -2
- package/dist/safe-bash-command-unalias/index.d.ts +12 -0
- package/dist/safe-bash-command-unalias/index.js +67 -0
- package/dist/safe-bash-command-unrtf/index.js +26 -4
- package/dist/safe-bash-command-xan/argv.d.ts +1 -1
- package/dist/safe-bash-command-xan/argv.js +2 -2
- package/dist/safe-bash-command-xan/budget.d.ts +0 -1
- package/dist/safe-bash-command-xan/budget.js +1 -1
- package/dist/safe-bash-command-xan/commands.js +6 -6
- package/dist/safe-bash-command-xan/csv.js +2 -2
- package/dist/safe-bash-command-xan/index.js +8 -9
- package/dist/safe-bash-command-xan/io.js +4 -4
- package/dist/safe-bash-command-xan/options.js +1 -1
- package/dist/safe-bash-command-xan/selector.js +2 -2
- package/dist/safe-bash-command-xmllint/index.js +45 -23
- package/dist/safe-bash-command-xxd/index.js +41 -10
- package/dist/safe-bash-command-yq/accounting.js +1 -1
- package/dist/safe-bash-command-yq/index.js +3 -2
- package/dist/safe-bash-command-yq/native-work.js +2 -0
- package/dist/safe-bash-command-yq/parser.js +2 -2
- package/dist/safe-bash-command-yq/query.js +5 -5
- package/dist/safe-bash-command-yq/toml.js +2 -2
- package/dist/safe-bash-command-zip/index.js +3 -3
- package/dist/safe-bash-compression-engine/bounded-codec.js +2 -2
- package/dist/safe-bash-compression-engine/codec-loader.js +1 -1
- package/dist/safe-bash-compression-engine/files.js +5 -5
- package/dist/safe-bash-compression-engine/index.js +4 -4
- package/dist/safe-bash-compression-engine/operand.js +5 -5
- package/dist/safe-bash-compression-engine/stream.js +4 -4
- package/dist/safe-bash-compression-engine/zstd-decode.js +3 -3
- package/dist/safe-bash-contracts/command.js +3 -3
- package/dist/safe-bash-contracts/default-executor.js +2 -2
- package/dist/safe-bash-contracts/diagnostics.js +3 -3
- package/dist/safe-bash-contracts/escaping.js +6 -6
- package/dist/safe-bash-contracts/filesystem-descriptor.js +3 -3
- package/dist/safe-bash-contracts/filesystem-output.js +5 -5
- package/dist/safe-bash-contracts/http.d.ts +7 -0
- package/dist/safe-bash-contracts/index.js +8 -8
- package/dist/safe-bash-contracts/io.js +2 -2
- package/dist/safe-bash-contracts/output.js +3 -3
- package/dist/safe-bash-contracts/runtime-control.d.ts +2 -2
- package/dist/safe-bash-contracts/runtime-control.js +4 -2
- package/dist/safe-bash-contracts/signals.d.ts +2 -0
- package/dist/safe-bash-contracts/signals.js +3 -1
- package/dist/safe-bash-contracts/yield.js +1 -1
- package/dist/safe-bash-csv-engine/index.d.ts +2 -1
- package/dist/safe-bash-csv-engine/index.js +21 -15
- package/dist/safe-bash-io-engine/commands/search/requirements.js +2 -2
- package/dist/safe-bash-io-engine/commands/text-programs/shared.js +6 -6
- package/dist/safe-bash-io-engine/internal.js +1 -1
- package/dist/safe-bash-io-engine/shell/pattern.js +38 -18
- package/dist/safe-bash-line-ending-engine/convert.js +9 -204
- package/dist/safe-bash-line-ending-engine/encoding.js +9 -42
- package/dist/safe-bash-line-ending-engine/index.js +48 -0
- package/dist/safe-bash-line-ending-engine/info.js +9 -90
- package/dist/safe-bash-line-ending-engine/internal.js +15 -160
- package/dist/safe-bash-line-ending-engine/io.js +12 -289
- package/dist/safe-bash-line-ending-engine/stage.js +10 -160
- package/dist/safe-bash-markdown-engine/index.js +3 -3
- package/dist/safe-bash-network-engine/args.d.ts +6 -0
- package/dist/safe-bash-network-engine/args.js +4 -2
- package/dist/safe-bash-network-engine/body.js +1 -1
- package/dist/safe-bash-network-engine/fetch-transport.js +3 -1
- package/dist/safe-bash-network-engine/index.js +3 -1
- package/dist/safe-bash-network-engine/input.js +2 -2
- package/dist/safe-bash-network-engine/platform-portable.js +3 -1
- package/dist/safe-bash-query-engine/dates.d.ts +1 -1
- package/dist/safe-bash-query-engine/dates.js +1 -1
- package/dist/safe-bash-query-engine/index.js +6 -6
- package/dist/safe-bash-query-engine/interpreter.js +4 -4
- package/dist/safe-bash-query-engine/parser.js +1 -1
- package/dist/safe-bash-query-engine/query-core.js +6 -6
- package/dist/safe-bash-regex-engine/execution/bounded-provider.js +10 -0
- package/dist/safe-bash-regex-engine/index.js +1 -1
- package/dist/safe-bash-regex-engine/text/regex.d.ts +1 -1
- package/dist/safe-bash-regex-engine/text/regex.js +1 -1
- package/dist/safe-bash-search-engine/ergonomic-regex.d.ts +1 -0
- package/dist/safe-bash-search-engine/ergonomic-regex.js +1 -1
- package/dist/safe-bash-search-engine/grep.js +16 -9
- package/dist/safe-bash-search-engine/matcher.d.ts +2 -2
- package/dist/safe-bash-search-engine/matcher.js +12 -8
- package/dist/safe-bash-search-engine/shared.js +1 -1
- package/dist/safe-bash-search-engine/walk.js +13 -1
- package/dist/safe-bash-text-stream-engine/stream-format/shared.d.ts +1 -1
- package/dist/safe-bash-text-stream-engine/stream-format/shared.js +2 -1
- package/dist/safe-bash-xml-engine/document.js +3 -3
- package/dist/safe-bash-xml-engine/evaluate.js +2 -2
- package/dist/safe-bash-xml-engine/index.js +4 -4
- package/dist/safe-bash-xml-engine/io.js +7 -2
- package/dist/safe-bash-xml-engine/limits.d.ts +0 -2
- package/dist/safe-bash-xml-engine/limits.js +1 -1
- package/dist/safe-bash-xml-engine/query.js +3 -3
- package/dist/safe-bash-zip-engine/index.js +3 -3
- package/dist/safe-bash-zip-engine/zip/repair.js +3 -3
- package/dist/safe-bash-zip-engine/zip/safety.js +1 -1
- package/dist/safe-bash-zip-engine/zip/sfx.js +3 -3
- package/dist/safe-bash-zip-engine/zip/volumes.js +1 -1
- package/dist/safe-bash-zip-engine/zip-format.js +3 -3
- package/dist/safe-playwright-cloudflare/browser-socket-closure.js +18 -3
- package/dist/safe-playwright-cloudflare/shell-browser-resource.js +1 -1
- package/dist/xlsx-ast/xlsx.js +6 -5
- package/package.json +86 -98
- package/dist/media-cli/bytes.d.ts +0 -8
- package/dist/media-cli/bytes.js +0 -40
- package/dist/media-cli/concat.d.ts +0 -30
- package/dist/media-cli/concat.js +0 -197
- package/dist/media-cli/content.js +0 -66
- package/dist/media-cli/dependency-grammars.d.ts +0 -12
- package/dist/media-cli/dependency-grammars.js +0 -557
- package/dist/media-cli/discover.js +0 -286
- package/dist/media-cli/engine.js +0 -190
- package/dist/media-cli/filename-expression.js +0 -147
- package/dist/media-cli/filesystem.js +0 -35
- package/dist/media-cli/frontend-contract.js +0 -8
- package/dist/media-cli/frontend-issues.d.ts +0 -6
- package/dist/media-cli/frontend-issues.js +0 -9
- package/dist/media-cli/imagemagick-operand.d.ts +0 -42
- package/dist/media-cli/imagemagick-operand.js +0 -229
- package/dist/media-cli/imagemagick-references.d.ts +0 -7
- package/dist/media-cli/imagemagick-references.js +0 -42
- package/dist/media-cli/imagemagick.generated.js +0 -3254
- package/dist/media-cli/imagemagick.js +0 -615
- package/dist/media-cli/index.js +0 -12
- package/dist/media-cli/mvg.d.ts +0 -10
- package/dist/media-cli/mvg.js +0 -102
- package/dist/media-cli/network.js +0 -78
- package/dist/media-cli/options.generated.js +0 -3312
- package/dist/media-cli/preset.d.ts +0 -11
- package/dist/media-cli/preset.js +0 -57
- package/dist/media-cli/resolution-path.d.ts +0 -23
- package/dist/media-cli/resolution-path.js +0 -217
- package/dist/media-cli/resolver.js +0 -494
- package/dist/media-cli/resources.d.ts +0 -16
- package/dist/media-cli/resources.js +0 -187
- package/dist/media-cli/shim.js +0 -52
- package/dist/media-cli/tee.d.ts +0 -6
- package/dist/media-cli/tee.js +0 -38
- package/dist/office-package/zip-sync.js +0 -111
- package/dist/remote-execution/binary.js +0 -178
- package/dist/remote-execution/callback-result.js +0 -26
- package/dist/remote-execution/canonical-capabilities.d.ts +0 -5
- package/dist/remote-execution/canonical-capabilities.js +0 -45
- package/dist/remote-execution/canonical-metadata.d.ts +0 -4
- package/dist/remote-execution/canonical-metadata.js +0 -32
- package/dist/remote-execution/client.js +0 -824
- package/dist/remote-execution/deployment.js +0 -131
- package/dist/remote-execution/descriptors.js +0 -267
- package/dist/remote-execution/effects.js +0 -357
- package/dist/remote-execution/endpoint.js +0 -224
- package/dist/remote-execution/files.js +0 -291
- package/dist/remote-execution/hosting-operation.js +0 -26
- package/dist/remote-execution/hosting-request.d.ts +0 -4
- package/dist/remote-execution/hosting-request.js +0 -12
- package/dist/remote-execution/hosting-stream.d.ts +0 -8
- package/dist/remote-execution/hosting-stream.js +0 -64
- package/dist/remote-execution/index.js +0 -18
- package/dist/remote-execution/invocation-admission.d.ts +0 -3
- package/dist/remote-execution/invocation-admission.js +0 -17
- package/dist/remote-execution/job-binding.js +0 -1269
- package/dist/remote-execution/materializations.js +0 -284
- package/dist/remote-execution/modal-driver.js +0 -90
- package/dist/remote-execution/native-result.d.ts +0 -3
- package/dist/remote-execution/native-result.js +0 -16
- package/dist/remote-execution/output-freshness.d.ts +0 -4
- package/dist/remote-execution/output-freshness.js +0 -19
- package/dist/remote-execution/output-retrieval.js +0 -474
- package/dist/remote-execution/process-http.js +0 -607
- package/dist/remote-execution/process.js +0 -577
- package/dist/remote-execution/protocol.js +0 -208
- package/dist/remote-execution/relay.js +0 -91
- package/dist/remote-execution/rest-driver.js +0 -93
- package/dist/remote-execution/upload-descriptor.js +0 -201
- package/dist/remote-execution/upload-protocol.js +0 -62
- package/dist/remote-execution/uploads.js +0 -324
- package/dist/remote-execution/wire-json.d.ts +0 -4
- package/dist/remote-execution/wire-json.js +0 -44
- package/dist/remote-execution/wire-validation.js +0 -131
- package/dist/remote-execution/wire.generated.js +0 -4224
- package/dist/safe-bash/chunks/chunk-GDYNCWRV.js +0 -161
- package/dist/safe-bash/chunks/chunk-IWDICZVK.js +0 -20
- package/dist/safe-bash/chunks/chunk-MHMMRCYC.js +0 -3464
- package/dist/safe-bash/chunks/chunk-UE5KZDEK.js +0 -77
- package/dist/safe-bash/chunks/csvkit-TACDU7FC.js +0 -1618
- package/dist/safe-bash/chunks/implementation-MLFHUQ5M.js +0 -133
- package/dist/safe-bash/commands/csvkit/sync.js +0 -1639
- package/dist/safe-bash/commands/node/unconfigured.d.ts +0 -3
- package/dist/safe-bash/commands/node/unconfigured.js +0 -10
- package/dist/safe-bash/commands/pandoc/implementation.d.ts +0 -8
- package/dist/safe-bash/commands/pandoc/implementation.js +0 -94
- package/dist/safe-bash-mcp/index.browser.js +0 -9167
- package/dist/safe-bash/command-chunks/{chunk-ZRRBXU3M.js → chunk-GIN5GUDP.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-LAOM65EE.js → chunk-IEO4XVN6.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-BXCXRYVU.js → chunk-JNANXVJV.js} +0 -0
- package/dist/safe-bash/command-chunks/{chunk-364TMWBT.js → chunk-MWREVL44.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-464RVBGB.js → chunk-Q5TDKFHK.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-AJR3AQYA.js → chunk-UKX3LZHR.js} +0 -0
- package/dist/safe-bash/command-chunks/{chunk-XIIBTGC5.js → chunk-XPXEQKRW.js} +9 -9
- package/dist/safe-bash/command-chunks/{chunk-FDBUV4HJ.js → chunk-Y4HGTG3E.js} +3 -3
- /package/dist/{safe-bash/commands/csvkit → safe-bash-command-csvkit}/sync.d.ts +0 -0
|
@@ -1,25 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
evalSyncCsvcut,
|
|
3
|
+
evalSyncCsvgrep,
|
|
4
|
+
evalSyncDiff3,
|
|
5
|
+
evalSyncHtmlq,
|
|
6
|
+
evalSyncUnrtf
|
|
7
|
+
} from "./chunk-YOXUCJER.js";
|
|
4
8
|
import {
|
|
5
9
|
evalSyncYqPrep,
|
|
6
10
|
formatSyncYqYamlLines
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import {
|
|
9
|
-
captureIgnoredTrapSignals,
|
|
10
|
-
defaultPortableTrapExtension,
|
|
11
|
-
isIdlePortableTrapInstance
|
|
12
|
-
} from "./chunk-3NDIFSNM.js";
|
|
13
|
-
import {
|
|
14
|
-
EreLedger,
|
|
15
|
-
EreProfileLimitError,
|
|
16
|
-
EreSyntaxError,
|
|
17
|
-
EreUnsupportedError,
|
|
18
|
-
compileEre,
|
|
19
|
-
matchEre,
|
|
20
|
-
tryCompileEreSync,
|
|
21
|
-
tryMatchEreSync
|
|
22
|
-
} from "./chunk-6O77NL2S.js";
|
|
11
|
+
} from "./chunk-D5Q7NFWI.js";
|
|
23
12
|
import {
|
|
24
13
|
abortManagedController,
|
|
25
14
|
addAbortSignalWaiter,
|
|
@@ -67,52 +56,53 @@ import {
|
|
|
67
56
|
tryFastPrintf,
|
|
68
57
|
variablePresence,
|
|
69
58
|
wcDisplayWidth
|
|
70
|
-
} from "./chunk-
|
|
71
|
-
import {
|
|
72
|
-
evalSyncMdq
|
|
73
|
-
} from "./chunk-OV6IHKO6.js";
|
|
74
|
-
import {
|
|
75
|
-
evalSyncPr
|
|
76
|
-
} from "./chunk-CHYGPFVM.js";
|
|
77
|
-
import {
|
|
78
|
-
evalSyncGetopt
|
|
79
|
-
} from "./chunk-AUSNDQTJ.js";
|
|
59
|
+
} from "./chunk-AW5KIT6V.js";
|
|
80
60
|
import {
|
|
81
61
|
evalSyncIconv
|
|
82
|
-
} from "./chunk-
|
|
62
|
+
} from "./chunk-IQW34XQT.js";
|
|
83
63
|
import {
|
|
84
64
|
evalSyncLineEndings
|
|
85
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-TCKYOLUE.js";
|
|
86
66
|
import {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
} from "./chunk-C5OWC2TL.js";
|
|
67
|
+
evalSyncMdq
|
|
68
|
+
} from "./chunk-FOB2FZR4.js";
|
|
90
69
|
import {
|
|
91
70
|
PublicDiagnostic,
|
|
92
71
|
publicDiagnosticMessage,
|
|
93
72
|
writeDiagnostic
|
|
94
|
-
} from "./chunk-
|
|
73
|
+
} from "./chunk-TC3F4UFF.js";
|
|
74
|
+
import {
|
|
75
|
+
evalSyncPr
|
|
76
|
+
} from "./chunk-22SX3F2R.js";
|
|
77
|
+
import {
|
|
78
|
+
evalSyncGetopt
|
|
79
|
+
} from "./chunk-JPSUHHOA.js";
|
|
95
80
|
import {
|
|
96
81
|
bytesToHex,
|
|
97
82
|
compareUtf8,
|
|
98
83
|
latin1Bytes,
|
|
99
84
|
latin1Text
|
|
100
|
-
} from "./chunk-
|
|
85
|
+
} from "./chunk-UV4X32QU.js";
|
|
101
86
|
import {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
87
|
+
EreLedger,
|
|
88
|
+
EreProfileLimitError,
|
|
89
|
+
EreSyntaxError,
|
|
90
|
+
EreUnsupportedError,
|
|
91
|
+
compileEre,
|
|
92
|
+
matchEre,
|
|
93
|
+
tryCompileEreSync,
|
|
94
|
+
tryMatchEreSync
|
|
95
|
+
} from "./chunk-6SMICPI3.js";
|
|
109
96
|
import {
|
|
110
|
-
|
|
111
|
-
} from "./chunk-
|
|
97
|
+
jobsExtension
|
|
98
|
+
} from "./chunk-Y7FW6GLT.js";
|
|
112
99
|
import {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
} from "./chunk-
|
|
100
|
+
evalSyncXmllint,
|
|
101
|
+
evalSyncXq
|
|
102
|
+
} from "./chunk-OQ3AGYCZ.js";
|
|
103
|
+
import {
|
|
104
|
+
openCommandFile
|
|
105
|
+
} from "./chunk-CL2FCTTO.js";
|
|
116
106
|
import {
|
|
117
107
|
basename,
|
|
118
108
|
cancelTurn,
|
|
@@ -127,7 +117,11 @@ import {
|
|
|
127
117
|
runYieldCheckpoint,
|
|
128
118
|
scheduleTurn,
|
|
129
119
|
yieldTurn
|
|
130
|
-
} from "./chunk-
|
|
120
|
+
} from "./chunk-62BOHHJT.js";
|
|
121
|
+
import {
|
|
122
|
+
FsError,
|
|
123
|
+
isFsError
|
|
124
|
+
} from "./chunk-DUTAG6ZD.js";
|
|
131
125
|
import {
|
|
132
126
|
createBytePipe,
|
|
133
127
|
outputFailure,
|
|
@@ -135,59 +129,63 @@ import {
|
|
|
135
129
|
toByteSource,
|
|
136
130
|
writeBytes,
|
|
137
131
|
writeText
|
|
138
|
-
} from "./chunk-
|
|
132
|
+
} from "./chunk-4KTMKD5W.js";
|
|
139
133
|
import {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
134
|
+
captureIgnoredTrapSignals,
|
|
135
|
+
defaultPortableTrapExtension,
|
|
136
|
+
isIdlePortableTrapInstance
|
|
137
|
+
} from "./chunk-SUJ3NTMH.js";
|
|
138
|
+
import {
|
|
139
|
+
concatShellValues,
|
|
140
|
+
shellValueByteLength,
|
|
141
|
+
shellValueBytes,
|
|
142
|
+
shellValueFromBytes,
|
|
143
|
+
shellValueRetainedBytes,
|
|
144
|
+
shellValueText
|
|
145
|
+
} from "./chunk-XQWCQSRN.js";
|
|
146
|
+
import {
|
|
147
|
+
evalSyncDu
|
|
148
|
+
} from "./chunk-RHFRJIWQ.js";
|
|
149
|
+
import {
|
|
150
|
+
evalSyncDate,
|
|
151
|
+
evalSyncPrintenv
|
|
152
|
+
} from "./chunk-KBZ4UB2O.js";
|
|
146
153
|
import {
|
|
147
154
|
evalSyncTree
|
|
148
|
-
} from "./chunk-
|
|
155
|
+
} from "./chunk-4T53AERN.js";
|
|
149
156
|
import {
|
|
150
157
|
evalSyncFile
|
|
151
|
-
} from "./chunk-
|
|
158
|
+
} from "./chunk-7O76UFQD.js";
|
|
152
159
|
import {
|
|
153
160
|
evalSyncHtmlToMarkdown
|
|
154
|
-
} from "./chunk-
|
|
161
|
+
} from "./chunk-5XIFJVOO.js";
|
|
155
162
|
import {
|
|
156
|
-
|
|
157
|
-
|
|
163
|
+
CommandRegistry,
|
|
164
|
+
builtInDirectContextExecutors,
|
|
165
|
+
commandRuntimeIdentity,
|
|
166
|
+
createCommandArguments,
|
|
167
|
+
getCommandArguments,
|
|
168
|
+
validateExitCode
|
|
169
|
+
} from "./chunk-OHML2BEU.js";
|
|
158
170
|
import {
|
|
159
171
|
evalSyncStat
|
|
160
|
-
} from "./chunk-
|
|
172
|
+
} from "./chunk-IOHH2GTI.js";
|
|
161
173
|
import {
|
|
162
174
|
evalSyncTar,
|
|
163
175
|
evalSyncUnzip,
|
|
164
176
|
evalSyncZip
|
|
165
|
-
} from "./chunk-
|
|
166
|
-
import {
|
|
167
|
-
evalSyncDate,
|
|
168
|
-
evalSyncPrintenv
|
|
169
|
-
} from "./chunk-ZVD5IS4V.js";
|
|
177
|
+
} from "./chunk-YL3GBUG4.js";
|
|
170
178
|
import {
|
|
171
179
|
RESOLVED_EXIT_ONE,
|
|
172
180
|
RESOLVED_EXIT_ZERO,
|
|
173
181
|
UsageError,
|
|
174
|
-
builtInDirectContextExecutors,
|
|
182
|
+
builtInDirectContextExecutors as builtInDirectContextExecutors2,
|
|
175
183
|
pathOf,
|
|
176
|
-
registerDefaultExecutor,
|
|
177
|
-
registerDefaultExecutors,
|
|
178
184
|
syncCommandEvaluators
|
|
179
|
-
} from "./chunk-
|
|
185
|
+
} from "./chunk-V7QT2RWC.js";
|
|
180
186
|
import {
|
|
181
187
|
init_platform
|
|
182
|
-
} from "./chunk-
|
|
183
|
-
|
|
184
|
-
// packages/safe-bash/src/fs/memory/index.ts
|
|
185
|
-
init_platform();
|
|
186
|
-
import {
|
|
187
|
-
createMemoryFileSystem,
|
|
188
|
-
defaultMemoryFileSystemLimits,
|
|
189
|
-
MemoryFileSystem
|
|
190
|
-
} from "@poe-platform/safe-fs/core";
|
|
188
|
+
} from "./chunk-PTAEWLSE.js";
|
|
191
189
|
|
|
192
190
|
// packages/safe-bash/src/shell/types.ts
|
|
193
191
|
init_platform();
|
|
@@ -467,6 +465,7 @@ function integer(text3) {
|
|
|
467
465
|
return value;
|
|
468
466
|
}
|
|
469
467
|
function parseArithmetic(source, offset = 0, budget = new ParseBudget()) {
|
|
468
|
+
if (source.includes("\\\n")) source = source.replace(/\\\n/gu, "");
|
|
470
469
|
const tokens = [];
|
|
471
470
|
let position = 0;
|
|
472
471
|
while (position < source.length) {
|
|
@@ -615,7 +614,11 @@ function arithmeticEnd(source, start, allowSubshell = false, maxSyntaxDepth = In
|
|
|
615
614
|
}
|
|
616
615
|
if (character === "(") depth++;
|
|
617
616
|
if (character === ")") {
|
|
618
|
-
if (depth === 0
|
|
617
|
+
if (depth === 0) {
|
|
618
|
+
let nextClose = position + 1;
|
|
619
|
+
while (source.startsWith("\\\n", nextClose)) nextClose += 2;
|
|
620
|
+
if (source[nextClose] === ")") return position;
|
|
621
|
+
}
|
|
619
622
|
if (--depth < 0) {
|
|
620
623
|
if (allowSubshell) return -1;
|
|
621
624
|
break;
|
|
@@ -695,7 +698,7 @@ var SMALL_BIGINTS = Array.from({ length: 4097 }, (_, i) => BigInt(i));
|
|
|
695
698
|
function smallBigInt(n) {
|
|
696
699
|
return n >= 0 && n <= 4096 ? SMALL_BIGINTS[n] : BigInt(n);
|
|
697
700
|
}
|
|
698
|
-
var LARGE_INT_KEYS = new
|
|
701
|
+
var LARGE_INT_KEYS = new Float64Array(16);
|
|
699
702
|
var LARGE_INT_STRS = new Array(16).fill("");
|
|
700
703
|
function intToStr(n) {
|
|
701
704
|
if (n >= 0 && n <= 65536) {
|
|
@@ -788,7 +791,7 @@ function evalSafeSmi(node, refs, budget) {
|
|
|
788
791
|
const v = evalSafeSmi(node.operand, refs, budget);
|
|
789
792
|
if (v === void 0 || v < -94906265 || v > 94906265) return void 0;
|
|
790
793
|
if (node.operator === "+") return v;
|
|
791
|
-
if (node.operator === "-") return -v;
|
|
794
|
+
if (node.operator === "-") return v === 0 ? 0 : -v;
|
|
792
795
|
if (node.operator === "!") return v === 0 ? 1 : 0;
|
|
793
796
|
return void 0;
|
|
794
797
|
}
|
|
@@ -835,10 +838,14 @@ function evalSafeSmi(node, refs, budget) {
|
|
|
835
838
|
return l - r;
|
|
836
839
|
case "*":
|
|
837
840
|
return l * r;
|
|
838
|
-
case "/":
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
841
|
+
case "/": {
|
|
842
|
+
const q = Math.trunc(l / r);
|
|
843
|
+
return q === 0 ? 0 : q;
|
|
844
|
+
}
|
|
845
|
+
case "%": {
|
|
846
|
+
const m = l % r | 0;
|
|
847
|
+
return m === 0 ? 0 : m;
|
|
848
|
+
}
|
|
842
849
|
case "<":
|
|
843
850
|
return l < r ? 1 : 0;
|
|
844
851
|
case "<=":
|
|
@@ -1560,7 +1567,8 @@ function stringIndex(source, budget, word) {
|
|
|
1560
1567
|
}
|
|
1561
1568
|
function arraySelector(source, offset, budget = new ParseBudget(), word) {
|
|
1562
1569
|
budget.admit();
|
|
1563
|
-
|
|
1570
|
+
const cleanSource = source.includes("\\\n") ? source.replace(/\\\n/gu, "") : source;
|
|
1571
|
+
return cleanSource === "@" || cleanSource === "*" ? { kind: "members", separator: cleanSource } : { kind: "element", index: word ? stringIndex(cleanSource, budget, word) : literalIndex(cleanSource, offset, budget) };
|
|
1564
1572
|
}
|
|
1565
1573
|
function setArraySelector(part, selector) {
|
|
1566
1574
|
selectors.set(part, selector);
|
|
@@ -1927,6 +1935,11 @@ var HereDocumentSyntaxError = class extends Error {
|
|
|
1927
1935
|
}
|
|
1928
1936
|
diagnostic;
|
|
1929
1937
|
};
|
|
1938
|
+
function isSelfDelimitingCompound(command) {
|
|
1939
|
+
if (!command || command.redirects.length > 0) return false;
|
|
1940
|
+
if (command.kind === "function") return isSelfDelimitingCompound(command.body);
|
|
1941
|
+
return command.kind !== "simple" && command.kind !== "arithmetic" && command.kind !== "conditional";
|
|
1942
|
+
}
|
|
1930
1943
|
var scriptSeparators = /* @__PURE__ */ new WeakMap();
|
|
1931
1944
|
var functionLayouts = /* @__PURE__ */ new WeakMap();
|
|
1932
1945
|
function functionReprintedLines(script) {
|
|
@@ -2081,7 +2094,7 @@ var IncompleteShellInput = class extends Error {
|
|
|
2081
2094
|
var CompoundListEofError = class extends ShellSyntaxError {
|
|
2082
2095
|
};
|
|
2083
2096
|
var Lexer = class {
|
|
2084
|
-
constructor(budget, source, depth, warnings = [], lineOffset = 0, byteLocale2 = false, documentLine, partial = false, lineIndex = new SourceLineIndex(source, budget), sourceOffset = 0, ordinaryBacktick = false, sourceValues, byteSource = false, syntax = defaultSyntax) {
|
|
2097
|
+
constructor(budget, source, depth, warnings = [], lineOffset = 0, byteLocale2 = false, documentLine, partial = false, lineIndex = new SourceLineIndex(source, budget), sourceOffset = 0, ordinaryBacktick = false, sourceValues, byteSource = false, syntax = defaultSyntax, aliases) {
|
|
2085
2098
|
this.budget = budget;
|
|
2086
2099
|
this.source = source;
|
|
2087
2100
|
this.depth = depth;
|
|
@@ -2096,6 +2109,7 @@ var Lexer = class {
|
|
|
2096
2109
|
this.sourceValues = sourceValues;
|
|
2097
2110
|
this.byteSource = byteSource;
|
|
2098
2111
|
this.syntax = syntax;
|
|
2112
|
+
this.aliases = aliases;
|
|
2099
2113
|
if (depth > this.budget.maxSyntaxDepth) throw new ShellSyntaxError(`Syntax nesting exceeds ${this.budget.maxSyntaxDepth}`, 0);
|
|
2100
2114
|
}
|
|
2101
2115
|
budget;
|
|
@@ -2112,6 +2126,7 @@ var Lexer = class {
|
|
|
2112
2126
|
sourceValues;
|
|
2113
2127
|
byteSource;
|
|
2114
2128
|
syntax;
|
|
2129
|
+
aliases;
|
|
2115
2130
|
position = 0;
|
|
2116
2131
|
operandDepth = 0;
|
|
2117
2132
|
printedNewlineReduction = 0;
|
|
@@ -2374,7 +2389,7 @@ shell: command substitution: line ${line}: \`${sourceLine}'
|
|
|
2374
2389
|
}
|
|
2375
2390
|
this.error("Unterminated delimiter expansion syntax");
|
|
2376
2391
|
}
|
|
2377
|
-
word(terminator, enclosingQuoted = false, literal = false, arithmetic = false, arithmeticExpansion = false) {
|
|
2392
|
+
word(terminator, enclosingQuoted = false, literal = false, arithmetic = false, arithmeticExpansion = false, assignmentSubscriptEnd = -1) {
|
|
2378
2393
|
this.budget.admit();
|
|
2379
2394
|
const offset = this.position;
|
|
2380
2395
|
const reduction = this.printedNewlineReduction;
|
|
@@ -2451,7 +2466,7 @@ shell: command substitution: line ${line}: \`${sourceLine}'
|
|
|
2451
2466
|
if (++brackets > this.budget.maxSyntaxDepth) this.error(`Subscript syntax nesting exceeds ${this.budget.maxSyntaxDepth}`);
|
|
2452
2467
|
} else if (current === "]" && brackets > 0) brackets--;
|
|
2453
2468
|
else if (terminator.includes(current) && (!arithmetic || current !== ":" || parentheses === 0 && conditionals === 0)) break;
|
|
2454
|
-
} else if (!this.braceReplay) {
|
|
2469
|
+
} else if (!this.braceReplay && this.position > assignmentSubscriptEnd) {
|
|
2455
2470
|
if (!enclosingQuoted && !literal && current === "(" && (patternParentheses > 0 || this.position > offset && "?*+@!".includes(this.source[this.position - 1] ?? " ") && (this.position - 1 === offset || this.source[this.position - 2] !== "\\") && !(this.source[this.position + 1] === ")" && /^\(\)\s*(?:\{|\(|if\b|case\b|while\b|until\b|for\b|select\b|\[\[)/u.test(this.source.slice(this.position))) && this.hasClosingExtglobParen(this.position))) {
|
|
2456
2471
|
if (++patternParentheses > this.budget.maxSyntaxDepth) this.error(`Syntax nesting exceeds ${this.budget.maxSyntaxDepth}`);
|
|
2457
2472
|
} else if (!enclosingQuoted && !literal && current === ")" && patternParentheses > 0) {
|
|
@@ -2471,7 +2486,7 @@ shell: command substitution: line ${line}: \`${sourceLine}'
|
|
|
2471
2486
|
let script;
|
|
2472
2487
|
try {
|
|
2473
2488
|
this.budget.admit();
|
|
2474
|
-
nested = new Parser(this.budget, this.source.slice(start), this.depth + this.operandDepth + 1, this.warnings, this.lineAt(start) - 1, void 0, this.byteLocale, false, this.lineIndex, this.sourceOffset + start, false, this.sourceValues, this.byteSource, this.syntax);
|
|
2489
|
+
nested = new Parser(this.budget, this.source.slice(start), this.depth + this.operandDepth + 1, this.warnings, this.lineAt(start) - 1, void 0, this.byteLocale, false, this.lineIndex, this.sourceOffset + start, false, this.sourceValues, this.byteSource, this.syntax, this.aliases);
|
|
2475
2490
|
script = nested.script(/* @__PURE__ */ new Set([")"]));
|
|
2476
2491
|
} catch (error) {
|
|
2477
2492
|
if (this.documentLine !== void 0 && error instanceof ShellSyntaxError && !/nesting|exceeds/u.test(error.reason)) throw this.documentSubstitutionError(this.source.slice(start), error);
|
|
@@ -2489,7 +2504,7 @@ shell: command substitution: line ${line}: \`${sourceLine}'
|
|
|
2489
2504
|
parts.push({ kind: "process-substitution", direction, script, line, sourceLine: script.line ?? line, quoted: true });
|
|
2490
2505
|
continue;
|
|
2491
2506
|
}
|
|
2492
|
-
if (current === "$" && this.source[this.position + 1] === "'" && !enclosingQuoted
|
|
2507
|
+
if (current === "$" && this.source[this.position + 1] === "'" && !enclosingQuoted) {
|
|
2493
2508
|
plain = false;
|
|
2494
2509
|
this.unprintedWords++;
|
|
2495
2510
|
const start = this.position;
|
|
@@ -2514,8 +2529,9 @@ shell: command substitution: line ${line}: \`${sourceLine}'
|
|
|
2514
2529
|
text3(this.source.slice(start, end), true, false, start, end);
|
|
2515
2530
|
} else text3(this.source.slice(this.position + 1, end), true, false, this.position, Math.min(end + 1, this.source.length));
|
|
2516
2531
|
this.position = Math.min(end + 1, this.source.length);
|
|
2517
|
-
} else if (current === '"') {
|
|
2532
|
+
} else if (current === '"' || current === "$" && this.source[this.position + 1] === '"' && !enclosingQuoted) {
|
|
2518
2533
|
plain = false;
|
|
2534
|
+
if (current === "$") this.position++;
|
|
2519
2535
|
const quoteLine = this.lineAt(this.position);
|
|
2520
2536
|
this.position++;
|
|
2521
2537
|
text3("", true, true, this.position - 1, this.position);
|
|
@@ -2570,7 +2586,6 @@ shell: command substitution: line ${line}: \`${sourceLine}'
|
|
|
2570
2586
|
} else if (current === "$" || current === "`") {
|
|
2571
2587
|
plain = false;
|
|
2572
2588
|
if (literal) {
|
|
2573
|
-
if (current === "$" && ["'", '"'].includes(this.source[this.position + 1] ?? "")) this.error("Unsupported shell quoting in here-document delimiter");
|
|
2574
2589
|
text3(this.literalExpansion(), current === "`");
|
|
2575
2590
|
} else this.expansion(parts, enclosingQuoted);
|
|
2576
2591
|
} else {
|
|
@@ -2690,6 +2705,47 @@ shell: command substitution: line ${line}: \`${sourceLine}'
|
|
|
2690
2705
|
}
|
|
2691
2706
|
this.error("Unterminated ANSI-C quote", { quote: "'", line: quoteLine });
|
|
2692
2707
|
}
|
|
2708
|
+
readExpansionName() {
|
|
2709
|
+
while (this.source.startsWith("\\\n", this.position)) this.position += 2;
|
|
2710
|
+
const first = this.source[this.position];
|
|
2711
|
+
if (first && /^[?@*#-]$/u.test(first)) {
|
|
2712
|
+
this.position++;
|
|
2713
|
+
return first;
|
|
2714
|
+
}
|
|
2715
|
+
if (first && /^[0-9]$/u.test(first)) {
|
|
2716
|
+
let name2 = "";
|
|
2717
|
+
while (this.position < this.source.length) {
|
|
2718
|
+
if (this.source.startsWith("\\\n", this.position)) {
|
|
2719
|
+
this.position += 2;
|
|
2720
|
+
continue;
|
|
2721
|
+
}
|
|
2722
|
+
const ch = this.source[this.position];
|
|
2723
|
+
if (!ch || !/^[0-9]$/u.test(ch)) break;
|
|
2724
|
+
name2 += ch;
|
|
2725
|
+
this.position++;
|
|
2726
|
+
}
|
|
2727
|
+
return name2;
|
|
2728
|
+
}
|
|
2729
|
+
if (first && /^[a-zA-Z_]$/u.test(first)) {
|
|
2730
|
+
let name2 = "";
|
|
2731
|
+
while (this.position < this.source.length) {
|
|
2732
|
+
if (this.source.startsWith("\\\n", this.position)) {
|
|
2733
|
+
this.position += 2;
|
|
2734
|
+
continue;
|
|
2735
|
+
}
|
|
2736
|
+
const ch = this.source[this.position];
|
|
2737
|
+
if (!ch || !/^[a-zA-Z_0-9]$/u.test(ch)) break;
|
|
2738
|
+
name2 += ch;
|
|
2739
|
+
this.position++;
|
|
2740
|
+
}
|
|
2741
|
+
return name2;
|
|
2742
|
+
}
|
|
2743
|
+
return void 0;
|
|
2744
|
+
}
|
|
2745
|
+
peekAfterContinuation(offset = this.position) {
|
|
2746
|
+
while (this.source.startsWith("\\\n", offset)) offset += 2;
|
|
2747
|
+
return offset;
|
|
2748
|
+
}
|
|
2693
2749
|
expansion(parts, quoted) {
|
|
2694
2750
|
this.budget.admit();
|
|
2695
2751
|
const spellingStart = this.position;
|
|
@@ -2703,8 +2759,9 @@ shell: command substitution: line ${line}: \`${sourceLine}'
|
|
|
2703
2759
|
this.position++;
|
|
2704
2760
|
let source = "";
|
|
2705
2761
|
const sourceValues = this.sourceValues ? /* @__PURE__ */ new Map() : void 0;
|
|
2762
|
+
const backtickEscapable = quoted && this.documentLine === void 0 ? /[$`\\"]/u : /[$`\\]/u;
|
|
2706
2763
|
while (this.position < this.source.length && this.source[this.position] !== "`") {
|
|
2707
|
-
if (this.source[this.position] === "\\" &&
|
|
2764
|
+
if (this.source[this.position] === "\\" && backtickEscapable.test(this.source[this.position + 1] ?? "")) this.position++;
|
|
2708
2765
|
const opaque = this.sourceValues?.get(this.sourceOffset + this.position);
|
|
2709
2766
|
if (opaque !== void 0) {
|
|
2710
2767
|
this.budget.admit();
|
|
@@ -2715,7 +2772,7 @@ shell: command substitution: line ${line}: \`${sourceLine}'
|
|
|
2715
2772
|
if (this.source[this.position] !== "`") this.error("Unterminated command substitution");
|
|
2716
2773
|
this.position++;
|
|
2717
2774
|
try {
|
|
2718
|
-
parts.push({ kind: "substitution", form: "backtick", script: parseSource(source, this.depth + this.operandDepth + 1, this.warnings, line - 1, this.byteLocale, this.budget, this.documentLine === void 0, sourceValues, this.byteSource, this.syntax), line, quoted });
|
|
2775
|
+
parts.push({ kind: "substitution", form: "backtick", script: parseSource(source, this.depth + this.operandDepth + 1, this.warnings, line - 1, this.byteLocale, this.budget, this.documentLine === void 0, sourceValues, this.byteSource, this.syntax, this.aliases), line, quoted });
|
|
2719
2776
|
} catch (error) {
|
|
2720
2777
|
if (this.documentLine === void 0 || !(error instanceof ShellSyntaxError) || /nesting|exceeds/u.test(error.reason)) throw error;
|
|
2721
2778
|
this.budget.admit();
|
|
@@ -2728,20 +2785,24 @@ shell: command substitution: line ${line}: \`${sourceLine}'
|
|
|
2728
2785
|
return;
|
|
2729
2786
|
}
|
|
2730
2787
|
this.position++;
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2788
|
+
while (this.source.startsWith("\\\n", this.position)) this.position += 2;
|
|
2789
|
+
const firstParen = this.source[this.position] === "(" ? this.position : -1;
|
|
2790
|
+
const secondParen = firstParen !== -1 ? this.peekAfterContinuation(firstParen + 1) : -1;
|
|
2791
|
+
const arithmeticEndPos = secondParen !== -1 && this.source[secondParen] === "(" ? arithmeticEnd(this.source, secondParen + 1, true, this.budget.maxSyntaxDepth) : -1;
|
|
2792
|
+
if (arithmeticEndPos !== -1) {
|
|
2793
|
+
const start = secondParen + 1;
|
|
2794
|
+
const end = arithmeticEndPos;
|
|
2735
2795
|
const source = this.source.slice(start, end);
|
|
2736
2796
|
parts.push({ kind: "arithmetic", expression: prepareArithmetic(source, this.budget), source, line, quoted });
|
|
2737
|
-
|
|
2797
|
+
const afterFirstClose = this.peekAfterContinuation(end + 1);
|
|
2798
|
+
this.position = afterFirstClose + 1;
|
|
2738
2799
|
} else if (this.source[this.position] === "(") {
|
|
2739
2800
|
const start = this.position + 1;
|
|
2740
2801
|
let nested;
|
|
2741
2802
|
let script;
|
|
2742
2803
|
try {
|
|
2743
2804
|
this.budget.admit();
|
|
2744
|
-
nested = new Parser(this.budget, this.source.slice(start), this.depth + this.operandDepth + 1, this.warnings, this.lineAt(start) - 1, void 0, this.byteLocale, false, this.lineIndex, this.sourceOffset + start, false, this.sourceValues, this.byteSource, this.syntax);
|
|
2805
|
+
nested = new Parser(this.budget, this.source.slice(start), this.depth + this.operandDepth + 1, this.warnings, this.lineAt(start) - 1, void 0, this.byteLocale, false, this.lineIndex, this.sourceOffset + start, false, this.sourceValues, this.byteSource, this.syntax, this.aliases);
|
|
2745
2806
|
script = nested.script(/* @__PURE__ */ new Set([")"]));
|
|
2746
2807
|
} catch (error) {
|
|
2747
2808
|
if (this.documentLine !== void 0 && error instanceof ShellSyntaxError && !/nesting|exceeds/u.test(error.reason)) throw this.documentSubstitutionError(this.source.slice(start), error);
|
|
@@ -2758,23 +2819,28 @@ shell: command substitution: line ${line}: \`${sourceLine}'
|
|
|
2758
2819
|
else this.printedNewlineReduction += this.source.slice(start, this.position - 1).split("\n").length - 1 - script.printedNewlines;
|
|
2759
2820
|
parts.push({ kind: "substitution", form: "dollar-parenthesis", script, line, sourceLine: script.line ?? line, quoted });
|
|
2760
2821
|
} else if (this.source[this.position] === "{") {
|
|
2761
|
-
this.position
|
|
2822
|
+
this.position = this.peekAfterContinuation(this.position + 1);
|
|
2762
2823
|
const parameterStart = this.position - 2;
|
|
2763
|
-
const
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2824
|
+
const afterBang = this.peekAfterContinuation(this.position + 1);
|
|
2825
|
+
const listing = this.source[this.position] === "!" && /[a-zA-Z_0-9]/u.test(this.source[afterBang] ?? "");
|
|
2826
|
+
if (listing) this.position = afterBang;
|
|
2827
|
+
const afterHash = this.peekAfterContinuation(this.position + 1);
|
|
2828
|
+
const length = !listing && this.source[this.position] === "#" && (/[a-zA-Z_0-9]/u.test(this.source[afterHash] ?? "") || ["@", "*"].includes(this.source[afterHash] ?? "") && this.source[this.peekAfterContinuation(afterHash + 1)] === "}" || this.syntax.specialParameters.some((parameter) => parameter.name === this.source[afterHash]));
|
|
2829
|
+
if (length) this.position = afterHash;
|
|
2767
2830
|
const specialParameter = this.syntax.specialParameters.find((parameter) => parameter.name === this.source[this.position]);
|
|
2768
|
-
|
|
2831
|
+
if (specialParameter) this.position += specialParameter.name.length;
|
|
2832
|
+
const dollarBang = !specialParameter && "$!".includes(this.source[this.position] ?? " ") ? this.source[this.position++] : void 0;
|
|
2833
|
+
const name2 = specialParameter?.name ?? dollarBang ?? this.readExpansionName();
|
|
2769
2834
|
if (!name2) this.error("Unsupported parameter expansion");
|
|
2770
|
-
this.position
|
|
2835
|
+
this.position = this.peekAfterContinuation(this.position);
|
|
2771
2836
|
let prefixNames;
|
|
2772
2837
|
let indirect = false;
|
|
2773
2838
|
if (listing && this.source[this.position] !== "[") {
|
|
2774
2839
|
const separator = this.source[this.position];
|
|
2775
|
-
|
|
2840
|
+
const afterSep = this.peekAfterContinuation(this.position + 1);
|
|
2841
|
+
if ((separator === "*" || separator === "@") && this.source[afterSep] === "}") {
|
|
2776
2842
|
prefixNames = separator;
|
|
2777
|
-
this.position
|
|
2843
|
+
this.position = afterSep;
|
|
2778
2844
|
} else indirect = true;
|
|
2779
2845
|
}
|
|
2780
2846
|
let selector;
|
|
@@ -2785,7 +2851,7 @@ shell: command substitution: line ${line}: \`${sourceLine}'
|
|
|
2785
2851
|
const end = this.position;
|
|
2786
2852
|
if (this.source[end] !== "]") this.error("Unterminated indexed-array subscript");
|
|
2787
2853
|
selector = arraySelector(this.source.slice(start, end), start, this.budget, keyWord);
|
|
2788
|
-
this.position = end + 1;
|
|
2854
|
+
this.position = this.peekAfterContinuation(end + 1);
|
|
2789
2855
|
if (listing && selector.kind === "members" && this.source[this.position] !== "}" && this.source[this.position] !== "@") this.error("Unsupported array-key operator");
|
|
2790
2856
|
}
|
|
2791
2857
|
if (listing && selector?.kind === "element") indirect = true;
|
|
@@ -2795,14 +2861,34 @@ shell: command substitution: line ${line}: \`${sourceLine}'
|
|
|
2795
2861
|
}
|
|
2796
2862
|
let transform;
|
|
2797
2863
|
if (this.source[this.position] === "@") {
|
|
2798
|
-
const
|
|
2799
|
-
|
|
2864
|
+
const opPos = this.peekAfterContinuation(this.position + 1);
|
|
2865
|
+
const operation2 = this.source[opPos];
|
|
2866
|
+
const closePos = this.peekAfterContinuation(opPos + 1);
|
|
2867
|
+
if (length || prefixNames || !["Q", "E", "a", "A", "K", "k", "P", "u", "U", "L"].includes(operation2 ?? "") || this.source[closePos] !== "}") this.error("Unsupported parameter transform");
|
|
2800
2868
|
transform = operation2;
|
|
2801
|
-
this.position
|
|
2869
|
+
this.position = closePos;
|
|
2870
|
+
}
|
|
2871
|
+
const firstOpChar = this.source[this.position];
|
|
2872
|
+
const secondOpPos = this.peekAfterContinuation(this.position + 1);
|
|
2873
|
+
const secondOpChar = this.source[secondOpPos];
|
|
2874
|
+
const caseOperator = firstOpChar === "^" || firstOpChar === "," ? firstOpChar.repeat(secondOpChar === firstOpChar ? 2 : 1) : void 0;
|
|
2875
|
+
let operator = caseOperator;
|
|
2876
|
+
let operatorEnd = caseOperator ? caseOperator.length === 2 ? secondOpPos + 1 : this.position + 1 : this.position;
|
|
2877
|
+
if (!operator) {
|
|
2878
|
+
if (firstOpChar === ":" && secondOpChar && "-=+?".includes(secondOpChar)) {
|
|
2879
|
+
operator = `:${secondOpChar}`;
|
|
2880
|
+
operatorEnd = secondOpPos + 1;
|
|
2881
|
+
} else if ((firstOpChar === "#" || firstOpChar === "%") && secondOpChar === firstOpChar) {
|
|
2882
|
+
operator = `${firstOpChar}${secondOpChar}`;
|
|
2883
|
+
operatorEnd = secondOpPos + 1;
|
|
2884
|
+
} else if (firstOpChar === "/" && secondOpChar && "/#%".includes(secondOpChar)) {
|
|
2885
|
+
operator = `/${secondOpChar}`;
|
|
2886
|
+
operatorEnd = secondOpPos + 1;
|
|
2887
|
+
} else if (firstOpChar && "-=+?#%/".includes(firstOpChar)) {
|
|
2888
|
+
operator = firstOpChar;
|
|
2889
|
+
operatorEnd = this.position + 1;
|
|
2890
|
+
}
|
|
2802
2891
|
}
|
|
2803
|
-
const caseCharacter = this.source[this.position];
|
|
2804
|
-
const caseOperator = caseCharacter === "^" || caseCharacter === "," ? caseCharacter.repeat(this.source[this.position + 1] === caseCharacter ? 2 : 1) : void 0;
|
|
2805
|
-
const operator = caseOperator ?? /^(?::[-=+?]|##|%%|\/\/|\/[#%]?|[-=+?#%])/u.exec(this.source.slice(this.position))?.[0];
|
|
2806
2892
|
let alternate;
|
|
2807
2893
|
let replacement;
|
|
2808
2894
|
let substring;
|
|
@@ -2812,7 +2898,7 @@ shell: command substitution: line ${line}: \`${sourceLine}'
|
|
|
2812
2898
|
try {
|
|
2813
2899
|
if (operator) {
|
|
2814
2900
|
if (length) this.error("Invalid length expansion");
|
|
2815
|
-
this.position
|
|
2901
|
+
this.position = operatorEnd;
|
|
2816
2902
|
alternate = this.word(operator.startsWith("/") ? "/}" : "}", quoted && !caseOperator && !["#", "##", "%", "%%"].includes(operator) && !operator.startsWith("/"));
|
|
2817
2903
|
if (operator.startsWith("/") && this.source[this.position] === "/") {
|
|
2818
2904
|
this.position++;
|
|
@@ -2820,7 +2906,7 @@ shell: command substitution: line ${line}: \`${sourceLine}'
|
|
|
2820
2906
|
}
|
|
2821
2907
|
} else {
|
|
2822
2908
|
if (length || name2 !== "@" && name2 !== "*" && !/^(?:[a-zA-Z_][a-zA-Z_0-9]*|[0-9]+)$/u.test(name2)) this.error("Unsupported non-scalar substring expansion");
|
|
2823
|
-
this.position
|
|
2909
|
+
this.position = secondOpPos;
|
|
2824
2910
|
const offset = this.word(":}", true, false, true);
|
|
2825
2911
|
let substringLength;
|
|
2826
2912
|
if (this.source[this.position] === ":") {
|
|
@@ -2834,6 +2920,7 @@ shell: command substitution: line ${line}: \`${sourceLine}'
|
|
|
2834
2920
|
this.operandDepth--;
|
|
2835
2921
|
}
|
|
2836
2922
|
}
|
|
2923
|
+
this.position = this.peekAfterContinuation(this.position);
|
|
2837
2924
|
if (this.source[this.position] !== "}") {
|
|
2838
2925
|
let end = this.position;
|
|
2839
2926
|
if (this.ordinaryBacktick && !selector && !operator && !substring && /^[a-zA-Z_]/u.test(name2) && !"^,@".includes(this.source[this.position] ?? "")) {
|
|
@@ -2851,9 +2938,10 @@ shell: command substitution: line ${line}: \`${sourceLine}'
|
|
|
2851
2938
|
}
|
|
2852
2939
|
} else {
|
|
2853
2940
|
const specialParameter = this.syntax.specialParameters.find((parameter) => parameter.name === this.source[this.position]);
|
|
2854
|
-
|
|
2941
|
+
if (specialParameter) this.position += specialParameter.name.length;
|
|
2942
|
+
const dollarBang = !specialParameter && "$!".includes(this.source[this.position] ?? " ") ? this.source[this.position++] : void 0;
|
|
2943
|
+
const name2 = specialParameter?.name ?? dollarBang ?? (this.source[this.position] && /^[0-9]$/u.test(this.source[this.position]) ? this.source[this.position++] : this.readExpansionName());
|
|
2855
2944
|
if (name2) {
|
|
2856
|
-
this.position += name2.length;
|
|
2857
2945
|
parts.push({ kind: "variable", name: name2, quoted, line, ...specialParameter ? { specialParameter } : {} });
|
|
2858
2946
|
} else parts.push({ kind: "text", value: "$", quoted });
|
|
2859
2947
|
}
|
|
@@ -2864,16 +2952,22 @@ shell: command substitution: line ${line}: \`${sourceLine}'
|
|
|
2864
2952
|
}
|
|
2865
2953
|
};
|
|
2866
2954
|
var Parser = class {
|
|
2867
|
-
constructor(budget, source, depth, warnings = [], lineOffset = 0, position, byteLocale2 = false, partial = false, lineIndex = new SourceLineIndex(source, budget), sourceOffset = 0, ordinaryBacktick = false, sourceValues, byteSource = false, syntax = defaultSyntax) {
|
|
2955
|
+
constructor(budget, source, depth, warnings = [], lineOffset = 0, position, byteLocale2 = false, partial = false, lineIndex = new SourceLineIndex(source, budget), sourceOffset = 0, ordinaryBacktick = false, sourceValues, byteSource = false, syntax = defaultSyntax, aliases) {
|
|
2868
2956
|
this.budget = budget;
|
|
2957
|
+
this.aliases = aliases;
|
|
2869
2958
|
if (position === void 0 && depth === 0 && source.includes("\0")) throw new ShellSyntaxError("NUL bytes are not valid shell source", source.indexOf("\0"));
|
|
2870
2959
|
budget.admit();
|
|
2871
|
-
this.lexer = new Lexer(budget, source, depth, warnings, lineOffset, byteLocale2, void 0, partial, lineIndex, sourceOffset, ordinaryBacktick, sourceValues, byteSource, syntax);
|
|
2960
|
+
this.lexer = new Lexer(budget, source, depth, warnings, lineOffset, byteLocale2, void 0, partial, lineIndex, sourceOffset, ordinaryBacktick, sourceValues, byteSource, syntax, aliases);
|
|
2872
2961
|
this.lexer.position = position ?? 0;
|
|
2873
2962
|
this.current = this.lexer.next();
|
|
2874
2963
|
}
|
|
2875
2964
|
budget;
|
|
2965
|
+
aliases;
|
|
2876
2966
|
lexer;
|
|
2967
|
+
aliasFrames = [];
|
|
2968
|
+
aliasNextWords = /* @__PURE__ */ new WeakSet();
|
|
2969
|
+
tokenAliases = /* @__PURE__ */ new WeakMap();
|
|
2970
|
+
tokenLexers = /* @__PURE__ */ new WeakMap();
|
|
2877
2971
|
current;
|
|
2878
2972
|
lookahead;
|
|
2879
2973
|
nesting = 0;
|
|
@@ -2886,12 +2980,74 @@ var Parser = class {
|
|
|
2886
2980
|
}
|
|
2887
2981
|
advance() {
|
|
2888
2982
|
const previous = this.current;
|
|
2889
|
-
this.current = this.lookahead ?? this.
|
|
2983
|
+
this.current = this.lookahead ?? this.nextToken();
|
|
2984
|
+
this.lexer = this.tokenLexers.get(this.current) ?? this.lexer;
|
|
2890
2985
|
this.lookahead = void 0;
|
|
2891
2986
|
return previous;
|
|
2892
2987
|
}
|
|
2893
2988
|
peek() {
|
|
2894
|
-
|
|
2989
|
+
if (!this.lookahead) {
|
|
2990
|
+
const lexer = this.lexer;
|
|
2991
|
+
this.lookahead = this.nextToken();
|
|
2992
|
+
this.lexer = lexer;
|
|
2993
|
+
}
|
|
2994
|
+
return this.lookahead;
|
|
2995
|
+
}
|
|
2996
|
+
nextToken() {
|
|
2997
|
+
let token = this.lexer.next();
|
|
2998
|
+
if (!this.aliases?.size) return token;
|
|
2999
|
+
this.tokenLexers.set(token, this.lexer);
|
|
3000
|
+
this.tokenAliases.set(token, this.aliasFrames.map((frame) => frame.name));
|
|
3001
|
+
let trailing = false;
|
|
3002
|
+
while (token.kind === "end" && this.aliasFrames.length) {
|
|
3003
|
+
const frame = this.aliasFrames.pop();
|
|
3004
|
+
this.lexer = frame.lexer;
|
|
3005
|
+
trailing ||= frame.trailing;
|
|
3006
|
+
token = frame.next;
|
|
3007
|
+
}
|
|
3008
|
+
if (trailing) this.aliasNextWords.add(token);
|
|
3009
|
+
return token;
|
|
3010
|
+
}
|
|
3011
|
+
expandAlias() {
|
|
3012
|
+
while (this.current.kind === "word") {
|
|
3013
|
+
const name2 = this.current.word?.plain;
|
|
3014
|
+
if (name2 === void 0 || this.current.word.parts.some((part) => part.quoted) || this.tokenAliases.get(this.current)?.includes(name2)) return;
|
|
3015
|
+
const value = this.aliases?.get(name2);
|
|
3016
|
+
if (value === void 0) return;
|
|
3017
|
+
this.budget.admit(value.length + 1);
|
|
3018
|
+
const lexer = this.lexer;
|
|
3019
|
+
const line = lexer.lineAt(this.current.offset);
|
|
3020
|
+
const next = this.lookahead ?? lexer.next();
|
|
3021
|
+
this.tokenLexers.set(next, this.tokenLexers.get(next) ?? lexer);
|
|
3022
|
+
this.lookahead = void 0;
|
|
3023
|
+
this.aliasFrames.push({ lexer, next, name: name2, trailing: value.endsWith(" ") || value.endsWith(" ") });
|
|
3024
|
+
this.lexer = new Lexer(this.budget, value, lexer.depth, lexer.warnings, line - 1, lexer.byteLocale, void 0, false, void 0, 0, false, void 0, lexer.byteSource, lexer.syntax, this.aliases);
|
|
3025
|
+
this.current = this.nextToken();
|
|
3026
|
+
}
|
|
3027
|
+
}
|
|
3028
|
+
assignmentWord(compound = false) {
|
|
3029
|
+
const word = this.current.word;
|
|
3030
|
+
const bracket = word.spelling?.indexOf("[") ?? -1;
|
|
3031
|
+
const prefix = word.spelling?.slice(0, bracket);
|
|
3032
|
+
if (bracket >= 0 && (compound && bracket === 0 || prefix && scalarAssignmentName({
|
|
3033
|
+
offset: word.offset,
|
|
3034
|
+
parts: [{ kind: "text", quoted: false, value: prefix + "=" }]
|
|
3035
|
+
}) === prefix)) {
|
|
3036
|
+
const scanner = new Lexer(this.budget, this.lexer.source, this.lexer.depth, [], this.lexer.lineOffset, this.lexer.byteLocale, void 0, false, this.lexer.lineIndex, this.lexer.sourceOffset, this.lexer.ordinaryBacktick, this.lexer.sourceValues, this.lexer.byteSource, this.lexer.syntax);
|
|
3037
|
+
scanner.position = word.offset + bracket + 1;
|
|
3038
|
+
scanner.word("]");
|
|
3039
|
+
const end = scanner.position;
|
|
3040
|
+
if (end >= this.current.end && this.lexer.source[end] === "]" && (this.lexer.source[end + 1] === "=" || this.lexer.source.slice(end + 1, end + 3) === "+=")) {
|
|
3041
|
+
this.lexer.position = word.offset;
|
|
3042
|
+
const parsed = this.lexer.word(void 0, false, false, false, false, end);
|
|
3043
|
+
this.budget.admit();
|
|
3044
|
+
const complete = { ...parsed, spelling: this.lexer.source.slice(word.offset, this.lexer.position) };
|
|
3045
|
+
this.lookahead = void 0;
|
|
3046
|
+
this.current = this.lexer.next();
|
|
3047
|
+
return complete;
|
|
3048
|
+
}
|
|
3049
|
+
}
|
|
3050
|
+
return this.advance().word;
|
|
2895
3051
|
}
|
|
2896
3052
|
is(value) {
|
|
2897
3053
|
return this.current.value === value;
|
|
@@ -2914,6 +3070,8 @@ var Parser = class {
|
|
|
2914
3070
|
const line = this.lexer.lineAt(this.current.offset);
|
|
2915
3071
|
if (captureInputUnits) this.completedInput = { lists, count: 0, line };
|
|
2916
3072
|
while (this.current.kind !== "end" && !stops.has(this.current.value)) {
|
|
3073
|
+
this.expandAlias();
|
|
3074
|
+
if (this.isEnd() || stops.has(this.current.value)) break;
|
|
2917
3075
|
this.budget.admit();
|
|
2918
3076
|
const pipelines = [this.pipeline()];
|
|
2919
3077
|
const operators = [];
|
|
@@ -2926,13 +3084,13 @@ var Parser = class {
|
|
|
2926
3084
|
lists.push({ pipelines, operators, ...terminator ? { terminator } : {} });
|
|
2927
3085
|
separators.push(this.is("\n"));
|
|
2928
3086
|
if (captureInputUnits && this.is("\n")) this.completedInput.count = lists.length;
|
|
2929
|
-
if (inputUnit && this.is("\n")) break;
|
|
3087
|
+
if (inputUnit && !this.aliasFrames.length && this.is("\n")) break;
|
|
2930
3088
|
if (terminator || this.is(";") || this.is("\n")) {
|
|
2931
3089
|
this.advance();
|
|
2932
3090
|
if (captureInputUnits && this.is("\n")) this.completedInput.count = lists.length;
|
|
2933
|
-
if (inputUnit && this.is("\n")) break;
|
|
3091
|
+
if (inputUnit && !this.aliasFrames.length && this.is("\n")) break;
|
|
2934
3092
|
this.newlines();
|
|
2935
|
-
} else if (!this.isEnd() && !this.is(")") && !(stops.has(this.current.value) && [";;", ";&", ";;&"].includes(this.current.value))) this.error("Expected command separator");
|
|
3093
|
+
} else if (!this.isEnd() && !this.is(")") && !(stops.has(this.current.value) && ([";;", ";&", ";;&"].includes(this.current.value) || isSelfDelimitingCompound(pipelines.at(-1)?.commands.at(-1))))) this.error("Expected command separator");
|
|
2936
3094
|
}
|
|
2937
3095
|
const printed = printedSimpleLines(lists, separators, this.budget);
|
|
2938
3096
|
scriptSeparators.set(lists, Object.freeze(separators));
|
|
@@ -2960,6 +3118,7 @@ var Parser = class {
|
|
|
2960
3118
|
return { commands, negate };
|
|
2961
3119
|
}
|
|
2962
3120
|
command() {
|
|
3121
|
+
this.expandAlias();
|
|
2963
3122
|
if (++this.nesting + this.lexer.depth > this.lexer.budget.maxSyntaxDepth) this.error(`Syntax nesting exceeds ${this.lexer.budget.maxSyntaxDepth}`);
|
|
2964
3123
|
this.budget.admit();
|
|
2965
3124
|
const line = this.lexer.lineAt(this.current.offset);
|
|
@@ -2975,7 +3134,8 @@ var Parser = class {
|
|
|
2975
3134
|
}
|
|
2976
3135
|
commandInner() {
|
|
2977
3136
|
this.budget.admit();
|
|
2978
|
-
const
|
|
3137
|
+
const arithmeticSecondOpen = this.is("(") ? this.lexer.peekAfterContinuation(this.current.offset + 1) : -1;
|
|
3138
|
+
const arithmeticCommandEnd = arithmeticSecondOpen !== -1 && this.lexer.source[arithmeticSecondOpen] === "(" ? arithmeticEnd(this.lexer.source, arithmeticSecondOpen + 1, true, this.lexer.budget.maxSyntaxDepth) : -1;
|
|
2979
3139
|
let command;
|
|
2980
3140
|
if (this.is("[[")) {
|
|
2981
3141
|
const start = this.current.end;
|
|
@@ -3048,11 +3208,11 @@ var Parser = class {
|
|
|
3048
3208
|
this.advance();
|
|
3049
3209
|
command = { kind: "conditional", expression, source, redirects: [] };
|
|
3050
3210
|
} else if (arithmeticCommandEnd !== -1) {
|
|
3051
|
-
const start =
|
|
3211
|
+
const start = arithmeticSecondOpen + 1;
|
|
3052
3212
|
const end = arithmeticCommandEnd;
|
|
3053
3213
|
const source = this.lexer.source.slice(start, end);
|
|
3054
3214
|
command = { kind: "arithmetic", expression: prepareArithmetic(source, this.budget), source, redirects: [] };
|
|
3055
|
-
this.lexer.position = end +
|
|
3215
|
+
this.lexer.position = this.lexer.peekAfterContinuation(end + 1) + 1;
|
|
3056
3216
|
this.lookahead = void 0;
|
|
3057
3217
|
this.current = this.lexer.next();
|
|
3058
3218
|
} else if (this.is("(") || this.is("{")) {
|
|
@@ -3118,32 +3278,60 @@ var Parser = class {
|
|
|
3118
3278
|
const body = this.nonemptyScript(/* @__PURE__ */ new Set(["done"]));
|
|
3119
3279
|
this.expect("done", true);
|
|
3120
3280
|
command = { kind, condition, body, redirects: [] };
|
|
3121
|
-
} else if (this.is("for") && this.peek().value === "(" && this.lexer.source.
|
|
3281
|
+
} else if (this.is("for") && this.peek().value === "(" && this.lexer.source[this.lexer.peekAfterContinuation(this.peek().offset + 1)] === "(") {
|
|
3122
3282
|
this.advance();
|
|
3123
|
-
const start = this.current.offset +
|
|
3283
|
+
const start = this.lexer.peekAfterContinuation(this.current.offset + 1) + 1;
|
|
3124
3284
|
let partStart = start;
|
|
3125
3285
|
let depth = 0;
|
|
3126
3286
|
let end = start;
|
|
3287
|
+
let quote = "";
|
|
3288
|
+
let ansiQuote = false;
|
|
3289
|
+
const quotedSubstitutions = [];
|
|
3127
3290
|
this.budget.admit(4);
|
|
3128
3291
|
const sources = [];
|
|
3129
3292
|
for (; end < this.lexer.source.length; end++) {
|
|
3130
3293
|
this.budget.admit();
|
|
3131
3294
|
const character = this.lexer.source[end];
|
|
3295
|
+
if (character === "\\" && (quote !== "'" || ansiQuote)) {
|
|
3296
|
+
end++;
|
|
3297
|
+
continue;
|
|
3298
|
+
}
|
|
3299
|
+
if (quote === '"' && character === "$" && this.lexer.source[end + 1] === "(") {
|
|
3300
|
+
if (quotedSubstitutions.length >= 64) this.error("Syntax nesting exceeds 64");
|
|
3301
|
+
quotedSubstitutions.push(depth);
|
|
3302
|
+
depth++;
|
|
3303
|
+
end++;
|
|
3304
|
+
quote = "";
|
|
3305
|
+
continue;
|
|
3306
|
+
}
|
|
3307
|
+
if (quote) {
|
|
3308
|
+
if (character === quote) quote = "";
|
|
3309
|
+
continue;
|
|
3310
|
+
}
|
|
3311
|
+
if (character === "'" || character === '"' || character === "`") {
|
|
3312
|
+
quote = character;
|
|
3313
|
+
ansiQuote = character === "'" && this.lexer.source[end - 1] === "$";
|
|
3314
|
+
continue;
|
|
3315
|
+
}
|
|
3132
3316
|
if (character === "(") depth++;
|
|
3133
3317
|
else if (character === ")") {
|
|
3134
|
-
if (!depth && this.lexer.source[end + 1] === ")") break;
|
|
3318
|
+
if (!depth && this.lexer.source[this.lexer.peekAfterContinuation(end + 1)] === ")") break;
|
|
3135
3319
|
if (--depth < 0) this.error("Unterminated arithmetic for", true);
|
|
3320
|
+
if (quotedSubstitutions.at(-1) === depth) {
|
|
3321
|
+
quotedSubstitutions.pop();
|
|
3322
|
+
quote = '"';
|
|
3323
|
+
}
|
|
3136
3324
|
} else if (character === ";" && !depth) {
|
|
3137
3325
|
if (sources.length === 2) this.error("Arithmetic for requires three expressions");
|
|
3138
3326
|
sources.push(this.lexer.source.slice(partStart, end));
|
|
3139
3327
|
partStart = end + 1;
|
|
3140
3328
|
}
|
|
3141
3329
|
}
|
|
3142
|
-
if (end === this.lexer.source.length) this.error("Unterminated arithmetic for", true);
|
|
3330
|
+
if (quote || end === this.lexer.source.length) this.error("Unterminated arithmetic for", true);
|
|
3143
3331
|
if (sources.length !== 2) this.error("Arithmetic for requires three expressions");
|
|
3144
3332
|
sources.push(this.lexer.source.slice(partStart, end));
|
|
3145
3333
|
const expressions = sources.map((source) => source.trim() ? prepareArithmetic(source, this.budget) : void 0);
|
|
3146
|
-
this.lexer.position = end +
|
|
3334
|
+
this.lexer.position = this.lexer.peekAfterContinuation(end + 1) + 1;
|
|
3147
3335
|
this.lookahead = void 0;
|
|
3148
3336
|
this.current = this.lexer.next();
|
|
3149
3337
|
if (this.is(";")) this.advance();
|
|
@@ -3200,6 +3388,10 @@ var Parser = class {
|
|
|
3200
3388
|
};
|
|
3201
3389
|
let line;
|
|
3202
3390
|
while (true) {
|
|
3391
|
+
if (this.aliasNextWords.has(this.current) || words.every((previous) => getArrayAssignment(previous) || scalarAssignmentName(previous))) {
|
|
3392
|
+
this.aliasNextWords.delete(this.current);
|
|
3393
|
+
this.expandAlias();
|
|
3394
|
+
}
|
|
3203
3395
|
const wordLine = this.lexer.lineAt(Math.max(this.current.offset, this.current.end - 1));
|
|
3204
3396
|
const redirect2 = this.redirect();
|
|
3205
3397
|
if (redirect2) {
|
|
@@ -3207,14 +3399,14 @@ var Parser = class {
|
|
|
3207
3399
|
redirects.push(redirect2);
|
|
3208
3400
|
} else if (this.current.kind === "word") {
|
|
3209
3401
|
line ??= wordLine;
|
|
3210
|
-
let word = this.advance().word;
|
|
3402
|
+
let word = words.every((previous) => getArrayAssignment(previous) || scalarAssignmentName(previous)) || indexedDeclaration() ? this.assignmentWord() : this.advance().word;
|
|
3211
3403
|
const head = compoundHead(word, this.budget);
|
|
3212
3404
|
if (head && this.is("(")) {
|
|
3213
3405
|
this.advance();
|
|
3214
3406
|
const entries = [];
|
|
3215
3407
|
this.newlines();
|
|
3216
3408
|
while (this.current.kind === "word") {
|
|
3217
|
-
const original = this.
|
|
3409
|
+
const original = this.assignmentWord(true);
|
|
3218
3410
|
const entry = compoundEntry(original, this.budget, (source) => parseArraySubscript(source, this.budget, this.lexer.byteLocale, this.lexer.depth, this.lexer.byteSource, this.lexer.syntax), (source, start) => {
|
|
3219
3411
|
const lexer = new Lexer(this.budget, source, this.lexer.depth, [], 0, this.lexer.byteLocale, void 0, false, void 0, 0, false, void 0, this.lexer.byteSource, this.lexer.syntax);
|
|
3220
3412
|
lexer.position = start;
|
|
@@ -3339,7 +3531,7 @@ function hereDocumentWords(document, line, byteLocale2, warnings, budgetOrSyntax
|
|
|
3339
3531
|
}
|
|
3340
3532
|
})();
|
|
3341
3533
|
}
|
|
3342
|
-
function parseShellUnit(source, position = 0, byteLocale2 = false, budgetOrByteSource = new ParseBudget(), lineIndexOrSyntax, sourceValues, byteSource = false, syntax) {
|
|
3534
|
+
function parseShellUnit(source, position = 0, byteLocale2 = false, budgetOrByteSource = new ParseBudget(), lineIndexOrSyntax, sourceValues, byteSource = false, syntax, aliases) {
|
|
3343
3535
|
const budget = budgetOrByteSource instanceof ParseBudget ? budgetOrByteSource : new ParseBudget();
|
|
3344
3536
|
const lineIndex = lineIndexOrSyntax instanceof SourceLineIndex ? lineIndexOrSyntax : new SourceLineIndex(source, budget);
|
|
3345
3537
|
const captured = captureShellSyntax(syntax === void 0 ? lineIndexOrSyntax instanceof SourceLineIndex ? void 0 : lineIndexOrSyntax : syntax);
|
|
@@ -3347,7 +3539,7 @@ function parseShellUnit(source, position = 0, byteLocale2 = false, budgetOrByteS
|
|
|
3347
3539
|
const warnings = [];
|
|
3348
3540
|
budget.admit();
|
|
3349
3541
|
if (lineIndex.source !== source || lineIndex.budget !== budget) throw new TypeError("Source line index belongs to a different source or parse budget");
|
|
3350
|
-
const parser = new Parser(budget, source, 0, warnings, 0, position, byteLocale2, false, lineIndex, 0, false, sourceValues, raw, captured);
|
|
3542
|
+
const parser = new Parser(budget, source, 0, warnings, 0, position, byteLocale2, false, lineIndex, 0, false, sourceValues, raw, captured, aliases);
|
|
3351
3543
|
const script = parser.script(/* @__PURE__ */ new Set(), true);
|
|
3352
3544
|
const next = parser.current.end;
|
|
3353
3545
|
const nul = source.indexOf("\0", position);
|
|
@@ -3355,7 +3547,7 @@ function parseShellUnit(source, position = 0, byteLocale2 = false, budgetOrByteS
|
|
|
3355
3547
|
budget.admit(2);
|
|
3356
3548
|
return { script: { ...script, ...warnings.length ? { warnings } : {} }, next };
|
|
3357
3549
|
}
|
|
3358
|
-
function parseShellInputUnit(source, byteLocale2 = false, budgetOrSyntax = new ParseBudget(), suppliedLineIndex, syntax) {
|
|
3550
|
+
function parseShellInputUnit(source, byteLocale2 = false, budgetOrSyntax = new ParseBudget(), suppliedLineIndex, syntax, aliases) {
|
|
3359
3551
|
const budget = budgetOrSyntax instanceof ParseBudget ? budgetOrSyntax : new ParseBudget();
|
|
3360
3552
|
const lineIndex = suppliedLineIndex ?? new SourceLineIndex(source, budget);
|
|
3361
3553
|
const captured = captureShellSyntax(syntax === void 0 ? budgetOrSyntax instanceof ParseBudget ? void 0 : budgetOrSyntax : syntax);
|
|
@@ -3363,7 +3555,7 @@ function parseShellInputUnit(source, byteLocale2 = false, budgetOrSyntax = new P
|
|
|
3363
3555
|
try {
|
|
3364
3556
|
budget.admit();
|
|
3365
3557
|
if (lineIndex.source !== source || lineIndex.budget !== budget) throw new TypeError("Source line index belongs to a different source or parse budget");
|
|
3366
|
-
const parser = new Parser(budget, source, 0, warnings, 0, 0, byteLocale2, true, lineIndex, 0, false, void 0, false, captured);
|
|
3558
|
+
const parser = new Parser(budget, source, 0, warnings, 0, 0, byteLocale2, true, lineIndex, 0, false, void 0, false, captured, aliases);
|
|
3367
3559
|
const script = parser.script(/* @__PURE__ */ new Set(), true);
|
|
3368
3560
|
budget.admit(2);
|
|
3369
3561
|
return { script: { ...script, ...warnings.length ? { warnings } : {} }, next: parser.current.end };
|
|
@@ -3373,10 +3565,10 @@ function parseShellInputUnit(source, byteLocale2 = false, budgetOrSyntax = new P
|
|
|
3373
3565
|
throw error;
|
|
3374
3566
|
}
|
|
3375
3567
|
}
|
|
3376
|
-
function parseSource(source, depth, warnings, lineOffset, byteLocale2, budget, ordinaryBacktick = false, sourceValues, byteSource = false, syntax = defaultSyntax) {
|
|
3568
|
+
function parseSource(source, depth, warnings, lineOffset, byteLocale2, budget, ordinaryBacktick = false, sourceValues, byteSource = false, syntax = defaultSyntax, aliases) {
|
|
3377
3569
|
budget.admit();
|
|
3378
3570
|
const warningCount = warnings.length;
|
|
3379
|
-
const parser = new Parser(budget, source, depth, warnings, lineOffset, void 0, byteLocale2, false, void 0, 0, ordinaryBacktick, sourceValues, byteSource, syntax);
|
|
3571
|
+
const parser = new Parser(budget, source, depth, warnings, lineOffset, void 0, byteLocale2, false, void 0, 0, ordinaryBacktick, sourceValues, byteSource, syntax, aliases);
|
|
3380
3572
|
try {
|
|
3381
3573
|
const script = parser.script(/* @__PURE__ */ new Set(), false, ordinaryBacktick);
|
|
3382
3574
|
if (parser.current.kind !== "end") parser.error("Unexpected token");
|
|
@@ -3392,502 +3584,6 @@ function parseSource(source, depth, warnings, lineOffset, byteLocale2, budget, o
|
|
|
3392
3584
|
}
|
|
3393
3585
|
}
|
|
3394
3586
|
|
|
3395
|
-
// packages/safe-bash/src/commands/csvcut/index.ts
|
|
3396
|
-
init_platform();
|
|
3397
|
-
import {
|
|
3398
|
-
CsvBudget,
|
|
3399
|
-
CsvParser,
|
|
3400
|
-
generatedHeaders,
|
|
3401
|
-
parseCsvcutArguments,
|
|
3402
|
-
resolveColumns,
|
|
3403
|
-
serializeRow,
|
|
3404
|
-
createCsvcutCommand as createRawCsvcutCommand,
|
|
3405
|
-
createCsvcutCommands as createRawCsvcutCommands,
|
|
3406
|
-
csvcutCommand as rawCsvcutCommand
|
|
3407
|
-
} from "../../safe-bash-command-csvcut/index.js";
|
|
3408
|
-
import { CsvBudget as CsvBudget2, CsvError, CsvParser as CsvParser2, csvcut, cutCsv, defaultCsvLimits, generatedHeaders as generatedHeaders2, parseCsvRecords, parseCsvcutArguments as parseCsvcutArguments2, resolveColumns as resolveColumns2, serializeRow as serializeRow2 } from "../../safe-bash-command-csvcut/index.js";
|
|
3409
|
-
builtInDirectContextExecutors.add(rawCsvcutCommand.execute);
|
|
3410
|
-
function createCsvcutCommand(options) {
|
|
3411
|
-
const def = createRawCsvcutCommand(options);
|
|
3412
|
-
if (options?.limits === void 0) builtInDirectContextExecutors.add(def.execute);
|
|
3413
|
-
return def;
|
|
3414
|
-
}
|
|
3415
|
-
function createCsvcutCommands(options) {
|
|
3416
|
-
const defs = createRawCsvcutCommands(options);
|
|
3417
|
-
if (options?.limits === void 0) {
|
|
3418
|
-
for (let i = 0; i < defs.length; i++) builtInDirectContextExecutors.add(defs[i].execute);
|
|
3419
|
-
}
|
|
3420
|
-
return defs;
|
|
3421
|
-
}
|
|
3422
|
-
function csvcutCommands(options = {}) {
|
|
3423
|
-
const commands = createCsvcutCommands(options);
|
|
3424
|
-
const replace = options.replace ?? false;
|
|
3425
|
-
return {
|
|
3426
|
-
name: "csvcut",
|
|
3427
|
-
setup(host) {
|
|
3428
|
-
for (const command of commands) host.commands.register(command, { replace });
|
|
3429
|
-
}
|
|
3430
|
-
};
|
|
3431
|
-
}
|
|
3432
|
-
var _syncAbortSignal;
|
|
3433
|
-
var syncAbortSignal = () => _syncAbortSignal ??= new AbortController().signal;
|
|
3434
|
-
function evalSyncCsvcut(inBytes, opArgs, readFileSync) {
|
|
3435
|
-
if (inBytes !== void 0 && inBytes.byteLength > 16384) return void 0;
|
|
3436
|
-
const budget = new CsvBudget({}, syncAbortSignal());
|
|
3437
|
-
try {
|
|
3438
|
-
const supplied = parseCsvcutArguments(opArgs, budget);
|
|
3439
|
-
if (supplied.help || supplied.version) return void 0;
|
|
3440
|
-
if (supplied.encoding && supplied.encoding.toLowerCase() !== "utf-8" && supplied.encoding.toLowerCase() !== "utf-8-sig") {
|
|
3441
|
-
return void 0;
|
|
3442
|
-
}
|
|
3443
|
-
let sourceBytes = inBytes;
|
|
3444
|
-
if (supplied.filePath !== void 0 && supplied.filePath !== "-") {
|
|
3445
|
-
if (!readFileSync) return void 0;
|
|
3446
|
-
const fileBytes = readFileSync(supplied.filePath);
|
|
3447
|
-
if (!fileBytes || fileBytes.byteLength > 16384) return void 0;
|
|
3448
|
-
sourceBytes = fileBytes;
|
|
3449
|
-
}
|
|
3450
|
-
if (supplied.names && supplied.headerless) return void 0;
|
|
3451
|
-
const dialect = { ...supplied.dialect, profile: supplied.dialect?.profile ?? "utf8-sig-permissive-v1" };
|
|
3452
|
-
if (Number.isSafeInteger(dialect.skipLines) && dialect.skipLines < 0) dialect.skipLines = 0;
|
|
3453
|
-
if (sourceBytes === void 0) return void 0;
|
|
3454
|
-
const parser = new CsvParser(dialect, budget);
|
|
3455
|
-
const rows = [...parser.push(sourceBytes), ...parser.end()];
|
|
3456
|
-
const first = rows[0];
|
|
3457
|
-
if (supplied.names && !first) return void 0;
|
|
3458
|
-
const headers = supplied.headerless ? generatedHeaders(first?.cells.length ?? 0, budget) : first?.cells ?? [];
|
|
3459
|
-
let out = supplied.addBom ? "\uFEFF" : "";
|
|
3460
|
-
if (supplied.names) {
|
|
3461
|
-
for (let i = 0; i < headers.length; i++) {
|
|
3462
|
-
out += `${String(i + (supplied.zero ? 0 : 1)).padStart(3, " ")}: ${headers[i]}
|
|
3463
|
-
`;
|
|
3464
|
-
}
|
|
3465
|
-
return out;
|
|
3466
|
-
}
|
|
3467
|
-
const columns = headers.length ? resolveColumns(supplied, headers, budget) : [];
|
|
3468
|
-
const project2 = (cells) => {
|
|
3469
|
-
const projected = [];
|
|
3470
|
-
for (let i = 0; i < columns.length; i++) {
|
|
3471
|
-
projected.push(cells[columns[i]] ?? "");
|
|
3472
|
-
}
|
|
3473
|
-
return projected;
|
|
3474
|
-
};
|
|
3475
|
-
const heading = project2(headers);
|
|
3476
|
-
if (supplied.lineNumbers) heading.unshift("line_number");
|
|
3477
|
-
out += serializeRow(heading, budget);
|
|
3478
|
-
let number2 = 0;
|
|
3479
|
-
for (let i = supplied.headerless ? 0 : 1; i < rows.length; i++) {
|
|
3480
|
-
const cells = project2(rows[i].cells);
|
|
3481
|
-
if (supplied.deleteEmptyRows && cells.every((c) => c === "")) continue;
|
|
3482
|
-
if (supplied.lineNumbers) cells.unshift(String(++number2));
|
|
3483
|
-
out += serializeRow(cells, budget);
|
|
3484
|
-
}
|
|
3485
|
-
return out;
|
|
3486
|
-
} catch {
|
|
3487
|
-
return void 0;
|
|
3488
|
-
} finally {
|
|
3489
|
-
budget.dispose();
|
|
3490
|
-
}
|
|
3491
|
-
}
|
|
3492
|
-
|
|
3493
|
-
// packages/safe-bash/src/commands/csvgrep/index.ts
|
|
3494
|
-
init_platform();
|
|
3495
|
-
import {
|
|
3496
|
-
CsvBudget as CsvBudget3,
|
|
3497
|
-
CsvParser as CsvParser3,
|
|
3498
|
-
createMatcher,
|
|
3499
|
-
generatedHeaders as generatedHeaders3,
|
|
3500
|
-
matchesRow,
|
|
3501
|
-
parseCsvgrepArguments,
|
|
3502
|
-
selectColumns,
|
|
3503
|
-
serializeRow as serializeRow3,
|
|
3504
|
-
createCsvgrepCommand as createRawCsvgrepCommand,
|
|
3505
|
-
createCsvgrepCommands as createRawCsvgrepCommands,
|
|
3506
|
-
csvgrepCommand as rawCsvgrepCommand
|
|
3507
|
-
} from "../../safe-bash-command-csvgrep/index.js";
|
|
3508
|
-
import { CsvBudget as CsvBudget4, CsvError as CsvError2, CsvParser as CsvParser4, createMatcher as createMatcher2, csvgrep, generatedHeaders as generatedHeaders4, matchesRow as matchesRow2, parseCsvgrepArguments as parseCsvgrepArguments2, selectColumns as selectColumns2, serializeRow as serializeRow4 } from "../../safe-bash-command-csvgrep/index.js";
|
|
3509
|
-
builtInDirectContextExecutors.add(rawCsvgrepCommand.execute);
|
|
3510
|
-
function createCsvgrepCommand(options) {
|
|
3511
|
-
const def = createRawCsvgrepCommand(options);
|
|
3512
|
-
if (options?.limits === void 0) builtInDirectContextExecutors.add(def.execute);
|
|
3513
|
-
return def;
|
|
3514
|
-
}
|
|
3515
|
-
function createCsvgrepCommands(options) {
|
|
3516
|
-
const defs = createRawCsvgrepCommands(options);
|
|
3517
|
-
if (options?.limits === void 0) {
|
|
3518
|
-
for (let i = 0; i < defs.length; i++) builtInDirectContextExecutors.add(defs[i].execute);
|
|
3519
|
-
}
|
|
3520
|
-
return defs;
|
|
3521
|
-
}
|
|
3522
|
-
function csvgrepCommands(options = {}) {
|
|
3523
|
-
const commands = createCsvgrepCommands(options);
|
|
3524
|
-
const replace = options.replace ?? false;
|
|
3525
|
-
return {
|
|
3526
|
-
name: "csvgrep",
|
|
3527
|
-
setup(host) {
|
|
3528
|
-
for (const command of commands) host.commands.register(command, { replace });
|
|
3529
|
-
}
|
|
3530
|
-
};
|
|
3531
|
-
}
|
|
3532
|
-
var _syncAbortSignal2;
|
|
3533
|
-
var syncAbortSignal2 = () => _syncAbortSignal2 ??= new AbortController().signal;
|
|
3534
|
-
function evalSyncCsvgrep(inBytes, opArgs, readFileSync) {
|
|
3535
|
-
if (inBytes !== void 0 && inBytes.byteLength > 16384) return void 0;
|
|
3536
|
-
const budget = new CsvBudget3({}, syncAbortSignal2());
|
|
3537
|
-
try {
|
|
3538
|
-
const options = parseCsvgrepArguments(opArgs, budget);
|
|
3539
|
-
if (!options.names) {
|
|
3540
|
-
if (!options.columns) return void 0;
|
|
3541
|
-
const modes = [options.match !== void 0, options.regex !== void 0, options.file !== void 0].filter(Boolean).length;
|
|
3542
|
-
if (modes !== 1) return void 0;
|
|
3543
|
-
}
|
|
3544
|
-
if (options.names && options.headerless) return void 0;
|
|
3545
|
-
let fileMatchSet = /* @__PURE__ */ new Set();
|
|
3546
|
-
if (options.file !== void 0) {
|
|
3547
|
-
if (!readFileSync) return void 0;
|
|
3548
|
-
const patBytes = readFileSync(options.file);
|
|
3549
|
-
if (!patBytes || patBytes.byteLength > 16384) return void 0;
|
|
3550
|
-
const patText = new TextDecoder("utf-8", { fatal: false }).decode(patBytes);
|
|
3551
|
-
fileMatchSet = new Set(patText.split(/\r?\n/).filter((l) => l.length > 0));
|
|
3552
|
-
}
|
|
3553
|
-
let sourceBytes = inBytes;
|
|
3554
|
-
if (options.filePath !== void 0 && options.filePath !== "-") {
|
|
3555
|
-
if (!readFileSync) return void 0;
|
|
3556
|
-
const fileBytes = readFileSync(options.filePath);
|
|
3557
|
-
if (!fileBytes || fileBytes.byteLength > 16384) return void 0;
|
|
3558
|
-
sourceBytes = fileBytes;
|
|
3559
|
-
}
|
|
3560
|
-
if (sourceBytes === void 0) return void 0;
|
|
3561
|
-
const parser = new CsvParser3(options.dialect ?? {}, budget);
|
|
3562
|
-
const rows = [...parser.push(sourceBytes), ...parser.end()];
|
|
3563
|
-
const matcher = options.names ? void 0 : createMatcher(options, fileMatchSet, budget);
|
|
3564
|
-
let headers;
|
|
3565
|
-
let columns = [];
|
|
3566
|
-
let out = "";
|
|
3567
|
-
for (const row of rows) {
|
|
3568
|
-
if (headers === void 0) {
|
|
3569
|
-
headers = options.headerless ? generatedHeaders3(row.cells.length + (options.lineNumbers ? 1 : 0), budget) : row.cells;
|
|
3570
|
-
if (options.lineNumbers && !options.headerless) {
|
|
3571
|
-
headers = ["line_numbers", ...headers];
|
|
3572
|
-
}
|
|
3573
|
-
if (options.names) {
|
|
3574
|
-
for (let i = 0; i < headers.length; i++) {
|
|
3575
|
-
out += `${String(i + (options.zero ? 0 : 1)).padStart(3)}: ${headers[i]}
|
|
3576
|
-
`;
|
|
3577
|
-
}
|
|
3578
|
-
return out;
|
|
3579
|
-
}
|
|
3580
|
-
columns = selectColumns(options.columns, headers, options.zero ?? false, budget, void 0, options.lineNumbers ? 1 : 0);
|
|
3581
|
-
out += serializeRow3(headers, budget);
|
|
3582
|
-
if (!options.headerless) continue;
|
|
3583
|
-
}
|
|
3584
|
-
const cells = options.lineNumbers ? [String(row.line - (options.headerless ? 0 : 1)), ...row.cells] : row.cells;
|
|
3585
|
-
if (matchesRow(cells, columns, matcher, options.any ?? false, options.invert ?? false, budget)) {
|
|
3586
|
-
out += serializeRow3(cells, budget);
|
|
3587
|
-
}
|
|
3588
|
-
}
|
|
3589
|
-
if (headers === void 0) {
|
|
3590
|
-
if (options.names) return void 0;
|
|
3591
|
-
out += serializeRow3([], budget);
|
|
3592
|
-
}
|
|
3593
|
-
return out;
|
|
3594
|
-
} catch {
|
|
3595
|
-
return void 0;
|
|
3596
|
-
} finally {
|
|
3597
|
-
budget.dispose();
|
|
3598
|
-
}
|
|
3599
|
-
}
|
|
3600
|
-
|
|
3601
|
-
// packages/safe-bash/src/commands/htmlq/index.ts
|
|
3602
|
-
init_platform();
|
|
3603
|
-
import {
|
|
3604
|
-
HtmlBudget,
|
|
3605
|
-
HtmlError,
|
|
3606
|
-
detachHtmlNode,
|
|
3607
|
-
getInternalHtmlNode,
|
|
3608
|
-
htmlText,
|
|
3609
|
-
htmlq,
|
|
3610
|
-
htmlqBaseline,
|
|
3611
|
-
htmlqBytes,
|
|
3612
|
-
inclusiveHtmlDescendants,
|
|
3613
|
-
invocationOptions,
|
|
3614
|
-
parseHtml,
|
|
3615
|
-
parseHtmlSync,
|
|
3616
|
-
parseHtmlqArguments,
|
|
3617
|
-
replaceHtmlAttribute,
|
|
3618
|
-
rustWhitespaceOnly,
|
|
3619
|
-
selectHtml,
|
|
3620
|
-
serializeHtml,
|
|
3621
|
-
serializeHtmlBytes
|
|
3622
|
-
} from "../../safe-bash-command-htmlq/index.js";
|
|
3623
|
-
import { createHtmlqCommand, createHtmlqCommands, htmlqCommand, htmlqCommands } from "../../safe-bash-command-htmlq/index.js";
|
|
3624
|
-
var _syncAbortSignal3;
|
|
3625
|
-
var syncAbortSignal3 = () => _syncAbortSignal3 ??= new AbortController().signal;
|
|
3626
|
-
var syncHtmlDecoder = new TextDecoder("utf-8", { fatal: false, ignoreBOM: true });
|
|
3627
|
-
var syncHtmlEncoder = new TextEncoder();
|
|
3628
|
-
var syncHtmlLimits = Object.freeze({
|
|
3629
|
-
inputBytes: Infinity,
|
|
3630
|
-
decodedBytes: Infinity,
|
|
3631
|
-
retainedBytes: Infinity,
|
|
3632
|
-
nodes: Infinity,
|
|
3633
|
-
attributes: Infinity,
|
|
3634
|
-
depth: Infinity,
|
|
3635
|
-
tokenBytes: Infinity,
|
|
3636
|
-
work: Infinity,
|
|
3637
|
-
outputBytes: Infinity
|
|
3638
|
-
});
|
|
3639
|
-
function evalSyncHtmlq(inBytes, opArgs, readFileSync, writeFileSync) {
|
|
3640
|
-
if (inBytes && inBytes.byteLength > 16384) return void 0;
|
|
3641
|
-
try {
|
|
3642
|
-
const invocation = invocationOptions({ signal: syncAbortSignal3(), limits: syncHtmlLimits });
|
|
3643
|
-
const args = parseHtmlqArguments(opArgs, invocation);
|
|
3644
|
-
if (args.help || args.version) return void 0;
|
|
3645
|
-
let srcBytes = inBytes;
|
|
3646
|
-
if (args.filename !== "-") {
|
|
3647
|
-
if (!readFileSync) return void 0;
|
|
3648
|
-
const fBytes = readFileSync(args.filename);
|
|
3649
|
-
if (!fBytes || fBytes.byteLength > 16384) return void 0;
|
|
3650
|
-
srcBytes = fBytes;
|
|
3651
|
-
}
|
|
3652
|
-
if (!srcBytes) return void 0;
|
|
3653
|
-
const budget = new HtmlBudget(invocation);
|
|
3654
|
-
const original = syncHtmlDecoder.decode(srcBytes);
|
|
3655
|
-
const document = parseHtmlSync(original, invocation, budget);
|
|
3656
|
-
let base;
|
|
3657
|
-
if (args.base) {
|
|
3658
|
-
try {
|
|
3659
|
-
base = new URL(args.base);
|
|
3660
|
-
} catch {
|
|
3661
|
-
base = void 0;
|
|
3662
|
-
}
|
|
3663
|
-
}
|
|
3664
|
-
if (args.detectBase) {
|
|
3665
|
-
const first = selectHtml(document, "base", invocation).next().value;
|
|
3666
|
-
const href = first?.attributes.find((a) => a.name === "href")?.value ?? "";
|
|
3667
|
-
if (href) {
|
|
3668
|
-
try {
|
|
3669
|
-
base = new URL(href);
|
|
3670
|
-
} catch {
|
|
3671
|
-
}
|
|
3672
|
-
}
|
|
3673
|
-
}
|
|
3674
|
-
const selected = selectHtml(document, args.selector, invocation);
|
|
3675
|
-
let removal = "";
|
|
3676
|
-
if (args.removeNodes.length) {
|
|
3677
|
-
removal = args.removeNodes.join(",");
|
|
3678
|
-
try {
|
|
3679
|
-
selectHtml(document, removal, invocation);
|
|
3680
|
-
} catch (error) {
|
|
3681
|
-
if (!(error instanceof HtmlError) || error.code !== "E_SELECTOR") throw error;
|
|
3682
|
-
removal = "";
|
|
3683
|
-
}
|
|
3684
|
-
}
|
|
3685
|
-
let out = "";
|
|
3686
|
-
let selectedIndex = 0;
|
|
3687
|
-
for (const node of selected) {
|
|
3688
|
-
const isFirstNode = selectedIndex++ === 0;
|
|
3689
|
-
if (removal) {
|
|
3690
|
-
const first = selectHtml(node, removal, invocation).next().value;
|
|
3691
|
-
if (first) detachHtmlNode(first, invocation);
|
|
3692
|
-
}
|
|
3693
|
-
if (base && node.namespace === "html" && ["a", "area", "link"].includes(node.name)) {
|
|
3694
|
-
const href = node.attributes.find((a) => a.namespace === "none" && a.name === "href")?.value;
|
|
3695
|
-
if (href !== void 0) {
|
|
3696
|
-
let value;
|
|
3697
|
-
if (href.startsWith("////")) {
|
|
3698
|
-
let i = 0;
|
|
3699
|
-
while (href[i] === "/") i++;
|
|
3700
|
-
value = href.slice(i);
|
|
3701
|
-
} else {
|
|
3702
|
-
try {
|
|
3703
|
-
value = new URL(href, base).href;
|
|
3704
|
-
} catch {
|
|
3705
|
-
value = base.href;
|
|
3706
|
-
}
|
|
3707
|
-
}
|
|
3708
|
-
replaceHtmlAttribute(node, "href", value, invocation);
|
|
3709
|
-
}
|
|
3710
|
-
}
|
|
3711
|
-
if (args.attributes.length) {
|
|
3712
|
-
for (const name2 of args.attributes) {
|
|
3713
|
-
const attribute = node.attributes.find((a) => a.namespace === "none" && a.name === name2);
|
|
3714
|
-
if (attribute) out += attribute.value + "\n";
|
|
3715
|
-
}
|
|
3716
|
-
} else if (args.text) {
|
|
3717
|
-
const internal = !args.ignoreWhitespace && !isFirstNode ? getInternalHtmlNode(node) : void 0;
|
|
3718
|
-
if (internal && internal.children.length === 1 && internal.children[0].kind === "text" && internal.children[0].children.length === 0) {
|
|
3719
|
-
out += internal.children[0].data + "\n";
|
|
3720
|
-
} else {
|
|
3721
|
-
for (const descendant of inclusiveHtmlDescendants(node, invocation)) {
|
|
3722
|
-
if (descendant.kind !== "text") continue;
|
|
3723
|
-
if (args.ignoreWhitespace && rustWhitespaceOnly(descendant.data)) continue;
|
|
3724
|
-
out += descendant.data;
|
|
3725
|
-
if (args.ignoreWhitespace) out += "\n";
|
|
3726
|
-
}
|
|
3727
|
-
out += "\n";
|
|
3728
|
-
}
|
|
3729
|
-
} else {
|
|
3730
|
-
out += serializeHtml(node, invocation, args.pretty ? "pretty" : "normalized") + "\n";
|
|
3731
|
-
}
|
|
3732
|
-
}
|
|
3733
|
-
if (args.output !== "-") {
|
|
3734
|
-
if (!writeFileSync || !writeFileSync(args.output, syncHtmlEncoder.encode(out))) return void 0;
|
|
3735
|
-
return "";
|
|
3736
|
-
}
|
|
3737
|
-
return out;
|
|
3738
|
-
} catch {
|
|
3739
|
-
return void 0;
|
|
3740
|
-
}
|
|
3741
|
-
}
|
|
3742
|
-
|
|
3743
|
-
// packages/safe-bash/src/commands/unrtf/index.ts
|
|
3744
|
-
init_platform();
|
|
3745
|
-
import {
|
|
3746
|
-
renderRtfSync,
|
|
3747
|
-
createUnrtfCommand as createRawUnrtfCommand,
|
|
3748
|
-
createUnrtfCommands as createRawUnrtfCommands
|
|
3749
|
-
} from "../../safe-bash-command-unrtf/index.js";
|
|
3750
|
-
import { UnrtfError, charsetCodePages, codecLabels, extractRtf, renderRtf, renderRtfSync as renderRtfSync2, tokenizeRtf, unrtf, unrtfBaseline, unrtfCommand } from "../../safe-bash-command-unrtf/index.js";
|
|
3751
|
-
function createUnrtfCommand(options = {}) {
|
|
3752
|
-
return registerDefaultExecutor(createRawUnrtfCommand(options), options);
|
|
3753
|
-
}
|
|
3754
|
-
function createUnrtfCommands(options = {}) {
|
|
3755
|
-
return registerDefaultExecutors(createRawUnrtfCommands(options), options);
|
|
3756
|
-
}
|
|
3757
|
-
function unrtfCommands(options = {}) {
|
|
3758
|
-
const commands = createUnrtfCommands(options);
|
|
3759
|
-
const replace = options.replace ?? false;
|
|
3760
|
-
return {
|
|
3761
|
-
name: "unrtf",
|
|
3762
|
-
setup(host) {
|
|
3763
|
-
if (!replace) {
|
|
3764
|
-
for (const command of commands) {
|
|
3765
|
-
if (host.commands.has(command.name)) throw new Error(`Command already registered: ${command.name}`);
|
|
3766
|
-
}
|
|
3767
|
-
}
|
|
3768
|
-
for (const command of commands) host.commands.register(command, { replace });
|
|
3769
|
-
}
|
|
3770
|
-
};
|
|
3771
|
-
}
|
|
3772
|
-
var _syncUnrtfSignal;
|
|
3773
|
-
var syncUnrtfSignal = () => _syncUnrtfSignal ??= new AbortController().signal;
|
|
3774
|
-
var syncUnrtfDecoder = new TextDecoder("utf-8", { fatal: false });
|
|
3775
|
-
var unrtfCache = /* @__PURE__ */ new Map();
|
|
3776
|
-
function evalSyncUnrtf(inBytes, opArgs, readFileSync) {
|
|
3777
|
-
let format = "html";
|
|
3778
|
-
let profile;
|
|
3779
|
-
let quiet;
|
|
3780
|
-
let noremap;
|
|
3781
|
-
let file;
|
|
3782
|
-
let literal = false;
|
|
3783
|
-
for (let i = 0; i < opArgs.length; i++) {
|
|
3784
|
-
const arg = opArgs[i];
|
|
3785
|
-
if (literal) {
|
|
3786
|
-
if (file !== void 0) return void 0;
|
|
3787
|
-
file = arg;
|
|
3788
|
-
} else if (arg === "--") literal = true;
|
|
3789
|
-
else if (arg === "--text") format = "text";
|
|
3790
|
-
else if (arg === "--html") format = "html";
|
|
3791
|
-
else if (arg === "--latex") format = "latex";
|
|
3792
|
-
else if (arg.startsWith("--profile=")) profile = arg.slice("--profile=".length);
|
|
3793
|
-
else if (arg === "--quiet") quiet = true;
|
|
3794
|
-
else if (arg === "--noremap") noremap = true;
|
|
3795
|
-
else if (arg === "--nopict" || arg === "-n") continue;
|
|
3796
|
-
else if (arg.startsWith("-")) return void 0;
|
|
3797
|
-
else {
|
|
3798
|
-
if (file !== void 0) return void 0;
|
|
3799
|
-
file = arg;
|
|
3800
|
-
}
|
|
3801
|
-
}
|
|
3802
|
-
let srcBytes = inBytes;
|
|
3803
|
-
if (file !== void 0) {
|
|
3804
|
-
if (!readFileSync || file.includes("\0")) return void 0;
|
|
3805
|
-
srcBytes = readFileSync(file) ?? readFileSync(file + ".rtf");
|
|
3806
|
-
}
|
|
3807
|
-
if (!srcBytes || srcBytes.byteLength === 0 || srcBytes.byteLength > 16384) return void 0;
|
|
3808
|
-
const cacheKey = `${format}|\0${profile ?? ""}|\0${quiet ? 1 : 0}|\0${noremap ? 1 : 0}|\0${syncUnrtfDecoder.decode(srcBytes)}`;
|
|
3809
|
-
const cached = unrtfCache.get(cacheKey);
|
|
3810
|
-
if (cached !== void 0) return cached;
|
|
3811
|
-
try {
|
|
3812
|
-
let out = renderRtfSync(srcBytes, {
|
|
3813
|
-
format,
|
|
3814
|
-
signal: syncUnrtfSignal(),
|
|
3815
|
-
...quiet === void 0 ? {} : { quiet },
|
|
3816
|
-
...noremap === void 0 ? {} : { noremap },
|
|
3817
|
-
...profile === void 0 ? {} : { profile }
|
|
3818
|
-
});
|
|
3819
|
-
if (out.endsWith("\n")) out = out.slice(0, -1);
|
|
3820
|
-
if (unrtfCache.size >= 8) unrtfCache.clear();
|
|
3821
|
-
unrtfCache.set(cacheKey, out);
|
|
3822
|
-
return out;
|
|
3823
|
-
} catch {
|
|
3824
|
-
return void 0;
|
|
3825
|
-
}
|
|
3826
|
-
}
|
|
3827
|
-
|
|
3828
|
-
// packages/safe-bash/src/commands/diff3/index.ts
|
|
3829
|
-
init_platform();
|
|
3830
|
-
import {
|
|
3831
|
-
compareDiff3,
|
|
3832
|
-
diff3DefaultLimits,
|
|
3833
|
-
parseDiff3Arguments,
|
|
3834
|
-
createDiff3Command as createRawDiff3Command,
|
|
3835
|
-
createDiff3Commands as createRawDiff3Commands
|
|
3836
|
-
} from "../../safe-bash-command-diff3/index.js";
|
|
3837
|
-
import { Diff3Error, analyzeDiff3, compareDiff3 as compareDiff32, createDiff3Engine, diff3, diff3Command, diff3DefaultLimits as diff3DefaultLimits2, parseDiff3Arguments as parseDiff3Arguments2, validateDiff3Invocation } from "../../safe-bash-command-diff3/index.js";
|
|
3838
|
-
function createDiff3Command(options = {}) {
|
|
3839
|
-
return registerDefaultExecutor(createRawDiff3Command(options), options);
|
|
3840
|
-
}
|
|
3841
|
-
function createDiff3Commands(options = {}) {
|
|
3842
|
-
return registerDefaultExecutors(createRawDiff3Commands(options), options);
|
|
3843
|
-
}
|
|
3844
|
-
function diff3Commands(options = {}) {
|
|
3845
|
-
const commands = createDiff3Commands(options);
|
|
3846
|
-
const replace = options.replace ?? false;
|
|
3847
|
-
return {
|
|
3848
|
-
name: "diff3-commands",
|
|
3849
|
-
setup(host) {
|
|
3850
|
-
if (!replace) {
|
|
3851
|
-
for (const command of commands) {
|
|
3852
|
-
if (host.commands.has(command.name)) throw new Error(`Command already registered: ${command.name}`);
|
|
3853
|
-
}
|
|
3854
|
-
}
|
|
3855
|
-
for (const command of commands) host.commands.register(command, { replace });
|
|
3856
|
-
}
|
|
3857
|
-
};
|
|
3858
|
-
}
|
|
3859
|
-
var _syncDiff3Signal;
|
|
3860
|
-
var syncDiff3Signal = () => _syncDiff3Signal ??= new AbortController().signal;
|
|
3861
|
-
var syncDiff3Decoder = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
|
|
3862
|
-
function evalSyncDiff3(inBytes, opArgs, readFileSync) {
|
|
3863
|
-
try {
|
|
3864
|
-
const options = parseDiff3Arguments([...opArgs], diff3DefaultLimits);
|
|
3865
|
-
if (options.information !== void 0 || options.files.length !== 3) return void 0;
|
|
3866
|
-
const inputs = [];
|
|
3867
|
-
let stdinUsed = false;
|
|
3868
|
-
for (const file of options.files) {
|
|
3869
|
-
let srcBytes;
|
|
3870
|
-
if (file === "-") {
|
|
3871
|
-
if (stdinUsed || !inBytes) return void 0;
|
|
3872
|
-
stdinUsed = true;
|
|
3873
|
-
srcBytes = inBytes;
|
|
3874
|
-
} else {
|
|
3875
|
-
if (!readFileSync) return void 0;
|
|
3876
|
-
srcBytes = readFileSync(file);
|
|
3877
|
-
}
|
|
3878
|
-
if (!srcBytes || srcBytes.byteLength > 16384) return void 0;
|
|
3879
|
-
inputs.push(srcBytes);
|
|
3880
|
-
}
|
|
3881
|
-
const rendered = compareDiff3(inputs, options, diff3DefaultLimits, syncDiff3Signal());
|
|
3882
|
-
if (rendered.exitCode !== 0 || rendered.stderr.byteLength !== 0) return void 0;
|
|
3883
|
-
let out = syncDiff3Decoder.decode(rendered.stdout);
|
|
3884
|
-
if (out.endsWith("\n")) out = out.slice(0, -1);
|
|
3885
|
-
return out;
|
|
3886
|
-
} catch {
|
|
3887
|
-
return void 0;
|
|
3888
|
-
}
|
|
3889
|
-
}
|
|
3890
|
-
|
|
3891
3587
|
// packages/safe-bash/src/commands/search/index.ts
|
|
3892
3588
|
init_platform();
|
|
3893
3589
|
|
|
@@ -3899,7 +3595,7 @@ import { createRgCommand } from "../../safe-bash-command-rg/index.js";
|
|
|
3899
3595
|
import { evalSyncRg } from "../../safe-bash-command-rg/index.js";
|
|
3900
3596
|
function createSearchCommands(options = {}) {
|
|
3901
3597
|
const definitions = [createRgCommand(options)];
|
|
3902
|
-
for (let i = 0; i < definitions.length; i++)
|
|
3598
|
+
for (let i = 0; i < definitions.length; i++) builtInDirectContextExecutors2.add(definitions[i].execute);
|
|
3903
3599
|
return definitions;
|
|
3904
3600
|
}
|
|
3905
3601
|
function searchCommands(options = {}) {
|
|
@@ -3917,6 +3613,7 @@ function searchCommands(options = {}) {
|
|
|
3917
3613
|
|
|
3918
3614
|
// packages/safe-bash/src/shell/shell.ts
|
|
3919
3615
|
init_platform();
|
|
3616
|
+
import { utf8ByteLength } from "../../safe-bash-byte-engine/index.js";
|
|
3920
3617
|
|
|
3921
3618
|
// packages/safe-bash/src/commands/text-programs/awk-reader.ts
|
|
3922
3619
|
init_platform();
|
|
@@ -6472,7 +6169,7 @@ var ValueStore = class {
|
|
|
6472
6169
|
return this._values?.get(name2)?.value ?? this._strings?.get(name2) ?? text3;
|
|
6473
6170
|
}
|
|
6474
6171
|
publishString(name2, value, rawVariables) {
|
|
6475
|
-
if (this.arena.hasInfiniteBytes) {
|
|
6172
|
+
if (this.arena.hasInfiniteBytes && this.arena.maximumSlots === Infinity) {
|
|
6476
6173
|
this.arena.assertOpen();
|
|
6477
6174
|
rawVariables[name2] = value;
|
|
6478
6175
|
this.invalidate(name2);
|
|
@@ -7547,7 +7244,7 @@ function observeDescriptor(source, scope, budget, signal) {
|
|
|
7547
7244
|
}
|
|
7548
7245
|
|
|
7549
7246
|
// packages/safe-bash/src/shell/runtime.ts
|
|
7550
|
-
import { MemoryFileSystem
|
|
7247
|
+
import { MemoryFileSystem, isCleanAbsolutePath, retargetScopedFileSystem, scopeFileSystem, tryGetMemoryDirectoryEntryNamesSync, tryMkdirMemorySync, tryOpenMemoryRedirectHandleSync, tryResolveMemoryDevicePath as tryResolveMemoryDevicePath2, tryRmRfMemorySync, tryWriteMemoryFileInDirSync, tryWriteMemoryFileSync } from "@poe-platform/safe-fs/core";
|
|
7551
7248
|
|
|
7552
7249
|
// packages/safe-bash/src/shell/brace-expansion.ts
|
|
7553
7250
|
init_platform();
|
|
@@ -7957,9 +7654,13 @@ async function* expandBraces(word, budget, signal) {
|
|
|
7957
7654
|
}
|
|
7958
7655
|
}
|
|
7959
7656
|
|
|
7657
|
+
// packages/safe-bash/src/shell/runtime.ts
|
|
7658
|
+
import { createAliasCommand } from "../../safe-bash-command-alias/index.js";
|
|
7659
|
+
import { createUnaliasCommand } from "../../safe-bash-command-unalias/index.js";
|
|
7660
|
+
|
|
7960
7661
|
// packages/safe-bash/src/shell/tilde-expansion.ts
|
|
7961
7662
|
init_platform();
|
|
7962
|
-
function expandTildes(parts, variables, budget, assignmentStart) {
|
|
7663
|
+
function expandTildes(parts, variables, budget, assignmentStart, colonEndsInitialTilde = false) {
|
|
7963
7664
|
const result = [];
|
|
7964
7665
|
for (let index = 0; index < parts.length; index++) {
|
|
7965
7666
|
const part = parts[index];
|
|
@@ -7974,7 +7675,7 @@ function expandTildes(parts, variables, budget, assignmentStart) {
|
|
|
7974
7675
|
const initial = index === 0 && offset === (assignmentStart ?? 0);
|
|
7975
7676
|
if (!initial && !(assignmentStart !== void 0 && offset > 0 && part.value[offset - 1] === ":")) continue;
|
|
7976
7677
|
let end = offset + 1;
|
|
7977
|
-
while (end < part.value.length && part.value[end] !== "/" && !(assignmentStart !== void 0 && part.value[end] === ":")) {
|
|
7678
|
+
while (end < part.value.length && part.value[end] !== "/" && !((assignmentStart !== void 0 || colonEndsInitialTilde && initial) && part.value[end] === ":")) {
|
|
7978
7679
|
if (end % 1024 === 0) budget.cpuCheckpoint();
|
|
7979
7680
|
end++;
|
|
7980
7681
|
}
|
|
@@ -11968,7 +11669,7 @@ function createSession(budget, scope) {
|
|
|
11968
11669
|
budget,
|
|
11969
11670
|
budget.limits.maxExpansionBytes,
|
|
11970
11671
|
budget.limits.maxExpansionFields,
|
|
11971
|
-
ArrayLedger.createInternal(budget.limits.maxCommands ??
|
|
11672
|
+
ArrayLedger.createInternal(budget.limits.maxCommands ?? Infinity),
|
|
11972
11673
|
scope
|
|
11973
11674
|
);
|
|
11974
11675
|
scope.setArraySession(session);
|
|
@@ -13385,7 +13086,7 @@ async function umaskBuiltin(context, state) {
|
|
|
13385
13086
|
}
|
|
13386
13087
|
|
|
13387
13088
|
// packages/safe-bash/src/shell/runtime.ts
|
|
13388
|
-
import { abortManagedController as abortManagedController2,
|
|
13089
|
+
import { abortManagedController as abortManagedController2, combineManagedSignals as combineManagedSignals2, releaseCombinedSignal, createManagedControlController as createManagedControlController2, getRuntimeBackingFileSystem as getRuntimeBackingFileSystem2, interruptible as interruptible2, isSyncResolved as isSyncResolved5, registerRuntimeBackingFileSystem, toNativeAbortSignal } from "../../safe-bash-contracts/runtime-control.js";
|
|
13389
13090
|
var sharedCaptureDecoder = new TextDecoder("utf-8", { ignoreBOM: true });
|
|
13390
13091
|
var cachedCaptureAsciiBytes = new Uint8Array(4096);
|
|
13391
13092
|
var cachedCaptureAsciiLen = 0;
|
|
@@ -13503,13 +13204,16 @@ var shellBuiltinNames = /* @__PURE__ */ new Set([
|
|
|
13503
13204
|
".",
|
|
13504
13205
|
"source",
|
|
13505
13206
|
"eval",
|
|
13207
|
+
"exec",
|
|
13506
13208
|
"getopts",
|
|
13507
13209
|
"let",
|
|
13508
13210
|
"pushd",
|
|
13509
13211
|
"dirs",
|
|
13510
13212
|
"popd",
|
|
13511
13213
|
"shopt",
|
|
13512
|
-
"hash"
|
|
13214
|
+
"hash",
|
|
13215
|
+
"alias",
|
|
13216
|
+
"unalias"
|
|
13513
13217
|
]);
|
|
13514
13218
|
var implementedBuiltins = new Set([...shellBuiltinNames].filter((name2) => !["echo", "printf", "test", "["].includes(name2)));
|
|
13515
13219
|
var extensionExitFailures = /* @__PURE__ */ new WeakMap();
|
|
@@ -13572,9 +13276,10 @@ function publishCommandSpelling(state, description) {
|
|
|
13572
13276
|
(monitor?.raw ?? state).variables.BASH_COMMAND = description;
|
|
13573
13277
|
}
|
|
13574
13278
|
function resolveLimits(...limits) {
|
|
13575
|
-
const
|
|
13279
|
+
const definedLimits = limits.map((layer) => Object.fromEntries(Object.entries(layer ?? {}).filter(([, value]) => value !== void 0)));
|
|
13280
|
+
const result = Object.assign({}, defaultLimits, ...definedLimits);
|
|
13576
13281
|
const commandLimits = resolveCommandLimits(...limits.map((value) => value?.commandLimits));
|
|
13577
|
-
for (const [key, value] of Object.entries(Object.assign({}, ...
|
|
13282
|
+
for (const [key, value] of Object.entries(Object.assign({}, ...definedLimits))) {
|
|
13578
13283
|
if (key === "commandLimits") continue;
|
|
13579
13284
|
if ((value !== Infinity || key === "pipeHighWaterMark") && (!Number.isSafeInteger(value) || value < (key === "pipeHighWaterMark" ? 1 : 0))) {
|
|
13580
13285
|
throw new RangeError(`${key} must be a ${key === "pipeHighWaterMark" ? "positive" : "nonnegative"} safe integer`);
|
|
@@ -13894,6 +13599,7 @@ var Budget2 = class {
|
|
|
13894
13599
|
return this._wallClockDeadline;
|
|
13895
13600
|
}
|
|
13896
13601
|
close() {
|
|
13602
|
+
if (this._hasExternalSignal) releaseCombinedSignal(this.signal);
|
|
13897
13603
|
const timer = this._wallClockTimer;
|
|
13898
13604
|
if (timer === void 0) return;
|
|
13899
13605
|
if (timer === true) {
|
|
@@ -14269,7 +13975,7 @@ var Capture = class {
|
|
|
14269
13975
|
}
|
|
14270
13976
|
if (same) return cachedCaptureAsciiStr;
|
|
14271
13977
|
}
|
|
14272
|
-
const decoded =
|
|
13978
|
+
const decoded = sharedCaptureDecoder.decode(buf.subarray(0, len));
|
|
14273
13979
|
if (len <= 4096) {
|
|
14274
13980
|
for (let i = 0; i < len; i++) cachedCaptureAsciiBytes[i] = buf[i];
|
|
14275
13981
|
cachedCaptureAsciiLen = len;
|
|
@@ -14307,6 +14013,16 @@ var invokedValues = /* @__PURE__ */ new WeakMap();
|
|
|
14307
14013
|
var functionDiagnostics = /* @__PURE__ */ new WeakMap();
|
|
14308
14014
|
var childIdentities = /* @__PURE__ */ new WeakMap();
|
|
14309
14015
|
var declarationArrays = /* @__PURE__ */ Symbol("declarationArrays");
|
|
14016
|
+
var execDescriptorFrames = /* @__PURE__ */ new WeakMap();
|
|
14017
|
+
async function closeExecDescriptors(state) {
|
|
14018
|
+
const raw = stateMonitor(state)?.raw ?? state;
|
|
14019
|
+
const frame = execDescriptorFrames.get(raw);
|
|
14020
|
+
if (!frame) return;
|
|
14021
|
+
execDescriptorFrames.delete(raw);
|
|
14022
|
+
const results = await Promise.allSettled([...frame.releases.values()].map((release) => release()));
|
|
14023
|
+
frame.releases.clear();
|
|
14024
|
+
throwCleanupFailures(results.filter((result) => result.status === "rejected").map((result) => result.reason));
|
|
14025
|
+
}
|
|
14310
14026
|
var DescriptorLifetime = class {
|
|
14311
14027
|
constructor(finalize) {
|
|
14312
14028
|
this.finalize = finalize;
|
|
@@ -14531,6 +14247,8 @@ var ExpansionFailure = class extends Error {
|
|
|
14531
14247
|
}
|
|
14532
14248
|
line;
|
|
14533
14249
|
};
|
|
14250
|
+
var FailglobFailure = class extends ExpansionFailure {
|
|
14251
|
+
};
|
|
14534
14252
|
var CommandFailure = class extends Error {
|
|
14535
14253
|
constructor(message2, status) {
|
|
14536
14254
|
super(message2);
|
|
@@ -14981,10 +14699,19 @@ function bindCommandIO(context, io, limits = {}) {
|
|
|
14981
14699
|
});
|
|
14982
14700
|
}
|
|
14983
14701
|
var FastShellCommandContext = class _FastShellCommandContext {
|
|
14984
|
-
|
|
14985
|
-
const
|
|
14702
|
+
get signal() {
|
|
14703
|
+
const self = this._self ?? this;
|
|
14704
|
+
return self._nativeSignal ??= toNativeAbortSignal(self._rawSignal);
|
|
14705
|
+
}
|
|
14706
|
+
set signal(signal) {
|
|
14707
|
+
const self = this._self ?? this;
|
|
14708
|
+
self._rawSignal = signal;
|
|
14709
|
+
self._nativeSignal = void 0;
|
|
14710
|
+
}
|
|
14711
|
+
constructor(runtime, state, io, scope, name2, args, argumentValues, env, signalIsScoped, definition) {
|
|
14712
|
+
const directContext = builtInDirectContextExecutors2.has(definition.execute) && !customRegisteredCommands.has(definition.execute) && (FAST_DIRECT_CONTEXT_COMMANDS.has(name2) || name2 === "find" && !args.includes("-exec") && !args.includes("-ok"));
|
|
14986
14713
|
if (!directContext) {
|
|
14987
|
-
const { [invocationScope]: ignoredScope, [valueScope]: ignoredAllocation, [declarationArrays]: ignoredArrays, argumentValues: ignoredArguments, ...publicIO } = io;
|
|
14714
|
+
const { [invocationScope]: ignoredScope, [valueScope]: ignoredAllocation, [declarationArrays]: ignoredArrays, argumentValues: ignoredArguments, signal: ignoredSignal, ...publicIO } = io;
|
|
14988
14715
|
Object.defineProperties(this, Object.getOwnPropertyDescriptors(publicIO));
|
|
14989
14716
|
}
|
|
14990
14717
|
this._self = this;
|
|
@@ -15003,14 +14730,20 @@ var FastShellCommandContext = class _FastShellCommandContext {
|
|
|
15003
14730
|
this._argumentValues = argumentValues;
|
|
15004
14731
|
this._env = env;
|
|
15005
14732
|
this.cwd = state.cwd;
|
|
15006
|
-
this.signal = runtime.
|
|
14733
|
+
this.signal = runtime.commandSignal;
|
|
15007
14734
|
this.onInternalError = runtime.budget.onInternalError;
|
|
15008
14735
|
this.argv0 = io.argv0;
|
|
15009
14736
|
this.capabilities = io.capabilities;
|
|
15010
14737
|
this.processSignals = io.processSignals;
|
|
15011
14738
|
this.diagnosticLine = io.diagnosticLine;
|
|
15012
14739
|
this.scriptName = io.scriptName;
|
|
15013
|
-
if (directContext)
|
|
14740
|
+
if (directContext) {
|
|
14741
|
+
Object.defineProperty(this, "signal", {
|
|
14742
|
+
...Object.getOwnPropertyDescriptor(_FastShellCommandContext.prototype, "signal"),
|
|
14743
|
+
enumerable: true
|
|
14744
|
+
});
|
|
14745
|
+
return;
|
|
14746
|
+
}
|
|
15014
14747
|
workerRuntimeContexts.set(this, {
|
|
15015
14748
|
budget: runtime.budget,
|
|
15016
14749
|
umask: state.umask ?? 18,
|
|
@@ -15051,7 +14784,7 @@ var FastShellCommandContext = class _FastShellCommandContext {
|
|
|
15051
14784
|
this.command = name2;
|
|
15052
14785
|
this.args = args;
|
|
15053
14786
|
this.cwd = state.cwd;
|
|
15054
|
-
this.signal =
|
|
14787
|
+
this.signal = signal;
|
|
15055
14788
|
this.onInternalError = runtime.budget.onInternalError;
|
|
15056
14789
|
this.argv0 = io.argv0;
|
|
15057
14790
|
this.capabilities = io.capabilities;
|
|
@@ -15195,7 +14928,6 @@ var FastShellCommandContext = class _FastShellCommandContext {
|
|
|
15195
14928
|
}
|
|
15196
14929
|
get fs() {
|
|
15197
14930
|
const self = this._self ?? this;
|
|
15198
|
-
self.signal = toNativeAbortSignal(self.signal);
|
|
15199
14931
|
if (!self._contextFs) {
|
|
15200
14932
|
self._contextFs = self._runtime.getContextFsForFast(self._state.umask ?? 18, self._getScopedSignal());
|
|
15201
14933
|
}
|
|
@@ -15281,7 +15013,7 @@ function isFastDirectCommand(name2, words) {
|
|
|
15281
15013
|
}
|
|
15282
15014
|
return true;
|
|
15283
15015
|
}
|
|
15284
|
-
var fastShellCommandAccessors = ["env", "fs", "shellPredicates", "inputBudget", "executionScope", "registerCleanup", "invoke", "argumentValues"].map((key) => [key, Object.getOwnPropertyDescriptor(FastShellCommandContext.prototype, key)]);
|
|
15016
|
+
var fastShellCommandAccessors = ["signal", "env", "fs", "shellPredicates", "inputBudget", "executionScope", "registerCleanup", "invoke", "argumentValues", "stdinInput", "stdoutFile"].map((key) => [key, Object.getOwnPropertyDescriptor(FastShellCommandContext.prototype, key)]);
|
|
15285
15017
|
function cloneRawState(raw, hasLocals) {
|
|
15286
15018
|
const variables = Object.assign(/* @__PURE__ */ Object.create(null), raw.variables);
|
|
15287
15019
|
const exported = raw.exported.size ? new Set(raw.exported) : /* @__PURE__ */ new Set();
|
|
@@ -15305,6 +15037,11 @@ function cloneRawState(raw, hasLocals) {
|
|
|
15305
15037
|
if (raw.variableAttributes) cloned.variableAttributes = new Map(raw.variableAttributes);
|
|
15306
15038
|
if (raw.getopts) cloned.getopts = cloneGetoptsBinding(raw);
|
|
15307
15039
|
if (raw.functionNames) cloned.functionNames = [...raw.functionNames];
|
|
15040
|
+
if (raw.aliases) cloned.aliases = new Map(raw.aliases);
|
|
15041
|
+
if (raw.loopDepth > 0 || raw._subshellInLoop) {
|
|
15042
|
+
cloned._subshellInLoop = true;
|
|
15043
|
+
}
|
|
15044
|
+
cloned.loopDepth = 0;
|
|
15308
15045
|
return cloned;
|
|
15309
15046
|
}
|
|
15310
15047
|
function tryCloneStateSync(state, scope, inheritLocals = true) {
|
|
@@ -16179,7 +15916,6 @@ function hasGlobOrEscape(text3, extglob = false) {
|
|
|
16179
15916
|
}
|
|
16180
15917
|
return false;
|
|
16181
15918
|
}
|
|
16182
|
-
var nextProcessSubstitutionId = 0;
|
|
16183
15919
|
var fastSubScratchArgs = [];
|
|
16184
15920
|
var defaultValueScopeReserve = ValueScope.prototype.reserve;
|
|
16185
15921
|
var defaultStringCodePointAt = String.prototype.codePointAt;
|
|
@@ -16393,14 +16129,12 @@ var PooledSyncPipeWriter = class {
|
|
|
16393
16129
|
signal;
|
|
16394
16130
|
target = EMPTY_BYTES;
|
|
16395
16131
|
used = 0;
|
|
16396
|
-
overflowed = false;
|
|
16397
16132
|
lineCountOnly = -1;
|
|
16398
16133
|
reset(budget, signal, target, lineCountOnly = -1) {
|
|
16399
16134
|
this.budget = budget;
|
|
16400
16135
|
this.signal = signal;
|
|
16401
16136
|
this.target = target;
|
|
16402
16137
|
this.used = 0;
|
|
16403
|
-
this.overflowed = false;
|
|
16404
16138
|
this.lineCountOnly = lineCountOnly;
|
|
16405
16139
|
}
|
|
16406
16140
|
writeLineCountSync(count, totalBytes) {
|
|
@@ -16408,27 +16142,31 @@ var PooledSyncPipeWriter = class {
|
|
|
16408
16142
|
if (totalBytes > 0) {
|
|
16409
16143
|
const budget = this.budget;
|
|
16410
16144
|
if (budget.bytes + totalBytes > budget.maxOutputBytesSmi && totalBytes > budget.limits.maxOutputBytes - budget.bytes) budget.fail("maxOutputBytes");
|
|
16411
|
-
if (this.used + totalBytes > this.target.byteLength) {
|
|
16412
|
-
this.overflowed = true;
|
|
16413
|
-
return false;
|
|
16414
|
-
}
|
|
16415
16145
|
this.used += totalBytes;
|
|
16416
16146
|
budget.bytes += totalBytes;
|
|
16417
16147
|
}
|
|
16418
16148
|
this.lineCountOnly = count;
|
|
16419
16149
|
return true;
|
|
16420
16150
|
}
|
|
16151
|
+
reserve(length) {
|
|
16152
|
+
const required = this.used + length;
|
|
16153
|
+
if (required <= this.target.byteLength) return;
|
|
16154
|
+
const capacity = Math.min(this.budget.limits.maxOutputBytes, Math.max(required, this.target.byteLength * 2));
|
|
16155
|
+
const target = new Uint8Array(capacity);
|
|
16156
|
+
target.set(this.target.subarray(0, this.used));
|
|
16157
|
+
this.target = target;
|
|
16158
|
+
}
|
|
16421
16159
|
writeSync(chunk) {
|
|
16422
16160
|
this.signal.throwIfAborted();
|
|
16423
16161
|
const len = chunk.byteLength;
|
|
16424
16162
|
if (len === 0) return true;
|
|
16425
16163
|
const budget = this.budget;
|
|
16426
16164
|
if (budget.bytes + len > budget.maxOutputBytesSmi && len > budget.limits.maxOutputBytes - budget.bytes) budget.fail("maxOutputBytes");
|
|
16427
|
-
|
|
16428
|
-
this.overflowed = true;
|
|
16429
|
-
return false;
|
|
16430
|
-
}
|
|
16165
|
+
this.reserve(len);
|
|
16431
16166
|
this.target.set(chunk, this.used);
|
|
16167
|
+
if (this.lineCountOnly >= 0) {
|
|
16168
|
+
for (const byte of chunk) if (byte === 10) this.lineCountOnly++;
|
|
16169
|
+
}
|
|
16432
16170
|
this.used += len;
|
|
16433
16171
|
budget.bytes += len;
|
|
16434
16172
|
return true;
|
|
@@ -16438,21 +16176,22 @@ var PooledSyncPipeWriter = class {
|
|
|
16438
16176
|
if (len === 0) return true;
|
|
16439
16177
|
const budget = this.budget;
|
|
16440
16178
|
if (budget.bytes + len > budget.maxOutputBytesSmi && len > budget.limits.maxOutputBytes - budget.bytes) budget.fail("maxOutputBytes");
|
|
16441
|
-
|
|
16442
|
-
this.overflowed = true;
|
|
16443
|
-
return false;
|
|
16444
|
-
}
|
|
16179
|
+
this.reserve(len);
|
|
16445
16180
|
const dst = this.target;
|
|
16446
16181
|
const base = this.used;
|
|
16447
|
-
for (let i = 0; i < len; i++)
|
|
16182
|
+
for (let i = 0; i < len; i++) {
|
|
16183
|
+
const byte = src[i];
|
|
16184
|
+
dst[base + i] = byte;
|
|
16185
|
+
if (this.lineCountOnly >= 0 && byte === 10) this.lineCountOnly++;
|
|
16186
|
+
}
|
|
16448
16187
|
this.used = base + len;
|
|
16449
16188
|
budget.bytes += len;
|
|
16450
16189
|
return true;
|
|
16451
16190
|
}
|
|
16452
16191
|
write(chunk) {
|
|
16453
16192
|
try {
|
|
16454
|
-
|
|
16455
|
-
return
|
|
16193
|
+
this.writeSync(chunk);
|
|
16194
|
+
return resolvedVoid4;
|
|
16456
16195
|
} catch (err) {
|
|
16457
16196
|
return Promise.reject(err);
|
|
16458
16197
|
}
|
|
@@ -16763,7 +16502,7 @@ function fastStringHexIdentity(str) {
|
|
|
16763
16502
|
return bytesToHex(fastSharedTextEncoder.encode(str));
|
|
16764
16503
|
}
|
|
16765
16504
|
var syncConditionalFileUnaryOps = /* @__PURE__ */ new Set(["-e", "-a", "-f", "-d", "-s", "-L", "-h", "-r", "-w", "-x"]);
|
|
16766
|
-
var memoryFilePredicateImplementation = Object.getOwnPropertyDescriptors(
|
|
16505
|
+
var memoryFilePredicateImplementation = Object.getOwnPropertyDescriptors(MemoryFileSystem.prototype);
|
|
16767
16506
|
var evalSingleUnitCache = /* @__PURE__ */ new Map();
|
|
16768
16507
|
function isDefaultShellSyntax(syntax) {
|
|
16769
16508
|
if (!syntax) return true;
|
|
@@ -16820,14 +16559,13 @@ var Runtime = class _Runtime {
|
|
|
16820
16559
|
this._canFastMemoryRedirect = void 0;
|
|
16821
16560
|
this.sourceFs = runtimeFileSystems.get(fs) ?? fs;
|
|
16822
16561
|
this.backingFs = getRuntimeBackingFileSystem2(this.sourceFs) ?? this.sourceFs;
|
|
16823
|
-
this._isMemoryBackingFs = Object.getPrototypeOf(this.backingFs) ===
|
|
16824
|
-
const method = Object.getOwnPropertyDescriptor(
|
|
16562
|
+
this._isMemoryBackingFs = Object.getPrototypeOf(this.backingFs) === MemoryFileSystem.prototype && Object.getOwnPropertyNames(this.backingFs).every((name2) => {
|
|
16563
|
+
const method = Object.getOwnPropertyDescriptor(MemoryFileSystem.prototype, name2)?.value;
|
|
16825
16564
|
return typeof method !== "function" || Object.getOwnPropertyDescriptor(this.backingFs, name2)?.value === method;
|
|
16826
|
-
}) && Object.getOwnPropertyNames(
|
|
16827
|
-
const method = Object.getOwnPropertyDescriptor(
|
|
16565
|
+
}) && Object.getOwnPropertyNames(MemoryFileSystem.prototype).every((name2) => {
|
|
16566
|
+
const method = Object.getOwnPropertyDescriptor(MemoryFileSystem.prototype, name2)?.value;
|
|
16828
16567
|
return typeof method !== "function" || Reflect.get(this.backingFs, name2) === method;
|
|
16829
16568
|
});
|
|
16830
|
-
if (this._isMemoryBackingFs) this.backingFs._activeRuntimeBudget = budget;
|
|
16831
16569
|
registerInternalYieldCheckpoint(signal, budget.yieldCheckpoint);
|
|
16832
16570
|
if (commandSignal !== signal) {
|
|
16833
16571
|
inheritYieldCheckpoint(signal, commandSignal);
|
|
@@ -16839,6 +16577,22 @@ var Runtime = class _Runtime {
|
|
|
16839
16577
|
}
|
|
16840
16578
|
}
|
|
16841
16579
|
reuseDefaultContextFs;
|
|
16580
|
+
persistentIO(state, io) {
|
|
16581
|
+
const frame = execDescriptorFrames.get(stateMonitor(state)?.raw ?? state);
|
|
16582
|
+
if (!frame || io.execFrame === frame && io.execVersion === frame.version) return io;
|
|
16583
|
+
const changed = new Map([...frame.descriptors].filter(([number2]) => io.execFrame !== frame || (frame.revisions.get(number2) ?? 0) > (io.execVersion ?? 0)));
|
|
16584
|
+
const descriptors = new Map(io.descriptors ?? [[0, { input: io.stdin }], [1, { output: io.stdout }], [2, { output: io.stderr }]]);
|
|
16585
|
+
for (const [number2, descriptor] of changed) descriptors.set(number2, descriptor);
|
|
16586
|
+
return {
|
|
16587
|
+
...io,
|
|
16588
|
+
descriptors,
|
|
16589
|
+
execFrame: frame,
|
|
16590
|
+
execVersion: frame.version,
|
|
16591
|
+
...changed.has(0) ? { stdin: descriptors.get(0)?.closed ? closedSource : descriptors.get(0)?.input ?? closedSource, stdinIsDefault: false } : {},
|
|
16592
|
+
...changed.has(1) ? { stdout: descriptors.get(1)?.closed ? closedSink : descriptors.get(1)?.output ?? closedSink } : {},
|
|
16593
|
+
...changed.has(2) ? { stderr: descriptors.get(2)?.closed ? closedSink : descriptors.get(2)?.output ?? closedSink } : {}
|
|
16594
|
+
};
|
|
16595
|
+
}
|
|
16842
16596
|
static clearStaticPools() {
|
|
16843
16597
|
clearRuntimePools();
|
|
16844
16598
|
}
|
|
@@ -16864,11 +16618,12 @@ var Runtime = class _Runtime {
|
|
|
16864
16618
|
const reusableEntry = reusableDefaultContextFsBySourceFs.get(this.sourceFs);
|
|
16865
16619
|
if (reusableEntry && reusableEntry.inUseBy === this) {
|
|
16866
16620
|
retargetScopedFileSystem(reusableEntry.scoped, noopFsCharge, NEVER_ABORTED_SIGNAL, noopFsCharge, 256);
|
|
16621
|
+
registerRuntimeBackingFileSystem(reusableEntry.scoped, this.backingFs);
|
|
16867
16622
|
reusableEntry.inUseBy = void 0;
|
|
16868
16623
|
}
|
|
16869
16624
|
}
|
|
16870
16625
|
if (this.backingFs) {
|
|
16871
|
-
const emptyFs = _sharedEmptyMemoryFs ??= new
|
|
16626
|
+
const emptyFs = _sharedEmptyMemoryFs ??= new MemoryFileSystem();
|
|
16872
16627
|
this.backingFs = emptyFs;
|
|
16873
16628
|
this.sourceFs = emptyFs;
|
|
16874
16629
|
this._rawFs = emptyFs;
|
|
@@ -16882,7 +16637,7 @@ var Runtime = class _Runtime {
|
|
|
16882
16637
|
if (!this._fs) {
|
|
16883
16638
|
this._fs = scopeFileSystem(this._rawFs, this.budget.chargeFs, this.signal, this.budget.cleanupChargeFs, { maxPathComponents: this.budget.limits.maxPathnameComponents });
|
|
16884
16639
|
runtimeFileSystems.set(this._fs, this.sourceFs);
|
|
16885
|
-
registerRuntimeBackingFileSystem(this._fs, this.backingFs);
|
|
16640
|
+
registerRuntimeBackingFileSystem(this._fs, this.backingFs, this.budget.chargeFs);
|
|
16886
16641
|
}
|
|
16887
16642
|
return this._fs;
|
|
16888
16643
|
}
|
|
@@ -16893,7 +16648,8 @@ var Runtime = class _Runtime {
|
|
|
16893
16648
|
if (this.reuseDefaultContextFs && sig === this.signal && umask === 18 && !this._contextFs && this._isMemoryBackingFs) {
|
|
16894
16649
|
const entry = reusableDefaultContextFsBySourceFs.get(this.sourceFs);
|
|
16895
16650
|
if (entry && (entry.inUseBy === void 0 || entry.inUseBy === this)) {
|
|
16896
|
-
if (retargetScopedFileSystem(entry.scoped, this.budget.chargeFs, sig, this.budget.cleanupChargeFs, this.budget.limits.maxPathnameComponents)) {
|
|
16651
|
+
if (retargetScopedFileSystem(entry.scoped, this.budget.chargeFs, toNativeAbortSignal(sig), this.budget.cleanupChargeFs, this.budget.limits.maxPathnameComponents)) {
|
|
16652
|
+
registerRuntimeBackingFileSystem(entry.scoped, this.backingFs, this.budget.chargeFs);
|
|
16897
16653
|
entry.inUseBy = this;
|
|
16898
16654
|
this._contextFsMask = umask;
|
|
16899
16655
|
this._contextFsSignal = sig;
|
|
@@ -16902,9 +16658,9 @@ var Runtime = class _Runtime {
|
|
|
16902
16658
|
}
|
|
16903
16659
|
}
|
|
16904
16660
|
}
|
|
16905
|
-
const created = scopeFileSystem(creationFileSystem(this.sourceFs, umask), this.budget.chargeFs, sig, this.budget.cleanupChargeFs, { maxPathComponents: this.budget.limits.maxPathnameComponents });
|
|
16661
|
+
const created = scopeFileSystem(creationFileSystem(this.sourceFs, umask), this.budget.chargeFs, toNativeAbortSignal(sig), this.budget.cleanupChargeFs, { maxPathComponents: this.budget.limits.maxPathnameComponents });
|
|
16906
16662
|
runtimeFileSystems.set(created, this.sourceFs);
|
|
16907
|
-
registerRuntimeBackingFileSystem(created, this.backingFs);
|
|
16663
|
+
registerRuntimeBackingFileSystem(created, this.backingFs, this.budget.chargeFs);
|
|
16908
16664
|
this._contextFsMask = umask;
|
|
16909
16665
|
this._contextFsSignal = sig;
|
|
16910
16666
|
this._contextFs = created;
|
|
@@ -17943,6 +17699,8 @@ var Runtime = class _Runtime {
|
|
|
17943
17699
|
}
|
|
17944
17700
|
variable(state, name2) {
|
|
17945
17701
|
name2 = this.referenceName(state, name2);
|
|
17702
|
+
if (name2 === "$" || name2 === "BASHPID") return "1";
|
|
17703
|
+
if (name2 === "!") return "";
|
|
17946
17704
|
if (name2 === "RANDOM" || name2 === "SECONDS") return readDynamicVariable(stateMonitor(state)?.raw ?? state, name2) ?? state.variables[name2];
|
|
17947
17705
|
const binding = arrayStore(state)?.get(name2);
|
|
17948
17706
|
if (binding) return binding.get(binding.associative ? binding.keys.get("30")?.index ?? -1 : 0);
|
|
@@ -19047,8 +18805,13 @@ var Runtime = class _Runtime {
|
|
|
19047
18805
|
}
|
|
19048
18806
|
const expandedEntries = [];
|
|
19049
18807
|
let elementFields;
|
|
18808
|
+
let attributedElement;
|
|
19050
18809
|
if (assignment.kind === "element") {
|
|
19051
18810
|
elementFields = await this.valueWord(assignment.value, state, io, false, false, false, false, void 0, false, false, 0);
|
|
18811
|
+
if (selectedIndex !== void 0 && state.variableAttributes?.get(name2)?.includes("i")) {
|
|
18812
|
+
const previous = assignment.append ? store.get(name2)?.getValue(selectedIndex) ?? (selectedIndex === 0 ? state.variables[name2] : void 0) ?? "" : void 0;
|
|
18813
|
+
attributedElement = await this.attributeValue(state, name2, concatShellValues(elementFields, io[valueScope]), io, "assignment", previous);
|
|
18814
|
+
}
|
|
19052
18815
|
} else for (const entry of assignment.entries) {
|
|
19053
18816
|
const original = compoundEntryWords.get(entry);
|
|
19054
18817
|
let expandedEntry = false;
|
|
@@ -19068,6 +18831,36 @@ var Runtime = class _Runtime {
|
|
|
19068
18831
|
}
|
|
19069
18832
|
current = store.get(name2);
|
|
19070
18833
|
initialMaximum = current?.maximum ?? (state.variables[name2] === void 0 ? -1 : 0);
|
|
18834
|
+
if (assignment.kind === "compound" && expandedEntries.length > 0 && (state.variableAttributes?.get(name2)?.includes("i") || !isAssociative && expandedEntries.some(({ entry }) => entry.index && numericIndex(entry.index) === void 0))) {
|
|
18835
|
+
let cursor = assignment.append ? initialMaximum + 1 : 0;
|
|
18836
|
+
if (!assignment.append) await this.arrayAssignment({ ...assignment, entries: [] }, state, io, void 0, origin, associative, true);
|
|
18837
|
+
for (const { entry, fields } of expandedEntries) {
|
|
18838
|
+
const values = entry.index ? [concatShellValues(fields, io[valueScope])] : fields;
|
|
18839
|
+
for (const value of values) {
|
|
18840
|
+
const index = entry.index && !isAssociative ? await this.arrayIndex(store.get(name2), entry.index, state, io, operation2, true) : cursor;
|
|
18841
|
+
const part = { kind: "text", value: shellValueText(value), quoted: true };
|
|
18842
|
+
if (typeof value !== "string") invokedValues.set(part, value);
|
|
18843
|
+
await this.arrayAssignment(
|
|
18844
|
+
{
|
|
18845
|
+
kind: "element",
|
|
18846
|
+
name: name2,
|
|
18847
|
+
append: entry.append ?? false,
|
|
18848
|
+
index: isAssociative ? entry.index : { decimal: String(index) },
|
|
18849
|
+
value: { offset: entry.value.offset, parts: [part] }
|
|
18850
|
+
},
|
|
18851
|
+
state,
|
|
18852
|
+
io,
|
|
18853
|
+
void 0,
|
|
18854
|
+
origin,
|
|
18855
|
+
associative,
|
|
18856
|
+
true
|
|
18857
|
+
);
|
|
18858
|
+
cursor = index + 1;
|
|
18859
|
+
}
|
|
18860
|
+
}
|
|
18861
|
+
if (declaration) await this.arrayAssignment({ ...assignment, append: true, entries: [] }, state, io, declaration, origin, associative, true);
|
|
18862
|
+
return;
|
|
18863
|
+
}
|
|
19071
18864
|
this.assertArrayWritable(state, name2, origin);
|
|
19072
18865
|
const watch = await store.watch(name2, operation2, this.signal);
|
|
19073
18866
|
const supersede = await stateMonitor(state).prepareTypedPublication(name2, operation2, this.signal);
|
|
@@ -19101,7 +18894,8 @@ var Runtime = class _Runtime {
|
|
|
19101
18894
|
if (index > 2147483647) throw new ArrayFailure("index outside 0..2147483647");
|
|
19102
18895
|
const previous = append ? targetBinding.getValue(index) ?? "" : void 0;
|
|
19103
18896
|
if (append && !state.variableAttributes?.get(name2)?.includes("i")) value = await join([previous, value]);
|
|
19104
|
-
if (
|
|
18897
|
+
if (attributedElement !== void 0) value = attributedElement;
|
|
18898
|
+
else if (state.variableAttributes?.get(name2)) value = await this.attributeValue(state, name2, value, io, "assignment", previous);
|
|
19105
18899
|
else if (shellValueByteLength(value) > this.budget.limits.maxExpansionBytes) this.budget.fail("maxExpansionBytes");
|
|
19106
18900
|
const token = await valueToken(targetBinding.owner, value, this.signal);
|
|
19107
18901
|
if (canReviseInPlace) {
|
|
@@ -19244,7 +19038,11 @@ var Runtime = class _Runtime {
|
|
|
19244
19038
|
}
|
|
19245
19039
|
}
|
|
19246
19040
|
async run(script, state, io) {
|
|
19247
|
-
|
|
19041
|
+
try {
|
|
19042
|
+
return await this.finishShell(state, io, (await this.runUnit(script, state, io)).exitCode);
|
|
19043
|
+
} finally {
|
|
19044
|
+
await closeExecDescriptors(state);
|
|
19045
|
+
}
|
|
19248
19046
|
}
|
|
19249
19047
|
extensionContext(state, io, command = "", args = [], argumentValues = args) {
|
|
19250
19048
|
const frame = state.extensions;
|
|
@@ -20241,7 +20039,7 @@ var Runtime = class _Runtime {
|
|
|
20241
20039
|
if (state.isolated) throw error;
|
|
20242
20040
|
throw error.reason;
|
|
20243
20041
|
}
|
|
20244
|
-
if (error instanceof Flow && error.kind === "exit") {
|
|
20042
|
+
if (error instanceof Flow && (error.kind === "exit" || error.kind === "return" || error.kind === "break" || error.kind === "continue")) {
|
|
20245
20043
|
if (this.tryFinishShellSync(state)) return { exitCode: error.status, terminated: true };
|
|
20246
20044
|
return this.finishShell(monitor.proxy, io, error.status).then((exitCode) => ({ exitCode, terminated: true }));
|
|
20247
20045
|
}
|
|
@@ -20263,7 +20061,7 @@ var Runtime = class _Runtime {
|
|
|
20263
20061
|
if (state.isolated) throw error;
|
|
20264
20062
|
throw error.reason;
|
|
20265
20063
|
}
|
|
20266
|
-
if (error instanceof Flow && error.kind === "exit") return { exitCode: await this.finishShell(state, io, error.status), terminated: true };
|
|
20064
|
+
if (error instanceof Flow && (error.kind === "exit" || error.kind === "return" || error.kind === "break" || error.kind === "continue")) return { exitCode: await this.finishShell(state, io, error.status), terminated: true };
|
|
20267
20065
|
throw error;
|
|
20268
20066
|
}
|
|
20269
20067
|
}
|
|
@@ -20276,7 +20074,7 @@ var Runtime = class _Runtime {
|
|
|
20276
20074
|
if (state.isolated) throw error;
|
|
20277
20075
|
throw error.reason;
|
|
20278
20076
|
}
|
|
20279
|
-
if (error instanceof Flow && error.kind === "exit") return { exitCode: await this.finishShell(state, io, error.status), terminated: true };
|
|
20077
|
+
if (error instanceof Flow && (error.kind === "exit" || error.kind === "return" || error.kind === "break" || error.kind === "continue")) return { exitCode: await this.finishShell(state, io, error.status), terminated: true };
|
|
20280
20078
|
throw error;
|
|
20281
20079
|
}
|
|
20282
20080
|
}
|
|
@@ -20312,7 +20110,7 @@ var Runtime = class _Runtime {
|
|
|
20312
20110
|
if (cSingle !== void 0 && !customRegisteredRegistries.has(this.commands) && !hasShellFunction(rawState, cSingle.w0Plain) && !rawState.extensions?.builtins.has(cSingle.w0Plain) && command.words.length <= this.budget.maxExpansionFieldsSmi && (this.budget.commands + 1 <= this.budget.maxCommandsSmi || this.budget.commands + 1 <= this.budget.limits.maxCommands)) {
|
|
20313
20111
|
w0Plain = cSingle.w0Plain;
|
|
20314
20112
|
const extD = this.commands.get(w0Plain);
|
|
20315
|
-
if (!extD || !
|
|
20113
|
+
if (!extD || !builtInDirectContextExecutors2.has(extD.execute) || customRegisteredCommands.has(extD.execute)) return void 0;
|
|
20316
20114
|
externalDef = extD;
|
|
20317
20115
|
args = cSingle.args;
|
|
20318
20116
|
lastArg = cSingle.lastArg;
|
|
@@ -20330,7 +20128,7 @@ var Runtime = class _Runtime {
|
|
|
20330
20128
|
}
|
|
20331
20129
|
w0Plain = w0P;
|
|
20332
20130
|
const extD = this.commands.get(w0Plain);
|
|
20333
|
-
if (!extD || !
|
|
20131
|
+
if (!extD || !builtInDirectContextExecutors2.has(extD.execute) || customRegisteredCommands.has(extD.execute) || customRegisteredRegistries.has(this.commands) || command.words.length > this.budget.maxExpansionFieldsSmi || this.budget.commands + 1 > this.budget.maxCommandsSmi && this.budget.commands + 1 > this.budget.limits.maxCommands) {
|
|
20334
20132
|
return void 0;
|
|
20335
20133
|
}
|
|
20336
20134
|
externalDef = extD;
|
|
@@ -20354,7 +20152,9 @@ var Runtime = class _Runtime {
|
|
|
20354
20152
|
try {
|
|
20355
20153
|
for (let i = 1; i < command.words.length; i++) {
|
|
20356
20154
|
const w = command.words[i];
|
|
20357
|
-
if (w.plain
|
|
20155
|
+
if (w.plain !== void 0 ? w.plain.includes("{") || w.plain.startsWith("~") || hasGlobOrEscape(w.plain, true) : !(w.parts.length === 1 && w.parts[0].kind === "text" && w.parts[0].quoted === true && !w.parts[0].byteValue)) {
|
|
20156
|
+
allPlain = false;
|
|
20157
|
+
}
|
|
20358
20158
|
const v = this.fastValueWord(w, rawState, io, true, false, false, true, void 0, diagnosticLine);
|
|
20359
20159
|
if (typeof v !== "string") return void 0;
|
|
20360
20160
|
args[i - 1] = v;
|
|
@@ -20364,6 +20164,7 @@ var Runtime = class _Runtime {
|
|
|
20364
20164
|
return void 0;
|
|
20365
20165
|
}
|
|
20366
20166
|
if (allPlain) {
|
|
20167
|
+
Object.freeze(args);
|
|
20367
20168
|
command._cachedConstArgs = args;
|
|
20368
20169
|
if (command.redirects.length === 0 || command.redirects[0].target.plain !== void 0 && (command.redirects[0].operator === ">" || command.redirects[0].operator === ">>")) {
|
|
20369
20170
|
command._cachedFastSingle = {
|
|
@@ -20426,7 +20227,7 @@ var Runtime = class _Runtime {
|
|
|
20426
20227
|
context._scopedSignal = void 0;
|
|
20427
20228
|
}
|
|
20428
20229
|
} else {
|
|
20429
|
-
context = new FastShellCommandContext(this, rawState, io, scope, w0Plain, args, void 0, void 0, this._isMemoryBackingFs);
|
|
20230
|
+
context = new FastShellCommandContext(this, rawState, io, scope, w0Plain, args, void 0, void 0, this._isMemoryBackingFs, externalDef);
|
|
20430
20231
|
if (redirectSink) context.stdout = redirectSink;
|
|
20431
20232
|
}
|
|
20432
20233
|
if (redirectSink && io.descriptors) {
|
|
@@ -20443,7 +20244,7 @@ var Runtime = class _Runtime {
|
|
|
20443
20244
|
const cmd = pipeline.commands[i];
|
|
20444
20245
|
if (cmd.kind !== "simple" || !this.isPureExternalStageCommand(cmd, rawState) || cmd.words.length > this.budget.maxExpansionFieldsSmi) return void 0;
|
|
20445
20246
|
}
|
|
20446
|
-
return this.
|
|
20247
|
+
return this.tryExecuteSyncPurePipelineUnit(pipeline, state, rawState, monitor, io, ignored || pipeline.negate);
|
|
20447
20248
|
}
|
|
20448
20249
|
return void 0;
|
|
20449
20250
|
}
|
|
@@ -20489,15 +20290,26 @@ var Runtime = class _Runtime {
|
|
|
20489
20290
|
return finalStatus === 0 ? SYNC_UNIT_ZERO : SYNC_UNIT_ONE;
|
|
20490
20291
|
}
|
|
20491
20292
|
} catch (error) {
|
|
20492
|
-
return this.finishFastSingleExternalUnitAsync(void 0, error, true, redirectSink, diagnosticLine, negate, ignored, monitor, rawState, existing, elem0, store, state, io, scope, restEpoch);
|
|
20293
|
+
return this.finishFastSingleExternalUnitAsync(context, void 0, error, true, redirectSink, diagnosticLine, negate, ignored, monitor, rawState, existing, elem0, store, state, io, scope, restEpoch);
|
|
20493
20294
|
}
|
|
20494
|
-
return this.finishFastSingleExternalUnitAsync(raw, void 0, false, redirectSink, diagnosticLine, negate, ignored, monitor, rawState, existing, elem0, store, state, io, scope, restEpoch);
|
|
20295
|
+
return this.finishFastSingleExternalUnitAsync(context, raw, void 0, false, redirectSink, diagnosticLine, negate, ignored, monitor, rawState, existing, elem0, store, state, io, scope, restEpoch);
|
|
20495
20296
|
}
|
|
20496
|
-
async finishFastSingleExternalUnitAsync(raw, initialError, hasInitialError, redirectSink, diagnosticLine, negate, ignored, monitor, rawState, existing, elem0, store, state, io, scope, restEpoch) {
|
|
20297
|
+
async finishFastSingleExternalUnitAsync(context, raw, initialError, hasInitialError, redirectSink, diagnosticLine, negate, ignored, monitor, rawState, existing, elem0, store, state, io, scope, restEpoch) {
|
|
20497
20298
|
let rawStatus = 0;
|
|
20299
|
+
let commandSettled = hasInitialError;
|
|
20300
|
+
const pending = hasInitialError ? void 0 : Promise.resolve(raw).then(
|
|
20301
|
+
(result) => {
|
|
20302
|
+
commandSettled = true;
|
|
20303
|
+
return result;
|
|
20304
|
+
},
|
|
20305
|
+
(error) => {
|
|
20306
|
+
commandSettled = true;
|
|
20307
|
+
throw error;
|
|
20308
|
+
}
|
|
20309
|
+
);
|
|
20498
20310
|
try {
|
|
20499
20311
|
if (hasInitialError) throw initialError;
|
|
20500
|
-
const res = this.budget._hasExternalSignal ? await interruptible2(
|
|
20312
|
+
const res = this.budget._hasExternalSignal ? await interruptible2(pending, this.signal) : await pending;
|
|
20501
20313
|
this.signal.throwIfAborted();
|
|
20502
20314
|
if (redirectSink?.failedError !== void 0) throw redirectSink.failedError;
|
|
20503
20315
|
rawStatus = validateExitCode(res.exitCode);
|
|
@@ -20520,6 +20332,10 @@ var Runtime = class _Runtime {
|
|
|
20520
20332
|
this.budget.endPathLookupSuspension();
|
|
20521
20333
|
scope.leaveWork();
|
|
20522
20334
|
redirectSink?.handle.close();
|
|
20335
|
+
if (commandSettled) context.releaseDirectStage();
|
|
20336
|
+
else {
|
|
20337
|
+
void pending.then(() => context.releaseDirectStage(), () => context.releaseDirectStage());
|
|
20338
|
+
}
|
|
20523
20339
|
}
|
|
20524
20340
|
if (!existing) {
|
|
20525
20341
|
monitor.lazyPipeStatus = rawStatus === 0 ? singleStatusZero : rawStatus === 1 ? singleStatusOne : [rawStatus];
|
|
@@ -20538,9 +20354,6 @@ var Runtime = class _Runtime {
|
|
|
20538
20354
|
}
|
|
20539
20355
|
return finalStatus === 0 ? SYNC_UNIT_ZERO : finalStatus === 1 ? SYNC_UNIT_ONE : { exitCode: finalStatus, terminated: false };
|
|
20540
20356
|
}
|
|
20541
|
-
executeFastPurePipelineUnit(pipeline, state, rawState, monitor, io, ignored) {
|
|
20542
|
-
return this.tryExecuteSyncPurePipelineUnit(pipeline, state, rawState, monitor, io, ignored);
|
|
20543
|
-
}
|
|
20544
20357
|
tryExecuteSyncPurePipelineUnit(pipeline, state, rawState, monitor, io, ignored) {
|
|
20545
20358
|
const backing = this.backingFs;
|
|
20546
20359
|
if (syncPurePipelineSlotInUse || !this._isMemoryBackingFs || !backing || backing.capabilitiesFor !== void 0 || this.middleware.length > 0 || customRegisteredRegistries.has(this.commands) || !io.stdinIsDefault || this.signal.aborted || hasYieldCheckpoint(this.signal) || !this.budget.canSyncPurePipe || !(io.stdout instanceof Capture && io.stdout._scratch4k !== void 0 && io.stdout.length === 0 && io.stdout.write === Capture.prototype.write) || !(io.stderr instanceof Capture && io.stderr.length === 0 && io.stderr.write === Capture.prototype.write)) {
|
|
@@ -20551,7 +20364,7 @@ var Runtime = class _Runtime {
|
|
|
20551
20364
|
const cmd = pipeline.commands[i];
|
|
20552
20365
|
const name2 = cmd.words[0].plain;
|
|
20553
20366
|
const extDef = this.commands.get(name2);
|
|
20554
|
-
if (!extDef || !
|
|
20367
|
+
if (!extDef || !builtInDirectContextExecutors2.has(extDef.execute) || customRegisteredCommands.has(extDef.execute)) {
|
|
20555
20368
|
return void 0;
|
|
20556
20369
|
}
|
|
20557
20370
|
let stageArgs = cmd._cachedPlainArgs;
|
|
@@ -20631,7 +20444,7 @@ var Runtime = class _Runtime {
|
|
|
20631
20444
|
stageStdout = sharedSyncPipeWriter;
|
|
20632
20445
|
}
|
|
20633
20446
|
if (!context) {
|
|
20634
|
-
context = new FastShellCommandContext(this, rawState, io, scope, firstName, stageArgs, void 0, void 0, true);
|
|
20447
|
+
context = new FastShellCommandContext(this, rawState, io, scope, firstName, stageArgs, void 0, void 0, true, extDef);
|
|
20635
20448
|
pooledSyncPipeContext = context;
|
|
20636
20449
|
}
|
|
20637
20450
|
context.resetDirectStage(this, rawState, io, scope, firstName, stageArgs, inputSource, isFirst, stageStdout, this.signal);
|
|
@@ -20655,7 +20468,7 @@ var Runtime = class _Runtime {
|
|
|
20655
20468
|
statuses ??= new Array(n).fill(0);
|
|
20656
20469
|
statuses[index] = status;
|
|
20657
20470
|
}
|
|
20658
|
-
}).finally(() => scope.leaveWork()).then(() => runStages(index + 1,
|
|
20471
|
+
}).finally(() => scope.leaveWork()).then(() => runStages(index + 1, sharedSyncPipeWriter.target, sharedSyncPipeWriter.used));
|
|
20659
20472
|
}
|
|
20660
20473
|
scope.leaveWork();
|
|
20661
20474
|
this.signal.throwIfAborted();
|
|
@@ -20663,7 +20476,7 @@ var Runtime = class _Runtime {
|
|
|
20663
20476
|
statuses ??= new Array(n).fill(0);
|
|
20664
20477
|
statuses[index] = 1;
|
|
20665
20478
|
}
|
|
20666
|
-
prevBuf =
|
|
20479
|
+
prevBuf = sharedSyncPipeWriter.target;
|
|
20667
20480
|
prevLen = sharedSyncPipeWriter.used;
|
|
20668
20481
|
}
|
|
20669
20482
|
};
|
|
@@ -20673,6 +20486,7 @@ var Runtime = class _Runtime {
|
|
|
20673
20486
|
sharedSyncPipeWriter.signal = void 0;
|
|
20674
20487
|
sharedSyncPipeWriter.target = EMPTY_BYTES;
|
|
20675
20488
|
sharedSyncPipeReader.reset(EMPTY_BYTES, 0);
|
|
20489
|
+
sharedSyncPipeReader.clearViews();
|
|
20676
20490
|
syncPurePipelineSlotInUse = false;
|
|
20677
20491
|
this.budget.leavePipelineStages(n);
|
|
20678
20492
|
};
|
|
@@ -20702,234 +20516,6 @@ var Runtime = class _Runtime {
|
|
|
20702
20516
|
release();
|
|
20703
20517
|
return finish();
|
|
20704
20518
|
}
|
|
20705
|
-
executeFastPurePipelineUnitSlow(pipeline, state, rawState, monitor, io, ignored) {
|
|
20706
|
-
const n = pipeline.commands.length;
|
|
20707
|
-
this.budget.enterPipelineStages(n);
|
|
20708
|
-
this.budget.commands += n;
|
|
20709
|
-
const pipeOptions = { highWaterMark: this.budget.limits.pipeHighWaterMark, signal: this.signal, admitWrite: this.budget.pipelineInput };
|
|
20710
|
-
const pipes = new Array(n - 1);
|
|
20711
|
-
for (let i = 0; i < n - 1; i++) {
|
|
20712
|
-
pipes[i] = createBytePipe(pipeOptions);
|
|
20713
|
-
}
|
|
20714
|
-
const controllers = new Array(n);
|
|
20715
|
-
for (let i = 0; i < n; i++) {
|
|
20716
|
-
controllers[i] = createManagedControlController2();
|
|
20717
|
-
}
|
|
20718
|
-
const onParentAbort = (reason) => {
|
|
20719
|
-
for (let i = 0; i < n; i++) abortManagedController2(controllers[i], reason);
|
|
20720
|
-
};
|
|
20721
|
-
addAbortSignalWaiter2(this.signal, onParentAbort);
|
|
20722
|
-
const scope = io[invocationScope];
|
|
20723
|
-
const onScopeSeal = () => {
|
|
20724
|
-
const closedReason = new Error("Invocation is closed");
|
|
20725
|
-
for (let i = 0; i < n; i++) abortManagedController2(controllers[i], closedReason);
|
|
20726
|
-
for (let i = 0; i < n - 1; i++) void pipes[i].abort(closedReason);
|
|
20727
|
-
};
|
|
20728
|
-
scope.addSealCallback(onScopeSeal);
|
|
20729
|
-
const statuses = new Array(n);
|
|
20730
|
-
let asyncTasks;
|
|
20731
|
-
try {
|
|
20732
|
-
for (let index = 0; index < n; index++) {
|
|
20733
|
-
const cmd = pipeline.commands[index];
|
|
20734
|
-
const firstName = cmd.words[0].plain;
|
|
20735
|
-
const extDef = this.commands.get(firstName);
|
|
20736
|
-
let stageArgs = cmd._cachedPlainArgs;
|
|
20737
|
-
if (!stageArgs) {
|
|
20738
|
-
stageArgs = new Array(cmd.words.length - 1);
|
|
20739
|
-
for (let w = 1; w < cmd.words.length; w++) {
|
|
20740
|
-
const word = cmd.words[w];
|
|
20741
|
-
stageArgs[w - 1] = word.plain ?? word.parts.map((p) => p.value).join("");
|
|
20742
|
-
}
|
|
20743
|
-
cmd._cachedPlainArgs = stageArgs;
|
|
20744
|
-
}
|
|
20745
|
-
const incoming = index > 0 ? pipes[index - 1] : void 0;
|
|
20746
|
-
const outgoing = index < n - 1 ? pipes[index] : void 0;
|
|
20747
|
-
const reading = incoming?.endpoints?.read;
|
|
20748
|
-
const writing = outgoing?.endpoints?.write;
|
|
20749
|
-
const stageSignal = controllers[index].signal;
|
|
20750
|
-
let input;
|
|
20751
|
-
if (incoming) {
|
|
20752
|
-
reading.abortSignal = stageSignal;
|
|
20753
|
-
input = reading;
|
|
20754
|
-
} else if (io.stdinIsDefault) input = io.stdin;
|
|
20755
|
-
else input = new ShellInput(io.stdin, this.budget, stageSignal, void 0, true);
|
|
20756
|
-
const writable = writing?.writable ?? outgoing?.writable;
|
|
20757
|
-
const stageStdout = outgoing ? new BudgetedPipeStageSink(this.budget, writable, stageSignal, void 0, index, controllers[index]) : signalSink(io.stdout, stageSignal);
|
|
20758
|
-
const context = new FastShellCommandContext(this, rawState, io, scope, firstName, stageArgs, void 0, void 0, true);
|
|
20759
|
-
context.stdin = input;
|
|
20760
|
-
if (incoming) context.stdinIsDefault = false;
|
|
20761
|
-
context.stdout = stageStdout;
|
|
20762
|
-
context.signal = this._isMemoryBackingFs ? stageSignal : toNativeAbortSignal(stageSignal);
|
|
20763
|
-
context._scopedSignal = stageSignal;
|
|
20764
|
-
if (asyncTasks === void 0) {
|
|
20765
|
-
scope.enterWork();
|
|
20766
|
-
this.budget.beginPathLookupSuspension();
|
|
20767
|
-
let syncExitCode = -1;
|
|
20768
|
-
let pendingRes;
|
|
20769
|
-
let syncErr;
|
|
20770
|
-
let hasSyncErr = false;
|
|
20771
|
-
try {
|
|
20772
|
-
const resPromise = extDef.execute(context);
|
|
20773
|
-
if (resPromise === RESOLVED_EXIT_ZERO) {
|
|
20774
|
-
stageSignal.throwIfAborted();
|
|
20775
|
-
syncExitCode = 0;
|
|
20776
|
-
} else if (resPromise === RESOLVED_EXIT_ONE) {
|
|
20777
|
-
stageSignal.throwIfAborted();
|
|
20778
|
-
syncExitCode = 1;
|
|
20779
|
-
} else pendingRes = Promise.resolve(resPromise);
|
|
20780
|
-
} catch (error) {
|
|
20781
|
-
hasSyncErr = true;
|
|
20782
|
-
syncErr = error;
|
|
20783
|
-
}
|
|
20784
|
-
if (syncExitCode >= 0) {
|
|
20785
|
-
this.budget.endPathLookupSuspension();
|
|
20786
|
-
scope.leaveWork();
|
|
20787
|
-
let asyncCleanup;
|
|
20788
|
-
if (!incoming && input !== io.stdin) {
|
|
20789
|
-
const closedInput = input.close();
|
|
20790
|
-
if (!isSyncResolved5(closedInput)) asyncCleanup = closedInput;
|
|
20791
|
-
}
|
|
20792
|
-
if (!asyncCleanup && reading) {
|
|
20793
|
-
const closedRead = reading.close();
|
|
20794
|
-
if (!isSyncResolved5(closedRead)) asyncCleanup = closedRead;
|
|
20795
|
-
}
|
|
20796
|
-
if (!asyncCleanup && writing) {
|
|
20797
|
-
const closedWrite = writing.close();
|
|
20798
|
-
if (!isSyncResolved5(closedWrite)) asyncCleanup = closedWrite;
|
|
20799
|
-
}
|
|
20800
|
-
if (!asyncCleanup && outgoing && !writing) {
|
|
20801
|
-
const closedOut = outgoing.close();
|
|
20802
|
-
if (!isSyncResolved5(closedOut)) asyncCleanup = closedOut;
|
|
20803
|
-
}
|
|
20804
|
-
if (!asyncCleanup) {
|
|
20805
|
-
statuses[index] = syncExitCode;
|
|
20806
|
-
continue;
|
|
20807
|
-
}
|
|
20808
|
-
asyncTasks = new Array(n);
|
|
20809
|
-
for (let prev = 0; prev < index; prev++) asyncTasks[prev] = Promise.resolve(statuses[prev]);
|
|
20810
|
-
asyncTasks[index] = asyncCleanup.then(() => syncExitCode);
|
|
20811
|
-
continue;
|
|
20812
|
-
}
|
|
20813
|
-
asyncTasks = new Array(n);
|
|
20814
|
-
for (let prev = 0; prev < index; prev++) asyncTasks[prev] = Promise.resolve(statuses[prev]);
|
|
20815
|
-
asyncTasks[index] = this.finishFastPurePipelineStageAsync(cmd, context, incoming, outgoing, reading, writing, input, stageSignal, scope, io, pendingRes, hasSyncErr, syncErr);
|
|
20816
|
-
continue;
|
|
20817
|
-
}
|
|
20818
|
-
scope.enterWork();
|
|
20819
|
-
this.budget.beginPathLookupSuspension();
|
|
20820
|
-
asyncTasks[index] = this.finishFastPurePipelineStageAsync(cmd, context, incoming, outgoing, reading, writing, input, stageSignal, scope, io, void 0, false, void 0, extDef);
|
|
20821
|
-
}
|
|
20822
|
-
if (asyncTasks !== void 0) {
|
|
20823
|
-
return this.finishFastPurePipelineUnitAsync(asyncTasks, n, pipes, controllers, onParentAbort, onScopeSeal, scope, monitor, rawState, pipeline, state, io, ignored);
|
|
20824
|
-
}
|
|
20825
|
-
} catch (syncFatal) {
|
|
20826
|
-
scope.removeSealCallback(onScopeSeal);
|
|
20827
|
-
removeAbortSignalWaiter2(this.signal, onParentAbort);
|
|
20828
|
-
for (let i = 0; i < n; i++) abortManagedController2(controllers[i], SHARED_PIPELINE_CLOSED);
|
|
20829
|
-
for (let i = 0; i < n - 1; i++) void pipes[i].abort();
|
|
20830
|
-
this.budget.leavePipelineStages(n);
|
|
20831
|
-
throw syncFatal;
|
|
20832
|
-
}
|
|
20833
|
-
scope.removeSealCallback(onScopeSeal);
|
|
20834
|
-
removeAbortSignalWaiter2(this.signal, onParentAbort);
|
|
20835
|
-
for (let i = 0; i < n; i++) {
|
|
20836
|
-
abortManagedController2(controllers[i], SHARED_PIPELINE_CLOSED);
|
|
20837
|
-
}
|
|
20838
|
-
for (let i = 0; i < n - 1; i++) {
|
|
20839
|
-
void pipes[i].abort();
|
|
20840
|
-
}
|
|
20841
|
-
this.budget.leavePipelineStages(n);
|
|
20842
|
-
const restEpoch = monitor.chargeInternal(syncRestorationCharge, syncRestorationTickets).epoch;
|
|
20843
|
-
monitor.lazyPipeStatus = statuses;
|
|
20844
|
-
monitor.chargeInternal(syncPipeStatusCharge, syncPipeStatusTickets);
|
|
20845
|
-
const rawStatus = rawState.pipefail ? statuses.findLast((s) => s !== 0) ?? 0 : statuses[n - 1];
|
|
20846
|
-
const finalStatus = pipeline.negate ? Number(rawStatus === 0) : rawStatus;
|
|
20847
|
-
rawState.status = finalStatus;
|
|
20848
|
-
monitor.epoch = restEpoch;
|
|
20849
|
-
if (rawStatus !== 0 && !pipeline.negate && !ignored && rawState.errexit) {
|
|
20850
|
-
if (this.tryFinishShellSync(state)) return { exitCode: finalStatus, terminated: true };
|
|
20851
|
-
return this.finishShell(state, io, finalStatus).then((exitCode) => ({ exitCode, terminated: true }));
|
|
20852
|
-
}
|
|
20853
|
-
return finalStatus === 0 ? SYNC_UNIT_ZERO : finalStatus === 1 ? SYNC_UNIT_ONE : { exitCode: finalStatus, terminated: false };
|
|
20854
|
-
}
|
|
20855
|
-
async finishFastPurePipelineStageAsync(cmd, context, incoming, outgoing, reading, writing, input, stageSignal, scope, io, pendingRes, hasSyncErr, syncErr, extDef) {
|
|
20856
|
-
let exitCode = 0;
|
|
20857
|
-
try {
|
|
20858
|
-
if (hasSyncErr) throw syncErr;
|
|
20859
|
-
const res = await (pendingRes ?? extDef.execute(context));
|
|
20860
|
-
stageSignal.throwIfAborted();
|
|
20861
|
-
exitCode = validateExitCode(res.exitCode);
|
|
20862
|
-
} catch (error) {
|
|
20863
|
-
if (error instanceof PipelineClosed || stageSignal.aborted && Object.is(stageSignal.reason, SHARED_PIPELINE_CLOSED)) exitCode = 141;
|
|
20864
|
-
else if (errorCode(error) === "EPIPE" && !this.signal.aborted) exitCode = 141;
|
|
20865
|
-
else {
|
|
20866
|
-
this.signal.throwIfAborted();
|
|
20867
|
-
if (error instanceof Flow || error instanceof ShellLimitError || error instanceof ShellSyntaxError) throw error;
|
|
20868
|
-
const line = io.diagnosticCommandLines?.get(cmd) ?? (cmd.line ?? 1) + (io.diagnosticOffset ?? 0);
|
|
20869
|
-
try {
|
|
20870
|
-
await writeDiagnostic(context.stderr, `${io.scriptName ?? "shell"}: line ${line}: ${message(error, this.budget.onInternalError)}
|
|
20871
|
-
`);
|
|
20872
|
-
} catch (failure) {
|
|
20873
|
-
this.signal.throwIfAborted();
|
|
20874
|
-
publicDiagnosticMessage(failure, this.budget.onInternalError);
|
|
20875
|
-
}
|
|
20876
|
-
exitCode = error instanceof CommandFailure ? error.status : 1;
|
|
20877
|
-
}
|
|
20878
|
-
} finally {
|
|
20879
|
-
this.budget.endPathLookupSuspension();
|
|
20880
|
-
scope.leaveWork();
|
|
20881
|
-
if (!incoming && input !== io.stdin) {
|
|
20882
|
-
const closedInput = input.close();
|
|
20883
|
-
if (!isSyncResolved5(closedInput)) {
|
|
20884
|
-
await closedInput.catch((error) => {
|
|
20885
|
-
if (!(error instanceof PipelineClosed)) throw error;
|
|
20886
|
-
});
|
|
20887
|
-
}
|
|
20888
|
-
}
|
|
20889
|
-
if (reading) {
|
|
20890
|
-
const closedRead = reading.close();
|
|
20891
|
-
if (!isSyncResolved5(closedRead)) await closedRead;
|
|
20892
|
-
}
|
|
20893
|
-
if (writing) {
|
|
20894
|
-
const closedWrite = writing.close();
|
|
20895
|
-
if (!isSyncResolved5(closedWrite)) await closedWrite;
|
|
20896
|
-
}
|
|
20897
|
-
if (outgoing && !writing) {
|
|
20898
|
-
const closedOut = outgoing.close();
|
|
20899
|
-
if (!isSyncResolved5(closedOut)) await closedOut.catch(() => void 0);
|
|
20900
|
-
}
|
|
20901
|
-
}
|
|
20902
|
-
return exitCode;
|
|
20903
|
-
}
|
|
20904
|
-
async finishFastPurePipelineUnitAsync(tasks, n, pipes, controllers, onParentAbort, onScopeSeal, scope, monitor, rawState, pipeline, state, io, ignored) {
|
|
20905
|
-
let statuses;
|
|
20906
|
-
try {
|
|
20907
|
-
statuses = this.budget._hasExternalSignal ? await interruptible2(Promise.all(tasks), this.signal) : await Promise.all(tasks);
|
|
20908
|
-
} finally {
|
|
20909
|
-
scope.removeSealCallback(onScopeSeal);
|
|
20910
|
-
removeAbortSignalWaiter2(this.signal, onParentAbort);
|
|
20911
|
-
for (let i = 0; i < n; i++) {
|
|
20912
|
-
abortManagedController2(controllers[i], SHARED_PIPELINE_CLOSED);
|
|
20913
|
-
}
|
|
20914
|
-
for (let i = 0; i < n - 1; i++) {
|
|
20915
|
-
const ab = pipes[i].abort();
|
|
20916
|
-
if (!isSyncResolved5(ab)) await ab;
|
|
20917
|
-
}
|
|
20918
|
-
this.budget.leavePipelineStages(n);
|
|
20919
|
-
}
|
|
20920
|
-
const restEpoch = monitor.chargeInternal(syncRestorationCharge, syncRestorationTickets).epoch;
|
|
20921
|
-
monitor.lazyPipeStatus = statuses;
|
|
20922
|
-
monitor.chargeInternal(syncPipeStatusCharge, syncPipeStatusTickets);
|
|
20923
|
-
const rawStatus = rawState.pipefail ? statuses.findLast((s) => s !== 0) ?? 0 : statuses[n - 1];
|
|
20924
|
-
const finalStatus = pipeline.negate ? Number(rawStatus === 0) : rawStatus;
|
|
20925
|
-
rawState.status = finalStatus;
|
|
20926
|
-
monitor.epoch = restEpoch;
|
|
20927
|
-
if (rawStatus !== 0 && !pipeline.negate && !ignored && rawState.errexit) {
|
|
20928
|
-
if (this.tryFinishShellSync(state)) return { exitCode: finalStatus, terminated: true };
|
|
20929
|
-
return { exitCode: await this.finishShell(state, io, finalStatus), terminated: true };
|
|
20930
|
-
}
|
|
20931
|
-
return finalStatus === 0 ? SYNC_UNIT_ZERO : finalStatus === 1 ? SYNC_UNIT_ONE : { exitCode: finalStatus, terminated: false };
|
|
20932
|
-
}
|
|
20933
20519
|
async inputUnit(script, state, io, startListIndex = 0, startPipelineIndex = 0, skipFirstSync = false) {
|
|
20934
20520
|
try {
|
|
20935
20521
|
return await this.script(script, state, io, startListIndex, startPipelineIndex, skipFirstSync);
|
|
@@ -20942,6 +20528,7 @@ var Runtime = class _Runtime {
|
|
|
20942
20528
|
}
|
|
20943
20529
|
}
|
|
20944
20530
|
trySyncPipeline(pipeline, state, io, ignored) {
|
|
20531
|
+
io = this.persistentIO(state, io);
|
|
20945
20532
|
const _rawSt = stateMonitor(state)?.raw ?? state;
|
|
20946
20533
|
if ((_rawSt._syncPendingFunctionResumes?.length ?? 0) > 0 || _rawSt._syncPendingEvalResume !== void 0) return void 0;
|
|
20947
20534
|
if (this.budget.limits.maxExpansionBytes < 65536 || this.budget.limits.maxCommands < 1e3 || this.script !== _Runtime.prototype.script) return void 0;
|
|
@@ -21137,7 +20724,7 @@ var Runtime = class _Runtime {
|
|
|
21137
20724
|
const uArg = wu.plain ?? (wu.parts.length === 1 && wu.parts[0].kind === "text" ? wu.parts[0].value : void 0);
|
|
21138
20725
|
if (uArg !== void 0) {
|
|
21139
20726
|
const br = uArg.indexOf("[");
|
|
21140
|
-
if (br > 0 && uArg.endsWith("]") && (wu.parts[0]?.quoted || rawState.noglob || !rawState.nullglob && this._isMemoryBackingFs && tryGetMemoryDirectoryEntryNamesSync(this.backingFs, rawState.cwd)?.size === 0)) {
|
|
20727
|
+
if (br > 0 && uArg.endsWith("]") && (wu.parts[0]?.quoted || rawState.noglob || !rawState.nullglob && !rawState.failglob && this._isMemoryBackingFs && tryGetMemoryDirectoryEntryNamesSync(this.backingFs, rawState.cwd)?.size === 0)) {
|
|
21141
20728
|
const arrName = uArg.slice(0, br);
|
|
21142
20729
|
const subStr = uArg.slice(br + 1, -1);
|
|
21143
20730
|
const b = isShellIdentifier(arrName) ? st?.get(arrName) : void 0;
|
|
@@ -21259,7 +20846,7 @@ var Runtime = class _Runtime {
|
|
|
21259
20846
|
}
|
|
21260
20847
|
if ((w0Plain === "dirname" || w0Plain === "basename") && !hasShellFunction(rawState, w0Plain) && !rawState.extensions?.builtins.has(w0Plain)) {
|
|
21261
20848
|
const def = this.commands.get(w0Plain);
|
|
21262
|
-
if (def &&
|
|
20849
|
+
if (def && builtInDirectContextExecutors2.has(def.execute) && !customRegisteredCommands.has(def.execute)) {
|
|
21263
20850
|
if (w0Plain === "dirname" && command.words.length === 2 && isNoBraceSyncWord(command.words[1])) return true;
|
|
21264
20851
|
if (w0Plain === "basename" && (command.words.length === 2 || command.words.length === 3 || command.words.length === 4 && command.words[1]?.plain === "-s") && command.words.slice(1).every(isNoBraceSyncWord)) return true;
|
|
21265
20852
|
}
|
|
@@ -21282,7 +20869,7 @@ var Runtime = class _Runtime {
|
|
|
21282
20869
|
let targetOk = false;
|
|
21283
20870
|
if (w2Plain !== void 0) {
|
|
21284
20871
|
const br = w2Plain.indexOf("[");
|
|
21285
|
-
if (br > 0 && w2Plain.endsWith("]") && (w2?.parts[0]?.quoted || rawState.noglob || !rawState.nullglob && this._isMemoryBackingFs && tryGetMemoryDirectoryEntryNamesSync(this.backingFs, rawState.cwd)?.size === 0)) {
|
|
20872
|
+
if (br > 0 && w2Plain.endsWith("]") && (w2?.parts[0]?.quoted || rawState.noglob || !rawState.nullglob && !rawState.failglob && this._isMemoryBackingFs && tryGetMemoryDirectoryEntryNamesSync(this.backingFs, rawState.cwd)?.size === 0)) {
|
|
21286
20873
|
const arrName = w2Plain.slice(0, br);
|
|
21287
20874
|
const subStr = w2Plain.slice(br + 1, -1);
|
|
21288
20875
|
const b = isShellIdentifier(arrName) ? st?.get(arrName) : void 0;
|
|
@@ -21758,7 +21345,7 @@ var Runtime = class _Runtime {
|
|
|
21758
21345
|
const follow = op !== "-L" && op !== "-h";
|
|
21759
21346
|
const syscall = isAccess ? "access" : follow ? "stat" : "lstat";
|
|
21760
21347
|
const prototype = Object.getPrototypeOf(mem);
|
|
21761
|
-
if (prototype !==
|
|
21348
|
+
if (prototype !== MemoryFileSystem.prototype) return void 0;
|
|
21762
21349
|
for (const method of ["stat", "lstat", "access", "snapshot"]) {
|
|
21763
21350
|
const descriptor = Object.getOwnPropertyDescriptor(mem, method) ?? Object.getOwnPropertyDescriptor(prototype, method);
|
|
21764
21351
|
if (!descriptor || !("value" in descriptor) || descriptor.value !== memoryFilePredicateImplementation[method]?.value) return void 0;
|
|
@@ -22796,7 +22383,7 @@ var Runtime = class _Runtime {
|
|
|
22796
22383
|
if (this.budget.limits.maxExpansionFields === Infinity && command.words.length >= 4 && w0Plain === "printf" && command.words[1]?.plain === "-v" && command.redirects.length === 0 && canMutatePipeStatus && (!pipeline.negate || ignored || !rawState.errexit) && !hasShellFunction(rawState, "printf") && !rawState.extensions?.builtins.has("printf")) {
|
|
22797
22384
|
const def = this.commands.get("printf");
|
|
22798
22385
|
if (def && def.execute === printfCommand.execute && command.words.length <= this.budget.maxExpansionFieldsSmi && (this.arePureArgWords(command.words, rawState) || command.words.every((w, idx) => idx < 4 ? this.isPureArgWord(w, rawState) : this.isPureArgWord(w, rawState) || this.canSyncArrayMembersWord(w, rawState)))) {
|
|
22799
|
-
let targetSpec = command.words[2]?.plain !== void 0 && (rawState.noglob || !hasGlobOrEscape(command.words[2].plain, !!rawState.extglob) || !rawState.nullglob && this._isMemoryBackingFs && tryGetMemoryDirectoryEntryNamesSync(this.backingFs, rawState.cwd)?.size === 0) ? command.words[2].plain : void 0;
|
|
22386
|
+
let targetSpec = command.words[2]?.plain !== void 0 && (rawState.noglob || !hasGlobOrEscape(command.words[2].plain, !!rawState.extglob) || !rawState.nullglob && !rawState.failglob && this._isMemoryBackingFs && tryGetMemoryDirectoryEntryNamesSync(this.backingFs, rawState.cwd)?.size === 0) ? command.words[2].plain : void 0;
|
|
22800
22387
|
if (targetSpec === void 0) {
|
|
22801
22388
|
try {
|
|
22802
22389
|
targetSpec = this.fastValueWord(command.words[2], rawState, io, true, false, false, true, void 0, diagnosticLine);
|
|
@@ -23254,7 +22841,7 @@ var Runtime = class _Runtime {
|
|
|
23254
22841
|
const fastSyncSink = io.stdout instanceof BudgetedSyncSink && io.stdout.write === BudgetedSyncSink.prototype.write || io.stdout instanceof Capture && io.stdout.write === Capture.prototype.write ? io.stdout : void 0;
|
|
23255
22842
|
const fastPipeSink = !fastSyncSink && io.stdout instanceof BudgetedPipeStageSink && io.stdout.write === BudgetedPipeStageSink.prototype.write && io.stdout.canWriteSync() ? io.stdout : void 0;
|
|
23256
22843
|
const syncOut = fastSyncSink || fastPipeSink ? void 0 : syncSinks.get(io.stdout);
|
|
23257
|
-
if (def &&
|
|
22844
|
+
if (def && builtInDirectContextExecutors2.has(def.execute) && !customRegisteredCommands.has(def.execute) && (fastSyncSink || fastPipeSink || syncOut)) {
|
|
23258
22845
|
let outText;
|
|
23259
22846
|
let lastArg = w0Plain;
|
|
23260
22847
|
try {
|
|
@@ -23793,7 +23380,7 @@ var Runtime = class _Runtime {
|
|
|
23793
23380
|
const ops = [];
|
|
23794
23381
|
for (let ui = uStart; ui < command.words.length; ui++) {
|
|
23795
23382
|
const wu = command.words[ui];
|
|
23796
|
-
const canSkipGlobUnset = Boolean(wu.parts[0]?.quoted || rawState.noglob || !rawState.nullglob && this._isMemoryBackingFs && tryGetMemoryDirectoryEntryNamesSync(this.backingFs, rawState.cwd)?.size === 0);
|
|
23383
|
+
const canSkipGlobUnset = Boolean(wu.parts[0]?.quoted || rawState.noglob || !rawState.nullglob && !rawState.failglob && this._isMemoryBackingFs && tryGetMemoryDirectoryEntryNamesSync(this.backingFs, rawState.cwd)?.size === 0);
|
|
23797
23384
|
let tExpanded;
|
|
23798
23385
|
try {
|
|
23799
23386
|
const fv = this.fastValueWord(wu, rawState, io, !canSkipGlobUnset, false, false, true, void 0, diagnosticLine);
|
|
@@ -24461,7 +24048,7 @@ var Runtime = class _Runtime {
|
|
|
24461
24048
|
}
|
|
24462
24049
|
}
|
|
24463
24050
|
}
|
|
24464
|
-
if (w0Plain === "eval" && canMutatePipeStatus && !pipeline.negate && !hasShellFunction(rawState, "eval") && !rawState.extensions?.builtins.has("eval") && isDefaultShellSyntax(rawState.extensions?.syntax) && !rawState.nounset && !rawState.readonlyVariables?.size && rawState.depth < this.budget.limits.maxSubstitutionDepth && !hasYieldCheckpoint(this.signal) && (this._syncReturnDepth > 0 || (this.budget.commands + 32 & 2047) >= 32)) {
|
|
24051
|
+
if (w0Plain === "eval" && !rawState.expand_aliases && canMutatePipeStatus && !pipeline.negate && !hasShellFunction(rawState, "eval") && !rawState.extensions?.builtins.has("eval") && isDefaultShellSyntax(rawState.extensions?.syntax) && !rawState.nounset && !rawState.readonlyVariables?.size && rawState.depth < this.budget.limits.maxSubstitutionDepth && !hasYieldCheckpoint(this.signal) && (this._syncReturnDepth > 0 || (this.budget.commands + 32 & 2047) >= 32)) {
|
|
24465
24052
|
const evalArgs = [];
|
|
24466
24053
|
let argsOk = true;
|
|
24467
24054
|
try {
|
|
@@ -25029,7 +24616,7 @@ var Runtime = class _Runtime {
|
|
|
25029
24616
|
const initializer = command.expressions[0]?.tree;
|
|
25030
24617
|
if (initializer?.kind !== "binary" || initializer.operator !== "=" || initializer.left.kind !== "name") return void 0;
|
|
25031
24618
|
const induction = initializer.left.name;
|
|
25032
|
-
const dynamicNames = /* @__PURE__ */ new Set(["PIPESTATUS", "LINENO", "_", "FUNCNAME", "DIRSTACK", "BASH_SUBSHELL"]);
|
|
24619
|
+
const dynamicNames = /* @__PURE__ */ new Set(["PIPESTATUS", "LINENO", "_", "FUNCNAME", "DIRSTACK", "BASH_SUBSHELL", "BASHPID"]);
|
|
25033
24620
|
const assignments2 = [];
|
|
25034
24621
|
const appends = /* @__PURE__ */ new Map();
|
|
25035
24622
|
for (const list of command.body.lists) {
|
|
@@ -25168,10 +24755,11 @@ var Runtime = class _Runtime {
|
|
|
25168
24755
|
const part = word.parts[i];
|
|
25169
24756
|
if (part.kind === "text") {
|
|
25170
24757
|
if (part.byteValue || invokedValues.has(part)) return false;
|
|
24758
|
+
if (!part.quoted && (part.value.includes("~") || part.value.includes("{") || hasGlobOrEscape(part.value, true))) return false;
|
|
25171
24759
|
continue;
|
|
25172
24760
|
}
|
|
25173
24761
|
if (part.kind === "variable") {
|
|
25174
|
-
if (part.name === "RANDOM" || part.name === "SECONDS" || stateMonitor(rawState)?.store?.get(part.name)) return false;
|
|
24762
|
+
if (part.name === "RANDOM" || part.name === "SECONDS" || part.name === "BASHPID" || stateMonitor(rawState)?.store?.get(part.name)) return false;
|
|
25175
24763
|
if (this._syncLoopFnCheckDepth > 0 && (part.substring || getArraySelector(part)?.kind === "element")) return false;
|
|
25176
24764
|
if (part.prefixNames !== void 0) {
|
|
25177
24765
|
if (part.prefixNames === "@") return false;
|
|
@@ -26818,8 +26406,8 @@ var Runtime = class _Runtime {
|
|
|
26818
26406
|
rawState.status = 0;
|
|
26819
26407
|
}
|
|
26820
26408
|
runYieldCheckpoint(this.signal);
|
|
26821
|
-
for (
|
|
26822
|
-
rawState.variables[
|
|
26409
|
+
for (const name2 of touchedIntNamesList) {
|
|
26410
|
+
rawState.variables[name2] = intToStr(sharedLoopIntRegs[regNames.indexOf(name2)]);
|
|
26823
26411
|
}
|
|
26824
26412
|
regNames.length = 0;
|
|
26825
26413
|
if (hasDeferredSteps && lastInductionInt !== void 0) lastInductionVal = intToStr(lastInductionInt);
|
|
@@ -28096,8 +27684,8 @@ ${s1}
|
|
|
28096
27684
|
encoded = encoded.slice();
|
|
28097
27685
|
if (step.targetDirPrefix !== void 0 && step.targetNamePrefix !== void 0) {
|
|
28098
27686
|
const fileName = this.evalSyncRedirectSuffix(step.targetWord, step.targetDirPrefix, step.targetNamePrefix, rawState, io);
|
|
28099
|
-
if (tryWriteMemoryFileInDirSync(this.backingFs, step.targetDirPrefix, fileName, encoded, append, mode, this.commandSignal)) return;
|
|
28100
|
-
tryWriteMemoryFileSync(this.backingFs, step.targetDirPrefix + fileName, encoded, append, mode, this.commandSignal);
|
|
27687
|
+
if (!fileName.includes("/") && fileName !== "." && fileName !== ".." && tryWriteMemoryFileInDirSync(this.backingFs, step.targetDirPrefix, fileName, encoded, append, mode, this.commandSignal)) return;
|
|
27688
|
+
tryWriteMemoryFileSync(this.backingFs, normalizePath(step.targetDirPrefix + fileName, rawState.cwd), encoded, append, mode, this.commandSignal);
|
|
28101
27689
|
return;
|
|
28102
27690
|
}
|
|
28103
27691
|
const targetVal = this.evalSyncRedirectWord(step.targetWord, rawState, io);
|
|
@@ -28626,6 +28214,7 @@ ${s1}
|
|
|
28626
28214
|
}
|
|
28627
28215
|
const firstIndex = listIndex === startListIndex ? startPipelineIndex : 0;
|
|
28628
28216
|
for (let index = firstIndex; index < list.pipelines.length; index++) {
|
|
28217
|
+
io = this.persistentIO(state, io);
|
|
28629
28218
|
if (state.noexec) throw new Flow("discard", 0);
|
|
28630
28219
|
const operator = index > 0 ? list.operators[index - 1] : void 0;
|
|
28631
28220
|
const resumingEnteredPipeline = skipFirstSync && listIndex === startListIndex && index === startPipelineIndex;
|
|
@@ -28817,6 +28406,7 @@ ${s1}
|
|
|
28817
28406
|
void installation.catch(() => void 0);
|
|
28818
28407
|
}
|
|
28819
28408
|
const tasks = pipeline.commands.map(async (command, index) => {
|
|
28409
|
+
const inCurrentShell = !!state.lastpipe && index === pipeline.commands.length - 1;
|
|
28820
28410
|
let admitted = false;
|
|
28821
28411
|
const admit = () => {
|
|
28822
28412
|
if (admitted) return;
|
|
@@ -28849,7 +28439,7 @@ ${s1}
|
|
|
28849
28439
|
let stageOwnsCleanup = false;
|
|
28850
28440
|
try {
|
|
28851
28441
|
const rawStateForChild = stateMonitor(state)?.raw ?? state;
|
|
28852
|
-
const isPureStage = !terminal && !(io.descriptors && (io.descriptors.size > 3 || io.descriptors.get(0)?.closed || io.descriptors.get(1)?.closed || io.descriptors.get(2)?.closed)) && runtime.isPureExternalStageCommand(command, rawStateForChild);
|
|
28442
|
+
const isPureStage = !inCurrentShell && !terminal && !(io.descriptors && (io.descriptors.size > 3 || io.descriptors.get(0)?.closed || io.descriptors.get(1)?.closed || io.descriptors.get(2)?.closed)) && runtime.isPureExternalStageCommand(command, rawStateForChild);
|
|
28853
28443
|
const references = isPureStage ? void 0 : cleanupRefs = new PipeDescriptorFrame(io[invocationScope]);
|
|
28854
28444
|
const descriptorFrame = isPureStage ? void 0 : cleanupDescFrame = new PreparedDescriptorFrame(references, this.budget);
|
|
28855
28445
|
const reading = incoming?.endpoints?.read;
|
|
@@ -28871,14 +28461,14 @@ ${s1}
|
|
|
28871
28461
|
try {
|
|
28872
28462
|
const isFastPure = isPureStage || runtime.isPureExternalStageCommand(command, rawStateForChild);
|
|
28873
28463
|
const forkedExt = isFastPure ? forkExtensions(state.extensions, "pipeline") : void 0;
|
|
28874
|
-
const child = isFastPure ? Object.assign(cloneRawState(rawStateForChild, false), {
|
|
28464
|
+
const child = inCurrentShell ? state : isFastPure ? Object.assign(cloneRawState(rawStateForChild, false), {
|
|
28875
28465
|
extensions: forkedExt,
|
|
28876
28466
|
isolated: true,
|
|
28877
28467
|
_readOnlyStage: true
|
|
28878
28468
|
}) : tryCloneStateSync(state) ?? await cloneState(state, this.signal);
|
|
28879
|
-
preparedChild = child;
|
|
28880
|
-
child.variables.BASH_SUBSHELL = String(Number(state.variables.BASH_SUBSHELL ?? 0) + 1);
|
|
28881
|
-
if (!child._readOnlyStage) {
|
|
28469
|
+
preparedChild = inCurrentShell ? void 0 : child;
|
|
28470
|
+
if (!inCurrentShell) child.variables.BASH_SUBSHELL = String(Number(state.variables.BASH_SUBSHELL ?? 0) + 1);
|
|
28471
|
+
if (!inCurrentShell && !child._readOnlyStage) {
|
|
28882
28472
|
child.extensions = void 0;
|
|
28883
28473
|
child.extensions = forkExtensions(state.extensions, "pipeline");
|
|
28884
28474
|
child.isolated = true;
|
|
@@ -28920,7 +28510,7 @@ ${s1}
|
|
|
28920
28510
|
await installation;
|
|
28921
28511
|
signal.throwIfAborted();
|
|
28922
28512
|
}
|
|
28923
|
-
const work = runtime.runPipelineStageWork(command, child, childIO, io, (reason) => {
|
|
28513
|
+
const work = inCurrentShell ? runtime.command(command, child, { ...childIO, terminal: void 0 }) : runtime.runPipelineStageWork(command, child, childIO, io, (reason) => {
|
|
28924
28514
|
checkpointFailure = reason;
|
|
28925
28515
|
});
|
|
28926
28516
|
preparedChild = void 0;
|
|
@@ -29210,6 +28800,7 @@ ${s1}
|
|
|
29210
28800
|
return status;
|
|
29211
28801
|
}
|
|
29212
28802
|
async executeCommand(command, state, originalIO, fileShortcut = false) {
|
|
28803
|
+
originalIO = this.persistentIO(state, originalIO);
|
|
29213
28804
|
const terminal = originalIO.terminal?.target === command ? originalIO.terminal : void 0;
|
|
29214
28805
|
if (!state._readOnlyStage) state = trackState(state, this.budget, originalIO[invocationScope]);
|
|
29215
28806
|
if (originalIO.asyncDefaultInput) {
|
|
@@ -29533,6 +29124,18 @@ ${s1}
|
|
|
29533
29124
|
let diagnosticFailure;
|
|
29534
29125
|
let outputTracker;
|
|
29535
29126
|
const snapshotHolder = {};
|
|
29127
|
+
const execState = stateMonitor(state)?.raw ?? state;
|
|
29128
|
+
const savedExecDescriptors = /* @__PURE__ */ new Map();
|
|
29129
|
+
if (command.redirects.length) {
|
|
29130
|
+
const frame = execDescriptorFrames.get(execState);
|
|
29131
|
+
for (const redirect of command.redirects) {
|
|
29132
|
+
for (const number2 of redirect.operator === "&>" || redirect.operator === "&>>" ? [1, 2] : [redirect.descriptor]) {
|
|
29133
|
+
if (savedExecDescriptors.has(number2)) continue;
|
|
29134
|
+
const descriptor = originalIO.descriptors?.get(number2) ?? (number2 === 0 ? { input: originalIO.stdin } : number2 === 1 ? { output: originalIO.stdout } : number2 === 2 ? { output: originalIO.stderr } : { closed: true });
|
|
29135
|
+
savedExecDescriptors.set(number2, { descriptor, revision: frame?.revisions.get(number2), release: descriptor.lifetime?.acquire() });
|
|
29136
|
+
}
|
|
29137
|
+
}
|
|
29138
|
+
}
|
|
29536
29139
|
try {
|
|
29537
29140
|
let status = 0;
|
|
29538
29141
|
if (command.kind === "simple") {
|
|
@@ -29560,11 +29163,28 @@ ${s1}
|
|
|
29560
29163
|
return errResult.status;
|
|
29561
29164
|
} finally {
|
|
29562
29165
|
try {
|
|
29563
|
-
|
|
29564
|
-
|
|
29166
|
+
const frame = execDescriptorFrames.get(execState);
|
|
29167
|
+
const retirements = [];
|
|
29168
|
+
for (const [number2, saved] of savedExecDescriptors) {
|
|
29169
|
+
if (frame && !snapshotHolder.persistentRedirects && frame.revisions.get(number2) !== saved.revision) {
|
|
29170
|
+
const release = frame.releases.get(number2);
|
|
29171
|
+
if (saved.release) frame.releases.set(number2, saved.release);
|
|
29172
|
+
else frame.releases.delete(number2);
|
|
29173
|
+
frame.descriptors.set(number2, saved.descriptor);
|
|
29174
|
+
frame.revisions.set(number2, ++frame.version);
|
|
29175
|
+
if (release) retirements.push(release());
|
|
29176
|
+
} else if (saved.release) retirements.push(saved.release());
|
|
29177
|
+
}
|
|
29178
|
+
const retired = await Promise.allSettled(retirements);
|
|
29179
|
+
throwCleanupFailures(retired.filter((result) => result.status === "rejected").map((result) => result.reason));
|
|
29565
29180
|
} finally {
|
|
29566
|
-
|
|
29567
|
-
|
|
29181
|
+
try {
|
|
29182
|
+
if (!references && outputs.size === 0 && inputs.size === 0 && processSubstitutions.length === 0) allocation.close();
|
|
29183
|
+
else await this.cleanupCommandResources(references, outputs, inputs, processSubstitutions, allocation, diagnosticFailure, io);
|
|
29184
|
+
} finally {
|
|
29185
|
+
snapshotHolder.finish?.();
|
|
29186
|
+
if (snapshotHolder.scope) await snapshotHolder.scope.close();
|
|
29187
|
+
}
|
|
29568
29188
|
}
|
|
29569
29189
|
}
|
|
29570
29190
|
}
|
|
@@ -29771,7 +29391,7 @@ ${s1}
|
|
|
29771
29391
|
}
|
|
29772
29392
|
}
|
|
29773
29393
|
if (!matched) continue;
|
|
29774
|
-
|
|
29394
|
+
status = clause.body.lists.length ? await this.script(clause.body, state, io) : 0;
|
|
29775
29395
|
if (clause.terminator === ";;" || clause.terminator === "esac") break;
|
|
29776
29396
|
fallthrough = clause.terminator === ";&";
|
|
29777
29397
|
}
|
|
@@ -29792,7 +29412,7 @@ ${s1}
|
|
|
29792
29412
|
}
|
|
29793
29413
|
}
|
|
29794
29414
|
if (!matched) continue;
|
|
29795
|
-
|
|
29415
|
+
status = clause.body.lists.length ? await this.script(clause.body, state, io) : 0;
|
|
29796
29416
|
if (clause.terminator === ";;" || clause.terminator === "esac") break;
|
|
29797
29417
|
fallthrough = clause.terminator === ";&";
|
|
29798
29418
|
}
|
|
@@ -30062,6 +29682,7 @@ ${s1}
|
|
|
30062
29682
|
publicDiagnosticMessage(failure, this.budget.onInternalError);
|
|
30063
29683
|
}
|
|
30064
29684
|
}
|
|
29685
|
+
if (error instanceof FailglobFailure) throw completedExit(1, state.errexit ? "exit" : "discard");
|
|
30065
29686
|
if (error instanceof ExpansionFailure || error instanceof BraceExpansionFailure) throw completedExit(error instanceof ParameterExpansionFailure && !state.isolated ? 127 : 1);
|
|
30066
29687
|
if (error instanceof FatalCommandFailure) throw completedExit(error.status);
|
|
30067
29688
|
if (error instanceof DiscardCommandFailure) throw completedExit(error.status, "discard");
|
|
@@ -30165,6 +29786,8 @@ ${s1}
|
|
|
30165
29786
|
const descriptor = descriptors.get(0)?.closed ? void 0 : descriptors.get(0);
|
|
30166
29787
|
const stdinIsDefault = descriptor?.input ? descriptor.stdinIsDefault : false;
|
|
30167
29788
|
return {
|
|
29789
|
+
...io.execVersion === void 0 ? {} : { execVersion: io.execVersion },
|
|
29790
|
+
...io.execFrame === void 0 ? {} : { execFrame: io.execFrame },
|
|
30168
29791
|
capabilities: io.capabilities,
|
|
30169
29792
|
...io.argv0 === void 0 ? {} : { argv0: io.argv0 },
|
|
30170
29793
|
[invocationScope]: io[invocationScope],
|
|
@@ -30292,7 +29915,16 @@ ${s1}
|
|
|
30292
29915
|
await replaceDescriptor(redirect.descriptor, { input, stdinIsDefault: false, lifetime, ...file ? { file } : {}, ...output ? { output } : {} });
|
|
30293
29916
|
} else {
|
|
30294
29917
|
const append = redirect.operator === ">>" || redirect.operator === "&>>";
|
|
30295
|
-
|
|
29918
|
+
let flag = append ? "a" : state.noclobber && redirect.operator !== ">|" ? "wx" : "w";
|
|
29919
|
+
if (flag === "wx") {
|
|
29920
|
+
try {
|
|
29921
|
+
const stat = await resourceFs.stat(path, options);
|
|
29922
|
+
if (stat.type !== "file" && stat.type !== "directory") flag = "w";
|
|
29923
|
+
} catch (error) {
|
|
29924
|
+
this.signal.throwIfAborted();
|
|
29925
|
+
if (!(error instanceof FsError) || error.code !== "ENOENT") throw error;
|
|
29926
|
+
}
|
|
29927
|
+
}
|
|
30296
29928
|
const capabilities = await this.fs.capabilitiesFor?.(path, { ...options, ...flag === "wx" ? { creation: "exclusive" } : {} }) ?? this.fs.capabilities;
|
|
30297
29929
|
const streaming = capabilities.preferStreamingRedirection === true && typeof this.fs.writeStream === "function" && (append ? capabilities.streamingAppend ?? capabilities.streamingWrite : capabilities.streamingWrite) === true;
|
|
30298
29930
|
const canonical = capabilities.open === true && !streaming;
|
|
@@ -30714,6 +30346,29 @@ ${s1}
|
|
|
30714
30346
|
}
|
|
30715
30347
|
}
|
|
30716
30348
|
if (!words.length) return state.substitutionStatus;
|
|
30349
|
+
if (words[declarationIndex] === "exec" && !functionCommand && !state.extensions?.builtins.has("exec")) {
|
|
30350
|
+
snapshotHolder.persistentRedirects = true;
|
|
30351
|
+
const raw = stateMonitor(state)?.raw ?? state;
|
|
30352
|
+
let frame = execDescriptorFrames.get(raw);
|
|
30353
|
+
if (!frame) {
|
|
30354
|
+
frame = { version: 0, descriptors: /* @__PURE__ */ new Map(), revisions: /* @__PURE__ */ new Map(), releases: /* @__PURE__ */ new Map() };
|
|
30355
|
+
execDescriptorFrames.set(raw, frame);
|
|
30356
|
+
this.budget.executionCleanup.register(() => closeExecDescriptors(raw));
|
|
30357
|
+
}
|
|
30358
|
+
for (const redirect of command.redirects) {
|
|
30359
|
+
const numbers = redirect.operator === "&>" || redirect.operator === "&>>" ? [1, 2] : [redirect.descriptor];
|
|
30360
|
+
for (const number2 of numbers) {
|
|
30361
|
+
const descriptor = io.descriptors?.get(number2) ?? { closed: true };
|
|
30362
|
+
const release = descriptor.lifetime?.acquire();
|
|
30363
|
+
const previousRelease = frame.releases.get(number2);
|
|
30364
|
+
if (release) frame.releases.set(number2, release);
|
|
30365
|
+
else frame.releases.delete(number2);
|
|
30366
|
+
frame.descriptors.set(number2, descriptor);
|
|
30367
|
+
frame.revisions.set(number2, ++frame.version);
|
|
30368
|
+
await previousRelease?.();
|
|
30369
|
+
}
|
|
30370
|
+
}
|
|
30371
|
+
}
|
|
30717
30372
|
const args = words.slice(1);
|
|
30718
30373
|
const argValues = allStrings ? args : wordValues.slice(1);
|
|
30719
30374
|
const dispatchIO = compounds ? { ...io, [declarationArrays]: compounds } : io;
|
|
@@ -30833,7 +30488,7 @@ ${s1}
|
|
|
30833
30488
|
if (body) env[`BASH_FUNC_${key}%%`] = functionDisplay(key, body).slice(key.length + 1).trimEnd();
|
|
30834
30489
|
}
|
|
30835
30490
|
}
|
|
30836
|
-
const context = new FastShellCommandContext(this, state, io, scope, name2, values, void 0, env, this._isMemoryBackingFs);
|
|
30491
|
+
const context = new FastShellCommandContext(this, state, io, scope, name2, values, void 0, env, this._isMemoryBackingFs, definition);
|
|
30837
30492
|
const runtimeFrame = {};
|
|
30838
30493
|
scope.enterWork();
|
|
30839
30494
|
this.budget.beginPathLookupSuspension();
|
|
@@ -31527,6 +31182,37 @@ ${s1}
|
|
|
31527
31182
|
state.lastArgument = context2.args.at(-1) ?? context2.command;
|
|
31528
31183
|
return { exitCode };
|
|
31529
31184
|
}
|
|
31185
|
+
if (context2.command === "exec") {
|
|
31186
|
+
let execIdx = 0;
|
|
31187
|
+
while (execIdx < context2.args.length) {
|
|
31188
|
+
const f = context2.args[execIdx];
|
|
31189
|
+
if (f === "--") {
|
|
31190
|
+
execIdx += 1;
|
|
31191
|
+
break;
|
|
31192
|
+
}
|
|
31193
|
+
if (f === "-a" && execIdx + 1 < context2.args.length) {
|
|
31194
|
+
execIdx += 2;
|
|
31195
|
+
continue;
|
|
31196
|
+
}
|
|
31197
|
+
if (f === "-c" || f === "-l") {
|
|
31198
|
+
execIdx += 1;
|
|
31199
|
+
continue;
|
|
31200
|
+
}
|
|
31201
|
+
break;
|
|
31202
|
+
}
|
|
31203
|
+
const execRest = context2.args.slice(execIdx);
|
|
31204
|
+
const execCmd = execRest[0];
|
|
31205
|
+
if (execCmd === void 0) {
|
|
31206
|
+
return { exitCode: 0 };
|
|
31207
|
+
}
|
|
31208
|
+
const execArgs = execRest.slice(1);
|
|
31209
|
+
const status = await this.dispatch(execCmd, execArgs, state, { ...io, ...context2 }, assignments2, true, context2.argumentValues.values.slice(execIdx + 1));
|
|
31210
|
+
throw completedExit(status, "exit");
|
|
31211
|
+
}
|
|
31212
|
+
if (context2.command === "read" && context2.args.some((arg) => arg.startsWith("-") && (arg.includes("u") || arg.includes("t")))) {
|
|
31213
|
+
const { executeRead } = await import("./read-builtin-A4QKAT45.js");
|
|
31214
|
+
return { exitCode: await executeRead(true, this.extensionContext(state, { ...io, ...context2 }, context2.command, context2.args, context2.argumentValues.values)) };
|
|
31215
|
+
}
|
|
31530
31216
|
const builtinWork = this.builtin({ ...context2, [declarationArrays]: io[declarationArrays] }, state, assignments2, (error, diagnostic) => {
|
|
31531
31217
|
builtinFailure = { error, diagnostic };
|
|
31532
31218
|
}, bypassFunctions);
|
|
@@ -31924,7 +31610,7 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
|
|
|
31924
31610
|
try {
|
|
31925
31611
|
do {
|
|
31926
31612
|
this.signal.throwIfAborted();
|
|
31927
|
-
const unit = parseShellUnit(source, position, byteLocale(state.variables), this.budget.parsing, lineIndex, void 0, false, state.extensions?.syntax);
|
|
31613
|
+
const unit = parseShellUnit(source, position, byteLocale(state.variables), this.budget.parsing, lineIndex, void 0, false, state.extensions?.syntax, state.expand_aliases ? state.aliases : void 0);
|
|
31928
31614
|
for (const warning of unit.script.warnings ?? []) await writeDiagnostic(io.stderr, `${io.scriptName}: warning: ${warning}
|
|
31929
31615
|
`);
|
|
31930
31616
|
if (unit.script.lists.length) {
|
|
@@ -31965,7 +31651,7 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
|
|
|
31965
31651
|
}
|
|
31966
31652
|
const unitIO = { ...io, diagnosticOffset: offset };
|
|
31967
31653
|
try {
|
|
31968
|
-
const unit = eof ? parseShellUnit(source, 0, byteLocale(state.variables), this.budget.parsing, lineIndex, void 0, false, state.extensions?.syntax) : parseShellInputUnit(source, byteLocale(state.variables), this.budget.parsing, lineIndex, state.extensions?.syntax);
|
|
31654
|
+
const unit = eof ? parseShellUnit(source, 0, byteLocale(state.variables), this.budget.parsing, lineIndex, void 0, false, state.extensions?.syntax, state.expand_aliases ? state.aliases : void 0) : parseShellInputUnit(source, byteLocale(state.variables), this.budget.parsing, lineIndex, state.extensions?.syntax, state.expand_aliases ? state.aliases : void 0);
|
|
31969
31655
|
if (unit) {
|
|
31970
31656
|
for (const warning of unit.script.warnings ?? []) await writeDiagnostic(io.stderr, `${io.scriptName}: warning: ${warning}
|
|
31971
31657
|
`);
|
|
@@ -32214,7 +31900,8 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
|
|
|
32214
31900
|
else {
|
|
32215
31901
|
const options2 = { signal: this.signal };
|
|
32216
31902
|
const stat = await interruptible2(this.fs.stat(path, options2), this.signal);
|
|
32217
|
-
if (stat.type
|
|
31903
|
+
if (stat.type === "directory") throw new CommandFailure(`${target}: Is a directory`, 126);
|
|
31904
|
+
if (stat.type !== "file" && (direct || stat.type !== "character" && stat.type !== "fifo")) throw new CommandFailure(`${target}: not a regular file`, 126);
|
|
32218
31905
|
if (direct) {
|
|
32219
31906
|
const capabilities = this.fs.capabilitiesFor ? await interruptible2(this.fs.capabilitiesFor(path, options2), this.signal) : this.fs.capabilities;
|
|
32220
31907
|
if (capabilities.permissions !== true) throw new CommandFailure(`${target}: execution permissions are not supported by this filesystem`, 126);
|
|
@@ -32285,7 +31972,7 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
|
|
|
32285
31972
|
this.signal.throwIfAborted();
|
|
32286
31973
|
let unit;
|
|
32287
31974
|
try {
|
|
32288
|
-
unit = parseShellUnit(source, position, byteLocale(child.variables), this.budget.parsing, lineIndex, void 0, false, child.extensions?.syntax);
|
|
31975
|
+
unit = parseShellUnit(source, position, byteLocale(child.variables), this.budget.parsing, lineIndex, void 0, false, child.extensions?.syntax, child.expand_aliases ? child.aliases : void 0);
|
|
32289
31976
|
} catch (error) {
|
|
32290
31977
|
if (!(error instanceof ShellSyntaxError)) throw error;
|
|
32291
31978
|
await writeDiagnostic(context.stderr, `${target}: line ${lineIndex.lineAt(error.offset)}: syntax error: ${error.reason}
|
|
@@ -32308,7 +31995,7 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
|
|
|
32308
31995
|
}
|
|
32309
31996
|
}
|
|
32310
31997
|
async runCurrentText(source, state, io, fatalSyntax, syntaxName, byteSource = false, includeSyntaxContext = true, sourceValues) {
|
|
32311
|
-
if (!sourceValues && !byteSource && isDefaultShellSyntax(state.extensions?.syntax) && source.length <= 4096) {
|
|
31998
|
+
if (!state.expand_aliases && !sourceValues && !byteSource && isDefaultShellSyntax(state.extensions?.syntax) && source.length <= 4096) {
|
|
32312
31999
|
try {
|
|
32313
32000
|
const cachedUnit = getOrParseSingleEvalUnit(source, byteLocale(state.variables), this.budget.parsing);
|
|
32314
32001
|
if (cachedUnit) {
|
|
@@ -32335,7 +32022,7 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
|
|
|
32335
32022
|
try {
|
|
32336
32023
|
do {
|
|
32337
32024
|
this.signal.throwIfAborted();
|
|
32338
|
-
const unit = parseShellUnit(source, position, byteLocale(state.variables), this.budget.parsing, lineIndex, sourceValues, byteSource, state.extensions?.syntax);
|
|
32025
|
+
const unit = parseShellUnit(source, position, byteLocale(state.variables), this.budget.parsing, lineIndex, sourceValues, byteSource, state.extensions?.syntax, state.expand_aliases ? state.aliases : void 0);
|
|
32339
32026
|
for (const warning of unit.script.warnings ?? []) await writeDiagnostic(io.stderr, `${io.scriptName ?? "shell"}: warning: ${warning}
|
|
32340
32027
|
`);
|
|
32341
32028
|
if (unit.script.lists.length) {
|
|
@@ -32438,7 +32125,7 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
|
|
|
32438
32125
|
const path = pathOf(state, target);
|
|
32439
32126
|
const stat = await interruptible2(this.fs.stat(path, options), this.signal);
|
|
32440
32127
|
if (stat.type === "directory") throw new CommandFailure(`${context.command}: ${target}: is a directory`, 1);
|
|
32441
|
-
if (stat.type !== "file") throw new CommandFailure(`${target}: not a regular file`, 1);
|
|
32128
|
+
if (stat.type !== "file" && stat.type !== "character" && stat.type !== "fifo") throw new CommandFailure(`${target}: not a regular file`, 1);
|
|
32442
32129
|
await interruptible2(this.fs.access(path, ACCESS_MODES.R_OK, options), this.signal);
|
|
32443
32130
|
const maxBytes = this.budget.limits.maxSourceBytes - this.budget.sourceBytes;
|
|
32444
32131
|
if (stat.size > maxBytes) this.budget.fail("maxSourceBytes");
|
|
@@ -33079,7 +32766,7 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
|
|
|
33079
32766
|
return 1;
|
|
33080
32767
|
}
|
|
33081
32768
|
const options = /* @__PURE__ */ new Map();
|
|
33082
|
-
for (const name2 of setNamespace ? ["allexport", "braceexpand", "errexit", "noclobber", "noexec", "noglob", "nounset", "pipefail"] : ["dotglob", "extglob", "globstar", "nocaseglob", "nocasematch", "nullglob"]) {
|
|
32769
|
+
for (const name2 of setNamespace ? ["allexport", "braceexpand", "errexit", "noclobber", "noexec", "noglob", "nounset", "pipefail"] : ["dotglob", "expand_aliases", "extglob", "failglob", "globstar", "inherit_errexit", "lastpipe", "nocaseglob", "nocasematch", "nullglob"]) {
|
|
33083
32770
|
options.set(name2, {
|
|
33084
32771
|
get enabled() {
|
|
33085
32772
|
return name2 === "braceexpand" ? state.braceexpand !== false : !!state[name2];
|
|
@@ -33492,6 +33179,12 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
|
|
|
33492
33179
|
return status;
|
|
33493
33180
|
}
|
|
33494
33181
|
if (command === "shopt") return this.shoptBuiltin(context, state);
|
|
33182
|
+
if (command === "alias" || command === "unalias") {
|
|
33183
|
+
const aliases = state.aliases ??= /* @__PURE__ */ new Map();
|
|
33184
|
+
const limits = { maxArgumentBytes: this.budget.limits.maxExpansionBytes, maxAliasBytes: this.budget.limits.maxExpansionBytes };
|
|
33185
|
+
const definition = command === "alias" ? createAliasCommand({ aliases, limits }) : createUnaliasCommand({ aliases, limits });
|
|
33186
|
+
return (await definition.execute(context)).exitCode;
|
|
33187
|
+
}
|
|
33495
33188
|
if (command === "let") return this.letBuiltin(context, state);
|
|
33496
33189
|
if (command === "mapfile" || command === "readarray") return this.mapfileBuiltin(context, state);
|
|
33497
33190
|
if (command === "getopts") return this.getoptsBuiltin(context, state);
|
|
@@ -34379,6 +34072,7 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
|
|
|
34379
34072
|
}
|
|
34380
34073
|
if (command === "break" || command === "continue") {
|
|
34381
34074
|
if (!state.loopDepth) {
|
|
34075
|
+
if (state._subshellInLoop) throw completedExit(0, command, 1);
|
|
34382
34076
|
await writeDiagnostic(stderr, `${command}: only meaningful in a loop
|
|
34383
34077
|
`);
|
|
34384
34078
|
return 0;
|
|
@@ -34583,7 +34277,7 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
|
|
|
34583
34277
|
const operator = part.operator.at(-1);
|
|
34584
34278
|
if (operator === "+" ? !missing : missing) {
|
|
34585
34279
|
if (operator === "=") throw new ArrayFailure(`${part.name}[${memberSelector.separator}]: bad array subscript`);
|
|
34586
|
-
const alternate = concatShellValues(await this.valueWord(part.alternate, state, this.parameterOperandIO(part.alternate, state, io), false, false, hereString, false, void 0, hereDocument), io[valueScope]);
|
|
34280
|
+
const alternate = concatShellValues(await this.valueWord(part.alternate, state, this.parameterOperandIO(part.alternate, state, io), false, false, hereString, false, void 0, hereDocument || part.quoted), io[valueScope]);
|
|
34587
34281
|
if (operator === "?") throw new ParameterExpansionFailure(`${part.name}: ${shellValueText(alternate) || "parameter not set"}`, io.diagnosticLine ?? part.line);
|
|
34588
34282
|
return alternate;
|
|
34589
34283
|
}
|
|
@@ -34601,12 +34295,13 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
|
|
|
34601
34295
|
if (operator === "+" ? !missing : missing) {
|
|
34602
34296
|
const operandIO = this.parameterOperandIO(part.alternate, state, io);
|
|
34603
34297
|
if (operator === "=") {
|
|
34604
|
-
|
|
34298
|
+
const elemAlt = part.quoted ? { ...part.alternate, parts: part.alternate.parts.map((p) => ({ ...p, quoted: true })) } : part.alternate;
|
|
34299
|
+
await this.arrayAssignment({ kind: "element", name: part.name, index: element.index, append: false, value: elemAlt }, state, operandIO);
|
|
34605
34300
|
const assigned = store.get(part.name);
|
|
34606
34301
|
const assignedIndex = assigned.associative ? await this.arrayIndex(assigned, element.index, state, io, store.owner) : index2;
|
|
34607
34302
|
return assignedIndex === void 0 ? "" : assigned.getValue(assignedIndex) ?? "";
|
|
34608
34303
|
}
|
|
34609
|
-
const alternate = concatShellValues(await this.valueWord(part.alternate, state, operandIO, false, false, hereString, false, void 0, hereDocument), io[valueScope]);
|
|
34304
|
+
const alternate = concatShellValues(await this.valueWord(part.alternate, state, operandIO, false, false, hereString, false, void 0, hereDocument || part.quoted), io[valueScope]);
|
|
34610
34305
|
if (operator === "?") throw new ParameterExpansionFailure(`${part.name}: ${shellValueText(alternate) || (part.operator.startsWith(":") ? "parameter null or not set" : "parameter not set")}`, io.diagnosticLine ?? part.line);
|
|
34611
34306
|
return alternate;
|
|
34612
34307
|
}
|
|
@@ -34808,13 +34503,29 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
|
|
|
34808
34503
|
if (part.kind === "process-substitution") {
|
|
34809
34504
|
if (state.depth >= this.budget.limits.maxSubstitutionDepth) this.budget.fail("maxSubstitutionDepth");
|
|
34810
34505
|
this.signal.throwIfAborted();
|
|
34811
|
-
const
|
|
34506
|
+
const ids = state.processSubstitutionIds ??= { next: 0 };
|
|
34507
|
+
const requestedDirectory = pathOf(state, state.variables.TMPDIR || "/tmp");
|
|
34508
|
+
const directory = requestedDirectory === "/" ? "/tmp" : requestedDirectory;
|
|
34509
|
+
await this.sourceFs.mkdir(directory, { recursive: true, signal: this.signal });
|
|
34510
|
+
let tempPath = "";
|
|
34511
|
+
let owned = false;
|
|
34812
34512
|
io[invocationScope].register(async () => {
|
|
34813
|
-
try {
|
|
34513
|
+
if (owned) try {
|
|
34814
34514
|
await this.sourceFs.rm(tempPath, { force: true });
|
|
34815
34515
|
} catch {
|
|
34816
34516
|
}
|
|
34817
34517
|
});
|
|
34518
|
+
while (!owned) {
|
|
34519
|
+
this.budget.tick();
|
|
34520
|
+
tempPath = pathOf(state, `${directory}/.procsub-${++ids.next}`);
|
|
34521
|
+
try {
|
|
34522
|
+
await this.sourceFs.writeFile(tempPath, new Uint8Array(0), { flag: "wx", signal: this.signal });
|
|
34523
|
+
owned = true;
|
|
34524
|
+
} catch (error) {
|
|
34525
|
+
this.signal.throwIfAborted();
|
|
34526
|
+
if (!(error instanceof FsError) || error.code !== "EEXIST") throw error;
|
|
34527
|
+
}
|
|
34528
|
+
}
|
|
34818
34529
|
if (part.direction === "<") {
|
|
34819
34530
|
const capture = new Capture();
|
|
34820
34531
|
const child = await cloneState(state, this.signal);
|
|
@@ -34824,7 +34535,6 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
|
|
|
34824
34535
|
if (state.profile !== "sh") child.errexit = false;
|
|
34825
34536
|
delete child.redirectAssignments;
|
|
34826
34537
|
child.depth++;
|
|
34827
|
-
child.loopDepth = 0;
|
|
34828
34538
|
const references = new PipeDescriptorFrame(io[invocationScope]);
|
|
34829
34539
|
const lifetime = new DescriptorLifetime();
|
|
34830
34540
|
const captureIO = isolateIO({
|
|
@@ -34873,7 +34583,6 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
|
|
|
34873
34583
|
if (state.profile !== "sh") child.errexit = false;
|
|
34874
34584
|
delete child.redirectAssignments;
|
|
34875
34585
|
child.depth++;
|
|
34876
|
-
child.loopDepth = 0;
|
|
34877
34586
|
const prepared = prepareBytesInput(bytes, this.budget);
|
|
34878
34587
|
const input = new ShellInput(prepared.source, this.budget, this.commandSignal, prepared.options);
|
|
34879
34588
|
const lifetime = new DescriptorLifetime(async () => {
|
|
@@ -34917,14 +34626,13 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
|
|
|
34917
34626
|
child.isolated = true;
|
|
34918
34627
|
child.variables.BASH_SUBSHELL = String(Number(state.variables.BASH_SUBSHELL ?? 0) + 1);
|
|
34919
34628
|
child.extensions = forkExtensions(state.extensions, "substitution");
|
|
34920
|
-
if (state.profile !== "sh") child.errexit = false;
|
|
34629
|
+
if (state.profile !== "sh" && !state.inherit_errexit) child.errexit = false;
|
|
34921
34630
|
for (const [name2, value2] of state.redirectAssignments ?? []) {
|
|
34922
34631
|
await this.writeVariable(child, name2, value2, io);
|
|
34923
34632
|
child.exported.add(name2);
|
|
34924
34633
|
}
|
|
34925
34634
|
delete child.redirectAssignments;
|
|
34926
34635
|
child.depth++;
|
|
34927
|
-
child.loopDepth = 0;
|
|
34928
34636
|
const pipeline = part.script.lists.length === 1 && part.script.lists[0].pipelines.length === 1 ? part.script.lists[0].pipelines[0] : void 0;
|
|
34929
34637
|
const command = pipeline && !pipeline.negate && pipeline.commands.length === 1 ? pipeline.commands[0] : void 0;
|
|
34930
34638
|
const fileShortcut = command?.kind === "simple" && command.words.length === 0 && command.redirects.length === 1 && command.redirects[0].operator === "<";
|
|
@@ -35045,16 +34753,17 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
|
|
|
35045
34753
|
if (operator === "+" && !missing || operator !== "+" && missing) {
|
|
35046
34754
|
const operandIO = this.parameterOperandIO(part.alternate, state, io);
|
|
35047
34755
|
let alternate;
|
|
34756
|
+
const altWord = !hereDocument && !part.quoted && operator === "=" ? { ...part.alternate, parts: expandTildes(part.alternate.parts, state.variables, this.budget, void 0, true) } : part.alternate;
|
|
35048
34757
|
if (operator === "=" && arrayStore(state)?.get(part.name)) {
|
|
35049
34758
|
alternate = "";
|
|
35050
34759
|
await this.arrayZero(state, part.name, io, async () => {
|
|
35051
|
-
retained = await this.arrayJoin(requireArrays(state).owner, await this.valueWord(
|
|
34760
|
+
retained = await this.arrayJoin(requireArrays(state).owner, await this.valueWord(altWord, state, operandIO, false, false, hereString, false, void 0, hereDocument || part.quoted || operator === "="), "");
|
|
35052
34761
|
return retained;
|
|
35053
34762
|
});
|
|
35054
34763
|
value = shellValueText(retained);
|
|
35055
34764
|
return part.length ? this.valueLength(retained, state, io) : retained;
|
|
35056
34765
|
}
|
|
35057
|
-
retained = concatShellValues(await this.valueWord(
|
|
34766
|
+
retained = concatShellValues(await this.valueWord(altWord, state, operandIO, false, false, hereString, false, void 0, hereDocument || part.quoted || operator === "="), io[valueScope]);
|
|
35058
34767
|
alternate = shellValueText(retained);
|
|
35059
34768
|
if (operator === "?") throw new ParameterExpansionFailure(`${part.name}: ${alternate || (part.operator.startsWith(":") ? "parameter null or not set" : "parameter not set")}`, io.diagnosticLine ?? part.line);
|
|
35060
34769
|
if (operator === "=") {
|
|
@@ -35506,7 +35215,7 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
|
|
|
35506
35215
|
continue;
|
|
35507
35216
|
}
|
|
35508
35217
|
if (part.indirect || part.specialParameter) return void 0;
|
|
35509
|
-
if (part.name === "@" || part.name === "*" || part.name === "PIPESTATUS" || part.name === "LINENO" || part.name === "BASH_SUBSHELL" || part.name === "_" || part.name === "FUNCNAME" || part.name === "DIRSTACK") return void 0;
|
|
35218
|
+
if (part.name === "@" || part.name === "*" || part.name === "PIPESTATUS" || part.name === "LINENO" || part.name === "BASH_SUBSHELL" || part.name === "BASHPID" || part.name === "_" || part.name === "FUNCNAME" || part.name === "DIRSTACK") return void 0;
|
|
35510
35219
|
if (!isShellIdentifier(part.name)) return void 0;
|
|
35511
35220
|
const selector = getArraySelector(part);
|
|
35512
35221
|
const arrayBinding = activeArrayStore?.get(part.name);
|
|
@@ -43107,7 +42816,7 @@ unsigned int ${ident}_len = ${view.byteLength};
|
|
|
43107
42816
|
const p = word.parts[i];
|
|
43108
42817
|
if (p.kind === "text") continue;
|
|
43109
42818
|
if (p.kind === "variable") {
|
|
43110
|
-
if (p.name === "BASH_SUBSHELL" || p.name === "RANDOM" || p.name === "SECONDS") return false;
|
|
42819
|
+
if (p.name === "BASH_SUBSHELL" || p.name === "BASHPID" || p.name === "RANDOM" || p.name === "SECONDS") return false;
|
|
43111
42820
|
if (!p.indirect && !p.prefixNames && !p.length && !p.substring && !p.transform && p.operator === void 0 && getArraySelector(p) === void 0 && (p.name === "?" || p.name === "#" || p.name.length === 1 && p.name >= "1" && p.name <= "9")) {
|
|
43112
42821
|
const activePos = this._fastSubPositional ?? rawState.positional;
|
|
43113
42822
|
if (rawState.nounset && p.name >= "1" && p.name <= "9" && activePos[p.name.charCodeAt(0) - 49] === void 0) return false;
|
|
@@ -43166,7 +42875,7 @@ unsigned int ${ident}_len = ${view.byteLength};
|
|
|
43166
42875
|
const definition = this.commands.get(name2);
|
|
43167
42876
|
if (definition && customRegisteredCommands.has(definition.execute)) return void 0;
|
|
43168
42877
|
if (name2 === "uname" || name2 === "nproc" || name2 === "hostname" || name2 === "id" || name2 === "whoami") {
|
|
43169
|
-
if (!definition || !
|
|
42878
|
+
if (!definition || !builtInDirectContextExecutors2.has(definition.execute)) return void 0;
|
|
43170
42879
|
}
|
|
43171
42880
|
}
|
|
43172
42881
|
if (pipeline.commands.length >= 2 && pipeline.commands.length <= 5) {
|
|
@@ -43187,7 +42896,7 @@ unsigned int ${ident}_len = ${view.byteLength};
|
|
|
43187
42896
|
if (cmd0HereStringRedir && w0Plain0 === "cat" && cmd0.words.length !== 1) return void 0;
|
|
43188
42897
|
if (!cmd0StdinRedir && !cmd0HereStringRedir && w0Plain0 === "cat" && cmd0.words.length < 2) return void 0;
|
|
43189
42898
|
const def0 = this.commands.get(w0Plain0);
|
|
43190
|
-
if (!def0 || (w0Plain0 === "printf" ? def0.execute !== printfCommand.execute : w0Plain0 === "echo" ? !defaultEchoExecutors.has(def0.execute) : w0Plain0 === "cat" || w0Plain0 === "seq" || cmd0YesStage || cmd0SysStage || cmd0StdinRedir || cmd0HereStringRedir || cmd0FileStage ? w0Plain0 !== "rev" && w0Plain0 !== "tac" && w0Plain0 !== "nl" && w0Plain0 !== "paste" && w0Plain0 !== "comm" && w0Plain0 !== "join" && w0Plain0 !== "jq" && w0Plain0 !== "strings" && w0Plain0 !== "bc" && w0Plain0 !== "factor" && w0Plain0 !== "tsort" && w0Plain0 !== "envsubst" && w0Plain0 !== "xxd" && w0Plain0 !== "od" && w0Plain0 !== "hexdump" && w0Plain0 !== "hd" && w0Plain0 !== "fmt" && w0Plain0 !== "md5sum" && w0Plain0 !== "sha1sum" && w0Plain0 !== "sha224sum" && w0Plain0 !== "sha256sum" && w0Plain0 !== "sha384sum" && w0Plain0 !== "sha512sum" && w0Plain0 !== "cksum" && w0Plain0 !== "base32" && w0Plain0 !== "base64" && w0Plain0 !== "csvcut" && w0Plain0 !== "csvgrep" && w0Plain0 !== "dos2unix" && w0Plain0 !== "unix2dos" && w0Plain0 !== "iconv" && w0Plain0 !== "gzip" && w0Plain0 !== "gunzip" && w0Plain0 !== "zcat" && w0Plain0 !== "unzstd" && w0Plain0 !== "zstdcat" && w0Plain0 !== "htmlq" && w0Plain0 !== "xmllint" && w0Plain0 !== "xq" && w0Plain0 !== "yq" && w0Plain0 !== "mdq" && w0Plain0 !== "shuf" && w0Plain0 !== "html-to-markdown" && w0Plain0 !== "unrtf" && w0Plain0 !== "pr" && w0Plain0 !== "file" && w0Plain0 !== "diff3" && w0Plain0 !== "cmp" && w0Plain0 !== "which" && w0Plain0 !== "diff" && w0Plain0 !== "xan" && w0Plain0 !== "less" && w0Plain0 !== "more" && w0Plain0 !== "df" && w0Plain0 !== "du" && w0Plain0 !== "tree" && w0Plain0 !== "stat" && w0Plain0 !== "fd" && w0Plain0 !== "rg" && w0Plain0 !== "readlink" && w0Plain0 !== "realpath" && w0Plain0 !== "ls" && w0Plain0 !== "find" && w0Plain0 !== "csvlook" && w0Plain0 !== "csvjson" && w0Plain0 !== "csvsort" && w0Plain0 !== "csvformat" && w0Plain0 !== "csvstat" && w0Plain0 !== "in2csv" && w0Plain0 !== "csvstack" && w0Plain0 !== "csvjoin" && w0Plain0 !== "dd" && w0Plain0 !== "env" && w0Plain0 !== "xargs" && w0Plain0 !== "openssl" && w0Plain0 !== "sqlite3" && w0Plain0 !== "gpg" && w0Plain0 !== "ssh" && w0Plain0 !== "ssh-keygen" && w0Plain0 !== "pdfinfo" && w0Plain0 !== "pdffonts" && w0Plain0 !== "pdftotext" && w0Plain0 !== "pdftohtml" && w0Plain0 !== "exiftool" && w0Plain0 !== "qpdf" && w0Plain0 !== "pdftk" && w0Plain0 !== "sips" && w0Plain0 !== "identify" && w0Plain0 !== "magick" && w0Plain0 !== "convert" && w0Plain0 !== "pdfimages" && w0Plain0 !== "pdfdetach" && w0Plain0 !== "ffprobe" && w0Plain0 !== "ffmpeg" && w0Plain0 !== "gh" && w0Plain0 !== "pdftoppm" && w0Plain0 !== "pdftocairo" && w0Plain0 !== "mmdc" && w0Plain0 !== "pandoc" && w0Plain0 !== "soffice" && w0Plain0 !== "libreoffice" && w0Plain0 !== "ssconvert" && w0Plain0 !== "wkhtmltopdf" && w0Plain0 !== "op" && w0Plain0 !== "date" && w0Plain0 !== "printenv" && w0Plain0 !== "egrep" && w0Plain0 !== "fgrep" && w0Plain0 !== "yes" && w0Plain0 !== "cal" && w0Plain0 !== "ncal" && w0Plain0 !== "expr" && w0Plain0 !== "getopt" && w0Plain0 !== "pathchk" && !
|
|
42899
|
+
if (!def0 || (w0Plain0 === "printf" ? def0.execute !== printfCommand.execute : w0Plain0 === "echo" ? !defaultEchoExecutors.has(def0.execute) : w0Plain0 === "cat" || w0Plain0 === "seq" || cmd0YesStage || cmd0SysStage || cmd0StdinRedir || cmd0HereStringRedir || cmd0FileStage ? w0Plain0 !== "rev" && w0Plain0 !== "tac" && w0Plain0 !== "nl" && w0Plain0 !== "paste" && w0Plain0 !== "comm" && w0Plain0 !== "join" && w0Plain0 !== "jq" && w0Plain0 !== "strings" && w0Plain0 !== "bc" && w0Plain0 !== "factor" && w0Plain0 !== "tsort" && w0Plain0 !== "envsubst" && w0Plain0 !== "xxd" && w0Plain0 !== "od" && w0Plain0 !== "hexdump" && w0Plain0 !== "hd" && w0Plain0 !== "fmt" && w0Plain0 !== "md5sum" && w0Plain0 !== "sha1sum" && w0Plain0 !== "sha224sum" && w0Plain0 !== "sha256sum" && w0Plain0 !== "sha384sum" && w0Plain0 !== "sha512sum" && w0Plain0 !== "cksum" && w0Plain0 !== "base32" && w0Plain0 !== "base64" && w0Plain0 !== "csvcut" && w0Plain0 !== "csvgrep" && w0Plain0 !== "dos2unix" && w0Plain0 !== "unix2dos" && w0Plain0 !== "iconv" && w0Plain0 !== "gzip" && w0Plain0 !== "gunzip" && w0Plain0 !== "zcat" && w0Plain0 !== "unzstd" && w0Plain0 !== "zstdcat" && w0Plain0 !== "htmlq" && w0Plain0 !== "xmllint" && w0Plain0 !== "xq" && w0Plain0 !== "yq" && w0Plain0 !== "mdq" && w0Plain0 !== "shuf" && w0Plain0 !== "html-to-markdown" && w0Plain0 !== "unrtf" && w0Plain0 !== "pr" && w0Plain0 !== "file" && w0Plain0 !== "diff3" && w0Plain0 !== "cmp" && w0Plain0 !== "which" && w0Plain0 !== "diff" && w0Plain0 !== "xan" && w0Plain0 !== "less" && w0Plain0 !== "more" && w0Plain0 !== "df" && w0Plain0 !== "du" && w0Plain0 !== "tree" && w0Plain0 !== "stat" && w0Plain0 !== "fd" && w0Plain0 !== "rg" && w0Plain0 !== "readlink" && w0Plain0 !== "realpath" && w0Plain0 !== "ls" && w0Plain0 !== "find" && w0Plain0 !== "csvlook" && w0Plain0 !== "csvjson" && w0Plain0 !== "csvsort" && w0Plain0 !== "csvformat" && w0Plain0 !== "csvstat" && w0Plain0 !== "in2csv" && w0Plain0 !== "csvstack" && w0Plain0 !== "csvjoin" && w0Plain0 !== "dd" && w0Plain0 !== "env" && w0Plain0 !== "xargs" && w0Plain0 !== "openssl" && w0Plain0 !== "sqlite3" && w0Plain0 !== "gpg" && w0Plain0 !== "ssh" && w0Plain0 !== "ssh-keygen" && w0Plain0 !== "pdfinfo" && w0Plain0 !== "pdffonts" && w0Plain0 !== "pdftotext" && w0Plain0 !== "pdftohtml" && w0Plain0 !== "exiftool" && w0Plain0 !== "qpdf" && w0Plain0 !== "pdftk" && w0Plain0 !== "sips" && w0Plain0 !== "identify" && w0Plain0 !== "magick" && w0Plain0 !== "convert" && w0Plain0 !== "pdfimages" && w0Plain0 !== "pdfdetach" && w0Plain0 !== "ffprobe" && w0Plain0 !== "ffmpeg" && w0Plain0 !== "gh" && w0Plain0 !== "pdftoppm" && w0Plain0 !== "pdftocairo" && w0Plain0 !== "mmdc" && w0Plain0 !== "pandoc" && w0Plain0 !== "soffice" && w0Plain0 !== "libreoffice" && w0Plain0 !== "ssconvert" && w0Plain0 !== "wkhtmltopdf" && w0Plain0 !== "op" && w0Plain0 !== "date" && w0Plain0 !== "printenv" && w0Plain0 !== "egrep" && w0Plain0 !== "fgrep" && w0Plain0 !== "yes" && w0Plain0 !== "cal" && w0Plain0 !== "ncal" && w0Plain0 !== "expr" && w0Plain0 !== "getopt" && w0Plain0 !== "pathchk" && !builtInDirectContextExecutors2.has(def0.execute) : customRegisteredCommands.has(def0.execute) || customRegisteredRegistries.has(this.commands))) return void 0;
|
|
43191
42900
|
if (!this.arePureArgWords(cmd0.words, rawState)) return void 0;
|
|
43192
42901
|
const n = pipeline.commands.length;
|
|
43193
42902
|
const stageDefs = [];
|
|
@@ -43200,8 +42909,8 @@ unsigned int ${ident}_len = ${view.byteLength};
|
|
|
43200
42909
|
const sName = sCmd.words[0].plain;
|
|
43201
42910
|
if (!sName || hasShellFunction(rawState, sName) || rawState.extensions?.builtins.has(sName)) return void 0;
|
|
43202
42911
|
const extDef = this.commands.get(sName);
|
|
43203
|
-
if (!extDef || (sName !== "cat" || startStageIdx === 0) && sName !== "rev" && sName !== "tac" && sName !== "nl" && sName !== "paste" && sName !== "column" && sName !== "fold" && sName !== "expand" && sName !== "unexpand" && sName !== "strings" && sName !== "comm" && sName !== "join" && sName !== "jq" && sName !== "bc" && sName !== "factor" && sName !== "tsort" && sName !== "envsubst" && sName !== "xxd" && sName !== "od" && sName !== "hexdump" && sName !== "hd" && sName !== "fmt" && sName !== "md5sum" && sName !== "sha1sum" && sName !== "sha224sum" && sName !== "sha256sum" && sName !== "sha384sum" && sName !== "sha512sum" && sName !== "cksum" && sName !== "base32" && sName !== "base64" && sName !== "csvcut" && sName !== "csvgrep" && sName !== "dos2unix" && sName !== "unix2dos" && sName !== "iconv" && sName !== "gzip" && sName !== "gunzip" && sName !== "zcat" && sName !== "unzstd" && sName !== "zstdcat" && sName !== "htmlq" && sName !== "xmllint" && sName !== "xq" && sName !== "yq" && sName !== "mdq" && sName !== "shuf" && sName !== "html-to-markdown" && sName !== "unrtf" && sName !== "pr" && sName !== "file" && sName !== "diff3" && sName !== "cmp" && sName !== "which" && sName !== "diff" && sName !== "xan" && sName !== "less" && sName !== "more" && sName !== "df" && sName !== "du" && sName !== "tree" && sName !== "stat" && sName !== "fd" && sName !== "rg" && sName !== "readlink" && sName !== "realpath" && sName !== "ls" && sName !== "find" && sName !== "csvlook" && sName !== "csvjson" && sName !== "csvsort" && sName !== "csvformat" && sName !== "csvstat" && sName !== "in2csv" && sName !== "csvstack" && sName !== "csvjoin" && sName !== "dd" && sName !== "xargs" && sName !== "openssl" && sName !== "sqlite3" && sName !== "gpg" && sName !== "ssh" && sName !== "ssh-keygen" && sName !== "pdfinfo" && sName !== "pdffonts" && sName !== "pdftotext" && sName !== "pdftohtml" && sName !== "exiftool" && sName !== "qpdf" && sName !== "pdftk" && sName !== "sips" && sName !== "identify" && sName !== "magick" && sName !== "convert" && sName !== "pdfimages" && sName !== "pdfdetach" && sName !== "ffprobe" && sName !== "ffmpeg" && sName !== "gh" && sName !== "pdftoppm" && sName !== "pdftocairo" && sName !== "mmdc" && sName !== "pandoc" && sName !== "soffice" && sName !== "libreoffice" && sName !== "ssconvert" && sName !== "wkhtmltopdf" && sName !== "op" && sName !== "date" && sName !== "cal" && sName !== "ncal" && sName !== "getopt" && sName !== "pathchk" && sName !== "printenv" && sName !== "env" && sName !== "egrep" && sName !== "fgrep" && !
|
|
43204
|
-
if ((sName === "xxd" || sName === "od") && !
|
|
42912
|
+
if (!extDef || (sName !== "cat" || startStageIdx === 0) && sName !== "rev" && sName !== "tac" && sName !== "nl" && sName !== "paste" && sName !== "column" && sName !== "fold" && sName !== "expand" && sName !== "unexpand" && sName !== "strings" && sName !== "comm" && sName !== "join" && sName !== "jq" && sName !== "bc" && sName !== "factor" && sName !== "tsort" && sName !== "envsubst" && sName !== "xxd" && sName !== "od" && sName !== "hexdump" && sName !== "hd" && sName !== "fmt" && sName !== "md5sum" && sName !== "sha1sum" && sName !== "sha224sum" && sName !== "sha256sum" && sName !== "sha384sum" && sName !== "sha512sum" && sName !== "cksum" && sName !== "base32" && sName !== "base64" && sName !== "csvcut" && sName !== "csvgrep" && sName !== "dos2unix" && sName !== "unix2dos" && sName !== "iconv" && sName !== "gzip" && sName !== "gunzip" && sName !== "zcat" && sName !== "unzstd" && sName !== "zstdcat" && sName !== "htmlq" && sName !== "xmllint" && sName !== "xq" && sName !== "yq" && sName !== "mdq" && sName !== "shuf" && sName !== "html-to-markdown" && sName !== "unrtf" && sName !== "pr" && sName !== "file" && sName !== "diff3" && sName !== "cmp" && sName !== "which" && sName !== "diff" && sName !== "xan" && sName !== "less" && sName !== "more" && sName !== "df" && sName !== "du" && sName !== "tree" && sName !== "stat" && sName !== "fd" && sName !== "rg" && sName !== "readlink" && sName !== "realpath" && sName !== "ls" && sName !== "find" && sName !== "csvlook" && sName !== "csvjson" && sName !== "csvsort" && sName !== "csvformat" && sName !== "csvstat" && sName !== "in2csv" && sName !== "csvstack" && sName !== "csvjoin" && sName !== "dd" && sName !== "xargs" && sName !== "openssl" && sName !== "sqlite3" && sName !== "gpg" && sName !== "ssh" && sName !== "ssh-keygen" && sName !== "pdfinfo" && sName !== "pdffonts" && sName !== "pdftotext" && sName !== "pdftohtml" && sName !== "exiftool" && sName !== "qpdf" && sName !== "pdftk" && sName !== "sips" && sName !== "identify" && sName !== "magick" && sName !== "convert" && sName !== "pdfimages" && sName !== "pdfdetach" && sName !== "ffprobe" && sName !== "ffmpeg" && sName !== "gh" && sName !== "pdftoppm" && sName !== "pdftocairo" && sName !== "mmdc" && sName !== "pandoc" && sName !== "soffice" && sName !== "libreoffice" && sName !== "ssconvert" && sName !== "wkhtmltopdf" && sName !== "op" && sName !== "date" && sName !== "cal" && sName !== "ncal" && sName !== "getopt" && sName !== "pathchk" && sName !== "printenv" && sName !== "env" && sName !== "egrep" && sName !== "fgrep" && !builtInDirectContextExecutors2.has(extDef.execute) || customRegisteredCommands.has(extDef.execute)) return void 0;
|
|
42913
|
+
if ((sName === "xxd" || sName === "od") && !builtInDirectContextExecutors2.has(extDef.execute)) return void 0;
|
|
43205
42914
|
if (!this.arePureArgWords(sCmd.words, rawState)) return void 0;
|
|
43206
42915
|
const sArgs = [];
|
|
43207
42916
|
for (let w = 1; w < sCmd.words.length; w++) {
|
|
@@ -43424,8 +43133,6 @@ unsigned int ${ident}_len = ${view.byteLength};
|
|
|
43424
43133
|
syncPurePipelineSlotInUse = true;
|
|
43425
43134
|
this.budget.enterPipelineStages(n);
|
|
43426
43135
|
this.budget.commands += n;
|
|
43427
|
-
const scope = io[invocationScope];
|
|
43428
|
-
let context = pooledSyncPipeContext;
|
|
43429
43136
|
let prevBuf = sharedSyncPipeBuf0;
|
|
43430
43137
|
let prevLen = fastSharedTextEncoder.encodeInto(stage0Formatted, sharedSyncPipeBuf0).written;
|
|
43431
43138
|
try {
|
|
@@ -44043,35 +43750,7 @@ unsigned int ${ident}_len = ${view.byteLength};
|
|
|
44043
43750
|
prevLen = written;
|
|
44044
43751
|
continue;
|
|
44045
43752
|
}
|
|
44046
|
-
|
|
44047
|
-
sharedSyncPipeWriter.reset(this.budget, this.signal, nextBuf, -1);
|
|
44048
|
-
if (!context) {
|
|
44049
|
-
context = new FastShellCommandContext(this, rawState, io, scope, firstName, stageArgs, void 0, void 0, true);
|
|
44050
|
-
pooledSyncPipeContext = context;
|
|
44051
|
-
}
|
|
44052
|
-
context.resetDirectStage(this, rawState, io, scope, firstName, stageArgs, sharedSyncPipeReader, false, sharedSyncPipeWriter, this.signal);
|
|
44053
|
-
sharedSyncPipeReader.abortSignal = context.signal;
|
|
44054
|
-
scope.enterWork();
|
|
44055
|
-
this.budget.beginPathLookupSuspension();
|
|
44056
|
-
let resPromise;
|
|
44057
|
-
try {
|
|
44058
|
-
resPromise = extDef.execute(context);
|
|
44059
|
-
} finally {
|
|
44060
|
-
this.budget.endPathLookupSuspension();
|
|
44061
|
-
scope.leaveWork();
|
|
44062
|
-
}
|
|
44063
|
-
if (resPromise !== RESOLVED_EXIT_ZERO) {
|
|
44064
|
-
if (resPromise && typeof resPromise.catch === "function") {
|
|
44065
|
-
resPromise.catch(() => {
|
|
44066
|
-
});
|
|
44067
|
-
}
|
|
44068
|
-
pooledSyncPipeContext = void 0;
|
|
44069
|
-
context = void 0;
|
|
44070
|
-
return void 0;
|
|
44071
|
-
}
|
|
44072
|
-
this.signal.throwIfAborted();
|
|
44073
|
-
prevBuf = nextBuf;
|
|
44074
|
-
prevLen = sharedSyncPipeWriter.used;
|
|
43753
|
+
return void 0;
|
|
44075
43754
|
}
|
|
44076
43755
|
if (prevBuf.subarray(0, prevLen).includes(0)) return void 0;
|
|
44077
43756
|
completed = true;
|
|
@@ -44080,11 +43759,6 @@ unsigned int ${ident}_len = ${view.byteLength};
|
|
|
44080
43759
|
this.budget.bytes = previousBytes;
|
|
44081
43760
|
this.budget.commands = previousCommands;
|
|
44082
43761
|
}
|
|
44083
|
-
if (context) context.releaseDirectStage();
|
|
44084
|
-
sharedSyncPipeWriter.budget = void 0;
|
|
44085
|
-
sharedSyncPipeWriter.signal = void 0;
|
|
44086
|
-
sharedSyncPipeWriter.target = EMPTY_BYTES;
|
|
44087
|
-
sharedSyncPipeReader.reset(EMPTY_BYTES, 0);
|
|
44088
43762
|
syncPurePipelineSlotInUse = false;
|
|
44089
43763
|
this.budget.leavePipelineStages(n);
|
|
44090
43764
|
}
|
|
@@ -44158,13 +43832,13 @@ unsigned int ${ident}_len = ${view.byteLength};
|
|
|
44158
43832
|
if (w0Plain === "fmt" && !hasSingleStdinRedir && !hasSingleHereStringRedir && !io.stdinIsDefault) return void 0;
|
|
44159
43833
|
if (w0Plain === "xxd" || w0Plain === "od" || w0Plain === "mktemp" || w0Plain === "chmod" || w0Plain === "uname" || w0Plain === "nproc" || w0Plain === "hostname" || w0Plain === "id" || w0Plain === "whoami") {
|
|
44160
43834
|
const definition = this.commands.get(w0Plain);
|
|
44161
|
-
if (!definition || !
|
|
43835
|
+
if (!definition || !builtInDirectContextExecutors2.has(definition.execute)) return void 0;
|
|
44162
43836
|
}
|
|
44163
43837
|
if (cmd.words.length === 2 && cmd.redirects.length === 0 && (cmd.words[1]?.plain === "--help" || cmd.words[1]?.plain === "--version")) {
|
|
44164
43838
|
const gnuInfo = gnuInformationSync(w0Plain, [cmd.words[1].plain], false, (rawState.exported.has("POSIXLY_CORRECT") || rawState.allexport) && rawState.variables.POSIXLY_CORRECT !== void 0);
|
|
44165
43839
|
if (gnuInfo !== void 0) {
|
|
44166
43840
|
const extDef = this.commands.get(w0Plain);
|
|
44167
|
-
if (!extDef || !
|
|
43841
|
+
if (!extDef || !builtInDirectContextExecutors2.has(extDef.execute)) return void 0;
|
|
44168
43842
|
return gnuInfo.replace(/\n+$/, "");
|
|
44169
43843
|
}
|
|
44170
43844
|
}
|
|
@@ -45770,8 +45444,8 @@ unsigned int ${ident}_len = ${view.byteLength};
|
|
|
45770
45444
|
if (!def) return void 0;
|
|
45771
45445
|
if (w0Plain === "printf" && def.execute !== printfCommand.execute) return void 0;
|
|
45772
45446
|
if (w0Plain === "echo" && !defaultEchoExecutors.has(def.execute)) return void 0;
|
|
45773
|
-
if ((w0Plain === "dirname" || w0Plain === "basename") && (!
|
|
45774
|
-
if (w0Plain === "seq" && !
|
|
45447
|
+
if ((w0Plain === "dirname" || w0Plain === "basename") && (!builtInDirectContextExecutors2.has(def.execute) || customRegisteredCommands.has(def.execute))) return void 0;
|
|
45448
|
+
if (w0Plain === "seq" && !builtInDirectContextExecutors2.has(def.execute) && (customRegisteredCommands.has(def.execute) || customRegisteredRegistries.has(this.commands))) return void 0;
|
|
45775
45449
|
if (cmd.words.length > this.budget.maxExpansionFieldsSmi && cmd.words.length > this.budget.limits.maxExpansionFields) return void 0;
|
|
45776
45450
|
for (let i = 0; i < cmd.words.length; i++) {
|
|
45777
45451
|
if (!this.isPureArgWord(cmd.words[i], rawState)) return void 0;
|
|
@@ -46554,6 +46228,7 @@ unsigned int ${ident}_len = ${view.byteLength};
|
|
|
46554
46228
|
}
|
|
46555
46229
|
}
|
|
46556
46230
|
await sortExpansionStrings(found, work, true);
|
|
46231
|
+
if (!found.length && state.failglob) throw new FailglobFailure(`no match: ${value}`);
|
|
46557
46232
|
return found.length ? found : state.nullglob ? [] : [value];
|
|
46558
46233
|
} finally {
|
|
46559
46234
|
scratch.close();
|
|
@@ -46634,6 +46309,7 @@ unsigned int ${ident}_len = ${view.byteLength};
|
|
|
46634
46309
|
exhausted: () => this.budget.fail("maxExpansionBytes")
|
|
46635
46310
|
};
|
|
46636
46311
|
await sortExpansionStrings(found, sortingWork, true);
|
|
46312
|
+
if (!found.length && state.failglob) throw new FailglobFailure(`no match: ${value}`);
|
|
46637
46313
|
return found.length ? found : state.nullglob ? [] : [value];
|
|
46638
46314
|
}
|
|
46639
46315
|
};
|
|
@@ -46672,6 +46348,7 @@ var RootShellState = class {
|
|
|
46672
46348
|
this.substitutionStatus = 0;
|
|
46673
46349
|
this.lastArgument = "";
|
|
46674
46350
|
this.secondsOrigin = Date.now();
|
|
46351
|
+
this.processSubstitutionIds = { next: 0 };
|
|
46675
46352
|
}
|
|
46676
46353
|
get exported() {
|
|
46677
46354
|
const raw = stateMonitor(this)?.raw;
|
|
@@ -46788,6 +46465,10 @@ function captureShellSessionState(state, exitCode) {
|
|
|
46788
46465
|
dotglob: Boolean(state.dotglob),
|
|
46789
46466
|
globstar: Boolean(state.globstar),
|
|
46790
46467
|
nullglob: Boolean(state.nullglob),
|
|
46468
|
+
failglob: Boolean(state.failglob),
|
|
46469
|
+
lastpipe: Boolean(state.lastpipe),
|
|
46470
|
+
inherit_errexit: Boolean(state.inherit_errexit),
|
|
46471
|
+
expand_aliases: Boolean(state.expand_aliases),
|
|
46791
46472
|
nocaseglob: Boolean(state.nocaseglob),
|
|
46792
46473
|
nocasematch: Boolean(state.nocasematch),
|
|
46793
46474
|
extglob: Boolean(state.extglob),
|
|
@@ -46801,6 +46482,7 @@ function captureShellSessionState(state, exitCode) {
|
|
|
46801
46482
|
nounset: Boolean(state.nounset)
|
|
46802
46483
|
};
|
|
46803
46484
|
const snapshot = {
|
|
46485
|
+
aliases: Object.fromEntries(state.aliases ?? []),
|
|
46804
46486
|
cwd: state.cwd,
|
|
46805
46487
|
umask: state.umask ?? 18,
|
|
46806
46488
|
variables,
|
|
@@ -46821,6 +46503,17 @@ function captureShellSessionState(state, exitCode) {
|
|
|
46821
46503
|
async function restoreShellSessionState(state, snapshot, explicitOptions, budget, scope, syntax) {
|
|
46822
46504
|
const resolvedCwd = explicitOptions.cwd !== void 0 ? resolvePath("/", explicitOptions.cwd) : resolvePath("/", snapshot.cwd || "/");
|
|
46823
46505
|
state.cwd = resolvedCwd;
|
|
46506
|
+
if (snapshot.aliases) {
|
|
46507
|
+
let bytes = 0;
|
|
46508
|
+
const aliases = /* @__PURE__ */ new Map();
|
|
46509
|
+
for (const [name2, value] of Object.entries(snapshot.aliases)) {
|
|
46510
|
+
budget.signal.throwIfAborted();
|
|
46511
|
+
bytes += shellValueByteLength(name2) + shellValueByteLength(value);
|
|
46512
|
+
if (bytes > budget.limits.maxExpansionBytes) budget.fail("maxExpansionBytes");
|
|
46513
|
+
aliases.set(name2, value);
|
|
46514
|
+
}
|
|
46515
|
+
state.aliases = aliases;
|
|
46516
|
+
}
|
|
46824
46517
|
if (typeof snapshot.umask === "number") {
|
|
46825
46518
|
state.umask = snapshot.umask & 511;
|
|
46826
46519
|
}
|
|
@@ -46899,6 +46592,10 @@ async function restoreShellSessionState(state, snapshot, explicitOptions, budget
|
|
|
46899
46592
|
if (opts.dotglob !== void 0) state.dotglob = opts.dotglob;
|
|
46900
46593
|
if (opts.globstar !== void 0) state.globstar = opts.globstar;
|
|
46901
46594
|
if (opts.nullglob !== void 0) state.nullglob = opts.nullglob;
|
|
46595
|
+
if (opts.failglob !== void 0) state.failglob = opts.failglob;
|
|
46596
|
+
if (opts.lastpipe !== void 0) state.lastpipe = opts.lastpipe;
|
|
46597
|
+
if (opts.inherit_errexit !== void 0) state.inherit_errexit = opts.inherit_errexit;
|
|
46598
|
+
if (opts.expand_aliases !== void 0) state.expand_aliases = opts.expand_aliases;
|
|
46902
46599
|
if (opts.nocaseglob !== void 0) state.nocaseglob = opts.nocaseglob;
|
|
46903
46600
|
if (opts.nocasematch !== void 0) state.nocasematch = opts.nocasematch;
|
|
46904
46601
|
if (opts.extglob !== void 0) state.extglob = opts.extglob;
|
|
@@ -46966,23 +46663,6 @@ async function restoreShellSessionState(state, snapshot, explicitOptions, budget
|
|
|
46966
46663
|
}
|
|
46967
46664
|
|
|
46968
46665
|
// packages/safe-bash/src/shell/shell.ts
|
|
46969
|
-
function utf8ByteLength(str) {
|
|
46970
|
-
if (typeof globalThis.Buffer === "function") return globalThis.Buffer.byteLength(str);
|
|
46971
|
-
let bytes = str.length;
|
|
46972
|
-
for (let i = 0; i < str.length; i++) {
|
|
46973
|
-
const code = str.charCodeAt(i);
|
|
46974
|
-
if (code >= 128) {
|
|
46975
|
-
if (code <= 2047) bytes += 1;
|
|
46976
|
-
else if (code >= 55296 && code <= 56319 && i + 1 < str.length && (str.charCodeAt(i + 1) & 64512) === 56320) {
|
|
46977
|
-
bytes += 2;
|
|
46978
|
-
i++;
|
|
46979
|
-
} else {
|
|
46980
|
-
bytes += 2;
|
|
46981
|
-
}
|
|
46982
|
-
}
|
|
46983
|
-
}
|
|
46984
|
-
return bytes;
|
|
46985
|
-
}
|
|
46986
46666
|
var EMPTY_CAPTURED_EXTENSIONS = captureShellExtensions([]);
|
|
46987
46667
|
var sharedUtf8Decoder = new TextDecoder("utf-8", { ignoreBOM: true });
|
|
46988
46668
|
var sharedUtf8Encoder = new TextEncoder();
|
|
@@ -47022,26 +46702,28 @@ var EMPTY_STDIN_OPTIONS = Object.freeze({
|
|
|
47022
46702
|
});
|
|
47023
46703
|
var EMPTY_EXEC_OPTIONS = Object.freeze({});
|
|
47024
46704
|
var EMPTY_STDOUT_BYTES = new Uint8Array(0);
|
|
47025
|
-
|
|
47026
|
-
|
|
47027
|
-
|
|
47028
|
-
|
|
47029
|
-
|
|
47030
|
-
|
|
47031
|
-
|
|
47032
|
-
|
|
47033
|
-
|
|
47034
|
-
|
|
47035
|
-
|
|
47036
|
-
|
|
47037
|
-
|
|
47038
|
-
|
|
47039
|
-
|
|
47040
|
-
|
|
47041
|
-
|
|
47042
|
-
return
|
|
46705
|
+
function syntaxDiagnostic(source, error) {
|
|
46706
|
+
const line = source.slice(0, error.offset).split("\n").length;
|
|
46707
|
+
if (error.unclosedQuote) {
|
|
46708
|
+
return `shell: -c: line ${error.unclosedQuote.line}: unexpected EOF while looking for matching \`${error.unclosedQuote.quote}'
|
|
46709
|
+
`;
|
|
46710
|
+
}
|
|
46711
|
+
if (error.exitCode === 127) {
|
|
46712
|
+
const token = /^[;&|()<>]|^[^\s;&|()<>]+/u.exec(source.slice(error.offset))?.[0] ?? "newline";
|
|
46713
|
+
return `shell: -c: line ${line}: syntax error near unexpected token \`${token}'
|
|
46714
|
+
shell: -c: line ${line}: \`${source.split("\n")[line - 1] ?? ""}'
|
|
46715
|
+
`;
|
|
46716
|
+
}
|
|
46717
|
+
if (error.offset >= source.length && !/Unterminated|nesting|Unsupported/u.test(error.reason)) {
|
|
46718
|
+
const context = error.incompleteCommand ? ` from \`${error.incompleteCommand.name}' command on line ${error.incompleteCommand.line}` : "";
|
|
46719
|
+
return `shell: -c: line ${source.split("\n").length + Number(!source.endsWith("\n"))}: syntax error: unexpected end of file${context}
|
|
46720
|
+
`;
|
|
46721
|
+
}
|
|
46722
|
+
return `shell: ${error.message}
|
|
46723
|
+
`;
|
|
47043
46724
|
}
|
|
47044
|
-
function getOrParseUnitFromCache(source, offset, unitLocale, sourceCache, parseState, budget, syntax) {
|
|
46725
|
+
function getOrParseUnitFromCache(source, offset, unitLocale, sourceCache, parseState, budget, syntax, aliases) {
|
|
46726
|
+
if (aliases?.size) sourceCache = void 0;
|
|
47045
46727
|
let cached;
|
|
47046
46728
|
if (sourceCache !== void 0) {
|
|
47047
46729
|
if (offset === 0) {
|
|
@@ -47067,7 +46749,7 @@ function getOrParseUnitFromCache(source, offset, unitLocale, sourceCache, parseS
|
|
|
47067
46749
|
parseState.lineIndexUnits = budget.parsing.admittedUnits - beforeLineIdx;
|
|
47068
46750
|
}
|
|
47069
46751
|
const beforeParse = budget.parsing.admittedUnits;
|
|
47070
|
-
const parsed = parseShellUnit(source, offset, unitLocale, budget.parsing, parseState.lineIndex, void 0, false, syntax);
|
|
46752
|
+
const parsed = parseShellUnit(source, offset, unitLocale, budget.parsing, parseState.lineIndex, void 0, false, syntax, aliases);
|
|
47071
46753
|
const parseUnits = budget.parsing.admittedUnits - beforeParse;
|
|
47072
46754
|
const unitsCharged = (offset === 0 ? parseState.lineIndexUnits : 0) + parseUnits;
|
|
47073
46755
|
if (sourceCache !== void 0 && (!parsed.script.warnings || parsed.script.warnings.length === 0)) {
|
|
@@ -47233,11 +46915,12 @@ function createInvocationSink(budget, capture, external) {
|
|
|
47233
46915
|
}
|
|
47234
46916
|
});
|
|
47235
46917
|
}
|
|
47236
|
-
var Shell = class
|
|
46918
|
+
var Shell = class {
|
|
47237
46919
|
commands;
|
|
47238
46920
|
#middleware = [];
|
|
47239
46921
|
#filesystems = /* @__PURE__ */ new Map();
|
|
47240
46922
|
#plugins = [];
|
|
46923
|
+
#processSubstitutionIds = { next: 0 };
|
|
47241
46924
|
#capabilities = {};
|
|
47242
46925
|
#options;
|
|
47243
46926
|
#resolvedLimits;
|
|
@@ -47254,10 +46937,36 @@ var Shell = class _Shell {
|
|
|
47254
46937
|
#singleActiveOwner;
|
|
47255
46938
|
#active;
|
|
47256
46939
|
#warmedInvocation;
|
|
46940
|
+
#parsedSourceCache = /* @__PURE__ */ new Map();
|
|
46941
|
+
#getSourceParseCache(source) {
|
|
46942
|
+
let entry = this.#parsedSourceCache.get(source);
|
|
46943
|
+
if (!entry) {
|
|
46944
|
+
if (this.#parsedSourceCache.size >= 64) {
|
|
46945
|
+
const oldest = this.#parsedSourceCache.keys().next().value;
|
|
46946
|
+
if (oldest !== void 0) this.#parsedSourceCache.delete(oldest);
|
|
46947
|
+
}
|
|
46948
|
+
entry = { byteLength: utf8ByteLength(source) };
|
|
46949
|
+
this.#parsedSourceCache.set(source, entry);
|
|
46950
|
+
}
|
|
46951
|
+
return entry;
|
|
46952
|
+
}
|
|
47257
46953
|
constructor(options) {
|
|
47258
46954
|
if (!options?.fs) throw new TypeError("Shell requires an explicit filesystem");
|
|
47259
46955
|
if (options.deviceView !== void 0 && options.deviceView !== "default" && options.deviceView !== "provided") throw new TypeError("deviceView must be default or provided");
|
|
47260
|
-
const
|
|
46956
|
+
const onRegister = (command) => {
|
|
46957
|
+
this.#clearWarmedInvocation();
|
|
46958
|
+
if (!builtInDirectContextExecutors.has(command.execute)) {
|
|
46959
|
+
this.#hasCustomCommands = true;
|
|
46960
|
+
customRegisteredCommands.add(command.execute);
|
|
46961
|
+
}
|
|
46962
|
+
};
|
|
46963
|
+
const commands = options.commands ?? new class extends CommandRegistry {
|
|
46964
|
+
register(command, options2) {
|
|
46965
|
+
super.register(command, options2);
|
|
46966
|
+
onRegister(command);
|
|
46967
|
+
return this;
|
|
46968
|
+
}
|
|
46969
|
+
}();
|
|
47261
46970
|
if (!(commands instanceof CommandRegistry)) throw new TypeError("CommandRegistry requires its matching shell runtime; do not mix source and compiled runtime modules");
|
|
47262
46971
|
if (options.commands) {
|
|
47263
46972
|
this.#hasCustomCommands = true;
|
|
@@ -47328,6 +47037,7 @@ var Shell = class _Shell {
|
|
|
47328
47037
|
}
|
|
47329
47038
|
register(command, options) {
|
|
47330
47039
|
if (this.#disposed) throw new Error("Shell is disposed");
|
|
47040
|
+
this.#clearWarmedInvocation();
|
|
47331
47041
|
this.#hasCustomCommands = true;
|
|
47332
47042
|
if (command && typeof command.execute === "function") customRegisteredCommands.add(command.execute);
|
|
47333
47043
|
this.commands.register(command, options);
|
|
@@ -47378,76 +47088,15 @@ var Shell = class _Shell {
|
|
|
47378
47088
|
void warm.stdin.close();
|
|
47379
47089
|
warm.budget.close();
|
|
47380
47090
|
void warm.scope.close();
|
|
47091
|
+
warm.owner.finish({ kind: "return", value: void 0 });
|
|
47381
47092
|
warm.cancellationState.close();
|
|
47382
47093
|
}
|
|
47383
47094
|
#isDefaultExecOptions(options, currentScope) {
|
|
47384
47095
|
return options.signal === void 0 && options.limits === void 0 && options.onInternalError === void 0 && options.stdin === void 0 && options.stdout === void 0 && options.stderr === void 0 && options.env === void 0 && options.cwd === void 0 && options.state === void 0 && options.onState === void 0 && options.hooks === void 0 && options.capabilities === void 0 && options.admittedHandles === void 0 && options.processSignals === void 0 && options.fs === void 0 && !this.#hasCustomCommands && this.#middleware.length === 0 && (!this.#options.extensions || this.#options.extensions.length === 0) && this.#options.hooks === void 0 && !this.#hasInitialEnv && isSyncResolved(this.#ready) && (!this.#singleActiveScope || this.#singleActiveScope === currentScope) && !this.#active;
|
|
47385
47096
|
}
|
|
47386
|
-
static #enginePrewarmed = false;
|
|
47387
|
-
async #prewarmIsolatedSandbox() {
|
|
47388
|
-
if (_Shell.#enginePrewarmed) return;
|
|
47389
|
-
_Shell.#enginePrewarmed = true;
|
|
47390
|
-
await this.#ready;
|
|
47391
|
-
if (!this.commands.get("rg") || !this.commands.get("jq") || !this.commands.get("awk")) {
|
|
47392
|
-
_Shell.#enginePrewarmed = false;
|
|
47393
|
-
return;
|
|
47394
|
-
}
|
|
47395
|
-
try {
|
|
47396
|
-
const enc = new TextEncoder();
|
|
47397
|
-
const dBytes = enc.encode(Array.from({ length: 120 }, (_, i) => `${i % 3 === 0 ? "alpha" : i % 3 === 1 ? "beta" : "gamma"}:val_${i * 17 % 97}:${i}
|
|
47398
|
-
`).join(""));
|
|
47399
|
-
const jBytes = enc.encode(Array.from({ length: 60 }, (_, i) => `{"id":${i},"active":${i % 2 === 0},"score":${i * 7 % 100},"tag":"t_${i % 10}"}
|
|
47400
|
-
`).join(""));
|
|
47401
|
-
const sandboxFs = new MemoryFileSystem();
|
|
47402
|
-
await sandboxFs.writeFile("/data.txt", dBytes);
|
|
47403
|
-
await sandboxFs.writeFile("/items.jsonl", jBytes);
|
|
47404
|
-
for (let d = 0; d < 2; d++) {
|
|
47405
|
-
await sandboxFs.mkdir(`/src/pkg_${d}`, { recursive: true });
|
|
47406
|
-
for (let f = 0; f < 2; f++) {
|
|
47407
|
-
await sandboxFs.writeFile(`/src/pkg_${d}/mod_${f}.ts`, enc.encode(Array.from({ length: 20 }, (_, l) => `export const v_${d}_${f}_${l} = "${(d + f + l) % 11 === 0 ? "NEEDLE_TOKEN" : "normal"}_${l}";
|
|
47408
|
-
`).join("")));
|
|
47409
|
-
}
|
|
47410
|
-
}
|
|
47411
|
-
const fsScript = [
|
|
47412
|
-
"mkdir -p /work/a /work/b",
|
|
47413
|
-
...Array.from({ length: 12 }, (_, i) => `echo "item_${i}" > /work/a/f_${i}.txt`),
|
|
47414
|
-
...Array.from({ length: 12 }, (_, i) => `echo "item_${i}" >> /work/b/f_${i}.txt`),
|
|
47415
|
-
"rm -rf /work/b",
|
|
47416
|
-
"find /work/a -name 'f_1*.txt' | wc -l"
|
|
47417
|
-
].join("\n");
|
|
47418
|
-
const scripts = [
|
|
47419
|
-
"grep '^alpha' /data.txt | cut -d: -f2 | tr 'a-z' 'A-Z' | sort | head -n 5",
|
|
47420
|
-
"rg -c NEEDLE_TOKEN /src",
|
|
47421
|
-
"sed 's/^alpha:/ALPHA_REPLACED:/g; s/:val_/:VALUE_/g' /data.txt > /out.txt",
|
|
47422
|
-
"awk -F: '/^alpha/ { sum += $3; cnt++ } END { print cnt, sum }' /data.txt",
|
|
47423
|
-
"jq -c 'select(.active) | {id, score}' /items.jsonl > /filtered.jsonl",
|
|
47424
|
-
fsScript,
|
|
47425
|
-
"acc=0; i=0; for i in {1..80}; do acc=$((acc + i)); done; echo $acc",
|
|
47426
|
-
'declare -a arr=(); declare -A map=(); fn() { local x="$1"; case "$x" in *0) return 0;; *) return 1;; esac; }; for ((i=0; i<40; i++)); do s="p_m_${i}_s_e"; a="${s#p_}"; b="${a%_e}"; c="${b//_/}"; arr+=("e_$i"); map["k_$i"]=$((i + ${#c})); if [[ "$s" =~ ^p_m_([0-9]+)_s_e$ ]]; then fn "${BASH_REMATCH[1]}"; fi; done'
|
|
47427
|
-
];
|
|
47428
|
-
const sandboxShell = new _Shell({ fs: sandboxFs });
|
|
47429
|
-
for (const plugin of this.#plugins) {
|
|
47430
|
-
sandboxShell.use(plugin);
|
|
47431
|
-
}
|
|
47432
|
-
for (const s of scripts) {
|
|
47433
|
-
const isFs = s === fsScript;
|
|
47434
|
-
const isSed = s.startsWith("sed ");
|
|
47435
|
-
const isJq = s.startsWith("jq ");
|
|
47436
|
-
for (let i = 0; i < 4; i++) {
|
|
47437
|
-
if (isFs && i > 0) await sandboxFs.rm("/work", { recursive: true, force: true });
|
|
47438
|
-
else if (isSed && i > 0) await sandboxFs.rm("/out.txt", { force: true });
|
|
47439
|
-
else if (isJq && i > 0) await sandboxFs.rm("/filtered.jsonl", { force: true });
|
|
47440
|
-
await sandboxShell.exec("");
|
|
47441
|
-
await sandboxShell.exec(s);
|
|
47442
|
-
}
|
|
47443
|
-
}
|
|
47444
|
-
sandboxShell.#clearWarmedInvocation();
|
|
47445
|
-
} catch {
|
|
47446
|
-
}
|
|
47447
|
-
}
|
|
47448
47097
|
exec(source, options = EMPTY_EXEC_OPTIONS) {
|
|
47449
|
-
if (!this.#disposed && this.#warmedInvocation && typeof source === "string" && source.length <= 16384 && (options === EMPTY_EXEC_OPTIONS || this.#isDefaultExecOptions(options))) {
|
|
47450
|
-
const sourceCache = getSourceParseCache(source);
|
|
47098
|
+
if (!this.#disposed && this.#warmedInvocation && typeof source === "string" && source.length > 0 && source.length <= 16384 && (options === EMPTY_EXEC_OPTIONS || this.#isDefaultExecOptions(options))) {
|
|
47099
|
+
const sourceCache = this.#getSourceParseCache(source);
|
|
47451
47100
|
const firstCached = sourceCache?.first0;
|
|
47452
47101
|
if (firstCached && (!firstCached.unit.script.warnings || firstCached.unit.script.warnings.length === 0)) {
|
|
47453
47102
|
return this.#execWarmSyncOrFallback(source, options, sourceCache, firstCached);
|
|
@@ -47579,14 +47228,14 @@ var Shell = class _Shell {
|
|
|
47579
47228
|
budget.signal.throwIfAborted();
|
|
47580
47229
|
const vars = currentState.variables;
|
|
47581
47230
|
const nextLocale = vars.LC_ALL || vars.LC_CTYPE || vars.LANG ? byteLocale(vars) : false;
|
|
47582
|
-
if (currentCachedUnit && currentCachedUnit.locale === nextLocale && currentCachedUnit.nextCached !== void 0) {
|
|
47231
|
+
if (!currentState.expand_aliases && currentCachedUnit && currentCachedUnit.locale === nextLocale && currentCachedUnit.nextCached !== void 0) {
|
|
47583
47232
|
currentCachedUnit = currentCachedUnit.nextCached;
|
|
47584
47233
|
budget.parsing.admit(currentCachedUnit.unitsCharged);
|
|
47585
47234
|
unit = currentCachedUnit.unit;
|
|
47586
47235
|
} else {
|
|
47587
47236
|
parseState ??= { lineIndex: void 0, lineIndexUnits: 0, currentCachedUnit };
|
|
47588
47237
|
parseState.currentCachedUnit = currentCachedUnit;
|
|
47589
|
-
unit = getOrParseUnitFromCache(source, unit.next, nextLocale, sourceCache, parseState, budget, void 0);
|
|
47238
|
+
unit = getOrParseUnitFromCache(source, unit.next, nextLocale, sourceCache, parseState, budget, void 0, currentState.expand_aliases ? currentState.aliases : void 0);
|
|
47590
47239
|
currentCachedUnit = parseState.currentCachedUnit;
|
|
47591
47240
|
}
|
|
47592
47241
|
if (unit.script.warnings) {
|
|
@@ -47610,8 +47259,7 @@ var Shell = class _Shell {
|
|
|
47610
47259
|
}
|
|
47611
47260
|
} catch (error) {
|
|
47612
47261
|
if (error instanceof ShellSyntaxError) {
|
|
47613
|
-
await writeDiagnostic(io.stderr,
|
|
47614
|
-
`);
|
|
47262
|
+
await writeDiagnostic(io.stderr, syntaxDiagnostic(source, error));
|
|
47615
47263
|
exitCode = error.exitCode;
|
|
47616
47264
|
} else {
|
|
47617
47265
|
failed = true;
|
|
@@ -47746,18 +47394,6 @@ var Shell = class _Shell {
|
|
|
47746
47394
|
}
|
|
47747
47395
|
if (selection.outcome.kind === "throw") throw selection.outcome.reason;
|
|
47748
47396
|
if (scope.hasFailures) throwCleanupFailures(scope.failures);
|
|
47749
|
-
if (!warmSyncExecJitWarmed && source === "" && this.#warmedInvocation) {
|
|
47750
|
-
warmSyncExecJitWarmed = true;
|
|
47751
|
-
await this.#prewarmIsolatedSandbox();
|
|
47752
|
-
for (let w = 0; w < 24; w++) {
|
|
47753
|
-
globalThis.process?.memoryUsage?.();
|
|
47754
|
-
performance.now();
|
|
47755
|
-
}
|
|
47756
|
-
for (let w = 0; w < 16; w++) {
|
|
47757
|
-
await this.exec(":", EMPTY_EXEC_OPTIONS);
|
|
47758
|
-
await this.#execAsync("", EMPTY_EXEC_OPTIONS);
|
|
47759
|
-
}
|
|
47760
|
-
}
|
|
47761
47397
|
return selection.outcome.value;
|
|
47762
47398
|
}
|
|
47763
47399
|
async #execute(source, options, scope, budget, cancellation, cancellationState, owner, admission, warm) {
|
|
@@ -47803,18 +47439,10 @@ var Shell = class _Shell {
|
|
|
47803
47439
|
const extensions = !rawExtensions || rawExtensions.length === 0 ? EMPTY_CAPTURED_EXTENSIONS : captureShellExtensions(rawExtensions);
|
|
47804
47440
|
const locale = options.env === void 0 ? this.#initialLocale : !this.#hasInitialEnv ? byteLocale(options.env) : byteLocale({ ...this.#options.env, ...options.env });
|
|
47805
47441
|
const canCacheParse = extensions === EMPTY_CAPTURED_EXTENSIONS && source.length <= 16384;
|
|
47806
|
-
const sourceCache = canCacheParse ? getSourceParseCache(source) : void 0;
|
|
47442
|
+
const sourceCache = canCacheParse ? this.#getSourceParseCache(source) : void 0;
|
|
47807
47443
|
let parseState;
|
|
47808
47444
|
let currentCachedUnit = sourceCache !== void 0 ? locale ? sourceCache.first1 : sourceCache.first0 : void 0;
|
|
47809
47445
|
let unit;
|
|
47810
|
-
if (currentCachedUnit) {
|
|
47811
|
-
budget.parsing.admit(currentCachedUnit.unitsCharged);
|
|
47812
|
-
unit = currentCachedUnit.unit;
|
|
47813
|
-
} else {
|
|
47814
|
-
parseState = { lineIndex: void 0, lineIndexUnits: 0, currentCachedUnit: void 0 };
|
|
47815
|
-
unit = getOrParseUnitFromCache(source, 0, locale, sourceCache, parseState, budget, extensions.syntax);
|
|
47816
|
-
currentCachedUnit = parseState.currentCachedUnit;
|
|
47817
|
-
}
|
|
47818
47446
|
let currentState;
|
|
47819
47447
|
if (warm) {
|
|
47820
47448
|
currentState = warm.currentState;
|
|
@@ -47861,6 +47489,7 @@ var Shell = class _Shell {
|
|
|
47861
47489
|
exported,
|
|
47862
47490
|
extensionState(extensions.definitions, void 0, void 0, defaultPortableTrapExtension)
|
|
47863
47491
|
);
|
|
47492
|
+
currentState.processSubstitutionIds = this.#processSubstitutionIds;
|
|
47864
47493
|
state = currentState;
|
|
47865
47494
|
const beforeExecHook = options.hooks?.beforeExec ?? this.#options.hooks?.beforeExec;
|
|
47866
47495
|
const restoredSnapshot = options.state ?? (beforeExecHook ? await beforeExecHook({ source, options }) : void 0);
|
|
@@ -47908,6 +47537,15 @@ var Shell = class _Shell {
|
|
|
47908
47537
|
);
|
|
47909
47538
|
scope.registerFinalizer(runtime.releaseAnchorResources.bind(runtime));
|
|
47910
47539
|
}
|
|
47540
|
+
const aliases = currentState.expand_aliases ? currentState.aliases : void 0;
|
|
47541
|
+
if (currentCachedUnit && !aliases?.size) {
|
|
47542
|
+
budget.parsing.admit(currentCachedUnit.unitsCharged);
|
|
47543
|
+
unit = currentCachedUnit.unit;
|
|
47544
|
+
} else {
|
|
47545
|
+
parseState = { lineIndex: void 0, lineIndexUnits: 0, currentCachedUnit: void 0 };
|
|
47546
|
+
unit = getOrParseUnitFromCache(source, 0, byteLocale(currentState.variables), sourceCache, parseState, budget, extensions.syntax, aliases);
|
|
47547
|
+
currentCachedUnit = parseState.currentCachedUnit;
|
|
47548
|
+
}
|
|
47911
47549
|
exitCode = 0;
|
|
47912
47550
|
while (true) {
|
|
47913
47551
|
if (unit.script.warnings) {
|
|
@@ -47925,34 +47563,20 @@ var Shell = class _Shell {
|
|
|
47925
47563
|
budget.signal.throwIfAborted();
|
|
47926
47564
|
const vars = currentState.variables;
|
|
47927
47565
|
const nextLocale = vars.LC_ALL || vars.LC_CTYPE || vars.LANG ? byteLocale(vars) : false;
|
|
47928
|
-
if (currentCachedUnit && currentCachedUnit.locale === nextLocale && currentCachedUnit.nextCached !== void 0) {
|
|
47566
|
+
if (!currentState.expand_aliases && currentCachedUnit && currentCachedUnit.locale === nextLocale && currentCachedUnit.nextCached !== void 0) {
|
|
47929
47567
|
currentCachedUnit = currentCachedUnit.nextCached;
|
|
47930
47568
|
budget.parsing.admit(currentCachedUnit.unitsCharged);
|
|
47931
47569
|
unit = currentCachedUnit.unit;
|
|
47932
47570
|
} else {
|
|
47933
47571
|
parseState ??= { lineIndex: void 0, lineIndexUnits: 0, currentCachedUnit };
|
|
47934
47572
|
parseState.currentCachedUnit = currentCachedUnit;
|
|
47935
|
-
unit = getOrParseUnitFromCache(source, unit.next, nextLocale, sourceCache, parseState, budget, extensions.syntax);
|
|
47573
|
+
unit = getOrParseUnitFromCache(source, unit.next, nextLocale, sourceCache, parseState, budget, extensions.syntax, currentState.expand_aliases ? currentState.aliases : void 0);
|
|
47936
47574
|
currentCachedUnit = parseState.currentCachedUnit;
|
|
47937
47575
|
}
|
|
47938
47576
|
}
|
|
47939
47577
|
} catch (error) {
|
|
47940
47578
|
if (!(error instanceof ShellSyntaxError)) throw error;
|
|
47941
|
-
|
|
47942
|
-
if (error.unclosedQuote) {
|
|
47943
|
-
await writeDiagnostic(io.stderr, `shell: -c: line ${error.unclosedQuote.line}: unexpected EOF while looking for matching \`${error.unclosedQuote.quote}'
|
|
47944
|
-
`);
|
|
47945
|
-
} else if (error.exitCode === 127) {
|
|
47946
|
-
const token = /^[;&|()<>]|^[^\s;&|()<>]+/u.exec(source.slice(error.offset))?.[0] ?? "newline";
|
|
47947
|
-
await writeDiagnostic(io.stderr, `shell: -c: line ${line}: syntax error near unexpected token \`${token}'
|
|
47948
|
-
shell: -c: line ${line}: \`${source.split("\n")[line - 1] ?? ""}'
|
|
47949
|
-
`);
|
|
47950
|
-
} else if (error.offset >= source.length && !/Unterminated|nesting|Unsupported/u.test(error.reason)) {
|
|
47951
|
-
const context = error.incompleteCommand ? ` from \`${error.incompleteCommand.name}' command on line ${error.incompleteCommand.line}` : "";
|
|
47952
|
-
await writeDiagnostic(io.stderr, `shell: -c: line ${source.split("\n").length + Number(!source.endsWith("\n"))}: syntax error: unexpected end of file${context}
|
|
47953
|
-
`);
|
|
47954
|
-
} else await writeDiagnostic(io.stderr, `shell: ${error.message}
|
|
47955
|
-
`);
|
|
47579
|
+
await writeDiagnostic(io.stderr, syntaxDiagnostic(source, error));
|
|
47956
47580
|
exitCode = error.exitCode;
|
|
47957
47581
|
}
|
|
47958
47582
|
if (runtime && state && !runtime.tryFinishShellSync(state)) {
|
|
@@ -47963,7 +47587,9 @@ shell: -c: line ${line}: \`${source.split("\n")[line - 1] ?? ""}'
|
|
|
47963
47587
|
if (budget.hasExecutionCleanup) budget.executionCleanup.abort(error);
|
|
47964
47588
|
throw error;
|
|
47965
47589
|
} finally {
|
|
47966
|
-
if (source === "" && !
|
|
47590
|
+
if (source === "" && !failed && // A retained invocation keeps its parse admissions and clock origins.
|
|
47591
|
+
// Bounded executions must create their own budget and deadline instead.
|
|
47592
|
+
budget.limits.maxParseUnits === Infinity && budget.limits.maxCpuMs === Infinity && budget.limits.maxWallClockMs === Infinity && !this.#warmedInvocation && !budget.hasExecutionCleanup && !scope.hasFailures && !budget.signal.aborted && stdin && runtime && // Host runtimes own native signals tied to the current Worker request.
|
|
47967
47593
|
// Only the direct memory path can retain an invocation for a later call.
|
|
47968
47594
|
runtime._isMemoryBackingFs && state && this.#isDefaultExecOptions(options, scope)) {
|
|
47969
47595
|
if (state.extensions) {
|
|
@@ -48056,6 +47682,7 @@ shell: -c: line ${line}: \`${source.split("\n")[line - 1] ?? ""}'
|
|
|
48056
47682
|
dispose() {
|
|
48057
47683
|
if (this.#disposal) return this.#disposal;
|
|
48058
47684
|
this.#disposed = true;
|
|
47685
|
+
this.#parsedSourceCache.clear();
|
|
48059
47686
|
Runtime.clearStaticPools();
|
|
48060
47687
|
clearAwkReaderPool();
|
|
48061
47688
|
clearRgFastRunnerPool();
|
|
@@ -48092,27 +47719,9 @@ shell: -c: line ${line}: \`${source.split("\n")[line - 1] ?? ""}'
|
|
|
48092
47719
|
};
|
|
48093
47720
|
|
|
48094
47721
|
export {
|
|
48095
|
-
createMemoryFileSystem,
|
|
48096
|
-
defaultMemoryFileSystemLimits,
|
|
48097
|
-
MemoryFileSystem,
|
|
48098
47722
|
ShellSyntaxError,
|
|
48099
47723
|
ShellLimitError,
|
|
48100
47724
|
parseShell,
|
|
48101
|
-
createCsvcutCommand,
|
|
48102
|
-
createCsvcutCommands,
|
|
48103
|
-
csvcutCommands,
|
|
48104
|
-
createCsvgrepCommand,
|
|
48105
|
-
createCsvgrepCommands,
|
|
48106
|
-
csvgrepCommands,
|
|
48107
|
-
createHtmlqCommand,
|
|
48108
|
-
createHtmlqCommands,
|
|
48109
|
-
htmlqCommands,
|
|
48110
|
-
createUnrtfCommand,
|
|
48111
|
-
createUnrtfCommands,
|
|
48112
|
-
unrtfCommands,
|
|
48113
|
-
createDiff3Command,
|
|
48114
|
-
createDiff3Commands,
|
|
48115
|
-
diff3Commands,
|
|
48116
47725
|
createSearchCommands,
|
|
48117
47726
|
searchCommands,
|
|
48118
47727
|
evalSyncRg,
|