@poe-platform/safe-bash 0.1.802 → 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 +60 -33
- 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 -8355
- package/dist/image-ast/index.js +692 -8355
- 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-NZQXYWA3.js → chunk-62BOHHJT.js} +1 -2
- 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-44ALJ4QG.js → chunk-AW5KIT6V.js} +3549 -84
- package/dist/safe-bash/chunks/{chunk-RSTHLAF3.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-KDNSPLII.js → chunk-CTXNARJH.js} +2 -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-IOHH2GTI.js +56 -0
- 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-NQCM3TYR.js → chunk-LPOVNKNB.js} +225 -176
- 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-WDLGKIHD.js → chunk-S4RFUUXO.js} +841 -26
- 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-SHEMU2Z7.js → chunk-W2IYOVHK.js} +839 -1211
- 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-BJA5XNP6.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-4R5ADJM5.js +178 -0
- 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-WPYIOKE3.js → chunk-6GKYHPJG.js} +2 -2
- 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-A7MU7762.js +200 -0
- package/dist/safe-bash/command-chunks/{chunk-ORYGZYKW.js → chunk-ARZMP2L2.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-OQKC5ZU2.js → chunk-BAKFZ477.js} +62 -20
- package/dist/safe-bash/command-chunks/{chunk-QRRYN2KO.js → chunk-BC7BK6R6.js} +0 -2424
- package/dist/safe-bash/command-chunks/{chunk-F4TEEZTL.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-YOFC45RK.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-2JRBIDAD.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-QKFSRZGQ.js → chunk-ICANWOXH.js} +7 -31
- package/dist/safe-bash/command-chunks/{chunk-SQRQW3CT.js → chunk-IJ6LGLXM.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-5E4WAO4O.js → chunk-JD5QNRNO.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-KJIMDLBB.js → chunk-JNANXVJV.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-I237SNW5.js → chunk-LFJJQQND.js} +1 -1
- 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-PEF7K3UQ.js → chunk-NJYHWKIL.js} +40 -10
- package/dist/safe-bash/command-chunks/{chunk-VXSLJH7G.js → chunk-OJQRSCBP.js} +27 -7
- 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-7U7EXOXX.js → chunk-R7C4MGZ5.js} +17 -223
- 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-VGG2DL5Q.js → chunk-TRR4MYWF.js} +4 -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-TZRI7BJZ.js +496 -0
- 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-MQFIPHIQ.js → chunk-WPANOB4A.js} +38 -35
- package/dist/safe-bash/command-chunks/{chunk-Y2WBSJG6.js → chunk-X4QZQI5Q.js} +65 -64
- package/dist/safe-bash/command-chunks/{chunk-FPVUD6TH.js → chunk-XGI57GCN.js} +10 -8
- 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-6GWJUQAV.js → chunk-Z5ZZVDUD.js} +181 -133
- package/dist/safe-bash/command-chunks/{chunk-W5DNF4JH.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/compression/index.js +54 -51
- package/dist/safe-bash/commands/bytes/index.js +2 -1
- package/dist/safe-bash/commands/chmod/index.browser.js +14 -0
- package/dist/safe-bash/commands/chmod/index.d.ts +2 -0
- package/dist/safe-bash/commands/chmod/index.js +2 -0
- 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/chmod.d.ts +1 -7
- package/dist/safe-bash/commands/metadata/chmod.js +1 -204
- package/dist/safe-bash/commands/metadata/index.browser.js +3 -8
- 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/metadata/internal.d.ts +1 -30
- package/dist/safe-bash/commands/metadata/internal.js +1 -76
- package/dist/safe-bash/commands/metadata/mktemp.d.ts +1 -3
- package/dist/safe-bash/commands/metadata/mktemp.js +1 -202
- package/dist/safe-bash/commands/metadata/stat.d.ts +1 -7
- package/dist/safe-bash/commands/metadata/stat.js +1 -530
- package/dist/safe-bash/commands/mktemp/index.browser.js +13 -0
- package/dist/safe-bash/commands/mktemp/index.d.ts +2 -0
- package/dist/safe-bash/commands/mktemp/index.js +2 -0
- 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/portable-random.d.ts +1 -1
- package/dist/safe-bash/commands/portable-random.js +1 -12
- 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 +13 -0
- package/dist/safe-bash/commands/stat/index.d.ts +2 -0
- package/dist/safe-bash/commands/stat/index.js +2 -0
- 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 +74 -34
- 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 +254 -916
- 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 +3 -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 +19 -14
- 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 +24 -4
- package/dist/safe-bash/shell/runtime.js +392 -414
- 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 +7 -0
- package/dist/safe-bash/shell/value-state.js +1 -1
- package/dist/safe-bash/shell/worker-limits.js +1 -0
- package/dist/safe-bash/shell-entry.browser.js +32 -33
- package/dist/safe-bash/trap.browser.js +4 -4
- package/dist/safe-bash/worker/host.js +1 -1
- 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 +218 -65
- package/dist/safe-bash-command-bzip2/index.js +4 -3
- package/dist/safe-bash-command-chmod/LICENSE +21 -0
- package/dist/safe-bash-command-chmod/command.d.ts +7 -0
- package/dist/safe-bash-command-chmod/command.js +11 -0
- package/dist/safe-bash-command-chmod/index.d.ts +6 -0
- package/dist/safe-bash-command-chmod/index.js +27 -0
- 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 +283 -55
- 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 +10 -6
- 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-gzip/index.js +45 -42
- 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 +59 -7
- 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 +42 -57
- 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 +2835 -2783
- 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/LICENSE +21 -0
- package/dist/safe-bash-command-mktemp/command.d.ts +3 -0
- package/dist/safe-bash-command-mktemp/command.js +9 -0
- package/dist/safe-bash-command-mktemp/index.d.ts +6 -0
- package/dist/safe-bash-command-mktemp/index.js +25 -0
- 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 +16 -8
- package/dist/safe-bash-command-op/index.js +62 -36
- 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 +15 -7
- package/dist/safe-bash-command-soffice/index.js +97 -12
- package/dist/safe-bash-command-sponge/index.js +13 -3
- 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/LICENSE +21 -0
- package/dist/safe-bash-command-stat/command.d.ts +7 -0
- package/dist/safe-bash-command-stat/command.js +9 -0
- package/dist/safe-bash-command-stat/index.d.ts +6 -0
- package/dist/safe-bash-command-stat/index.js +25 -0
- 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 +37 -5
- 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 +47 -12
- package/dist/safe-bash-command-xz/command.d.ts +1 -1
- package/dist/safe-bash-command-xz/index.js +3 -2
- package/dist/safe-bash-command-yq/accounting.js +1 -1
- package/dist/safe-bash-command-yq/index.js +4 -2
- package/dist/safe-bash-command-yq/native-work.js +3 -0
- package/dist/safe-bash-command-yq/parser.js +2 -2
- package/dist/safe-bash-command-yq/query.js +8 -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 +3 -3
- package/dist/safe-bash-compression-engine/codec-loader.js +2 -2
- package/dist/safe-bash-compression-engine/files.js +6 -6
- package/dist/safe-bash-compression-engine/index.js +5 -5
- package/dist/safe-bash-compression-engine/operand.js +6 -6
- package/dist/safe-bash-compression-engine/options.js +1 -1
- package/dist/safe-bash-compression-engine/stream.js +5 -5
- package/dist/safe-bash-compression-engine/zstd-decode.js +4 -4
- 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.d.ts +2 -0
- 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-metadata-engine/LICENSE +21 -0
- package/dist/safe-bash-metadata-engine/index.d.ts +30 -0
- package/dist/safe-bash-metadata-engine/index.js +82 -0
- package/dist/safe-bash-metadata-engine/random.d.ts +1 -0
- package/dist/safe-bash-metadata-engine/random.js +21 -0
- 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 +2 -2
- package/dist/safe-bash-search-engine/glob.js +2 -2
- package/dist/safe-bash-search-engine/grep.js +17 -10
- package/dist/safe-bash-search-engine/matcher.d.ts +2 -2
- package/dist/safe-bash-search-engine/matcher.js +13 -9
- package/dist/safe-bash-search-engine/options.d.ts +2 -0
- package/dist/safe-bash-search-engine/options.js +1 -1
- package/dist/safe-bash-search-engine/output.js +1 -1
- package/dist/safe-bash-search-engine/shared.js +2 -2
- package/dist/safe-bash-search-engine/walk.js +15 -3
- 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-snapshot-json.js +2 -2
- package/dist/safe-playwright-cloudflare/browser-snapshot-references.js +1 -1
- 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 +112 -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-GETUOD5D.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/chunk-VSAJ4OTM.js +0 -962
- 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 -9157
- 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-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
|
@@ -28,6 +28,8 @@ import { MemoryFileSystem, isCleanAbsolutePath, retargetScopedFileSystem, scopeF
|
|
|
28
28
|
import { collectPureReadOnlySmiNames, compilePureSmiProgram, evaluateArithmetic, evaluateArithmeticReferences, evaluateArithmeticSync, evaluateArithmeticSyncNonZero, evaluateArithmeticSyncString, fastSafeInt, intToStr, isSafeSmiProgram, prepareArithmetic, runIntArithForLoop, runIntForLoop, sharedLoopIntRegs } from "./arithmetic.js";
|
|
29
29
|
import { ParseBudget } from "./parse-budget.js";
|
|
30
30
|
import { BraceExpansionFailure, expandBraces, tryFastExpandBraceRange } from "./brace-expansion.js";
|
|
31
|
+
import { createAliasCommand } from "../../safe-bash-command-alias/index.js";
|
|
32
|
+
import { createUnaliasCommand } from "../../safe-bash-command-unalias/index.js";
|
|
31
33
|
import { expandTildes } from "./tilde-expansion.js";
|
|
32
34
|
import { evaluatePositionalArithmetic } from "./arithmetic-parameters.js";
|
|
33
35
|
import { compilePattern, compilePatternBoundaries, matchesPattern, tryMatchesPatternSync } from "./pattern.js";
|
|
@@ -163,6 +165,7 @@ export const defaultLimits = {
|
|
|
163
165
|
maxPathnameComponents: Infinity,
|
|
164
166
|
maxRedirects: Infinity,
|
|
165
167
|
maxPipelineStages: Infinity,
|
|
168
|
+
maxPipelineBytes: Infinity,
|
|
166
169
|
maxLoopIterations: Infinity,
|
|
167
170
|
maxSubstitutionDepth: Infinity,
|
|
168
171
|
maxFunctionDepth: Infinity,
|
|
@@ -177,7 +180,7 @@ export const defaultLimits = {
|
|
|
177
180
|
pipeHighWaterMark: 64 * 1024,
|
|
178
181
|
};
|
|
179
182
|
const shellBuiltinNames = new Set([
|
|
180
|
-
":", "true", "false", "pwd", "cd", "set", "shift", "export", "local", "unset", "read", "declare", "typeset", "mapfile", "readarray", "umask", "exit", "return", "break", "continue", "command", "builtin", "type", "readonly", "echo", "printf", "test", "[", ".", "source", "eval", "getopts", "let", "pushd", "dirs", "popd", "shopt", "hash",
|
|
183
|
+
":", "true", "false", "pwd", "cd", "set", "shift", "export", "local", "unset", "read", "declare", "typeset", "mapfile", "readarray", "umask", "exit", "return", "break", "continue", "command", "builtin", "type", "readonly", "echo", "printf", "test", "[", ".", "source", "eval", "exec", "getopts", "let", "pushd", "dirs", "popd", "shopt", "hash", "alias", "unalias",
|
|
181
184
|
]);
|
|
182
185
|
const implementedBuiltins = new Set([...shellBuiltinNames].filter(name => !["echo", "printf", "test", "["].includes(name)));
|
|
183
186
|
const extensionExitFailures = new WeakMap();
|
|
@@ -228,9 +231,10 @@ function publishCommandSpelling(state, description) {
|
|
|
228
231
|
(monitor?.raw ?? state).variables.BASH_COMMAND = description;
|
|
229
232
|
}
|
|
230
233
|
export function resolveLimits(...limits) {
|
|
231
|
-
const
|
|
234
|
+
const definedLimits = limits.map(layer => Object.fromEntries(Object.entries(layer ?? {}).filter(([, value]) => value !== undefined)));
|
|
235
|
+
const result = Object.assign({}, defaultLimits, ...definedLimits);
|
|
232
236
|
const commandLimits = resolveCommandLimits(...limits.map(value => value?.commandLimits));
|
|
233
|
-
for (const [key, value] of Object.entries(Object.assign({}, ...
|
|
237
|
+
for (const [key, value] of Object.entries(Object.assign({}, ...definedLimits))) {
|
|
234
238
|
if (key === "commandLimits")
|
|
235
239
|
continue;
|
|
236
240
|
if ((value !== Infinity || key === "pipeHighWaterMark") && (!Number.isSafeInteger(value) || value < (key === "pipeHighWaterMark" ? 1 : 0))) {
|
|
@@ -453,6 +457,7 @@ function tickSharedWallClockBudgets() {
|
|
|
453
457
|
}
|
|
454
458
|
}
|
|
455
459
|
export class Budget {
|
|
460
|
+
pipelineBytes = 0;
|
|
456
461
|
get fileSystemOperations() {
|
|
457
462
|
return this._fileSystemOperations;
|
|
458
463
|
}
|
|
@@ -494,7 +499,7 @@ export class Budget {
|
|
|
494
499
|
this.maxSourceBytesSmi = limits.maxSourceBytes | 0;
|
|
495
500
|
if (limits.maxPipelineStages < 0x3fffffff)
|
|
496
501
|
this.maxPipelineStagesSmi = limits.maxPipelineStages | 0;
|
|
497
|
-
if (limits.pipeHighWaterMark < 65536)
|
|
502
|
+
if (limits.pipeHighWaterMark < 65536 || limits.maxPipelineBytes !== Infinity)
|
|
498
503
|
this.canSyncPurePipe = false;
|
|
499
504
|
this.signal = signal ? combineManagedSignals(signal, this.controller.signal) : this.controller.signal;
|
|
500
505
|
if (signal)
|
|
@@ -588,6 +593,8 @@ export class Budget {
|
|
|
588
593
|
return this._wallClockDeadline;
|
|
589
594
|
}
|
|
590
595
|
close() {
|
|
596
|
+
if (this._hasExternalSignal)
|
|
597
|
+
releaseCombinedSignal(this.signal);
|
|
591
598
|
const timer = this._wallClockTimer;
|
|
592
599
|
if (timer === undefined)
|
|
593
600
|
return;
|
|
@@ -643,6 +650,16 @@ export class Budget {
|
|
|
643
650
|
set fsOperations(value) {
|
|
644
651
|
this._fileSystemOperations = value;
|
|
645
652
|
}
|
|
653
|
+
pipelineInput = (bytes) => {
|
|
654
|
+
if (this.limits.maxPipelineBytes === Infinity)
|
|
655
|
+
return;
|
|
656
|
+
this.assertPipelineInput(bytes);
|
|
657
|
+
this.pipelineBytes += bytes;
|
|
658
|
+
};
|
|
659
|
+
assertPipelineInput(bytes) {
|
|
660
|
+
if (bytes > this.limits.maxPipelineBytes - this.pipelineBytes)
|
|
661
|
+
this.fail("maxPipelineBytes");
|
|
662
|
+
}
|
|
646
663
|
reservePipelineStages(count) {
|
|
647
664
|
this.signal.throwIfAborted();
|
|
648
665
|
if (count > this.limits.maxPipelineStages - this._pipelineStages)
|
|
@@ -989,7 +1006,7 @@ export class Capture {
|
|
|
989
1006
|
if (same)
|
|
990
1007
|
return cachedCaptureAsciiStr;
|
|
991
1008
|
}
|
|
992
|
-
const decoded =
|
|
1009
|
+
const decoded = sharedCaptureDecoder.decode(buf.subarray(0, len));
|
|
993
1010
|
if (len <= 4096) {
|
|
994
1011
|
for (let i = 0; i < len; i++)
|
|
995
1012
|
cachedCaptureAsciiBytes[i] = buf[i];
|
|
@@ -1020,6 +1037,17 @@ const invokedValues = new WeakMap();
|
|
|
1020
1037
|
const functionDiagnostics = new WeakMap();
|
|
1021
1038
|
const childIdentities = new WeakMap();
|
|
1022
1039
|
const declarationArrays = Symbol("declarationArrays");
|
|
1040
|
+
const execDescriptorFrames = new WeakMap();
|
|
1041
|
+
async function closeExecDescriptors(state) {
|
|
1042
|
+
const raw = stateMonitor(state)?.raw ?? state;
|
|
1043
|
+
const frame = execDescriptorFrames.get(raw);
|
|
1044
|
+
if (!frame)
|
|
1045
|
+
return;
|
|
1046
|
+
execDescriptorFrames.delete(raw);
|
|
1047
|
+
const results = await Promise.allSettled([...frame.releases.values()].map(release => release()));
|
|
1048
|
+
frame.releases.clear();
|
|
1049
|
+
throwCleanupFailures(results.filter(result => result.status === "rejected").map(result => result.reason));
|
|
1050
|
+
}
|
|
1023
1051
|
class DescriptorLifetime {
|
|
1024
1052
|
finalize;
|
|
1025
1053
|
_references = 1;
|
|
@@ -1264,6 +1292,8 @@ class ExpansionFailure extends Error {
|
|
|
1264
1292
|
this.line = line;
|
|
1265
1293
|
}
|
|
1266
1294
|
}
|
|
1295
|
+
class FailglobFailure extends ExpansionFailure {
|
|
1296
|
+
}
|
|
1267
1297
|
class CommandFailure extends Error {
|
|
1268
1298
|
status;
|
|
1269
1299
|
constructor(message, status) {
|
|
@@ -1493,6 +1523,7 @@ class BudgetedPipeStageSink {
|
|
|
1493
1523
|
return Boolean(w.open && pipe && !pipe.failed && !pipe.signal?.aborted && pipe.readerReferences && (!pipe.writes || pipe.writes.size === 0) && (pipe.availableBytes ?? 0) < (pipe.highWaterMark ?? 0));
|
|
1494
1524
|
}
|
|
1495
1525
|
writeSync(chunk) {
|
|
1526
|
+
this.budget.assertPipelineInput(chunk.byteLength);
|
|
1496
1527
|
this.budget.bytes += chunk.byteLength;
|
|
1497
1528
|
this.writable.write(chunk);
|
|
1498
1529
|
if (chunk.byteLength && this.written)
|
|
@@ -1742,10 +1773,20 @@ function bindCommandIO(context, io, limits = {}) {
|
|
|
1742
1773
|
});
|
|
1743
1774
|
}
|
|
1744
1775
|
class FastShellCommandContext {
|
|
1745
|
-
|
|
1746
|
-
const
|
|
1776
|
+
get signal() {
|
|
1777
|
+
const self = this._self ?? this;
|
|
1778
|
+
return self._nativeSignal ??= toNativeAbortSignal(self._rawSignal);
|
|
1779
|
+
}
|
|
1780
|
+
set signal(signal) {
|
|
1781
|
+
const self = this._self ?? this;
|
|
1782
|
+
self._rawSignal = signal;
|
|
1783
|
+
self._nativeSignal = undefined;
|
|
1784
|
+
}
|
|
1785
|
+
constructor(runtime, state, io, scope, name, args, argumentValues, env, signalIsScoped, definition) {
|
|
1786
|
+
const directContext = builtInDirectContextExecutors.has(definition.execute) && !customRegisteredCommands.has(definition.execute)
|
|
1787
|
+
&& (FAST_DIRECT_CONTEXT_COMMANDS.has(name) || (name === "find" && !args.includes("-exec") && !args.includes("-ok")));
|
|
1747
1788
|
if (!directContext) {
|
|
1748
|
-
const { [invocationScope]: ignoredScope, [valueScope]: ignoredAllocation, [declarationArrays]: ignoredArrays, argumentValues: ignoredArguments, ...publicIO } = io;
|
|
1789
|
+
const { [invocationScope]: ignoredScope, [valueScope]: ignoredAllocation, [declarationArrays]: ignoredArrays, argumentValues: ignoredArguments, signal: ignoredSignal, ...publicIO } = io;
|
|
1749
1790
|
Object.defineProperties(this, Object.getOwnPropertyDescriptors(publicIO));
|
|
1750
1791
|
}
|
|
1751
1792
|
this._self = this;
|
|
@@ -1764,15 +1805,19 @@ class FastShellCommandContext {
|
|
|
1764
1805
|
this._argumentValues = argumentValues;
|
|
1765
1806
|
this._env = env;
|
|
1766
1807
|
this.cwd = state.cwd;
|
|
1767
|
-
this.signal = runtime.
|
|
1808
|
+
this.signal = runtime.commandSignal;
|
|
1768
1809
|
this.onInternalError = runtime.budget.onInternalError;
|
|
1769
1810
|
this.argv0 = io.argv0;
|
|
1770
1811
|
this.capabilities = io.capabilities;
|
|
1771
1812
|
this.processSignals = io.processSignals;
|
|
1772
1813
|
this.diagnosticLine = io.diagnosticLine;
|
|
1773
1814
|
this.scriptName = io.scriptName;
|
|
1774
|
-
if (directContext)
|
|
1815
|
+
if (directContext) {
|
|
1816
|
+
Object.defineProperty(this, "signal", {
|
|
1817
|
+
...Object.getOwnPropertyDescriptor(FastShellCommandContext.prototype, "signal"), enumerable: true,
|
|
1818
|
+
});
|
|
1775
1819
|
return;
|
|
1820
|
+
}
|
|
1776
1821
|
workerRuntimeContexts.set(this, {
|
|
1777
1822
|
budget: runtime.budget, umask: state.umask ?? 0o022, ignoredSignals: captureIgnoredTrapSignals(state.extensions), get fs() { return runtime.getContextFsForFast(0, combineManagedSignals(runtime.signal, scope.signal)); },
|
|
1778
1823
|
});
|
|
@@ -1805,7 +1850,7 @@ class FastShellCommandContext {
|
|
|
1805
1850
|
this.command = name;
|
|
1806
1851
|
this.args = args;
|
|
1807
1852
|
this.cwd = state.cwd;
|
|
1808
|
-
this.signal =
|
|
1853
|
+
this.signal = signal;
|
|
1809
1854
|
this.onInternalError = runtime.budget.onInternalError;
|
|
1810
1855
|
this.argv0 = io.argv0;
|
|
1811
1856
|
this.capabilities = io.capabilities;
|
|
@@ -1941,7 +1986,6 @@ class FastShellCommandContext {
|
|
|
1941
1986
|
}
|
|
1942
1987
|
get fs() {
|
|
1943
1988
|
const self = this._self ?? this;
|
|
1944
|
-
self.signal = toNativeAbortSignal(self.signal);
|
|
1945
1989
|
if (!self._contextFs) {
|
|
1946
1990
|
self._contextFs = self._runtime.getContextFsForFast(self._state.umask ?? 0o022, self._getScopedSignal());
|
|
1947
1991
|
}
|
|
@@ -2005,7 +2049,7 @@ function isFastDirectCommand(name, words) {
|
|
|
2005
2049
|
}
|
|
2006
2050
|
return true;
|
|
2007
2051
|
}
|
|
2008
|
-
const fastShellCommandAccessors = ["env", "fs", "shellPredicates", "inputBudget", "executionScope", "registerCleanup", "invoke", "argumentValues"].map(key => [key, Object.getOwnPropertyDescriptor(FastShellCommandContext.prototype, key)]);
|
|
2052
|
+
const fastShellCommandAccessors = ["signal", "env", "fs", "shellPredicates", "inputBudget", "executionScope", "registerCleanup", "invoke", "argumentValues", "stdinInput", "stdoutFile"].map(key => [key, Object.getOwnPropertyDescriptor(FastShellCommandContext.prototype, key)]);
|
|
2009
2053
|
function cloneRawState(raw, hasLocals) {
|
|
2010
2054
|
const variables = Object.assign(Object.create(null), raw.variables);
|
|
2011
2055
|
const exported = raw.exported.size ? new Set(raw.exported) : new Set();
|
|
@@ -2033,6 +2077,12 @@ function cloneRawState(raw, hasLocals) {
|
|
|
2033
2077
|
cloned.getopts = cloneGetoptsBinding(raw);
|
|
2034
2078
|
if (raw.functionNames)
|
|
2035
2079
|
cloned.functionNames = [...raw.functionNames];
|
|
2080
|
+
if (raw.aliases)
|
|
2081
|
+
cloned.aliases = new Map(raw.aliases);
|
|
2082
|
+
if (raw.loopDepth > 0 || raw._subshellInLoop) {
|
|
2083
|
+
cloned._subshellInLoop = true;
|
|
2084
|
+
}
|
|
2085
|
+
cloned.loopDepth = 0;
|
|
2036
2086
|
return cloned;
|
|
2037
2087
|
}
|
|
2038
2088
|
function tryCloneStateSync(state, scope, inheritLocals = true) {
|
|
@@ -2924,7 +2974,7 @@ export function warmDefaultRuntimeContextFs(sourceFs, backingFs) {
|
|
|
2924
2974
|
void created.rm;
|
|
2925
2975
|
reusableDefaultContextFsBySourceFs.set(sourceFs, { scoped: created, inUseBy: undefined });
|
|
2926
2976
|
}
|
|
2927
|
-
import { abortManagedController, addAbortSignalWaiter, combineManagedSignals, createManagedControlController, getRuntimeBackingFileSystem, interruptible, isSyncResolved, registerRuntimeBackingFileSystem, removeAbortSignalWaiter, toNativeAbortSignal } from "../../safe-bash-contracts/runtime-control.js";
|
|
2977
|
+
import { abortManagedController, addAbortSignalWaiter, combineManagedSignals, releaseCombinedSignal, createManagedControlController, getRuntimeBackingFileSystem, interruptible, isSyncResolved, registerRuntimeBackingFileSystem, removeAbortSignalWaiter, toNativeAbortSignal } from "../../safe-bash-contracts/runtime-control.js";
|
|
2928
2978
|
export { getRuntimeBackingFileSystem, interruptible, registerRuntimeBackingFileSystem };
|
|
2929
2979
|
const emptyWords = [];
|
|
2930
2980
|
const emptyShellValues = [];
|
|
@@ -2969,7 +3019,6 @@ function hasGlobOrEscape(text, extglob = false) {
|
|
|
2969
3019
|
}
|
|
2970
3020
|
return false;
|
|
2971
3021
|
}
|
|
2972
|
-
let nextProcessSubstitutionId = 0;
|
|
2973
3022
|
const fastSubScratchArgs = [];
|
|
2974
3023
|
const defaultValueScopeReserve = ValueScope.prototype.reserve;
|
|
2975
3024
|
const defaultStringCodePointAt = String.prototype.codePointAt;
|
|
@@ -3217,14 +3266,12 @@ class PooledSyncPipeWriter {
|
|
|
3217
3266
|
signal;
|
|
3218
3267
|
target = EMPTY_BYTES;
|
|
3219
3268
|
used = 0;
|
|
3220
|
-
overflowed = false;
|
|
3221
3269
|
lineCountOnly = -1;
|
|
3222
3270
|
reset(budget, signal, target, lineCountOnly = -1) {
|
|
3223
3271
|
this.budget = budget;
|
|
3224
3272
|
this.signal = signal;
|
|
3225
3273
|
this.target = target;
|
|
3226
3274
|
this.used = 0;
|
|
3227
|
-
this.overflowed = false;
|
|
3228
3275
|
this.lineCountOnly = lineCountOnly;
|
|
3229
3276
|
}
|
|
3230
3277
|
writeLineCountSync(count, totalBytes) {
|
|
@@ -3233,16 +3280,22 @@ class PooledSyncPipeWriter {
|
|
|
3233
3280
|
const budget = this.budget;
|
|
3234
3281
|
if (budget.bytes + totalBytes > budget.maxOutputBytesSmi && totalBytes > budget.limits.maxOutputBytes - budget.bytes)
|
|
3235
3282
|
budget.fail("maxOutputBytes");
|
|
3236
|
-
if (this.used + totalBytes > this.target.byteLength) {
|
|
3237
|
-
this.overflowed = true;
|
|
3238
|
-
return false;
|
|
3239
|
-
}
|
|
3240
3283
|
this.used += totalBytes;
|
|
3241
3284
|
budget.bytes += totalBytes;
|
|
3242
3285
|
}
|
|
3243
3286
|
this.lineCountOnly = count;
|
|
3244
3287
|
return true;
|
|
3245
3288
|
}
|
|
3289
|
+
reserve(length) {
|
|
3290
|
+
const required = this.used + length;
|
|
3291
|
+
if (required <= this.target.byteLength)
|
|
3292
|
+
return;
|
|
3293
|
+
// Output admission precedes allocation; intermediate stages may exceed 64 KiB.
|
|
3294
|
+
const capacity = Math.min(this.budget.limits.maxOutputBytes, Math.max(required, this.target.byteLength * 2));
|
|
3295
|
+
const target = new Uint8Array(capacity);
|
|
3296
|
+
target.set(this.target.subarray(0, this.used));
|
|
3297
|
+
this.target = target;
|
|
3298
|
+
}
|
|
3246
3299
|
writeSync(chunk) {
|
|
3247
3300
|
this.signal.throwIfAborted();
|
|
3248
3301
|
const len = chunk.byteLength;
|
|
@@ -3251,11 +3304,12 @@ class PooledSyncPipeWriter {
|
|
|
3251
3304
|
const budget = this.budget;
|
|
3252
3305
|
if (budget.bytes + len > budget.maxOutputBytesSmi && len > budget.limits.maxOutputBytes - budget.bytes)
|
|
3253
3306
|
budget.fail("maxOutputBytes");
|
|
3254
|
-
|
|
3255
|
-
this.overflowed = true;
|
|
3256
|
-
return false;
|
|
3257
|
-
}
|
|
3307
|
+
this.reserve(len);
|
|
3258
3308
|
this.target.set(chunk, this.used);
|
|
3309
|
+
if (this.lineCountOnly >= 0)
|
|
3310
|
+
for (const byte of chunk)
|
|
3311
|
+
if (byte === 10)
|
|
3312
|
+
this.lineCountOnly++;
|
|
3259
3313
|
this.used += len;
|
|
3260
3314
|
budget.bytes += len;
|
|
3261
3315
|
return true;
|
|
@@ -3267,23 +3321,23 @@ class PooledSyncPipeWriter {
|
|
|
3267
3321
|
const budget = this.budget;
|
|
3268
3322
|
if (budget.bytes + len > budget.maxOutputBytesSmi && len > budget.limits.maxOutputBytes - budget.bytes)
|
|
3269
3323
|
budget.fail("maxOutputBytes");
|
|
3270
|
-
|
|
3271
|
-
this.overflowed = true;
|
|
3272
|
-
return false;
|
|
3273
|
-
}
|
|
3324
|
+
this.reserve(len);
|
|
3274
3325
|
const dst = this.target;
|
|
3275
3326
|
const base = this.used;
|
|
3276
|
-
for (let i = 0; i < len; i++)
|
|
3277
|
-
|
|
3327
|
+
for (let i = 0; i < len; i++) {
|
|
3328
|
+
const byte = src[i];
|
|
3329
|
+
dst[base + i] = byte;
|
|
3330
|
+
if (this.lineCountOnly >= 0 && byte === 10)
|
|
3331
|
+
this.lineCountOnly++;
|
|
3332
|
+
}
|
|
3278
3333
|
this.used = base + len;
|
|
3279
3334
|
budget.bytes += len;
|
|
3280
3335
|
return true;
|
|
3281
3336
|
}
|
|
3282
3337
|
write(chunk) {
|
|
3283
3338
|
try {
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
return Promise.reject(new Error("Sync pipe stage buffer overflow"));
|
|
3339
|
+
this.writeSync(chunk);
|
|
3340
|
+
return resolvedVoid;
|
|
3287
3341
|
}
|
|
3288
3342
|
catch (err) {
|
|
3289
3343
|
return Promise.reject(err);
|
|
@@ -3702,6 +3756,19 @@ function getOrParseSingleEvalUnit(source, unitLocale, parseBudget) {
|
|
|
3702
3756
|
}
|
|
3703
3757
|
export class Runtime {
|
|
3704
3758
|
reuseDefaultContextFs;
|
|
3759
|
+
persistentIO(state, io) {
|
|
3760
|
+
const frame = execDescriptorFrames.get(stateMonitor(state)?.raw ?? state);
|
|
3761
|
+
if (!frame || io.execFrame === frame && io.execVersion === frame.version)
|
|
3762
|
+
return io;
|
|
3763
|
+
const changed = new Map([...frame.descriptors].filter(([number]) => io.execFrame !== frame || (frame.revisions.get(number) ?? 0) > (io.execVersion ?? 0)));
|
|
3764
|
+
const descriptors = new Map(io.descriptors ?? [[0, { input: io.stdin }], [1, { output: io.stdout }], [2, { output: io.stderr }]]);
|
|
3765
|
+
for (const [number, descriptor] of changed)
|
|
3766
|
+
descriptors.set(number, descriptor);
|
|
3767
|
+
return { ...io, descriptors, execFrame: frame, execVersion: frame.version,
|
|
3768
|
+
...(changed.has(0) ? { stdin: descriptors.get(0)?.closed ? closedSource : descriptors.get(0)?.input ?? closedSource, stdinIsDefault: false } : {}),
|
|
3769
|
+
...(changed.has(1) ? { stdout: descriptors.get(1)?.closed ? closedSink : descriptors.get(1)?.output ?? closedSink } : {}),
|
|
3770
|
+
...(changed.has(2) ? { stderr: descriptors.get(2)?.closed ? closedSink : descriptors.get(2)?.output ?? closedSink } : {}) };
|
|
3771
|
+
}
|
|
3705
3772
|
static clearStaticPools() { clearRuntimePools(); }
|
|
3706
3773
|
_syncReturnDepth = 0;
|
|
3707
3774
|
_syncPendingReturnStatus;
|
|
@@ -3748,8 +3815,6 @@ export class Runtime {
|
|
|
3748
3815
|
const method = Object.getOwnPropertyDescriptor(MemoryFileSystem.prototype, name)?.value;
|
|
3749
3816
|
return typeof method !== "function" || Reflect.get(this.backingFs, name) === method;
|
|
3750
3817
|
});
|
|
3751
|
-
if (this._isMemoryBackingFs)
|
|
3752
|
-
this.backingFs._activeRuntimeBudget = budget;
|
|
3753
3818
|
registerInternalYieldCheckpoint(signal, budget.yieldCheckpoint);
|
|
3754
3819
|
if (commandSignal !== signal) {
|
|
3755
3820
|
inheritYieldCheckpoint(signal, commandSignal);
|
|
@@ -3771,6 +3836,7 @@ export class Runtime {
|
|
|
3771
3836
|
const reusableEntry = reusableDefaultContextFsBySourceFs.get(this.sourceFs);
|
|
3772
3837
|
if (reusableEntry && reusableEntry.inUseBy === this) {
|
|
3773
3838
|
retargetScopedFileSystem(reusableEntry.scoped, noopFsCharge, NEVER_ABORTED_SIGNAL, noopFsCharge, 256);
|
|
3839
|
+
registerRuntimeBackingFileSystem(reusableEntry.scoped, this.backingFs);
|
|
3774
3840
|
reusableEntry.inUseBy = undefined;
|
|
3775
3841
|
}
|
|
3776
3842
|
}
|
|
@@ -3789,7 +3855,7 @@ export class Runtime {
|
|
|
3789
3855
|
if (!this._fs) {
|
|
3790
3856
|
this._fs = scopeFileSystem(this._rawFs, this.budget.chargeFs, this.signal, this.budget.cleanupChargeFs, { maxPathComponents: this.budget.limits.maxPathnameComponents });
|
|
3791
3857
|
runtimeFileSystems.set(this._fs, this.sourceFs);
|
|
3792
|
-
registerRuntimeBackingFileSystem(this._fs, this.backingFs);
|
|
3858
|
+
registerRuntimeBackingFileSystem(this._fs, this.backingFs, this.budget.chargeFs);
|
|
3793
3859
|
}
|
|
3794
3860
|
return this._fs;
|
|
3795
3861
|
}
|
|
@@ -3801,7 +3867,8 @@ export class Runtime {
|
|
|
3801
3867
|
if (this.reuseDefaultContextFs && sig === this.signal && umask === 0o022 && !this._contextFs && this._isMemoryBackingFs) {
|
|
3802
3868
|
const entry = reusableDefaultContextFsBySourceFs.get(this.sourceFs);
|
|
3803
3869
|
if (entry && (entry.inUseBy === undefined || entry.inUseBy === this)) {
|
|
3804
|
-
if (retargetScopedFileSystem(entry.scoped, this.budget.chargeFs, sig, this.budget.cleanupChargeFs, this.budget.limits.maxPathnameComponents)) {
|
|
3870
|
+
if (retargetScopedFileSystem(entry.scoped, this.budget.chargeFs, toNativeAbortSignal(sig), this.budget.cleanupChargeFs, this.budget.limits.maxPathnameComponents)) {
|
|
3871
|
+
registerRuntimeBackingFileSystem(entry.scoped, this.backingFs, this.budget.chargeFs);
|
|
3805
3872
|
entry.inUseBy = this;
|
|
3806
3873
|
this._contextFsMask = umask;
|
|
3807
3874
|
this._contextFsSignal = sig;
|
|
@@ -3810,9 +3877,9 @@ export class Runtime {
|
|
|
3810
3877
|
}
|
|
3811
3878
|
}
|
|
3812
3879
|
}
|
|
3813
|
-
const created = scopeFileSystem(creationFileSystem(this.sourceFs, umask), this.budget.chargeFs, sig, this.budget.cleanupChargeFs, { maxPathComponents: this.budget.limits.maxPathnameComponents });
|
|
3880
|
+
const created = scopeFileSystem(creationFileSystem(this.sourceFs, umask), this.budget.chargeFs, toNativeAbortSignal(sig), this.budget.cleanupChargeFs, { maxPathComponents: this.budget.limits.maxPathnameComponents });
|
|
3814
3881
|
runtimeFileSystems.set(created, this.sourceFs);
|
|
3815
|
-
registerRuntimeBackingFileSystem(created, this.backingFs);
|
|
3882
|
+
registerRuntimeBackingFileSystem(created, this.backingFs, this.budget.chargeFs);
|
|
3816
3883
|
this._contextFsMask = umask;
|
|
3817
3884
|
this._contextFsSignal = sig;
|
|
3818
3885
|
this._contextFs = created;
|
|
@@ -5038,6 +5105,10 @@ export class Runtime {
|
|
|
5038
5105
|
}
|
|
5039
5106
|
variable(state, name) {
|
|
5040
5107
|
name = this.referenceName(state, name);
|
|
5108
|
+
if (name === "$" || name === "BASHPID")
|
|
5109
|
+
return "1";
|
|
5110
|
+
if (name === "!")
|
|
5111
|
+
return "";
|
|
5041
5112
|
if (name === "RANDOM" || name === "SECONDS")
|
|
5042
5113
|
return readDynamicVariable(stateMonitor(state)?.raw ?? state, name) ?? state.variables[name];
|
|
5043
5114
|
const binding = arrayStore(state)?.get(name);
|
|
@@ -6384,8 +6455,14 @@ export class Runtime {
|
|
|
6384
6455
|
// publication snapshot, and choose the append cursor from the new maximum.
|
|
6385
6456
|
const expandedEntries = [];
|
|
6386
6457
|
let elementFields;
|
|
6458
|
+
let attributedElement;
|
|
6387
6459
|
if (assignment.kind === "element") {
|
|
6388
6460
|
elementFields = await this.valueWord(assignment.value, state, io, false, false, false, false, undefined, false, false, 0);
|
|
6461
|
+
if (selectedIndex !== undefined && state.variableAttributes?.get(name)?.includes("i")) {
|
|
6462
|
+
const previous = assignment.append ? store.get(name)?.getValue(selectedIndex)
|
|
6463
|
+
?? (selectedIndex === 0 ? state.variables[name] : undefined) ?? "" : undefined;
|
|
6464
|
+
attributedElement = await this.attributeValue(state, name, concatShellValues(elementFields, io[valueScope]), io, "assignment", previous);
|
|
6465
|
+
}
|
|
6389
6466
|
}
|
|
6390
6467
|
else
|
|
6391
6468
|
for (const entry of assignment.entries) {
|
|
@@ -6409,6 +6486,32 @@ export class Runtime {
|
|
|
6409
6486
|
}
|
|
6410
6487
|
current = store.get(name);
|
|
6411
6488
|
initialMaximum = current?.maximum ?? (state.variables[name] === undefined ? -1 : 0);
|
|
6489
|
+
// Arithmetic attributes and computed indices observe each preceding write.
|
|
6490
|
+
// Expand words against the original binding first, then use ordinary element
|
|
6491
|
+
// assignment publication so arithmetic reads the current array, not a draft.
|
|
6492
|
+
if (assignment.kind === "compound" && expandedEntries.length > 0
|
|
6493
|
+
&& (state.variableAttributes?.get(name)?.includes("i")
|
|
6494
|
+
|| !isAssociative && expandedEntries.some(({ entry }) => entry.index && numericIndex(entry.index) === undefined))) {
|
|
6495
|
+
let cursor = assignment.append ? initialMaximum + 1 : 0;
|
|
6496
|
+
if (!assignment.append)
|
|
6497
|
+
await this.arrayAssignment({ ...assignment, entries: [] }, state, io, undefined, origin, associative, true);
|
|
6498
|
+
for (const { entry, fields } of expandedEntries) {
|
|
6499
|
+
const values = entry.index ? [concatShellValues(fields, io[valueScope])] : fields;
|
|
6500
|
+
for (const value of values) {
|
|
6501
|
+
const index = entry.index && !isAssociative
|
|
6502
|
+
? (await this.arrayIndex(store.get(name), entry.index, state, io, operation, true)) : cursor;
|
|
6503
|
+
const part = { kind: "text", value: shellValueText(value), quoted: true };
|
|
6504
|
+
if (typeof value !== "string")
|
|
6505
|
+
invokedValues.set(part, value);
|
|
6506
|
+
await this.arrayAssignment({ kind: "element", name, append: entry.append ?? false,
|
|
6507
|
+
index: isAssociative ? entry.index : { decimal: String(index) }, value: { offset: entry.value.offset, parts: [part] } }, state, io, undefined, origin, associative, true);
|
|
6508
|
+
cursor = index + 1;
|
|
6509
|
+
}
|
|
6510
|
+
}
|
|
6511
|
+
if (declaration)
|
|
6512
|
+
await this.arrayAssignment({ ...assignment, append: true, entries: [] }, state, io, declaration, origin, associative, true);
|
|
6513
|
+
return;
|
|
6514
|
+
}
|
|
6412
6515
|
this.assertArrayWritable(state, name, origin);
|
|
6413
6516
|
const watch = await store.watch(name, operation, this.signal);
|
|
6414
6517
|
const supersede = await stateMonitor(state).prepareTypedPublication(name, operation, this.signal);
|
|
@@ -6446,7 +6549,9 @@ export class Runtime {
|
|
|
6446
6549
|
const previous = append ? targetBinding.getValue(index) ?? "" : undefined;
|
|
6447
6550
|
if (append && !state.variableAttributes?.get(name)?.includes("i"))
|
|
6448
6551
|
value = await join([previous, value]);
|
|
6449
|
-
if (
|
|
6552
|
+
if (attributedElement !== undefined)
|
|
6553
|
+
value = attributedElement;
|
|
6554
|
+
else if (state.variableAttributes?.get(name))
|
|
6450
6555
|
value = await this.attributeValue(state, name, value, io, "assignment", previous);
|
|
6451
6556
|
else if (shellValueByteLength(value) > this.budget.limits.maxExpansionBytes)
|
|
6452
6557
|
this.budget.fail("maxExpansionBytes");
|
|
@@ -6613,7 +6718,12 @@ export class Runtime {
|
|
|
6613
6718
|
}
|
|
6614
6719
|
}
|
|
6615
6720
|
async run(script, state, io) {
|
|
6616
|
-
|
|
6721
|
+
try {
|
|
6722
|
+
return await this.finishShell(state, io, (await this.runUnit(script, state, io)).exitCode);
|
|
6723
|
+
}
|
|
6724
|
+
finally {
|
|
6725
|
+
await closeExecDescriptors(state);
|
|
6726
|
+
}
|
|
6617
6727
|
}
|
|
6618
6728
|
extensionContext(state, io, command = "", args = [], argumentValues = args) {
|
|
6619
6729
|
const frame = state.extensions;
|
|
@@ -7707,7 +7817,7 @@ export class Runtime {
|
|
|
7707
7817
|
throw error;
|
|
7708
7818
|
throw error.reason;
|
|
7709
7819
|
}
|
|
7710
|
-
if (error instanceof Flow && error.kind === "exit") {
|
|
7820
|
+
if (error instanceof Flow && (error.kind === "exit" || error.kind === "return" || error.kind === "break" || error.kind === "continue")) {
|
|
7711
7821
|
if (this.tryFinishShellSync(state))
|
|
7712
7822
|
return { exitCode: error.status, terminated: true };
|
|
7713
7823
|
return this.finishShell(monitor.proxy, io, error.status).then(exitCode => ({ exitCode, terminated: true }));
|
|
@@ -7735,7 +7845,7 @@ export class Runtime {
|
|
|
7735
7845
|
throw error;
|
|
7736
7846
|
throw error.reason;
|
|
7737
7847
|
}
|
|
7738
|
-
if (error instanceof Flow && error.kind === "exit")
|
|
7848
|
+
if (error instanceof Flow && (error.kind === "exit" || error.kind === "return" || error.kind === "break" || error.kind === "continue"))
|
|
7739
7849
|
return { exitCode: await this.finishShell(state, io, error.status), terminated: true };
|
|
7740
7850
|
throw error;
|
|
7741
7851
|
}
|
|
@@ -7752,7 +7862,7 @@ export class Runtime {
|
|
|
7752
7862
|
throw error;
|
|
7753
7863
|
throw error.reason;
|
|
7754
7864
|
}
|
|
7755
|
-
if (error instanceof Flow && error.kind === "exit")
|
|
7865
|
+
if (error instanceof Flow && (error.kind === "exit" || error.kind === "return" || error.kind === "break" || error.kind === "continue"))
|
|
7756
7866
|
return { exitCode: await this.finishShell(state, io, error.status), terminated: true };
|
|
7757
7867
|
throw error;
|
|
7758
7868
|
}
|
|
@@ -7843,8 +7953,11 @@ export class Runtime {
|
|
|
7843
7953
|
try {
|
|
7844
7954
|
for (let i = 1; i < command.words.length; i++) {
|
|
7845
7955
|
const w = command.words[i];
|
|
7846
|
-
if (w.plain
|
|
7956
|
+
if (w.plain !== undefined
|
|
7957
|
+
? w.plain.includes("{") || w.plain.startsWith("~") || hasGlobOrEscape(w.plain, true)
|
|
7958
|
+
: !(w.parts.length === 1 && w.parts[0].kind === "text" && w.parts[0].quoted === true && !w.parts[0].byteValue)) {
|
|
7847
7959
|
allPlain = false;
|
|
7960
|
+
}
|
|
7848
7961
|
const v = this.fastValueWord(w, rawState, io, true, false, false, true, undefined, diagnosticLine);
|
|
7849
7962
|
if (typeof v !== "string")
|
|
7850
7963
|
return undefined;
|
|
@@ -7856,6 +7969,7 @@ export class Runtime {
|
|
|
7856
7969
|
return undefined;
|
|
7857
7970
|
}
|
|
7858
7971
|
if (allPlain) {
|
|
7972
|
+
Object.freeze(args);
|
|
7859
7973
|
command._cachedConstArgs = args;
|
|
7860
7974
|
if (command.redirects.length === 0 || (command.redirects[0].target.plain !== undefined && (command.redirects[0].operator === ">" || command.redirects[0].operator === ">>"))) {
|
|
7861
7975
|
command._cachedFastSingle = {
|
|
@@ -7928,7 +8042,7 @@ export class Runtime {
|
|
|
7928
8042
|
}
|
|
7929
8043
|
}
|
|
7930
8044
|
else {
|
|
7931
|
-
context = new FastShellCommandContext(this, rawState, io, scope, w0Plain, args, undefined, undefined, this._isMemoryBackingFs);
|
|
8045
|
+
context = new FastShellCommandContext(this, rawState, io, scope, w0Plain, args, undefined, undefined, this._isMemoryBackingFs, externalDef);
|
|
7932
8046
|
if (redirectSink)
|
|
7933
8047
|
context.stdout = redirectSink;
|
|
7934
8048
|
}
|
|
@@ -7948,7 +8062,7 @@ export class Runtime {
|
|
|
7948
8062
|
if (cmd.kind !== "simple" || !this.isPureExternalStageCommand(cmd, rawState) || cmd.words.length > this.budget.maxExpansionFieldsSmi)
|
|
7949
8063
|
return undefined;
|
|
7950
8064
|
}
|
|
7951
|
-
return this.
|
|
8065
|
+
return this.tryExecuteSyncPurePipelineUnit(pipeline, state, rawState, monitor, io, ignored || pipeline.negate);
|
|
7952
8066
|
}
|
|
7953
8067
|
return undefined;
|
|
7954
8068
|
}
|
|
@@ -7999,18 +8113,20 @@ export class Runtime {
|
|
|
7999
8113
|
}
|
|
8000
8114
|
}
|
|
8001
8115
|
catch (error) {
|
|
8002
|
-
return this.finishFastSingleExternalUnitAsync(undefined, error, true, redirectSink, diagnosticLine, negate, ignored, monitor, rawState, existing, elem0, store, state, io, scope, restEpoch);
|
|
8116
|
+
return this.finishFastSingleExternalUnitAsync(context, undefined, error, true, redirectSink, diagnosticLine, negate, ignored, monitor, rawState, existing, elem0, store, state, io, scope, restEpoch);
|
|
8003
8117
|
}
|
|
8004
|
-
return this.finishFastSingleExternalUnitAsync(raw, undefined, false, redirectSink, diagnosticLine, negate, ignored, monitor, rawState, existing, elem0, store, state, io, scope, restEpoch);
|
|
8118
|
+
return this.finishFastSingleExternalUnitAsync(context, raw, undefined, false, redirectSink, diagnosticLine, negate, ignored, monitor, rawState, existing, elem0, store, state, io, scope, restEpoch);
|
|
8005
8119
|
}
|
|
8006
|
-
async finishFastSingleExternalUnitAsync(raw, initialError, hasInitialError, redirectSink, diagnosticLine, negate, ignored, monitor, rawState, existing, elem0, store, state, io, scope, restEpoch) {
|
|
8120
|
+
async finishFastSingleExternalUnitAsync(context, raw, initialError, hasInitialError, redirectSink, diagnosticLine, negate, ignored, monitor, rawState, existing, elem0, store, state, io, scope, restEpoch) {
|
|
8007
8121
|
let rawStatus = 0;
|
|
8122
|
+
let commandSettled = hasInitialError;
|
|
8123
|
+
const pending = hasInitialError ? undefined : Promise.resolve(raw).then(result => { commandSettled = true; return result; }, error => { commandSettled = true; throw error; });
|
|
8008
8124
|
try {
|
|
8009
8125
|
if (hasInitialError)
|
|
8010
8126
|
throw initialError;
|
|
8011
8127
|
const res = this.budget._hasExternalSignal
|
|
8012
|
-
? await interruptible(
|
|
8013
|
-
: await
|
|
8128
|
+
? await interruptible(pending, this.signal)
|
|
8129
|
+
: await pending;
|
|
8014
8130
|
this.signal.throwIfAborted();
|
|
8015
8131
|
if (redirectSink?.failedError !== undefined)
|
|
8016
8132
|
throw redirectSink.failedError;
|
|
@@ -8038,6 +8154,12 @@ export class Runtime {
|
|
|
8038
8154
|
this.budget.endPathLookupSuspension();
|
|
8039
8155
|
scope.leaveWork();
|
|
8040
8156
|
redirectSink?.handle.close();
|
|
8157
|
+
if (commandSettled)
|
|
8158
|
+
context.releaseDirectStage();
|
|
8159
|
+
else {
|
|
8160
|
+
// Cancellation may win before the command stops using its context.
|
|
8161
|
+
void pending.then(() => context.releaseDirectStage(), () => context.releaseDirectStage());
|
|
8162
|
+
}
|
|
8041
8163
|
}
|
|
8042
8164
|
if (!existing) {
|
|
8043
8165
|
monitor.lazyPipeStatus = rawStatus === 0 ? singleStatusZero : rawStatus === 1 ? singleStatusOne : [rawStatus];
|
|
@@ -8061,9 +8183,6 @@ export class Runtime {
|
|
|
8061
8183
|
}
|
|
8062
8184
|
return finalStatus === 0 ? SYNC_UNIT_ZERO : finalStatus === 1 ? SYNC_UNIT_ONE : { exitCode: finalStatus, terminated: false };
|
|
8063
8185
|
}
|
|
8064
|
-
executeFastPurePipelineUnit(pipeline, state, rawState, monitor, io, ignored) {
|
|
8065
|
-
return this.tryExecuteSyncPurePipelineUnit(pipeline, state, rawState, monitor, io, ignored);
|
|
8066
|
-
}
|
|
8067
8186
|
tryExecuteSyncPurePipelineUnit(pipeline, state, rawState, monitor, io, ignored) {
|
|
8068
8187
|
const backing = this.backingFs;
|
|
8069
8188
|
if (syncPurePipelineSlotInUse || !this._isMemoryBackingFs || !backing || backing.capabilitiesFor !== undefined || 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 !== undefined && io.stdout.length === 0 && io.stdout.write === Capture.prototype.write) || !(io.stderr instanceof Capture && io.stderr.length === 0 && io.stderr.write === Capture.prototype.write)) {
|
|
@@ -8182,7 +8301,7 @@ export class Runtime {
|
|
|
8182
8301
|
stageStdout = sharedSyncPipeWriter;
|
|
8183
8302
|
}
|
|
8184
8303
|
if (!context) {
|
|
8185
|
-
context = new FastShellCommandContext(this, rawState, io, scope, firstName, stageArgs, undefined, undefined, true);
|
|
8304
|
+
context = new FastShellCommandContext(this, rawState, io, scope, firstName, stageArgs, undefined, undefined, true, extDef);
|
|
8186
8305
|
pooledSyncPipeContext = context;
|
|
8187
8306
|
}
|
|
8188
8307
|
context.resetDirectStage(this, rawState, io, scope, firstName, stageArgs, inputSource, isFirst, stageStdout, this.signal);
|
|
@@ -8209,7 +8328,7 @@ export class Runtime {
|
|
|
8209
8328
|
statuses ??= new Array(n).fill(0);
|
|
8210
8329
|
statuses[index] = status;
|
|
8211
8330
|
}
|
|
8212
|
-
}).finally(() => scope.leaveWork()).then(() => runStages(index + 1,
|
|
8331
|
+
}).finally(() => scope.leaveWork()).then(() => runStages(index + 1, sharedSyncPipeWriter.target, sharedSyncPipeWriter.used));
|
|
8213
8332
|
}
|
|
8214
8333
|
scope.leaveWork();
|
|
8215
8334
|
this.signal.throwIfAborted();
|
|
@@ -8217,7 +8336,7 @@ export class Runtime {
|
|
|
8217
8336
|
statuses ??= new Array(n).fill(0);
|
|
8218
8337
|
statuses[index] = 1;
|
|
8219
8338
|
}
|
|
8220
|
-
prevBuf =
|
|
8339
|
+
prevBuf = sharedSyncPipeWriter.target;
|
|
8221
8340
|
prevLen = sharedSyncPipeWriter.used;
|
|
8222
8341
|
}
|
|
8223
8342
|
};
|
|
@@ -8228,6 +8347,7 @@ export class Runtime {
|
|
|
8228
8347
|
sharedSyncPipeWriter.signal = undefined;
|
|
8229
8348
|
sharedSyncPipeWriter.target = EMPTY_BYTES;
|
|
8230
8349
|
sharedSyncPipeReader.reset(EMPTY_BYTES, 0);
|
|
8350
|
+
sharedSyncPipeReader.clearViews();
|
|
8231
8351
|
syncPurePipelineSlotInUse = false;
|
|
8232
8352
|
this.budget.leavePipelineStages(n);
|
|
8233
8353
|
};
|
|
@@ -8260,270 +8380,6 @@ export class Runtime {
|
|
|
8260
8380
|
release();
|
|
8261
8381
|
return finish();
|
|
8262
8382
|
}
|
|
8263
|
-
executeFastPurePipelineUnitSlow(pipeline, state, rawState, monitor, io, ignored) {
|
|
8264
|
-
const n = pipeline.commands.length;
|
|
8265
|
-
this.budget.enterPipelineStages(n);
|
|
8266
|
-
this.budget.commands += n;
|
|
8267
|
-
const pipeOptions = { highWaterMark: this.budget.limits.pipeHighWaterMark, signal: this.signal };
|
|
8268
|
-
const pipes = new Array(n - 1);
|
|
8269
|
-
for (let i = 0; i < n - 1; i++) {
|
|
8270
|
-
pipes[i] = createBytePipe(pipeOptions);
|
|
8271
|
-
}
|
|
8272
|
-
const controllers = new Array(n);
|
|
8273
|
-
for (let i = 0; i < n; i++) {
|
|
8274
|
-
controllers[i] = createManagedControlController();
|
|
8275
|
-
}
|
|
8276
|
-
const onParentAbort = (reason) => {
|
|
8277
|
-
for (let i = 0; i < n; i++)
|
|
8278
|
-
abortManagedController(controllers[i], reason);
|
|
8279
|
-
};
|
|
8280
|
-
addAbortSignalWaiter(this.signal, onParentAbort);
|
|
8281
|
-
const scope = io[invocationScope];
|
|
8282
|
-
const onScopeSeal = () => {
|
|
8283
|
-
const closedReason = new Error("Invocation is closed");
|
|
8284
|
-
for (let i = 0; i < n; i++)
|
|
8285
|
-
abortManagedController(controllers[i], closedReason);
|
|
8286
|
-
for (let i = 0; i < n - 1; i++)
|
|
8287
|
-
void pipes[i].abort(closedReason);
|
|
8288
|
-
};
|
|
8289
|
-
scope.addSealCallback(onScopeSeal);
|
|
8290
|
-
const statuses = new Array(n);
|
|
8291
|
-
let asyncTasks;
|
|
8292
|
-
try {
|
|
8293
|
-
for (let index = 0; index < n; index++) {
|
|
8294
|
-
const cmd = pipeline.commands[index];
|
|
8295
|
-
const firstName = cmd.words[0].plain;
|
|
8296
|
-
const extDef = this.commands.get(firstName);
|
|
8297
|
-
let stageArgs = cmd._cachedPlainArgs;
|
|
8298
|
-
if (!stageArgs) {
|
|
8299
|
-
stageArgs = new Array(cmd.words.length - 1);
|
|
8300
|
-
for (let w = 1; w < cmd.words.length; w++) {
|
|
8301
|
-
const word = cmd.words[w];
|
|
8302
|
-
stageArgs[w - 1] = word.plain ?? word.parts.map(p => p.value).join("");
|
|
8303
|
-
}
|
|
8304
|
-
cmd._cachedPlainArgs = stageArgs;
|
|
8305
|
-
}
|
|
8306
|
-
const incoming = index > 0 ? pipes[index - 1] : undefined;
|
|
8307
|
-
const outgoing = index < n - 1 ? pipes[index] : undefined;
|
|
8308
|
-
const reading = incoming?.endpoints?.read;
|
|
8309
|
-
const writing = outgoing?.endpoints?.write;
|
|
8310
|
-
const stageSignal = controllers[index].signal;
|
|
8311
|
-
let input;
|
|
8312
|
-
if (incoming) {
|
|
8313
|
-
reading.abortSignal = stageSignal;
|
|
8314
|
-
input = reading;
|
|
8315
|
-
}
|
|
8316
|
-
else if (io.stdinIsDefault)
|
|
8317
|
-
input = io.stdin;
|
|
8318
|
-
else
|
|
8319
|
-
input = new ShellInput(io.stdin, this.budget, stageSignal, undefined, true);
|
|
8320
|
-
const writable = writing?.writable ?? outgoing?.writable;
|
|
8321
|
-
const stageStdout = outgoing
|
|
8322
|
-
? new BudgetedPipeStageSink(this.budget, writable, stageSignal, undefined, index, controllers[index])
|
|
8323
|
-
: signalSink(io.stdout, stageSignal);
|
|
8324
|
-
const context = new FastShellCommandContext(this, rawState, io, scope, firstName, stageArgs, undefined, undefined, true);
|
|
8325
|
-
context.stdin = input;
|
|
8326
|
-
if (incoming)
|
|
8327
|
-
context.stdinIsDefault = false;
|
|
8328
|
-
context.stdout = stageStdout;
|
|
8329
|
-
context.signal = this._isMemoryBackingFs ? stageSignal : toNativeAbortSignal(stageSignal);
|
|
8330
|
-
context._scopedSignal = stageSignal;
|
|
8331
|
-
if (asyncTasks === undefined) {
|
|
8332
|
-
scope.enterWork();
|
|
8333
|
-
this.budget.beginPathLookupSuspension();
|
|
8334
|
-
let syncExitCode = -1;
|
|
8335
|
-
let pendingRes;
|
|
8336
|
-
let syncErr;
|
|
8337
|
-
let hasSyncErr = false;
|
|
8338
|
-
try {
|
|
8339
|
-
const resPromise = extDef.execute(context);
|
|
8340
|
-
if (resPromise === RESOLVED_EXIT_ZERO) {
|
|
8341
|
-
stageSignal.throwIfAborted();
|
|
8342
|
-
syncExitCode = 0;
|
|
8343
|
-
}
|
|
8344
|
-
else if (resPromise === RESOLVED_EXIT_ONE) {
|
|
8345
|
-
stageSignal.throwIfAborted();
|
|
8346
|
-
syncExitCode = 1;
|
|
8347
|
-
}
|
|
8348
|
-
else
|
|
8349
|
-
pendingRes = Promise.resolve(resPromise);
|
|
8350
|
-
}
|
|
8351
|
-
catch (error) {
|
|
8352
|
-
hasSyncErr = true;
|
|
8353
|
-
syncErr = error;
|
|
8354
|
-
}
|
|
8355
|
-
if (syncExitCode >= 0) {
|
|
8356
|
-
this.budget.endPathLookupSuspension();
|
|
8357
|
-
scope.leaveWork();
|
|
8358
|
-
let asyncCleanup;
|
|
8359
|
-
if (!incoming && input !== io.stdin) {
|
|
8360
|
-
const closedInput = input.close();
|
|
8361
|
-
if (!isSyncResolved(closedInput))
|
|
8362
|
-
asyncCleanup = closedInput;
|
|
8363
|
-
}
|
|
8364
|
-
if (!asyncCleanup && reading) {
|
|
8365
|
-
const closedRead = reading.close();
|
|
8366
|
-
if (!isSyncResolved(closedRead))
|
|
8367
|
-
asyncCleanup = closedRead;
|
|
8368
|
-
}
|
|
8369
|
-
if (!asyncCleanup && writing) {
|
|
8370
|
-
const closedWrite = writing.close();
|
|
8371
|
-
if (!isSyncResolved(closedWrite))
|
|
8372
|
-
asyncCleanup = closedWrite;
|
|
8373
|
-
}
|
|
8374
|
-
if (!asyncCleanup && outgoing && !writing) {
|
|
8375
|
-
const closedOut = outgoing.close();
|
|
8376
|
-
if (!isSyncResolved(closedOut))
|
|
8377
|
-
asyncCleanup = closedOut;
|
|
8378
|
-
}
|
|
8379
|
-
if (!asyncCleanup) {
|
|
8380
|
-
statuses[index] = syncExitCode;
|
|
8381
|
-
continue;
|
|
8382
|
-
}
|
|
8383
|
-
asyncTasks = new Array(n);
|
|
8384
|
-
for (let prev = 0; prev < index; prev++)
|
|
8385
|
-
asyncTasks[prev] = Promise.resolve(statuses[prev]);
|
|
8386
|
-
asyncTasks[index] = asyncCleanup.then(() => syncExitCode);
|
|
8387
|
-
continue;
|
|
8388
|
-
}
|
|
8389
|
-
asyncTasks = new Array(n);
|
|
8390
|
-
for (let prev = 0; prev < index; prev++)
|
|
8391
|
-
asyncTasks[prev] = Promise.resolve(statuses[prev]);
|
|
8392
|
-
asyncTasks[index] = this.finishFastPurePipelineStageAsync(cmd, context, incoming, outgoing, reading, writing, input, stageSignal, scope, io, pendingRes, hasSyncErr, syncErr);
|
|
8393
|
-
continue;
|
|
8394
|
-
}
|
|
8395
|
-
scope.enterWork();
|
|
8396
|
-
this.budget.beginPathLookupSuspension();
|
|
8397
|
-
asyncTasks[index] = this.finishFastPurePipelineStageAsync(cmd, context, incoming, outgoing, reading, writing, input, stageSignal, scope, io, undefined, false, undefined, extDef);
|
|
8398
|
-
}
|
|
8399
|
-
if (asyncTasks !== undefined) {
|
|
8400
|
-
return this.finishFastPurePipelineUnitAsync(asyncTasks, n, pipes, controllers, onParentAbort, onScopeSeal, scope, monitor, rawState, pipeline, state, io, ignored);
|
|
8401
|
-
}
|
|
8402
|
-
}
|
|
8403
|
-
catch (syncFatal) {
|
|
8404
|
-
scope.removeSealCallback(onScopeSeal);
|
|
8405
|
-
removeAbortSignalWaiter(this.signal, onParentAbort);
|
|
8406
|
-
for (let i = 0; i < n; i++)
|
|
8407
|
-
abortManagedController(controllers[i], SHARED_PIPELINE_CLOSED);
|
|
8408
|
-
for (let i = 0; i < n - 1; i++)
|
|
8409
|
-
void pipes[i].abort();
|
|
8410
|
-
this.budget.leavePipelineStages(n);
|
|
8411
|
-
throw syncFatal;
|
|
8412
|
-
}
|
|
8413
|
-
scope.removeSealCallback(onScopeSeal);
|
|
8414
|
-
removeAbortSignalWaiter(this.signal, onParentAbort);
|
|
8415
|
-
for (let i = 0; i < n; i++) {
|
|
8416
|
-
abortManagedController(controllers[i], SHARED_PIPELINE_CLOSED);
|
|
8417
|
-
}
|
|
8418
|
-
for (let i = 0; i < n - 1; i++) {
|
|
8419
|
-
void pipes[i].abort();
|
|
8420
|
-
}
|
|
8421
|
-
this.budget.leavePipelineStages(n);
|
|
8422
|
-
const restEpoch = monitor.chargeInternal(syncRestorationCharge, syncRestorationTickets).epoch;
|
|
8423
|
-
monitor.lazyPipeStatus = statuses;
|
|
8424
|
-
monitor.chargeInternal(syncPipeStatusCharge, syncPipeStatusTickets);
|
|
8425
|
-
const rawStatus = rawState.pipefail ? statuses.findLast(s => s !== 0) ?? 0 : statuses[n - 1];
|
|
8426
|
-
const finalStatus = pipeline.negate ? Number(rawStatus === 0) : rawStatus;
|
|
8427
|
-
rawState.status = finalStatus;
|
|
8428
|
-
monitor.epoch = restEpoch;
|
|
8429
|
-
if (rawStatus !== 0 && !pipeline.negate && !ignored && rawState.errexit) {
|
|
8430
|
-
if (this.tryFinishShellSync(state))
|
|
8431
|
-
return { exitCode: finalStatus, terminated: true };
|
|
8432
|
-
return this.finishShell(state, io, finalStatus).then(exitCode => ({ exitCode, terminated: true }));
|
|
8433
|
-
}
|
|
8434
|
-
return finalStatus === 0 ? SYNC_UNIT_ZERO : finalStatus === 1 ? SYNC_UNIT_ONE : { exitCode: finalStatus, terminated: false };
|
|
8435
|
-
}
|
|
8436
|
-
async finishFastPurePipelineStageAsync(cmd, context, incoming, outgoing, reading, writing, input, stageSignal, scope, io, pendingRes, hasSyncErr, syncErr, extDef) {
|
|
8437
|
-
let exitCode = 0;
|
|
8438
|
-
try {
|
|
8439
|
-
if (hasSyncErr)
|
|
8440
|
-
throw syncErr;
|
|
8441
|
-
const res = await (pendingRes ?? extDef.execute(context));
|
|
8442
|
-
stageSignal.throwIfAborted();
|
|
8443
|
-
exitCode = validateExitCode(res.exitCode);
|
|
8444
|
-
}
|
|
8445
|
-
catch (error) {
|
|
8446
|
-
if (error instanceof PipelineClosed || (stageSignal.aborted && Object.is(stageSignal.reason, SHARED_PIPELINE_CLOSED)))
|
|
8447
|
-
exitCode = 141;
|
|
8448
|
-
else if (errorCode(error) === "EPIPE" && !this.signal.aborted)
|
|
8449
|
-
exitCode = 141;
|
|
8450
|
-
else {
|
|
8451
|
-
this.signal.throwIfAborted();
|
|
8452
|
-
if (error instanceof Flow || error instanceof ShellLimitError || error instanceof ShellSyntaxError)
|
|
8453
|
-
throw error;
|
|
8454
|
-
const line = io.diagnosticCommandLines?.get(cmd) ?? (cmd.line ?? 1) + (io.diagnosticOffset ?? 0);
|
|
8455
|
-
try {
|
|
8456
|
-
await writeDiagnostic(context.stderr, `${io.scriptName ?? "shell"}: line ${line}: ${message(error, this.budget.onInternalError)}\n`);
|
|
8457
|
-
}
|
|
8458
|
-
catch (failure) {
|
|
8459
|
-
this.signal.throwIfAborted();
|
|
8460
|
-
publicDiagnosticMessage(failure, this.budget.onInternalError);
|
|
8461
|
-
}
|
|
8462
|
-
exitCode = error instanceof CommandFailure ? error.status : 1;
|
|
8463
|
-
}
|
|
8464
|
-
}
|
|
8465
|
-
finally {
|
|
8466
|
-
this.budget.endPathLookupSuspension();
|
|
8467
|
-
scope.leaveWork();
|
|
8468
|
-
if (!incoming && input !== io.stdin) {
|
|
8469
|
-
const closedInput = input.close();
|
|
8470
|
-
if (!isSyncResolved(closedInput)) {
|
|
8471
|
-
await closedInput.catch((error) => { if (!(error instanceof PipelineClosed))
|
|
8472
|
-
throw error; });
|
|
8473
|
-
}
|
|
8474
|
-
}
|
|
8475
|
-
if (reading) {
|
|
8476
|
-
const closedRead = reading.close();
|
|
8477
|
-
if (!isSyncResolved(closedRead))
|
|
8478
|
-
await closedRead;
|
|
8479
|
-
}
|
|
8480
|
-
if (writing) {
|
|
8481
|
-
const closedWrite = writing.close();
|
|
8482
|
-
if (!isSyncResolved(closedWrite))
|
|
8483
|
-
await closedWrite;
|
|
8484
|
-
}
|
|
8485
|
-
if (outgoing && !writing) {
|
|
8486
|
-
const closedOut = outgoing.close();
|
|
8487
|
-
if (!isSyncResolved(closedOut))
|
|
8488
|
-
await closedOut.catch(() => undefined);
|
|
8489
|
-
}
|
|
8490
|
-
}
|
|
8491
|
-
return exitCode;
|
|
8492
|
-
}
|
|
8493
|
-
async finishFastPurePipelineUnitAsync(tasks, n, pipes, controllers, onParentAbort, onScopeSeal, scope, monitor, rawState, pipeline, state, io, ignored) {
|
|
8494
|
-
let statuses;
|
|
8495
|
-
try {
|
|
8496
|
-
statuses = this.budget._hasExternalSignal
|
|
8497
|
-
? await interruptible(Promise.all(tasks), this.signal)
|
|
8498
|
-
: await Promise.all(tasks);
|
|
8499
|
-
}
|
|
8500
|
-
finally {
|
|
8501
|
-
scope.removeSealCallback(onScopeSeal);
|
|
8502
|
-
removeAbortSignalWaiter(this.signal, onParentAbort);
|
|
8503
|
-
for (let i = 0; i < n; i++) {
|
|
8504
|
-
abortManagedController(controllers[i], SHARED_PIPELINE_CLOSED);
|
|
8505
|
-
}
|
|
8506
|
-
for (let i = 0; i < n - 1; i++) {
|
|
8507
|
-
const ab = pipes[i].abort();
|
|
8508
|
-
if (!isSyncResolved(ab))
|
|
8509
|
-
await ab;
|
|
8510
|
-
}
|
|
8511
|
-
this.budget.leavePipelineStages(n);
|
|
8512
|
-
}
|
|
8513
|
-
const restEpoch = monitor.chargeInternal(syncRestorationCharge, syncRestorationTickets).epoch;
|
|
8514
|
-
monitor.lazyPipeStatus = statuses;
|
|
8515
|
-
monitor.chargeInternal(syncPipeStatusCharge, syncPipeStatusTickets);
|
|
8516
|
-
const rawStatus = rawState.pipefail ? statuses.findLast(s => s !== 0) ?? 0 : statuses[n - 1];
|
|
8517
|
-
const finalStatus = pipeline.negate ? Number(rawStatus === 0) : rawStatus;
|
|
8518
|
-
rawState.status = finalStatus;
|
|
8519
|
-
monitor.epoch = restEpoch;
|
|
8520
|
-
if (rawStatus !== 0 && !pipeline.negate && !ignored && rawState.errexit) {
|
|
8521
|
-
if (this.tryFinishShellSync(state))
|
|
8522
|
-
return { exitCode: finalStatus, terminated: true };
|
|
8523
|
-
return { exitCode: await this.finishShell(state, io, finalStatus), terminated: true };
|
|
8524
|
-
}
|
|
8525
|
-
return finalStatus === 0 ? SYNC_UNIT_ZERO : finalStatus === 1 ? SYNC_UNIT_ONE : { exitCode: finalStatus, terminated: false };
|
|
8526
|
-
}
|
|
8527
8383
|
async inputUnit(script, state, io, startListIndex = 0, startPipelineIndex = 0, skipFirstSync = false) {
|
|
8528
8384
|
try {
|
|
8529
8385
|
return await this.script(script, state, io, startListIndex, startPipelineIndex, skipFirstSync);
|
|
@@ -8538,6 +8394,7 @@ export class Runtime {
|
|
|
8538
8394
|
}
|
|
8539
8395
|
}
|
|
8540
8396
|
trySyncPipeline(pipeline, state, io, ignored) {
|
|
8397
|
+
io = this.persistentIO(state, io);
|
|
8541
8398
|
const _rawSt = (stateMonitor(state)?.raw ?? state);
|
|
8542
8399
|
if ((_rawSt._syncPendingFunctionResumes?.length ?? 0) > 0 || _rawSt._syncPendingEvalResume !== undefined)
|
|
8543
8400
|
return undefined;
|
|
@@ -8797,7 +8654,7 @@ export class Runtime {
|
|
|
8797
8654
|
const uArg = wu.plain ?? (wu.parts.length === 1 && wu.parts[0].kind === "text" ? wu.parts[0].value : undefined);
|
|
8798
8655
|
if (uArg !== undefined) {
|
|
8799
8656
|
const br = uArg.indexOf("[");
|
|
8800
|
-
if (br > 0 && uArg.endsWith("]") && (wu.parts[0]?.quoted || rawState.noglob || (!rawState.nullglob && this._isMemoryBackingFs && tryGetMemoryDirectoryEntryNamesSync(this.backingFs, rawState.cwd)?.size === 0))) {
|
|
8657
|
+
if (br > 0 && uArg.endsWith("]") && (wu.parts[0]?.quoted || rawState.noglob || (!rawState.nullglob && !rawState.failglob && this._isMemoryBackingFs && tryGetMemoryDirectoryEntryNamesSync(this.backingFs, rawState.cwd)?.size === 0))) {
|
|
8801
8658
|
const arrName = uArg.slice(0, br);
|
|
8802
8659
|
const subStr = uArg.slice(br + 1, -1);
|
|
8803
8660
|
const b = isShellIdentifier(arrName) ? st?.get(arrName) : undefined;
|
|
@@ -9022,7 +8879,7 @@ export class Runtime {
|
|
|
9022
8879
|
let targetOk = false;
|
|
9023
8880
|
if (w2Plain !== undefined) {
|
|
9024
8881
|
const br = w2Plain.indexOf("[");
|
|
9025
|
-
if (br > 0 && w2Plain.endsWith("]") && (w2?.parts[0]?.quoted || rawState.noglob || (!rawState.nullglob && this._isMemoryBackingFs && tryGetMemoryDirectoryEntryNamesSync(this.backingFs, rawState.cwd)?.size === 0))) {
|
|
8882
|
+
if (br > 0 && w2Plain.endsWith("]") && (w2?.parts[0]?.quoted || rawState.noglob || (!rawState.nullglob && !rawState.failglob && this._isMemoryBackingFs && tryGetMemoryDirectoryEntryNamesSync(this.backingFs, rawState.cwd)?.size === 0))) {
|
|
9026
8883
|
const arrName = w2Plain.slice(0, br);
|
|
9027
8884
|
const subStr = w2Plain.slice(br + 1, -1);
|
|
9028
8885
|
const b = isShellIdentifier(arrName) ? st?.get(arrName) : undefined;
|
|
@@ -10944,7 +10801,7 @@ export class Runtime {
|
|
|
10944
10801
|
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")) {
|
|
10945
10802
|
const def = this.commands.get("printf");
|
|
10946
10803
|
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))))) {
|
|
10947
|
-
let targetSpec = command.words[2]?.plain !== undefined && (rawState.noglob || !hasGlobOrEscape(command.words[2].plain, !!rawState.extglob) || (!rawState.nullglob && this._isMemoryBackingFs && tryGetMemoryDirectoryEntryNamesSync(this.backingFs, rawState.cwd)?.size === 0)) ? command.words[2].plain : undefined;
|
|
10804
|
+
let targetSpec = command.words[2]?.plain !== undefined && (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 : undefined;
|
|
10948
10805
|
if (targetSpec === undefined) {
|
|
10949
10806
|
try {
|
|
10950
10807
|
targetSpec = this.fastValueWord(command.words[2], rawState, io, true, false, false, true, undefined, diagnosticLine);
|
|
@@ -12190,7 +12047,7 @@ export class Runtime {
|
|
|
12190
12047
|
const ops = [];
|
|
12191
12048
|
for (let ui = uStart; ui < command.words.length; ui++) {
|
|
12192
12049
|
const wu = command.words[ui];
|
|
12193
|
-
const canSkipGlobUnset = Boolean(wu.parts[0]?.quoted || rawState.noglob || (!rawState.nullglob && this._isMemoryBackingFs && tryGetMemoryDirectoryEntryNamesSync(this.backingFs, rawState.cwd)?.size === 0));
|
|
12050
|
+
const canSkipGlobUnset = Boolean(wu.parts[0]?.quoted || rawState.noglob || (!rawState.nullglob && !rawState.failglob && this._isMemoryBackingFs && tryGetMemoryDirectoryEntryNamesSync(this.backingFs, rawState.cwd)?.size === 0));
|
|
12194
12051
|
let tExpanded;
|
|
12195
12052
|
try {
|
|
12196
12053
|
const fv = this.fastValueWord(wu, rawState, io, !canSkipGlobUnset, false, false, true, undefined, diagnosticLine);
|
|
@@ -12987,6 +12844,7 @@ export class Runtime {
|
|
|
12987
12844
|
}
|
|
12988
12845
|
}
|
|
12989
12846
|
if (w0Plain === "eval" &&
|
|
12847
|
+
!rawState.expand_aliases &&
|
|
12990
12848
|
canMutatePipeStatus &&
|
|
12991
12849
|
!pipeline.negate &&
|
|
12992
12850
|
!hasShellFunction(rawState, "eval") &&
|
|
@@ -13685,7 +13543,7 @@ export class Runtime {
|
|
|
13685
13543
|
if (initializer?.kind !== "binary" || initializer.operator !== "=" || initializer.left.kind !== "name")
|
|
13686
13544
|
return undefined;
|
|
13687
13545
|
const induction = initializer.left.name;
|
|
13688
|
-
const dynamicNames = new Set(["PIPESTATUS", "LINENO", "_", "FUNCNAME", "DIRSTACK", "BASH_SUBSHELL"]);
|
|
13546
|
+
const dynamicNames = new Set(["PIPESTATUS", "LINENO", "_", "FUNCNAME", "DIRSTACK", "BASH_SUBSHELL", "BASHPID"]);
|
|
13689
13547
|
const assignments = [];
|
|
13690
13548
|
const appends = new Map();
|
|
13691
13549
|
for (const list of command.body.lists) {
|
|
@@ -13878,13 +13736,15 @@ export class Runtime {
|
|
|
13878
13736
|
if (part.kind === "text") {
|
|
13879
13737
|
if (part.byteValue || invokedValues.has(part))
|
|
13880
13738
|
return false;
|
|
13739
|
+
if (!part.quoted && (part.value.includes("~") || part.value.includes("{") || hasGlobOrEscape(part.value, true)))
|
|
13740
|
+
return false;
|
|
13881
13741
|
continue;
|
|
13882
13742
|
}
|
|
13883
13743
|
if (part.kind === "variable") {
|
|
13884
13744
|
// Unsubscripted array references expand element zero through the normal
|
|
13885
13745
|
// evaluator. fastValueWord cannot guarantee that expansion throughout
|
|
13886
13746
|
// a loop, so reject it before executing any loop effects.
|
|
13887
|
-
if (part.name === "RANDOM" || part.name === "SECONDS" || stateMonitor(rawState)?.store?.get(part.name))
|
|
13747
|
+
if (part.name === "RANDOM" || part.name === "SECONDS" || part.name === "BASHPID" || stateMonitor(rawState)?.store?.get(part.name))
|
|
13888
13748
|
return false;
|
|
13889
13749
|
// These expansions can require multiple fields or asynchronous quoting
|
|
13890
13750
|
// as loop state changes. Decide before the loop produces any effects.
|
|
@@ -15948,8 +15808,8 @@ export class Runtime {
|
|
|
15948
15808
|
rawState.status = 0;
|
|
15949
15809
|
}
|
|
15950
15810
|
runYieldCheckpoint(this.signal);
|
|
15951
|
-
for (
|
|
15952
|
-
rawState.variables[
|
|
15811
|
+
for (const name of touchedIntNamesList) {
|
|
15812
|
+
rawState.variables[name] = intToStr(sharedLoopIntRegs[regNames.indexOf(name)]);
|
|
15953
15813
|
}
|
|
15954
15814
|
regNames.length = 0;
|
|
15955
15815
|
if (hasDeferredSteps && lastInductionInt !== undefined)
|
|
@@ -17506,9 +17366,9 @@ export class Runtime {
|
|
|
17506
17366
|
encoded = encoded.slice();
|
|
17507
17367
|
if (step.targetDirPrefix !== undefined && step.targetNamePrefix !== undefined) {
|
|
17508
17368
|
const fileName = this.evalSyncRedirectSuffix(step.targetWord, step.targetDirPrefix, step.targetNamePrefix, rawState, io);
|
|
17509
|
-
if (tryWriteMemoryFileInDirSync(this.backingFs, step.targetDirPrefix, fileName, encoded, append, mode, this.commandSignal))
|
|
17369
|
+
if (!fileName.includes("/") && fileName !== "." && fileName !== ".." && tryWriteMemoryFileInDirSync(this.backingFs, step.targetDirPrefix, fileName, encoded, append, mode, this.commandSignal))
|
|
17510
17370
|
return;
|
|
17511
|
-
tryWriteMemoryFileSync(this.backingFs, step.targetDirPrefix + fileName, encoded, append, mode, this.commandSignal);
|
|
17371
|
+
tryWriteMemoryFileSync(this.backingFs, normalizePath(step.targetDirPrefix + fileName, rawState.cwd), encoded, append, mode, this.commandSignal);
|
|
17512
17372
|
return;
|
|
17513
17373
|
}
|
|
17514
17374
|
const targetVal = this.evalSyncRedirectWord(step.targetWord, rawState, io);
|
|
@@ -18144,6 +18004,7 @@ export class Runtime {
|
|
|
18144
18004
|
}
|
|
18145
18005
|
const firstIndex = listIndex === startListIndex ? startPipelineIndex : 0;
|
|
18146
18006
|
for (let index = firstIndex; index < list.pipelines.length; index++) {
|
|
18007
|
+
io = this.persistentIO(state, io);
|
|
18147
18008
|
if (state.noexec)
|
|
18148
18009
|
throw new Flow("discard", 0);
|
|
18149
18010
|
const operator = index > 0 ? list.operators[index - 1] : undefined;
|
|
@@ -18326,7 +18187,7 @@ export class Runtime {
|
|
|
18326
18187
|
}
|
|
18327
18188
|
for (let index = 1; index < pipeline.commands.length; index++)
|
|
18328
18189
|
pipes.push(createBytePipe({
|
|
18329
|
-
highWaterMark: this.budget.limits.pipeHighWaterMark, signal: this.signal,
|
|
18190
|
+
highWaterMark: this.budget.limits.pipeHighWaterMark, signal: this.signal, admitWrite: this.budget.pipelineInput,
|
|
18330
18191
|
}));
|
|
18331
18192
|
for (let index = 0; index < pipeline.commands.length; index++) {
|
|
18332
18193
|
controllers.push(createManagedControlController());
|
|
@@ -18362,6 +18223,7 @@ export class Runtime {
|
|
|
18362
18223
|
void installation.catch(() => undefined);
|
|
18363
18224
|
}
|
|
18364
18225
|
const tasks = pipeline.commands.map(async (command, index) => {
|
|
18226
|
+
const inCurrentShell = !!state.lastpipe && index === pipeline.commands.length - 1;
|
|
18365
18227
|
let admitted = false;
|
|
18366
18228
|
const admit = () => {
|
|
18367
18229
|
if (admitted)
|
|
@@ -18397,7 +18259,7 @@ export class Runtime {
|
|
|
18397
18259
|
let stageOwnsCleanup = false;
|
|
18398
18260
|
try {
|
|
18399
18261
|
const rawStateForChild = stateMonitor(state)?.raw ?? state;
|
|
18400
|
-
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);
|
|
18262
|
+
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);
|
|
18401
18263
|
const references = isPureStage ? undefined : (cleanupRefs = new PipeDescriptorFrame(io[invocationScope]));
|
|
18402
18264
|
const descriptorFrame = isPureStage ? undefined : (cleanupDescFrame = new PreparedDescriptorFrame(references, this.budget));
|
|
18403
18265
|
const reading = incoming?.endpoints?.read;
|
|
@@ -18421,14 +18283,15 @@ export class Runtime {
|
|
|
18421
18283
|
try {
|
|
18422
18284
|
const isFastPure = isPureStage || runtime.isPureExternalStageCommand(command, rawStateForChild);
|
|
18423
18285
|
const forkedExt = isFastPure ? forkExtensions(state.extensions, "pipeline") : undefined;
|
|
18424
|
-
const child = isFastPure
|
|
18286
|
+
const child = inCurrentShell ? state : isFastPure
|
|
18425
18287
|
? Object.assign(cloneRawState(rawStateForChild, false), {
|
|
18426
18288
|
extensions: forkedExt, isolated: true, _readOnlyStage: true,
|
|
18427
18289
|
})
|
|
18428
18290
|
: (tryCloneStateSync(state) ?? await cloneState(state, this.signal));
|
|
18429
|
-
preparedChild = child;
|
|
18430
|
-
|
|
18431
|
-
|
|
18291
|
+
preparedChild = inCurrentShell ? undefined : child;
|
|
18292
|
+
if (!inCurrentShell)
|
|
18293
|
+
child.variables.BASH_SUBSHELL = String(Number(state.variables.BASH_SUBSHELL ?? 0) + 1);
|
|
18294
|
+
if (!inCurrentShell && !child._readOnlyStage) {
|
|
18432
18295
|
child.extensions = undefined;
|
|
18433
18296
|
child.extensions = forkExtensions(state.extensions, "pipeline");
|
|
18434
18297
|
child.isolated = true;
|
|
@@ -18459,7 +18322,9 @@ export class Runtime {
|
|
|
18459
18322
|
await installation;
|
|
18460
18323
|
signal.throwIfAborted();
|
|
18461
18324
|
}
|
|
18462
|
-
const work =
|
|
18325
|
+
const work = inCurrentShell
|
|
18326
|
+
? runtime.command(command, child, { ...childIO, terminal: undefined })
|
|
18327
|
+
: runtime.runPipelineStageWork(command, child, childIO, io, reason => { checkpointFailure = reason; });
|
|
18463
18328
|
preparedChild = undefined;
|
|
18464
18329
|
started = true;
|
|
18465
18330
|
retain(work);
|
|
@@ -18809,6 +18674,7 @@ export class Runtime {
|
|
|
18809
18674
|
return status;
|
|
18810
18675
|
}
|
|
18811
18676
|
async executeCommand(command, state, originalIO, fileShortcut = false) {
|
|
18677
|
+
originalIO = this.persistentIO(state, originalIO);
|
|
18812
18678
|
const terminal = originalIO.terminal?.target === command ? originalIO.terminal : undefined;
|
|
18813
18679
|
if (!state._readOnlyStage)
|
|
18814
18680
|
state = trackState(state, this.budget, originalIO[invocationScope]);
|
|
@@ -19173,6 +19039,20 @@ export class Runtime {
|
|
|
19173
19039
|
let diagnosticFailure;
|
|
19174
19040
|
let outputTracker;
|
|
19175
19041
|
const snapshotHolder = {};
|
|
19042
|
+
const execState = stateMonitor(state)?.raw ?? state;
|
|
19043
|
+
const savedExecDescriptors = new Map();
|
|
19044
|
+
if (command.redirects.length) {
|
|
19045
|
+
const frame = execDescriptorFrames.get(execState);
|
|
19046
|
+
for (const redirect of command.redirects) {
|
|
19047
|
+
for (const number of redirect.operator === "&>" || redirect.operator === "&>>" ? [1, 2] : [redirect.descriptor]) {
|
|
19048
|
+
if (savedExecDescriptors.has(number))
|
|
19049
|
+
continue;
|
|
19050
|
+
const descriptor = originalIO.descriptors?.get(number)
|
|
19051
|
+
?? (number === 0 ? { input: originalIO.stdin } : number === 1 ? { output: originalIO.stdout } : number === 2 ? { output: originalIO.stderr } : { closed: true });
|
|
19052
|
+
savedExecDescriptors.set(number, { descriptor, revision: frame?.revisions.get(number), release: descriptor.lifetime?.acquire() });
|
|
19053
|
+
}
|
|
19054
|
+
}
|
|
19055
|
+
}
|
|
19176
19056
|
try {
|
|
19177
19057
|
let status = 0;
|
|
19178
19058
|
if (command.kind === "simple") {
|
|
@@ -19208,15 +19088,38 @@ export class Runtime {
|
|
|
19208
19088
|
}
|
|
19209
19089
|
finally {
|
|
19210
19090
|
try {
|
|
19211
|
-
|
|
19212
|
-
|
|
19213
|
-
|
|
19214
|
-
|
|
19091
|
+
const frame = execDescriptorFrames.get(execState);
|
|
19092
|
+
const retirements = [];
|
|
19093
|
+
for (const [number, saved] of savedExecDescriptors) {
|
|
19094
|
+
if (frame && !snapshotHolder.persistentRedirects && frame.revisions.get(number) !== saved.revision) {
|
|
19095
|
+
const release = frame.releases.get(number);
|
|
19096
|
+
if (saved.release)
|
|
19097
|
+
frame.releases.set(number, saved.release);
|
|
19098
|
+
else
|
|
19099
|
+
frame.releases.delete(number);
|
|
19100
|
+
frame.descriptors.set(number, saved.descriptor);
|
|
19101
|
+
frame.revisions.set(number, ++frame.version);
|
|
19102
|
+
if (release)
|
|
19103
|
+
retirements.push(release());
|
|
19104
|
+
}
|
|
19105
|
+
else if (saved.release)
|
|
19106
|
+
retirements.push(saved.release());
|
|
19107
|
+
}
|
|
19108
|
+
const retired = await Promise.allSettled(retirements);
|
|
19109
|
+
throwCleanupFailures(retired.filter(result => result.status === "rejected").map(result => result.reason));
|
|
19215
19110
|
}
|
|
19216
19111
|
finally {
|
|
19217
|
-
|
|
19218
|
-
|
|
19219
|
-
|
|
19112
|
+
try {
|
|
19113
|
+
if (!references && outputs.size === 0 && inputs.size === 0 && processSubstitutions.length === 0)
|
|
19114
|
+
allocation.close();
|
|
19115
|
+
else
|
|
19116
|
+
await this.cleanupCommandResources(references, outputs, inputs, processSubstitutions, allocation, diagnosticFailure, io);
|
|
19117
|
+
}
|
|
19118
|
+
finally {
|
|
19119
|
+
snapshotHolder.finish?.();
|
|
19120
|
+
if (snapshotHolder.scope)
|
|
19121
|
+
await snapshotHolder.scope.close();
|
|
19122
|
+
}
|
|
19220
19123
|
}
|
|
19221
19124
|
}
|
|
19222
19125
|
}
|
|
@@ -19446,8 +19349,7 @@ export class Runtime {
|
|
|
19446
19349
|
}
|
|
19447
19350
|
if (!matched)
|
|
19448
19351
|
continue;
|
|
19449
|
-
|
|
19450
|
-
status = await this.script(clause.body, state, io);
|
|
19352
|
+
status = clause.body.lists.length ? await this.script(clause.body, state, io) : 0;
|
|
19451
19353
|
if (clause.terminator === ";;" || clause.terminator === "esac")
|
|
19452
19354
|
break;
|
|
19453
19355
|
fallthrough = clause.terminator === ";&";
|
|
@@ -19473,8 +19375,7 @@ export class Runtime {
|
|
|
19473
19375
|
}
|
|
19474
19376
|
if (!matched)
|
|
19475
19377
|
continue;
|
|
19476
|
-
|
|
19477
|
-
status = await this.script(clause.body, state, io);
|
|
19378
|
+
status = clause.body.lists.length ? await this.script(clause.body, state, io) : 0;
|
|
19478
19379
|
if (clause.terminator === ";;" || clause.terminator === "esac")
|
|
19479
19380
|
break;
|
|
19480
19381
|
fallthrough = clause.terminator === ";&";
|
|
@@ -19805,6 +19706,8 @@ export class Runtime {
|
|
|
19805
19706
|
publicDiagnosticMessage(failure, this.budget.onInternalError);
|
|
19806
19707
|
}
|
|
19807
19708
|
}
|
|
19709
|
+
if (error instanceof FailglobFailure)
|
|
19710
|
+
throw completedExit(1, state.errexit ? "exit" : "discard");
|
|
19808
19711
|
if (error instanceof ExpansionFailure || error instanceof BraceExpansionFailure)
|
|
19809
19712
|
throw completedExit(error instanceof ParameterExpansionFailure && !state.isolated ? 127 : 1);
|
|
19810
19713
|
if (error instanceof FatalCommandFailure)
|
|
@@ -19923,6 +19826,8 @@ export class Runtime {
|
|
|
19923
19826
|
const descriptor = descriptors.get(0)?.closed ? undefined : descriptors.get(0);
|
|
19924
19827
|
const stdinIsDefault = descriptor?.input ? descriptor.stdinIsDefault : false;
|
|
19925
19828
|
return {
|
|
19829
|
+
...(io.execVersion === undefined ? {} : { execVersion: io.execVersion }),
|
|
19830
|
+
...(io.execFrame === undefined ? {} : { execFrame: io.execFrame }),
|
|
19926
19831
|
capabilities: io.capabilities, ...(io.argv0 === undefined ? {} : { argv0: io.argv0 }), [invocationScope]: io[invocationScope], ...(io.admittedHandles === undefined ? {} : { admittedHandles: io.admittedHandles }), ...(io.processSignals === undefined ? {} : { processSignals: io.processSignals }), ...(io[valueScope] === undefined ? {} : { [valueScope]: io[valueScope] }), ...(io.execution === undefined ? {} : { execution: io.execution }), ...(io.diagnosticLine === undefined ? {} : { diagnosticLine: io.diagnosticLine }), ...(io.diagnosticOffset === undefined ? {} : { diagnosticOffset: io.diagnosticOffset }), ...(io.assignmentDiagnosticContext === undefined ? {} : { assignmentDiagnosticContext: io.assignmentDiagnosticContext }), ...(io.functionCommandLines === undefined ? {} : { functionCommandLines: io.functionCommandLines }), ...(io.diagnosticCommandLines === undefined ? {} : { diagnosticCommandLines: io.diagnosticCommandLines }), ...(io.scriptName === undefined ? {} : { scriptName: io.scriptName }), ...(io.substitutionDiagnosticLine === undefined ? {} : { substitutionDiagnosticLine: io.substitutionDiagnosticLine }), ...(io.substitutionDiagnosticLines === undefined ? {} : { substitutionDiagnosticLines: io.substitutionDiagnosticLines }), ...(io.processSubstitutions === undefined ? {} : { processSubstitutions: io.processSubstitutions }), stdin: descriptor?.input ?? closedSource, ...(stdinIsDefault === undefined ? {} : { stdinIsDefault }), stdout: descriptors.get(1)?.closed ? closedSink : descriptors.get(1)?.output ?? closedSink, stderr: descriptors.get(2)?.closed ? closedSink : descriptors.get(2)?.output ?? closedSink, descriptors,
|
|
19927
19832
|
};
|
|
19928
19833
|
};
|
|
@@ -20054,7 +19959,19 @@ export class Runtime {
|
|
|
20054
19959
|
}
|
|
20055
19960
|
else {
|
|
20056
19961
|
const append = redirect.operator === ">>" || redirect.operator === "&>>";
|
|
20057
|
-
|
|
19962
|
+
let flag = append ? "a" : state.noclobber && redirect.operator !== ">|" ? "wx" : "w";
|
|
19963
|
+
if (flag === "wx") {
|
|
19964
|
+
try {
|
|
19965
|
+
const stat = await resourceFs.stat(path, options);
|
|
19966
|
+
if (stat.type !== "file" && stat.type !== "directory")
|
|
19967
|
+
flag = "w";
|
|
19968
|
+
}
|
|
19969
|
+
catch (error) {
|
|
19970
|
+
this.signal.throwIfAborted();
|
|
19971
|
+
if (!(error instanceof FsError) || error.code !== "ENOENT")
|
|
19972
|
+
throw error;
|
|
19973
|
+
}
|
|
19974
|
+
}
|
|
20058
19975
|
const capabilities = await this.fs.capabilitiesFor?.(path, { ...options, ...(flag === "wx" ? { creation: "exclusive" } : {}) }) ?? this.fs.capabilities;
|
|
20059
19976
|
const streaming = capabilities.preferStreamingRedirection === true && typeof this.fs.writeStream === "function"
|
|
20060
19977
|
&& (append ? capabilities.streamingAppend ?? capabilities.streamingWrite : capabilities.streamingWrite) === true;
|
|
@@ -20548,6 +20465,31 @@ export class Runtime {
|
|
|
20548
20465
|
}
|
|
20549
20466
|
if (!words.length)
|
|
20550
20467
|
return state.substitutionStatus;
|
|
20468
|
+
if (words[declarationIndex] === "exec" && !functionCommand && !state.extensions?.builtins.has("exec")) {
|
|
20469
|
+
snapshotHolder.persistentRedirects = true;
|
|
20470
|
+
const raw = stateMonitor(state)?.raw ?? state;
|
|
20471
|
+
let frame = execDescriptorFrames.get(raw);
|
|
20472
|
+
if (!frame) {
|
|
20473
|
+
frame = { version: 0, descriptors: new Map(), revisions: new Map(), releases: new Map() };
|
|
20474
|
+
execDescriptorFrames.set(raw, frame);
|
|
20475
|
+
this.budget.executionCleanup.register(() => closeExecDescriptors(raw));
|
|
20476
|
+
}
|
|
20477
|
+
for (const redirect of command.redirects) {
|
|
20478
|
+
const numbers = redirect.operator === "&>" || redirect.operator === "&>>" ? [1, 2] : [redirect.descriptor];
|
|
20479
|
+
for (const number of numbers) {
|
|
20480
|
+
const descriptor = io.descriptors?.get(number) ?? { closed: true };
|
|
20481
|
+
const release = descriptor.lifetime?.acquire();
|
|
20482
|
+
const previousRelease = frame.releases.get(number);
|
|
20483
|
+
if (release)
|
|
20484
|
+
frame.releases.set(number, release);
|
|
20485
|
+
else
|
|
20486
|
+
frame.releases.delete(number);
|
|
20487
|
+
frame.descriptors.set(number, descriptor);
|
|
20488
|
+
frame.revisions.set(number, ++frame.version);
|
|
20489
|
+
await previousRelease?.();
|
|
20490
|
+
}
|
|
20491
|
+
}
|
|
20492
|
+
}
|
|
20551
20493
|
const args = words.slice(1);
|
|
20552
20494
|
const argValues = allStrings ? args : wordValues.slice(1);
|
|
20553
20495
|
const dispatchIO = compounds ? { ...io, [declarationArrays]: compounds } : io;
|
|
@@ -20688,7 +20630,7 @@ export class Runtime {
|
|
|
20688
20630
|
env[`BASH_FUNC_${key}%%`] = functionDisplay(key, body).slice(key.length + 1).trimEnd();
|
|
20689
20631
|
}
|
|
20690
20632
|
}
|
|
20691
|
-
const context = new FastShellCommandContext(this, state, io, scope, name, values, undefined, env, this._isMemoryBackingFs);
|
|
20633
|
+
const context = new FastShellCommandContext(this, state, io, scope, name, values, undefined, env, this._isMemoryBackingFs, definition);
|
|
20692
20634
|
const runtimeFrame = {};
|
|
20693
20635
|
scope.enterWork();
|
|
20694
20636
|
this.budget.beginPathLookupSuspension();
|
|
@@ -21429,6 +21371,37 @@ export class Runtime {
|
|
|
21429
21371
|
state.lastArgument = context.args.at(-1) ?? context.command;
|
|
21430
21372
|
return { exitCode };
|
|
21431
21373
|
}
|
|
21374
|
+
if (context.command === "exec") {
|
|
21375
|
+
let execIdx = 0;
|
|
21376
|
+
while (execIdx < context.args.length) {
|
|
21377
|
+
const f = context.args[execIdx];
|
|
21378
|
+
if (f === "--") {
|
|
21379
|
+
execIdx += 1;
|
|
21380
|
+
break;
|
|
21381
|
+
}
|
|
21382
|
+
if (f === "-a" && execIdx + 1 < context.args.length) {
|
|
21383
|
+
execIdx += 2;
|
|
21384
|
+
continue;
|
|
21385
|
+
}
|
|
21386
|
+
if (f === "-c" || f === "-l") {
|
|
21387
|
+
execIdx += 1;
|
|
21388
|
+
continue;
|
|
21389
|
+
}
|
|
21390
|
+
break;
|
|
21391
|
+
}
|
|
21392
|
+
const execRest = context.args.slice(execIdx);
|
|
21393
|
+
const execCmd = execRest[0];
|
|
21394
|
+
if (execCmd === undefined) {
|
|
21395
|
+
return { exitCode: 0 };
|
|
21396
|
+
}
|
|
21397
|
+
const execArgs = execRest.slice(1);
|
|
21398
|
+
const status = await this.dispatch(execCmd, execArgs, state, { ...io, ...context }, assignments, true, context.argumentValues.values.slice(execIdx + 1));
|
|
21399
|
+
throw completedExit(status, "exit");
|
|
21400
|
+
}
|
|
21401
|
+
if (context.command === "read" && context.args.some(arg => arg.startsWith("-") && (arg.includes("u") || arg.includes("t")))) {
|
|
21402
|
+
const { executeRead } = await import("./read-builtin.js");
|
|
21403
|
+
return { exitCode: await executeRead(true, this.extensionContext(state, { ...io, ...context }, context.command, context.args, context.argumentValues.values)) };
|
|
21404
|
+
}
|
|
21432
21405
|
const builtinWork = this.builtin({ ...context, [declarationArrays]: io[declarationArrays] }, state, assignments, (error, diagnostic) => { builtinFailure = { error, diagnostic }; }, bypassFunctions);
|
|
21433
21406
|
const builtin = await interruptible(builtinWork, this.signal);
|
|
21434
21407
|
if (builtin !== undefined) {
|
|
@@ -21862,7 +21835,7 @@ export class Runtime {
|
|
|
21862
21835
|
try {
|
|
21863
21836
|
do {
|
|
21864
21837
|
this.signal.throwIfAborted();
|
|
21865
|
-
const unit = parseShellUnit(source, position, byteLocale(state.variables), this.budget.parsing, lineIndex, undefined, false, state.extensions?.syntax);
|
|
21838
|
+
const unit = parseShellUnit(source, position, byteLocale(state.variables), this.budget.parsing, lineIndex, undefined, false, state.extensions?.syntax, state.expand_aliases ? state.aliases : undefined);
|
|
21866
21839
|
for (const warning of unit.script.warnings ?? [])
|
|
21867
21840
|
await writeDiagnostic(io.stderr, `${io.scriptName}: warning: ${warning}\n`);
|
|
21868
21841
|
if (unit.script.lists.length) {
|
|
@@ -21909,7 +21882,7 @@ export class Runtime {
|
|
|
21909
21882
|
}
|
|
21910
21883
|
const unitIO = { ...io, diagnosticOffset: offset };
|
|
21911
21884
|
try {
|
|
21912
|
-
const unit = eof ? parseShellUnit(source, 0, byteLocale(state.variables), this.budget.parsing, lineIndex, undefined, false, state.extensions?.syntax) : parseShellInputUnit(source, byteLocale(state.variables), this.budget.parsing, lineIndex, state.extensions?.syntax);
|
|
21885
|
+
const unit = eof ? parseShellUnit(source, 0, byteLocale(state.variables), this.budget.parsing, lineIndex, undefined, false, state.extensions?.syntax, state.expand_aliases ? state.aliases : undefined) : parseShellInputUnit(source, byteLocale(state.variables), this.budget.parsing, lineIndex, state.extensions?.syntax, state.expand_aliases ? state.aliases : undefined);
|
|
21913
21886
|
if (unit) {
|
|
21914
21887
|
for (const warning of unit.script.warnings ?? [])
|
|
21915
21888
|
await writeDiagnostic(io.stderr, `${io.scriptName}: warning: ${warning}\n`);
|
|
@@ -22145,8 +22118,10 @@ export class Runtime {
|
|
|
22145
22118
|
else {
|
|
22146
22119
|
const options = { signal: this.signal };
|
|
22147
22120
|
const stat = await interruptible(this.fs.stat(path, options), this.signal);
|
|
22148
|
-
if (stat.type
|
|
22149
|
-
throw new CommandFailure(`${target}:
|
|
22121
|
+
if (stat.type === "directory")
|
|
22122
|
+
throw new CommandFailure(`${target}: Is a directory`, 126);
|
|
22123
|
+
if (stat.type !== "file" && (direct || (stat.type !== "character" && stat.type !== "fifo")))
|
|
22124
|
+
throw new CommandFailure(`${target}: not a regular file`, 126);
|
|
22150
22125
|
if (direct) {
|
|
22151
22126
|
const capabilities = this.fs.capabilitiesFor
|
|
22152
22127
|
? await interruptible(this.fs.capabilitiesFor(path, options), this.signal) : this.fs.capabilities;
|
|
@@ -22228,7 +22203,7 @@ export class Runtime {
|
|
|
22228
22203
|
this.signal.throwIfAborted();
|
|
22229
22204
|
let unit;
|
|
22230
22205
|
try {
|
|
22231
|
-
unit = parseShellUnit(source, position, byteLocale(child.variables), this.budget.parsing, lineIndex, undefined, false, child.extensions?.syntax);
|
|
22206
|
+
unit = parseShellUnit(source, position, byteLocale(child.variables), this.budget.parsing, lineIndex, undefined, false, child.extensions?.syntax, child.expand_aliases ? child.aliases : undefined);
|
|
22232
22207
|
}
|
|
22233
22208
|
catch (error) {
|
|
22234
22209
|
if (!(error instanceof ShellSyntaxError))
|
|
@@ -22254,7 +22229,7 @@ export class Runtime {
|
|
|
22254
22229
|
}
|
|
22255
22230
|
}
|
|
22256
22231
|
async runCurrentText(source, state, io, fatalSyntax, syntaxName, byteSource = false, includeSyntaxContext = true, sourceValues) {
|
|
22257
|
-
if (!sourceValues && !byteSource && isDefaultShellSyntax(state.extensions?.syntax) && source.length <= 4096) {
|
|
22232
|
+
if (!state.expand_aliases && !sourceValues && !byteSource && isDefaultShellSyntax(state.extensions?.syntax) && source.length <= 4096) {
|
|
22258
22233
|
try {
|
|
22259
22234
|
const cachedUnit = getOrParseSingleEvalUnit(source, byteLocale(state.variables), this.budget.parsing);
|
|
22260
22235
|
if (cachedUnit) {
|
|
@@ -22285,7 +22260,7 @@ export class Runtime {
|
|
|
22285
22260
|
try {
|
|
22286
22261
|
do {
|
|
22287
22262
|
this.signal.throwIfAborted();
|
|
22288
|
-
const unit = parseShellUnit(source, position, byteLocale(state.variables), this.budget.parsing, lineIndex, sourceValues, byteSource, state.extensions?.syntax);
|
|
22263
|
+
const unit = parseShellUnit(source, position, byteLocale(state.variables), this.budget.parsing, lineIndex, sourceValues, byteSource, state.extensions?.syntax, state.expand_aliases ? state.aliases : undefined);
|
|
22289
22264
|
for (const warning of unit.script.warnings ?? [])
|
|
22290
22265
|
await writeDiagnostic(io.stderr, `${io.scriptName ?? "shell"}: warning: ${warning}\n`);
|
|
22291
22266
|
if (unit.script.lists.length) {
|
|
@@ -22408,7 +22383,7 @@ export class Runtime {
|
|
|
22408
22383
|
const stat = await interruptible(this.fs.stat(path, options), this.signal);
|
|
22409
22384
|
if (stat.type === "directory")
|
|
22410
22385
|
throw new CommandFailure(`${context.command}: ${target}: is a directory`, 1);
|
|
22411
|
-
if (stat.type !== "file")
|
|
22386
|
+
if (stat.type !== "file" && stat.type !== "character" && stat.type !== "fifo")
|
|
22412
22387
|
throw new CommandFailure(`${target}: not a regular file`, 1);
|
|
22413
22388
|
await interruptible(this.fs.access(path, ACCESS_MODES.R_OK, options), this.signal);
|
|
22414
22389
|
const maxBytes = this.budget.limits.maxSourceBytes - this.budget.sourceBytes;
|
|
@@ -23150,7 +23125,7 @@ export class Runtime {
|
|
|
23150
23125
|
return 1;
|
|
23151
23126
|
}
|
|
23152
23127
|
const options = new Map();
|
|
23153
|
-
for (const name of setNamespace ? ["allexport", "braceexpand", "errexit", "noclobber", "noexec", "noglob", "nounset", "pipefail"] : ["dotglob", "extglob", "globstar", "nocaseglob", "nocasematch", "nullglob"]) {
|
|
23128
|
+
for (const name of setNamespace ? ["allexport", "braceexpand", "errexit", "noclobber", "noexec", "noglob", "nounset", "pipefail"] : ["dotglob", "expand_aliases", "extglob", "failglob", "globstar", "inherit_errexit", "lastpipe", "nocaseglob", "nocasematch", "nullglob"]) {
|
|
23154
23129
|
options.set(name, {
|
|
23155
23130
|
get enabled() { return name === "braceexpand" ? state.braceexpand !== false : !!state[name]; }, set enabled(value) { state[name] = value; },
|
|
23156
23131
|
});
|
|
@@ -23620,6 +23595,12 @@ export class Runtime {
|
|
|
23620
23595
|
}
|
|
23621
23596
|
if (command === "shopt")
|
|
23622
23597
|
return this.shoptBuiltin(context, state);
|
|
23598
|
+
if (command === "alias" || command === "unalias") {
|
|
23599
|
+
const aliases = state.aliases ??= new Map();
|
|
23600
|
+
const limits = { maxArgumentBytes: this.budget.limits.maxExpansionBytes, maxAliasBytes: this.budget.limits.maxExpansionBytes };
|
|
23601
|
+
const definition = command === "alias" ? createAliasCommand({ aliases, limits }) : createUnaliasCommand({ aliases, limits });
|
|
23602
|
+
return (await definition.execute(context)).exitCode;
|
|
23603
|
+
}
|
|
23623
23604
|
if (command === "let")
|
|
23624
23605
|
return this.letBuiltin(context, state);
|
|
23625
23606
|
if (command === "mapfile" || command === "readarray")
|
|
@@ -24632,6 +24613,8 @@ export class Runtime {
|
|
|
24632
24613
|
}
|
|
24633
24614
|
if (command === "break" || command === "continue") {
|
|
24634
24615
|
if (!state.loopDepth) {
|
|
24616
|
+
if (state._subshellInLoop)
|
|
24617
|
+
throw completedExit(0, command, 1);
|
|
24635
24618
|
await writeDiagnostic(stderr, `${command}: only meaningful in a loop\n`);
|
|
24636
24619
|
return 0;
|
|
24637
24620
|
}
|
|
@@ -24868,7 +24851,7 @@ export class Runtime {
|
|
|
24868
24851
|
if (operator === "+" ? !missing : missing) {
|
|
24869
24852
|
if (operator === "=")
|
|
24870
24853
|
throw new ArrayFailure(`${part.name}[${memberSelector.separator}]: bad array subscript`);
|
|
24871
|
-
const alternate = concatShellValues(await this.valueWord(part.alternate, state, this.parameterOperandIO(part.alternate, state, io), false, false, hereString, false, undefined, hereDocument), io[valueScope]);
|
|
24854
|
+
const alternate = concatShellValues(await this.valueWord(part.alternate, state, this.parameterOperandIO(part.alternate, state, io), false, false, hereString, false, undefined, hereDocument || part.quoted), io[valueScope]);
|
|
24872
24855
|
if (operator === "?")
|
|
24873
24856
|
throw new ParameterExpansionFailure(`${part.name}: ${shellValueText(alternate) || "parameter not set"}`, io.diagnosticLine ?? part.line);
|
|
24874
24857
|
return alternate;
|
|
@@ -24892,12 +24875,13 @@ export class Runtime {
|
|
|
24892
24875
|
if (operator === "+" ? !missing : missing) {
|
|
24893
24876
|
const operandIO = this.parameterOperandIO(part.alternate, state, io);
|
|
24894
24877
|
if (operator === "=") {
|
|
24895
|
-
|
|
24878
|
+
const elemAlt = part.quoted ? { ...part.alternate, parts: part.alternate.parts.map(p => ({ ...p, quoted: true })) } : part.alternate;
|
|
24879
|
+
await this.arrayAssignment({ kind: "element", name: part.name, index: element.index, append: false, value: elemAlt }, state, operandIO);
|
|
24896
24880
|
const assigned = store.get(part.name);
|
|
24897
24881
|
const assignedIndex = assigned.associative ? await this.arrayIndex(assigned, element.index, state, io, store.owner) : index;
|
|
24898
24882
|
return assignedIndex === undefined ? "" : assigned.getValue(assignedIndex) ?? "";
|
|
24899
24883
|
}
|
|
24900
|
-
const alternate = concatShellValues(await this.valueWord(part.alternate, state, operandIO, false, false, hereString, false, undefined, hereDocument), io[valueScope]);
|
|
24884
|
+
const alternate = concatShellValues(await this.valueWord(part.alternate, state, operandIO, false, false, hereString, false, undefined, hereDocument || part.quoted), io[valueScope]);
|
|
24901
24885
|
if (operator === "?")
|
|
24902
24886
|
throw new ParameterExpansionFailure(`${part.name}: ${shellValueText(alternate) || (part.operator.startsWith(":") ? "parameter null or not set" : "parameter not set")}`, io.diagnosticLine ?? part.line);
|
|
24903
24887
|
return alternate;
|
|
@@ -25144,13 +25128,32 @@ export class Runtime {
|
|
|
25144
25128
|
if (state.depth >= this.budget.limits.maxSubstitutionDepth)
|
|
25145
25129
|
this.budget.fail("maxSubstitutionDepth");
|
|
25146
25130
|
this.signal.throwIfAborted();
|
|
25147
|
-
const
|
|
25131
|
+
const ids = state.processSubstitutionIds ??= { next: 0 };
|
|
25132
|
+
const requestedDirectory = pathOf(state, state.variables.TMPDIR || "/tmp");
|
|
25133
|
+
const directory = requestedDirectory === "/" ? "/tmp" : requestedDirectory;
|
|
25134
|
+
await this.sourceFs.mkdir(directory, { recursive: true, signal: this.signal });
|
|
25135
|
+
let tempPath = "";
|
|
25136
|
+
let owned = false;
|
|
25148
25137
|
io[invocationScope].register(async () => {
|
|
25138
|
+
if (owned)
|
|
25139
|
+
try {
|
|
25140
|
+
await this.sourceFs.rm(tempPath, { force: true });
|
|
25141
|
+
}
|
|
25142
|
+
catch { }
|
|
25143
|
+
});
|
|
25144
|
+
while (!owned) {
|
|
25145
|
+
this.budget.tick();
|
|
25146
|
+
tempPath = pathOf(state, `${directory}/.procsub-${++ids.next}`);
|
|
25149
25147
|
try {
|
|
25150
|
-
await this.sourceFs.
|
|
25148
|
+
await this.sourceFs.writeFile(tempPath, new Uint8Array(0), { flag: "wx", signal: this.signal });
|
|
25149
|
+
owned = true;
|
|
25151
25150
|
}
|
|
25152
|
-
catch {
|
|
25153
|
-
|
|
25151
|
+
catch (error) {
|
|
25152
|
+
this.signal.throwIfAborted();
|
|
25153
|
+
if (!(error instanceof FsError) || error.code !== "EEXIST")
|
|
25154
|
+
throw error;
|
|
25155
|
+
}
|
|
25156
|
+
}
|
|
25154
25157
|
if (part.direction === "<") {
|
|
25155
25158
|
const capture = new Capture();
|
|
25156
25159
|
const child = await cloneState(state, this.signal);
|
|
@@ -25161,7 +25164,6 @@ export class Runtime {
|
|
|
25161
25164
|
child.errexit = false;
|
|
25162
25165
|
delete child.redirectAssignments;
|
|
25163
25166
|
child.depth++;
|
|
25164
|
-
child.loopDepth = 0;
|
|
25165
25167
|
const references = new PipeDescriptorFrame(io[invocationScope]);
|
|
25166
25168
|
const lifetime = new DescriptorLifetime();
|
|
25167
25169
|
const captureIO = isolateIO({
|
|
@@ -25215,7 +25217,6 @@ export class Runtime {
|
|
|
25215
25217
|
child.errexit = false;
|
|
25216
25218
|
delete child.redirectAssignments;
|
|
25217
25219
|
child.depth++;
|
|
25218
|
-
child.loopDepth = 0;
|
|
25219
25220
|
const prepared = prepareBytesInput(bytes, this.budget);
|
|
25220
25221
|
const input = new ShellInput(prepared.source, this.budget, this.commandSignal, prepared.options);
|
|
25221
25222
|
const lifetime = new DescriptorLifetime(async () => {
|
|
@@ -25265,7 +25266,7 @@ export class Runtime {
|
|
|
25265
25266
|
child.isolated = true;
|
|
25266
25267
|
child.variables.BASH_SUBSHELL = String(Number(state.variables.BASH_SUBSHELL ?? 0) + 1);
|
|
25267
25268
|
child.extensions = forkExtensions(state.extensions, "substitution");
|
|
25268
|
-
if (state.profile !== "sh")
|
|
25269
|
+
if (state.profile !== "sh" && !state.inherit_errexit)
|
|
25269
25270
|
child.errexit = false;
|
|
25270
25271
|
for (const [name, value] of state.redirectAssignments ?? []) {
|
|
25271
25272
|
await this.writeVariable(child, name, value, io);
|
|
@@ -25273,7 +25274,6 @@ export class Runtime {
|
|
|
25273
25274
|
}
|
|
25274
25275
|
delete child.redirectAssignments;
|
|
25275
25276
|
child.depth++;
|
|
25276
|
-
child.loopDepth = 0;
|
|
25277
25277
|
const pipeline = part.script.lists.length === 1 && part.script.lists[0].pipelines.length === 1 ? part.script.lists[0].pipelines[0] : undefined;
|
|
25278
25278
|
const command = pipeline && !pipeline.negate && pipeline.commands.length === 1 ? pipeline.commands[0] : undefined;
|
|
25279
25279
|
const fileShortcut = command?.kind === "simple" && command.words.length === 0 && command.redirects.length === 1 && command.redirects[0].operator === "<";
|
|
@@ -25416,16 +25416,19 @@ export class Runtime {
|
|
|
25416
25416
|
if ((operator === "+" && !missing) || (operator !== "+" && missing)) {
|
|
25417
25417
|
const operandIO = this.parameterOperandIO(part.alternate, state, io);
|
|
25418
25418
|
let alternate;
|
|
25419
|
+
const altWord = !hereDocument && !part.quoted && operator === "="
|
|
25420
|
+
? { ...part.alternate, parts: expandTildes(part.alternate.parts, state.variables, this.budget, undefined, true) }
|
|
25421
|
+
: part.alternate;
|
|
25419
25422
|
if (operator === "=" && arrayStore(state)?.get(part.name)) {
|
|
25420
25423
|
alternate = "";
|
|
25421
25424
|
await this.arrayZero(state, part.name, io, async () => {
|
|
25422
|
-
retained = await this.arrayJoin(requireArrays(state).owner, await this.valueWord(
|
|
25425
|
+
retained = await this.arrayJoin(requireArrays(state).owner, await this.valueWord(altWord, state, operandIO, false, false, hereString, false, undefined, hereDocument || part.quoted || operator === "="), "");
|
|
25423
25426
|
return retained;
|
|
25424
25427
|
});
|
|
25425
25428
|
value = shellValueText(retained);
|
|
25426
25429
|
return part.length ? this.valueLength(retained, state, io) : retained;
|
|
25427
25430
|
}
|
|
25428
|
-
retained = concatShellValues(await this.valueWord(
|
|
25431
|
+
retained = concatShellValues(await this.valueWord(altWord, state, operandIO, false, false, hereString, false, undefined, hereDocument || part.quoted || operator === "="), io[valueScope]);
|
|
25429
25432
|
alternate = shellValueText(retained);
|
|
25430
25433
|
if (operator === "?")
|
|
25431
25434
|
throw new ParameterExpansionFailure(`${part.name}: ${alternate || (part.operator.startsWith(":") ? "parameter null or not set" : "parameter not set")}`, io.diagnosticLine ?? part.line);
|
|
@@ -26010,7 +26013,7 @@ export class Runtime {
|
|
|
26010
26013
|
}
|
|
26011
26014
|
if (part.indirect || part.specialParameter)
|
|
26012
26015
|
return undefined;
|
|
26013
|
-
if (part.name === "@" || part.name === "*" || part.name === "PIPESTATUS" || part.name === "LINENO" || part.name === "BASH_SUBSHELL" || part.name === "_" || part.name === "FUNCNAME" || part.name === "DIRSTACK")
|
|
26016
|
+
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")
|
|
26014
26017
|
return undefined;
|
|
26015
26018
|
if (!isShellIdentifier(part.name))
|
|
26016
26019
|
return undefined;
|
|
@@ -35449,7 +35452,7 @@ export class Runtime {
|
|
|
35449
35452
|
if (p.kind === "text")
|
|
35450
35453
|
continue;
|
|
35451
35454
|
if (p.kind === "variable") {
|
|
35452
|
-
if (p.name === "BASH_SUBSHELL" || p.name === "RANDOM" || p.name === "SECONDS")
|
|
35455
|
+
if (p.name === "BASH_SUBSHELL" || p.name === "BASHPID" || p.name === "RANDOM" || p.name === "SECONDS")
|
|
35453
35456
|
return false;
|
|
35454
35457
|
if (!p.indirect && !p.prefixNames && !p.length && !p.substring && !p.transform && p.operator === undefined && getArraySelector(p) === undefined && (p.name === "?" || p.name === "#" || (p.name.length === 1 && p.name >= "1" && p.name <= "9"))) {
|
|
35455
35458
|
const activePos = this._fastSubPositional ?? rawState.positional;
|
|
@@ -35476,6 +35479,10 @@ export class Runtime {
|
|
|
35476
35479
|
return true;
|
|
35477
35480
|
}
|
|
35478
35481
|
tryFastPureSubstitution(part, state, rawState, io) {
|
|
35482
|
+
if (!cCollation(rawState.variables.LC_ALL || rawState.variables.LC_COLLATE || rawState.variables.LANG || "C"))
|
|
35483
|
+
return undefined;
|
|
35484
|
+
if (this.budget.limits.maxPipelineBytes !== Infinity)
|
|
35485
|
+
return undefined;
|
|
35479
35486
|
// Synchronous evaluators do not expose cumulative source-read accounting.
|
|
35480
35487
|
// Use the command context whenever the caller has set an input ceiling.
|
|
35481
35488
|
if (this.budget.limits.maxInputBytes !== Infinity)
|
|
@@ -35929,8 +35936,6 @@ export class Runtime {
|
|
|
35929
35936
|
syncPurePipelineSlotInUse = true;
|
|
35930
35937
|
this.budget.enterPipelineStages(n);
|
|
35931
35938
|
this.budget.commands += n;
|
|
35932
|
-
const scope = io[invocationScope];
|
|
35933
|
-
let context = pooledSyncPipeContext;
|
|
35934
35939
|
let prevBuf = sharedSyncPipeBuf0;
|
|
35935
35940
|
let prevLen = fastSharedTextEncoder.encodeInto(stage0Formatted, sharedSyncPipeBuf0).written;
|
|
35936
35941
|
try {
|
|
@@ -37017,35 +37022,9 @@ export class Runtime {
|
|
|
37017
37022
|
prevLen = written;
|
|
37018
37023
|
continue;
|
|
37019
37024
|
}
|
|
37020
|
-
|
|
37021
|
-
|
|
37022
|
-
|
|
37023
|
-
context = new FastShellCommandContext(this, rawState, io, scope, firstName, stageArgs, undefined, undefined, true);
|
|
37024
|
-
pooledSyncPipeContext = context;
|
|
37025
|
-
}
|
|
37026
|
-
context.resetDirectStage(this, rawState, io, scope, firstName, stageArgs, sharedSyncPipeReader, false, sharedSyncPipeWriter, this.signal);
|
|
37027
|
-
sharedSyncPipeReader.abortSignal = context.signal;
|
|
37028
|
-
scope.enterWork();
|
|
37029
|
-
this.budget.beginPathLookupSuspension();
|
|
37030
|
-
let resPromise;
|
|
37031
|
-
try {
|
|
37032
|
-
resPromise = extDef.execute(context);
|
|
37033
|
-
}
|
|
37034
|
-
finally {
|
|
37035
|
-
this.budget.endPathLookupSuspension();
|
|
37036
|
-
scope.leaveWork();
|
|
37037
|
-
}
|
|
37038
|
-
if (resPromise !== RESOLVED_EXIT_ZERO) {
|
|
37039
|
-
if (resPromise && typeof resPromise.catch === "function") {
|
|
37040
|
-
resPromise.catch(() => { });
|
|
37041
|
-
}
|
|
37042
|
-
pooledSyncPipeContext = undefined;
|
|
37043
|
-
context = undefined;
|
|
37044
|
-
return undefined;
|
|
37045
|
-
}
|
|
37046
|
-
this.signal.throwIfAborted();
|
|
37047
|
-
prevBuf = nextBuf;
|
|
37048
|
-
prevLen = sharedSyncPipeWriter.used;
|
|
37025
|
+
// A command executor may suspend. Decline before invoking it so the
|
|
37026
|
+
// ordinary pipeline owns its context and executes every stage once.
|
|
37027
|
+
return undefined;
|
|
37049
37028
|
}
|
|
37050
37029
|
if (prevBuf.subarray(0, prevLen).includes(0))
|
|
37051
37030
|
return undefined;
|
|
@@ -37057,12 +37036,6 @@ export class Runtime {
|
|
|
37057
37036
|
this.budget.bytes = previousBytes;
|
|
37058
37037
|
this.budget.commands = previousCommands;
|
|
37059
37038
|
}
|
|
37060
|
-
if (context)
|
|
37061
|
-
context.releaseDirectStage();
|
|
37062
|
-
sharedSyncPipeWriter.budget = undefined;
|
|
37063
|
-
sharedSyncPipeWriter.signal = undefined;
|
|
37064
|
-
sharedSyncPipeWriter.target = EMPTY_BYTES;
|
|
37065
|
-
sharedSyncPipeReader.reset(EMPTY_BYTES, 0);
|
|
37066
37039
|
syncPurePipelineSlotInUse = false;
|
|
37067
37040
|
this.budget.leavePipelineStages(n);
|
|
37068
37041
|
}
|
|
@@ -40173,6 +40146,8 @@ export class Runtime {
|
|
|
40173
40146
|
}
|
|
40174
40147
|
}
|
|
40175
40148
|
await sortExpansionStrings(found, work, true);
|
|
40149
|
+
if (!found.length && state.failglob)
|
|
40150
|
+
throw new FailglobFailure(`no match: ${value}`);
|
|
40176
40151
|
return found.length ? found : state.nullglob ? [] : [value];
|
|
40177
40152
|
}
|
|
40178
40153
|
finally {
|
|
@@ -40267,6 +40242,8 @@ export class Runtime {
|
|
|
40267
40242
|
remaining: Math.min(Number.MAX_SAFE_INTEGER, this.budget.limits.maxExpansionBytes * 4 * (Math.ceil(Math.log2(found.length + 1)) + 1) + 1024), signal: this.signal, exhausted: () => this.budget.fail("maxExpansionBytes"),
|
|
40268
40243
|
};
|
|
40269
40244
|
await sortExpansionStrings(found, sortingWork, true);
|
|
40245
|
+
if (!found.length && state.failglob)
|
|
40246
|
+
throw new FailglobFailure(`no match: ${value}`);
|
|
40270
40247
|
return found.length ? found : state.nullglob ? [] : [value];
|
|
40271
40248
|
}
|
|
40272
40249
|
}
|
|
@@ -40286,6 +40263,7 @@ export class RootShellState {
|
|
|
40286
40263
|
this.substitutionStatus = 0;
|
|
40287
40264
|
this.lastArgument = "";
|
|
40288
40265
|
this.secondsOrigin = Date.now();
|
|
40266
|
+
this.processSubstitutionIds = { next: 0 };
|
|
40289
40267
|
}
|
|
40290
40268
|
get exported() {
|
|
40291
40269
|
const raw = stateMonitor(this)?.raw;
|