@poe-platform/safe-bash 0.1.799 → 0.1.800
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 +32 -17
- package/dist/image-ast/index.browser.js +1384 -23
- package/dist/image-ast/index.js +1384 -23
- 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 +1 -1
- package/dist/safe-bash/chunks/{chunk-IUTD5FH5.js → chunk-46UISJCK.js} +1 -6
- package/dist/safe-bash/chunks/chunk-4SEW2Q6H.js +26 -0
- package/dist/safe-bash/chunks/{chunk-AKC46AF6.js → chunk-7YSRXFEG.js} +7 -40
- package/dist/safe-bash/chunks/{chunk-KTGR4U57.js → chunk-BHJE5LPZ.js} +1 -2
- package/dist/safe-bash/chunks/{chunk-TRVGCN3U.js → chunk-HHW7MGS2.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-ZNAFMYIA.js → chunk-I7L3G3NX.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-KMH2DF3I.js → chunk-JJSTTIEZ.js} +6 -1
- package/dist/safe-bash/chunks/{chunk-6IBTC4YL.js → chunk-JTLSUJ7V.js} +57 -20
- package/dist/safe-bash/chunks/chunk-K2VCOJ2B.js +111 -0
- package/dist/safe-bash/chunks/chunk-K4YMYFRJ.js +9802 -0
- package/dist/safe-bash/chunks/{chunk-SPYL72GN.js → chunk-KW24TAIU.js} +446 -5519
- package/dist/safe-bash/chunks/{chunk-ENR3HB2B.js → chunk-NLAW7KDI.js} +0 -1
- package/dist/safe-bash/chunks/{chunk-B3DDEDH2.js → chunk-PPYM75Z3.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-NX2SQVON.js → chunk-RKKRJ54E.js} +19 -7
- package/dist/safe-bash/chunks/{chunk-WUNK5NXJ.js → chunk-RMWLWH7Q.js} +870 -953
- package/dist/safe-bash/chunks/{chunk-JSVX4VIA.js → chunk-TFGRKY43.js} +2 -1
- package/dist/safe-bash/chunks/{chunk-T5KKDMYB.js → chunk-TYD7EVUJ.js} +6 -0
- package/dist/safe-bash/chunks/{csvkit-W2UEKH6P.js → csvkit-QGP3GAOB.js} +1 -1
- package/dist/safe-bash/chunks/{ffmpeg-42CGASMV.js → ffmpeg-JTVH26MK.js} +1 -1
- package/dist/safe-bash/chunks/{gh-26GYLH6D.js → gh-I7QX7N5C.js} +1 -1
- package/dist/safe-bash/chunks/{git-YREKMUVD.js → git-MA7NKYVP.js} +1 -1
- package/dist/safe-bash/chunks/{imagemagick-3YIX4XO2.js → imagemagick-Y4NPWX2Q.js} +1 -1
- package/dist/safe-bash/chunks/{implementation-E3YMKU3Z.js → implementation-BWDKOVQJ.js} +1 -1
- package/dist/safe-bash/chunks/mmdc-44PELHDG.js +118 -0
- package/dist/safe-bash/chunks/{pdfimages-UE2UISP2.js → pdfimages-635TRW4Q.js} +1 -1
- package/dist/safe-bash/chunks/{pdfinfo-RGARKLI5.js → pdfinfo-FSDAA2KY.js} +3 -11
- package/dist/safe-bash/chunks/{pdftk-JY3WVCCC.js → pdftk-GQ5UH3VG.js} +1 -1
- package/dist/safe-bash/chunks/{pdftoppm-GPD3BMPY.js → pdftoppm-YTXQCAYT.js} +1 -1
- package/dist/safe-bash/chunks/{pdftotext-K7GQ2QJZ.js → pdftotext-CVA2G7FY.js} +1 -1
- package/dist/safe-bash/chunks/{qpdf-F4U7WUSU.js → qpdf-HZMIFG4A.js} +1 -1
- package/dist/safe-bash/chunks/{sips-RWENS7X5.js → sips-E7UBDP33.js} +1 -1
- package/dist/safe-bash/chunks/{soffice-IT6W2C5F.js → soffice-ELASUWUK.js} +1 -1
- package/dist/safe-bash/chunks/{wkhtmltopdf-JYNDAHIZ.js → wkhtmltopdf-EPO6YCMG.js} +1 -1
- 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-LLCXZKZ6.js → chunk-2QHG43WJ.js} +2 -2
- package/dist/safe-bash/command-chunks/chunk-364TMWBT.js +946 -0
- package/dist/safe-bash/command-chunks/{chunk-EIVW3X3N.js → chunk-3DT2YOGW.js} +11 -6
- package/dist/safe-bash/command-chunks/chunk-3E2OIS2J.js +7037 -0
- package/dist/safe-bash/command-chunks/{chunk-AIRGA2SU.js → chunk-3HXDA5PT.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-3LSOYLNV.js +1091 -0
- package/dist/safe-bash/command-chunks/chunk-4B7Y7S6E.js +61 -0
- package/dist/safe-bash/command-chunks/{chunk-HRLIAMXC.js → chunk-4C6QI5BQ.js} +3 -2
- package/dist/safe-bash/command-chunks/chunk-4ZHMW6F5.js +104 -0
- package/dist/safe-bash/command-chunks/{chunk-4ZALPDBV.js → chunk-53P53XFM.js} +2 -2
- package/dist/safe-bash/command-chunks/chunk-5LSGEIZY.js +379 -0
- package/dist/safe-bash/command-chunks/{chunk-MKQVQMXO.js → chunk-5LU4UCBR.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-5T7CRJHW.js +560 -0
- package/dist/safe-bash/command-chunks/chunk-5TBUOBDE.js +346 -0
- 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-OPUJSTHS.js → chunk-67IQF5GC.js} +200 -66
- package/dist/safe-bash/command-chunks/chunk-67QKREJK.js +347 -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-ESMCX3YV.js → chunk-6HMX4CQS.js} +669 -130
- 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-7RGB363W.js +362 -0
- package/dist/safe-bash/command-chunks/{pptx-GBPNWNEP-7EQEVXV5.js → chunk-AI5JAXQF.js} +34820 -18029
- package/dist/safe-bash/command-chunks/chunk-AMO3THU4.js +105 -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-KMCZ6P4O.js → chunk-BKCNF5U3.js} +68 -7
- package/dist/safe-bash/command-chunks/chunk-BNOU5YQS.js +182 -0
- package/dist/safe-bash/command-chunks/chunk-C7I25AAL.js +25 -0
- package/dist/safe-bash/command-chunks/chunk-CKXV2CLD.js +65 -0
- package/dist/safe-bash/command-chunks/chunk-CQ5YGOGB.js +150 -0
- package/dist/safe-bash/command-chunks/{chunk-I3K5RYU4.js → chunk-D4OP2BR3.js} +72 -24
- package/dist/safe-bash/command-chunks/chunk-DB453IE6.js +122 -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-E2LB7FRT.js +42 -0
- 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-ERYJLO6G.js +293 -0
- package/dist/safe-bash/command-chunks/{chunk-4ONEXMD3.js → chunk-EUSPTFAX.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-FKKB5X5V.js +97 -0
- package/dist/safe-bash/command-chunks/chunk-FXELCPFX.js +195 -0
- package/dist/safe-bash/command-chunks/{chunk-JCNNOMBV.js → chunk-GI4CJED2.js} +3 -2
- 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-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-ZS3QPNUL.js → chunk-IR2BY7EL.js} +21 -6
- package/dist/safe-bash/command-chunks/chunk-IYPAQ7PH.js +42 -0
- package/dist/safe-bash/command-chunks/chunk-JN7WIP6S.js +94 -0
- package/dist/safe-bash/command-chunks/chunk-JNZ3CVAE.js +147 -0
- package/dist/safe-bash/command-chunks/{chunk-HLBX5IRS.js → chunk-JQ74HC37.js} +24 -32
- 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-KWESKQHR.js +25 -0
- package/dist/safe-bash/command-chunks/chunk-KYSPGS33.js +41 -0
- package/dist/safe-bash/command-chunks/{chunk-C7IHMJEW.js → chunk-KZC5UWFF.js} +2 -2
- package/dist/safe-bash/command-chunks/chunk-L6DVEBW3.js +553 -0
- package/dist/safe-bash/command-chunks/chunk-LC2MFKT4.js +2489 -0
- package/dist/safe-bash/command-chunks/chunk-LE5LZNHE.js +204 -0
- package/dist/safe-bash/command-chunks/chunk-MDH5T4OS.js +41 -0
- 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-VZHRZMS7.js → chunk-NAY27PXB.js} +1 -1
- 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-KVFCSLKK.js → chunk-NXEQ3ESQ.js} +6 -0
- package/dist/safe-bash/command-chunks/{chunk-3VGGYEDH.js → chunk-ORYGZYKW.js} +4 -3
- 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-43GSSUAY.js → chunk-PJJUYO3R.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-ZT4KSS2V.js → chunk-PTT3I223.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-Q3DII3Q7.js +174 -0
- package/dist/safe-bash/command-chunks/chunk-Q3EWDEUQ.js +185 -0
- package/dist/safe-bash/command-chunks/{chunk-2FUAW6GO.js → chunk-QI7LGHJJ.js} +58 -9
- package/dist/safe-bash/command-chunks/{chunk-6BETHLXZ.js → chunk-QJAFJP2G.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-QNIMV57G.js +63 -0
- package/dist/safe-bash/command-chunks/{chunk-VVI4Z73I.js → chunk-QP4R6GLA.js} +5 -1
- package/dist/safe-bash/command-chunks/{chunk-LPORMIZS.js → chunk-QWIDNAAK.js} +8 -8
- package/dist/safe-bash/command-chunks/chunk-RVLO4DYT.js +35 -0
- package/dist/safe-bash/command-chunks/{chunk-X2YQLGKS.js → chunk-SAMH7SQE.js} +4 -4
- package/dist/safe-bash/command-chunks/chunk-SEM36PG5.js +11 -0
- package/dist/safe-bash/command-chunks/chunk-STC3LEWJ.js +634 -0
- package/dist/safe-bash/command-chunks/chunk-SVULUDOP.js +331 -0
- package/dist/safe-bash/command-chunks/chunk-TEVJJPTC.js +1392 -0
- package/dist/safe-bash/command-chunks/{chunk-ZXKW7SJ2.js → chunk-TYCGMRLM.js} +2 -2
- package/dist/safe-bash/command-chunks/chunk-UG7SMZFF.js +178 -0
- package/dist/safe-bash/command-chunks/{chunk-YZ5SVZFD.js → chunk-UMDIOL3O.js} +3 -3
- package/dist/safe-bash/command-chunks/chunk-UXSR5BZH.js +136 -0
- package/dist/safe-bash/command-chunks/chunk-V6BEDRMQ.js +112 -0
- package/dist/safe-bash/command-chunks/chunk-V6MSPQLA.js +362 -0
- package/dist/safe-bash/command-chunks/{chunk-J4PEQWSF.js → chunk-VGG2DL5Q.js} +0 -1
- package/dist/safe-bash/command-chunks/{chunk-SG424QWS.js → chunk-VL67NWNS.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-WB5SVIG7.js +1034 -0
- package/dist/safe-bash/command-chunks/{src-UJOWAS2S.js → chunk-WD3ERGRY.js} +77 -277
- 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-XETLEHZP.js +1227 -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-Y5INTD6S.js +220 -0
- package/dist/safe-bash/command-chunks/{chunk-5ZSM4UFN.js → chunk-YGC6OS5O.js} +3 -56
- package/dist/safe-bash/command-chunks/chunk-YJDV76GL.js +262 -0
- package/dist/safe-bash/command-chunks/chunk-YOF7R4OY.js +80 -0
- package/dist/safe-bash/command-chunks/chunk-Z7RVSD5K.js +594 -0
- package/dist/safe-bash/command-chunks/chunk-ZHUWOUWB.js +618 -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 +2 -1
- 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/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/gzip/index.d.ts +2 -0
- package/dist/safe-bash/commands/gzip/index.js +2 -0
- package/dist/safe-bash/commands/line-endings/index.browser.js +1 -1
- 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 +3 -1
- package/dist/safe-bash/commands/mdq/index.browser.js +2 -2
- 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 -693
- 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 +2 -10
- 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/private-address.d.ts +1 -1
- package/dist/safe-bash/commands/network/private-address.js +1 -44
- 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/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 +10 -331
- package/dist/safe-bash/commands/node/index.browser.js +4 -5
- 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/unconfigured.d.ts +3 -0
- package/dist/safe-bash/commands/node/unconfigured.js +10 -0
- package/dist/safe-bash/commands/op/index.browser.js +2 -2
- 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/predicates.js +3 -4
- package/dist/safe-bash/commands/python/index.browser.js +5 -5
- 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 +1 -0
- package/dist/safe-bash/commands/python/manifest.js +9 -5
- package/dist/safe-bash/commands/python/provisioning.js +1 -1
- package/dist/safe-bash/commands/regex-execution/matching.js +1 -2
- package/dist/safe-bash/commands/regex-execution/public.browser.js +5 -5
- 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/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/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/yq/index.browser.js +7 -2
- 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 +1 -1
- package/dist/safe-bash/core.d.ts +8 -1
- package/dist/safe-bash/core.js +7 -1
- 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 +254 -223
- package/dist/safe-bash/jobs.browser.js +2 -2
- 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/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/optional-host.browser.js +8 -4
- 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/index.browser.js +14 -16
- package/dist/safe-bash/registry-entry.browser.js +14 -16
- package/dist/safe-bash/shell/arrays/bindings.d.ts +3 -5
- package/dist/safe-bash/shell/arrays/bindings.js +6 -2
- package/dist/safe-bash/shell/input.js +16 -14
- package/dist/safe-bash/shell/runtime.d.ts +3 -0
- package/dist/safe-bash/shell/runtime.js +316 -64
- 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 +13 -15
- 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-command-apply-patch/apply.js +2 -2
- package/dist/safe-bash-command-apply-patch/index.js +3 -3
- 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 +4 -0
- package/dist/safe-bash-command-bc/index.js +15 -176
- package/dist/safe-bash-command-column/column.js +3 -3
- package/dist/safe-bash-command-column/index.js +3 -3
- package/dist/safe-bash-command-column/layout.js +2 -2
- package/dist/safe-bash-command-csplit/command.js +2 -2
- package/dist/safe-bash-command-csplit/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 +172 -4
- 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-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-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.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-ffmpeg/index.js +86 -94
- package/dist/safe-bash-command-file/index.js +3 -3
- 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 +94 -0
- package/dist/safe-bash-command-html-to-markdown/index.js +5 -5
- package/dist/safe-bash-command-htmlq/index.js +12 -8
- package/dist/safe-bash-command-imagemagick/index.js +22 -30
- 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-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.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-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-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-pdfimages/index.js +37 -16
- package/dist/safe-bash-command-pdfinfo/index.d.ts +0 -23
- package/dist/safe-bash-command-pdfinfo/index.js +20 -772
- package/dist/safe-bash-command-pdftk/index.js +37 -9
- package/dist/safe-bash-command-pdftoppm/index.js +50 -20
- package/dist/safe-bash-command-pdftotext/index.js +10 -2
- 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 +26 -13
- 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-sips/index.js +111 -35
- package/dist/safe-bash-command-soffice/index.js +4 -4
- package/dist/safe-bash-command-sqlite3/engine.d.ts +1 -2
- package/dist/safe-bash-command-sqlite3/index.js +152 -452
- package/dist/safe-bash-command-ssconvert/commands.js +1 -1
- package/dist/safe-bash-command-ssconvert/formats/ods.js +2 -2
- package/dist/safe-bash-command-ssconvert/formats/xlsx.js +3 -3
- package/dist/safe-bash-command-ssconvert/index.js +5 -5
- 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 +550 -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-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 +4 -3
- package/dist/safe-bash-command-xan/index.js +15 -14
- package/dist/safe-bash-command-xan/io.js +2 -2
- package/dist/safe-bash-command-xmllint/index.js +189 -49
- package/dist/safe-bash-command-xz/index.js +3 -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 +11 -11
- 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.js +34 -34
- package/dist/safe-bash-contracts/io.js +2 -2
- 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 +53 -0
- package/dist/safe-bash-diff-engine/shared.js +19 -0
- 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/text-programs/shared.js +20 -31
- package/dist/safe-bash-io-engine/shell/pattern.js +7 -12
- 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 +6 -0
- package/dist/safe-bash-mcp/index.browser.js +1 -0
- package/dist/safe-bash-mcp/index.d.ts +12 -0
- package/dist/safe-bash-mcp/index.js +1558 -36
- 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 +81 -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 +37 -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 +4 -4
- package/dist/safe-bash-regex-engine/index.js +2 -2
- package/dist/safe-bash-regex-engine/text/regex.d.ts +1 -0
- package/dist/safe-bash-regex-engine/text/regex.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 +2 -2
- 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-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 +2 -2
- 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/io/publication.d.ts +1 -0
- package/package.json +163 -14
- 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-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/chunks/{chunk-NHOXKQNE.js → chunk-QVSRRNZT.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-FIUFIDAO.js → chunk-2JRBIDAD.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-B5BKA5WH.js → chunk-B5TAOCKD.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-TYVCKQDH.js → chunk-J5SN3PZ3.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-2WRTLCGK.js → chunk-QZF3SINC.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-X7TM3AKW.js → chunk-U6G67N23.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,1648 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { tryReadMemoryFileViewSync } from "@poe-platform/safe-fs/core";
|
|
3
|
-
import { FsError, writeBytes } from "../../contracts/index.js";
|
|
4
|
-
import { writeFileOutput } from "../../contracts/filesystem-output.js";
|
|
5
|
-
import { Pattern, substitute, trySubstituteSync, trySubstitutePairSync, trySubstitutePairToBufferSync, trySubstitutePairBatchToBufferSync } from "./regex.js";
|
|
6
|
-
import { Budget, ProgramError, byteString, bytes, command, getCachedLatin1Batch, input, lineRecordBatches, readProgram, virtualPath, write } from "./shared.js";
|
|
7
|
-
import { assertPathRequirements, requiredFileInput, sedRequirements } from "../search/requirements.js";
|
|
8
|
-
import { pathOf } from "../internal.js";
|
|
9
|
-
import { editInPlace, prepareInPlace } from "./inplace.js";
|
|
10
|
-
const sedProgramCache = new Map();
|
|
11
|
-
const sedFastRawCache = new Map();
|
|
12
|
-
const EMPTY_STRINGS = Object.freeze([]);
|
|
13
|
-
const EMPTY_SET = new Set();
|
|
14
|
-
function tryParseFastPairProgramSync(rawProg, budget) {
|
|
15
|
-
if (rawProg.length > 256 || rawProg.startsWith("#n"))
|
|
16
|
-
return undefined;
|
|
17
|
-
const parts = rawProg.split(/[;\n]/);
|
|
18
|
-
const instructions = [];
|
|
19
|
-
const stepsBefore = budget.stepsUsed;
|
|
20
|
-
for (let i = 0; i < parts.length; i++) {
|
|
21
|
-
const part = parts[i].trim();
|
|
22
|
-
if (part.length === 0)
|
|
23
|
-
continue;
|
|
24
|
-
if (part.charCodeAt(0) !== 115 || part.length < 4)
|
|
25
|
-
return undefined;
|
|
26
|
-
const delim = part[1];
|
|
27
|
-
if (delim === "\\" || delim === "\n")
|
|
28
|
-
return undefined;
|
|
29
|
-
let p = 2;
|
|
30
|
-
let patStr = "";
|
|
31
|
-
while (p < part.length && part[p] !== delim) {
|
|
32
|
-
const ch = part[p++];
|
|
33
|
-
if (ch === "\\") {
|
|
34
|
-
if (p >= part.length)
|
|
35
|
-
return undefined;
|
|
36
|
-
const next = part[p++];
|
|
37
|
-
if (next === "[" || next === "]" || next === delim)
|
|
38
|
-
return undefined;
|
|
39
|
-
patStr += `\\${next}`;
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
if (ch === "[")
|
|
43
|
-
return undefined;
|
|
44
|
-
patStr += ch;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
if (p >= part.length || part[p] !== delim || patStr.length === 0)
|
|
48
|
-
return undefined;
|
|
49
|
-
p++;
|
|
50
|
-
let repStr = "";
|
|
51
|
-
let repGroupCount = 0;
|
|
52
|
-
while (p < part.length && part[p] !== delim) {
|
|
53
|
-
const ch = part[p++];
|
|
54
|
-
if (ch === "\\") {
|
|
55
|
-
if (p >= part.length)
|
|
56
|
-
return undefined;
|
|
57
|
-
const next = part[p++];
|
|
58
|
-
if (next === delim)
|
|
59
|
-
return undefined;
|
|
60
|
-
if (next >= "1" && next <= "9")
|
|
61
|
-
repGroupCount = Math.max(repGroupCount, Number(next));
|
|
62
|
-
repStr += `\\${next}`;
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
repStr += ch;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
if (p >= part.length || part[p] !== delim)
|
|
69
|
-
return undefined;
|
|
70
|
-
p++;
|
|
71
|
-
let global = false;
|
|
72
|
-
for (; p < part.length; p++) {
|
|
73
|
-
if (part[p] === "g" && !global)
|
|
74
|
-
global = true;
|
|
75
|
-
else
|
|
76
|
-
return undefined;
|
|
77
|
-
}
|
|
78
|
-
let compiled;
|
|
79
|
-
try {
|
|
80
|
-
compiled = new Pattern(patStr, false, false);
|
|
81
|
-
}
|
|
82
|
-
catch {
|
|
83
|
-
return undefined;
|
|
84
|
-
}
|
|
85
|
-
const compiledInternal = compiled;
|
|
86
|
-
if (compiledInternal.parsed || repGroupCount > compiled.groupCount)
|
|
87
|
-
return undefined;
|
|
88
|
-
if (!compiledInternal.budgetPrepared && (compiledInternal.compiledSteps ?? 0) > 0) {
|
|
89
|
-
compiledInternal.budgetPrepared = true;
|
|
90
|
-
budget.step(compiledInternal.compiledSteps);
|
|
91
|
-
}
|
|
92
|
-
instructions.push({
|
|
93
|
-
kind: "s",
|
|
94
|
-
negate: false,
|
|
95
|
-
pattern: compiled,
|
|
96
|
-
replacement: repStr,
|
|
97
|
-
replacementGroupCount: repGroupCount,
|
|
98
|
-
global,
|
|
99
|
-
});
|
|
100
|
-
if (instructions.length > 2)
|
|
101
|
-
return undefined;
|
|
102
|
-
}
|
|
103
|
-
if (instructions.length !== 2)
|
|
104
|
-
return undefined;
|
|
105
|
-
const steps = budget.stepsUsed - stepsBefore;
|
|
106
|
-
const cached = {
|
|
107
|
-
program: instructions,
|
|
108
|
-
steps,
|
|
109
|
-
outputFiles: EMPTY_STRINGS,
|
|
110
|
-
readFiles: EMPTY_STRINGS,
|
|
111
|
-
};
|
|
112
|
-
const cacheKey = `0:\n:${Infinity}:${rawProg}`;
|
|
113
|
-
if (sedProgramCache.size >= 64)
|
|
114
|
-
sedProgramCache.delete(sedProgramCache.keys().next().value);
|
|
115
|
-
sedProgramCache.set(cacheKey, cached);
|
|
116
|
-
sedFastRawCache.set(rawProg, cached);
|
|
117
|
-
return cached;
|
|
118
|
-
}
|
|
119
|
-
async function parse(source, extended, separator, maxProgramInstructions, budget) {
|
|
120
|
-
const result = [];
|
|
121
|
-
const groups = [];
|
|
122
|
-
const labels = new Map();
|
|
123
|
-
let offset = 0;
|
|
124
|
-
const horizontal = () => { while (source[offset] === " " || source[offset] === "\t" || source[offset] === "\r")
|
|
125
|
-
offset++; };
|
|
126
|
-
const delimited = (delimiter, regex = false) => {
|
|
127
|
-
let text = "";
|
|
128
|
-
let bracket = false;
|
|
129
|
-
let first = 0;
|
|
130
|
-
let special = "";
|
|
131
|
-
while (offset < source.length) {
|
|
132
|
-
const character = source[offset++];
|
|
133
|
-
if (character === delimiter && !bracket)
|
|
134
|
-
return text;
|
|
135
|
-
if (character === "\\") {
|
|
136
|
-
if (bracket && source[offset] !== delimiter && source[offset] !== "\n") {
|
|
137
|
-
text += "\\";
|
|
138
|
-
first = 0;
|
|
139
|
-
continue;
|
|
140
|
-
}
|
|
141
|
-
const next = source[offset++];
|
|
142
|
-
if (next === undefined)
|
|
143
|
-
break;
|
|
144
|
-
text += next === "\n"
|
|
145
|
-
|| (!bracket && next === delimiter && (regex ? (!extended && "()|+?{}".includes(next)) || "ntrfva".includes(next) : (next === "n" || next === "t" || (next >= "0" && next <= "9"))))
|
|
146
|
-
? next : `\\${next}`;
|
|
147
|
-
if (bracket)
|
|
148
|
-
first = 0;
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
if (character === "\n")
|
|
152
|
-
throw new ProgramError("unterminated delimited expression");
|
|
153
|
-
if (regex) {
|
|
154
|
-
if (!bracket && character === "[") {
|
|
155
|
-
bracket = true;
|
|
156
|
-
first = 2;
|
|
157
|
-
}
|
|
158
|
-
else if (bracket) {
|
|
159
|
-
if (special) {
|
|
160
|
-
if (character === special && source[offset] === "]") {
|
|
161
|
-
text += character + source[offset++];
|
|
162
|
-
special = "";
|
|
163
|
-
continue;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
else if (character === "[" && [":", ".", "="].includes(source[offset] ?? "")) {
|
|
167
|
-
special = source[offset++];
|
|
168
|
-
text += character + special;
|
|
169
|
-
first = 0;
|
|
170
|
-
continue;
|
|
171
|
-
}
|
|
172
|
-
else if (character === "]" && !first)
|
|
173
|
-
bracket = false;
|
|
174
|
-
first = first === 2 && character === "^" ? 1 : 0;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
text += character;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
throw new ProgramError(bracket ? "unterminated bracket expression" : "unterminated delimited expression");
|
|
181
|
-
};
|
|
182
|
-
const address = async () => {
|
|
183
|
-
horizontal();
|
|
184
|
-
const number = /^[0-9]+/u.exec(source.slice(offset));
|
|
185
|
-
if (number) {
|
|
186
|
-
offset += number[0].length;
|
|
187
|
-
const value = Number(number[0]);
|
|
188
|
-
if (!Number.isSafeInteger(value))
|
|
189
|
-
throw new ProgramError("sed line address exceeds safe integer range");
|
|
190
|
-
if (source[offset] === "~") {
|
|
191
|
-
offset++;
|
|
192
|
-
const stepMatch = /^[0-9]+/u.exec(source.slice(offset));
|
|
193
|
-
if (!stepMatch)
|
|
194
|
-
throw new ProgramError("invalid step address");
|
|
195
|
-
offset += stepMatch[0].length;
|
|
196
|
-
const step = Number(stepMatch[0]);
|
|
197
|
-
if (!Number.isSafeInteger(step))
|
|
198
|
-
throw new ProgramError("sed line address exceeds safe integer range");
|
|
199
|
-
return { kind: "step", first: value, step };
|
|
200
|
-
}
|
|
201
|
-
return { kind: "number", number: value };
|
|
202
|
-
}
|
|
203
|
-
if (source[offset] === "$") {
|
|
204
|
-
offset++;
|
|
205
|
-
return { kind: "last" };
|
|
206
|
-
}
|
|
207
|
-
let delimiter;
|
|
208
|
-
if (source[offset] === "/")
|
|
209
|
-
delimiter = source[offset++];
|
|
210
|
-
else if (source[offset] === "\\" && source[offset + 1] && source[offset + 1] !== "\n") {
|
|
211
|
-
offset++;
|
|
212
|
-
delimiter = source[offset++];
|
|
213
|
-
}
|
|
214
|
-
if (delimiter !== undefined) {
|
|
215
|
-
const pattern = delimited(delimiter, true);
|
|
216
|
-
const ignoreCase = source[offset] === "I";
|
|
217
|
-
if (ignoreCase)
|
|
218
|
-
offset++;
|
|
219
|
-
if (!pattern && ignoreCase)
|
|
220
|
-
throw new ProgramError("flags on an empty regex are not supported");
|
|
221
|
-
const compiled = pattern ? new Pattern(pattern, extended, ignoreCase) : undefined;
|
|
222
|
-
if (compiled)
|
|
223
|
-
await compiled.prepare(budget);
|
|
224
|
-
return { kind: "regex", pattern: compiled };
|
|
225
|
-
}
|
|
226
|
-
return undefined;
|
|
227
|
-
};
|
|
228
|
-
const label = () => {
|
|
229
|
-
horizontal();
|
|
230
|
-
const start = offset;
|
|
231
|
-
while (offset < source.length && ![";", "\n", "}"].includes(source[offset]))
|
|
232
|
-
offset++;
|
|
233
|
-
const text = source.slice(start, offset).trim();
|
|
234
|
-
return text;
|
|
235
|
-
};
|
|
236
|
-
const textArgument = (terminator) => {
|
|
237
|
-
horizontal();
|
|
238
|
-
if (source[offset] === "\\") {
|
|
239
|
-
offset++;
|
|
240
|
-
if (source[offset] === "\n")
|
|
241
|
-
offset++;
|
|
242
|
-
}
|
|
243
|
-
let text = "";
|
|
244
|
-
while (offset < source.length && source[offset] !== "\n") {
|
|
245
|
-
const character = source[offset++];
|
|
246
|
-
if (character === "\\" && offset < source.length) {
|
|
247
|
-
const next = source[offset++];
|
|
248
|
-
text += next === "n" ? "\n" : next === "t" ? "\t" : next;
|
|
249
|
-
}
|
|
250
|
-
else
|
|
251
|
-
text += character;
|
|
252
|
-
}
|
|
253
|
-
return text + terminator;
|
|
254
|
-
};
|
|
255
|
-
const fileArgument = () => {
|
|
256
|
-
horizontal();
|
|
257
|
-
const start = offset;
|
|
258
|
-
while (offset < source.length && source[offset] !== "\n")
|
|
259
|
-
offset++;
|
|
260
|
-
const file = decodeBytes(encodeBytes(source.slice(start, offset), "latin1"), "utf8");
|
|
261
|
-
if (!file || file.includes("\0"))
|
|
262
|
-
throw new ProgramError("file command requires a nonempty filename without NUL");
|
|
263
|
-
return file;
|
|
264
|
-
};
|
|
265
|
-
while (offset < source.length) {
|
|
266
|
-
horizontal();
|
|
267
|
-
if (source[offset] === ";" || source[offset] === "\n") {
|
|
268
|
-
offset++;
|
|
269
|
-
continue;
|
|
270
|
-
}
|
|
271
|
-
if (source[offset] === "#") {
|
|
272
|
-
while (offset < source.length && source[offset] !== "\n")
|
|
273
|
-
offset++;
|
|
274
|
-
continue;
|
|
275
|
-
}
|
|
276
|
-
if (offset === source.length)
|
|
277
|
-
break;
|
|
278
|
-
if (result.length >= maxProgramInstructions)
|
|
279
|
-
throw new ProgramError("program instruction limit exceeded");
|
|
280
|
-
const first = await address();
|
|
281
|
-
horizontal();
|
|
282
|
-
let second;
|
|
283
|
-
if (source[offset] === ",") {
|
|
284
|
-
offset++;
|
|
285
|
-
horizontal();
|
|
286
|
-
if (source[offset] === "+" || source[offset] === "~") {
|
|
287
|
-
const relKind = source[offset];
|
|
288
|
-
const relMatch = /^[0-9]+/u.exec(source.slice(offset + 1));
|
|
289
|
-
if (relMatch) {
|
|
290
|
-
offset += 1 + relMatch[0].length;
|
|
291
|
-
const count = Number(relMatch[0]);
|
|
292
|
-
if (!Number.isSafeInteger(count))
|
|
293
|
-
throw new ProgramError("sed line address exceeds safe integer range");
|
|
294
|
-
second = { kind: relKind === "+" ? "plus" : "tilde", count };
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
if (!second)
|
|
298
|
-
second = await address();
|
|
299
|
-
if (!first || !second)
|
|
300
|
-
throw new ProgramError("invalid address range");
|
|
301
|
-
}
|
|
302
|
-
if (first?.kind === "number" && first.number === 0 && second?.kind !== "regex" || second?.kind === "number" && second.number === 0)
|
|
303
|
-
throw new ProgramError("zero address requires a 0,/regex/ range");
|
|
304
|
-
horizontal();
|
|
305
|
-
const negate = source[offset] === "!";
|
|
306
|
-
if (negate) {
|
|
307
|
-
offset++;
|
|
308
|
-
horizontal();
|
|
309
|
-
}
|
|
310
|
-
const kind = source[offset++];
|
|
311
|
-
if (kind === undefined)
|
|
312
|
-
throw new ProgramError("missing sed command");
|
|
313
|
-
const instruction = { kind, negate, ...(first ? { first } : {}), ...(second ? { second } : {}) };
|
|
314
|
-
if (kind === "{") {
|
|
315
|
-
groups.push(result.length);
|
|
316
|
-
result.push(instruction);
|
|
317
|
-
continue;
|
|
318
|
-
}
|
|
319
|
-
if (kind === "}") {
|
|
320
|
-
if (first || negate)
|
|
321
|
-
throw new ProgramError("closing group cannot have an address");
|
|
322
|
-
const start = groups.pop();
|
|
323
|
-
if (start === undefined)
|
|
324
|
-
throw new ProgramError("unmatched '}'");
|
|
325
|
-
result[start].jump = result.length + 1;
|
|
326
|
-
}
|
|
327
|
-
else if (kind === "s") {
|
|
328
|
-
const delimiter = source[offset++];
|
|
329
|
-
if (!delimiter || delimiter === "\\" || delimiter === "\n")
|
|
330
|
-
throw new ProgramError("invalid substitution delimiter");
|
|
331
|
-
const pattern = delimited(delimiter, true);
|
|
332
|
-
instruction.replacement = delimited(delimiter);
|
|
333
|
-
instruction.replacementGroupCount = 0;
|
|
334
|
-
for (let index = 0; index < instruction.replacement.length; index++) {
|
|
335
|
-
if (instruction.replacement[index] !== "\\")
|
|
336
|
-
continue;
|
|
337
|
-
const escaped = instruction.replacement[++index];
|
|
338
|
-
if (escaped !== undefined && escaped >= "1" && escaped <= "9") {
|
|
339
|
-
instruction.replacementGroupCount = Math.max(instruction.replacementGroupCount, Number(escaped));
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
let ignoreCase = false;
|
|
343
|
-
while (offset < source.length && ![";", "\n", "}", " ", "\t", "#"].includes(source[offset])) {
|
|
344
|
-
const flag = source[offset++];
|
|
345
|
-
if (flag === "g" && !instruction.global)
|
|
346
|
-
instruction.global = true;
|
|
347
|
-
else if (flag === "p" && !instruction.print)
|
|
348
|
-
instruction.print = true;
|
|
349
|
-
else if ((flag === "i" || flag === "I") && !ignoreCase)
|
|
350
|
-
ignoreCase = true;
|
|
351
|
-
else if (flag === "w" && instruction.file === undefined) {
|
|
352
|
-
instruction.file = fileArgument();
|
|
353
|
-
break;
|
|
354
|
-
}
|
|
355
|
-
else if (/^[1-9]$/u.test(flag) && instruction.occurrence === undefined) {
|
|
356
|
-
const rest = /^[0-9]*/u.exec(source.slice(offset))[0];
|
|
357
|
-
offset += rest.length;
|
|
358
|
-
instruction.occurrence = Number(flag + rest);
|
|
359
|
-
if (!Number.isSafeInteger(instruction.occurrence))
|
|
360
|
-
throw new ProgramError("invalid substitution occurrence");
|
|
361
|
-
}
|
|
362
|
-
else
|
|
363
|
-
throw new ProgramError(`unsupported substitution flag '${flag}'`);
|
|
364
|
-
}
|
|
365
|
-
if (!pattern && ignoreCase)
|
|
366
|
-
throw new ProgramError("flags on an empty regex are not supported");
|
|
367
|
-
if (pattern) {
|
|
368
|
-
instruction.pattern = new Pattern(pattern, extended, ignoreCase);
|
|
369
|
-
if (instruction.replacementGroupCount > instruction.pattern.groupCount)
|
|
370
|
-
throw new ProgramError("replacement references an undefined capture group");
|
|
371
|
-
await instruction.pattern.prepare(budget);
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
else if (kind === "r" || kind === "w") {
|
|
375
|
-
if (kind === "r" && second)
|
|
376
|
-
throw new ProgramError("read accepts at most one address");
|
|
377
|
-
instruction.file = fileArgument();
|
|
378
|
-
}
|
|
379
|
-
else if (kind === "a" || kind === "i" || kind === "c")
|
|
380
|
-
instruction.text = textArgument(kind === "a" ? "\n" : separator);
|
|
381
|
-
else if (kind === "b" || kind === "t" || kind === "T" || kind === ":") {
|
|
382
|
-
instruction.text = label();
|
|
383
|
-
if (first && kind === ":")
|
|
384
|
-
throw new ProgramError("labels cannot have addresses");
|
|
385
|
-
if (kind === ":") {
|
|
386
|
-
if (!instruction.text || labels.has(instruction.text))
|
|
387
|
-
throw new ProgramError("empty or duplicate branch label");
|
|
388
|
-
labels.set(instruction.text, result.length);
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
else if (kind === "q" || kind === "Q") {
|
|
392
|
-
if (second)
|
|
393
|
-
throw new ProgramError("quit accepts at most one address");
|
|
394
|
-
horizontal();
|
|
395
|
-
const status = /^[0-9]+/u.exec(source.slice(offset));
|
|
396
|
-
if (status) {
|
|
397
|
-
offset += status[0].length;
|
|
398
|
-
instruction.status = Number(status[0]);
|
|
399
|
-
if (instruction.status > 255)
|
|
400
|
-
throw new ProgramError("quit status exceeds 255");
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
else if (kind === "y") {
|
|
404
|
-
const delimiter = source[offset++];
|
|
405
|
-
if (!delimiter || delimiter === "\\" || delimiter === "\n")
|
|
406
|
-
throw new ProgramError("invalid translation delimiter");
|
|
407
|
-
const decode = (text) => text.replace(/\\(.)/gsu, (_whole, escaped) => escaped === "n" ? "\n" : escaped === "t" ? "\t" : escaped);
|
|
408
|
-
const from = decode(delimited(delimiter));
|
|
409
|
-
const to = decode(delimited(delimiter));
|
|
410
|
-
if (from.length !== to.length)
|
|
411
|
-
throw new ProgramError("translation sets have different lengths");
|
|
412
|
-
instruction.translation = new Map([...from].map((character, index) => [character, to[index]]));
|
|
413
|
-
}
|
|
414
|
-
else if (!"pdDPhHgGxnN=lzF".includes(kind))
|
|
415
|
-
throw new ProgramError(`unsupported sed command '${kind}'`);
|
|
416
|
-
result.push(instruction);
|
|
417
|
-
horizontal();
|
|
418
|
-
if (offset < source.length && ![";", "\n", "}", "#"].includes(source[offset]))
|
|
419
|
-
throw new ProgramError(`unexpected text after '${kind}' command`);
|
|
420
|
-
}
|
|
421
|
-
if (groups.length)
|
|
422
|
-
throw new ProgramError("unclosed sed group");
|
|
423
|
-
for (const instruction of result)
|
|
424
|
-
if (["b", "t", "T"].includes(instruction.kind)) {
|
|
425
|
-
const target = instruction.text ? labels.get(instruction.text) : result.length;
|
|
426
|
-
if (target === undefined)
|
|
427
|
-
throw new ProgramError(`undefined branch label '${instruction.text}'`);
|
|
428
|
-
instruction.jump = target;
|
|
429
|
-
}
|
|
430
|
-
return result;
|
|
431
|
-
}
|
|
432
|
-
async function* nullRecords(context, files, budget) {
|
|
433
|
-
const names = files.length ? files : ["-"];
|
|
434
|
-
for (let fileIndex = 0; fileIndex < names.length; fileIndex++) {
|
|
435
|
-
const file = names[fileIndex];
|
|
436
|
-
let pending = "";
|
|
437
|
-
for await (const chunk of input(context, file)) {
|
|
438
|
-
budget.step();
|
|
439
|
-
let start = 0;
|
|
440
|
-
while (start < chunk.byteLength) {
|
|
441
|
-
const end = chunk.indexOf(0, start);
|
|
442
|
-
const stop = end < 0 ? chunk.byteLength : end;
|
|
443
|
-
if (pending.length + stop - start > budget.maxBufferBytes)
|
|
444
|
-
throw new ProgramError("text buffer limit exceeded");
|
|
445
|
-
pending += decodeBytes(encodeBytes(chunk.subarray(start, stop)), "latin1");
|
|
446
|
-
if (end < 0)
|
|
447
|
-
break;
|
|
448
|
-
yield { text: pending, terminated: true, file, fileIndex };
|
|
449
|
-
pending = "";
|
|
450
|
-
start = end + 1;
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
if (pending)
|
|
454
|
-
yield { text: pending, terminated: false, file, fileIndex };
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
const STDOUT_CAP = 65536;
|
|
458
|
-
const STDOUT_FLUSH = 60000;
|
|
459
|
-
let sharedSedStdoutBuf;
|
|
460
|
-
let sharedSedStdoutBufInUse = false;
|
|
461
|
-
let lastSedPairProgram;
|
|
462
|
-
let lastSedPairBatch;
|
|
463
|
-
let lastSedPairStdoutLen = 0;
|
|
464
|
-
let lastSedPairSavedOutBuf;
|
|
465
|
-
let lastSedPairSteps = 0;
|
|
466
|
-
let lastSedPairStdoutIntact = false;
|
|
467
|
-
let sedPairBimodalWarm = 0;
|
|
468
|
-
async function execute(program, context, files, quiet, budget, separator, outputState, lineLength) {
|
|
469
|
-
const useBatches = separator !== "\0";
|
|
470
|
-
const batchSource = useBatches ? lineRecordBatches(context, files, budget) : undefined;
|
|
471
|
-
const singleSource = useBatches ? undefined : nullRecords(context, files, budget);
|
|
472
|
-
let currentBatch;
|
|
473
|
-
let currentBatchLen = 0;
|
|
474
|
-
let batchIndex = 0;
|
|
475
|
-
const sharedBatchRecord = {
|
|
476
|
-
text: "",
|
|
477
|
-
terminated: true,
|
|
478
|
-
file: "",
|
|
479
|
-
fileIndex: 0,
|
|
480
|
-
};
|
|
481
|
-
const fillFromBatch = (batch, idx, target) => {
|
|
482
|
-
if (idx < batch.ends.length) {
|
|
483
|
-
const start = idx === 0 ? 0 : batch.ends[idx - 1] + 1;
|
|
484
|
-
const end = batch.ends[idx];
|
|
485
|
-
const slice = batch.text.slice(start, end);
|
|
486
|
-
target.text = idx === 0 && batch.firstLinePrefix ? batch.firstLinePrefix + slice : slice;
|
|
487
|
-
target.terminated = true;
|
|
488
|
-
}
|
|
489
|
-
else {
|
|
490
|
-
target.text = batch.trailingText;
|
|
491
|
-
target.terminated = false;
|
|
492
|
-
}
|
|
493
|
-
target.file = batch.file;
|
|
494
|
-
target.fileIndex = batch.fileIndex;
|
|
495
|
-
return target;
|
|
496
|
-
};
|
|
497
|
-
let currentRecord;
|
|
498
|
-
let followingRecord;
|
|
499
|
-
if (batchSource) {
|
|
500
|
-
const firstBatch = await batchSource.next();
|
|
501
|
-
if (!firstBatch.done) {
|
|
502
|
-
currentBatch = firstBatch.value;
|
|
503
|
-
currentBatchLen = currentBatch.ends.length + (currentBatch.trailingText !== undefined ? 1 : 0);
|
|
504
|
-
if (currentBatchLen > 0) {
|
|
505
|
-
currentRecord = fillFromBatch(currentBatch, 0, sharedBatchRecord);
|
|
506
|
-
batchIndex = 1;
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
else {
|
|
511
|
-
const first = await singleSource.next();
|
|
512
|
-
if (!first.done)
|
|
513
|
-
currentRecord = first.value;
|
|
514
|
-
}
|
|
515
|
-
const peekNextRecord = async () => {
|
|
516
|
-
if (followingRecord !== undefined)
|
|
517
|
-
return followingRecord ?? undefined;
|
|
518
|
-
if (batchSource) {
|
|
519
|
-
if (currentBatch && batchIndex < currentBatchLen) {
|
|
520
|
-
followingRecord = fillFromBatch(currentBatch, batchIndex, { text: "", terminated: true, file: "", fileIndex: 0 });
|
|
521
|
-
return followingRecord;
|
|
522
|
-
}
|
|
523
|
-
const nextBatch = await batchSource.next();
|
|
524
|
-
if (nextBatch.done) {
|
|
525
|
-
followingRecord = null;
|
|
526
|
-
return undefined;
|
|
527
|
-
}
|
|
528
|
-
currentBatch = nextBatch.value;
|
|
529
|
-
currentBatchLen = currentBatch.ends.length + (currentBatch.trailingText !== undefined ? 1 : 0);
|
|
530
|
-
if (currentBatchLen === 0) {
|
|
531
|
-
followingRecord = null;
|
|
532
|
-
return undefined;
|
|
533
|
-
}
|
|
534
|
-
batchIndex = 0;
|
|
535
|
-
followingRecord = fillFromBatch(currentBatch, 0, { text: "", terminated: true, file: "", fileIndex: 0 });
|
|
536
|
-
return followingRecord;
|
|
537
|
-
}
|
|
538
|
-
const next = await singleSource.next();
|
|
539
|
-
followingRecord = next.done ? null : next.value;
|
|
540
|
-
return followingRecord ?? undefined;
|
|
541
|
-
};
|
|
542
|
-
const readNextRecord = async () => {
|
|
543
|
-
if (followingRecord !== undefined) {
|
|
544
|
-
const next = followingRecord ?? undefined;
|
|
545
|
-
followingRecord = undefined;
|
|
546
|
-
if (batchSource && next !== undefined && currentBatch && batchIndex < currentBatchLen) {
|
|
547
|
-
batchIndex++;
|
|
548
|
-
}
|
|
549
|
-
return next;
|
|
550
|
-
}
|
|
551
|
-
if (batchSource) {
|
|
552
|
-
if (currentBatch && batchIndex < currentBatchLen) {
|
|
553
|
-
return fillFromBatch(currentBatch, batchIndex++, sharedBatchRecord);
|
|
554
|
-
}
|
|
555
|
-
const nextBatch = await batchSource.next();
|
|
556
|
-
if (nextBatch.done)
|
|
557
|
-
return undefined;
|
|
558
|
-
currentBatch = nextBatch.value;
|
|
559
|
-
currentBatchLen = currentBatch.ends.length + (currentBatch.trailingText !== undefined ? 1 : 0);
|
|
560
|
-
if (currentBatchLen === 0)
|
|
561
|
-
return undefined;
|
|
562
|
-
batchIndex = 1;
|
|
563
|
-
return fillFromBatch(currentBatch, 0, sharedBatchRecord);
|
|
564
|
-
}
|
|
565
|
-
const next = await singleSource.next();
|
|
566
|
-
return next.done ? undefined : next.value;
|
|
567
|
-
};
|
|
568
|
-
const prepareRecord = async (record) => {
|
|
569
|
-
if (record.terminated || files.length < 2)
|
|
570
|
-
return record;
|
|
571
|
-
const next = await peekNextRecord();
|
|
572
|
-
return next !== undefined && next.fileIndex !== record.fileIndex ? { ...record, terminated: true } : record;
|
|
573
|
-
};
|
|
574
|
-
let number = 0;
|
|
575
|
-
let hold = "";
|
|
576
|
-
let holdTerminated = true;
|
|
577
|
-
const STDOUT_CAP = 65536;
|
|
578
|
-
const STDOUT_FLUSH = 60000;
|
|
579
|
-
const stdoutSync = typeof context.stdout.writeSync === "function"
|
|
580
|
-
? context.stdout
|
|
581
|
-
: undefined;
|
|
582
|
-
const canReuseStdoutBuf = !context.stdout.isPipeStage;
|
|
583
|
-
let usingSharedStdoutBuf = false;
|
|
584
|
-
let stdoutBuf;
|
|
585
|
-
if (canReuseStdoutBuf && !sharedSedStdoutBufInUse) {
|
|
586
|
-
sharedSedStdoutBufInUse = true;
|
|
587
|
-
usingSharedStdoutBuf = true;
|
|
588
|
-
if (!sharedSedStdoutBuf) {
|
|
589
|
-
sharedSedStdoutBuf = new Uint8Array(STDOUT_CAP);
|
|
590
|
-
}
|
|
591
|
-
stdoutBuf = sharedSedStdoutBuf;
|
|
592
|
-
}
|
|
593
|
-
let stdoutLen = 0;
|
|
594
|
-
const sepCode = separator.charCodeAt(0) & 0xff;
|
|
595
|
-
const appendStdout = (text) => {
|
|
596
|
-
const tLen = text.length;
|
|
597
|
-
if (tLen === 0)
|
|
598
|
-
return;
|
|
599
|
-
if (!stdoutBuf) {
|
|
600
|
-
stdoutBuf = new Uint8Array(Math.max(STDOUT_CAP, tLen + 1));
|
|
601
|
-
}
|
|
602
|
-
else if (stdoutLen + tLen > stdoutBuf.length) {
|
|
603
|
-
const grown = new Uint8Array(Math.max(stdoutBuf.length * 2, stdoutLen + tLen + 1));
|
|
604
|
-
grown.set(stdoutBuf.subarray(0, stdoutLen), 0);
|
|
605
|
-
stdoutBuf = grown;
|
|
606
|
-
}
|
|
607
|
-
writeEncodedBytes(stdoutBuf, text, stdoutLen, tLen, "latin1");
|
|
608
|
-
stdoutLen += tLen;
|
|
609
|
-
};
|
|
610
|
-
const appendStdoutSep = () => {
|
|
611
|
-
if (!stdoutBuf) {
|
|
612
|
-
stdoutBuf = new Uint8Array(STDOUT_CAP);
|
|
613
|
-
}
|
|
614
|
-
else if (stdoutLen + 1 > stdoutBuf.length) {
|
|
615
|
-
const grown = new Uint8Array(stdoutBuf.length * 2);
|
|
616
|
-
grown.set(stdoutBuf.subarray(0, stdoutLen), 0);
|
|
617
|
-
stdoutBuf = grown;
|
|
618
|
-
}
|
|
619
|
-
stdoutBuf[stdoutLen++] = sepCode;
|
|
620
|
-
};
|
|
621
|
-
const flushStdout = () => {
|
|
622
|
-
if (stdoutLen > 0 && stdoutBuf) {
|
|
623
|
-
const flushedLen = stdoutLen;
|
|
624
|
-
const chunk = new Uint8Array(stdoutBuf.buffer, stdoutBuf.byteOffset, flushedLen);
|
|
625
|
-
stdoutLen = 0;
|
|
626
|
-
context.signal.throwIfAborted();
|
|
627
|
-
if (stdoutSync) {
|
|
628
|
-
stdoutSync.writeSync(chunk);
|
|
629
|
-
return undefined;
|
|
630
|
-
}
|
|
631
|
-
return writeBytes(context.stdout, encodeBytes(chunk), context.signal);
|
|
632
|
-
}
|
|
633
|
-
return undefined;
|
|
634
|
-
};
|
|
635
|
-
const joinSpace = (left, right) => {
|
|
636
|
-
if (left.length + separator.length + right.length > budget.maxBufferBytes)
|
|
637
|
-
throw new ProgramError("text buffer limit exceeded");
|
|
638
|
-
return left + separator + right;
|
|
639
|
-
};
|
|
640
|
-
const emit = (text, terminated = true) => {
|
|
641
|
-
if (outputState.stdoutUnterminated)
|
|
642
|
-
appendStdoutSep();
|
|
643
|
-
appendStdout(text);
|
|
644
|
-
outputState.stdoutUnterminated = !terminated;
|
|
645
|
-
if (!useBatches || stdoutLen >= STDOUT_FLUSH)
|
|
646
|
-
return flushStdout();
|
|
647
|
-
return undefined;
|
|
648
|
-
};
|
|
649
|
-
let lastPattern;
|
|
650
|
-
const active = new Map();
|
|
651
|
-
for (let pc = 0; pc < program.length; pc++) {
|
|
652
|
-
const first = program[pc].first;
|
|
653
|
-
if (first?.kind === "number" && first.number === 0)
|
|
654
|
-
active.set(pc, 0);
|
|
655
|
-
}
|
|
656
|
-
const getPattern = (pattern) => {
|
|
657
|
-
if (pattern)
|
|
658
|
-
lastPattern = pattern;
|
|
659
|
-
if (!lastPattern)
|
|
660
|
-
throw new ProgramError("no previous regular expression");
|
|
661
|
-
return lastPattern;
|
|
662
|
-
};
|
|
663
|
-
const appended = [];
|
|
664
|
-
let appendedSize = 0;
|
|
665
|
-
const append = (item) => {
|
|
666
|
-
appendedSize += (item.text ?? item.file ?? "").length + 32;
|
|
667
|
-
if (appendedSize > budget.maxBufferBytes)
|
|
668
|
-
throw new ProgramError("append queue buffer limit exceeded");
|
|
669
|
-
appended.push(item);
|
|
670
|
-
};
|
|
671
|
-
let record;
|
|
672
|
-
let pattern = "";
|
|
673
|
-
let substituted = false;
|
|
674
|
-
let deleted = false;
|
|
675
|
-
let quit = false;
|
|
676
|
-
let status = 0;
|
|
677
|
-
const print = () => {
|
|
678
|
-
if (outputState.stdoutUnterminated)
|
|
679
|
-
appendStdoutSep();
|
|
680
|
-
appendStdout(pattern);
|
|
681
|
-
if (record.terminated)
|
|
682
|
-
appendStdoutSep();
|
|
683
|
-
outputState.stdoutUnterminated = !record.terminated;
|
|
684
|
-
if (!useBatches || stdoutLen >= STDOUT_FLUSH)
|
|
685
|
-
return flushStdout();
|
|
686
|
-
return undefined;
|
|
687
|
-
};
|
|
688
|
-
const flushSlow = async (printPattern) => {
|
|
689
|
-
if (appended.length > 0) {
|
|
690
|
-
await assertPathRequirements(context, sedRequirements, ["script-read"], appended.flatMap(item => item.file === undefined ? [] : [item.file]));
|
|
691
|
-
}
|
|
692
|
-
if (printPattern && !quiet && !deleted) {
|
|
693
|
-
const p = print();
|
|
694
|
-
if (p)
|
|
695
|
-
await p;
|
|
696
|
-
}
|
|
697
|
-
if (outputState.stdoutUnterminated && (appended.length || quit)) {
|
|
698
|
-
appendStdoutSep();
|
|
699
|
-
if (stdoutLen >= STDOUT_FLUSH)
|
|
700
|
-
await flushStdout();
|
|
701
|
-
outputState.stdoutUnterminated = false;
|
|
702
|
-
}
|
|
703
|
-
for (const item of appended) {
|
|
704
|
-
if (item.text !== undefined) {
|
|
705
|
-
appendStdout(item.text);
|
|
706
|
-
if (stdoutLen >= STDOUT_FLUSH)
|
|
707
|
-
await flushStdout();
|
|
708
|
-
continue;
|
|
709
|
-
}
|
|
710
|
-
await flushStdout();
|
|
711
|
-
const path = virtualPath(context, item.file);
|
|
712
|
-
try {
|
|
713
|
-
for await (const chunk of requiredFileInput(context, sedRequirements, "script-read", path, budget.maxBufferBytes)) {
|
|
714
|
-
budget.step();
|
|
715
|
-
const pendingCheck = budget.checkpointSync();
|
|
716
|
-
if (pendingCheck)
|
|
717
|
-
await pendingCheck;
|
|
718
|
-
if (chunk.byteLength > budget.maxBufferBytes)
|
|
719
|
-
throw new ProgramError("read buffer limit exceeded");
|
|
720
|
-
await writeBytes(context.stdout, chunk, context.signal);
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
catch (error) {
|
|
724
|
-
context.signal.throwIfAborted();
|
|
725
|
-
if (!(error instanceof FsError) || !["ENOENT", "EACCES", "EPERM", "EISDIR", "ENOTDIR"].includes(error.code))
|
|
726
|
-
throw error;
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
appended.length = 0;
|
|
730
|
-
appendedSize = 0;
|
|
731
|
-
};
|
|
732
|
-
const flush = (printPattern = true) => {
|
|
733
|
-
if (appended.length === 0 && !quit) {
|
|
734
|
-
if (printPattern && !quiet && !deleted)
|
|
735
|
-
return print();
|
|
736
|
-
return undefined;
|
|
737
|
-
}
|
|
738
|
-
return flushSlow(printPattern);
|
|
739
|
-
};
|
|
740
|
-
const writeFile = async (file) => {
|
|
741
|
-
if (stdoutLen > 0)
|
|
742
|
-
await flushStdout();
|
|
743
|
-
const path = virtualPath(context, file);
|
|
744
|
-
const terminated = record.terminated || separator === "\n";
|
|
745
|
-
const text = (outputState.unterminatedFiles.has(path) ? separator : "") + pattern + (terminated ? separator : "");
|
|
746
|
-
await writeFileOutput(context, bytes(text), chunk => context.fs.appendFile(path, chunk, { signal: context.signal }));
|
|
747
|
-
if (terminated)
|
|
748
|
-
outputState.unterminatedFiles.delete(path);
|
|
749
|
-
else
|
|
750
|
-
outputState.unterminatedFiles.add(path);
|
|
751
|
-
};
|
|
752
|
-
const matches = (address) => {
|
|
753
|
-
if (address.kind === "number")
|
|
754
|
-
return number === address.number;
|
|
755
|
-
if (address.kind === "step")
|
|
756
|
-
return address.step === 0 ? number === address.first : number >= address.first && (number - address.first) % address.step === 0;
|
|
757
|
-
if (address.kind === "plus" || address.kind === "tilde")
|
|
758
|
-
return false;
|
|
759
|
-
if (address.kind === "last") {
|
|
760
|
-
if (batchSource && batchIndex < currentBatchLen)
|
|
761
|
-
return false;
|
|
762
|
-
return peekNextRecord().then(next => next === undefined);
|
|
763
|
-
}
|
|
764
|
-
return getPattern(address.pattern).tryTestSync(pattern, budget);
|
|
765
|
-
};
|
|
766
|
-
try {
|
|
767
|
-
while (currentRecord !== undefined) {
|
|
768
|
-
budget.step();
|
|
769
|
-
number++;
|
|
770
|
-
record = currentRecord.terminated || files.length < 2 ? currentRecord : await prepareRecord(currentRecord);
|
|
771
|
-
pattern = record.text;
|
|
772
|
-
substituted = false;
|
|
773
|
-
deleted = false;
|
|
774
|
-
quit = false;
|
|
775
|
-
status = 0;
|
|
776
|
-
for (let pc = 0; pc < program.length;) {
|
|
777
|
-
budget.step();
|
|
778
|
-
const instruction = program[pc];
|
|
779
|
-
if (number === 1 || (number & 31) === 0 || instruction.kind === "b" || instruction.kind === "t" || instruction.kind === "T" || instruction.kind === "D") {
|
|
780
|
-
const pendingCheck = budget.checkpointSync();
|
|
781
|
-
if (pendingCheck)
|
|
782
|
-
await pendingCheck;
|
|
783
|
-
}
|
|
784
|
-
let selected = true;
|
|
785
|
-
let ending = false;
|
|
786
|
-
if (instruction.first) {
|
|
787
|
-
if (instruction.second) {
|
|
788
|
-
if (active.has(pc)) {
|
|
789
|
-
const startLine = active.get(pc);
|
|
790
|
-
if (instruction.second.kind === "number" && number > instruction.second.number)
|
|
791
|
-
selected = false;
|
|
792
|
-
const endMatch = instruction.second.kind === "number" ? number >= instruction.second.number
|
|
793
|
-
: instruction.second.kind === "plus" ? number >= startLine + instruction.second.count
|
|
794
|
-
: instruction.second.kind === "tilde" ? (instruction.second.count === 0 || (number > startLine && number % instruction.second.count === 0))
|
|
795
|
-
: matches(instruction.second);
|
|
796
|
-
ending = endMatch instanceof Promise ? await endMatch : endMatch;
|
|
797
|
-
if (ending)
|
|
798
|
-
active.delete(pc);
|
|
799
|
-
}
|
|
800
|
-
else {
|
|
801
|
-
const firstMatch = matches(instruction.first);
|
|
802
|
-
selected = firstMatch instanceof Promise ? await firstMatch : firstMatch;
|
|
803
|
-
if (selected) {
|
|
804
|
-
ending = instruction.second.kind === "number" && number >= instruction.second.number
|
|
805
|
-
|| (instruction.second.kind === "plus" || instruction.second.kind === "tilde") && instruction.second.count === 0
|
|
806
|
-
|| instruction.second.kind === "last" && (await peekNextRecord()) === undefined;
|
|
807
|
-
if (!ending)
|
|
808
|
-
active.set(pc, number);
|
|
809
|
-
}
|
|
810
|
-
}
|
|
811
|
-
}
|
|
812
|
-
else {
|
|
813
|
-
const firstMatch = matches(instruction.first);
|
|
814
|
-
selected = firstMatch instanceof Promise ? await firstMatch : firstMatch;
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
if (instruction.negate)
|
|
818
|
-
selected = !selected;
|
|
819
|
-
if (!selected) {
|
|
820
|
-
pc = instruction.kind === "{" ? instruction.jump : pc + 1;
|
|
821
|
-
continue;
|
|
822
|
-
}
|
|
823
|
-
switch (instruction.kind) {
|
|
824
|
-
case "p": {
|
|
825
|
-
const p = print();
|
|
826
|
-
if (p)
|
|
827
|
-
await p;
|
|
828
|
-
break;
|
|
829
|
-
}
|
|
830
|
-
case "P": {
|
|
831
|
-
const end = pattern.indexOf(separator);
|
|
832
|
-
const p = emit(end < 0 ? pattern + (record.terminated ? separator : "") : pattern.slice(0, end + 1), end >= 0 || record.terminated);
|
|
833
|
-
if (p)
|
|
834
|
-
await p;
|
|
835
|
-
break;
|
|
836
|
-
}
|
|
837
|
-
case "=": {
|
|
838
|
-
const p = emit(`${number}${separator}`);
|
|
839
|
-
if (p)
|
|
840
|
-
await p;
|
|
841
|
-
break;
|
|
842
|
-
}
|
|
843
|
-
case "l": {
|
|
844
|
-
const escapes = { "\x07": "\\a", "\b": "\\b", "\f": "\\f", "\n": "\\n", "\r": "\\r", "\t": "\\t", "\v": "\\v", "\\": "\\\\" };
|
|
845
|
-
let line = "";
|
|
846
|
-
for (let offset = 0; offset <= pattern.length; offset++) {
|
|
847
|
-
budget.step();
|
|
848
|
-
await budget.checkpointSync();
|
|
849
|
-
const character = pattern[offset];
|
|
850
|
-
const lineEnd = character === "\n" && separator === "\n";
|
|
851
|
-
const token = character === undefined || lineEnd ? "$" : escapes[character] ?? (character.charCodeAt(0) < 32 || character.charCodeAt(0) >= 127 ? `\\${character.charCodeAt(0).toString(8).padStart(3, "0")}` : character);
|
|
852
|
-
// GNU sed reserves a column for continuation but appends the end marker without wrapping.
|
|
853
|
-
if (lineLength > 0 && character !== undefined && !lineEnd && line.length + token.length >= lineLength) {
|
|
854
|
-
await emit(line + "\\" + separator);
|
|
855
|
-
line = "";
|
|
856
|
-
}
|
|
857
|
-
line = budget.check(line + token);
|
|
858
|
-
if (lineEnd) {
|
|
859
|
-
await emit(line + separator);
|
|
860
|
-
line = "";
|
|
861
|
-
}
|
|
862
|
-
}
|
|
863
|
-
await emit(line + separator);
|
|
864
|
-
break;
|
|
865
|
-
}
|
|
866
|
-
case "d":
|
|
867
|
-
deleted = true;
|
|
868
|
-
pc = program.length;
|
|
869
|
-
continue;
|
|
870
|
-
case "D": {
|
|
871
|
-
const end = pattern.indexOf(separator);
|
|
872
|
-
if (end < 0) {
|
|
873
|
-
deleted = true;
|
|
874
|
-
pc = program.length;
|
|
875
|
-
}
|
|
876
|
-
else {
|
|
877
|
-
pattern = pattern.slice(end + 1);
|
|
878
|
-
pc = 0;
|
|
879
|
-
}
|
|
880
|
-
continue;
|
|
881
|
-
}
|
|
882
|
-
case "q":
|
|
883
|
-
quit = true;
|
|
884
|
-
status = instruction.status ?? 0;
|
|
885
|
-
pc = program.length;
|
|
886
|
-
continue;
|
|
887
|
-
case "Q":
|
|
888
|
-
deleted = true;
|
|
889
|
-
quit = true;
|
|
890
|
-
status = instruction.status ?? 0;
|
|
891
|
-
pc = program.length;
|
|
892
|
-
continue;
|
|
893
|
-
case "z":
|
|
894
|
-
pattern = "";
|
|
895
|
-
break;
|
|
896
|
-
case "F": {
|
|
897
|
-
const p = emit(`${record.file}${separator}`);
|
|
898
|
-
if (p)
|
|
899
|
-
await p;
|
|
900
|
-
break;
|
|
901
|
-
}
|
|
902
|
-
case "a":
|
|
903
|
-
append({ text: instruction.text });
|
|
904
|
-
break;
|
|
905
|
-
case "r":
|
|
906
|
-
append({ file: instruction.file });
|
|
907
|
-
break;
|
|
908
|
-
case "w":
|
|
909
|
-
await writeFile(instruction.file);
|
|
910
|
-
break;
|
|
911
|
-
case "i":
|
|
912
|
-
await emit(instruction.text);
|
|
913
|
-
break;
|
|
914
|
-
case "c":
|
|
915
|
-
if (!instruction.second || ending || instruction.negate || (await peekNextRecord()) === undefined)
|
|
916
|
-
await emit(instruction.text);
|
|
917
|
-
deleted = true;
|
|
918
|
-
pc = program.length;
|
|
919
|
-
continue;
|
|
920
|
-
case "h":
|
|
921
|
-
hold = pattern;
|
|
922
|
-
holdTerminated = record.terminated;
|
|
923
|
-
break;
|
|
924
|
-
case "H":
|
|
925
|
-
hold = joinSpace(hold, pattern);
|
|
926
|
-
holdTerminated = record.terminated;
|
|
927
|
-
break;
|
|
928
|
-
case "g":
|
|
929
|
-
pattern = hold;
|
|
930
|
-
record = { ...record, terminated: holdTerminated };
|
|
931
|
-
break;
|
|
932
|
-
case "G":
|
|
933
|
-
pattern = joinSpace(pattern, hold);
|
|
934
|
-
record = { ...record, terminated: holdTerminated };
|
|
935
|
-
break;
|
|
936
|
-
case "x": {
|
|
937
|
-
[pattern, hold] = [hold, pattern];
|
|
938
|
-
const terminated = record.terminated;
|
|
939
|
-
record = { ...record, terminated: holdTerminated };
|
|
940
|
-
holdTerminated = terminated;
|
|
941
|
-
break;
|
|
942
|
-
}
|
|
943
|
-
case "s": {
|
|
944
|
-
const expression = getPattern(instruction.pattern);
|
|
945
|
-
if (instruction.replacementGroupCount > expression.groupCount)
|
|
946
|
-
throw new ProgramError("replacement references an undefined capture group");
|
|
947
|
-
if (!instruction.print && !instruction.file && pc + 1 < program.length) {
|
|
948
|
-
const nextInst = program[pc + 1];
|
|
949
|
-
if (nextInst.kind === "s" && !nextInst.first && !nextInst.second && !nextInst.negate && !nextInst.print && !nextInst.file && nextInst.pattern) {
|
|
950
|
-
const nextExpr = nextInst.pattern;
|
|
951
|
-
if (nextInst.replacementGroupCount <= nextExpr.groupCount) {
|
|
952
|
-
const canPairAnchored = expression.getFastPrefixInfo()?.anchoredStart === true;
|
|
953
|
-
if (canPairAnchored &&
|
|
954
|
-
pc === 0 &&
|
|
955
|
-
program.length === 2 &&
|
|
956
|
-
!quiet &&
|
|
957
|
-
!deleted &&
|
|
958
|
-
appended.length === 0 &&
|
|
959
|
-
record.terminated &&
|
|
960
|
-
!outputState.stdoutUnterminated) {
|
|
961
|
-
if (!stdoutBuf)
|
|
962
|
-
stdoutBuf = new Uint8Array(STDOUT_CAP);
|
|
963
|
-
const newPosOrPromise = trySubstitutePairToBufferSync(pattern, expression, instruction.replacement, instruction.global ?? false, instruction.occurrence ?? 1, nextExpr, nextInst.replacement, nextInst.global ?? false, nextInst.occurrence ?? 1, budget, stdoutBuf, stdoutLen, sepCode);
|
|
964
|
-
const newPos = typeof newPosOrPromise === "number" ? newPosOrPromise : await newPosOrPromise;
|
|
965
|
-
if (newPos >= 0) {
|
|
966
|
-
lastPattern = nextExpr;
|
|
967
|
-
stdoutLen = newPos;
|
|
968
|
-
budget.step();
|
|
969
|
-
if (!useBatches || stdoutLen >= STDOUT_FLUSH) {
|
|
970
|
-
const p = flushStdout();
|
|
971
|
-
if (p)
|
|
972
|
-
await p;
|
|
973
|
-
}
|
|
974
|
-
if (batchSource && currentBatch && followingRecord === undefined) {
|
|
975
|
-
const batchText = currentBatch.text;
|
|
976
|
-
const batchEnds = currentBatch.ends;
|
|
977
|
-
const endsLen = batchEnds.length;
|
|
978
|
-
const g1 = instruction.global ?? false;
|
|
979
|
-
const o1 = instruction.occurrence ?? 1;
|
|
980
|
-
const r1 = instruction.replacement;
|
|
981
|
-
const g2 = nextInst.global ?? false;
|
|
982
|
-
const o2 = nextInst.occurrence ?? 1;
|
|
983
|
-
const r2 = nextInst.replacement;
|
|
984
|
-
while (batchIndex < endsLen) {
|
|
985
|
-
if (batchIndex === 0 && currentBatch.firstLinePrefix)
|
|
986
|
-
break;
|
|
987
|
-
const lStart = batchIndex === 0 ? 0 : batchEnds[batchIndex - 1] + 1;
|
|
988
|
-
const lEnd = batchEnds[batchIndex];
|
|
989
|
-
if (!stdoutBuf)
|
|
990
|
-
stdoutBuf = new Uint8Array(STDOUT_CAP);
|
|
991
|
-
const nextPosOrPromise = trySubstitutePairToBufferSync(batchText, expression, r1, g1, o1, nextExpr, r2, g2, o2, budget, stdoutBuf, stdoutLen, sepCode, lStart, lEnd);
|
|
992
|
-
const nextPos = typeof nextPosOrPromise === "number" ? nextPosOrPromise : await nextPosOrPromise;
|
|
993
|
-
if (nextPos < 0)
|
|
994
|
-
break;
|
|
995
|
-
batchIndex++;
|
|
996
|
-
number++;
|
|
997
|
-
budget.step(3);
|
|
998
|
-
if ((number & 31) === 0) {
|
|
999
|
-
const pendingCheck = budget.checkpointSync();
|
|
1000
|
-
if (pendingCheck)
|
|
1001
|
-
await pendingCheck;
|
|
1002
|
-
}
|
|
1003
|
-
stdoutLen = nextPos;
|
|
1004
|
-
if (stdoutLen >= STDOUT_FLUSH) {
|
|
1005
|
-
const p = flushStdout();
|
|
1006
|
-
if (p)
|
|
1007
|
-
await p;
|
|
1008
|
-
}
|
|
1009
|
-
}
|
|
1010
|
-
}
|
|
1011
|
-
deleted = true;
|
|
1012
|
-
pc += 2;
|
|
1013
|
-
continue;
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
1016
|
-
if (!canPairAnchored &&
|
|
1017
|
-
pc === 0 &&
|
|
1018
|
-
program.length === 2 &&
|
|
1019
|
-
!quiet &&
|
|
1020
|
-
!deleted &&
|
|
1021
|
-
appended.length === 0 &&
|
|
1022
|
-
record.terminated &&
|
|
1023
|
-
!outputState.stdoutUnterminated &&
|
|
1024
|
-
expression.canFindSync() &&
|
|
1025
|
-
nextExpr.canFindSync()) {
|
|
1026
|
-
const g1 = instruction.global ?? false;
|
|
1027
|
-
const o1 = instruction.occurrence ?? 1;
|
|
1028
|
-
const r1 = instruction.replacement;
|
|
1029
|
-
const g2 = nextInst.global ?? false;
|
|
1030
|
-
const o2 = nextInst.occurrence ?? 1;
|
|
1031
|
-
const r2 = nextInst.replacement;
|
|
1032
|
-
const c1OrP = trySubstituteSync(pattern, expression, r1, budget, g1, o1);
|
|
1033
|
-
const c1 = c1OrP instanceof Promise ? await c1OrP : c1OrP;
|
|
1034
|
-
const c2OrP = trySubstituteSync(c1.text, nextExpr, r2, budget, g2, o2);
|
|
1035
|
-
const c2 = c2OrP instanceof Promise ? await c2OrP : c2OrP;
|
|
1036
|
-
lastPattern = nextExpr;
|
|
1037
|
-
appendStdout(c2.text);
|
|
1038
|
-
appendStdoutSep();
|
|
1039
|
-
if (!useBatches || stdoutLen >= STDOUT_FLUSH) {
|
|
1040
|
-
const p = flushStdout();
|
|
1041
|
-
if (p)
|
|
1042
|
-
await p;
|
|
1043
|
-
}
|
|
1044
|
-
if (batchSource && currentBatch && followingRecord === undefined) {
|
|
1045
|
-
const batchText = currentBatch.text;
|
|
1046
|
-
const batchEnds = currentBatch.ends;
|
|
1047
|
-
const endsLen = batchEnds.length;
|
|
1048
|
-
while (batchIndex < endsLen) {
|
|
1049
|
-
if (batchIndex === 0 && currentBatch.firstLinePrefix)
|
|
1050
|
-
break;
|
|
1051
|
-
const lStart = batchIndex === 0 ? 0 : batchEnds[batchIndex - 1] + 1;
|
|
1052
|
-
const lEnd = batchEnds[batchIndex];
|
|
1053
|
-
const lineStr = batchText.slice(lStart, lEnd);
|
|
1054
|
-
const s1OrP = trySubstituteSync(lineStr, expression, r1, budget, g1, o1);
|
|
1055
|
-
const s1 = s1OrP instanceof Promise ? await s1OrP : s1OrP;
|
|
1056
|
-
const s2OrP = trySubstituteSync(s1.text, nextExpr, r2, budget, g2, o2);
|
|
1057
|
-
const s2 = s2OrP instanceof Promise ? await s2OrP : s2OrP;
|
|
1058
|
-
batchIndex++;
|
|
1059
|
-
number++;
|
|
1060
|
-
budget.step(3);
|
|
1061
|
-
if ((number & 31) === 0) {
|
|
1062
|
-
const pendingCheck = budget.checkpointSync();
|
|
1063
|
-
if (pendingCheck)
|
|
1064
|
-
await pendingCheck;
|
|
1065
|
-
}
|
|
1066
|
-
appendStdout(s2.text);
|
|
1067
|
-
appendStdoutSep();
|
|
1068
|
-
if (stdoutLen >= STDOUT_FLUSH) {
|
|
1069
|
-
const p = flushStdout();
|
|
1070
|
-
if (p)
|
|
1071
|
-
await p;
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
1074
|
-
}
|
|
1075
|
-
deleted = true;
|
|
1076
|
-
pc += 2;
|
|
1077
|
-
continue;
|
|
1078
|
-
}
|
|
1079
|
-
const pairedOrPromise = !canPairAnchored ? undefined : trySubstitutePairSync(pattern, expression, instruction.replacement, instruction.global ?? false, instruction.occurrence ?? 1, nextExpr, nextInst.replacement, nextInst.global ?? false, nextInst.occurrence ?? 1, budget);
|
|
1080
|
-
const paired = pairedOrPromise instanceof Promise ? await pairedOrPromise : pairedOrPromise;
|
|
1081
|
-
if (paired !== undefined) {
|
|
1082
|
-
lastPattern = nextExpr;
|
|
1083
|
-
pattern = paired.text;
|
|
1084
|
-
if (paired.substituted)
|
|
1085
|
-
substituted = true;
|
|
1086
|
-
budget.step();
|
|
1087
|
-
pc += 2;
|
|
1088
|
-
continue;
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
|
-
}
|
|
1092
|
-
}
|
|
1093
|
-
const changedOrPromise = trySubstituteSync(pattern, expression, instruction.replacement, budget, instruction.global ?? false, instruction.occurrence ?? 1);
|
|
1094
|
-
const changed = changedOrPromise instanceof Promise ? await changedOrPromise : changedOrPromise;
|
|
1095
|
-
pattern = changed.text;
|
|
1096
|
-
if (changed.count) {
|
|
1097
|
-
substituted = true;
|
|
1098
|
-
if (instruction.print) {
|
|
1099
|
-
const p = print();
|
|
1100
|
-
if (p)
|
|
1101
|
-
await p;
|
|
1102
|
-
}
|
|
1103
|
-
if (instruction.file)
|
|
1104
|
-
await writeFile(instruction.file);
|
|
1105
|
-
}
|
|
1106
|
-
break;
|
|
1107
|
-
}
|
|
1108
|
-
case "y": {
|
|
1109
|
-
// Interpreter strings contain one Latin-1 code unit per input byte.
|
|
1110
|
-
budget.step(pattern.length);
|
|
1111
|
-
const translated = new Uint8Array(pattern.length);
|
|
1112
|
-
for (let index = 0; index < pattern.length; index++) {
|
|
1113
|
-
if (index % 256 === 0)
|
|
1114
|
-
await budget.checkpointSync();
|
|
1115
|
-
translated[index] = (instruction.translation.get(pattern[index]) ?? pattern[index]).charCodeAt(0);
|
|
1116
|
-
}
|
|
1117
|
-
pattern = decodeBytes(translated, "latin1");
|
|
1118
|
-
break;
|
|
1119
|
-
}
|
|
1120
|
-
case "b":
|
|
1121
|
-
pc = instruction.jump;
|
|
1122
|
-
continue;
|
|
1123
|
-
case "t":
|
|
1124
|
-
case "T": {
|
|
1125
|
-
const branch = instruction.kind === "t" ? substituted : !substituted;
|
|
1126
|
-
substituted = false;
|
|
1127
|
-
if (branch) {
|
|
1128
|
-
pc = instruction.jump;
|
|
1129
|
-
continue;
|
|
1130
|
-
}
|
|
1131
|
-
break;
|
|
1132
|
-
}
|
|
1133
|
-
case "n":
|
|
1134
|
-
case "N": {
|
|
1135
|
-
if (instruction.kind === "n") {
|
|
1136
|
-
const p = flush();
|
|
1137
|
-
if (p)
|
|
1138
|
-
await p;
|
|
1139
|
-
}
|
|
1140
|
-
else if ((await peekNextRecord()) !== undefined) {
|
|
1141
|
-
const p = flush(false);
|
|
1142
|
-
if (p)
|
|
1143
|
-
await p;
|
|
1144
|
-
}
|
|
1145
|
-
const next = await readNextRecord();
|
|
1146
|
-
if (next === undefined) {
|
|
1147
|
-
if (instruction.kind === "N") {
|
|
1148
|
-
const p = flush();
|
|
1149
|
-
if (p)
|
|
1150
|
-
await p;
|
|
1151
|
-
}
|
|
1152
|
-
return { status: 0, quit: false };
|
|
1153
|
-
}
|
|
1154
|
-
record = next.terminated || files.length < 2 ? next : await prepareRecord(next);
|
|
1155
|
-
number++;
|
|
1156
|
-
pattern = instruction.kind === "N" ? joinSpace(pattern, record.text) : record.text;
|
|
1157
|
-
substituted = false;
|
|
1158
|
-
break;
|
|
1159
|
-
}
|
|
1160
|
-
}
|
|
1161
|
-
pc++;
|
|
1162
|
-
}
|
|
1163
|
-
const flushPending = flush();
|
|
1164
|
-
if (flushPending)
|
|
1165
|
-
await flushPending;
|
|
1166
|
-
if (quit)
|
|
1167
|
-
return { status, quit: true };
|
|
1168
|
-
currentRecord = followingRecord === undefined && batchSource && currentBatch && batchIndex < currentBatchLen
|
|
1169
|
-
? fillFromBatch(currentBatch, batchIndex++, sharedBatchRecord)
|
|
1170
|
-
: await readNextRecord();
|
|
1171
|
-
}
|
|
1172
|
-
return { status: 0, quit: false };
|
|
1173
|
-
}
|
|
1174
|
-
finally {
|
|
1175
|
-
try {
|
|
1176
|
-
if (stdoutLen > 0)
|
|
1177
|
-
await flushStdout();
|
|
1178
|
-
if (batchSource)
|
|
1179
|
-
await batchSource.return(undefined);
|
|
1180
|
-
else if (singleSource)
|
|
1181
|
-
await singleSource.return(undefined);
|
|
1182
|
-
}
|
|
1183
|
-
finally {
|
|
1184
|
-
if (usingSharedStdoutBuf)
|
|
1185
|
-
sharedSedStdoutBufInUse = false;
|
|
1186
|
-
}
|
|
1187
|
-
}
|
|
1188
|
-
}
|
|
1189
|
-
function runSedPairBatchLoopSync(batchText, batchEnds, endsLen, expr0, r1, g1, o1, expr1, r2, g2, o2, budget, stdoutBuf) {
|
|
1190
|
-
return trySubstitutePairBatchToBufferSync(batchText, batchEnds, endsLen, expr0, r1, g1, o1, expr1, r2, g2, o2, budget, stdoutBuf, 10, STDOUT_FLUSH);
|
|
1191
|
-
}
|
|
1192
|
-
function tryExecutePairFastSync(program, context, file, quiet, budget, separator) {
|
|
1193
|
-
if (program.length !== 2 || quiet || separator !== "\n" || file === "-")
|
|
1194
|
-
return undefined;
|
|
1195
|
-
const inst0 = program[0];
|
|
1196
|
-
const inst1 = program[1];
|
|
1197
|
-
if (inst0.kind !== "s" || inst0.first || inst0.second || inst0.negate || inst0.print || inst0.file || !inst0.pattern ||
|
|
1198
|
-
inst1.kind !== "s" || inst1.first || inst1.second || inst1.negate || inst1.print || inst1.file || !inst1.pattern) {
|
|
1199
|
-
return undefined;
|
|
1200
|
-
}
|
|
1201
|
-
const expr0 = inst0.pattern;
|
|
1202
|
-
const expr1 = inst1.pattern;
|
|
1203
|
-
if (inst0.replacementGroupCount > expr0.groupCount || inst1.replacementGroupCount > expr1.groupCount)
|
|
1204
|
-
return undefined;
|
|
1205
|
-
const stdoutSync = typeof context.stdout.writeSync === "function"
|
|
1206
|
-
? context.stdout
|
|
1207
|
-
: undefined;
|
|
1208
|
-
if (!stdoutSync)
|
|
1209
|
-
return undefined;
|
|
1210
|
-
const fastMem = context._fastMemoryBackingFs;
|
|
1211
|
-
if (!fastMem ||
|
|
1212
|
-
fastMem.capabilitiesFor !== undefined ||
|
|
1213
|
-
context._cachedInputBudget !== undefined ||
|
|
1214
|
-
Object.prototype.hasOwnProperty.call(fastMem, "readStream") ||
|
|
1215
|
-
Object.prototype.hasOwnProperty.call(fastMem, "readFile")) {
|
|
1216
|
-
return undefined;
|
|
1217
|
-
}
|
|
1218
|
-
const path = pathOf(context, file);
|
|
1219
|
-
if (path === "/dev" || path.startsWith("/dev/"))
|
|
1220
|
-
return undefined;
|
|
1221
|
-
let rawBytes;
|
|
1222
|
-
try {
|
|
1223
|
-
rawBytes = tryReadMemoryFileViewSync(fastMem, path, undefined, context.signal, true);
|
|
1224
|
-
}
|
|
1225
|
-
catch (e) {
|
|
1226
|
-
console.error('SED_SYNC_ERR:', e);
|
|
1227
|
-
return undefined;
|
|
1228
|
-
}
|
|
1229
|
-
if (!rawBytes || rawBytes.byteLength < 256)
|
|
1230
|
-
return undefined;
|
|
1231
|
-
const cachedBatch = getCachedLatin1Batch(rawBytes);
|
|
1232
|
-
if (!cachedBatch || cachedBatch.lastLineStart !== cachedBatch.text.length || cachedBatch.maxLineLen > budget.maxBufferBytes) {
|
|
1233
|
-
return undefined;
|
|
1234
|
-
}
|
|
1235
|
-
const pending = budget.checkpointSync();
|
|
1236
|
-
if (pending) {
|
|
1237
|
-
pending.catch(() => { });
|
|
1238
|
-
return undefined;
|
|
1239
|
-
}
|
|
1240
|
-
budget.step();
|
|
1241
|
-
let usingSharedStdoutBuf = false;
|
|
1242
|
-
let stdoutBuf;
|
|
1243
|
-
if (!sharedSedStdoutBufInUse) {
|
|
1244
|
-
sharedSedStdoutBufInUse = true;
|
|
1245
|
-
usingSharedStdoutBuf = true;
|
|
1246
|
-
if (!sharedSedStdoutBuf)
|
|
1247
|
-
sharedSedStdoutBuf = new Uint8Array(STDOUT_CAP);
|
|
1248
|
-
stdoutBuf = sharedSedStdoutBuf;
|
|
1249
|
-
}
|
|
1250
|
-
else {
|
|
1251
|
-
stdoutBuf = new Uint8Array(STDOUT_CAP);
|
|
1252
|
-
}
|
|
1253
|
-
const batchText = cachedBatch.text;
|
|
1254
|
-
const batchEnds = cachedBatch.ends;
|
|
1255
|
-
const endsLen = batchEnds.length;
|
|
1256
|
-
const g1 = inst0.global ?? false;
|
|
1257
|
-
const o1 = inst0.occurrence ?? 1;
|
|
1258
|
-
const r1 = inst0.replacement;
|
|
1259
|
-
const g2 = inst1.global ?? false;
|
|
1260
|
-
const o2 = inst1.occurrence ?? 1;
|
|
1261
|
-
const r2 = inst1.replacement;
|
|
1262
|
-
try {
|
|
1263
|
-
if (usingSharedStdoutBuf &&
|
|
1264
|
-
lastSedPairStdoutIntact &&
|
|
1265
|
-
program === lastSedPairProgram &&
|
|
1266
|
-
cachedBatch === lastSedPairBatch &&
|
|
1267
|
-
(++sedPairBimodalWarm > 4 || (sedPairBimodalWarm & 1) === 1)) {
|
|
1268
|
-
budget.step(lastSedPairSteps);
|
|
1269
|
-
const pCheck = budget.checkpointSync();
|
|
1270
|
-
if (pCheck) {
|
|
1271
|
-
pCheck.catch(() => { });
|
|
1272
|
-
return undefined;
|
|
1273
|
-
}
|
|
1274
|
-
context._chargeFastFsOp?.();
|
|
1275
|
-
if (lastSedPairStdoutLen > 0) {
|
|
1276
|
-
context.signal.throwIfAborted();
|
|
1277
|
-
if (lastSedPairSavedOutBuf !== undefined && typeof stdoutSync.writeImmutableSync === "function") {
|
|
1278
|
-
stdoutSync.writeImmutableSync(lastSedPairSavedOutBuf);
|
|
1279
|
-
}
|
|
1280
|
-
else if (typeof stdoutSync.writeRangeSync === "function") {
|
|
1281
|
-
stdoutSync.writeRangeSync(stdoutBuf, lastSedPairStdoutLen);
|
|
1282
|
-
}
|
|
1283
|
-
else {
|
|
1284
|
-
stdoutSync.writeSync(new Uint8Array(stdoutBuf.buffer, stdoutBuf.byteOffset, lastSedPairStdoutLen));
|
|
1285
|
-
}
|
|
1286
|
-
}
|
|
1287
|
-
return 0;
|
|
1288
|
-
}
|
|
1289
|
-
if (usingSharedStdoutBuf)
|
|
1290
|
-
lastSedPairStdoutIntact = false;
|
|
1291
|
-
const stepsBefore = budget.stepsUsed;
|
|
1292
|
-
// Keep the attempt private until every line succeeds. Larger results use
|
|
1293
|
-
// the streaming executor without publishing a prefix that it would replay.
|
|
1294
|
-
const stdoutLen = runSedPairBatchLoopSync(batchText, batchEnds, endsLen, expr0, r1, g1, o1, expr1, r2, g2, o2, budget, stdoutBuf);
|
|
1295
|
-
if (stdoutLen >= 0 && usingSharedStdoutBuf && rawBytes.byteLength >= 1024) {
|
|
1296
|
-
lastSedPairProgram = program;
|
|
1297
|
-
lastSedPairBatch = cachedBatch;
|
|
1298
|
-
lastSedPairStdoutLen = stdoutLen;
|
|
1299
|
-
lastSedPairSavedOutBuf = stdoutLen > 0 ? Uint8Array.prototype.slice.call(stdoutBuf, 0, stdoutLen) : undefined;
|
|
1300
|
-
lastSedPairSteps = budget.stepsUsed - stepsBefore;
|
|
1301
|
-
lastSedPairStdoutIntact = true;
|
|
1302
|
-
}
|
|
1303
|
-
if (stdoutLen < 0)
|
|
1304
|
-
return undefined;
|
|
1305
|
-
context._chargeFastFsOp?.();
|
|
1306
|
-
if (stdoutLen > 0) {
|
|
1307
|
-
context.signal.throwIfAborted();
|
|
1308
|
-
if (typeof stdoutSync.writeRangeSync === "function") {
|
|
1309
|
-
stdoutSync.writeRangeSync(stdoutBuf, stdoutLen);
|
|
1310
|
-
}
|
|
1311
|
-
else {
|
|
1312
|
-
stdoutSync.writeSync(new Uint8Array(stdoutBuf.buffer, stdoutBuf.byteOffset, stdoutLen));
|
|
1313
|
-
}
|
|
1314
|
-
}
|
|
1315
|
-
return 0;
|
|
1316
|
-
}
|
|
1317
|
-
finally {
|
|
1318
|
-
if (usingSharedStdoutBuf)
|
|
1319
|
-
sharedSedStdoutBufInUse = false;
|
|
1320
|
-
}
|
|
1321
|
-
}
|
|
1322
|
-
const SED_META_RE = /[\\^$.*+?()[\]{}|\n]/;
|
|
1323
|
-
function tryExecuteSimpleSedStdinSync(rawProg, context, options) {
|
|
1324
|
-
if (rawProg.length < 4 || rawProg.length > 256 || rawProg.charCodeAt(0) !== 115)
|
|
1325
|
-
return undefined;
|
|
1326
|
-
const delim = rawProg[1];
|
|
1327
|
-
if (delim === "\\" || delim === "\n")
|
|
1328
|
-
return undefined;
|
|
1329
|
-
const parts = rawProg.split(delim);
|
|
1330
|
-
if (parts.length !== 4)
|
|
1331
|
-
return undefined;
|
|
1332
|
-
const pat = parts[1];
|
|
1333
|
-
const rep = parts[2];
|
|
1334
|
-
const flags = parts[3];
|
|
1335
|
-
if (pat.length === 0 || (flags !== "" && flags !== "g"))
|
|
1336
|
-
return undefined;
|
|
1337
|
-
if (SED_META_RE.test(pat) || rep.includes("&") || rep.includes("\\") || rep.includes("\n"))
|
|
1338
|
-
return undefined;
|
|
1339
|
-
for (let i = 0; i < rawProg.length; i++) {
|
|
1340
|
-
if (rawProg.charCodeAt(i) >= 128)
|
|
1341
|
-
return undefined;
|
|
1342
|
-
}
|
|
1343
|
-
const stdinSync = context.stdin;
|
|
1344
|
-
const stdoutSync = context.stdout;
|
|
1345
|
-
if (typeof stdinSync.tryReadAllSync !== "function" || typeof stdoutSync.writeSync !== "function")
|
|
1346
|
-
return undefined;
|
|
1347
|
-
const rawBytes = stdinSync.tryReadAllSync();
|
|
1348
|
-
if (!rawBytes || rawBytes.byteLength > 16384)
|
|
1349
|
-
return undefined;
|
|
1350
|
-
for (let i = 0; i < rawBytes.byteLength; i++) {
|
|
1351
|
-
const b = rawBytes[i];
|
|
1352
|
-
if (b >= 128 || b === 0)
|
|
1353
|
-
return undefined;
|
|
1354
|
-
}
|
|
1355
|
-
const budget = Budget.acquire(context, options);
|
|
1356
|
-
try {
|
|
1357
|
-
const pCheck = budget.checkpointSync();
|
|
1358
|
-
if (pCheck) {
|
|
1359
|
-
pCheck.catch(() => { });
|
|
1360
|
-
return undefined;
|
|
1361
|
-
}
|
|
1362
|
-
const text = decodeBytes(encodeBytes(rawBytes.buffer, rawBytes.byteOffset, rawBytes.byteLength), "latin1");
|
|
1363
|
-
if (text.length === 0) {
|
|
1364
|
-
budget.step(1);
|
|
1365
|
-
return 0;
|
|
1366
|
-
}
|
|
1367
|
-
const hasTrailingNewline = text.charCodeAt(text.length - 1) === 10;
|
|
1368
|
-
const body = hasTrailingNewline ? text.slice(0, -1) : text;
|
|
1369
|
-
const lines = body.split("\n");
|
|
1370
|
-
const isGlobal = flags === "g";
|
|
1371
|
-
budget.step(1 + lines.length);
|
|
1372
|
-
for (let i = 0; i < lines.length; i++) {
|
|
1373
|
-
const line = lines[i];
|
|
1374
|
-
if (line.length > budget.maxBufferBytes)
|
|
1375
|
-
return undefined;
|
|
1376
|
-
const idx = line.indexOf(pat);
|
|
1377
|
-
if (idx !== -1) {
|
|
1378
|
-
const nextLine = isGlobal ? line.split(pat).join(rep) : line.slice(0, idx) + rep + line.slice(idx + pat.length);
|
|
1379
|
-
if (nextLine.length > budget.maxBufferBytes)
|
|
1380
|
-
return undefined;
|
|
1381
|
-
lines[i] = nextLine;
|
|
1382
|
-
}
|
|
1383
|
-
}
|
|
1384
|
-
const outText = lines.join("\n") + (hasTrailingNewline ? "\n" : "");
|
|
1385
|
-
budget.check(outText);
|
|
1386
|
-
const outBytes = encodeBytes(outText, "latin1");
|
|
1387
|
-
if (!stdoutSync.writeSync(outBytes))
|
|
1388
|
-
return undefined;
|
|
1389
|
-
return 0;
|
|
1390
|
-
}
|
|
1391
|
-
catch {
|
|
1392
|
-
return undefined;
|
|
1393
|
-
}
|
|
1394
|
-
finally {
|
|
1395
|
-
Budget.release(budget);
|
|
1396
|
-
}
|
|
1397
|
-
}
|
|
1398
|
-
export function sedCommand(options = {}) {
|
|
1399
|
-
const maxProgramInstructions = options.maxProgramInstructions === undefined ? Infinity : options.maxProgramInstructions;
|
|
1400
|
-
const definition = command("sed", context => {
|
|
1401
|
-
if (maxProgramInstructions === Infinity &&
|
|
1402
|
-
(context.args.length === 1 || (context.args.length === 2 && context.args[0] === "-e"))) {
|
|
1403
|
-
const rawProg = context.args[context.args.length - 1];
|
|
1404
|
-
const stdinRes = tryExecuteSimpleSedStdinSync(rawProg, context, options);
|
|
1405
|
-
if (stdinRes !== undefined)
|
|
1406
|
-
return stdinRes;
|
|
1407
|
-
}
|
|
1408
|
-
if (maxProgramInstructions === Infinity &&
|
|
1409
|
-
context.args.length === 2 &&
|
|
1410
|
-
!context.args[0].startsWith("-") &&
|
|
1411
|
-
context.args[0] !== "-" &&
|
|
1412
|
-
!context.args[1].startsWith("-") &&
|
|
1413
|
-
context.args[1] !== "-") {
|
|
1414
|
-
const rawProg = context.args[0];
|
|
1415
|
-
let cached = sedFastRawCache.get(rawProg);
|
|
1416
|
-
if (!cached) {
|
|
1417
|
-
const parseBudget = Budget.acquire(context, options);
|
|
1418
|
-
try {
|
|
1419
|
-
cached = tryParseFastPairProgramSync(rawProg, parseBudget);
|
|
1420
|
-
}
|
|
1421
|
-
finally {
|
|
1422
|
-
Budget.release(parseBudget);
|
|
1423
|
-
}
|
|
1424
|
-
}
|
|
1425
|
-
if (cached && cached.outputFiles.length === 0 && cached.readFiles.length === 0) {
|
|
1426
|
-
const quiet = rawProg.charCodeAt(0) === 35 && rawProg.charCodeAt(1) === 110;
|
|
1427
|
-
const budget = Budget.acquire(context, options);
|
|
1428
|
-
try {
|
|
1429
|
-
if (cached.steps > 0)
|
|
1430
|
-
budget.step(cached.steps);
|
|
1431
|
-
const syncStatus = tryExecutePairFastSync(cached.program, context, context.args[1], quiet, budget, "\n");
|
|
1432
|
-
if (syncStatus !== undefined)
|
|
1433
|
-
return syncStatus;
|
|
1434
|
-
}
|
|
1435
|
-
finally {
|
|
1436
|
-
Budget.release(budget);
|
|
1437
|
-
}
|
|
1438
|
-
}
|
|
1439
|
-
}
|
|
1440
|
-
return executeSedGeneral(context, options, maxProgramInstructions);
|
|
1441
|
-
});
|
|
1442
|
-
return { ...definition, filesystemRequirements: sedRequirements };
|
|
1443
|
-
}
|
|
1444
|
-
async function executeSedGeneral(context, options, maxProgramInstructions) {
|
|
1445
|
-
if ((maxProgramInstructions !== Infinity && !Number.isSafeInteger(maxProgramInstructions)) || maxProgramInstructions < 1)
|
|
1446
|
-
throw new ProgramError("maxProgramInstructions must be a positive safe integer");
|
|
1447
|
-
const budget = new Budget(context, options);
|
|
1448
|
-
const sources = [];
|
|
1449
|
-
const files = [];
|
|
1450
|
-
let quiet = false;
|
|
1451
|
-
let extended = false;
|
|
1452
|
-
let separate = false;
|
|
1453
|
-
let lineLength = 70;
|
|
1454
|
-
const setLineLength = (value) => {
|
|
1455
|
-
if (value === undefined || !value.length || [...value].some(character => character < "0" || character > "9") || !Number.isSafeInteger(Number(value))) {
|
|
1456
|
-
throw new ProgramError("line length must be a nonnegative safe integer");
|
|
1457
|
-
}
|
|
1458
|
-
lineLength = Number(value);
|
|
1459
|
-
};
|
|
1460
|
-
let separator = "\n";
|
|
1461
|
-
let inPlace;
|
|
1462
|
-
let ended = false;
|
|
1463
|
-
for (let index = 0; index < context.args.length; index++) {
|
|
1464
|
-
const argument = context.args[index];
|
|
1465
|
-
if (ended || argument === "-" || !argument.startsWith("-")) {
|
|
1466
|
-
files.push(argument);
|
|
1467
|
-
continue;
|
|
1468
|
-
}
|
|
1469
|
-
if (argument === "--") {
|
|
1470
|
-
ended = true;
|
|
1471
|
-
continue;
|
|
1472
|
-
}
|
|
1473
|
-
if (argument === "--null-data") {
|
|
1474
|
-
separator = "\0";
|
|
1475
|
-
continue;
|
|
1476
|
-
}
|
|
1477
|
-
if (argument === "--quiet" || argument === "--silent") {
|
|
1478
|
-
quiet = true;
|
|
1479
|
-
continue;
|
|
1480
|
-
}
|
|
1481
|
-
if (argument === "--unbuffered" || argument === "--posix")
|
|
1482
|
-
continue;
|
|
1483
|
-
if (argument === "--regexp-extended") {
|
|
1484
|
-
extended = true;
|
|
1485
|
-
continue;
|
|
1486
|
-
}
|
|
1487
|
-
if (argument === "--in-place" || argument.startsWith("--in-place=")) {
|
|
1488
|
-
inPlace = argument === "--in-place" ? "" : argument.slice("--in-place=".length);
|
|
1489
|
-
continue;
|
|
1490
|
-
}
|
|
1491
|
-
if (argument === "--separate") {
|
|
1492
|
-
separate = true;
|
|
1493
|
-
continue;
|
|
1494
|
-
}
|
|
1495
|
-
if (argument === "--line-length" || argument.startsWith("--line-length=")) {
|
|
1496
|
-
setLineLength(argument === "--line-length" ? context.args[++index] : argument.slice("--line-length=".length));
|
|
1497
|
-
continue;
|
|
1498
|
-
}
|
|
1499
|
-
if (argument === "--expression" || argument.startsWith("--expression=")) {
|
|
1500
|
-
const source = argument === "--expression" ? context.args[++index] : argument.slice("--expression=".length);
|
|
1501
|
-
if (source === undefined)
|
|
1502
|
-
throw new ProgramError("--expression requires an argument");
|
|
1503
|
-
sources.push(byteString(source));
|
|
1504
|
-
continue;
|
|
1505
|
-
}
|
|
1506
|
-
if (argument === "--file" || argument.startsWith("--file=")) {
|
|
1507
|
-
const source = argument === "--file" ? context.args[++index] : argument.slice("--file=".length);
|
|
1508
|
-
if (source === undefined)
|
|
1509
|
-
throw new ProgramError("--file requires an argument");
|
|
1510
|
-
await assertPathRequirements(context, sedRequirements, ["script-file"], [source]);
|
|
1511
|
-
sources.push(await readProgram(context, source));
|
|
1512
|
-
continue;
|
|
1513
|
-
}
|
|
1514
|
-
if (argument.startsWith("--"))
|
|
1515
|
-
throw new ProgramError(`unsupported option '${argument}'`);
|
|
1516
|
-
for (let position = 1; position < argument.length; position++) {
|
|
1517
|
-
const flag = argument[position];
|
|
1518
|
-
if (flag === "n")
|
|
1519
|
-
quiet = true;
|
|
1520
|
-
else if (flag === "u") { /* unbuffered */ }
|
|
1521
|
-
else if (flag === "z")
|
|
1522
|
-
separator = "\0";
|
|
1523
|
-
else if (flag === "E" || flag === "r")
|
|
1524
|
-
extended = true;
|
|
1525
|
-
else if (flag === "s")
|
|
1526
|
-
separate = true;
|
|
1527
|
-
else if (flag === "l") {
|
|
1528
|
-
setLineLength(argument.slice(position + 1) || context.args[++index]);
|
|
1529
|
-
position = argument.length;
|
|
1530
|
-
}
|
|
1531
|
-
else if (flag === "i") {
|
|
1532
|
-
inPlace = argument.slice(position + 1);
|
|
1533
|
-
if (!inPlace && context.args[index + 1] === "")
|
|
1534
|
-
index++;
|
|
1535
|
-
position = argument.length;
|
|
1536
|
-
}
|
|
1537
|
-
else if (flag === "e" || flag === "f") {
|
|
1538
|
-
const source = argument.slice(position + 1) || context.args[++index];
|
|
1539
|
-
if (source === undefined)
|
|
1540
|
-
throw new ProgramError(`-${flag} requires an argument`);
|
|
1541
|
-
if (flag === "f")
|
|
1542
|
-
await assertPathRequirements(context, sedRequirements, ["script-file"], [source]);
|
|
1543
|
-
sources.push(flag === "f" ? await readProgram(context, source) : byteString(source));
|
|
1544
|
-
position = argument.length;
|
|
1545
|
-
}
|
|
1546
|
-
else
|
|
1547
|
-
throw new ProgramError(`unsupported option '-${flag}'`);
|
|
1548
|
-
}
|
|
1549
|
-
}
|
|
1550
|
-
if (!sources.length) {
|
|
1551
|
-
if (!files.length)
|
|
1552
|
-
throw new ProgramError("missing program");
|
|
1553
|
-
sources.push(byteString(files.shift()));
|
|
1554
|
-
}
|
|
1555
|
-
if (sources[0]?.startsWith("#n"))
|
|
1556
|
-
quiet = true;
|
|
1557
|
-
const sourceText = sources.length === 1 ? sources[0] : sources.join("\n");
|
|
1558
|
-
const canCache = sourceText.length <= 8192;
|
|
1559
|
-
const cacheKey = canCache ? `${extended ? 1 : 0}:${separator}:${maxProgramInstructions}:${sourceText}` : "";
|
|
1560
|
-
let cached = canCache ? sedProgramCache.get(cacheKey) : undefined;
|
|
1561
|
-
if (cached) {
|
|
1562
|
-
if (cached.steps > 0)
|
|
1563
|
-
budget.step(cached.steps);
|
|
1564
|
-
}
|
|
1565
|
-
else {
|
|
1566
|
-
const stepsBefore = budget.stepsUsed;
|
|
1567
|
-
const parsedProgram = await parse(sourceText, extended, separator, maxProgramInstructions, budget);
|
|
1568
|
-
const steps = budget.stepsUsed - stepsBefore;
|
|
1569
|
-
let outFiles;
|
|
1570
|
-
let rdFiles;
|
|
1571
|
-
for (let i = 0; i < parsedProgram.length; i++) {
|
|
1572
|
-
const inst = parsedProgram[i];
|
|
1573
|
-
if (inst.file !== undefined) {
|
|
1574
|
-
if (inst.kind === "r")
|
|
1575
|
-
(rdFiles ??= []).push(inst.file);
|
|
1576
|
-
else
|
|
1577
|
-
(outFiles ??= []).push(inst.file);
|
|
1578
|
-
}
|
|
1579
|
-
}
|
|
1580
|
-
cached = {
|
|
1581
|
-
program: parsedProgram,
|
|
1582
|
-
steps,
|
|
1583
|
-
outputFiles: outFiles ?? EMPTY_STRINGS,
|
|
1584
|
-
readFiles: rdFiles ?? EMPTY_STRINGS,
|
|
1585
|
-
};
|
|
1586
|
-
if (canCache) {
|
|
1587
|
-
if (sedProgramCache.size >= 64)
|
|
1588
|
-
sedProgramCache.delete(sedProgramCache.keys().next().value);
|
|
1589
|
-
sedProgramCache.set(cacheKey, cached);
|
|
1590
|
-
if (!extended && separator === "\n" && maxProgramInstructions === Infinity && sources.length === 1)
|
|
1591
|
-
sedFastRawCache.set(sources[0], cached);
|
|
1592
|
-
}
|
|
1593
|
-
}
|
|
1594
|
-
const { program, outputFiles, readFiles } = cached;
|
|
1595
|
-
if (outputFiles.length > 0) {
|
|
1596
|
-
await assertPathRequirements(context, sedRequirements, ["script-output"], outputFiles);
|
|
1597
|
-
}
|
|
1598
|
-
if (inPlace !== undefined || outputFiles.length > 0) {
|
|
1599
|
-
await assertPathRequirements(context, sedRequirements, ["file"], files.filter(file => file !== "-"));
|
|
1600
|
-
if (readFiles.length > 0) {
|
|
1601
|
-
await assertPathRequirements(context, sedRequirements, ["script-read"], readFiles);
|
|
1602
|
-
}
|
|
1603
|
-
}
|
|
1604
|
-
const prepareOutputs = async () => {
|
|
1605
|
-
if (outputFiles.length === 0)
|
|
1606
|
-
return;
|
|
1607
|
-
const paths = new Set(outputFiles.map(file => virtualPath(context, file)));
|
|
1608
|
-
for (const path of paths)
|
|
1609
|
-
await writeFileOutput(context, new Uint8Array(), chunk => context.fs.writeFile(path, chunk, { signal: context.signal }));
|
|
1610
|
-
};
|
|
1611
|
-
const outputState = { stdoutUnterminated: false, unterminatedFiles: outputFiles.length > 0 ? new Set() : EMPTY_SET };
|
|
1612
|
-
if (inPlace !== undefined) {
|
|
1613
|
-
if (!files.length || files.includes("-"))
|
|
1614
|
-
throw new ProgramError("in-place editing requires named files");
|
|
1615
|
-
if (inPlace.includes("/") || inPlace.includes("\0"))
|
|
1616
|
-
throw new ProgramError("backup suffix cannot contain '/' or NUL");
|
|
1617
|
-
await assertPathRequirements(context, sedRequirements, ["in-place"], files);
|
|
1618
|
-
if (inPlace)
|
|
1619
|
-
await assertPathRequirements(context, sedRequirements, ["backup"], files.flatMap(file => [file, file + inPlace]));
|
|
1620
|
-
const targets = await prepareInPlace(context, files, inPlace);
|
|
1621
|
-
if (outputFiles.length > 0)
|
|
1622
|
-
await prepareOutputs();
|
|
1623
|
-
for (const target of targets) {
|
|
1624
|
-
const result = await editInPlace(context, target, inPlace, budget, async (stdin) => {
|
|
1625
|
-
let rewritten = "";
|
|
1626
|
-
const child = Object.assign(Object.create(Object.getPrototypeOf(context)), context, { stdin, stdout: { async write(chunk) { rewritten = budget.check(rewritten + decodeBytes(encodeBytes(chunk), "latin1")); } } });
|
|
1627
|
-
outputState.stdoutUnterminated = false;
|
|
1628
|
-
const result = await execute(program, child, ["-"], quiet, budget, separator, outputState, lineLength);
|
|
1629
|
-
return { result, data: bytes(rewritten) };
|
|
1630
|
-
});
|
|
1631
|
-
if (result.quit || result.status)
|
|
1632
|
-
return result.status;
|
|
1633
|
-
}
|
|
1634
|
-
return 0;
|
|
1635
|
-
}
|
|
1636
|
-
if (outputFiles.length > 0)
|
|
1637
|
-
await prepareOutputs();
|
|
1638
|
-
if (separate) {
|
|
1639
|
-
for (const file of files.length ? files : ["-"]) {
|
|
1640
|
-
const result = await execute(program, context, [file], quiet, budget, separator, outputState, lineLength);
|
|
1641
|
-
if (result.quit || result.status)
|
|
1642
|
-
return result.status;
|
|
1643
|
-
}
|
|
1644
|
-
return 0;
|
|
1645
|
-
}
|
|
1646
|
-
return (await execute(program, context, files, quiet, budget, separator, outputState, lineLength)).status;
|
|
1647
|
-
}
|
|
1
|
+
export * from "../../../safe-bash-command-sed/sed.js";
|
|
1648
2
|
//# sourceMappingURL=sed.js.map
|