@poe-platform/safe-bash 0.1.799 → 0.1.801
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 +48 -22
- package/dist/image-ast/index.browser.js +1503 -98
- package/dist/image-ast/index.js +1503 -98
- package/dist/mp4-ast/types.d.ts +1 -0
- package/dist/office-package/zip.d.ts +2 -0
- package/dist/office-package/zip.js +1 -1
- package/dist/pdf-ast/index.js +5 -4
- package/dist/safe-bash/chunks/{chunk-LUOFIVNI.js → chunk-3NDIFSNM.js} +3 -3
- package/dist/safe-bash/chunks/chunk-3R3AANOR.js +26 -0
- package/dist/safe-bash/chunks/{chunk-TRVGCN3U.js → chunk-45PK3NWI.js} +4 -4
- package/dist/safe-bash/chunks/{chunk-KHMGTPD6.js → chunk-46Z5E5EV.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-XB3B7KMM.js → chunk-6O77NL2S.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-T3JTVIEP.js → chunk-6PAVEFT3.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-PYVEAFJM.js → chunk-74GHTNJA.js} +3 -2
- package/dist/safe-bash/chunks/{chunk-LQHGH25W.js → chunk-7R5BDCG7.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-WUNK5NXJ.js → chunk-7VNF5BFF.js} +1140 -1660
- package/dist/safe-bash/chunks/{chunk-NHOXKQNE.js → chunk-A7XEHALN.js} +6 -6
- package/dist/safe-bash/chunks/{chunk-MHZ24KEI.js → chunk-AM5ESLPH.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-3L3T6LYV.js → chunk-AUSNDQTJ.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-YG5WAHK7.js → chunk-B7TAL7S5.js} +1 -3
- package/dist/safe-bash/chunks/{chunk-K7IQZE7D.js → chunk-C5OWC2TL.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-F3RV2F72.js → chunk-CHYGPFVM.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-M4CFCXHN.js → chunk-CS4MNM6I.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-H6JW3E4F.js → chunk-CTVWDACF.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-KTGR4U57.js → chunk-D3ANYGMC.js} +2 -3
- package/dist/safe-bash/chunks/{chunk-ENR3HB2B.js → chunk-E7OYNDGL.js} +1 -2
- package/dist/safe-bash/chunks/{chunk-SOZK5JVX.js → chunk-FBUCWVTE.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-NX2SQVON.js → chunk-FNDNHAGE.js} +46 -27
- package/dist/safe-bash/chunks/{chunk-KCVSVD65.js → chunk-I5HZ4FGE.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-KMH2DF3I.js → chunk-ICFDYV64.js} +7 -2
- package/dist/safe-bash/chunks/{chunk-T5KKDMYB.js → chunk-IVRQ4BXL.js} +7 -1
- package/dist/safe-bash/chunks/{chunk-KV7PKOHV.js → chunk-IWDICZVK.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-I4OAEOP6.js → chunk-J42RIHHJ.js} +1 -1
- package/dist/safe-bash/chunks/chunk-K6VCD7IY.js +106 -0
- package/dist/safe-bash/chunks/{chunk-63FXVDGF.js → chunk-LVOBFF4D.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-U5NUZPCC.js → chunk-MHMMRCYC.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-6HZYFL3H.js → chunk-NR3EM4LS.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-VYZTG3GV.js → chunk-NZQXYWA3.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-JSVX4VIA.js → chunk-OQRVVGR6.js} +3 -2
- package/dist/safe-bash/chunks/{chunk-B3DDEDH2.js → chunk-OV6IHKO6.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-SPYL72GN.js → chunk-PQRAK7HU.js} +1196 -5781
- package/dist/safe-bash/chunks/chunk-SZH7EJLD.js +9221 -0
- package/dist/safe-bash/chunks/{chunk-AKC46AF6.js → chunk-TFIBK2GI.js} +8 -41
- package/dist/safe-bash/chunks/{chunk-ZNAFMYIA.js → chunk-UE5KZDEK.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-QU3BVQ53.js → chunk-UTBUUFDM.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-6IBTC4YL.js → chunk-VQDD3G76.js} +93 -39
- package/dist/safe-bash/chunks/{chunk-IUTD5FH5.js → chunk-VTH3MLDU.js} +2 -7
- package/dist/safe-bash/chunks/{chunk-LLZCZ24K.js → chunk-XVOSKJE2.js} +1 -1
- package/dist/safe-bash/chunks/{csvkit-W2UEKH6P.js → csvkit-TACDU7FC.js} +3 -3
- package/dist/safe-bash/chunks/{ffmpeg-42CGASMV.js → ffmpeg-WTC3TEFI.js} +2 -2
- package/dist/safe-bash/chunks/{gh-26GYLH6D.js → gh-6WU6PXL4.js} +2 -2
- package/dist/safe-bash/chunks/{git-YREKMUVD.js → git-EFZIGJW4.js} +2 -2
- package/dist/safe-bash/chunks/{imagemagick-3YIX4XO2.js → imagemagick-EIEYGWPF.js} +2 -2
- package/dist/safe-bash/chunks/{implementation-E3YMKU3Z.js → implementation-MLFHUQ5M.js} +2 -2
- package/dist/safe-bash/chunks/mmdc-ROQJT5HQ.js +118 -0
- package/dist/safe-bash/chunks/{pdfimages-UE2UISP2.js → pdfimages-DW7LWXFI.js} +2 -2
- package/dist/safe-bash/chunks/{pdfinfo-RGARKLI5.js → pdfinfo-TIP6XLUQ.js} +4 -12
- package/dist/safe-bash/chunks/{pdftk-JY3WVCCC.js → pdftk-DMG22ITZ.js} +2 -2
- package/dist/safe-bash/chunks/{pdftoppm-GPD3BMPY.js → pdftoppm-WNDYR72T.js} +2 -2
- package/dist/safe-bash/chunks/{pdftotext-K7GQ2QJZ.js → pdftotext-5IPZ4NI7.js} +2 -2
- package/dist/safe-bash/chunks/{qpdf-F4U7WUSU.js → qpdf-TTX2DIUA.js} +2 -2
- package/dist/safe-bash/chunks/{sips-RWENS7X5.js → sips-XYS46JPJ.js} +2 -2
- package/dist/safe-bash/chunks/{soffice-IT6W2C5F.js → soffice-TU73E5KL.js} +2 -2
- package/dist/safe-bash/chunks/{wkhtmltopdf-JYNDAHIZ.js → wkhtmltopdf-FSZ2CHGE.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-QBGA56UH.js → chunk-2ELYGJDD.js} +7 -7
- package/dist/safe-bash/command-chunks/chunk-2FGJYFWZ.js +44 -0
- package/dist/safe-bash/command-chunks/chunk-2H4JTFIL.js +53 -0
- package/dist/safe-bash/command-chunks/{chunk-52PCQXD2.js → chunk-2NHI5F5S.js} +2 -1
- package/dist/safe-bash/command-chunks/{chunk-HDKVO47G.js → chunk-2SQEIUGJ.js} +3 -3
- package/dist/safe-bash/command-chunks/chunk-364TMWBT.js +946 -0
- package/dist/safe-bash/command-chunks/chunk-3E2OIS2J.js +7037 -0
- package/dist/safe-bash/command-chunks/chunk-3HHCU5YU.js +380 -0
- package/dist/safe-bash/command-chunks/{chunk-TF6OA2GK.js → chunk-3NV3HYT2.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-4B7Y7S6E.js +61 -0
- package/dist/safe-bash/command-chunks/{chunk-LLCXZKZ6.js → chunk-4BB2SWJ5.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-IEXHHNOF.js → chunk-4J5CZ2DP.js} +2 -7
- package/dist/safe-bash/command-chunks/{chunk-WDHI3S6Y.js → chunk-4OOUQTQO.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-4ZHMW6F5.js +104 -0
- package/dist/safe-bash/command-chunks/{chunk-YMONDXET.js → chunk-4ZQWGOZB.js} +2 -2
- package/dist/safe-bash/command-chunks/chunk-5BSTFCXG.js +553 -0
- package/dist/safe-bash/command-chunks/{chunk-MKQVQMXO.js → chunk-5LU4UCBR.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-5PWJG2UK.js +174 -0
- package/dist/safe-bash/command-chunks/chunk-5TBUOBDE.js +346 -0
- package/dist/safe-bash/command-chunks/{chunk-JMPP4TCW.js → chunk-5UBXNSFZ.js} +3 -2
- package/dist/safe-bash/command-chunks/chunk-5XY4DTNG.js +34 -0
- package/dist/safe-bash/command-chunks/chunk-5ZMZ573Q.js +140 -0
- package/dist/safe-bash/command-chunks/{chunk-3NG75MOB.js → chunk-67GQA75T.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-67QKREJK.js +347 -0
- package/dist/safe-bash/command-chunks/{chunk-L6SU4S26.js → chunk-6B7WQIKB.js} +0 -7
- package/dist/safe-bash/command-chunks/chunk-6BNTBWIK.js +327 -0
- package/dist/safe-bash/command-chunks/chunk-6EPHJGGF.js +23 -0
- package/dist/safe-bash/command-chunks/chunk-6F4XCVON.js +266 -0
- package/dist/safe-bash/command-chunks/chunk-6KJ3LPI2.js +94 -0
- package/dist/safe-bash/command-chunks/{chunk-HLDTOR7M.js → chunk-6ZVI7LUY.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-X6NJC3IC.js → chunk-75OFBY5R.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-7K6JYKPJ.js +422 -0
- package/dist/safe-bash/command-chunks/chunk-7N2LI2KO.js +206 -0
- package/dist/safe-bash/command-chunks/{chunk-MRW5HD2D.js → chunk-7O3E4LPT.js} +4 -22
- package/dist/safe-bash/command-chunks/chunk-7U7EXOXX.js +1392 -0
- package/dist/safe-bash/command-chunks/{chunk-6CYTRQ24.js → chunk-7VTKQUA5.js} +20 -17
- package/dist/safe-bash/command-chunks/{chunk-BZPAWTUL.js → chunk-AEF5BA3D.js} +1 -1
- package/dist/safe-bash/command-chunks/{pptx-GBPNWNEP-7EQEVXV5.js → chunk-AI5JAXQF.js} +34820 -18029
- package/dist/safe-bash/command-chunks/{chunk-63R3FEZJ.js → chunk-AIV5BF5W.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-AYUTO323.js → chunk-AKJG2XD3.js} +2 -18
- package/dist/safe-bash/command-chunks/{chunk-J34TZVMW.js → chunk-ALDC4XP4.js} +0 -5
- package/dist/safe-bash/command-chunks/chunk-AMO3THU4.js +105 -0
- package/dist/safe-bash/command-chunks/chunk-ARBYOQUZ.js +65 -0
- package/dist/safe-bash/command-chunks/chunk-BAGCY35S.js +231 -0
- package/dist/safe-bash/command-chunks/chunk-BAXU7B5Z.js +101 -0
- package/dist/safe-bash/command-chunks/{chunk-44AHAB5O.js → chunk-BDSMROQZ.js} +1 -4
- package/dist/safe-bash/command-chunks/chunk-BNOU5YQS.js +182 -0
- package/dist/safe-bash/command-chunks/{chunk-4ZALPDBV.js → chunk-BPE5INLI.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-OT4LZMLB.js → chunk-BR73BIOW.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-C5YYCQHW.js +1444 -0
- package/dist/safe-bash/command-chunks/chunk-C7I25AAL.js +25 -0
- package/dist/safe-bash/command-chunks/{chunk-4ONEXMD3.js → chunk-CAP7ZJSY.js} +8 -8
- package/dist/safe-bash/command-chunks/{chunk-DWFLVJC6.js → chunk-CCRHMAU5.js} +2 -1
- package/dist/safe-bash/command-chunks/chunk-CQ5YGOGB.js +150 -0
- package/dist/safe-bash/command-chunks/{chunk-JCNNOMBV.js → chunk-CQTRW45K.js} +3 -2
- package/dist/safe-bash/command-chunks/{chunk-N2F74VRO.js → chunk-CZ7EN3JG.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-DB453IE6.js +122 -0
- package/dist/safe-bash/command-chunks/{chunk-KKG4BAFZ.js → chunk-DIEPXUM4.js} +6 -0
- package/dist/safe-bash/command-chunks/chunk-DOKKNRRM.js +87 -0
- package/dist/safe-bash/command-chunks/{chunk-2PX5B7T5.js → chunk-DQAVUDDX.js} +2 -2
- package/dist/safe-bash/command-chunks/chunk-DT7BCTWY.js +249 -0
- package/dist/safe-bash/command-chunks/{chunk-6BETHLXZ.js → chunk-DZCY63VJ.js} +13 -11
- package/dist/safe-bash/command-chunks/{chunk-QUENU6GM.js → chunk-E55UKBIE.js} +3 -3
- package/dist/safe-bash/command-chunks/chunk-EK6YNAXT.js +343 -0
- package/dist/safe-bash/command-chunks/chunk-EQ4HV54N.js +22 -0
- package/dist/safe-bash/command-chunks/{chunk-HLGKIZ25.js → chunk-F6OYH562.js} +2 -0
- package/dist/safe-bash/command-chunks/{chunk-MC3VWLIZ.js → chunk-FDBUV4HJ.js} +28 -19
- package/dist/safe-bash/command-chunks/{chunk-7FKUC34S.js → chunk-FPVUD6TH.js} +6 -3
- package/dist/safe-bash/command-chunks/chunk-FXELCPFX.js +195 -0
- package/dist/safe-bash/command-chunks/chunk-FXOA7RBK.js +42 -0
- package/dist/safe-bash/command-chunks/{chunk-LPORMIZS.js → chunk-FZTK4MFI.js} +9 -9
- package/dist/safe-bash/command-chunks/{chunk-K543PB3I.js → chunk-G66QUHIZ.js} +6 -35
- package/dist/safe-bash/command-chunks/chunk-GFQZCKO6.js +272 -0
- package/dist/safe-bash/command-chunks/{chunk-CU5RLO62.js → chunk-GLOZX57Y.js} +92 -18
- package/dist/safe-bash/command-chunks/chunk-GMIHJYDG.js +331 -0
- package/dist/safe-bash/command-chunks/chunk-GOB777HR.js +97 -0
- package/dist/safe-bash/command-chunks/chunk-GRBWW4SG.js +48 -0
- package/dist/safe-bash/command-chunks/{chunk-PPNBNFAU.js → chunk-GYQ2HAKQ.js} +8 -8
- package/dist/safe-bash/command-chunks/chunk-H622NS6Z.js +11 -0
- package/dist/safe-bash/command-chunks/{chunk-UI32HWGS.js → chunk-HMOZ6XVJ.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-AVSPNLWV.js → chunk-I237SNW5.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-43GSSUAY.js → chunk-II77KPZN.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-ZS3QPNUL.js → chunk-IR2BY7EL.js} +21 -6
- package/dist/safe-bash/command-chunks/{chunk-SG424QWS.js → chunk-JDYXY44P.js} +2 -2
- package/dist/safe-bash/command-chunks/chunk-JNZ3CVAE.js +147 -0
- package/dist/safe-bash/command-chunks/{chunk-4QJOYXVB.js → chunk-JV7LBUTP.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-IKS2YXZQ.js → chunk-K67MWWWH.js} +3 -3
- package/dist/safe-bash/command-chunks/chunk-KFVV7ZJO.js +216 -0
- package/dist/safe-bash/command-chunks/{chunk-G4PNVO6Z.js → chunk-KP7AO66M.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-KMCZ6P4O.js → chunk-KQLD3AED.js} +68 -7
- package/dist/safe-bash/command-chunks/chunk-KWESKQHR.js +25 -0
- package/dist/safe-bash/command-chunks/{chunk-YZ5SVZFD.js → chunk-KXU3IRUO.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-C7IHMJEW.js → chunk-KZC5UWFF.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-2WRTLCGK.js → chunk-LAOM65EE.js} +5 -5
- package/dist/safe-bash/command-chunks/chunk-LE5LZNHE.js +204 -0
- package/dist/safe-bash/command-chunks/{chunk-HFII3QYO.js → chunk-LWS62ISU.js} +46 -32
- package/dist/safe-bash/command-chunks/{chunk-BZDDAPSV.js → chunk-LWSBAWLT.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-MDH5T4OS.js +41 -0
- package/dist/safe-bash/command-chunks/{chunk-X7TM3AKW.js → chunk-MIXBO6U7.js} +20 -7
- package/dist/safe-bash/command-chunks/chunk-MM6HU6CX.js +20 -0
- package/dist/safe-bash/command-chunks/{chunk-MYJAZ3U2.js → chunk-MPL2466A.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-HLBX5IRS.js → chunk-MQFIPHIQ.js} +46 -81
- package/dist/safe-bash/command-chunks/{chunk-ZJBR5Q5I.js → chunk-MSFXC3OC.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-NI7MKJPN.js → chunk-MTQH74CF.js} +3 -55
- package/dist/safe-bash/command-chunks/chunk-MWUZZWXK.js +354 -0
- package/dist/safe-bash/command-chunks/chunk-N4PFUSRM.js +35 -0
- package/dist/safe-bash/command-chunks/chunk-NCD7PEWH.js +298 -0
- package/dist/safe-bash/command-chunks/chunk-NFGI5IGF.js +266 -0
- package/dist/safe-bash/command-chunks/{chunk-I3K5RYU4.js → chunk-NKFYQSES.js} +73 -26
- package/dist/safe-bash/command-chunks/{chunk-KVFCSLKK.js → chunk-NXEQ3ESQ.js} +6 -0
- package/dist/safe-bash/command-chunks/{chunk-NGWB2YBL.js → chunk-O4JQSB7O.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-7L24L4UO.js → chunk-OQU6UT6X.js} +2 -20
- package/dist/safe-bash/command-chunks/{chunk-3VGGYEDH.js → chunk-ORYGZYKW.js} +4 -3
- package/dist/safe-bash/command-chunks/{chunk-ZXKW7SJ2.js → chunk-OYYV7ZAF.js} +2 -2
- package/dist/safe-bash/command-chunks/chunk-P2N33UMN.js +270 -0
- package/dist/safe-bash/command-chunks/{chunk-Q7Q5GM5S.js → chunk-P5APDEFB.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-X2YQLGKS.js → chunk-PCEFOYA3.js} +240 -148
- package/dist/safe-bash/command-chunks/{chunk-OLQG7ZCN.js → chunk-PEF7K3UQ.js} +136 -75
- package/dist/safe-bash/command-chunks/chunk-PII4YEZW.js +123 -0
- package/dist/safe-bash/command-chunks/{chunk-AIRGA2SU.js → chunk-PMBFZXTK.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-ZT4KSS2V.js → chunk-PTT3I223.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-4Y3WVMK4.js → chunk-PV66YWHB.js} +1 -0
- package/dist/safe-bash/command-chunks/chunk-Q3EWDEUQ.js +185 -0
- package/dist/safe-bash/command-chunks/{chunk-AXK3H4PX.js → chunk-QJ33BHI4.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-QKFSRZGQ.js +1091 -0
- package/dist/safe-bash/command-chunks/{chunk-JZSNU2MY.js → chunk-QKJLP53H.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-VVI4Z73I.js → chunk-QP4R6GLA.js} +5 -1
- package/dist/safe-bash/command-chunks/chunk-RMWQAAO5.js +2488 -0
- package/dist/safe-bash/command-chunks/{chunk-QDTBMSBE.js → chunk-RO62EWX6.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-HRLIAMXC.js → chunk-RZZI24ZE.js} +7 -6
- package/dist/safe-bash/command-chunks/{chunk-PFAADCB5.js → chunk-SDNBCQ3X.js} +10 -24
- package/dist/safe-bash/command-chunks/chunk-SEM36PG5.js +11 -0
- package/dist/safe-bash/command-chunks/{chunk-36O5OT7E.js → chunk-T35Y7YQD.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-ESMCX3YV.js → chunk-TGSNCQSR.js} +710 -143
- package/dist/safe-bash/command-chunks/chunk-TIOCQVUQ.js +557 -0
- package/dist/safe-bash/command-chunks/{chunk-T5H5UJQ3.js → chunk-TNOA7FCQ.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-GN2TKLE7.js → chunk-TS65BJHG.js} +5 -5
- package/dist/safe-bash/command-chunks/chunk-TSCGT46G.js +363 -0
- package/dist/safe-bash/command-chunks/chunk-UG7SMZFF.js +178 -0
- package/dist/safe-bash/command-chunks/{chunk-KBEURXFF.js → chunk-UN6WS55J.js} +3 -3
- package/dist/safe-bash/command-chunks/chunk-UXSR5BZH.js +136 -0
- package/dist/safe-bash/command-chunks/{chunk-SX2X3IH4.js → chunk-V2V5OCL3.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-V6BEDRMQ.js +112 -0
- package/dist/safe-bash/command-chunks/chunk-V7A7DRTU.js +293 -0
- package/dist/safe-bash/command-chunks/{chunk-5SHGJ7NO.js → chunk-VA5ZHYYA.js} +73 -33
- package/dist/safe-bash/command-chunks/{chunk-J4PEQWSF.js → chunk-VGG2DL5Q.js} +0 -1
- package/dist/safe-bash/command-chunks/chunk-VPR5LQYX.js +1228 -0
- package/dist/safe-bash/command-chunks/{chunk-EIVW3X3N.js → chunk-VSRGNQCP.js} +11 -6
- package/dist/safe-bash/command-chunks/{chunk-TYVCKQDH.js → chunk-VXSLJH7G.js} +56 -6
- package/dist/safe-bash/command-chunks/{chunk-PXYOWWMV.js → chunk-W7RAD4EW.js} +4 -3
- package/dist/safe-bash/command-chunks/{src-UJOWAS2S.js → chunk-WD3ERGRY.js} +77 -277
- package/dist/safe-bash/command-chunks/{chunk-5ZSM4UFN.js → chunk-WECIOOQB.js} +8 -64
- package/dist/safe-bash/command-chunks/{chunk-YFSDDFGV.js → chunk-WH627NJL.js} +446 -53
- package/dist/safe-bash/command-chunks/chunk-WNE7FPVR.js +236 -0
- package/dist/safe-bash/command-chunks/{chunk-UKS2XJZI.js → chunk-WPYIOKE3.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-HHP343KT.js → chunk-WTECBRU4.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-AO6Z5EQ7.js → chunk-WVE64WM2.js} +6 -5
- package/dist/safe-bash/command-chunks/chunk-WVHONVZ4.js +594 -0
- package/dist/safe-bash/command-chunks/chunk-XIIBTGC5.js +580 -0
- package/dist/safe-bash/command-chunks/chunk-XJXU3VVH.js +737 -0
- package/dist/safe-bash/command-chunks/chunk-XNLFHHOC.js +63 -0
- package/dist/safe-bash/command-chunks/{chunk-XAFSZDY2.js → chunk-XS72HTMA.js} +11 -0
- package/dist/safe-bash/command-chunks/chunk-Y5INTD6S.js +220 -0
- package/dist/safe-bash/command-chunks/chunk-YIQACGEW.js +43 -0
- package/dist/safe-bash/command-chunks/chunk-YOF7R4OY.js +80 -0
- package/dist/safe-bash/command-chunks/{chunk-VZHRZMS7.js → chunk-YOFC45RK.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-2FUAW6GO.js → chunk-Z45N42QC.js} +75 -11
- package/dist/safe-bash/command-chunks/chunk-ZHUWOUWB.js +618 -0
- package/dist/safe-bash/command-chunks/{chunk-OPUJSTHS.js → chunk-ZYHTWNAE.js} +215 -67
- package/dist/safe-bash/command-chunks/chunk-ZYXH3B66.js +636 -0
- package/dist/safe-bash/command-chunks/{model-store-L35QTZMJ.js → model-store-WPKMRPV4.js} +2 -2
- package/dist/safe-bash/command-chunks/pptx-7G52EJ6L-4JACH5FB.js +625 -0
- package/dist/safe-bash/command-chunks/python-worker-source-TYOFJMCW.js +4 -0
- package/dist/safe-bash/command-chunks/src-ICMQISAA.js +501 -0
- package/dist/safe-bash/commands/archive/create.d.ts +1 -17
- package/dist/safe-bash/commands/archive/create.js +1 -252
- package/dist/safe-bash/commands/archive/extract.d.ts +1 -11
- package/dist/safe-bash/commands/archive/extract.js +1 -640
- package/dist/safe-bash/commands/archive/format.d.ts +1 -32
- package/dist/safe-bash/commands/archive/format.js +1 -225
- package/dist/safe-bash/commands/archive/index.d.ts +5 -10
- package/dist/safe-bash/commands/archive/index.js +6 -931
- package/dist/safe-bash/commands/archive/listing.d.ts +1 -2
- package/dist/safe-bash/commands/archive/listing.js +1 -21
- package/dist/safe-bash/commands/archive/modes.d.ts +1 -5
- package/dist/safe-bash/commands/archive/modes.js +1 -182
- package/dist/safe-bash/commands/archive/options.d.ts +1 -53
- package/dist/safe-bash/commands/archive/options.js +1 -462
- package/dist/safe-bash/commands/archive/stream.d.ts +1 -22
- package/dist/safe-bash/commands/archive/stream.js +1 -188
- package/dist/safe-bash/commands/archive/transform.d.ts +1 -16
- package/dist/safe-bash/commands/archive/transform.js +1 -85
- package/dist/safe-bash/commands/archive/unzip/arguments.d.ts +1 -53
- package/dist/safe-bash/commands/archive/unzip/arguments.js +1 -322
- package/dist/safe-bash/commands/archive/unzip/safety.d.ts +1 -32
- package/dist/safe-bash/commands/archive/unzip/safety.js +1 -295
- package/dist/safe-bash/commands/archive/unzip.d.ts +1 -3
- package/dist/safe-bash/commands/archive/unzip.js +1 -398
- package/dist/safe-bash/commands/archive/zip/aes.d.ts +1 -17
- package/dist/safe-bash/commands/archive/zip/aes.js +1 -156
- package/dist/safe-bash/commands/archive/zip/comments.d.ts +1 -17
- package/dist/safe-bash/commands/archive/zip/comments.js +1 -83
- package/dist/safe-bash/commands/archive/zip/crc.d.ts +1 -1
- package/dist/safe-bash/commands/archive/zip/crc.js +1 -1
- package/dist/safe-bash/commands/archive/zip/crypto.d.ts +1 -19
- package/dist/safe-bash/commands/archive/zip/crypto.js +1 -118
- package/dist/safe-bash/commands/archive/zip/dates.d.ts +1 -4
- package/dist/safe-bash/commands/archive/zip/dates.js +1 -66
- package/dist/safe-bash/commands/archive/zip/environment.d.ts +1 -2
- package/dist/safe-bash/commands/archive/zip/environment.js +1 -62
- package/dist/safe-bash/commands/archive/zip/grow.d.ts +1 -3
- package/dist/safe-bash/commands/archive/zip/grow.js +1 -2
- package/dist/safe-bash/commands/archive/zip/help.d.ts +1 -4
- package/dist/safe-bash/commands/archive/zip/help.js +1 -182
- package/dist/safe-bash/commands/archive/zip/line-endings.d.ts +1 -2
- package/dist/safe-bash/commands/archive/zip/line-endings.js +1 -194
- package/dist/safe-bash/commands/archive/zip/log.d.ts +1 -22
- package/dist/safe-bash/commands/archive/zip/log.js +1 -159
- package/dist/safe-bash/commands/archive/zip/lzma.d.ts +1 -9
- package/dist/safe-bash/commands/archive/zip/lzma.js +1 -40
- package/dist/safe-bash/commands/archive/zip/move.d.ts +1 -11
- package/dist/safe-bash/commands/archive/zip/move.js +1 -59
- package/dist/safe-bash/commands/archive/zip/names.d.ts +1 -2
- package/dist/safe-bash/commands/archive/zip/names.js +1 -33
- package/dist/safe-bash/commands/archive/zip/options.d.ts +1 -13
- package/dist/safe-bash/commands/archive/zip/options.js +1 -124
- package/dist/safe-bash/commands/archive/zip/repair.d.ts +1 -10
- package/dist/safe-bash/commands/archive/zip/repair.js +1 -392
- package/dist/safe-bash/commands/archive/zip/safety.d.ts +1 -54
- package/dist/safe-bash/commands/archive/zip/safety.js +1 -360
- package/dist/safe-bash/commands/archive/zip/sfx.d.ts +1 -4
- package/dist/safe-bash/commands/archive/zip/sfx.js +1 -52
- package/dist/safe-bash/commands/archive/zip/test-command.d.ts +1 -5
- package/dist/safe-bash/commands/archive/zip/test-command.js +1 -101
- package/dist/safe-bash/commands/archive/zip/volumes.d.ts +1 -21
- package/dist/safe-bash/commands/archive/zip/volumes.js +1 -281
- package/dist/safe-bash/commands/archive/zip/zip64.d.ts +1 -30
- package/dist/safe-bash/commands/archive/zip/zip64.js +1 -227
- package/dist/safe-bash/commands/archive/zip-format.d.ts +1 -68
- package/dist/safe-bash/commands/archive/zip-format.js +1 -1075
- package/dist/safe-bash/commands/archive/zip.d.ts +1 -3
- package/dist/safe-bash/commands/archive/zip.js +1 -1523
- package/dist/safe-bash/commands/awk/index.d.ts +2 -0
- package/dist/safe-bash/commands/awk/index.js +2 -0
- package/dist/safe-bash/commands/bytes/compression/index.js +4 -2
- package/dist/safe-bash/commands/copy-preserve.d.ts +1 -0
- package/dist/safe-bash/commands/csplit/index.browser.js +2 -2
- package/dist/safe-bash/commands/curl/index.d.ts +2 -0
- package/dist/safe-bash/commands/curl/index.js +2 -0
- package/dist/safe-bash/commands/diff/index.d.ts +2 -0
- package/dist/safe-bash/commands/diff/index.js +2 -0
- package/dist/safe-bash/commands/diff-patch/diff-format.d.ts +1 -10
- package/dist/safe-bash/commands/diff-patch/diff-format.js +1 -237
- package/dist/safe-bash/commands/diff-patch/diff-options.d.ts +1 -38
- package/dist/safe-bash/commands/diff-patch/diff-options.js +1 -261
- package/dist/safe-bash/commands/diff-patch/diff-output.d.ts +1 -20
- package/dist/safe-bash/commands/diff-patch/diff-output.js +1 -290
- package/dist/safe-bash/commands/diff-patch/diff.d.ts +1 -2
- package/dist/safe-bash/commands/diff-patch/diff.js +1 -656
- package/dist/safe-bash/commands/diff-patch/index.d.ts +4 -5
- package/dist/safe-bash/commands/diff-patch/index.js +8 -333
- package/dist/safe-bash/commands/diff-patch/patch-envelope.d.ts +1 -2
- package/dist/safe-bash/commands/diff-patch/patch-envelope.js +1 -63
- package/dist/safe-bash/commands/diff-patch/patch-formats.d.ts +1 -7
- package/dist/safe-bash/commands/diff-patch/patch-formats.js +1 -264
- package/dist/safe-bash/commands/diff-patch/patch-gnu-paths.d.ts +1 -41
- package/dist/safe-bash/commands/diff-patch/patch-gnu-paths.js +1 -263
- package/dist/safe-bash/commands/diff-patch/patch-gnu-reject.d.ts +1 -3
- package/dist/safe-bash/commands/diff-patch/patch-gnu-reject.js +1 -100
- package/dist/safe-bash/commands/diff-patch/patch-path.d.ts +1 -3
- package/dist/safe-bash/commands/diff-patch/patch-path.js +1 -91
- package/dist/safe-bash/commands/diff-patch/patch-publication.d.ts +1 -13
- package/dist/safe-bash/commands/diff-patch/patch-publication.js +1 -107
- package/dist/safe-bash/commands/diff-patch/patch.d.ts +1 -2
- package/dist/safe-bash/commands/diff-patch/patch.js +1 -653
- package/dist/safe-bash/commands/diff-patch/shared.d.ts +1 -53
- package/dist/safe-bash/commands/diff-patch/shared.js +1 -267
- package/dist/safe-bash/commands/diff-patch/unified.d.ts +1 -52
- package/dist/safe-bash/commands/diff-patch/unified.js +1 -385
- package/dist/safe-bash/commands/directory-admission.d.ts +1 -3
- package/dist/safe-bash/commands/directory-admission.js +1 -26
- package/dist/safe-bash/commands/docx/index.browser.js +1 -1
- package/dist/safe-bash/commands/execution.js +19 -13
- package/dist/safe-bash/commands/factor/index.browser.js +2 -2
- package/dist/safe-bash/commands/filesystem.d.ts +1 -1
- package/dist/safe-bash/commands/filesystem.js +17 -13
- package/dist/safe-bash/commands/find/index.d.ts +2 -0
- package/dist/safe-bash/commands/find/index.js +2 -0
- package/dist/safe-bash/commands/find-format.d.ts +1 -20
- package/dist/safe-bash/commands/find-format.js +1 -161
- package/dist/safe-bash/commands/find.d.ts +2 -18
- package/dist/safe-bash/commands/find.js +2 -1236
- package/dist/safe-bash/commands/getopt/index.browser.js +2 -2
- package/dist/safe-bash/commands/gzip/index.d.ts +2 -0
- package/dist/safe-bash/commands/gzip/index.js +2 -0
- package/dist/safe-bash/commands/hexdump/index.browser.js +2 -2
- package/dist/safe-bash/commands/htmlq/index.d.ts +1 -1
- 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/line-endings/index.d.ts +1 -1
- package/dist/safe-bash/commands/line-endings/index.js +1 -262
- package/dist/safe-bash/commands/llm/index.browser.js +4 -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 +1 -1
- package/dist/safe-bash/commands/metadata/chmod.d.ts +1 -4
- package/dist/safe-bash/commands/metadata/chmod.js +2 -63
- package/dist/safe-bash/commands/network/aggregate.d.ts +1 -4
- package/dist/safe-bash/commands/network/aggregate.js +1 -23
- package/dist/safe-bash/commands/network/args.d.ts +1 -68
- package/dist/safe-bash/commands/network/args.js +1 -321
- package/dist/safe-bash/commands/network/authorizer.d.ts +1 -6
- package/dist/safe-bash/commands/network/authorizer.js +1 -33
- package/dist/safe-bash/commands/network/body.d.ts +1 -9
- package/dist/safe-bash/commands/network/body.js +1 -393
- package/dist/safe-bash/commands/network/curl.d.ts +3 -13
- package/dist/safe-bash/commands/network/curl.js +6 -695
- package/dist/safe-bash/commands/network/deadline.d.ts +1 -2
- package/dist/safe-bash/commands/network/deadline.js +1 -14
- package/dist/safe-bash/commands/network/decode.d.ts +1 -2
- package/dist/safe-bash/commands/network/decode.js +1 -79
- package/dist/safe-bash/commands/network/fetch-transport.d.ts +1 -7
- package/dist/safe-bash/commands/network/fetch-transport.js +1 -94
- package/dist/safe-bash/commands/network/form-content-type.d.ts +1 -5
- package/dist/safe-bash/commands/network/form-content-type.js +1 -63
- package/dist/safe-bash/commands/network/form-headers.d.ts +1 -2
- package/dist/safe-bash/commands/network/form-headers.js +1 -35
- package/dist/safe-bash/commands/network/glob.d.ts +1 -7
- package/dist/safe-bash/commands/network/glob.js +1 -134
- package/dist/safe-bash/commands/network/index.browser.js +4 -12
- package/dist/safe-bash/commands/network/input.d.ts +1 -5
- package/dist/safe-bash/commands/network/input.js +1 -276
- package/dist/safe-bash/commands/network/output.d.ts +1 -6
- package/dist/safe-bash/commands/network/output.js +1 -131
- package/dist/safe-bash/commands/network/platform-portable.d.ts +1 -5
- package/dist/safe-bash/commands/network/platform-portable.js +1 -26
- package/dist/safe-bash/commands/network/private-address.d.ts +1 -1
- package/dist/safe-bash/commands/network/private-address.js +1 -44
- package/dist/safe-bash/commands/network/public.d.ts +2 -2
- package/dist/safe-bash/commands/network/public.js +2 -2
- package/dist/safe-bash/commands/network/shared.d.ts +1 -14
- package/dist/safe-bash/commands/network/shared.js +1 -71
- package/dist/safe-bash/commands/network/transport.js +2 -2
- package/dist/safe-bash/commands/network/types.d.ts +1 -37
- package/dist/safe-bash/commands/network/types.js +1 -31
- package/dist/safe-bash/commands/network/url.d.ts +1 -2
- package/dist/safe-bash/commands/network/url.js +1 -30
- package/dist/safe-bash/commands/network/wget.d.ts +3 -3
- package/dist/safe-bash/commands/network/wget.js +9 -332
- package/dist/safe-bash/commands/node/filesystem.js +3 -2
- package/dist/safe-bash/commands/node/index.browser.js +8 -9
- package/dist/safe-bash/commands/node/index.d.ts +3 -3
- package/dist/safe-bash/commands/node/index.js +5 -0
- package/dist/safe-bash/commands/node/safejs.d.ts +3 -3
- package/dist/safe-bash/commands/node/safejs.js +6 -1
- package/dist/safe-bash/commands/node/types.d.ts +1 -1
- package/dist/safe-bash/commands/node/types.js +1 -1
- package/dist/safe-bash/commands/node/unconfigured.d.ts +3 -0
- package/dist/safe-bash/commands/node/unconfigured.js +10 -0
- package/dist/safe-bash/commands/op/index.browser.js +3 -3
- package/dist/safe-bash/commands/patch/index.d.ts +2 -0
- package/dist/safe-bash/commands/patch/index.js +2 -0
- package/dist/safe-bash/commands/pdfinfo/index.js +2 -1
- package/dist/safe-bash/commands/pr/index.browser.js +2 -2
- package/dist/safe-bash/commands/predicates.js +3 -4
- package/dist/safe-bash/commands/python/host-capabilities.js +31 -14
- package/dist/safe-bash/commands/python/index.browser.js +11 -11
- package/dist/safe-bash/commands/python/llm-capability.d.ts +1 -0
- package/dist/safe-bash/commands/python/llm-capability.js +27 -7
- package/dist/safe-bash/commands/python/llm-module.js +11 -0
- package/dist/safe-bash/commands/python/manifest.d.ts +2 -0
- package/dist/safe-bash/commands/python/manifest.js +13 -6
- package/dist/safe-bash/commands/python/provisioning.js +1 -1
- package/dist/safe-bash/commands/python/shell-capability.d.ts +1 -0
- package/dist/safe-bash/commands/python/shell-capability.js +3 -2
- package/dist/safe-bash/commands/python/worker.browser.js +3 -3
- package/dist/safe-bash/commands/regex-execution/matching.js +1 -2
- package/dist/safe-bash/commands/regex-execution/public.browser.js +8 -8
- package/dist/safe-bash/commands/safejs/runtime.js +16 -7
- package/dist/safe-bash/commands/search/index.d.ts +1 -1
- package/dist/safe-bash/commands/search/index.js +1 -347
- package/dist/safe-bash/commands/search/portable.d.ts +2 -2
- package/dist/safe-bash/commands/search/portable.js +3 -2
- package/dist/safe-bash/commands/sed/index.d.ts +2 -0
- package/dist/safe-bash/commands/sed/index.js +2 -0
- package/dist/safe-bash/commands/standard.d.ts +1 -0
- package/dist/safe-bash/commands/standard.js +2 -1
- package/dist/safe-bash/commands/streams.js +6 -24
- package/dist/safe-bash/commands/tar/index.d.ts +2 -0
- package/dist/safe-bash/commands/tar/index.js +2 -0
- package/dist/safe-bash/commands/text-programs/awk-inspection.d.ts +1 -19
- package/dist/safe-bash/commands/text-programs/awk-inspection.js +1 -50
- package/dist/safe-bash/commands/text-programs/awk-pipes.d.ts +2 -0
- package/dist/safe-bash/commands/text-programs/awk-pipes.js +2 -0
- package/dist/safe-bash/commands/text-programs/awk-pretty.d.ts +1 -3
- package/dist/safe-bash/commands/text-programs/awk-pretty.js +1 -197
- package/dist/safe-bash/commands/text-programs/awk-quote.d.ts +1 -2
- package/dist/safe-bash/commands/text-programs/awk-quote.js +1 -15
- package/dist/safe-bash/commands/text-programs/awk-reader.d.ts +1 -42
- package/dist/safe-bash/commands/text-programs/awk-reader.js +1 -449
- package/dist/safe-bash/commands/text-programs/awk-retention.d.ts +1 -13
- package/dist/safe-bash/commands/text-programs/awk-retention.js +1 -51
- package/dist/safe-bash/commands/text-programs/awk-runtime.d.ts +1 -150
- package/dist/safe-bash/commands/text-programs/awk-runtime.js +1 -2627
- package/dist/safe-bash/commands/text-programs/awk-syntax.d.ts +1 -142
- package/dist/safe-bash/commands/text-programs/awk-syntax.js +1 -509
- package/dist/safe-bash/commands/text-programs/awk-values.d.ts +1 -32
- package/dist/safe-bash/commands/text-programs/awk-values.js +1 -386
- package/dist/safe-bash/commands/text-programs/awk.d.ts +1 -3
- package/dist/safe-bash/commands/text-programs/awk.js +1 -361
- package/dist/safe-bash/commands/text-programs/inplace.d.ts +1 -16
- package/dist/safe-bash/commands/text-programs/inplace.js +1 -155
- package/dist/safe-bash/commands/text-programs/sed.d.ts +1 -3
- package/dist/safe-bash/commands/text-programs/sed.js +1 -1647
- package/dist/safe-bash/commands/text.js +268 -364
- package/dist/safe-bash/commands/tsort/index.browser.js +2 -2
- package/dist/safe-bash/commands/unzip/index.d.ts +2 -0
- package/dist/safe-bash/commands/unzip/index.js +2 -0
- package/dist/safe-bash/commands/wget/index.d.ts +2 -0
- package/dist/safe-bash/commands/wget/index.js +2 -0
- package/dist/safe-bash/commands/xml/index.browser.js +2 -2
- package/dist/safe-bash/commands/yq/index.browser.js +8 -3
- package/dist/safe-bash/commands/yq/index.d.ts +1 -6
- package/dist/safe-bash/commands/yq/index.js +1 -36
- package/dist/safe-bash/commands/zip/index.d.ts +2 -0
- package/dist/safe-bash/commands/zip/index.js +2 -0
- package/dist/safe-bash/core.browser.js +2 -2
- package/dist/safe-bash/core.d.ts +14 -2
- package/dist/safe-bash/core.js +8 -2
- package/dist/safe-bash/fs/s3/index.d.ts +2 -2
- package/dist/safe-bash/fs/s3/index.js +1 -1
- package/dist/safe-bash/full-core.browser.js +321 -286
- package/dist/safe-bash/jobs.browser.js +5 -5
- package/dist/safe-bash/lazy-mmdc.d.ts +6 -0
- package/dist/safe-bash/lazy-mmdc.js +23 -0
- package/dist/safe-bash/opt-in/commands/dd/index.js +2 -0
- package/dist/safe-bash/opt-in/commands/yq/mike.js +6 -13
- package/dist/safe-bash/opt-in/commands/yq/native-work.d.ts +1 -0
- package/dist/safe-bash/opt-in/commands/yq/native-work.js +17 -0
- package/dist/safe-bash/opt-in/optional/commands/shuf/options.d.ts +1 -0
- package/dist/safe-bash/opt-in/optional/commands/shuf/options.js +2 -4
- package/dist/safe-bash/opt-in/optional/commands/shuf/shuf.js +2 -1
- package/dist/safe-bash/optional-host.browser.js +15 -11
- package/dist/safe-bash/optional-host.d.ts +1 -1
- package/dist/safe-bash/optional-host.js +1 -1
- package/dist/safe-bash/playwright/ability-execution.js +3 -2
- package/dist/safe-bash/playwright/adapter.js +1 -1
- package/dist/safe-bash/playwright/controller.js +9 -8
- package/dist/safe-bash/playwright/modal-capabilities.js +2 -1
- package/dist/safe-bash/playwright/native-json-snapshot.js +4 -3
- package/dist/safe-bash/playwright/native-snapshot.js +5 -4
- package/dist/safe-bash/playwright/open-options.js +3 -3
- package/dist/safe-bash/playwright/resource-limit.d.ts +2 -0
- package/dist/safe-bash/playwright/resource-limit.js +4 -0
- package/dist/safe-bash/playwright/session-configuration.js +8 -3
- package/dist/safe-bash/playwright/snapshot.js +8 -7
- package/dist/safe-bash/playwright/standard-capabilities.js +5 -4
- package/dist/safe-bash/plugins/composition.d.ts +1 -0
- package/dist/safe-bash/plugins/composition.js +3 -8
- package/dist/safe-bash/plugins/index.browser.js +27 -29
- package/dist/safe-bash/registry-entry.browser.js +28 -30
- package/dist/safe-bash/shell/arrays/bindings.d.ts +3 -5
- package/dist/safe-bash/shell/arrays/bindings.js +7 -3
- package/dist/safe-bash/shell/arrays/state.js +4 -0
- package/dist/safe-bash/shell/brace-expansion.js +1 -1
- package/dist/safe-bash/shell/dynamic-variables.d.ts +10 -0
- package/dist/safe-bash/shell/dynamic-variables.js +25 -0
- package/dist/safe-bash/shell/input.js +16 -14
- package/dist/safe-bash/shell/parser.js +8 -1
- package/dist/safe-bash/shell/runtime.d.ts +7 -4
- package/dist/safe-bash/shell/runtime.js +604 -802
- package/dist/safe-bash/shell/shell.js +2 -31
- package/dist/safe-bash/shell/types.d.ts +2 -0
- package/dist/safe-bash/shell/value-state.js +17 -2
- package/dist/safe-bash/shell/worker-limits.js +1 -0
- package/dist/safe-bash/shell-entry.browser.js +25 -27
- package/dist/safe-bash/trap.browser.d.ts +3 -0
- package/dist/safe-bash/trap.browser.js +14 -0
- package/dist/safe-bash/worker/host.js +1 -1
- package/dist/safe-bash/yq-browser/index.js +1 -1
- package/dist/safe-bash-base-encoding-engine/base.js +2 -2
- package/dist/safe-bash-base-encoding-engine/shared.js +1 -1
- package/dist/safe-bash-byte-input-engine/index.d.ts +3 -2
- package/dist/safe-bash-byte-input-engine/index.js +4 -1
- package/dist/safe-bash-checksum-engine/index.js +13 -6
- package/dist/safe-bash-command-apply-patch/apply.d.ts +1 -1
- package/dist/safe-bash-command-apply-patch/apply.js +4 -3
- package/dist/safe-bash-command-apply-patch/index.js +4 -4
- 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/LICENSE +21 -0
- package/dist/safe-bash-command-awk/awk-inspection.d.ts +19 -0
- package/dist/safe-bash-command-awk/awk-inspection.js +9 -0
- package/dist/safe-bash-command-awk/awk-pipes.d.ts +19 -0
- package/dist/safe-bash-command-awk/awk-pipes.js +8 -0
- package/dist/safe-bash-command-awk/awk-pretty.d.ts +3 -0
- package/dist/safe-bash-command-awk/awk-pretty.js +8 -0
- package/dist/safe-bash-command-awk/awk-quote.d.ts +2 -0
- package/dist/safe-bash-command-awk/awk-quote.js +7 -0
- package/dist/safe-bash-command-awk/awk-reader.d.ts +42 -0
- package/dist/safe-bash-command-awk/awk-reader.js +9 -0
- package/dist/safe-bash-command-awk/awk-retention.d.ts +13 -0
- package/dist/safe-bash-command-awk/awk-retention.js +7 -0
- package/dist/safe-bash-command-awk/awk-runtime.d.ts +151 -0
- package/dist/safe-bash-command-awk/awk-runtime.js +11 -0
- package/dist/safe-bash-command-awk/awk-syntax.d.ts +144 -0
- package/dist/safe-bash-command-awk/awk-syntax.js +14 -0
- package/dist/safe-bash-command-awk/awk-values.d.ts +32 -0
- package/dist/safe-bash-command-awk/awk-values.js +35 -0
- package/dist/safe-bash-command-awk/awk.d.ts +3 -0
- package/dist/safe-bash-command-awk/awk.js +16 -0
- package/dist/safe-bash-command-awk/index.d.ts +7 -0
- package/dist/safe-bash-command-awk/index.js +36 -0
- package/dist/safe-bash-command-bc/index.d.ts +6 -0
- package/dist/safe-bash-command-bc/index.js +136 -266
- package/dist/safe-bash-command-column/column.js +5 -5
- package/dist/safe-bash-command-column/display.d.ts +1 -1
- package/dist/safe-bash-command-column/display.js +1 -1
- package/dist/safe-bash-command-column/index.js +5 -5
- package/dist/safe-bash-command-column/internal.d.ts +0 -2
- package/dist/safe-bash-command-column/internal.js +1 -1
- package/dist/safe-bash-command-column/layout.js +4 -4
- package/dist/safe-bash-command-column/table.js +2 -2
- package/dist/safe-bash-command-comm/comm.js +1 -1
- package/dist/safe-bash-command-comm/index.js +1 -1
- package/dist/safe-bash-command-csplit/command.js +2 -2
- package/dist/safe-bash-command-csplit/index.js +2 -2
- package/dist/safe-bash-command-csvcut/index.d.ts +1 -0
- package/dist/safe-bash-command-csvcut/index.js +1 -0
- package/dist/safe-bash-command-csvgrep/index.d.ts +1 -0
- package/dist/safe-bash-command-csvgrep/index.js +2 -2
- package/dist/safe-bash-command-csvkit/contracts.d.ts +1 -0
- package/dist/safe-bash-command-csvkit/csvpy-interpreter.d.ts +2 -1
- package/dist/safe-bash-command-csvkit/default-csvpy.d.ts +11 -0
- package/dist/safe-bash-command-csvkit/errors.js +22 -0
- package/dist/safe-bash-command-csvkit/index.d.ts +1 -0
- package/dist/safe-bash-command-csvkit/index.js +180 -12
- package/dist/safe-bash-command-csvkit/python-worker-browser.d.ts +3 -0
- package/dist/safe-bash-command-csvkit/python-worker-browser.js +16 -0
- package/dist/safe-bash-command-csvkit/python-worker-contract.d.ts +20 -0
- package/dist/safe-bash-command-csvkit/python-worker-node.d.ts +3 -0
- package/dist/safe-bash-command-csvkit/python-worker-node.js +9 -0
- package/dist/safe-bash-command-csvkit/runtime.d.ts +1 -0
- package/dist/safe-bash-command-csvkit/sync-support.js +1 -1
- package/dist/safe-bash-command-curl/LICENSE +21 -0
- package/dist/safe-bash-command-curl/curl.d.ts +13 -0
- package/dist/safe-bash-command-curl/curl.js +9 -0
- package/dist/safe-bash-command-curl/index.d.ts +6 -0
- package/dist/safe-bash-command-curl/index.js +26 -0
- package/dist/safe-bash-command-dd/index.js +2 -0
- package/dist/safe-bash-command-diff/LICENSE +21 -0
- package/dist/safe-bash-command-diff/diff-format.d.ts +10 -0
- package/dist/safe-bash-command-diff/diff-format.js +10 -0
- package/dist/safe-bash-command-diff/diff-options.d.ts +38 -0
- package/dist/safe-bash-command-diff/diff-options.js +7 -0
- package/dist/safe-bash-command-diff/diff-output.d.ts +20 -0
- package/dist/safe-bash-command-diff/diff-output.js +19 -0
- package/dist/safe-bash-command-diff/diff.d.ts +2 -0
- package/dist/safe-bash-command-diff/diff.js +10 -0
- package/dist/safe-bash-command-diff/index.d.ts +8 -0
- package/dist/safe-bash-command-diff/index.js +34 -0
- package/dist/safe-bash-command-diff/sync.d.ts +2 -0
- package/dist/safe-bash-command-diff/sync.js +9 -0
- package/dist/safe-bash-command-diff3/index.js +5 -5
- package/dist/safe-bash-command-docx/index.d.ts +4 -4
- package/dist/safe-bash-command-docx/index.js +12 -5
- package/dist/safe-bash-command-dos2unix/index.d.ts +1 -0
- package/dist/safe-bash-command-dos2unix/index.js +225 -1
- package/dist/safe-bash-command-dos2unix/sync.d.ts +1 -0
- package/dist/safe-bash-command-exiftool/index.d.ts +1 -0
- package/dist/safe-bash-command-exiftool/index.js +2 -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/index.js +9 -9
- package/dist/safe-bash-command-ffmpeg/index.js +117 -102
- package/dist/safe-bash-command-file/index.js +4 -4
- package/dist/safe-bash-command-file/shared.js +1 -1
- package/dist/safe-bash-command-find/LICENSE +21 -0
- package/dist/safe-bash-command-find/find-format.d.ts +20 -0
- package/dist/safe-bash-command-find/find-format.js +9 -0
- package/dist/safe-bash-command-find/find.d.ts +18 -0
- package/dist/safe-bash-command-find/find.js +10 -0
- package/dist/safe-bash-command-find/index.d.ts +13 -0
- package/dist/safe-bash-command-find/index.js +45 -0
- package/dist/safe-bash-command-fmt/index.js +7 -4
- package/dist/safe-bash-command-git/git_rust.wasm +0 -0
- package/dist/safe-bash-command-git/index.js +5 -7
- package/dist/safe-bash-command-git/wasm.generated.js +1 -1
- package/dist/safe-bash-command-gzip/LICENSE +21 -0
- package/dist/safe-bash-command-gzip/index.d.ts +11 -0
- package/dist/safe-bash-command-gzip/index.js +95 -0
- package/dist/safe-bash-command-hexdump/command.js +4 -4
- package/dist/safe-bash-command-hexdump/custom.d.ts +24 -0
- package/dist/safe-bash-command-hexdump/index.js +4 -4
- package/dist/safe-bash-command-hexdump/internal.d.ts +2 -0
- package/dist/safe-bash-command-hexdump/internal.js +1 -1
- package/dist/safe-bash-command-hexdump/io.js +2 -2
- package/dist/safe-bash-command-hexdump/options.d.ts +3 -0
- package/dist/safe-bash-command-hexdump/options.js +2 -2
- package/dist/safe-bash-command-hostname/index.js +1 -1
- package/dist/safe-bash-command-html-to-markdown/budget.js +1 -1
- package/dist/safe-bash-command-html-to-markdown/entities.js +3 -3
- package/dist/safe-bash-command-html-to-markdown/index.js +11 -11
- package/dist/safe-bash-command-html-to-markdown/input.js +5 -5
- package/dist/safe-bash-command-html-to-markdown/parser.d.ts +1 -0
- package/dist/safe-bash-command-html-to-markdown/parser.js +4 -4
- package/dist/safe-bash-command-html-to-markdown/render.js +5 -5
- package/dist/safe-bash-command-html-to-markdown/text.js +2 -2
- package/dist/safe-bash-command-htmlq/index.d.ts +1 -0
- package/dist/safe-bash-command-htmlq/index.js +39 -17
- package/dist/safe-bash-command-iconv/codec.js +1 -1
- package/dist/safe-bash-command-iconv/command.js +2 -2
- package/dist/safe-bash-command-iconv/index.js +2 -2
- package/dist/safe-bash-command-imagemagick/index.js +45 -35
- package/dist/safe-bash-command-join/index.js +1 -1
- package/dist/safe-bash-command-join/join.js +1 -1
- 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 +43 -28
- package/dist/safe-bash-command-llm/command.js +1 -1
- package/dist/safe-bash-command-llm/index.d.ts +1 -0
- package/dist/safe-bash-command-llm/index.js +16 -14
- package/dist/safe-bash-command-llm/openai.js +3 -3
- package/dist/safe-bash-command-llm/providers/index.js +3 -3
- package/dist/safe-bash-command-llm/providers/openai.js +3 -3
- package/dist/safe-bash-command-llm/stored-schema.d.ts +10 -0
- package/dist/safe-bash-command-mmdc/index.d.ts +1 -0
- package/dist/safe-bash-command-mmdc/index.js +13 -604
- package/dist/safe-bash-command-mmdc/settings.d.ts +2 -0
- package/dist/safe-bash-command-mmdc/settings.js +7 -0
- package/dist/safe-bash-command-numfmt/index.js +0 -11
- package/dist/safe-bash-command-od/index.js +101 -68
- package/dist/safe-bash-command-pandoc/command.js +4 -3
- package/dist/safe-bash-command-pandoc/defaults.d.ts +1 -0
- package/dist/safe-bash-command-pandoc/index.js +4 -3
- package/dist/safe-bash-command-pandoc/lua-filters.js +1 -1
- package/dist/safe-bash-command-pandoc/types.d.ts +3 -1
- package/dist/safe-bash-command-paste/index.js +1 -1
- package/dist/safe-bash-command-paste/paste.js +1 -1
- package/dist/safe-bash-command-patch/LICENSE +21 -0
- package/dist/safe-bash-command-patch/index.d.ts +8 -0
- package/dist/safe-bash-command-patch/index.js +38 -0
- package/dist/safe-bash-command-patch/patch-envelope.d.ts +2 -0
- package/dist/safe-bash-command-patch/patch-envelope.js +7 -0
- package/dist/safe-bash-command-patch/patch-formats.d.ts +7 -0
- package/dist/safe-bash-command-patch/patch-formats.js +9 -0
- package/dist/safe-bash-command-patch/patch-gnu-paths.d.ts +41 -0
- package/dist/safe-bash-command-patch/patch-gnu-paths.js +26 -0
- package/dist/safe-bash-command-patch/patch-gnu-reject.d.ts +3 -0
- package/dist/safe-bash-command-patch/patch-gnu-reject.js +7 -0
- package/dist/safe-bash-command-patch/patch-path.d.ts +3 -0
- package/dist/safe-bash-command-patch/patch-path.js +11 -0
- package/dist/safe-bash-command-patch/patch-publication.d.ts +13 -0
- package/dist/safe-bash-command-patch/patch-publication.js +7 -0
- package/dist/safe-bash-command-patch/patch.d.ts +2 -0
- package/dist/safe-bash-command-patch/patch.js +14 -0
- package/dist/safe-bash-command-patch/sync.d.ts +2 -0
- package/dist/safe-bash-command-patch/sync.js +7 -0
- package/dist/safe-bash-command-patch/unified.d.ts +52 -0
- package/dist/safe-bash-command-patch/unified.js +16 -0
- package/dist/safe-bash-command-pathchk/index.js +3 -13
- package/dist/safe-bash-command-pdfimages/index.js +62 -25
- package/dist/safe-bash-command-pdfinfo/index.d.ts +0 -23
- package/dist/safe-bash-command-pdfinfo/index.js +39 -782
- package/dist/safe-bash-command-pdftk/index.js +40 -12
- package/dist/safe-bash-command-pdftoppm/index.js +76 -30
- package/dist/safe-bash-command-pdftotext/index.js +37 -15
- package/dist/safe-bash-command-pptx/index.d.ts +4 -4
- package/dist/safe-bash-command-pptx/index.js +11 -5
- package/dist/safe-bash-command-pr/command.js +2 -2
- package/dist/safe-bash-command-pr/index.js +4 -4
- package/dist/safe-bash-command-qpdf/index.js +31 -18
- package/dist/safe-bash-command-rg/index.d.ts +1 -0
- package/dist/safe-bash-command-rg/index.js +222 -1
- package/dist/safe-bash-command-rg/rg-command.js +1 -1
- package/dist/safe-bash-command-rg/sync.d.ts +1 -0
- package/dist/safe-bash-command-sed/LICENSE +21 -0
- package/dist/safe-bash-command-sed/index.d.ts +7 -0
- package/dist/safe-bash-command-sed/index.js +28 -0
- package/dist/safe-bash-command-sed/inplace.d.ts +16 -0
- package/dist/safe-bash-command-sed/inplace.js +9 -0
- package/dist/safe-bash-command-sed/sed.d.ts +3 -0
- package/dist/safe-bash-command-sed/sed.js +8 -0
- package/dist/safe-bash-command-shuf/options.d.ts +1 -0
- package/dist/safe-bash-command-shuf/options.js +2 -4
- package/dist/safe-bash-command-shuf/shuf.js +2 -1
- package/dist/safe-bash-command-sips/index.js +111 -35
- package/dist/safe-bash-command-soffice/index.js +21 -17
- package/dist/safe-bash-command-split/index.js +3 -3
- package/dist/safe-bash-command-split/io.js +1 -1
- package/dist/safe-bash-command-split/outputs.js +2 -2
- package/dist/safe-bash-command-split/split.js +3 -3
- package/dist/safe-bash-command-sqlite3/btree.d.ts +1 -0
- package/dist/safe-bash-command-sqlite3/engine.d.ts +7 -2
- package/dist/safe-bash-command-sqlite3/index.js +436 -537
- package/dist/safe-bash-command-ssconvert/commands.js +9 -9
- package/dist/safe-bash-command-ssconvert/core.js +8 -8
- package/dist/safe-bash-command-ssconvert/formats/csv.js +9 -9
- package/dist/safe-bash-command-ssconvert/formats/ods.js +9 -9
- package/dist/safe-bash-command-ssconvert/formats/spreadsheetml.js +2 -2
- package/dist/safe-bash-command-ssconvert/formats/xls.js +9 -9
- package/dist/safe-bash-command-ssconvert/formats/xlsx.js +9 -9
- package/dist/safe-bash-command-ssconvert/index.js +21 -21
- package/dist/safe-bash-command-tar/LICENSE +21 -0
- package/dist/safe-bash-command-tar/create.d.ts +17 -0
- package/dist/safe-bash-command-tar/create.js +14 -0
- package/dist/safe-bash-command-tar/extract.d.ts +11 -0
- package/dist/safe-bash-command-tar/extract.js +14 -0
- package/dist/safe-bash-command-tar/format.d.ts +32 -0
- package/dist/safe-bash-command-tar/format.js +19 -0
- package/dist/safe-bash-command-tar/index.d.ts +8 -0
- package/dist/safe-bash-command-tar/index.js +551 -0
- package/dist/safe-bash-command-tar/listing.d.ts +2 -0
- package/dist/safe-bash-command-tar/listing.js +7 -0
- package/dist/safe-bash-command-tar/modes.d.ts +5 -0
- package/dist/safe-bash-command-tar/modes.js +16 -0
- package/dist/safe-bash-command-tar/options.d.ts +53 -0
- package/dist/safe-bash-command-tar/options.js +10 -0
- package/dist/safe-bash-command-tar/stream.d.ts +22 -0
- package/dist/safe-bash-command-tar/stream.js +15 -0
- package/dist/safe-bash-command-tar/transform.d.ts +16 -0
- package/dist/safe-bash-command-tar/transform.js +9 -0
- package/dist/safe-bash-command-tree/arguments.js +3 -3
- package/dist/safe-bash-command-tree/charset.js +1 -1
- package/dist/safe-bash-command-tree/index.js +4 -4
- package/dist/safe-bash-command-tree/io.js +1 -1
- package/dist/safe-bash-command-tree/pattern.js +2 -2
- package/dist/safe-bash-command-tree/tree.js +4 -4
- package/dist/safe-bash-command-unrtf/index.js +14 -7
- package/dist/safe-bash-command-unzip/LICENSE +21 -0
- package/dist/safe-bash-command-unzip/index.d.ts +7 -0
- package/dist/safe-bash-command-unzip/index.js +39 -0
- package/dist/safe-bash-command-unzip/sync.d.ts +3 -0
- package/dist/safe-bash-command-unzip/sync.js +9 -0
- package/dist/safe-bash-command-unzip/unzip/safety.d.ts +32 -0
- package/dist/safe-bash-command-unzip/unzip/safety.js +7 -0
- package/dist/safe-bash-command-unzip/unzip.d.ts +3 -0
- package/dist/safe-bash-command-unzip/unzip.js +8 -0
- package/dist/safe-bash-command-wget/LICENSE +21 -0
- package/dist/safe-bash-command-wget/index.d.ts +6 -0
- package/dist/safe-bash-command-wget/index.js +26 -0
- package/dist/safe-bash-command-wget/wget.d.ts +3 -0
- package/dist/safe-bash-command-wget/wget.js +7 -0
- package/dist/safe-bash-command-xan/argv.d.ts +4 -1
- package/dist/safe-bash-command-xan/argv.js +1 -1
- package/dist/safe-bash-command-xan/commands.js +6 -3
- package/dist/safe-bash-command-xan/csv.d.ts +1 -1
- package/dist/safe-bash-command-xan/csv.js +1 -1
- package/dist/safe-bash-command-xan/index.js +18 -17
- package/dist/safe-bash-command-xan/io.js +3 -3
- package/dist/safe-bash-command-xmllint/index.js +190 -50
- package/dist/safe-bash-command-xxd/index.js +105 -91
- package/dist/safe-bash-command-xz/command.d.ts +2 -0
- package/dist/safe-bash-command-xz/index.d.ts +1 -1
- package/dist/safe-bash-command-xz/index.js +11 -2
- package/dist/safe-bash-command-xz/options.d.ts +9 -1
- package/dist/safe-bash-command-xz/options.js +3 -1
- package/dist/safe-bash-command-yq/index.d.ts +4 -11
- package/dist/safe-bash-command-yq/index.js +3367 -670
- package/dist/safe-bash-command-yq/mike.js +6 -13
- package/dist/safe-bash-command-yq/native-work.d.ts +1 -0
- package/dist/safe-bash-command-yq/native-work.js +17 -0
- package/dist/safe-bash-command-yq/query.d.ts +11 -0
- package/dist/safe-bash-command-yq/query.js +735 -0
- package/dist/safe-bash-command-zip/LICENSE +21 -0
- package/dist/safe-bash-command-zip/index.d.ts +7 -0
- package/dist/safe-bash-command-zip/index.js +38 -0
- package/dist/safe-bash-command-zip/sync.d.ts +3 -0
- package/dist/safe-bash-command-zip/sync.js +9 -0
- package/dist/safe-bash-command-zip/zip.d.ts +3 -0
- package/dist/safe-bash-command-zip/zip.js +7 -0
- package/dist/safe-bash-compression-engine/files.js +4 -4
- package/dist/safe-bash-compression-engine/index.js +2 -2
- package/dist/safe-bash-compression-engine/operand.js +6 -6
- package/dist/safe-bash-compression-engine/stream.js +2 -2
- package/dist/safe-bash-compression-engine/zstd-decode.js +1 -1
- package/dist/safe-bash-contracts/command.js +1 -1
- package/dist/safe-bash-contracts/diagnostics.js +4 -4
- package/dist/safe-bash-contracts/escaping.js +12 -12
- package/dist/safe-bash-contracts/filesystem-descriptor.js +1 -1
- package/dist/safe-bash-contracts/filesystem-output.js +8 -8
- package/dist/safe-bash-contracts/index.d.ts +1 -0
- package/dist/safe-bash-contracts/index.js +39 -35
- package/dist/safe-bash-contracts/io.d.ts +4 -1
- package/dist/safe-bash-contracts/io.js +4 -2
- package/dist/safe-bash-contracts/managed-abort.d.ts +10 -0
- package/dist/safe-bash-contracts/output.js +3 -3
- package/dist/safe-bash-diff-engine/LICENSE +21 -0
- package/dist/safe-bash-diff-engine/index.d.ts +1 -0
- package/dist/safe-bash-diff-engine/index.js +24 -0
- package/dist/safe-bash-diff-engine/shared.d.ts +54 -0
- package/dist/safe-bash-diff-engine/shared.js +19 -0
- package/dist/safe-bash-io-engine/commands/archive/internal.js +5 -23
- package/dist/safe-bash-io-engine/commands/directory-admission.d.ts +3 -0
- package/dist/safe-bash-io-engine/commands/directory-admission.js +34 -0
- package/dist/safe-bash-io-engine/commands/mode-change.d.ts +4 -0
- package/dist/safe-bash-io-engine/commands/mode-change.js +60 -0
- package/dist/safe-bash-io-engine/commands/search/requirements.js +2 -2
- package/dist/safe-bash-io-engine/commands/text-programs/shared.js +44 -66
- package/dist/safe-bash-io-engine/internal.js +1 -1
- package/dist/safe-bash-io-engine/shell/pattern.js +8 -13
- package/dist/safe-bash-io-engine/shell/string-operations.js +1 -1
- package/dist/safe-bash-markdown-engine/commonmark-blocks.js +4 -4
- package/dist/safe-bash-markdown-engine/commonmark-inlines.js +4 -4
- package/dist/safe-bash-markdown-engine/commonmark-syntax.js +2 -2
- package/dist/safe-bash-markdown-engine/gfm-syntax.js +3 -3
- package/dist/safe-bash-markdown-engine/index.js +7 -7
- package/dist/safe-bash-mcp/index.browser.d.ts +161 -35
- package/dist/safe-bash-mcp/index.browser.js +417 -0
- package/dist/safe-bash-mcp/index.d.ts +66 -2
- package/dist/safe-bash-mcp/index.js +1838 -122
- package/dist/safe-bash-network-engine/LICENSE +21 -0
- package/dist/safe-bash-network-engine/aggregate.d.ts +4 -0
- package/dist/safe-bash-network-engine/aggregate.js +37 -0
- package/dist/safe-bash-network-engine/args.d.ts +68 -0
- package/dist/safe-bash-network-engine/args.js +19 -0
- package/dist/safe-bash-network-engine/authorizer.d.ts +6 -0
- package/dist/safe-bash-network-engine/authorizer.js +8 -0
- package/dist/safe-bash-network-engine/body.d.ts +9 -0
- package/dist/safe-bash-network-engine/body.js +374 -0
- package/dist/safe-bash-network-engine/deadline.d.ts +2 -0
- package/dist/safe-bash-network-engine/deadline.js +7 -0
- package/dist/safe-bash-network-engine/decode.d.ts +2 -0
- package/dist/safe-bash-network-engine/decode.js +80 -0
- package/dist/safe-bash-network-engine/fetch-transport.d.ts +7 -0
- package/dist/safe-bash-network-engine/fetch-transport.js +9 -0
- package/dist/safe-bash-network-engine/form-content-type.d.ts +5 -0
- package/dist/safe-bash-network-engine/form-content-type.js +8 -0
- package/dist/safe-bash-network-engine/form-headers.d.ts +2 -0
- package/dist/safe-bash-network-engine/form-headers.js +10 -0
- package/dist/safe-bash-network-engine/glob.d.ts +7 -0
- package/dist/safe-bash-network-engine/glob.js +124 -0
- package/dist/safe-bash-network-engine/index.d.ts +3 -0
- package/dist/safe-bash-network-engine/index.js +26 -0
- package/dist/safe-bash-network-engine/input.d.ts +5 -0
- package/dist/safe-bash-network-engine/input.js +255 -0
- package/dist/safe-bash-network-engine/output.d.ts +6 -0
- package/dist/safe-bash-network-engine/output.js +132 -0
- package/dist/safe-bash-network-engine/platform-portable.d.ts +5 -0
- package/dist/safe-bash-network-engine/platform-portable.js +19 -0
- package/dist/safe-bash-network-engine/private-address.d.ts +1 -0
- package/dist/safe-bash-network-engine/private-address.js +7 -0
- package/dist/safe-bash-network-engine/shared.d.ts +14 -0
- package/dist/safe-bash-network-engine/shared.js +23 -0
- package/dist/safe-bash-network-engine/types.d.ts +42 -0
- package/dist/safe-bash-network-engine/types.js +11 -0
- package/dist/safe-bash-network-engine/url.d.ts +2 -0
- package/dist/safe-bash-network-engine/url.js +8 -0
- package/dist/safe-bash-query-engine/capture.d.ts +1 -0
- package/dist/safe-bash-query-engine/capture.js +9 -7
- package/dist/safe-bash-query-engine/dates.d.ts +5 -1
- package/dist/safe-bash-query-engine/dates.js +10 -2
- package/dist/safe-bash-query-engine/delpaths.js +5 -5
- package/dist/safe-bash-query-engine/formats.js +3 -3
- package/dist/safe-bash-query-engine/index.js +15 -15
- package/dist/safe-bash-query-engine/indices.js +5 -5
- package/dist/safe-bash-query-engine/input.d.ts +1 -2
- package/dist/safe-bash-query-engine/input.js +2 -4
- package/dist/safe-bash-query-engine/interpreter.d.ts +5 -0
- package/dist/safe-bash-query-engine/interpreter.js +13 -13
- package/dist/safe-bash-query-engine/limits.js +1 -1
- package/dist/safe-bash-query-engine/parser.d.ts +8 -1
- package/dist/safe-bash-query-engine/parser.js +2 -2
- package/dist/safe-bash-query-engine/query-core.js +15 -15
- package/dist/safe-bash-query-engine/recurse.js +2 -2
- package/dist/safe-bash-query-engine/regex.d.ts +4 -2
- package/dist/safe-bash-query-engine/regex.js +10 -5
- package/dist/safe-bash-query-engine/split.js +2 -2
- package/dist/safe-bash-query-engine/splits.d.ts +1 -1
- package/dist/safe-bash-query-engine/splits.js +7 -6
- package/dist/safe-bash-query-engine/values.js +4 -4
- package/dist/safe-bash-regex-engine/ere/matcher.js +106 -34
- package/dist/safe-bash-regex-engine/execution/bounded-provider.js +55 -67
- package/dist/safe-bash-regex-engine/execution/portable.d.ts +0 -1
- package/dist/safe-bash-regex-engine/execution/portable.js +6 -10
- package/dist/safe-bash-regex-engine/execution/protocol.d.ts +0 -5
- package/dist/safe-bash-regex-engine/execution/protocol.js +1 -3
- package/dist/safe-bash-regex-engine/index.js +6 -4
- package/dist/safe-bash-regex-engine/text/budget.d.ts +1 -0
- package/dist/safe-bash-regex-engine/text/budget.js +1 -1
- package/dist/safe-bash-regex-engine/text/regex.d.ts +15 -0
- package/dist/safe-bash-regex-engine/text/regex.js +6 -4
- package/dist/safe-bash-regex-engine/text/replacement-buffer.js +2 -2
- package/dist/safe-bash-regex-engine/text/rust-syntax.js +2 -2
- package/dist/safe-bash-search-engine/ergonomic-regex.d.ts +12 -2
- 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 +191 -229
- package/dist/safe-bash-search-engine/matcher.d.ts +6 -2
- package/dist/safe-bash-search-engine/matcher.js +30 -8
- package/dist/safe-bash-search-engine/options.js +1 -1
- package/dist/safe-bash-search-engine/output.d.ts +3 -2
- package/dist/safe-bash-search-engine/output.js +111 -30
- package/dist/safe-bash-search-engine/shared.d.ts +2 -0
- package/dist/safe-bash-search-engine/shared.js +2 -2
- package/dist/safe-bash-search-engine/walk.js +11 -10
- package/dist/safe-bash-table-text-engine/table-text/internal.d.ts +7 -5
- package/dist/safe-bash-table-text-engine/table-text/internal.js +39 -21
- package/dist/safe-bash-xml-engine/document.d.ts +1 -1
- package/dist/safe-bash-xml-engine/document.js +3 -3
- package/dist/safe-bash-xml-engine/evaluate.d.ts +1 -0
- package/dist/safe-bash-xml-engine/evaluate.js +4 -1
- package/dist/safe-bash-xml-engine/index.js +8 -6
- package/dist/safe-bash-xml-engine/io.js +1 -1
- package/dist/safe-bash-xml-engine/limits.d.ts +2 -0
- package/dist/safe-bash-xml-engine/limits.js +1 -1
- package/dist/safe-bash-xml-engine/predicate.d.ts +57 -0
- package/dist/safe-bash-xml-engine/query.d.ts +3 -15
- package/dist/safe-bash-xml-engine/query.js +3 -2
- package/dist/safe-bash-zip-engine/LICENSE +21 -0
- package/dist/safe-bash-zip-engine/index.d.ts +1 -0
- package/dist/safe-bash-zip-engine/index.js +32 -0
- package/dist/safe-bash-zip-engine/unzip/arguments.d.ts +53 -0
- package/dist/safe-bash-zip-engine/unzip/arguments.js +270 -0
- package/dist/safe-bash-zip-engine/zip/aes.d.ts +17 -0
- package/dist/safe-bash-zip-engine/zip/aes.js +15 -0
- package/dist/safe-bash-zip-engine/zip/comments.d.ts +17 -0
- package/dist/safe-bash-zip-engine/zip/comments.js +77 -0
- package/dist/safe-bash-zip-engine/zip/crc.d.ts +1 -0
- package/dist/safe-bash-zip-engine/zip/crc.js +7 -0
- package/dist/safe-bash-zip-engine/zip/crypto.d.ts +19 -0
- package/dist/safe-bash-zip-engine/zip/crypto.js +16 -0
- package/dist/safe-bash-zip-engine/zip/dates.d.ts +4 -0
- package/dist/safe-bash-zip-engine/zip/dates.js +68 -0
- package/dist/safe-bash-zip-engine/zip/environment.d.ts +2 -0
- package/dist/safe-bash-zip-engine/zip/environment.js +60 -0
- package/dist/safe-bash-zip-engine/zip/grow.d.ts +3 -0
- package/dist/safe-bash-zip-engine/zip/grow.js +7 -0
- package/dist/safe-bash-zip-engine/zip/help.d.ts +4 -0
- package/dist/safe-bash-zip-engine/zip/help.js +194 -0
- package/dist/safe-bash-zip-engine/zip/line-endings.d.ts +2 -0
- package/dist/safe-bash-zip-engine/zip/line-endings.js +165 -0
- package/dist/safe-bash-zip-engine/zip/log.d.ts +22 -0
- package/dist/safe-bash-zip-engine/zip/log.js +153 -0
- package/dist/safe-bash-zip-engine/zip/lzma.d.ts +9 -0
- package/dist/safe-bash-zip-engine/zip/lzma.js +7 -0
- package/dist/safe-bash-zip-engine/zip/move.d.ts +11 -0
- package/dist/safe-bash-zip-engine/zip/move.js +57 -0
- package/dist/safe-bash-zip-engine/zip/names.d.ts +2 -0
- package/dist/safe-bash-zip-engine/zip/names.js +37 -0
- package/dist/safe-bash-zip-engine/zip/options.d.ts +13 -0
- package/dist/safe-bash-zip-engine/zip/options.js +23 -0
- package/dist/safe-bash-zip-engine/zip/repair.d.ts +10 -0
- package/dist/safe-bash-zip-engine/zip/repair.js +348 -0
- package/dist/safe-bash-zip-engine/zip/safety.d.ts +54 -0
- package/dist/safe-bash-zip-engine/zip/safety.js +19 -0
- package/dist/safe-bash-zip-engine/zip/sfx.d.ts +4 -0
- package/dist/safe-bash-zip-engine/zip/sfx.js +58 -0
- package/dist/safe-bash-zip-engine/zip/test-command.d.ts +5 -0
- package/dist/safe-bash-zip-engine/zip/test-command.js +98 -0
- package/dist/safe-bash-zip-engine/zip/volumes.d.ts +21 -0
- package/dist/safe-bash-zip-engine/zip/volumes.js +255 -0
- package/dist/safe-bash-zip-engine/zip/zip64.d.ts +30 -0
- package/dist/safe-bash-zip-engine/zip/zip64.js +25 -0
- package/dist/safe-bash-zip-engine/zip-format.d.ts +68 -0
- package/dist/safe-bash-zip-engine/zip-format.js +27 -0
- package/dist/safe-playwright-cloudflare/browser-codegen.generated.d.ts +7 -7
- package/dist/safe-playwright-cloudflare/browser-codegen.generated.js +866 -8069
- package/dist/safe-playwright-cloudflare/browser-run-code-budget.d.ts +0 -1
- package/dist/safe-playwright-cloudflare/browser-run-code-budget.js +0 -2
- package/dist/safe-playwright-cloudflare/browser-trace-archive.d.ts +5 -1
- package/dist/safe-playwright-cloudflare/browser-trace-archive.js +2 -1
- package/dist/safe-playwright-cloudflare/browser-trace-budget.js +8 -4
- package/dist/safe-playwright-cloudflare/shell-browser-resource.d.ts +2 -0
- package/dist/safe-playwright-cloudflare/shell-browser-resource.js +3 -11
- package/dist/safe-playwright-cloudflare/shell-playwright.d.ts +2 -0
- package/dist/safe-playwright-cloudflare/shell-playwright.js +1 -1
- package/dist/spreadsheet-engine/codecs/odf-hyperlinks.js +8 -2
- package/dist/spreadsheet-engine/formulas/functions/captured-bessel-phase.js +2 -2
- package/dist/spreadsheet-engine/formulas/label-references.js +54 -33
- package/dist/spreadsheet-engine/formulas/parser.js +3 -1
- package/dist/spreadsheet-engine/formulas/rewriting.js +13 -3
- package/dist/spreadsheet-engine/io/publication.d.ts +1 -0
- package/dist/spreadsheet-format-xls/biff-data-tables.js +4 -6
- package/dist/spreadsheet-format-xls/biff-formulas.js +3 -0
- package/dist/spreadsheet-format-xls/biff-label-ranges.js +9 -6
- package/dist/spreadsheet-format-xls/biff.js +1 -1
- package/dist/xlsx-ast/xlsx.js +8 -5
- package/package.json +165 -15
- package/dist/safe-bash/chunks/chunk-AZAJJVFX.js +0 -23017
- package/dist/safe-bash/chunks/chunk-O4ZUCRGN.js +0 -13
- package/dist/safe-bash/chunks/chunk-S264DZO2.js +0 -243
- package/dist/safe-bash/chunks/chunk-WVG5SHHQ.js +0 -12
- package/dist/safe-bash/chunks/chunk-ZW6K2J7P.js +0 -2652
- package/dist/safe-bash/command-chunks/chunk-5MPOQ6V3.js +0 -181
- package/dist/safe-bash/command-chunks/chunk-BIXLZ3OG.js +0 -14342
- package/dist/safe-bash/command-chunks/chunk-DUYJE2HY.js +0 -14
- package/dist/safe-bash/command-chunks/chunk-KAGBORIC.js +0 -88
- package/dist/safe-bash/command-chunks/chunk-NETECMOF.js +0 -40
- package/dist/safe-bash/command-chunks/chunk-XS3PGJU2.js +0 -343
- package/dist/safe-bash/command-chunks/chunk-XTZALMLR.js +0 -488
- package/dist/safe-bash/commands/archive/zip/aes-primitives-unavailable.d.ts +0 -2
- package/dist/safe-bash/commands/archive/zip/aes-primitives-unavailable.js +0 -3
- package/dist/safe-bash/commands/archive/zip/aes-primitives.d.ts +0 -2
- package/dist/safe-bash/commands/archive/zip/aes-primitives.js +0 -3
- package/dist/safe-bash/commands/xml/document.d.ts +0 -2
- package/dist/safe-bash/commands/xml/document.js +0 -2
- package/dist/safe-bash/commands/xml/evaluate.d.ts +0 -2
- package/dist/safe-bash/commands/xml/evaluate.js +0 -2
- package/dist/safe-bash/commands/xml/json.d.ts +0 -2
- package/dist/safe-bash/commands/xml/json.js +0 -2
- package/dist/safe-bash/commands/xml/limits.d.ts +0 -2
- package/dist/safe-bash/commands/xml/limits.js +0 -2
- package/dist/safe-bash/commands/xml/query.d.ts +0 -2
- package/dist/safe-bash/commands/xml/query.js +0 -2
- package/dist/safe-bash/command-chunks/{chunk-FIUFIDAO.js → chunk-2JRBIDAD.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-BWNXWI33.js → chunk-2LMZVE3I.js} +0 -0
- package/dist/safe-bash/command-chunks/{chunk-B5BKA5WH.js → chunk-B5TAOCKD.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-2ENZ6JGA.js → chunk-KEV7C3KH.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-S62HELHU.js → chunk-PL6O4K6W.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-DDLQ5YDB.js → chunk-YHFXOX6U.js} +9 -9
- package/dist/safe-bash/command-chunks/{chunk-DQMOM72Z.js → chunk-ZRRBXU3M.js} +4 -4
|
@@ -1,2628 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { latin1Bytes, latin1Text } from "../../byte-encoding.js";
|
|
3
|
-
import { shellValueByteLength } from "../../contracts/value.js";
|
|
4
|
-
const textDecoder = new TextDecoder("utf-8", { ignoreBOM: true });
|
|
5
|
-
import { isSyncResolved } from "../../fs/creation-mask.js";
|
|
6
|
-
import { tryReadMemoryFileViewSync } from "@poe-platform/safe-fs/core";
|
|
7
|
-
import { FsError, writeBytes } from "../../contracts/index.js";
|
|
8
|
-
import { writeFileOutput } from "../../contracts/filesystem-output.js";
|
|
9
|
-
import { decodeString } from "./awk-syntax.js";
|
|
10
|
-
import { AwkArray, SCALAR_ONE, SCALAR_ZERO, compare, formatted, inputValue, inputValueFromSlice, number, numeric, scalar, string, text, truth, unset } from "./awk-values.js";
|
|
11
|
-
import { Pattern, substitute } from "./regex.js";
|
|
12
|
-
import { Budget, ProgramError, byteString, bytes, input, virtualPath, write } from "./shared.js";
|
|
13
|
-
import { AwkRetention } from "./awk-retention.js";
|
|
14
|
-
import { Reader } from "./awk-reader.js";
|
|
15
|
-
function textSize(value) {
|
|
16
|
-
return value && !(value instanceof AwkArray) && (value.kind === "string" || value.kind === "numeric") ? value.text.length : 0;
|
|
17
|
-
}
|
|
18
|
-
function isAsciiText(text) {
|
|
19
|
-
for (let i = 0; i < text.length; i++) {
|
|
20
|
-
if (text.charCodeAt(i) > 0x7f)
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
function isOperandAssignment(text) {
|
|
26
|
-
const eq = text.indexOf("=");
|
|
27
|
-
if (eq <= 0)
|
|
28
|
-
return false;
|
|
29
|
-
const c0 = text.charCodeAt(0);
|
|
30
|
-
if (!((c0 >= 65 && c0 <= 90) || (c0 >= 97 && c0 <= 122) || c0 === 95))
|
|
31
|
-
return false;
|
|
32
|
-
for (let i = 1; i < eq; i++) {
|
|
33
|
-
const c = text.charCodeAt(i);
|
|
34
|
-
if (!((c >= 65 && c <= 90) || (c >= 97 && c <= 122) || (c >= 48 && c <= 57) || c === 95))
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
function ownScalar(value) {
|
|
40
|
-
if (value.kind === "string" || value.kind === "numeric") {
|
|
41
|
-
if (value.text.length < 13 && Object.isFrozen(value))
|
|
42
|
-
return value;
|
|
43
|
-
const ownedText = value.text.length >= 13 ? latin1Text(latin1Bytes(value.text)) : value.text;
|
|
44
|
-
return value.kind === "numeric"
|
|
45
|
-
? { kind: "numeric", text: ownedText, number: value.number }
|
|
46
|
-
: { kind: "string", text: ownedText };
|
|
47
|
-
}
|
|
48
|
-
if (value.kind === "number" && !Object.isFrozen(value)) {
|
|
49
|
-
return { kind: "number", number: value.number };
|
|
50
|
-
}
|
|
51
|
-
return value;
|
|
52
|
-
}
|
|
53
|
-
const DEFAULT_VARIABLES = [
|
|
54
|
-
["FS", Object.freeze({ kind: "string", text: " " })],
|
|
55
|
-
["RS", Object.freeze({ kind: "string", text: "\n" })],
|
|
56
|
-
["OFS", Object.freeze({ kind: "string", text: " " })],
|
|
57
|
-
["ORS", Object.freeze({ kind: "string", text: "\n" })],
|
|
58
|
-
["OFMT", Object.freeze({ kind: "string", text: "%.6g" })],
|
|
59
|
-
["CONVFMT", Object.freeze({ kind: "string", text: "%.6g" })],
|
|
60
|
-
["SUBSEP", Object.freeze({ kind: "string", text: "\x1c" })],
|
|
61
|
-
["NR", numeric(0)],
|
|
62
|
-
["FNR", numeric(0)],
|
|
63
|
-
["NF", numeric(0)],
|
|
64
|
-
["FILENAME", string("")],
|
|
65
|
-
["RSTART", numeric(0)],
|
|
66
|
-
["RLENGTH", numeric(0)],
|
|
67
|
-
];
|
|
68
|
-
const AWK_ARGV0 = Object.freeze({ kind: "string", text: "awk" });
|
|
69
|
-
function hasMainGetline(node) {
|
|
70
|
-
if (!node || typeof node !== "object")
|
|
71
|
-
return false;
|
|
72
|
-
if (node.kind === "getline" && !node.file)
|
|
73
|
-
return true;
|
|
74
|
-
return Object.values(node).some(child => Array.isArray(child) ? child.some(hasMainGetline) : hasMainGetline(child));
|
|
75
|
-
}
|
|
76
|
-
const FAST_AWK_MATCH_OFFSETS = new Int32Array(20);
|
|
77
|
-
const RETURN_SCALAR_ZERO = () => SCALAR_ZERO;
|
|
78
|
-
const RETURN_SCALAR_ONE = () => SCALAR_ONE;
|
|
79
|
-
const RELEASED_AWK_SIGNAL = Object.freeze({
|
|
80
|
-
aborted: false,
|
|
81
|
-
reason: undefined,
|
|
82
|
-
onabort: null,
|
|
83
|
-
throwIfAborted() { },
|
|
84
|
-
addEventListener() { },
|
|
85
|
-
removeEventListener() { },
|
|
86
|
-
dispatchEvent() { return true; },
|
|
87
|
-
});
|
|
88
|
-
const RELEASED_AWK_CONTEXT = Object.freeze({ signal: RELEASED_AWK_SIGNAL });
|
|
89
|
-
const _lastAwkArrayAnchor = new AwkArray();
|
|
90
|
-
void _lastAwkArrayAnchor;
|
|
91
|
-
const SMALL_ARG_KEYS = ["0", "1", "2", "3", "4", "5", "6", "7", "8"];
|
|
92
|
-
class Flow {
|
|
93
|
-
kind;
|
|
94
|
-
value;
|
|
95
|
-
constructor(kind, value = unset) {
|
|
96
|
-
this.kind = kind;
|
|
97
|
-
this.value = value;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
export class AwkRuntime {
|
|
101
|
-
program;
|
|
102
|
-
context;
|
|
103
|
-
budget;
|
|
104
|
-
retention;
|
|
105
|
-
operandAssignments;
|
|
106
|
-
ordchr;
|
|
107
|
-
inspection;
|
|
108
|
-
variables = new Map();
|
|
109
|
-
frames = [];
|
|
110
|
-
arrays = new Map();
|
|
111
|
-
regexes;
|
|
112
|
-
outputs;
|
|
113
|
-
inputs;
|
|
114
|
-
environInitialized = false;
|
|
115
|
-
mainReader;
|
|
116
|
-
argument = 1;
|
|
117
|
-
sawFile = false;
|
|
118
|
-
defaultUsed = false;
|
|
119
|
-
rawFields = [];
|
|
120
|
-
get fields() { return this.ensureFields(); }
|
|
121
|
-
set fields(v) { this.rawFields = v; }
|
|
122
|
-
fieldStarts;
|
|
123
|
-
fieldEnds;
|
|
124
|
-
fieldCount = 0;
|
|
125
|
-
deferredFieldSeparator = " ";
|
|
126
|
-
fieldsMaterialized = true;
|
|
127
|
-
fieldGeneration;
|
|
128
|
-
lazyFieldGen;
|
|
129
|
-
lazyFields;
|
|
130
|
-
fieldBytes = 0;
|
|
131
|
-
rawRecord = "";
|
|
132
|
-
recordSource = "";
|
|
133
|
-
recordStart = 0;
|
|
134
|
-
recordEnd = 0;
|
|
135
|
-
get record() {
|
|
136
|
-
return this.rawRecord ??= this.recordSource.slice(this.recordStart, this.recordEnd);
|
|
137
|
-
}
|
|
138
|
-
set record(v) {
|
|
139
|
-
this.rawRecord = v;
|
|
140
|
-
this.recordSource = v;
|
|
141
|
-
this.recordStart = 0;
|
|
142
|
-
this.recordEnd = v.length;
|
|
143
|
-
}
|
|
144
|
-
get recordLength() {
|
|
145
|
-
return this.rawRecord !== undefined ? this.rawRecord.length : this.recordEnd - this.recordStart;
|
|
146
|
-
}
|
|
147
|
-
sliceBox = { source: "", start: 0, end: 0 };
|
|
148
|
-
recordValue = string("");
|
|
149
|
-
entries = 0;
|
|
150
|
-
fsText = " ";
|
|
151
|
-
rsText = "\n";
|
|
152
|
-
convfmtText = "%.6g";
|
|
153
|
-
nrNum = 0;
|
|
154
|
-
nrDirty = false;
|
|
155
|
-
fnrNum = 0;
|
|
156
|
-
fnrDirty = false;
|
|
157
|
-
nfNum = 0;
|
|
158
|
-
nfDirty = false;
|
|
159
|
-
phase = "BEGIN";
|
|
160
|
-
status = 0;
|
|
161
|
-
randomSeed = 1;
|
|
162
|
-
randomState = 1;
|
|
163
|
-
constructor(program, context, budget, retention, args, assignments, separator, operandAssignments = true, ordchr = false, inspection) {
|
|
164
|
-
this.program = program;
|
|
165
|
-
this.context = context;
|
|
166
|
-
this.budget = budget;
|
|
167
|
-
this.retention = retention;
|
|
168
|
-
this.operandAssignments = operandAssignments;
|
|
169
|
-
this.ordchr = ordchr;
|
|
170
|
-
this.inspection = inspection;
|
|
171
|
-
this.fieldStarts = new Array(64).fill(0);
|
|
172
|
-
this.fieldEnds = new Array(64).fill(0);
|
|
173
|
-
this.lazyFieldGen = new Array(64).fill(0);
|
|
174
|
-
this.lazyFields = new Array(64);
|
|
175
|
-
this.fieldGeneration = 1;
|
|
176
|
-
try {
|
|
177
|
-
for (let i = 0; i < DEFAULT_VARIABLES.length; i++) {
|
|
178
|
-
const pair = DEFAULT_VARIABLES[i];
|
|
179
|
-
this.storeScalar(this.variables, pair[0], pair[1]);
|
|
180
|
-
}
|
|
181
|
-
this.storeScalar(this.variables, "ARGC", numeric(args.length + 1));
|
|
182
|
-
if (inspection !== undefined || retention.capacity <= 65536 || budget.options.maxArrayEntries !== undefined || budget.options.maxBufferBytes !== undefined || budget.options.maxRetainedBytes !== undefined) {
|
|
183
|
-
this.ensureEnviron();
|
|
184
|
-
}
|
|
185
|
-
const argv = this.array("ARGV");
|
|
186
|
-
this.arraySet(argv, "0", AWK_ARGV0);
|
|
187
|
-
for (let index = 0; index < args.length; index++) {
|
|
188
|
-
const k = index + 1 < SMALL_ARG_KEYS.length ? SMALL_ARG_KEYS[index + 1] : String(index + 1);
|
|
189
|
-
this.arraySet(argv, k, inputValue(byteString(args[index])));
|
|
190
|
-
}
|
|
191
|
-
if (separator !== undefined)
|
|
192
|
-
this.set("FS", string(separator));
|
|
193
|
-
for (const assignment of assignments)
|
|
194
|
-
this.assignment(assignment);
|
|
195
|
-
}
|
|
196
|
-
catch (error) {
|
|
197
|
-
this.releaseStore(this.variables);
|
|
198
|
-
throw error;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
ensureEnviron() {
|
|
202
|
-
if (this.environInitialized)
|
|
203
|
-
return;
|
|
204
|
-
this.environInitialized = true;
|
|
205
|
-
const environment = new AwkArray();
|
|
206
|
-
this.bindArray(this.variables, "ENVIRON", environment);
|
|
207
|
-
for (const [name, value] of Object.entries(this.context.env)) {
|
|
208
|
-
this.arraySet(environment, byteString(name), inputValue(byteString(value)));
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
store(name) { return this.frames.at(-1)?.has(name) ? this.frames.at(-1) : this.variables; }
|
|
212
|
-
syncSpecialVars() {
|
|
213
|
-
if (this.nrDirty) {
|
|
214
|
-
this.nrDirty = false;
|
|
215
|
-
this.storeScalar(this.variables, "NR", numeric(this.nrNum));
|
|
216
|
-
}
|
|
217
|
-
if (this.fnrDirty) {
|
|
218
|
-
this.fnrDirty = false;
|
|
219
|
-
this.storeScalar(this.variables, "FNR", numeric(this.fnrNum));
|
|
220
|
-
}
|
|
221
|
-
if (this.nfDirty) {
|
|
222
|
-
if (this.fieldCount < 0)
|
|
223
|
-
this.ensureSliceFieldsSplit();
|
|
224
|
-
this.nfDirty = false;
|
|
225
|
-
this.storeScalar(this.variables, "NF", numeric(this.nfNum));
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
get(name) {
|
|
229
|
-
if (this.frames.length === 0 || !this.frames.at(-1).has(name)) {
|
|
230
|
-
if (name === "NR" && this.nrDirty) {
|
|
231
|
-
this.nrDirty = false;
|
|
232
|
-
this.storeScalar(this.variables, "NR", numeric(this.nrNum));
|
|
233
|
-
}
|
|
234
|
-
else if (name === "FNR" && this.fnrDirty) {
|
|
235
|
-
this.fnrDirty = false;
|
|
236
|
-
this.storeScalar(this.variables, "FNR", numeric(this.fnrNum));
|
|
237
|
-
}
|
|
238
|
-
else if (name === "NF" && this.nfDirty) {
|
|
239
|
-
if (this.fieldCount < 0)
|
|
240
|
-
this.ensureSliceFieldsSplit();
|
|
241
|
-
this.nfDirty = false;
|
|
242
|
-
this.storeScalar(this.variables, "NF", numeric(this.nfNum));
|
|
243
|
-
}
|
|
244
|
-
else if (name === "ENVIRON" && !this.environInitialized)
|
|
245
|
-
this.ensureEnviron();
|
|
246
|
-
}
|
|
247
|
-
return this.store(name).get(name) ?? unset;
|
|
248
|
-
}
|
|
249
|
-
getScalar(name) { return scalar(this.get(name)); }
|
|
250
|
-
asText(value) {
|
|
251
|
-
if (value.kind === "string" || value.kind === "numeric")
|
|
252
|
-
return value.text;
|
|
253
|
-
if (value.kind === "unset")
|
|
254
|
-
return "";
|
|
255
|
-
return text(value, text(this.getScalar("CONVFMT"), undefined, this.budget), this.budget);
|
|
256
|
-
}
|
|
257
|
-
varText(name) {
|
|
258
|
-
if (this.frames.length === 0) {
|
|
259
|
-
if (name === "FS")
|
|
260
|
-
return this.fsText;
|
|
261
|
-
if (name === "RS")
|
|
262
|
-
return this.rsText;
|
|
263
|
-
if (name === "CONVFMT")
|
|
264
|
-
return this.convfmtText;
|
|
265
|
-
}
|
|
266
|
-
return this.asText(this.getScalar(name));
|
|
267
|
-
}
|
|
268
|
-
retainName(path) {
|
|
269
|
-
this.context.signal.throwIfAborted();
|
|
270
|
-
return this.retention.replace(0, shellValueByteLength(path), () => path.split("").join(""));
|
|
271
|
-
}
|
|
272
|
-
storeScalar(store, name, value) {
|
|
273
|
-
if (value.kind === "string" || value.kind === "numeric")
|
|
274
|
-
this.budget.check(value.text);
|
|
275
|
-
this.retention.admit(textSize(store.get(name)), textSize(value));
|
|
276
|
-
const owned = ownScalar(value);
|
|
277
|
-
store.set(name, owned);
|
|
278
|
-
if (store === this.variables) {
|
|
279
|
-
if (name === "FS")
|
|
280
|
-
this.fsText = this.asText(owned);
|
|
281
|
-
else if (name === "RS")
|
|
282
|
-
this.rsText = this.asText(owned);
|
|
283
|
-
else if (name === "CONVFMT")
|
|
284
|
-
this.convfmtText = this.asText(owned);
|
|
285
|
-
else if (name === "NR") {
|
|
286
|
-
this.nrNum = number(owned);
|
|
287
|
-
this.nrDirty = false;
|
|
288
|
-
}
|
|
289
|
-
else if (name === "FNR") {
|
|
290
|
-
this.fnrNum = number(owned);
|
|
291
|
-
this.fnrDirty = false;
|
|
292
|
-
}
|
|
293
|
-
else if (name === "NF") {
|
|
294
|
-
this.nfNum = number(owned);
|
|
295
|
-
this.nfDirty = false;
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
bindArray(store, name, array) {
|
|
300
|
-
let allocation = this.arrays.get(array);
|
|
301
|
-
if (!allocation) {
|
|
302
|
-
allocation = { bytes: 0, references: 0 };
|
|
303
|
-
this.arrays.set(array, allocation);
|
|
304
|
-
}
|
|
305
|
-
allocation.references++;
|
|
306
|
-
store.set(name, array);
|
|
307
|
-
}
|
|
308
|
-
releaseStore(store) {
|
|
309
|
-
for (const value of store.values()) {
|
|
310
|
-
if (value instanceof AwkArray) {
|
|
311
|
-
const allocation = this.arrays.get(value);
|
|
312
|
-
if (--allocation.references === 0) {
|
|
313
|
-
this.retention.release(allocation.bytes);
|
|
314
|
-
this.entries -= value.entries.size;
|
|
315
|
-
this.arrays.delete(value);
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
else
|
|
319
|
-
this.retention.release(textSize(value));
|
|
320
|
-
}
|
|
321
|
-
store.clear();
|
|
322
|
-
}
|
|
323
|
-
set(name, value) {
|
|
324
|
-
if (this.get(name) instanceof AwkArray)
|
|
325
|
-
throw new ProgramError(`cannot assign a scalar to array '${name}'`);
|
|
326
|
-
if (name === "NF" && this.store(name) === this.variables) {
|
|
327
|
-
const length = Math.trunc(number(value));
|
|
328
|
-
if (!Number.isSafeInteger(length) || length < 0 || length > (this.budget.options.maxFields ?? Infinity))
|
|
329
|
-
throw new ProgramError("invalid or excessive NF");
|
|
330
|
-
const fields = this.ensureFields().slice(0, length);
|
|
331
|
-
while (fields.length < length)
|
|
332
|
-
fields.push(string(""));
|
|
333
|
-
this.rebuild(fields);
|
|
334
|
-
return;
|
|
335
|
-
}
|
|
336
|
-
this.storeScalar(this.store(name), name, value);
|
|
337
|
-
}
|
|
338
|
-
setNumber(name, n) {
|
|
339
|
-
const valNum = (n | 0) === n && (n !== 0 || 1 / n > 0) ? (n | 0) : n;
|
|
340
|
-
const store = this.store(name);
|
|
341
|
-
if (name === "NF" && store === this.variables) {
|
|
342
|
-
const val = numeric(valNum);
|
|
343
|
-
this.set(name, val);
|
|
344
|
-
return val;
|
|
345
|
-
}
|
|
346
|
-
const existing = store.get(name);
|
|
347
|
-
if (existing instanceof AwkArray)
|
|
348
|
-
throw new ProgramError(`cannot assign a scalar to array '${name}'`);
|
|
349
|
-
this.retention.admit(textSize(existing), 0);
|
|
350
|
-
const box = numeric(valNum);
|
|
351
|
-
store.set(name, box);
|
|
352
|
-
if (store === this.variables) {
|
|
353
|
-
if (name === "FS")
|
|
354
|
-
this.fsText = this.asText(box);
|
|
355
|
-
else if (name === "RS")
|
|
356
|
-
this.rsText = this.asText(box);
|
|
357
|
-
else if (name === "CONVFMT")
|
|
358
|
-
this.convfmtText = this.asText(box);
|
|
359
|
-
else if (name === "NR") {
|
|
360
|
-
this.nrNum = valNum;
|
|
361
|
-
this.nrDirty = false;
|
|
362
|
-
}
|
|
363
|
-
else if (name === "FNR") {
|
|
364
|
-
this.fnrNum = valNum;
|
|
365
|
-
this.fnrDirty = false;
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
return box;
|
|
369
|
-
}
|
|
370
|
-
array(name) {
|
|
371
|
-
const value = this.get(name);
|
|
372
|
-
if (value instanceof AwkArray)
|
|
373
|
-
return value;
|
|
374
|
-
if (value.kind !== "unset")
|
|
375
|
-
throw new ProgramError(`scalar '${name}' used as an array`);
|
|
376
|
-
const array = new AwkArray();
|
|
377
|
-
this.bindArray(this.store(name), name, array);
|
|
378
|
-
return array;
|
|
379
|
-
}
|
|
380
|
-
arraySet(array, key, value) {
|
|
381
|
-
this.budget.check(key);
|
|
382
|
-
if (value.kind === "string" || value.kind === "numeric")
|
|
383
|
-
this.budget.check(value.text);
|
|
384
|
-
const existingValue = array.entries.get(key);
|
|
385
|
-
if (existingValue !== undefined && existingValue.kind === "number" && value.kind === "number") {
|
|
386
|
-
if (this.budget.context.signal.aborted)
|
|
387
|
-
this.budget.context.signal.throwIfAborted();
|
|
388
|
-
array.entries.set(key, ownScalar(value));
|
|
389
|
-
return;
|
|
390
|
-
}
|
|
391
|
-
const existing = existingValue !== undefined || array.entries.has(key);
|
|
392
|
-
if (!existing && this.entries >= (this.budget.options.maxArrayEntries ?? Infinity))
|
|
393
|
-
throw new ProgramError("array entry limit exceeded");
|
|
394
|
-
const previous = textSize(existingValue), next = textSize(value) + (existing ? 0 : key.length);
|
|
395
|
-
this.retention.admit(previous, next);
|
|
396
|
-
const ownedKey = existing || key.length < 13 ? key : latin1Text(latin1Bytes(key));
|
|
397
|
-
array.entries.set(ownedKey, ownScalar(value));
|
|
398
|
-
if (next !== previous)
|
|
399
|
-
this.arrays.get(array).bytes += next - previous;
|
|
400
|
-
if (!existing)
|
|
401
|
-
this.entries++;
|
|
402
|
-
}
|
|
403
|
-
pattern(source) {
|
|
404
|
-
const map = this.regexes ??= new Map();
|
|
405
|
-
let pattern = map.get(source);
|
|
406
|
-
if (!pattern) {
|
|
407
|
-
pattern = new Pattern(source, true, false, "awk");
|
|
408
|
-
if (map.size >= 256)
|
|
409
|
-
map.delete(map.keys().next().value);
|
|
410
|
-
map.set(source, pattern);
|
|
411
|
-
}
|
|
412
|
-
return pattern;
|
|
413
|
-
}
|
|
414
|
-
async regex(expression) { return expression.kind === "regex" ? expression.pattern : this.pattern(this.asText(await this.scalarExpression(expression))); }
|
|
415
|
-
splitSync(value, separator, paragraph) {
|
|
416
|
-
if (!paragraph && value.length < 256 && (separator === " " || separator.length === 1)) {
|
|
417
|
-
this.budget.step(value.length);
|
|
418
|
-
const maxFields = this.budget.options.maxFields ?? Infinity;
|
|
419
|
-
const parts = [];
|
|
420
|
-
if (separator === " ") {
|
|
421
|
-
let start = -1;
|
|
422
|
-
for (let index = 0; index < value.length; index++) {
|
|
423
|
-
const ch = value.charCodeAt(index);
|
|
424
|
-
if (ch === 32 || ch === 9 || ch === 10) {
|
|
425
|
-
if (start >= 0) {
|
|
426
|
-
if (parts.length >= maxFields)
|
|
427
|
-
throw new ProgramError("field count limit exceeded");
|
|
428
|
-
parts.push(inputValue(value.slice(start, index)));
|
|
429
|
-
start = -1;
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
else if (start < 0)
|
|
433
|
-
start = index;
|
|
434
|
-
}
|
|
435
|
-
if (start >= 0) {
|
|
436
|
-
if (parts.length >= maxFields)
|
|
437
|
-
throw new ProgramError("field count limit exceeded");
|
|
438
|
-
parts.push(inputValue(value.slice(start, value.length)));
|
|
439
|
-
}
|
|
440
|
-
return parts;
|
|
441
|
-
}
|
|
442
|
-
if (value !== "") {
|
|
443
|
-
let start = 0;
|
|
444
|
-
let idx;
|
|
445
|
-
while ((idx = value.indexOf(separator, start)) >= 0) {
|
|
446
|
-
if (parts.length >= maxFields)
|
|
447
|
-
throw new ProgramError("field count limit exceeded");
|
|
448
|
-
parts.push(inputValue(value.slice(start, idx)));
|
|
449
|
-
start = idx + 1;
|
|
450
|
-
}
|
|
451
|
-
if (parts.length >= maxFields)
|
|
452
|
-
throw new ProgramError("field count limit exceeded");
|
|
453
|
-
parts.push(inputValue(value.slice(start, value.length)));
|
|
454
|
-
}
|
|
455
|
-
return parts;
|
|
456
|
-
}
|
|
457
|
-
return this.split(value, separator, paragraph);
|
|
458
|
-
}
|
|
459
|
-
async split(value, separator, paragraph = false) {
|
|
460
|
-
// Admit the byte scan/copy before building fields; regex matching charges its own work.
|
|
461
|
-
this.budget.step(value.length);
|
|
462
|
-
const parts = [];
|
|
463
|
-
const append = (start, end) => {
|
|
464
|
-
if (parts.length >= (this.budget.options.maxFields ?? Infinity))
|
|
465
|
-
throw new ProgramError("field count limit exceeded");
|
|
466
|
-
parts.push(inputValue(value.slice(start, end)));
|
|
467
|
-
};
|
|
468
|
-
if (separator === " ") {
|
|
469
|
-
let start = -1;
|
|
470
|
-
for (let index = 0; index < value.length; index++) {
|
|
471
|
-
if (index % 256 === 0)
|
|
472
|
-
await this.budget.checkpointSync();
|
|
473
|
-
if (" \t\n".includes(value[index])) {
|
|
474
|
-
if (start >= 0) {
|
|
475
|
-
append(start, index);
|
|
476
|
-
start = -1;
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
else if (start < 0)
|
|
480
|
-
start = index;
|
|
481
|
-
}
|
|
482
|
-
if (start >= 0)
|
|
483
|
-
append(start, value.length);
|
|
484
|
-
}
|
|
485
|
-
else if (separator === "") {
|
|
486
|
-
if (value.length > (this.budget.options.maxFields ?? Infinity))
|
|
487
|
-
throw new ProgramError("field count limit exceeded");
|
|
488
|
-
for (let index = 0; index < value.length; index++) {
|
|
489
|
-
if (index % 256 === 0)
|
|
490
|
-
await this.budget.checkpointSync();
|
|
491
|
-
append(index, index + 1);
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
else if (typeof separator === "string" && separator.length === 1) {
|
|
495
|
-
if (!paragraph && value.length < 256) {
|
|
496
|
-
if (value !== "") {
|
|
497
|
-
let start = 0;
|
|
498
|
-
let idx;
|
|
499
|
-
while ((idx = value.indexOf(separator, start)) >= 0) {
|
|
500
|
-
append(start, idx);
|
|
501
|
-
start = idx + 1;
|
|
502
|
-
}
|
|
503
|
-
append(start, value.length);
|
|
504
|
-
}
|
|
505
|
-
return parts;
|
|
506
|
-
}
|
|
507
|
-
let start = 0;
|
|
508
|
-
for (let index = 0; index < value.length; index++) {
|
|
509
|
-
if (index > 0 && index % 256 === 0) {
|
|
510
|
-
const p = this.budget.checkpointSync();
|
|
511
|
-
if (p)
|
|
512
|
-
await p;
|
|
513
|
-
}
|
|
514
|
-
if (value[index] === separator || paragraph && value[index] === "\n") {
|
|
515
|
-
append(start, index);
|
|
516
|
-
start = index + 1;
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
if (value !== "")
|
|
520
|
-
append(start, value.length);
|
|
521
|
-
}
|
|
522
|
-
else {
|
|
523
|
-
const matcher = typeof separator === "string" ? this.pattern(separator) : separator;
|
|
524
|
-
const segment = async (start, end) => {
|
|
525
|
-
if (paragraph)
|
|
526
|
-
for (let index = start; index < end; index++) {
|
|
527
|
-
if (index % 256 === 0)
|
|
528
|
-
await this.budget.checkpointSync();
|
|
529
|
-
if (value[index] === "\n") {
|
|
530
|
-
append(start, index);
|
|
531
|
-
start = index + 1;
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
append(start, end);
|
|
535
|
-
};
|
|
536
|
-
let consumed = 0;
|
|
537
|
-
let search = 0;
|
|
538
|
-
while (search <= value.length) {
|
|
539
|
-
await this.budget.checkpointSync();
|
|
540
|
-
const match = await matcher.find(value, this.budget, search);
|
|
541
|
-
if (!match)
|
|
542
|
-
break;
|
|
543
|
-
if (match.start === match.end) {
|
|
544
|
-
search = match.end + 1;
|
|
545
|
-
continue;
|
|
546
|
-
}
|
|
547
|
-
await segment(consumed, match.start);
|
|
548
|
-
consumed = match.end;
|
|
549
|
-
search = match.end;
|
|
550
|
-
}
|
|
551
|
-
if (value !== "")
|
|
552
|
-
await segment(consumed, value.length);
|
|
553
|
-
}
|
|
554
|
-
return parts;
|
|
555
|
-
}
|
|
556
|
-
parseSliceNumber(record, start, end) {
|
|
557
|
-
const len = end - start;
|
|
558
|
-
if (len <= 0)
|
|
559
|
-
return 0;
|
|
560
|
-
const first = record.charCodeAt(start);
|
|
561
|
-
if (first >= 48 && first <= 57 && len <= 9) {
|
|
562
|
-
let num = (first - 48) | 0;
|
|
563
|
-
for (let i = start + 1; i < end; i++) {
|
|
564
|
-
const c = record.charCodeAt(i);
|
|
565
|
-
if (c < 48 || c > 57) {
|
|
566
|
-
return number(inputValueFromSlice(record, start, end));
|
|
567
|
-
}
|
|
568
|
-
num = (Math.imul(num, 10) + (c - 48)) | 0;
|
|
569
|
-
}
|
|
570
|
-
return num;
|
|
571
|
-
}
|
|
572
|
-
if (first >= 48 && first <= 57 && len <= 15) {
|
|
573
|
-
let num = first - 48;
|
|
574
|
-
for (let i = start + 1; i < end; i++) {
|
|
575
|
-
const c = record.charCodeAt(i);
|
|
576
|
-
if (c < 48 || c > 57) {
|
|
577
|
-
return number(inputValueFromSlice(record, start, end));
|
|
578
|
-
}
|
|
579
|
-
num = num * 10 + (c - 48);
|
|
580
|
-
}
|
|
581
|
-
return num;
|
|
582
|
-
}
|
|
583
|
-
return number(inputValueFromSlice(record, start, end));
|
|
584
|
-
}
|
|
585
|
-
getFieldNumber(index) {
|
|
586
|
-
if (index === 0)
|
|
587
|
-
return number(this.getField(0));
|
|
588
|
-
const slot = index - 1;
|
|
589
|
-
if (this.fieldsMaterialized) {
|
|
590
|
-
const f = this.rawFields[slot];
|
|
591
|
-
return f ? number(f) : 0;
|
|
592
|
-
}
|
|
593
|
-
if (this.fieldCount < 0) {
|
|
594
|
-
const sep = this.deferredFieldSeparator;
|
|
595
|
-
if (sep.length === 1 && sep !== " ") {
|
|
596
|
-
const source = this.recordSource;
|
|
597
|
-
const recEnd = this.recordEnd;
|
|
598
|
-
let start = this.recordStart;
|
|
599
|
-
if (start >= recEnd)
|
|
600
|
-
return 0;
|
|
601
|
-
for (let s = 0; s < slot; s++) {
|
|
602
|
-
const idx = source.indexOf(sep, start);
|
|
603
|
-
if (idx < 0 || idx >= recEnd)
|
|
604
|
-
return 0;
|
|
605
|
-
start = idx + 1;
|
|
606
|
-
}
|
|
607
|
-
const nextIdx = source.indexOf(sep, start);
|
|
608
|
-
const end = nextIdx >= 0 && nextIdx < recEnd ? nextIdx : recEnd;
|
|
609
|
-
return this.parseSliceNumber(source, start, end);
|
|
610
|
-
}
|
|
611
|
-
this.ensureSliceFieldsSplit();
|
|
612
|
-
}
|
|
613
|
-
if (slot < 0 || slot >= this.fieldCount)
|
|
614
|
-
return 0;
|
|
615
|
-
if (this.lazyFieldGen[slot] === this.fieldGeneration) {
|
|
616
|
-
return number(this.lazyFields[slot]);
|
|
617
|
-
}
|
|
618
|
-
return this.parseSliceNumber(this.recordSource, this.fieldStarts[slot], this.fieldEnds[slot]);
|
|
619
|
-
}
|
|
620
|
-
getField(index) {
|
|
621
|
-
if (index === 0) {
|
|
622
|
-
return this.recordValue ??= inputValue(this.record);
|
|
623
|
-
}
|
|
624
|
-
if (this.fieldCount < 0)
|
|
625
|
-
this.ensureSliceFieldsSplit();
|
|
626
|
-
const slot = index - 1;
|
|
627
|
-
if (this.fieldsMaterialized) {
|
|
628
|
-
return this.rawFields[slot] ?? string("");
|
|
629
|
-
}
|
|
630
|
-
if (slot < 0 || slot >= this.fieldCount)
|
|
631
|
-
return string("");
|
|
632
|
-
if (this.lazyFieldGen[slot] === this.fieldGeneration) {
|
|
633
|
-
return this.lazyFields[slot];
|
|
634
|
-
}
|
|
635
|
-
const val = inputValueFromSlice(this.recordSource, this.fieldStarts[slot], this.fieldEnds[slot]);
|
|
636
|
-
this.lazyFieldGen[slot] = this.fieldGeneration;
|
|
637
|
-
this.lazyFields[slot] = val;
|
|
638
|
-
return val;
|
|
639
|
-
}
|
|
640
|
-
ensureFields() {
|
|
641
|
-
if (this.fieldCount < 0)
|
|
642
|
-
this.ensureSliceFieldsSplit();
|
|
643
|
-
if (!this.fieldsMaterialized) {
|
|
644
|
-
const out = new Array(this.fieldCount);
|
|
645
|
-
for (let i = 0; i < this.fieldCount; i++) {
|
|
646
|
-
out[i] = this.lazyFieldGen[i] === this.fieldGeneration
|
|
647
|
-
? this.lazyFields[i]
|
|
648
|
-
: inputValueFromSlice(this.recordSource, this.fieldStarts[i], this.fieldEnds[i]);
|
|
649
|
-
}
|
|
650
|
-
this.rawFields = out;
|
|
651
|
-
this.fieldsMaterialized = true;
|
|
652
|
-
}
|
|
653
|
-
return this.rawFields;
|
|
654
|
-
}
|
|
655
|
-
ensureSliceFieldsSplit() {
|
|
656
|
-
if (this.fieldCount >= 0)
|
|
657
|
-
return;
|
|
658
|
-
const source = this.recordSource;
|
|
659
|
-
const recStart = this.recordStart;
|
|
660
|
-
const recEnd = this.recordEnd;
|
|
661
|
-
const recLen = recEnd - recStart;
|
|
662
|
-
const separator = this.deferredFieldSeparator;
|
|
663
|
-
let count = 0;
|
|
664
|
-
let fieldBytes = 0;
|
|
665
|
-
const starts = this.fieldStarts;
|
|
666
|
-
const ends = this.fieldEnds;
|
|
667
|
-
if (separator === " ") {
|
|
668
|
-
let start = -1;
|
|
669
|
-
for (let index = recStart; index < recEnd; index++) {
|
|
670
|
-
const ch = source.charCodeAt(index);
|
|
671
|
-
if (ch === 32 || ch === 9 || ch === 10) {
|
|
672
|
-
if (start >= 0) {
|
|
673
|
-
starts[count] = start;
|
|
674
|
-
ends[count] = index;
|
|
675
|
-
fieldBytes += index - start;
|
|
676
|
-
count++;
|
|
677
|
-
start = -1;
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
else if (start < 0)
|
|
681
|
-
start = index;
|
|
682
|
-
}
|
|
683
|
-
if (start >= 0) {
|
|
684
|
-
starts[count] = start;
|
|
685
|
-
ends[count] = recEnd;
|
|
686
|
-
fieldBytes += recEnd - start;
|
|
687
|
-
count++;
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
else if (recLen > 0) {
|
|
691
|
-
let start = recStart;
|
|
692
|
-
let idx;
|
|
693
|
-
while ((idx = source.indexOf(separator, start)) >= 0 && idx < recEnd) {
|
|
694
|
-
starts[count] = start;
|
|
695
|
-
ends[count] = idx;
|
|
696
|
-
fieldBytes += idx - start;
|
|
697
|
-
count++;
|
|
698
|
-
start = idx + 1;
|
|
699
|
-
}
|
|
700
|
-
starts[count] = start;
|
|
701
|
-
ends[count] = recEnd;
|
|
702
|
-
fieldBytes += recEnd - start;
|
|
703
|
-
count++;
|
|
704
|
-
}
|
|
705
|
-
this.retention.admit(0, fieldBytes);
|
|
706
|
-
this.fieldBytes = fieldBytes;
|
|
707
|
-
this.fieldCount = count;
|
|
708
|
-
this.nfNum = count;
|
|
709
|
-
}
|
|
710
|
-
setRecordSliceSync(source, recStart, recEnd) {
|
|
711
|
-
const recLen = recEnd - recStart;
|
|
712
|
-
if (recLen > this.budget.maxBufferBytes)
|
|
713
|
-
throw new ProgramError("text buffer limit exceeded");
|
|
714
|
-
const separator = this.varText("FS");
|
|
715
|
-
const paragraph = this.varText("RS") === "";
|
|
716
|
-
const maxFields = this.budget.options.maxFields ?? Infinity;
|
|
717
|
-
if (!paragraph && recLen < 256 && (separator === " " || separator.length === 1) && maxFields >= 64) {
|
|
718
|
-
this.budget.step(recLen);
|
|
719
|
-
if (recLen < 64 && this.retention.capacity === Infinity) {
|
|
720
|
-
this.retention.admit(this.recordLength + this.fieldBytes, recLen);
|
|
721
|
-
this.rawRecord = undefined;
|
|
722
|
-
this.recordSource = source;
|
|
723
|
-
this.recordStart = recStart;
|
|
724
|
-
this.recordEnd = recEnd;
|
|
725
|
-
this.fieldBytes = 0;
|
|
726
|
-
this.fieldCount = -1;
|
|
727
|
-
this.deferredFieldSeparator = separator;
|
|
728
|
-
this.fieldsMaterialized = false;
|
|
729
|
-
this.fieldGeneration = (this.fieldGeneration + 1) | 0 || 1;
|
|
730
|
-
this.recordValue = undefined;
|
|
731
|
-
this.nfDirty = true;
|
|
732
|
-
return;
|
|
733
|
-
}
|
|
734
|
-
let count = 0;
|
|
735
|
-
let fieldBytes = 0;
|
|
736
|
-
const starts = this.fieldStarts;
|
|
737
|
-
const ends = this.fieldEnds;
|
|
738
|
-
if (separator === " ") {
|
|
739
|
-
let start = -1;
|
|
740
|
-
for (let index = recStart; index < recEnd; index++) {
|
|
741
|
-
const ch = source.charCodeAt(index);
|
|
742
|
-
if (ch === 32 || ch === 9 || ch === 10) {
|
|
743
|
-
if (start >= 0) {
|
|
744
|
-
if (count >= maxFields || count >= 64)
|
|
745
|
-
return this.setRecordSlow(source.slice(recStart, recEnd), separator, paragraph);
|
|
746
|
-
starts[count] = start;
|
|
747
|
-
ends[count] = index;
|
|
748
|
-
fieldBytes += index - start;
|
|
749
|
-
count++;
|
|
750
|
-
start = -1;
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
else if (start < 0)
|
|
754
|
-
start = index;
|
|
755
|
-
}
|
|
756
|
-
if (start >= 0) {
|
|
757
|
-
if (count >= maxFields || count >= 64)
|
|
758
|
-
return this.setRecordSlow(source.slice(recStart, recEnd), separator, paragraph);
|
|
759
|
-
starts[count] = start;
|
|
760
|
-
ends[count] = recEnd;
|
|
761
|
-
fieldBytes += recEnd - start;
|
|
762
|
-
count++;
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
|
-
else if (recLen > 0) {
|
|
766
|
-
let start = recStart;
|
|
767
|
-
let idx;
|
|
768
|
-
while ((idx = source.indexOf(separator, start)) >= 0 && idx < recEnd) {
|
|
769
|
-
if (count >= maxFields || count >= 64)
|
|
770
|
-
return this.setRecordSlow(source.slice(recStart, recEnd), separator, paragraph);
|
|
771
|
-
starts[count] = start;
|
|
772
|
-
ends[count] = idx;
|
|
773
|
-
fieldBytes += idx - start;
|
|
774
|
-
count++;
|
|
775
|
-
start = idx + 1;
|
|
776
|
-
}
|
|
777
|
-
if (count >= maxFields || count >= 64)
|
|
778
|
-
return this.setRecordSlow(source.slice(recStart, recEnd), separator, paragraph);
|
|
779
|
-
starts[count] = start;
|
|
780
|
-
ends[count] = recEnd;
|
|
781
|
-
fieldBytes += recEnd - start;
|
|
782
|
-
count++;
|
|
783
|
-
}
|
|
784
|
-
this.retention.admit(this.recordLength + this.fieldBytes, recLen + fieldBytes);
|
|
785
|
-
this.rawRecord = undefined;
|
|
786
|
-
this.recordSource = source;
|
|
787
|
-
this.recordStart = recStart;
|
|
788
|
-
this.recordEnd = recEnd;
|
|
789
|
-
this.fieldBytes = fieldBytes;
|
|
790
|
-
this.fieldCount = count;
|
|
791
|
-
this.fieldsMaterialized = false;
|
|
792
|
-
this.fieldGeneration = (this.fieldGeneration + 1) | 0 || 1;
|
|
793
|
-
this.recordValue = undefined;
|
|
794
|
-
this.nfNum = count;
|
|
795
|
-
this.nfDirty = true;
|
|
796
|
-
return;
|
|
797
|
-
}
|
|
798
|
-
return this.setRecordSlow(source.slice(recStart, recEnd), separator, paragraph);
|
|
799
|
-
}
|
|
800
|
-
setRecordSync(record, value) {
|
|
801
|
-
if (value === undefined)
|
|
802
|
-
return this.setRecordSliceSync(record, 0, record.length);
|
|
803
|
-
this.budget.check(record);
|
|
804
|
-
const separator = this.varText("FS");
|
|
805
|
-
const paragraph = this.varText("RS") === "";
|
|
806
|
-
const maxFields = this.budget.options.maxFields ?? Infinity;
|
|
807
|
-
if (value === undefined && !paragraph && record.length < 256 && (separator === " " || separator.length === 1) && maxFields >= 64) {
|
|
808
|
-
this.budget.step(record.length);
|
|
809
|
-
let count = 0;
|
|
810
|
-
let fieldBytes = 0;
|
|
811
|
-
const starts = this.fieldStarts;
|
|
812
|
-
const ends = this.fieldEnds;
|
|
813
|
-
if (separator === " ") {
|
|
814
|
-
let start = -1;
|
|
815
|
-
for (let index = 0; index < record.length; index++) {
|
|
816
|
-
const ch = record.charCodeAt(index);
|
|
817
|
-
if (ch === 32 || ch === 9 || ch === 10) {
|
|
818
|
-
if (start >= 0) {
|
|
819
|
-
if (count >= maxFields || count >= 64)
|
|
820
|
-
return this.setRecordSlow(record, separator, paragraph, value);
|
|
821
|
-
starts[count] = start;
|
|
822
|
-
ends[count] = index;
|
|
823
|
-
fieldBytes += index - start;
|
|
824
|
-
count++;
|
|
825
|
-
start = -1;
|
|
826
|
-
}
|
|
827
|
-
}
|
|
828
|
-
else if (start < 0)
|
|
829
|
-
start = index;
|
|
830
|
-
}
|
|
831
|
-
if (start >= 0) {
|
|
832
|
-
if (count >= maxFields || count >= 64)
|
|
833
|
-
return this.setRecordSlow(record, separator, paragraph, value);
|
|
834
|
-
starts[count] = start;
|
|
835
|
-
ends[count] = record.length;
|
|
836
|
-
fieldBytes += record.length - start;
|
|
837
|
-
count++;
|
|
838
|
-
}
|
|
839
|
-
}
|
|
840
|
-
else if (record !== "") {
|
|
841
|
-
let start = 0;
|
|
842
|
-
let idx;
|
|
843
|
-
while ((idx = record.indexOf(separator, start)) >= 0) {
|
|
844
|
-
if (count >= maxFields || count >= 64)
|
|
845
|
-
return this.setRecordSlow(record, separator, paragraph, value);
|
|
846
|
-
starts[count] = start;
|
|
847
|
-
ends[count] = idx;
|
|
848
|
-
fieldBytes += idx - start;
|
|
849
|
-
count++;
|
|
850
|
-
start = idx + 1;
|
|
851
|
-
}
|
|
852
|
-
if (count >= maxFields || count >= 64)
|
|
853
|
-
return this.setRecordSlow(record, separator, paragraph, value);
|
|
854
|
-
starts[count] = start;
|
|
855
|
-
ends[count] = record.length;
|
|
856
|
-
fieldBytes += record.length - start;
|
|
857
|
-
count++;
|
|
858
|
-
}
|
|
859
|
-
this.retention.admit(this.record.length + this.fieldBytes, record.length + fieldBytes);
|
|
860
|
-
this.record = record;
|
|
861
|
-
this.fieldBytes = fieldBytes;
|
|
862
|
-
this.fieldCount = count;
|
|
863
|
-
this.fieldsMaterialized = false;
|
|
864
|
-
this.fieldGeneration = (this.fieldGeneration + 1) | 0 || 1;
|
|
865
|
-
this.recordValue = undefined;
|
|
866
|
-
this.variables.set("NF", numeric(count));
|
|
867
|
-
return;
|
|
868
|
-
}
|
|
869
|
-
return this.setRecordSlow(record, separator, paragraph, value);
|
|
870
|
-
}
|
|
871
|
-
setRecordSlow(record, separator, paragraph, value) {
|
|
872
|
-
const resolvedVal = value ?? inputValue(record);
|
|
873
|
-
const fields = this.splitSync(record, separator, paragraph);
|
|
874
|
-
if (!(fields instanceof Promise)) {
|
|
875
|
-
this.replaceRecord(record, fields, resolvedVal);
|
|
876
|
-
return;
|
|
877
|
-
}
|
|
878
|
-
return fields.then(resolved => { this.replaceRecord(record, resolved, resolvedVal); });
|
|
879
|
-
}
|
|
880
|
-
async setRecord(record, value) {
|
|
881
|
-
await this.setRecordSync(record, value);
|
|
882
|
-
}
|
|
883
|
-
replaceRecord(record, fields, value = string(record)) {
|
|
884
|
-
let fieldBytes = 0;
|
|
885
|
-
for (const field of fields) {
|
|
886
|
-
if (field.kind === "string" || field.kind === "numeric")
|
|
887
|
-
this.budget.check(field.text);
|
|
888
|
-
fieldBytes += textSize(field);
|
|
889
|
-
}
|
|
890
|
-
this.retention.admit(this.recordLength + this.fieldBytes, record.length + fieldBytes);
|
|
891
|
-
this.record = record;
|
|
892
|
-
this.fields = fields;
|
|
893
|
-
this.fieldCount = fields.length;
|
|
894
|
-
this.fieldsMaterialized = true;
|
|
895
|
-
this.fieldBytes = fieldBytes;
|
|
896
|
-
this.recordValue = value.kind === "string" || value.kind === "numeric" ? { ...value, text: this.record } : value;
|
|
897
|
-
this.nfNum = fields.length;
|
|
898
|
-
this.nfDirty = true;
|
|
899
|
-
}
|
|
900
|
-
join(parts, separator, suffix = "") {
|
|
901
|
-
this.budget.step(parts.length + 1);
|
|
902
|
-
let used = 0;
|
|
903
|
-
for (let index = 0; index < parts.length; index++) {
|
|
904
|
-
if (index > 0) {
|
|
905
|
-
if (separator.length > this.budget.maxBufferBytes - used)
|
|
906
|
-
throw new ProgramError("text buffer limit exceeded");
|
|
907
|
-
used += separator.length;
|
|
908
|
-
}
|
|
909
|
-
if (parts[index].length > this.budget.maxBufferBytes - used)
|
|
910
|
-
throw new ProgramError("text buffer limit exceeded");
|
|
911
|
-
used += parts[index].length;
|
|
912
|
-
}
|
|
913
|
-
if (suffix.length > this.budget.maxBufferBytes - used)
|
|
914
|
-
throw new ProgramError("text buffer limit exceeded");
|
|
915
|
-
used += suffix.length;
|
|
916
|
-
this.budget.step(used);
|
|
917
|
-
return parts.join(separator) + suffix;
|
|
918
|
-
}
|
|
919
|
-
rebuild(fields) {
|
|
920
|
-
const record = this.join(fields.map(value => this.asText(value)), this.varText("OFS"));
|
|
921
|
-
this.replaceRecord(record, fields);
|
|
922
|
-
}
|
|
923
|
-
key(items) {
|
|
924
|
-
if (items.length === 1) {
|
|
925
|
-
const first = this.scalarExpression(items[0]);
|
|
926
|
-
if (!(first instanceof Promise)) {
|
|
927
|
-
const k = this.asText(first);
|
|
928
|
-
this.budget.step(2);
|
|
929
|
-
if (k.length > this.budget.maxBufferBytes)
|
|
930
|
-
throw new ProgramError("text buffer limit exceeded");
|
|
931
|
-
this.budget.step(k.length);
|
|
932
|
-
return k;
|
|
933
|
-
}
|
|
934
|
-
}
|
|
935
|
-
return this.keySlow(items);
|
|
936
|
-
}
|
|
937
|
-
async keySlow(items) {
|
|
938
|
-
const pieces = [];
|
|
939
|
-
for (const item of items)
|
|
940
|
-
pieces.push(this.asText(await this.scalarExpression(item)));
|
|
941
|
-
return this.join(pieces, this.varText("SUBSEP"));
|
|
942
|
-
}
|
|
943
|
-
async reference(expression) {
|
|
944
|
-
if (expression.kind === "variable")
|
|
945
|
-
return { get: () => this.get(expression.name), set: value => this.set(expression.name, value) };
|
|
946
|
-
if (expression.kind === "field") {
|
|
947
|
-
const index = Math.trunc(number(await this.scalarExpression(expression.index)));
|
|
948
|
-
if (!Number.isSafeInteger(index) || index < 0 || index > (this.budget.options.maxFields ?? Infinity))
|
|
949
|
-
throw new ProgramError("invalid or excessive field index");
|
|
950
|
-
return {
|
|
951
|
-
get: () => this.getField(index),
|
|
952
|
-
set: value => {
|
|
953
|
-
if (index === 0)
|
|
954
|
-
return this.setRecord(this.asText(value), value);
|
|
955
|
-
const fields = this.ensureFields().slice();
|
|
956
|
-
while (fields.length < index)
|
|
957
|
-
fields.push(string(""));
|
|
958
|
-
fields[index - 1] = value;
|
|
959
|
-
this.rebuild(fields);
|
|
960
|
-
},
|
|
961
|
-
};
|
|
962
|
-
}
|
|
963
|
-
if (expression.kind === "array") {
|
|
964
|
-
const array = this.array(expression.name);
|
|
965
|
-
const key = await this.key(expression.indexes);
|
|
966
|
-
return { get: () => { if (!array.entries.has(key))
|
|
967
|
-
this.arraySet(array, key, unset); return array.entries.get(key); }, set: value => this.arraySet(array, key, value) };
|
|
968
|
-
}
|
|
969
|
-
throw new ProgramError("expression is not assignable");
|
|
970
|
-
}
|
|
971
|
-
arithmetic(operator, left, right) {
|
|
972
|
-
if ((operator === "/" || operator === "%") && right === 0)
|
|
973
|
-
throw new ProgramError("division by zero");
|
|
974
|
-
const result = operator === "+" ? left + right : operator === "-" ? left - right : operator === "*" ? left * right : operator === "/" ? left / right : operator === "%" ? left % right : left ** right;
|
|
975
|
-
if (!Number.isFinite(result))
|
|
976
|
-
throw new ProgramError("non-finite arithmetic result");
|
|
977
|
-
return result;
|
|
978
|
-
}
|
|
979
|
-
scalarExpression(expression) {
|
|
980
|
-
const val = this.evaluate(expression);
|
|
981
|
-
return val instanceof Promise ? val.then(scalar) : scalar(val);
|
|
982
|
-
}
|
|
983
|
-
evaluate(expression) {
|
|
984
|
-
this.budget.step();
|
|
985
|
-
switch (expression.kind) {
|
|
986
|
-
case "number": return numeric(expression.value);
|
|
987
|
-
case "string": return string(expression.value);
|
|
988
|
-
case "regex": return this.evaluateRegexMatch(expression.pattern);
|
|
989
|
-
case "variable": return this.get(expression.name);
|
|
990
|
-
case "field": {
|
|
991
|
-
if (expression.index.kind === "number") {
|
|
992
|
-
this.budget.step();
|
|
993
|
-
const index = Math.trunc(expression.index.value);
|
|
994
|
-
if (!Number.isSafeInteger(index) || index < 0 || index > (this.budget.options.maxFields ?? Infinity))
|
|
995
|
-
throw new ProgramError("invalid or excessive field index");
|
|
996
|
-
return this.getField(index);
|
|
997
|
-
}
|
|
998
|
-
const idxVal = this.scalarExpression(expression.index);
|
|
999
|
-
if (!(idxVal instanceof Promise)) {
|
|
1000
|
-
const index = Math.trunc(number(idxVal));
|
|
1001
|
-
if (!Number.isSafeInteger(index) || index < 0 || index > (this.budget.options.maxFields ?? Infinity))
|
|
1002
|
-
throw new ProgramError("invalid or excessive field index");
|
|
1003
|
-
return this.getField(index);
|
|
1004
|
-
}
|
|
1005
|
-
return this.evaluateFieldAsync(idxVal);
|
|
1006
|
-
}
|
|
1007
|
-
case "array": {
|
|
1008
|
-
const array = this.array(expression.name);
|
|
1009
|
-
const k = this.key(expression.indexes);
|
|
1010
|
-
if (!(k instanceof Promise)) {
|
|
1011
|
-
let existing = array.entries.get(k);
|
|
1012
|
-
if (existing === undefined && !array.entries.has(k)) {
|
|
1013
|
-
this.arraySet(array, k, unset);
|
|
1014
|
-
existing = unset;
|
|
1015
|
-
}
|
|
1016
|
-
return existing;
|
|
1017
|
-
}
|
|
1018
|
-
return this.evaluateArrayAsync(array, k);
|
|
1019
|
-
}
|
|
1020
|
-
case "getline": return this.getline(expression);
|
|
1021
|
-
case "tuple": throw new ProgramError("tuple is only valid as an array membership key");
|
|
1022
|
-
case "conditional": {
|
|
1023
|
-
const cond = this.scalarExpression(expression.condition);
|
|
1024
|
-
return cond instanceof Promise ? this.evaluateConditionalAsync(expression, cond) : this.evaluate(truth(cond) ? expression.yes : expression.no);
|
|
1025
|
-
}
|
|
1026
|
-
case "unary": {
|
|
1027
|
-
if (expression.operator === "++" || expression.operator === "--") {
|
|
1028
|
-
if (expression.operand.kind === "variable") {
|
|
1029
|
-
const name = expression.operand.name;
|
|
1030
|
-
const previous = number(scalar(this.get(name)));
|
|
1031
|
-
const delta = expression.operator === "++" ? 1 : -1;
|
|
1032
|
-
const next = (previous | 0) === previous && previous > -1073741820 && previous < 1073741820
|
|
1033
|
-
? (previous + delta) | 0
|
|
1034
|
-
: previous + delta;
|
|
1035
|
-
const updated = this.setNumber(name, next);
|
|
1036
|
-
return expression.postfix ? numeric(previous) : updated;
|
|
1037
|
-
}
|
|
1038
|
-
if (expression.operand.kind === "array") {
|
|
1039
|
-
const array = this.array(expression.operand.name);
|
|
1040
|
-
const k = this.key(expression.operand.indexes);
|
|
1041
|
-
if (!(k instanceof Promise)) {
|
|
1042
|
-
let current = array.entries.get(k);
|
|
1043
|
-
if (current === undefined && !array.entries.has(k)) {
|
|
1044
|
-
this.arraySet(array, k, unset);
|
|
1045
|
-
current = unset;
|
|
1046
|
-
}
|
|
1047
|
-
const previous = number(scalar(current));
|
|
1048
|
-
const next = previous + (expression.operator === "++" ? 1 : -1);
|
|
1049
|
-
this.arraySet(array, k, numeric(next));
|
|
1050
|
-
return numeric(expression.postfix ? previous : next);
|
|
1051
|
-
}
|
|
1052
|
-
return this.evaluateUnaryArrayAsync(expression, array, k);
|
|
1053
|
-
}
|
|
1054
|
-
return this.evaluateUnarySlow(expression);
|
|
1055
|
-
}
|
|
1056
|
-
const operand = this.scalarExpression(expression.operand);
|
|
1057
|
-
if (!(operand instanceof Promise)) {
|
|
1058
|
-
return numeric(expression.operator === "!" ? truth(operand) ? 0 : 1 : expression.operator === "-" ? -number(operand) : number(operand));
|
|
1059
|
-
}
|
|
1060
|
-
return this.evaluateUnaryValueAsync(expression.operator, operand);
|
|
1061
|
-
}
|
|
1062
|
-
case "binary": {
|
|
1063
|
-
const operator = expression.operator;
|
|
1064
|
-
if (operator === "=" || operator === "+=" || operator === "-=" || operator === "*=" || operator === "/=" || operator === "%=" || operator === "^=") {
|
|
1065
|
-
if (expression.left.kind === "variable") {
|
|
1066
|
-
const name = expression.left.name;
|
|
1067
|
-
if (operator !== "=" && expression.right.kind === "field" && expression.right.index.kind === "number") {
|
|
1068
|
-
this.budget.step(2);
|
|
1069
|
-
const idx = Math.trunc(expression.right.index.value);
|
|
1070
|
-
if (Number.isSafeInteger(idx) && idx > 0 && idx <= (this.budget.options.maxFields ?? Infinity)) {
|
|
1071
|
-
const prevNum = number(scalar(this.get(name)));
|
|
1072
|
-
const rightNum = this.getFieldNumber(idx);
|
|
1073
|
-
const nextNum = operator === "+=" && (prevNum | 0) === prevNum && (rightNum | 0) === rightNum && prevNum > -536870912 && prevNum < 536870912 && rightNum > -536870912 && rightNum < 536870912
|
|
1074
|
-
? (prevNum + rightNum) | 0
|
|
1075
|
-
: this.arithmetic(operator[0], prevNum, rightNum);
|
|
1076
|
-
return this.setNumber(name, nextNum);
|
|
1077
|
-
}
|
|
1078
|
-
}
|
|
1079
|
-
const previous = operator === "=" ? unset : scalar(this.get(name));
|
|
1080
|
-
const rightVal = this.scalarExpression(expression.right);
|
|
1081
|
-
if (!(rightVal instanceof Promise)) {
|
|
1082
|
-
if (operator !== "=") {
|
|
1083
|
-
return this.setNumber(name, this.arithmetic(operator[0], number(previous), number(rightVal)));
|
|
1084
|
-
}
|
|
1085
|
-
this.set(name, rightVal);
|
|
1086
|
-
return rightVal;
|
|
1087
|
-
}
|
|
1088
|
-
return this.evaluateAssignVarAsync(operator, name, previous, rightVal);
|
|
1089
|
-
}
|
|
1090
|
-
else if (expression.left.kind === "array") {
|
|
1091
|
-
const array = this.array(expression.left.name);
|
|
1092
|
-
const k = this.key(expression.left.indexes);
|
|
1093
|
-
if (!(k instanceof Promise)) {
|
|
1094
|
-
let current = operator === "=" ? unset : array.entries.get(k);
|
|
1095
|
-
if (operator !== "=" && current === undefined && !array.entries.has(k)) {
|
|
1096
|
-
this.arraySet(array, k, unset);
|
|
1097
|
-
current = unset;
|
|
1098
|
-
}
|
|
1099
|
-
const previous = scalar(current);
|
|
1100
|
-
const rightVal = this.scalarExpression(expression.right);
|
|
1101
|
-
if (!(rightVal instanceof Promise)) {
|
|
1102
|
-
const value = operator === "=" ? rightVal : numeric(this.arithmetic(operator[0], number(previous), number(rightVal)));
|
|
1103
|
-
this.arraySet(array, k, value);
|
|
1104
|
-
return value;
|
|
1105
|
-
}
|
|
1106
|
-
return this.evaluateAssignArrayRightAsync(operator, array, k, previous, rightVal);
|
|
1107
|
-
}
|
|
1108
|
-
return this.evaluateAssignArrayKeyAsync(expression, operator, array, k);
|
|
1109
|
-
}
|
|
1110
|
-
return this.evaluateBinarySlow(expression);
|
|
1111
|
-
}
|
|
1112
|
-
if (operator === "~" || operator === "!~") {
|
|
1113
|
-
if (expression.right.kind === "regex") {
|
|
1114
|
-
const left = this.scalarExpression(expression.left);
|
|
1115
|
-
if (!(left instanceof Promise)) {
|
|
1116
|
-
const matched = expression.right.pattern.tryTestSync(this.asText(left), this.budget);
|
|
1117
|
-
if (!(matched instanceof Promise)) {
|
|
1118
|
-
return numeric((operator === "~" ? matched : !matched) ? 1 : 0);
|
|
1119
|
-
}
|
|
1120
|
-
}
|
|
1121
|
-
}
|
|
1122
|
-
return this.evaluateBinarySlow(expression);
|
|
1123
|
-
}
|
|
1124
|
-
if (operator === "in") {
|
|
1125
|
-
return this.evaluateBinarySlow(expression);
|
|
1126
|
-
}
|
|
1127
|
-
const left = this.scalarExpression(expression.left);
|
|
1128
|
-
if (left instanceof Promise)
|
|
1129
|
-
return this.evaluateBinaryWithLeftPromise(expression, left);
|
|
1130
|
-
if (operator === "&&" && !truth(left))
|
|
1131
|
-
return numeric(0);
|
|
1132
|
-
if (operator === "||" && truth(left))
|
|
1133
|
-
return numeric(1);
|
|
1134
|
-
const right = this.scalarExpression(expression.right);
|
|
1135
|
-
if (right instanceof Promise)
|
|
1136
|
-
return this.evaluateBinaryWithRightPromise(operator, left, right);
|
|
1137
|
-
return this.evaluateBinarySyncOperands(operator, left, right);
|
|
1138
|
-
}
|
|
1139
|
-
case "call": return this.call(expression.name, expression.args);
|
|
1140
|
-
}
|
|
1141
|
-
}
|
|
1142
|
-
evaluateRegexMatch(pattern) {
|
|
1143
|
-
if (pattern.canFindSync() && this.recordLength < 256) {
|
|
1144
|
-
const fastMatched = this.rawRecord !== undefined
|
|
1145
|
-
? pattern.findSyncFastInto(this.rawRecord, this.budget, 0, FAST_AWK_MATCH_OFFSETS, this.rawRecord.length, 0)
|
|
1146
|
-
: pattern.findSyncFastInto(this.recordSource, this.budget, this.recordStart, FAST_AWK_MATCH_OFFSETS, this.recordEnd, this.recordStart);
|
|
1147
|
-
const count = ++this.recordChecks;
|
|
1148
|
-
if (count <= 2 || (count & 31) === 0) {
|
|
1149
|
-
const p = this.budget.checkpointSync();
|
|
1150
|
-
if (p)
|
|
1151
|
-
return p.then(fastMatched ? RETURN_SCALAR_ONE : RETURN_SCALAR_ZERO);
|
|
1152
|
-
}
|
|
1153
|
-
return fastMatched ? SCALAR_ONE : SCALAR_ZERO;
|
|
1154
|
-
}
|
|
1155
|
-
const matched = this.rawRecord !== undefined
|
|
1156
|
-
? pattern.tryTestSync(this.rawRecord, this.budget, 0, this.rawRecord.length)
|
|
1157
|
-
: pattern.tryTestSync(this.recordSource, this.budget, this.recordStart, this.recordEnd);
|
|
1158
|
-
if (matched instanceof Promise)
|
|
1159
|
-
return matched.then(m => (m ? SCALAR_ONE : SCALAR_ZERO));
|
|
1160
|
-
return matched ? SCALAR_ONE : SCALAR_ZERO;
|
|
1161
|
-
}
|
|
1162
|
-
async evaluateFieldAsync(idxPromise) {
|
|
1163
|
-
const resolved = await idxPromise;
|
|
1164
|
-
const index = Math.trunc(number(resolved));
|
|
1165
|
-
if (!Number.isSafeInteger(index) || index < 0 || index > (this.budget.options.maxFields ?? Infinity))
|
|
1166
|
-
throw new ProgramError("invalid or excessive field index");
|
|
1167
|
-
return this.getField(index);
|
|
1168
|
-
}
|
|
1169
|
-
async evaluateArrayAsync(array, keyPromise) {
|
|
1170
|
-
const resolvedKey = await keyPromise;
|
|
1171
|
-
let existing = array.entries.get(resolvedKey);
|
|
1172
|
-
if (existing === undefined && !array.entries.has(resolvedKey)) {
|
|
1173
|
-
this.arraySet(array, resolvedKey, unset);
|
|
1174
|
-
existing = unset;
|
|
1175
|
-
}
|
|
1176
|
-
return existing;
|
|
1177
|
-
}
|
|
1178
|
-
async evaluateConditionalAsync(expression, condPromise) {
|
|
1179
|
-
const c = await condPromise;
|
|
1180
|
-
return this.evaluate(truth(c) ? expression.yes : expression.no);
|
|
1181
|
-
}
|
|
1182
|
-
async evaluateUnaryArrayAsync(expression, array, keyPromise) {
|
|
1183
|
-
const resolvedKey = await keyPromise;
|
|
1184
|
-
let current = array.entries.get(resolvedKey);
|
|
1185
|
-
if (current === undefined && !array.entries.has(resolvedKey)) {
|
|
1186
|
-
this.arraySet(array, resolvedKey, unset);
|
|
1187
|
-
current = unset;
|
|
1188
|
-
}
|
|
1189
|
-
const previous = number(scalar(current));
|
|
1190
|
-
const next = previous + (expression.operator === "++" ? 1 : -1);
|
|
1191
|
-
this.arraySet(array, resolvedKey, numeric(next));
|
|
1192
|
-
return numeric(expression.postfix ? previous : next);
|
|
1193
|
-
}
|
|
1194
|
-
async evaluateUnaryValueAsync(operator, operandPromise) {
|
|
1195
|
-
const op = await operandPromise;
|
|
1196
|
-
return numeric(operator === "!" ? truth(op) ? 0 : 1 : operator === "-" ? -number(op) : number(op));
|
|
1197
|
-
}
|
|
1198
|
-
async evaluateAssignVarAsync(operator, name, previous, rightPromise) {
|
|
1199
|
-
const resolved = await rightPromise;
|
|
1200
|
-
const value = operator === "=" ? resolved : numeric(this.arithmetic(operator[0], number(previous), number(resolved)));
|
|
1201
|
-
this.set(name, value);
|
|
1202
|
-
return value;
|
|
1203
|
-
}
|
|
1204
|
-
async evaluateAssignArrayRightAsync(operator, array, k, previous, rightPromise) {
|
|
1205
|
-
const resolved = await rightPromise;
|
|
1206
|
-
const value = operator === "=" ? resolved : numeric(this.arithmetic(operator[0], number(previous), number(resolved)));
|
|
1207
|
-
this.arraySet(array, k, value);
|
|
1208
|
-
return value;
|
|
1209
|
-
}
|
|
1210
|
-
async evaluateAssignArrayKeyAsync(expression, operator, array, keyPromise) {
|
|
1211
|
-
const resolvedKey = await keyPromise;
|
|
1212
|
-
let current = operator === "=" ? unset : array.entries.get(resolvedKey);
|
|
1213
|
-
if (operator !== "=" && current === undefined && !array.entries.has(resolvedKey)) {
|
|
1214
|
-
this.arraySet(array, resolvedKey, unset);
|
|
1215
|
-
current = unset;
|
|
1216
|
-
}
|
|
1217
|
-
const previous = scalar(current);
|
|
1218
|
-
const resolved = await this.scalarExpression(expression.right);
|
|
1219
|
-
const value = operator === "=" ? resolved : numeric(this.arithmetic(operator[0], number(previous), number(resolved)));
|
|
1220
|
-
this.arraySet(array, resolvedKey, value);
|
|
1221
|
-
return value;
|
|
1222
|
-
}
|
|
1223
|
-
async evaluateBinaryWithRightPromise(operator, left, rightPromise) {
|
|
1224
|
-
const r = await rightPromise;
|
|
1225
|
-
return this.evaluateBinarySyncOperands(operator, left, r);
|
|
1226
|
-
}
|
|
1227
|
-
evaluateBinarySyncOperands(operator, left, right) {
|
|
1228
|
-
if (operator === "&&" || operator === "||")
|
|
1229
|
-
return numeric(truth(right) ? 1 : 0);
|
|
1230
|
-
if (operator === "concat") {
|
|
1231
|
-
const leftText = this.asText(left);
|
|
1232
|
-
const rightText = this.asText(right);
|
|
1233
|
-
this.budget.step(0);
|
|
1234
|
-
if (rightText.length > this.budget.maxBufferBytes - leftText.length)
|
|
1235
|
-
throw new ProgramError("text buffer limit exceeded");
|
|
1236
|
-
this.budget.step(leftText.length + rightText.length);
|
|
1237
|
-
return string(leftText + rightText);
|
|
1238
|
-
}
|
|
1239
|
-
if (operator === "==" || operator === "!=" || operator === "<" || operator === "<=" || operator === ">" || operator === ">=") {
|
|
1240
|
-
let order;
|
|
1241
|
-
if (left.kind !== "string" && right.kind !== "string") {
|
|
1242
|
-
const first = number(left);
|
|
1243
|
-
const second = number(right);
|
|
1244
|
-
order = first < second ? -1 : first > second ? 1 : 0;
|
|
1245
|
-
}
|
|
1246
|
-
else {
|
|
1247
|
-
order = compare(left, right, this.varText("CONVFMT"), this.budget);
|
|
1248
|
-
}
|
|
1249
|
-
return numeric((operator === "==" ? order === 0 : operator === "!=" ? order !== 0 : operator === "<" ? order < 0 : operator === "<=" ? order <= 0 : operator === ">" ? order > 0 : order >= 0) ? 1 : 0);
|
|
1250
|
-
}
|
|
1251
|
-
return numeric(this.arithmetic(operator, number(left), number(right)));
|
|
1252
|
-
}
|
|
1253
|
-
async evaluateBinaryWithLeftPromise(expression, leftPromise) {
|
|
1254
|
-
const operator = expression.operator;
|
|
1255
|
-
const left = await leftPromise;
|
|
1256
|
-
if (operator === "&&" && !truth(left))
|
|
1257
|
-
return numeric(0);
|
|
1258
|
-
if (operator === "||" && truth(left))
|
|
1259
|
-
return numeric(1);
|
|
1260
|
-
const right = await this.scalarExpression(expression.right);
|
|
1261
|
-
return this.evaluateBinarySyncOperands(operator, left, right);
|
|
1262
|
-
}
|
|
1263
|
-
async evaluateUnarySlow(expression) {
|
|
1264
|
-
if (expression.operator === "++" || expression.operator === "--") {
|
|
1265
|
-
const reference = await this.reference(expression.operand);
|
|
1266
|
-
const previous = number(scalar(reference.get()));
|
|
1267
|
-
const next = previous + (expression.operator === "++" ? 1 : -1);
|
|
1268
|
-
await reference.set(numeric(next));
|
|
1269
|
-
return numeric(expression.postfix ? previous : next);
|
|
1270
|
-
}
|
|
1271
|
-
const operand = await this.scalarExpression(expression.operand);
|
|
1272
|
-
return numeric(expression.operator === "!" ? truth(operand) ? 0 : 1 : expression.operator === "-" ? -number(operand) : number(operand));
|
|
1273
|
-
}
|
|
1274
|
-
async evaluateBinarySlow(expression) {
|
|
1275
|
-
const operator = expression.operator;
|
|
1276
|
-
if (["=", "+=", "-=", "*=", "/=", "%=", "^="].includes(operator)) {
|
|
1277
|
-
const reference = await this.reference(expression.left);
|
|
1278
|
-
const previous = operator === "=" ? unset : scalar(reference.get());
|
|
1279
|
-
let value = await this.scalarExpression(expression.right);
|
|
1280
|
-
if (operator !== "=")
|
|
1281
|
-
value = numeric(this.arithmetic(operator[0], number(previous), number(value)));
|
|
1282
|
-
await reference.set(value);
|
|
1283
|
-
return value;
|
|
1284
|
-
}
|
|
1285
|
-
if (operator === "in") {
|
|
1286
|
-
const array = this.array(expression.right.name);
|
|
1287
|
-
const key = expression.left.kind === "tuple" ? await this.key(expression.left.items) : this.asText(await this.scalarExpression(expression.left));
|
|
1288
|
-
return numeric(array.entries.has(key) ? 1 : 0);
|
|
1289
|
-
}
|
|
1290
|
-
const left = await this.scalarExpression(expression.left);
|
|
1291
|
-
if (operator === "~" || operator === "!~") {
|
|
1292
|
-
const matched = (await (await this.regex(expression.right)).find(this.asText(left), this.budget)) !== undefined;
|
|
1293
|
-
return numeric((operator === "~" ? matched : !matched) ? 1 : 0);
|
|
1294
|
-
}
|
|
1295
|
-
const right = await this.scalarExpression(expression.right);
|
|
1296
|
-
return this.evaluateBinarySyncOperands(operator, left, right);
|
|
1297
|
-
}
|
|
1298
|
-
async getline(expression) {
|
|
1299
|
-
if (!expression.file) {
|
|
1300
|
-
const record = await this.readMainRecord();
|
|
1301
|
-
if (record === undefined)
|
|
1302
|
-
return numeric(0);
|
|
1303
|
-
const target = expression.target ? await this.reference(expression.target) : undefined;
|
|
1304
|
-
if (target)
|
|
1305
|
-
await target.set(inputValue(record));
|
|
1306
|
-
else
|
|
1307
|
-
await this.setRecord(record);
|
|
1308
|
-
return numeric(1);
|
|
1309
|
-
}
|
|
1310
|
-
const target = expression.target ? await this.reference(expression.target) : undefined;
|
|
1311
|
-
const file = textDecoder.decode(latin1Bytes(this.asText(await this.scalarExpression(expression.file))));
|
|
1312
|
-
if (!file)
|
|
1313
|
-
throw new ProgramError("getline requires a nonempty filename");
|
|
1314
|
-
let path;
|
|
1315
|
-
try {
|
|
1316
|
-
path = virtualPath(this.context, file);
|
|
1317
|
-
}
|
|
1318
|
-
catch (error) {
|
|
1319
|
-
if (!(error instanceof FsError))
|
|
1320
|
-
throw error;
|
|
1321
|
-
this.set("ERRNO", string(byteString(error.message)));
|
|
1322
|
-
return numeric(-1);
|
|
1323
|
-
}
|
|
1324
|
-
const inputs = this.inputs ??= new Map();
|
|
1325
|
-
let reader = inputs.get(path);
|
|
1326
|
-
if (!reader) {
|
|
1327
|
-
if (inputs.size >= (this.budget.options.maxGetlineFiles ?? Infinity))
|
|
1328
|
-
throw new ProgramError("getline open-file limit exceeded");
|
|
1329
|
-
const { context, budget } = this;
|
|
1330
|
-
const name = this.retainName(path);
|
|
1331
|
-
const useStdin = file === "-" || file === "/dev/stdin";
|
|
1332
|
-
const source = (async function* () {
|
|
1333
|
-
if (useStdin)
|
|
1334
|
-
yield* context.stdin;
|
|
1335
|
-
else {
|
|
1336
|
-
budget.step();
|
|
1337
|
-
await budget.checkpointSync();
|
|
1338
|
-
const capabilities = await context.fs.capabilitiesFor?.(name, { signal: context.signal }) ?? context.fs.capabilities;
|
|
1339
|
-
context.signal.throwIfAborted();
|
|
1340
|
-
if (context.fs.readStream && capabilities.streamingRead !== false)
|
|
1341
|
-
yield* context.fs.readStream(name, { signal: context.signal });
|
|
1342
|
-
else
|
|
1343
|
-
yield await context.fs.readFile(name, { signal: context.signal, ...(Number.isFinite(budget.maxBufferBytes) ? { maxBytes: budget.maxBufferBytes } : {}) });
|
|
1344
|
-
}
|
|
1345
|
-
})();
|
|
1346
|
-
try {
|
|
1347
|
-
reader = new Reader(source, budget, this.retention);
|
|
1348
|
-
inputs.set(name, reader);
|
|
1349
|
-
}
|
|
1350
|
-
catch (error) {
|
|
1351
|
-
this.retention.release(shellValueByteLength(name));
|
|
1352
|
-
throw error;
|
|
1353
|
-
}
|
|
1354
|
-
}
|
|
1355
|
-
let record;
|
|
1356
|
-
try {
|
|
1357
|
-
record = await reader.read(this.varText("RS"));
|
|
1358
|
-
}
|
|
1359
|
-
catch (error) {
|
|
1360
|
-
this.context.signal.throwIfAborted();
|
|
1361
|
-
if (!(error instanceof FsError))
|
|
1362
|
-
throw error;
|
|
1363
|
-
inputs.delete(path);
|
|
1364
|
-
this.retention.release(shellValueByteLength(path));
|
|
1365
|
-
await reader.close();
|
|
1366
|
-
this.set("ERRNO", string(byteString(error.message)));
|
|
1367
|
-
return numeric(-1);
|
|
1368
|
-
}
|
|
1369
|
-
if (record === undefined)
|
|
1370
|
-
return numeric(0);
|
|
1371
|
-
if (target)
|
|
1372
|
-
await target.set(inputValue(record));
|
|
1373
|
-
else
|
|
1374
|
-
await this.setRecord(record);
|
|
1375
|
-
return numeric(1);
|
|
1376
|
-
}
|
|
1377
|
-
async call(name, args) {
|
|
1378
|
-
const definition = this.program.functions.get(name);
|
|
1379
|
-
if (definition) {
|
|
1380
|
-
if (this.frames.length >= (this.budget.options.maxRecursionDepth ?? Infinity))
|
|
1381
|
-
throw new ProgramError("function recursion limit exceeded");
|
|
1382
|
-
const frame = new Map();
|
|
1383
|
-
try {
|
|
1384
|
-
for (let index = 0; index < definition.parameters.length; index++) {
|
|
1385
|
-
const parameter = definition.parameters[index];
|
|
1386
|
-
const argument = args[index];
|
|
1387
|
-
if (definition.arrays.has(parameter)) {
|
|
1388
|
-
if (argument !== undefined && argument.kind !== "variable")
|
|
1389
|
-
throw new ProgramError("array parameter requires an array variable");
|
|
1390
|
-
this.bindArray(frame, parameter, argument ? this.array(argument.name) : new AwkArray());
|
|
1391
|
-
}
|
|
1392
|
-
else {
|
|
1393
|
-
const value = argument ? await this.evaluate(argument) : unset;
|
|
1394
|
-
if (value instanceof AwkArray)
|
|
1395
|
-
this.bindArray(frame, parameter, value);
|
|
1396
|
-
else
|
|
1397
|
-
this.storeScalar(frame, parameter, value);
|
|
1398
|
-
}
|
|
1399
|
-
}
|
|
1400
|
-
}
|
|
1401
|
-
catch (error) {
|
|
1402
|
-
this.releaseStore(frame);
|
|
1403
|
-
throw error;
|
|
1404
|
-
}
|
|
1405
|
-
this.frames.push(frame);
|
|
1406
|
-
try {
|
|
1407
|
-
await this.execute(definition.body);
|
|
1408
|
-
return unset;
|
|
1409
|
-
}
|
|
1410
|
-
catch (error) {
|
|
1411
|
-
if (error instanceof Flow && error.kind === "return")
|
|
1412
|
-
return error.value;
|
|
1413
|
-
throw error;
|
|
1414
|
-
}
|
|
1415
|
-
finally {
|
|
1416
|
-
this.frames.pop();
|
|
1417
|
-
this.releaseStore(frame);
|
|
1418
|
-
}
|
|
1419
|
-
}
|
|
1420
|
-
if (name === "length") {
|
|
1421
|
-
const value = args[0] ? await this.evaluate(args[0]) : string(this.record);
|
|
1422
|
-
return numeric(value instanceof AwkArray ? value.entries.size : this.asText(value).length);
|
|
1423
|
-
}
|
|
1424
|
-
if (name === "sub" || name === "gsub") {
|
|
1425
|
-
const pattern = await this.regex(args[0]);
|
|
1426
|
-
const replacement = this.asText(await this.scalarExpression(args[1]));
|
|
1427
|
-
const target = await this.reference(args[2] ?? { kind: "field", index: { kind: "number", value: 0 } });
|
|
1428
|
-
const result = await substitute(this.asText(scalar(target.get())), pattern, replacement, this.budget, name === "gsub", 1, "awk");
|
|
1429
|
-
if (result.count)
|
|
1430
|
-
await target.set(string(result.text));
|
|
1431
|
-
return numeric(result.count);
|
|
1432
|
-
}
|
|
1433
|
-
if (name === "split") {
|
|
1434
|
-
const value = this.asText(await this.scalarExpression(args[0]));
|
|
1435
|
-
const target = this.array(args[1].name);
|
|
1436
|
-
const separator = args[2]?.kind === "regex" ? args[2].pattern : args[2] ? this.asText(await this.scalarExpression(args[2])) : this.varText("FS");
|
|
1437
|
-
const parts = await this.split(value, separator);
|
|
1438
|
-
if (this.entries - target.entries.size + parts.length > (this.budget.options.maxArrayEntries ?? Infinity))
|
|
1439
|
-
throw new ProgramError("array entry limit exceeded");
|
|
1440
|
-
let size = 0;
|
|
1441
|
-
for (let index = 0; index < parts.length; index++) {
|
|
1442
|
-
const part = parts[index];
|
|
1443
|
-
if (part.kind === "string" || part.kind === "numeric")
|
|
1444
|
-
this.budget.check(part.text);
|
|
1445
|
-
const key = String(index + 1);
|
|
1446
|
-
this.budget.check(key);
|
|
1447
|
-
size += key.length + textSize(part);
|
|
1448
|
-
}
|
|
1449
|
-
const allocation = this.arrays.get(target);
|
|
1450
|
-
const entries = this.retention.replace(allocation.bytes, size, () => parts.map((part, index) => [String(index + 1), ownScalar(part)]));
|
|
1451
|
-
this.entries += entries.length - target.entries.size;
|
|
1452
|
-
target.entries.clear();
|
|
1453
|
-
for (const [key, part] of entries)
|
|
1454
|
-
target.entries.set(key, part);
|
|
1455
|
-
allocation.bytes = size;
|
|
1456
|
-
return numeric(parts.length);
|
|
1457
|
-
}
|
|
1458
|
-
if (name === "match") {
|
|
1459
|
-
const value = this.asText(await this.scalarExpression(args[0]));
|
|
1460
|
-
const matched = await (await this.regex(args[1])).find(value, this.budget);
|
|
1461
|
-
this.set("RSTART", numeric(matched ? matched.start + 1 : 0));
|
|
1462
|
-
this.set("RLENGTH", numeric(matched ? matched.end - matched.start : -1));
|
|
1463
|
-
return this.get("RSTART");
|
|
1464
|
-
}
|
|
1465
|
-
const values = [];
|
|
1466
|
-
for (const argument of args)
|
|
1467
|
-
values.push(await this.scalarExpression(argument));
|
|
1468
|
-
const first = values[0] ?? unset;
|
|
1469
|
-
if (name === "srand") {
|
|
1470
|
-
const previous = this.randomSeed;
|
|
1471
|
-
this.randomSeed = values.length ? Math.trunc(number(first)) : Math.floor(Date.now() / 1000);
|
|
1472
|
-
this.randomState = this.randomSeed >>> 0;
|
|
1473
|
-
return numeric(previous);
|
|
1474
|
-
}
|
|
1475
|
-
if (name === "rand") {
|
|
1476
|
-
// A full-period 32-bit generator; keep state local to this invocation.
|
|
1477
|
-
this.randomState = (Math.imul(this.randomState, 1664525) + 1013904223) >>> 0;
|
|
1478
|
-
return numeric(this.randomState / 0x100000000);
|
|
1479
|
-
}
|
|
1480
|
-
if (this.ordchr && name === "ord")
|
|
1481
|
-
return numeric(this.asText(first).charCodeAt(0) || 0);
|
|
1482
|
-
if (this.ordchr && name === "chr") {
|
|
1483
|
-
const value = number(first);
|
|
1484
|
-
if (!Number.isFinite(value))
|
|
1485
|
-
throw new ProgramError("invalid numeric argument in 'chr'");
|
|
1486
|
-
return string(String.fromCharCode(Math.trunc(value) & 255));
|
|
1487
|
-
}
|
|
1488
|
-
if (name === "sprintf")
|
|
1489
|
-
return string(this.budget.check(formatted(this.asText(first), values.slice(1), value => this.asText(value), this.budget)));
|
|
1490
|
-
if (name === "substr") {
|
|
1491
|
-
const start = Math.max(0, Math.trunc(number(values[1])) - 1);
|
|
1492
|
-
const length = values[2] === undefined ? undefined : Math.max(0, Math.trunc(number(values[2])));
|
|
1493
|
-
return string(this.asText(first).slice(start, length === undefined ? undefined : start + length));
|
|
1494
|
-
}
|
|
1495
|
-
if (name === "index")
|
|
1496
|
-
return numeric(this.asText(first).indexOf(this.asText(values[1])) + 1);
|
|
1497
|
-
if (name === "tolower")
|
|
1498
|
-
return string(this.asText(first).replace(/[A-Z]/gu, character => character.toLowerCase()));
|
|
1499
|
-
if (name === "toupper")
|
|
1500
|
-
return string(this.asText(first).replace(/[a-z]/gu, character => character.toUpperCase()));
|
|
1501
|
-
if (name === "close") {
|
|
1502
|
-
const path = virtualPath(this.context, textDecoder.decode(latin1Bytes(this.asText(first))));
|
|
1503
|
-
const reader = this.inputs?.get(path);
|
|
1504
|
-
this.inputs?.delete(path);
|
|
1505
|
-
if (reader)
|
|
1506
|
-
this.retention.release(shellValueByteLength(path));
|
|
1507
|
-
await reader?.close();
|
|
1508
|
-
const output = this.outputs?.delete(path) ?? false;
|
|
1509
|
-
if (output)
|
|
1510
|
-
this.retention.release(shellValueByteLength(path));
|
|
1511
|
-
return numeric(output || reader !== undefined ? 0 : -1);
|
|
1512
|
-
}
|
|
1513
|
-
const amount = number(first);
|
|
1514
|
-
const result = name === "int" ? Math.trunc(amount) : name === "sqrt" ? Math.sqrt(amount) : name === "exp" ? Math.exp(amount) : name === "log" ? Math.log(amount) : name === "sin" ? Math.sin(amount) : name === "cos" ? Math.cos(amount) : name === "atan2" ? Math.atan2(amount, number(values[1])) : NaN;
|
|
1515
|
-
if (!Number.isFinite(result))
|
|
1516
|
-
throw new ProgramError(`invalid mathematical result in '${name}'`);
|
|
1517
|
-
return numeric(result);
|
|
1518
|
-
}
|
|
1519
|
-
recordChecks = 0;
|
|
1520
|
-
stdoutBuffer = "";
|
|
1521
|
-
flushStdout() {
|
|
1522
|
-
if (this.stdoutBuffer.length === 0)
|
|
1523
|
-
return undefined;
|
|
1524
|
-
const chunk = this.stdoutBuffer;
|
|
1525
|
-
this.stdoutBuffer = "";
|
|
1526
|
-
const p = write(this.context, chunk);
|
|
1527
|
-
return isSyncResolved(p) ? undefined : p;
|
|
1528
|
-
}
|
|
1529
|
-
executeSync(statement) {
|
|
1530
|
-
if (!this.inspection) {
|
|
1531
|
-
const count = ++this.recordChecks;
|
|
1532
|
-
const p = (count <= 2 || (count & 31) === 0)
|
|
1533
|
-
? this.budget.checkpointSync()
|
|
1534
|
-
: undefined;
|
|
1535
|
-
if (!p) {
|
|
1536
|
-
return this.executeSyncBody(statement);
|
|
1537
|
-
}
|
|
1538
|
-
else
|
|
1539
|
-
return this.executeAfterCheckpoint(p, statement);
|
|
1540
|
-
}
|
|
1541
|
-
return this.execute(statement);
|
|
1542
|
-
}
|
|
1543
|
-
tryFastExpressionStatement(expr) {
|
|
1544
|
-
if (this.frames.length !== 0)
|
|
1545
|
-
return false;
|
|
1546
|
-
if (expr.kind === "unary" && (expr.operator === "++" || expr.operator === "--") && expr.operand.kind === "variable") {
|
|
1547
|
-
const name = expr.operand.name;
|
|
1548
|
-
if (name !== "NF" && name !== "NR" && name !== "FNR" && name !== "FS" && name !== "RS" && name !== "CONVFMT") {
|
|
1549
|
-
this.budget.step();
|
|
1550
|
-
const existing = this.variables.get(name);
|
|
1551
|
-
if (existing === undefined || !(existing instanceof AwkArray)) {
|
|
1552
|
-
const prevNum = existing !== undefined ? (existing.kind === "number" ? existing.number : number(existing)) : 0;
|
|
1553
|
-
const rawNext = prevNum + (expr.operator === "++" ? 1 : -1);
|
|
1554
|
-
const next = (rawNext | 0) === rawNext && (rawNext !== 0 || 1 / rawNext > 0) ? (rawNext | 0) : rawNext;
|
|
1555
|
-
this.retention.admit(textSize(existing), 0);
|
|
1556
|
-
const box = numeric(next);
|
|
1557
|
-
this.variables.set(name, box);
|
|
1558
|
-
return true;
|
|
1559
|
-
}
|
|
1560
|
-
}
|
|
1561
|
-
return false;
|
|
1562
|
-
}
|
|
1563
|
-
if (expr.kind === "binary" &&
|
|
1564
|
-
(expr.operator === "+=" || expr.operator === "-=" || expr.operator === "*=" || expr.operator === "/=") &&
|
|
1565
|
-
expr.left.kind === "variable") {
|
|
1566
|
-
const name = expr.left.name;
|
|
1567
|
-
if (name !== "NF" && name !== "NR" && name !== "FNR" && name !== "FS" && name !== "RS" && name !== "CONVFMT") {
|
|
1568
|
-
const right = expr.right;
|
|
1569
|
-
let rightNum;
|
|
1570
|
-
if (right.kind === "field" && right.index.kind === "number") {
|
|
1571
|
-
this.budget.step(3);
|
|
1572
|
-
const idx = Math.trunc(right.index.value);
|
|
1573
|
-
if (idx > 0 && idx <= (this.budget.options.maxFields ?? Infinity)) {
|
|
1574
|
-
rightNum = this.getFieldNumber(idx);
|
|
1575
|
-
}
|
|
1576
|
-
}
|
|
1577
|
-
else if (right.kind === "number") {
|
|
1578
|
-
this.budget.step(2);
|
|
1579
|
-
rightNum = right.value;
|
|
1580
|
-
}
|
|
1581
|
-
if (rightNum !== undefined) {
|
|
1582
|
-
const existing = this.variables.get(name);
|
|
1583
|
-
if (existing === undefined || !(existing instanceof AwkArray)) {
|
|
1584
|
-
const prevNum = existing !== undefined ? (existing.kind === "number" ? existing.number : number(existing)) : 0;
|
|
1585
|
-
const rawNext = expr.operator === "+=" && Number.isFinite(prevNum) && Number.isFinite(rightNum)
|
|
1586
|
-
? prevNum + rightNum
|
|
1587
|
-
: this.arithmetic(expr.operator[0], prevNum, rightNum);
|
|
1588
|
-
const next = (rawNext | 0) === rawNext && (rawNext !== 0 || 1 / rawNext > 0) ? (rawNext | 0) : rawNext;
|
|
1589
|
-
this.retention.admit(textSize(existing), 0);
|
|
1590
|
-
const box = numeric(next);
|
|
1591
|
-
this.variables.set(name, box);
|
|
1592
|
-
return true;
|
|
1593
|
-
}
|
|
1594
|
-
}
|
|
1595
|
-
}
|
|
1596
|
-
}
|
|
1597
|
-
return false;
|
|
1598
|
-
}
|
|
1599
|
-
executeSyncBody(statement) {
|
|
1600
|
-
if (statement.kind === "expression") {
|
|
1601
|
-
this.budget.step();
|
|
1602
|
-
if (!this.inspection && this.tryFastExpressionStatement(statement.expression))
|
|
1603
|
-
return undefined;
|
|
1604
|
-
const val = this.evaluate(statement.expression);
|
|
1605
|
-
return val instanceof Promise ? this.ignorePromiseValue(val) : undefined;
|
|
1606
|
-
}
|
|
1607
|
-
if (statement.kind === "block") {
|
|
1608
|
-
this.budget.step();
|
|
1609
|
-
for (let i = 0; i < statement.body.length; i++) {
|
|
1610
|
-
const child = statement.body[i];
|
|
1611
|
-
let res;
|
|
1612
|
-
if (child.kind === "expression" && !this.inspection) {
|
|
1613
|
-
this.budget.step();
|
|
1614
|
-
if (this.tryFastExpressionStatement(child.expression))
|
|
1615
|
-
continue;
|
|
1616
|
-
const val = this.evaluate(child.expression);
|
|
1617
|
-
res = val instanceof Promise ? this.ignorePromiseValue(val) : undefined;
|
|
1618
|
-
}
|
|
1619
|
-
else {
|
|
1620
|
-
res = this.executeSync(child);
|
|
1621
|
-
}
|
|
1622
|
-
if (res instanceof Promise) {
|
|
1623
|
-
return this.executeBlockRemainder(statement.body, i + 1, res);
|
|
1624
|
-
}
|
|
1625
|
-
}
|
|
1626
|
-
return undefined;
|
|
1627
|
-
}
|
|
1628
|
-
if (statement.kind === "if") {
|
|
1629
|
-
this.budget.step();
|
|
1630
|
-
const cond = this.scalarExpression(statement.condition);
|
|
1631
|
-
if (!(cond instanceof Promise)) {
|
|
1632
|
-
const branch = truth(cond) ? statement.yes : statement.no;
|
|
1633
|
-
return branch ? this.executeSync(branch) : undefined;
|
|
1634
|
-
}
|
|
1635
|
-
return this.executeIfAsync(statement, cond);
|
|
1636
|
-
}
|
|
1637
|
-
if (statement.kind === "print" && !statement.redirect && !statement.formatted) {
|
|
1638
|
-
this.budget.step();
|
|
1639
|
-
const args = statement.args;
|
|
1640
|
-
const ofs = args.length ? this.varText("OFS") : "";
|
|
1641
|
-
const ors = this.varText("ORS");
|
|
1642
|
-
if (args.length === 0) {
|
|
1643
|
-
const output = this.budget.check(this.record + ors);
|
|
1644
|
-
this.stdoutBuffer += output;
|
|
1645
|
-
if (this.stdoutBuffer.length >= 16384)
|
|
1646
|
-
return this.flushStdout();
|
|
1647
|
-
return undefined;
|
|
1648
|
-
}
|
|
1649
|
-
const ofmt = this.varText("OFMT");
|
|
1650
|
-
let acc = "";
|
|
1651
|
-
for (let i = 0; i < args.length; i++) {
|
|
1652
|
-
const v = this.scalarExpression(args[i]);
|
|
1653
|
-
if (v instanceof Promise)
|
|
1654
|
-
return this.executePrintRemainder(args, i, v, acc, ofs, ors, ofmt);
|
|
1655
|
-
const t = text(v, ofmt, this.budget);
|
|
1656
|
-
acc = i === 0 ? t : acc + ofs + t;
|
|
1657
|
-
}
|
|
1658
|
-
const output = this.budget.check(acc + ors);
|
|
1659
|
-
this.stdoutBuffer += output;
|
|
1660
|
-
if (this.stdoutBuffer.length >= 16384)
|
|
1661
|
-
return this.flushStdout();
|
|
1662
|
-
return undefined;
|
|
1663
|
-
}
|
|
1664
|
-
return this.execute(statement);
|
|
1665
|
-
}
|
|
1666
|
-
async executePrintRemainder(args, index, pending, acc, ofs, ors, ofmt) {
|
|
1667
|
-
const first = text(await pending, ofmt, this.budget);
|
|
1668
|
-
acc = index === 0 ? first : acc + ofs + first;
|
|
1669
|
-
for (let i = index + 1; i < args.length; i++) {
|
|
1670
|
-
acc += ofs + text(await this.scalarExpression(args[i]), ofmt, this.budget);
|
|
1671
|
-
}
|
|
1672
|
-
this.stdoutBuffer += this.budget.check(acc + ors);
|
|
1673
|
-
if (this.stdoutBuffer.length >= 16384)
|
|
1674
|
-
await this.flushStdout();
|
|
1675
|
-
}
|
|
1676
|
-
async ignorePromiseValue(promise) {
|
|
1677
|
-
await promise;
|
|
1678
|
-
}
|
|
1679
|
-
async executeIfAsync(statement, condPromise) {
|
|
1680
|
-
const resolved = await condPromise;
|
|
1681
|
-
const branch = truth(resolved) ? statement.yes : statement.no;
|
|
1682
|
-
if (branch) {
|
|
1683
|
-
const res = this.executeSync(branch);
|
|
1684
|
-
if (res instanceof Promise)
|
|
1685
|
-
await res;
|
|
1686
|
-
}
|
|
1687
|
-
}
|
|
1688
|
-
async executeAfterCheckpoint(checkpoint, statement) {
|
|
1689
|
-
await checkpoint;
|
|
1690
|
-
const res = this.executeSyncBody(statement);
|
|
1691
|
-
if (res instanceof Promise)
|
|
1692
|
-
await res;
|
|
1693
|
-
}
|
|
1694
|
-
async executeBlockRemainder(body, startIndex, current) {
|
|
1695
|
-
await current;
|
|
1696
|
-
for (let i = startIndex; i < body.length; i++) {
|
|
1697
|
-
const res = this.executeSync(body[i]);
|
|
1698
|
-
if (res instanceof Promise)
|
|
1699
|
-
await res;
|
|
1700
|
-
}
|
|
1701
|
-
}
|
|
1702
|
-
async execute(statement) {
|
|
1703
|
-
this.budget.step();
|
|
1704
|
-
if (this.inspection)
|
|
1705
|
-
await this.inspection.observe(statement, this.phase);
|
|
1706
|
-
const p = this.budget.checkpointSync();
|
|
1707
|
-
if (p)
|
|
1708
|
-
await p;
|
|
1709
|
-
switch (statement.kind) {
|
|
1710
|
-
case "block":
|
|
1711
|
-
for (const child of statement.body)
|
|
1712
|
-
await this.execute(child);
|
|
1713
|
-
return;
|
|
1714
|
-
case "expression":
|
|
1715
|
-
await this.evaluate(statement.expression);
|
|
1716
|
-
return;
|
|
1717
|
-
case "print": {
|
|
1718
|
-
const values = [];
|
|
1719
|
-
for (const argument of statement.args)
|
|
1720
|
-
values.push(await this.scalarExpression(argument));
|
|
1721
|
-
const output = statement.formatted
|
|
1722
|
-
? this.budget.check(formatted(this.asText(values[0]), values.slice(1), value => this.asText(value), this.budget))
|
|
1723
|
-
: this.join(values.length ? values.map(value => text(value, this.varText("OFMT"), this.budget)) : [this.record], values.length ? this.varText("OFS") : "", this.varText("ORS"));
|
|
1724
|
-
if (!statement.redirect) {
|
|
1725
|
-
this.stdoutBuffer += output;
|
|
1726
|
-
if (this.stdoutBuffer.length >= 16384)
|
|
1727
|
-
await this.flushStdout();
|
|
1728
|
-
return;
|
|
1729
|
-
}
|
|
1730
|
-
const destination = textDecoder.decode(latin1Bytes(this.asText(await this.scalarExpression(statement.redirect.destination))));
|
|
1731
|
-
if (destination === "/dev/stdout") {
|
|
1732
|
-
this.stdoutBuffer += output;
|
|
1733
|
-
if (this.stdoutBuffer.length >= 16384)
|
|
1734
|
-
await this.flushStdout();
|
|
1735
|
-
return;
|
|
1736
|
-
}
|
|
1737
|
-
if (this.stdoutBuffer.length > 0)
|
|
1738
|
-
await this.flushStdout();
|
|
1739
|
-
if (destination === "/dev/stderr") {
|
|
1740
|
-
this.context.signal.throwIfAborted();
|
|
1741
|
-
await writeBytes(this.context.stderr, bytes(output), this.context.signal);
|
|
1742
|
-
return;
|
|
1743
|
-
}
|
|
1744
|
-
const path = virtualPath(this.context, destination);
|
|
1745
|
-
const outputs = this.outputs ??= new Set();
|
|
1746
|
-
if (outputs.has(path))
|
|
1747
|
-
await writeFileOutput(this.context, bytes(output), chunk => this.context.fs.appendFile(path, chunk, { signal: this.context.signal }));
|
|
1748
|
-
else {
|
|
1749
|
-
const name = this.retainName(path);
|
|
1750
|
-
try {
|
|
1751
|
-
const flag = statement.redirect.append ? "a" : "w";
|
|
1752
|
-
await writeFileOutput(this.context, bytes(output), chunk => this.context.fs.writeFile(name, chunk, { flag, signal: this.context.signal }));
|
|
1753
|
-
this.context.signal.throwIfAborted();
|
|
1754
|
-
outputs.add(name);
|
|
1755
|
-
}
|
|
1756
|
-
catch (error) {
|
|
1757
|
-
this.retention.release(shellValueByteLength(name));
|
|
1758
|
-
throw error;
|
|
1759
|
-
}
|
|
1760
|
-
}
|
|
1761
|
-
return;
|
|
1762
|
-
}
|
|
1763
|
-
case "if": {
|
|
1764
|
-
const branch = truth(await this.scalarExpression(statement.condition)) ? statement.yes : statement.no;
|
|
1765
|
-
if (branch)
|
|
1766
|
-
await this.execute(branch);
|
|
1767
|
-
return;
|
|
1768
|
-
}
|
|
1769
|
-
case "flow": {
|
|
1770
|
-
if ((statement.flow === "next" || statement.flow === "nextfile") && this.phase !== "record")
|
|
1771
|
-
throw new ProgramError(`${statement.flow} is only valid while processing records`);
|
|
1772
|
-
throw new Flow(statement.flow, statement.value ? await this.scalarExpression(statement.value) : unset);
|
|
1773
|
-
}
|
|
1774
|
-
case "delete": {
|
|
1775
|
-
const array = this.array(statement.target.name);
|
|
1776
|
-
const allocation = this.arrays.get(array);
|
|
1777
|
-
if (statement.target.kind === "variable") {
|
|
1778
|
-
this.retention.release(allocation.bytes);
|
|
1779
|
-
allocation.bytes = 0;
|
|
1780
|
-
this.entries -= array.entries.size;
|
|
1781
|
-
array.entries.clear();
|
|
1782
|
-
}
|
|
1783
|
-
else {
|
|
1784
|
-
const key = await this.key(statement.target.indexes);
|
|
1785
|
-
const value = array.entries.get(key);
|
|
1786
|
-
if (array.entries.delete(key)) {
|
|
1787
|
-
const size = key.length + textSize(value);
|
|
1788
|
-
this.retention.release(size);
|
|
1789
|
-
allocation.bytes -= size;
|
|
1790
|
-
this.entries--;
|
|
1791
|
-
}
|
|
1792
|
-
}
|
|
1793
|
-
return;
|
|
1794
|
-
}
|
|
1795
|
-
case "foreach": {
|
|
1796
|
-
const array = this.array(statement.array);
|
|
1797
|
-
for (const key of [...array.entries.keys()]) {
|
|
1798
|
-
this.budget.step();
|
|
1799
|
-
if (!array.entries.has(key))
|
|
1800
|
-
continue;
|
|
1801
|
-
this.set(statement.variable, string(key));
|
|
1802
|
-
try {
|
|
1803
|
-
const res = this.executeSync(statement.body);
|
|
1804
|
-
if (res instanceof Promise)
|
|
1805
|
-
await res;
|
|
1806
|
-
}
|
|
1807
|
-
catch (error) {
|
|
1808
|
-
if (error instanceof Flow && error.kind === "break")
|
|
1809
|
-
break;
|
|
1810
|
-
if (!(error instanceof Flow && error.kind === "continue"))
|
|
1811
|
-
throw error;
|
|
1812
|
-
}
|
|
1813
|
-
}
|
|
1814
|
-
return;
|
|
1815
|
-
}
|
|
1816
|
-
case "while":
|
|
1817
|
-
case "do":
|
|
1818
|
-
case "for": {
|
|
1819
|
-
if (statement.kind === "for" && statement.initial) {
|
|
1820
|
-
const initial = this.evaluate(statement.initial);
|
|
1821
|
-
if (initial instanceof Promise)
|
|
1822
|
-
await initial;
|
|
1823
|
-
}
|
|
1824
|
-
let first = true;
|
|
1825
|
-
while (true) {
|
|
1826
|
-
this.budget.step();
|
|
1827
|
-
if (!(statement.kind === "do" && first) && statement.condition) {
|
|
1828
|
-
const condition = this.scalarExpression(statement.condition);
|
|
1829
|
-
if (!truth(condition instanceof Promise ? await condition : condition))
|
|
1830
|
-
break;
|
|
1831
|
-
}
|
|
1832
|
-
first = false;
|
|
1833
|
-
try {
|
|
1834
|
-
const body = this.executeSync(statement.body);
|
|
1835
|
-
if (body instanceof Promise)
|
|
1836
|
-
await body;
|
|
1837
|
-
}
|
|
1838
|
-
catch (error) {
|
|
1839
|
-
if (error instanceof Flow && error.kind === "break")
|
|
1840
|
-
break;
|
|
1841
|
-
if (!(error instanceof Flow && error.kind === "continue"))
|
|
1842
|
-
throw error;
|
|
1843
|
-
}
|
|
1844
|
-
if (statement.kind === "for" && statement.update) {
|
|
1845
|
-
const update = this.evaluate(statement.update);
|
|
1846
|
-
if (update instanceof Promise)
|
|
1847
|
-
await update;
|
|
1848
|
-
}
|
|
1849
|
-
}
|
|
1850
|
-
return;
|
|
1851
|
-
}
|
|
1852
|
-
}
|
|
1853
|
-
}
|
|
1854
|
-
assignment(assignment) {
|
|
1855
|
-
const match = /^([A-Za-z_][A-Za-z0-9_]*)=([\s\S]*)$/u.exec(assignment);
|
|
1856
|
-
if (!match)
|
|
1857
|
-
throw new ProgramError(`invalid assignment '${assignment}'`);
|
|
1858
|
-
this.set(match[1], inputValue(decodeString(match[2])));
|
|
1859
|
-
}
|
|
1860
|
-
exit(flow) {
|
|
1861
|
-
if (flow.value.kind !== "unset") {
|
|
1862
|
-
const status = Math.trunc(number(flow.value));
|
|
1863
|
-
if (!Number.isFinite(status))
|
|
1864
|
-
throw new ProgramError("invalid exit status");
|
|
1865
|
-
this.status = (status % 256 + 256) % 256;
|
|
1866
|
-
}
|
|
1867
|
-
}
|
|
1868
|
-
finishSyncCleanup(status) {
|
|
1869
|
-
this.releaseStore(this.variables);
|
|
1870
|
-
this.retention.release(this.recordLength + this.fieldBytes);
|
|
1871
|
-
this.record = "";
|
|
1872
|
-
if (this.rawFields.length > 0)
|
|
1873
|
-
this.rawFields.length = 0;
|
|
1874
|
-
this.fieldCount = 0;
|
|
1875
|
-
this.fieldsMaterialized = true;
|
|
1876
|
-
this.fieldBytes = 0;
|
|
1877
|
-
this.sliceBox.source = "";
|
|
1878
|
-
this.recordValue = unset;
|
|
1879
|
-
this.context.signal.throwIfAborted();
|
|
1880
|
-
this.context = RELEASED_AWK_CONTEXT;
|
|
1881
|
-
this.budget.context = RELEASED_AWK_CONTEXT;
|
|
1882
|
-
this.budget.signal = RELEASED_AWK_SIGNAL;
|
|
1883
|
-
this.retention.signal = RELEASED_AWK_SIGNAL;
|
|
1884
|
-
return status;
|
|
1885
|
-
}
|
|
1886
|
-
runSyncOrAsync() {
|
|
1887
|
-
if (!this.inspection && this.program.begin.length === 0) {
|
|
1888
|
-
try {
|
|
1889
|
-
const progRes = this.tryRunProgramSync();
|
|
1890
|
-
if (typeof progRes === "number") {
|
|
1891
|
-
if (!this.inputs || this.inputs.size === 0) {
|
|
1892
|
-
if (!this.outputs || this.outputs.size === 0) {
|
|
1893
|
-
if (this.mainReader) {
|
|
1894
|
-
const pendingClose = this.mainReader.closeSyncOrAsync();
|
|
1895
|
-
this.mainReader = undefined;
|
|
1896
|
-
if (pendingClose) {
|
|
1897
|
-
return this.finishRunAfterSyncProgram(progRes, pendingClose);
|
|
1898
|
-
}
|
|
1899
|
-
}
|
|
1900
|
-
if (this.stdoutBuffer.length > 0) {
|
|
1901
|
-
const flushPending = this.flushStdout();
|
|
1902
|
-
if (flushPending) {
|
|
1903
|
-
return this.finishRunAfterFlush(progRes, flushPending);
|
|
1904
|
-
}
|
|
1905
|
-
}
|
|
1906
|
-
if (this.inspection)
|
|
1907
|
-
this.syncSpecialVars();
|
|
1908
|
-
else {
|
|
1909
|
-
this.nrDirty = false;
|
|
1910
|
-
this.fnrDirty = false;
|
|
1911
|
-
this.nfDirty = false;
|
|
1912
|
-
}
|
|
1913
|
-
return this.finishSyncCleanup(progRes);
|
|
1914
|
-
}
|
|
1915
|
-
}
|
|
1916
|
-
return this.finishRunAfterSyncProgram(progRes, undefined);
|
|
1917
|
-
}
|
|
1918
|
-
return this.finishRunFromPromise(progRes);
|
|
1919
|
-
}
|
|
1920
|
-
catch (error) {
|
|
1921
|
-
return this.finishRunFromPromise(Promise.reject(error));
|
|
1922
|
-
}
|
|
1923
|
-
}
|
|
1924
|
-
return this.run();
|
|
1925
|
-
}
|
|
1926
|
-
async finishRunAfterFlush(status, flushPending) {
|
|
1927
|
-
let failed = false;
|
|
1928
|
-
let failure;
|
|
1929
|
-
try {
|
|
1930
|
-
await flushPending;
|
|
1931
|
-
this.syncSpecialVars();
|
|
1932
|
-
}
|
|
1933
|
-
catch (error) {
|
|
1934
|
-
failed = true;
|
|
1935
|
-
failure = error;
|
|
1936
|
-
}
|
|
1937
|
-
const res = this.finishSyncCleanup(status);
|
|
1938
|
-
if (failed)
|
|
1939
|
-
throw failure;
|
|
1940
|
-
return res;
|
|
1941
|
-
}
|
|
1942
|
-
async finishRunAfterSyncProgram(status, pendingClose) {
|
|
1943
|
-
return this.finishRunFromPromise(pendingClose ? pendingClose.then(() => status) : Promise.resolve(status));
|
|
1944
|
-
}
|
|
1945
|
-
async finishRunFromPromise(programPromise) {
|
|
1946
|
-
let status = 0, failed = false;
|
|
1947
|
-
let failure;
|
|
1948
|
-
try {
|
|
1949
|
-
status = await programPromise;
|
|
1950
|
-
if (this.stdoutBuffer.length > 0)
|
|
1951
|
-
await this.flushStdout();
|
|
1952
|
-
this.syncSpecialVars();
|
|
1953
|
-
await this.inspection?.publish(this.variables);
|
|
1954
|
-
}
|
|
1955
|
-
catch (error) {
|
|
1956
|
-
failed = true;
|
|
1957
|
-
failure = error;
|
|
1958
|
-
}
|
|
1959
|
-
if (this.stdoutBuffer.length > 0) {
|
|
1960
|
-
try {
|
|
1961
|
-
await this.flushStdout();
|
|
1962
|
-
}
|
|
1963
|
-
catch (error) {
|
|
1964
|
-
if (!failed) {
|
|
1965
|
-
failed = true;
|
|
1966
|
-
failure = error;
|
|
1967
|
-
}
|
|
1968
|
-
}
|
|
1969
|
-
}
|
|
1970
|
-
let cleanup;
|
|
1971
|
-
if (this.mainReader && (!this.inputs || this.inputs.size === 0)) {
|
|
1972
|
-
const pendingClose = this.mainReader.closeSyncOrAsync();
|
|
1973
|
-
this.mainReader = undefined;
|
|
1974
|
-
if (pendingClose) {
|
|
1975
|
-
try {
|
|
1976
|
-
await pendingClose;
|
|
1977
|
-
}
|
|
1978
|
-
catch (error) {
|
|
1979
|
-
if (!failed) {
|
|
1980
|
-
failed = true;
|
|
1981
|
-
failure = error;
|
|
1982
|
-
}
|
|
1983
|
-
}
|
|
1984
|
-
}
|
|
1985
|
-
}
|
|
1986
|
-
else if (this.mainReader || (this.inputs && this.inputs.size > 0)) {
|
|
1987
|
-
const readers = [...this.mainReader ? [this.mainReader] : [], ...this.inputs ? this.inputs.values() : []];
|
|
1988
|
-
this.mainReader = undefined;
|
|
1989
|
-
if (this.inputs) {
|
|
1990
|
-
for (const name of this.inputs.keys())
|
|
1991
|
-
this.retention.release(shellValueByteLength(name));
|
|
1992
|
-
this.inputs.clear();
|
|
1993
|
-
}
|
|
1994
|
-
cleanup = await Promise.allSettled(readers.map(async (reader) => { await reader.close(); }));
|
|
1995
|
-
}
|
|
1996
|
-
if (this.outputs && this.outputs.size > 0) {
|
|
1997
|
-
for (const name of this.outputs)
|
|
1998
|
-
this.retention.release(shellValueByteLength(name));
|
|
1999
|
-
this.outputs.clear();
|
|
2000
|
-
}
|
|
2001
|
-
const res = this.finishSyncCleanup(status);
|
|
2002
|
-
if (failed)
|
|
2003
|
-
throw failure;
|
|
2004
|
-
if (cleanup)
|
|
2005
|
-
for (const result of cleanup)
|
|
2006
|
-
if (result.status === "rejected")
|
|
2007
|
-
throw result.reason;
|
|
2008
|
-
return res;
|
|
2009
|
-
}
|
|
2010
|
-
async run() {
|
|
2011
|
-
return this.finishRunFromPromise(this.runProgram());
|
|
2012
|
-
}
|
|
2013
|
-
tryRunProgramSync() {
|
|
2014
|
-
this.phase = "record";
|
|
2015
|
-
let ranges;
|
|
2016
|
-
if (this.program.rules.length || this.program.end.length) {
|
|
2017
|
-
if (!this.mainReader) {
|
|
2018
|
-
this.tryOpenNextMainReaderSync();
|
|
2019
|
-
}
|
|
2020
|
-
while (true) {
|
|
2021
|
-
this.budget.step();
|
|
2022
|
-
if (this.mainReader && this.mainReader.readSliceSync(this.varText("RS"), this.sliceBox)) {
|
|
2023
|
-
this.incrementCounter("NR");
|
|
2024
|
-
this.incrementCounter("FNR");
|
|
2025
|
-
const setRecPromise = this.setRecordSliceSync(this.sliceBox.source, this.sliceBox.start, this.sliceBox.end);
|
|
2026
|
-
if (setRecPromise instanceof Promise) {
|
|
2027
|
-
return this.continueProgramAsyncAfterRecord(setRecPromise, ranges, 0);
|
|
2028
|
-
}
|
|
2029
|
-
}
|
|
2030
|
-
else if (this.mainReader && this.mainReader.isEnded && this.argument >= number(this.getScalar("ARGC"))) {
|
|
2031
|
-
const closePending = this.mainReader.closeSyncOrAsync();
|
|
2032
|
-
this.mainReader = undefined;
|
|
2033
|
-
if (closePending) {
|
|
2034
|
-
return closePending.then(() => this.runEndPhaseSyncOrAsync(0));
|
|
2035
|
-
}
|
|
2036
|
-
break;
|
|
2037
|
-
}
|
|
2038
|
-
else {
|
|
2039
|
-
return this.continueProgramSlowAsync(ranges);
|
|
2040
|
-
}
|
|
2041
|
-
try {
|
|
2042
|
-
for (let index = 0; index < this.program.rules.length; index++) {
|
|
2043
|
-
const rule = this.program.rules[index];
|
|
2044
|
-
let selected = !rule.pattern || (ranges !== undefined && ranges.has(index));
|
|
2045
|
-
if (!selected) {
|
|
2046
|
-
const patVal = this.scalarExpression(rule.pattern);
|
|
2047
|
-
if (patVal instanceof Promise) {
|
|
2048
|
-
return this.continueProgramAsyncAtRule(patVal, ranges, index, "pattern");
|
|
2049
|
-
}
|
|
2050
|
-
selected = truth(patVal);
|
|
2051
|
-
}
|
|
2052
|
-
if (!selected)
|
|
2053
|
-
continue;
|
|
2054
|
-
if (rule.end) {
|
|
2055
|
-
const endVal = this.scalarExpression(rule.end);
|
|
2056
|
-
if (endVal instanceof Promise) {
|
|
2057
|
-
return this.continueProgramAsyncAtRule(endVal, ranges, index, "end");
|
|
2058
|
-
}
|
|
2059
|
-
if (truth(endVal))
|
|
2060
|
-
ranges?.delete(index);
|
|
2061
|
-
else
|
|
2062
|
-
(ranges ??= new Set()).add(index);
|
|
2063
|
-
}
|
|
2064
|
-
const execRes = this.executeSync(rule.action);
|
|
2065
|
-
if (execRes instanceof Promise) {
|
|
2066
|
-
return this.continueProgramAsyncAtRule(execRes, ranges, index, "action");
|
|
2067
|
-
}
|
|
2068
|
-
}
|
|
2069
|
-
}
|
|
2070
|
-
catch (error) {
|
|
2071
|
-
if (!(error instanceof Flow))
|
|
2072
|
-
throw error;
|
|
2073
|
-
if (error.kind === "exit") {
|
|
2074
|
-
this.exit(error);
|
|
2075
|
-
break;
|
|
2076
|
-
}
|
|
2077
|
-
if (error.kind === "nextfile") {
|
|
2078
|
-
const closePending = this.mainReader?.closeSyncOrAsync();
|
|
2079
|
-
this.mainReader = undefined;
|
|
2080
|
-
if (closePending)
|
|
2081
|
-
return closePending.then(() => this.continueProgramSlowAsync(ranges));
|
|
2082
|
-
}
|
|
2083
|
-
else if (error.kind !== "next")
|
|
2084
|
-
throw error;
|
|
2085
|
-
}
|
|
2086
|
-
}
|
|
2087
|
-
}
|
|
2088
|
-
if (this.mainReader && !hasMainGetline(this.program.end) && ![...this.program.functions.values()].some(hasMainGetline)) {
|
|
2089
|
-
void this.mainReader.close().catch(() => undefined);
|
|
2090
|
-
}
|
|
2091
|
-
return this.runEndPhaseSyncOrAsync(0);
|
|
2092
|
-
}
|
|
2093
|
-
runEndPhaseSyncOrAsync(startIdx) {
|
|
2094
|
-
this.phase = "END";
|
|
2095
|
-
try {
|
|
2096
|
-
for (let i = startIdx; i < this.program.end.length; i++) {
|
|
2097
|
-
const endRes = this.executeSync(this.program.end[i]);
|
|
2098
|
-
if (endRes instanceof Promise) {
|
|
2099
|
-
return this.continueEndPhaseAsync(endRes, i + 1);
|
|
2100
|
-
}
|
|
2101
|
-
}
|
|
2102
|
-
}
|
|
2103
|
-
catch (error) {
|
|
2104
|
-
if (error instanceof Flow && error.kind === "exit")
|
|
2105
|
-
this.exit(error);
|
|
2106
|
-
else
|
|
2107
|
-
throw error;
|
|
2108
|
-
}
|
|
2109
|
-
return this.status;
|
|
2110
|
-
}
|
|
2111
|
-
async continueEndPhaseAsync(pending, nextIdx) {
|
|
2112
|
-
try {
|
|
2113
|
-
await pending;
|
|
2114
|
-
for (let i = nextIdx; i < this.program.end.length; i++) {
|
|
2115
|
-
await this.execute(this.program.end[i]);
|
|
2116
|
-
}
|
|
2117
|
-
}
|
|
2118
|
-
catch (error) {
|
|
2119
|
-
if (error instanceof Flow && error.kind === "exit")
|
|
2120
|
-
this.exit(error);
|
|
2121
|
-
else
|
|
2122
|
-
throw error;
|
|
2123
|
-
}
|
|
2124
|
-
return this.status;
|
|
2125
|
-
}
|
|
2126
|
-
async continueProgramAsyncAfterRecord(pending, ranges, startRule) {
|
|
2127
|
-
await pending;
|
|
2128
|
-
return this.continueProgramAsyncRulesAndLoop(ranges, startRule);
|
|
2129
|
-
}
|
|
2130
|
-
async continueProgramAsyncAtRule(pending, ranges, ruleIdx, step) {
|
|
2131
|
-
const rule = this.program.rules[ruleIdx];
|
|
2132
|
-
try {
|
|
2133
|
-
if (step === "pattern") {
|
|
2134
|
-
if (truth((await pending))) {
|
|
2135
|
-
if (rule.end) {
|
|
2136
|
-
const endVal = this.scalarExpression(rule.end);
|
|
2137
|
-
if (truth(endVal instanceof Promise ? await endVal : endVal))
|
|
2138
|
-
ranges?.delete(ruleIdx);
|
|
2139
|
-
else
|
|
2140
|
-
(ranges ??= new Set()).add(ruleIdx);
|
|
2141
|
-
}
|
|
2142
|
-
const execRes = this.executeSync(rule.action);
|
|
2143
|
-
if (execRes instanceof Promise)
|
|
2144
|
-
await execRes;
|
|
2145
|
-
}
|
|
2146
|
-
}
|
|
2147
|
-
else if (step === "end") {
|
|
2148
|
-
if (truth((await pending)))
|
|
2149
|
-
ranges?.delete(ruleIdx);
|
|
2150
|
-
else
|
|
2151
|
-
(ranges ??= new Set()).add(ruleIdx);
|
|
2152
|
-
const execRes = this.executeSync(rule.action);
|
|
2153
|
-
if (execRes instanceof Promise)
|
|
2154
|
-
await execRes;
|
|
2155
|
-
}
|
|
2156
|
-
else {
|
|
2157
|
-
await pending;
|
|
2158
|
-
}
|
|
2159
|
-
}
|
|
2160
|
-
catch (error) {
|
|
2161
|
-
if (!(error instanceof Flow))
|
|
2162
|
-
throw error;
|
|
2163
|
-
if (error.kind === "exit") {
|
|
2164
|
-
this.exit(error);
|
|
2165
|
-
return this.runEndPhaseSyncOrAsync(0);
|
|
2166
|
-
}
|
|
2167
|
-
if (error.kind === "nextfile") {
|
|
2168
|
-
await this.mainReader?.close();
|
|
2169
|
-
this.mainReader = undefined;
|
|
2170
|
-
return this.continueProgramSlowAsync(ranges);
|
|
2171
|
-
}
|
|
2172
|
-
if (error.kind !== "next")
|
|
2173
|
-
throw error;
|
|
2174
|
-
return this.continueProgramSlowAsync(ranges);
|
|
2175
|
-
}
|
|
2176
|
-
return this.continueProgramAsyncRulesAndLoop(ranges, ruleIdx + 1);
|
|
2177
|
-
}
|
|
2178
|
-
async continueProgramAsyncRulesAndLoop(ranges, startRule) {
|
|
2179
|
-
try {
|
|
2180
|
-
for (let index = startRule; index < this.program.rules.length; index++) {
|
|
2181
|
-
const rule = this.program.rules[index];
|
|
2182
|
-
let selected = !rule.pattern || (ranges !== undefined && ranges.has(index));
|
|
2183
|
-
if (!selected) {
|
|
2184
|
-
const patVal = this.scalarExpression(rule.pattern);
|
|
2185
|
-
selected = truth(patVal instanceof Promise ? await patVal : patVal);
|
|
2186
|
-
}
|
|
2187
|
-
if (!selected)
|
|
2188
|
-
continue;
|
|
2189
|
-
if (rule.end) {
|
|
2190
|
-
const endVal = this.scalarExpression(rule.end);
|
|
2191
|
-
if (truth(endVal instanceof Promise ? await endVal : endVal))
|
|
2192
|
-
ranges?.delete(index);
|
|
2193
|
-
else
|
|
2194
|
-
(ranges ??= new Set()).add(index);
|
|
2195
|
-
}
|
|
2196
|
-
const execRes = this.executeSync(rule.action);
|
|
2197
|
-
if (execRes instanceof Promise)
|
|
2198
|
-
await execRes;
|
|
2199
|
-
}
|
|
2200
|
-
}
|
|
2201
|
-
catch (error) {
|
|
2202
|
-
if (!(error instanceof Flow))
|
|
2203
|
-
throw error;
|
|
2204
|
-
if (error.kind === "exit") {
|
|
2205
|
-
this.exit(error);
|
|
2206
|
-
return this.runEndPhaseSyncOrAsync(0);
|
|
2207
|
-
}
|
|
2208
|
-
if (error.kind === "nextfile") {
|
|
2209
|
-
await this.mainReader?.close();
|
|
2210
|
-
this.mainReader = undefined;
|
|
2211
|
-
}
|
|
2212
|
-
else if (error.kind !== "next")
|
|
2213
|
-
throw error;
|
|
2214
|
-
}
|
|
2215
|
-
return this.continueProgramSlowAsync(ranges);
|
|
2216
|
-
}
|
|
2217
|
-
async continueProgramSlowAsync(ranges) {
|
|
2218
|
-
while (true) {
|
|
2219
|
-
this.budget.step();
|
|
2220
|
-
if (this.mainReader && this.mainReader.readSliceSync(this.varText("RS"), this.sliceBox)) {
|
|
2221
|
-
this.incrementCounter("NR");
|
|
2222
|
-
this.incrementCounter("FNR");
|
|
2223
|
-
const setRecPromise = this.setRecordSliceSync(this.sliceBox.source, this.sliceBox.start, this.sliceBox.end);
|
|
2224
|
-
if (setRecPromise instanceof Promise)
|
|
2225
|
-
await setRecPromise;
|
|
2226
|
-
}
|
|
2227
|
-
else if (this.mainReader && this.mainReader.isEnded && this.argument >= number(this.getScalar("ARGC"))) {
|
|
2228
|
-
void this.mainReader.close();
|
|
2229
|
-
this.mainReader = undefined;
|
|
2230
|
-
break;
|
|
2231
|
-
}
|
|
2232
|
-
else {
|
|
2233
|
-
const recOrPromise = this.readMainRecordSync();
|
|
2234
|
-
const record = recOrPromise instanceof Promise ? await recOrPromise : recOrPromise;
|
|
2235
|
-
if (record === undefined)
|
|
2236
|
-
break;
|
|
2237
|
-
const setRecPromise = this.setRecordSync(record);
|
|
2238
|
-
if (setRecPromise instanceof Promise)
|
|
2239
|
-
await setRecPromise;
|
|
2240
|
-
}
|
|
2241
|
-
try {
|
|
2242
|
-
for (let index = 0; index < this.program.rules.length; index++) {
|
|
2243
|
-
const rule = this.program.rules[index];
|
|
2244
|
-
let selected = !rule.pattern || (ranges !== undefined && ranges.has(index));
|
|
2245
|
-
if (!selected) {
|
|
2246
|
-
const patVal = this.scalarExpression(rule.pattern);
|
|
2247
|
-
selected = truth(patVal instanceof Promise ? await patVal : patVal);
|
|
2248
|
-
}
|
|
2249
|
-
if (!selected)
|
|
2250
|
-
continue;
|
|
2251
|
-
if (rule.end) {
|
|
2252
|
-
const endVal = this.scalarExpression(rule.end);
|
|
2253
|
-
if (truth(endVal instanceof Promise ? await endVal : endVal))
|
|
2254
|
-
ranges?.delete(index);
|
|
2255
|
-
else
|
|
2256
|
-
(ranges ??= new Set()).add(index);
|
|
2257
|
-
}
|
|
2258
|
-
const execRes = this.executeSync(rule.action);
|
|
2259
|
-
if (execRes instanceof Promise)
|
|
2260
|
-
await execRes;
|
|
2261
|
-
}
|
|
2262
|
-
}
|
|
2263
|
-
catch (error) {
|
|
2264
|
-
if (!(error instanceof Flow))
|
|
2265
|
-
throw error;
|
|
2266
|
-
if (error.kind === "exit") {
|
|
2267
|
-
this.exit(error);
|
|
2268
|
-
break;
|
|
2269
|
-
}
|
|
2270
|
-
if (error.kind === "nextfile") {
|
|
2271
|
-
await this.mainReader?.close();
|
|
2272
|
-
this.mainReader = undefined;
|
|
2273
|
-
}
|
|
2274
|
-
else if (error.kind !== "next")
|
|
2275
|
-
throw error;
|
|
2276
|
-
}
|
|
2277
|
-
}
|
|
2278
|
-
if (this.mainReader && !hasMainGetline(this.program.end) && ![...this.program.functions.values()].some(hasMainGetline)) {
|
|
2279
|
-
void this.mainReader.close().catch(() => undefined);
|
|
2280
|
-
}
|
|
2281
|
-
return this.runEndPhaseSyncOrAsync(0);
|
|
2282
|
-
}
|
|
2283
|
-
async _unusedOldRun() {
|
|
2284
|
-
let status = 0, failed = false;
|
|
2285
|
-
let failure;
|
|
2286
|
-
try {
|
|
2287
|
-
status = await this.runProgram();
|
|
2288
|
-
if (this.stdoutBuffer.length > 0)
|
|
2289
|
-
await this.flushStdout();
|
|
2290
|
-
this.syncSpecialVars();
|
|
2291
|
-
await this.inspection?.publish(this.variables);
|
|
2292
|
-
}
|
|
2293
|
-
catch (error) {
|
|
2294
|
-
failed = true;
|
|
2295
|
-
failure = error;
|
|
2296
|
-
}
|
|
2297
|
-
if (this.stdoutBuffer.length > 0) {
|
|
2298
|
-
try {
|
|
2299
|
-
await this.flushStdout();
|
|
2300
|
-
}
|
|
2301
|
-
catch (error) {
|
|
2302
|
-
if (!failed) {
|
|
2303
|
-
failed = true;
|
|
2304
|
-
failure = error;
|
|
2305
|
-
}
|
|
2306
|
-
}
|
|
2307
|
-
}
|
|
2308
|
-
let cleanup;
|
|
2309
|
-
if (this.mainReader && (!this.inputs || this.inputs.size === 0)) {
|
|
2310
|
-
const pendingClose = this.mainReader.closeSyncOrAsync();
|
|
2311
|
-
this.mainReader = undefined;
|
|
2312
|
-
if (pendingClose) {
|
|
2313
|
-
try {
|
|
2314
|
-
await pendingClose;
|
|
2315
|
-
}
|
|
2316
|
-
catch (error) {
|
|
2317
|
-
if (!failed) {
|
|
2318
|
-
failed = true;
|
|
2319
|
-
failure = error;
|
|
2320
|
-
}
|
|
2321
|
-
}
|
|
2322
|
-
}
|
|
2323
|
-
}
|
|
2324
|
-
else if (this.mainReader || (this.inputs && this.inputs.size > 0)) {
|
|
2325
|
-
const readers = [...this.mainReader ? [this.mainReader] : [], ...this.inputs ? this.inputs.values() : []];
|
|
2326
|
-
this.mainReader = undefined;
|
|
2327
|
-
if (this.inputs) {
|
|
2328
|
-
for (const name of this.inputs.keys())
|
|
2329
|
-
this.retention.release(shellValueByteLength(name));
|
|
2330
|
-
this.inputs.clear();
|
|
2331
|
-
}
|
|
2332
|
-
cleanup = await Promise.allSettled(readers.map(async (reader) => { await reader.close(); }));
|
|
2333
|
-
}
|
|
2334
|
-
if (this.outputs && this.outputs.size > 0) {
|
|
2335
|
-
for (const name of this.outputs)
|
|
2336
|
-
this.retention.release(shellValueByteLength(name));
|
|
2337
|
-
this.outputs.clear();
|
|
2338
|
-
}
|
|
2339
|
-
this.releaseStore(this.variables);
|
|
2340
|
-
this.retention.release(this.recordLength + this.fieldBytes);
|
|
2341
|
-
this.record = "";
|
|
2342
|
-
this.fields = [];
|
|
2343
|
-
this.fieldCount = 0;
|
|
2344
|
-
this.fieldsMaterialized = true;
|
|
2345
|
-
this.fieldBytes = 0;
|
|
2346
|
-
this.sliceBox.source = "";
|
|
2347
|
-
this.recordValue = unset;
|
|
2348
|
-
this.context.signal.throwIfAborted();
|
|
2349
|
-
this.context = RELEASED_AWK_CONTEXT;
|
|
2350
|
-
this.budget.context = RELEASED_AWK_CONTEXT;
|
|
2351
|
-
this.budget.signal = RELEASED_AWK_SIGNAL;
|
|
2352
|
-
if (failed)
|
|
2353
|
-
throw failure;
|
|
2354
|
-
if (cleanup)
|
|
2355
|
-
for (const result of cleanup)
|
|
2356
|
-
if (result.status === "rejected")
|
|
2357
|
-
throw result.reason;
|
|
2358
|
-
return status;
|
|
2359
|
-
}
|
|
2360
|
-
async readMainRecord() {
|
|
2361
|
-
const syncRes = this.readMainRecordSync();
|
|
2362
|
-
return syncRes instanceof Promise ? await syncRes : syncRes;
|
|
2363
|
-
}
|
|
2364
|
-
incrementCounter(name) {
|
|
2365
|
-
if (this.frames.length === 0 || !this.frames.at(-1).has(name)) {
|
|
2366
|
-
const nrVal = name === "NR" && !this.nrDirty ? this.variables.get("NR") : undefined;
|
|
2367
|
-
if (nrVal && !("entries" in nrVal) && nrVal.kind === "number") {
|
|
2368
|
-
this.nrNum++;
|
|
2369
|
-
this.nrDirty = true;
|
|
2370
|
-
return;
|
|
2371
|
-
}
|
|
2372
|
-
if (name === "NR" && this.nrDirty) {
|
|
2373
|
-
this.nrNum++;
|
|
2374
|
-
return;
|
|
2375
|
-
}
|
|
2376
|
-
const fnrVal = name === "FNR" && !this.fnrDirty ? this.variables.get("FNR") : undefined;
|
|
2377
|
-
if (fnrVal && !("entries" in fnrVal) && fnrVal.kind === "number") {
|
|
2378
|
-
this.fnrNum++;
|
|
2379
|
-
this.fnrDirty = true;
|
|
2380
|
-
return;
|
|
2381
|
-
}
|
|
2382
|
-
if (name === "FNR" && this.fnrDirty) {
|
|
2383
|
-
this.fnrNum++;
|
|
2384
|
-
return;
|
|
2385
|
-
}
|
|
2386
|
-
}
|
|
2387
|
-
this.set(name, numeric(number(this.getScalar(name)) + 1));
|
|
2388
|
-
}
|
|
2389
|
-
readMainRecordSync() {
|
|
2390
|
-
if (this.mainReader) {
|
|
2391
|
-
this.budget.step();
|
|
2392
|
-
const record = this.mainReader.readSync(this.varText("RS"));
|
|
2393
|
-
if (typeof record === "string") {
|
|
2394
|
-
this.incrementCounter("NR");
|
|
2395
|
-
this.incrementCounter("FNR");
|
|
2396
|
-
return record;
|
|
2397
|
-
}
|
|
2398
|
-
if (record instanceof Promise) {
|
|
2399
|
-
return this.readMainRecordAfterPromise(record);
|
|
2400
|
-
}
|
|
2401
|
-
return this.readMainRecordSlowAfterEof();
|
|
2402
|
-
}
|
|
2403
|
-
return this.readMainRecordSlow();
|
|
2404
|
-
}
|
|
2405
|
-
async readMainRecordAfterPromise(recordPromise) {
|
|
2406
|
-
const resolved = await recordPromise;
|
|
2407
|
-
if (resolved !== undefined) {
|
|
2408
|
-
this.incrementCounter("NR");
|
|
2409
|
-
this.incrementCounter("FNR");
|
|
2410
|
-
return resolved;
|
|
2411
|
-
}
|
|
2412
|
-
return this.readMainRecordSlowAfterEof();
|
|
2413
|
-
}
|
|
2414
|
-
async readMainRecordSlowAfterEof() {
|
|
2415
|
-
await this.mainReader?.close();
|
|
2416
|
-
this.mainReader = undefined;
|
|
2417
|
-
return this.readMainRecordSlow();
|
|
2418
|
-
}
|
|
2419
|
-
async readMainRecordSlow() {
|
|
2420
|
-
while (true) {
|
|
2421
|
-
this.budget.step();
|
|
2422
|
-
if (!this.mainReader) {
|
|
2423
|
-
let file;
|
|
2424
|
-
while (this.argument < number(this.getScalar("ARGC"))) {
|
|
2425
|
-
this.budget.step();
|
|
2426
|
-
const argumentOptions = this.budget.options;
|
|
2427
|
-
if (this.argument > (argumentOptions?.maxArguments ?? Infinity))
|
|
2428
|
-
throw new ProgramError("argument count limit exceeded");
|
|
2429
|
-
const p = this.budget.checkpointSync();
|
|
2430
|
-
if (p)
|
|
2431
|
-
await p;
|
|
2432
|
-
const next = this.asText(this.array("ARGV").entries.get(String(this.argument++)) ?? unset);
|
|
2433
|
-
if (!next)
|
|
2434
|
-
continue;
|
|
2435
|
-
if (this.operandAssignments && /^[A-Za-z_][A-Za-z0-9_]*=/u.test(next)) {
|
|
2436
|
-
this.assignment(next);
|
|
2437
|
-
continue;
|
|
2438
|
-
}
|
|
2439
|
-
file = next;
|
|
2440
|
-
this.sawFile = true;
|
|
2441
|
-
break;
|
|
2442
|
-
}
|
|
2443
|
-
if (file === undefined && !this.sawFile && !this.defaultUsed) {
|
|
2444
|
-
file = "-";
|
|
2445
|
-
this.defaultUsed = true;
|
|
2446
|
-
}
|
|
2447
|
-
if (file === undefined)
|
|
2448
|
-
return undefined;
|
|
2449
|
-
this.set("FILENAME", string(file));
|
|
2450
|
-
this.set("FNR", numeric(0));
|
|
2451
|
-
this.mainReader = new Reader(input(this.context, decodeBytes(encodeBytes(file, "latin1"), "utf8")), this.budget, this.retention);
|
|
2452
|
-
}
|
|
2453
|
-
const record = await this.mainReader.read(this.varText("RS"));
|
|
2454
|
-
if (record === undefined) {
|
|
2455
|
-
await this.mainReader.close();
|
|
2456
|
-
this.mainReader = undefined;
|
|
2457
|
-
continue;
|
|
2458
|
-
}
|
|
2459
|
-
this.incrementCounter("NR");
|
|
2460
|
-
this.incrementCounter("FNR");
|
|
2461
|
-
return record;
|
|
2462
|
-
}
|
|
2463
|
-
}
|
|
2464
|
-
tryOpenNextMainReaderSync() {
|
|
2465
|
-
const argc = number(this.getScalar("ARGC"));
|
|
2466
|
-
const argumentOptions = this.budget.options;
|
|
2467
|
-
const maxArgs = argumentOptions?.maxArguments ?? Infinity;
|
|
2468
|
-
while (this.argument < argc) {
|
|
2469
|
-
this.budget.step();
|
|
2470
|
-
if (this.argument > maxArgs)
|
|
2471
|
-
throw new ProgramError("argument count limit exceeded");
|
|
2472
|
-
{
|
|
2473
|
-
const cp = this.budget.checkpointSync();
|
|
2474
|
-
if (cp) {
|
|
2475
|
-
cp.catch(() => { });
|
|
2476
|
-
return false;
|
|
2477
|
-
}
|
|
2478
|
-
}
|
|
2479
|
-
const argIdx = this.argument++;
|
|
2480
|
-
const argKey = argIdx < SMALL_ARG_KEYS.length ? SMALL_ARG_KEYS[argIdx] : String(argIdx);
|
|
2481
|
-
const next = this.asText(this.array("ARGV").entries.get(argKey) ?? unset);
|
|
2482
|
-
if (!next)
|
|
2483
|
-
continue;
|
|
2484
|
-
if (this.operandAssignments && isOperandAssignment(next)) {
|
|
2485
|
-
this.assignment(next);
|
|
2486
|
-
continue;
|
|
2487
|
-
}
|
|
2488
|
-
this.sawFile = true;
|
|
2489
|
-
this.set("FILENAME", string(next));
|
|
2490
|
-
if (this.fnrNum !== 0 || this.fnrDirty || this.variables.get("FNR") !== SCALAR_ZERO) {
|
|
2491
|
-
this.set("FNR", SCALAR_ZERO);
|
|
2492
|
-
}
|
|
2493
|
-
const utf8File = isAsciiText(next) ? next : decodeBytes(encodeBytes(next, "latin1"), "utf8");
|
|
2494
|
-
if (utf8File !== "-") {
|
|
2495
|
-
const fastMem = this.context._fastMemoryBackingFs;
|
|
2496
|
-
if (fastMem &&
|
|
2497
|
-
fastMem.capabilitiesFor === undefined &&
|
|
2498
|
-
!Object.prototype.hasOwnProperty.call(fastMem, "readStream") &&
|
|
2499
|
-
!Object.prototype.hasOwnProperty.call(fastMem, "readFile")) {
|
|
2500
|
-
const resolvedPath = virtualPath(this.context, utf8File);
|
|
2501
|
-
if (resolvedPath !== "/dev" && !resolvedPath.startsWith("/dev/")) {
|
|
2502
|
-
let rawView;
|
|
2503
|
-
try {
|
|
2504
|
-
rawView = tryReadMemoryFileViewSync(fastMem, resolvedPath, undefined, this.context.signal, true);
|
|
2505
|
-
}
|
|
2506
|
-
catch {
|
|
2507
|
-
rawView = undefined;
|
|
2508
|
-
}
|
|
2509
|
-
if (rawView !== undefined && rawView.byteLength <= this.budget.maxBufferBytes) {
|
|
2510
|
-
this.context.inputBudget?.check(rawView.byteLength);
|
|
2511
|
-
this.context._chargeFastFsOp?.();
|
|
2512
|
-
this.mainReader = Reader.fromMemoryView(rawView, this.budget, this.retention);
|
|
2513
|
-
return true;
|
|
2514
|
-
}
|
|
2515
|
-
}
|
|
2516
|
-
}
|
|
2517
|
-
}
|
|
2518
|
-
this.mainReader = new Reader(input(this.context, utf8File), this.budget, this.retention);
|
|
2519
|
-
return true;
|
|
2520
|
-
}
|
|
2521
|
-
if (!this.sawFile && !this.defaultUsed) {
|
|
2522
|
-
this.defaultUsed = true;
|
|
2523
|
-
this.set("FILENAME", string("-"));
|
|
2524
|
-
this.set("FNR", numeric(0));
|
|
2525
|
-
this.mainReader = new Reader(input(this.context, "-"), this.budget, this.retention);
|
|
2526
|
-
return true;
|
|
2527
|
-
}
|
|
2528
|
-
return false;
|
|
2529
|
-
}
|
|
2530
|
-
async runProgram() {
|
|
2531
|
-
let stopped = false;
|
|
2532
|
-
try {
|
|
2533
|
-
for (const statement of this.program.begin)
|
|
2534
|
-
await this.execute(statement);
|
|
2535
|
-
}
|
|
2536
|
-
catch (error) {
|
|
2537
|
-
if (error instanceof Flow && error.kind === "exit") {
|
|
2538
|
-
this.exit(error);
|
|
2539
|
-
stopped = true;
|
|
2540
|
-
}
|
|
2541
|
-
else
|
|
2542
|
-
throw error;
|
|
2543
|
-
}
|
|
2544
|
-
this.phase = "record";
|
|
2545
|
-
let ranges;
|
|
2546
|
-
if (!stopped && (this.program.rules.length || this.program.end.length)) {
|
|
2547
|
-
if (!this.mainReader) {
|
|
2548
|
-
this.tryOpenNextMainReaderSync();
|
|
2549
|
-
}
|
|
2550
|
-
while (true) {
|
|
2551
|
-
this.budget.step();
|
|
2552
|
-
if (this.mainReader && this.mainReader.readSliceSync(this.varText("RS"), this.sliceBox)) {
|
|
2553
|
-
this.incrementCounter("NR");
|
|
2554
|
-
this.incrementCounter("FNR");
|
|
2555
|
-
const setRecPromise = this.setRecordSliceSync(this.sliceBox.source, this.sliceBox.start, this.sliceBox.end);
|
|
2556
|
-
if (setRecPromise instanceof Promise)
|
|
2557
|
-
await setRecPromise;
|
|
2558
|
-
}
|
|
2559
|
-
else if (this.mainReader && this.mainReader.isEnded && this.argument >= number(this.getScalar("ARGC"))) {
|
|
2560
|
-
void this.mainReader.close();
|
|
2561
|
-
this.mainReader = undefined;
|
|
2562
|
-
break;
|
|
2563
|
-
}
|
|
2564
|
-
else {
|
|
2565
|
-
const recOrPromise = this.readMainRecordSync();
|
|
2566
|
-
const record = recOrPromise instanceof Promise ? await recOrPromise : recOrPromise;
|
|
2567
|
-
if (record === undefined)
|
|
2568
|
-
break;
|
|
2569
|
-
const setRecPromise = this.setRecordSync(record);
|
|
2570
|
-
if (setRecPromise instanceof Promise)
|
|
2571
|
-
await setRecPromise;
|
|
2572
|
-
}
|
|
2573
|
-
try {
|
|
2574
|
-
for (let index = 0; index < this.program.rules.length; index++) {
|
|
2575
|
-
const rule = this.program.rules[index];
|
|
2576
|
-
let selected = !rule.pattern || (ranges !== undefined && ranges.has(index));
|
|
2577
|
-
if (!selected) {
|
|
2578
|
-
const patVal = this.scalarExpression(rule.pattern);
|
|
2579
|
-
selected = truth(patVal instanceof Promise ? await patVal : patVal);
|
|
2580
|
-
}
|
|
2581
|
-
if (!selected)
|
|
2582
|
-
continue;
|
|
2583
|
-
if (rule.end) {
|
|
2584
|
-
const endVal = this.scalarExpression(rule.end);
|
|
2585
|
-
if (truth(endVal instanceof Promise ? await endVal : endVal))
|
|
2586
|
-
ranges?.delete(index);
|
|
2587
|
-
else
|
|
2588
|
-
(ranges ??= new Set()).add(index);
|
|
2589
|
-
}
|
|
2590
|
-
const execRes = this.executeSync(rule.action);
|
|
2591
|
-
if (execRes instanceof Promise)
|
|
2592
|
-
await execRes;
|
|
2593
|
-
}
|
|
2594
|
-
}
|
|
2595
|
-
catch (error) {
|
|
2596
|
-
if (!(error instanceof Flow))
|
|
2597
|
-
throw error;
|
|
2598
|
-
if (error.kind === "exit") {
|
|
2599
|
-
this.exit(error);
|
|
2600
|
-
break;
|
|
2601
|
-
}
|
|
2602
|
-
if (error.kind === "nextfile") {
|
|
2603
|
-
await this.mainReader?.close();
|
|
2604
|
-
this.mainReader = undefined;
|
|
2605
|
-
}
|
|
2606
|
-
else if (error.kind !== "next")
|
|
2607
|
-
throw error;
|
|
2608
|
-
}
|
|
2609
|
-
}
|
|
2610
|
-
}
|
|
2611
|
-
if (this.mainReader && !hasMainGetline(this.program.end) && ![...this.program.functions.values()].some(hasMainGetline)) {
|
|
2612
|
-
void this.mainReader.close().catch(() => undefined);
|
|
2613
|
-
}
|
|
2614
|
-
this.phase = "END";
|
|
2615
|
-
try {
|
|
2616
|
-
for (const statement of this.program.end)
|
|
2617
|
-
await this.execute(statement);
|
|
2618
|
-
}
|
|
2619
|
-
catch (error) {
|
|
2620
|
-
if (error instanceof Flow && error.kind === "exit")
|
|
2621
|
-
this.exit(error);
|
|
2622
|
-
else
|
|
2623
|
-
throw error;
|
|
2624
|
-
}
|
|
2625
|
-
return this.status;
|
|
2626
|
-
}
|
|
2627
|
-
}
|
|
1
|
+
export * from "../../../safe-bash-command-awk/awk-runtime.js";
|
|
2628
2
|
//# sourceMappingURL=awk-runtime.js.map
|