just-bash 2.11.13 → 2.11.14
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/dist/bin/{shell/chunks/chunk-7ECKLAVW.js → chunks/chunk-5UH3Q7QT.js} +1 -1
- package/dist/bin/chunks/chunk-5UHJVSR5.js +10 -0
- package/dist/bin/chunks/chunk-AHMZLMTU.js +100 -0
- package/dist/bin/chunks/{chunk-A4442AOC.js → chunk-BWWPUUC5.js} +3 -3
- package/dist/bin/chunks/{chunk-Q4QFIAHB.js → chunk-D2VMRCQU.js} +1 -1
- package/dist/bin/chunks/chunk-F3LGZXLQ.js +9 -0
- package/dist/bin/chunks/chunk-GA6KXSOC.js +9 -0
- package/dist/bin/{shell/chunks/chunk-TIDZOIPX.js → chunks/chunk-IDGH4PGU.js} +2 -2
- package/dist/bin/chunks/chunk-KPWFKFSD.js +21 -0
- package/dist/bin/{shell/chunks/chunk-QXB5WI2V.js → chunks/chunk-LGJM5YFT.js} +6 -5
- package/dist/bin/chunks/{chunk-X2I3PJTX.js → chunk-LW7FS3EH.js} +4 -4
- package/dist/bin/{shell/chunks/chunk-MNNOATCV.js → chunks/chunk-V4CRXAQO.js} +1 -1
- package/dist/bin/chunks/{chunk-CHB75QIN.js → chunk-XB2MDT3B.js} +1 -1
- package/dist/bin/{shell/chunks/chunk-QEBPVWVB.js → chunks/chunk-XORPAMNK.js} +1 -1
- package/dist/bin/chunks/chunk-XY5HGZW5.js +8 -0
- package/dist/bin/chunks/{du-66BNA4IN.js → du-LDAPXSGF.js} +1 -1
- package/dist/bin/{shell/chunks/find-K777TRNA.js → chunks/find-PHHSZYDL.js} +1 -1
- package/dist/bin/{shell/chunks/flag-coverage-CVSXSL4T.js → chunks/flag-coverage-KFNWHFPU.js} +1 -1
- package/dist/bin/{shell/chunks/grep-FRIPZKKT.js → chunks/grep-F3GT2VPG.js} +1 -1
- package/dist/bin/{shell/chunks/jq-CXQ33VMW.js → chunks/jq-TIHNHMOR.js} +1 -1
- package/dist/bin/{shell/chunks/printf-TZC5BRAY.js → chunks/printf-4NJFGX3O.js} +1 -1
- package/dist/bin/chunks/{rg-3R5G2XL4.js → rg-EJJ3ILD5.js} +1 -1
- package/dist/bin/{shell/chunks/sed-PHQQJ4SI.js → chunks/sed-3DO5EXEU.js} +1 -1
- package/dist/bin/chunks/{sleep-PICQVS6Q.js → sleep-3QRDZXBH.js} +1 -1
- package/dist/bin/{shell/chunks/split-NOZ7FFXW.js → chunks/split-YWV64TJH.js} +1 -1
- package/dist/bin/chunks/tac-T42SKDDI.js +2 -0
- package/dist/bin/chunks/{tr-GDDRKGRB.js → tr-4V5A3V2C.js} +1 -1
- package/dist/bin/chunks/{which-67WZ6OMV.js → which-5PO4LAOG.js} +1 -1
- package/dist/bin/chunks/{xan-FMSZPFX4.js → xan-3IA4WP2G.js} +1 -1
- package/dist/bin/chunks/{yq-WUJ5JNDT.js → yq-OUNV2BWM.js} +1 -1
- package/dist/bin/just-bash.js +1 -1
- package/dist/bin/{chunks/chunk-7ECKLAVW.js → shell/chunks/chunk-5UH3Q7QT.js} +1 -1
- package/dist/bin/shell/chunks/chunk-5UHJVSR5.js +10 -0
- package/dist/bin/shell/chunks/chunk-AHMZLMTU.js +100 -0
- package/dist/bin/shell/chunks/{chunk-A4442AOC.js → chunk-BWWPUUC5.js} +3 -3
- package/dist/bin/shell/chunks/{chunk-Q4QFIAHB.js → chunk-D2VMRCQU.js} +1 -1
- package/dist/bin/shell/chunks/chunk-F3LGZXLQ.js +9 -0
- package/dist/bin/shell/chunks/chunk-GA6KXSOC.js +9 -0
- package/dist/bin/{chunks/chunk-TIDZOIPX.js → shell/chunks/chunk-IDGH4PGU.js} +2 -2
- package/dist/bin/shell/chunks/chunk-KPWFKFSD.js +21 -0
- package/dist/bin/{chunks/chunk-QXB5WI2V.js → shell/chunks/chunk-LGJM5YFT.js} +6 -5
- package/dist/bin/shell/chunks/{chunk-X2I3PJTX.js → chunk-LW7FS3EH.js} +4 -4
- package/dist/bin/{chunks/chunk-MNNOATCV.js → shell/chunks/chunk-V4CRXAQO.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-CHB75QIN.js → chunk-XB2MDT3B.js} +1 -1
- package/dist/bin/{chunks/chunk-QEBPVWVB.js → shell/chunks/chunk-XORPAMNK.js} +1 -1
- package/dist/bin/shell/chunks/chunk-XY5HGZW5.js +8 -0
- package/dist/bin/shell/chunks/{du-66BNA4IN.js → du-LDAPXSGF.js} +1 -1
- package/dist/bin/{chunks/find-K777TRNA.js → shell/chunks/find-PHHSZYDL.js} +1 -1
- package/dist/bin/{chunks/flag-coverage-CVSXSL4T.js → shell/chunks/flag-coverage-KFNWHFPU.js} +1 -1
- package/dist/bin/{chunks/grep-FRIPZKKT.js → shell/chunks/grep-F3GT2VPG.js} +1 -1
- package/dist/bin/{chunks/jq-CXQ33VMW.js → shell/chunks/jq-TIHNHMOR.js} +1 -1
- package/dist/bin/{chunks/printf-TZC5BRAY.js → shell/chunks/printf-4NJFGX3O.js} +1 -1
- package/dist/bin/shell/chunks/{rg-3R5G2XL4.js → rg-EJJ3ILD5.js} +1 -1
- package/dist/bin/{chunks/sed-PHQQJ4SI.js → shell/chunks/sed-3DO5EXEU.js} +1 -1
- package/dist/bin/shell/chunks/{sleep-PICQVS6Q.js → sleep-3QRDZXBH.js} +1 -1
- package/dist/bin/{chunks/split-NOZ7FFXW.js → shell/chunks/split-YWV64TJH.js} +1 -1
- package/dist/bin/shell/chunks/tac-T42SKDDI.js +2 -0
- package/dist/bin/shell/chunks/{tr-GDDRKGRB.js → tr-4V5A3V2C.js} +1 -1
- package/dist/bin/shell/chunks/{which-67WZ6OMV.js → which-5PO4LAOG.js} +1 -1
- package/dist/bin/shell/chunks/{xan-FMSZPFX4.js → xan-3IA4WP2G.js} +1 -1
- package/dist/bin/shell/chunks/{yq-WUJ5JNDT.js → yq-OUNV2BWM.js} +1 -1
- package/dist/bin/shell/shell.js +1 -1
- package/dist/bundle/browser.js +371 -369
- package/dist/bundle/chunks/{chunk-FRDGR5VK.js → chunk-3JDQKHMS.js} +3 -3
- package/dist/bundle/chunks/chunk-5BFLZVGH.js +20 -0
- package/dist/bundle/chunks/{chunk-YYB54I7F.js → chunk-73RYQHTW.js} +1 -1
- package/dist/bundle/chunks/chunk-7WX4V2UH.js +9 -0
- package/dist/bundle/chunks/{chunk-UYGR3CFC.js → chunk-A65PWWJC.js} +2 -2
- package/dist/bundle/chunks/chunk-CYTBPLPE.js +8 -0
- package/dist/bundle/chunks/{chunk-QOENL5UZ.js → chunk-FJNVFD75.js} +1 -1
- package/dist/bundle/chunks/{chunk-2OCD45J4.js → chunk-FWYCF7NE.js} +1 -1
- package/dist/bundle/chunks/chunk-IBG6HR7V.js +99 -0
- package/dist/bundle/chunks/{chunk-L4KW73FJ.js → chunk-M2LI252W.js} +4 -4
- package/dist/bundle/chunks/chunk-MHTUABJP.js +8 -0
- package/dist/bundle/chunks/{chunk-KTGH7NTP.js → chunk-MYE6AGBJ.js} +6 -5
- package/dist/bundle/chunks/{chunk-JI3KJ32H.js → chunk-OAOCWUTE.js} +1 -1
- package/dist/bundle/chunks/chunk-RPNGRAAP.js +7 -0
- package/dist/bundle/chunks/{chunk-XMDVFEVC.js → chunk-U5TNQJ3C.js} +1 -1
- package/dist/bundle/chunks/{du-DM4QX4XA.js → du-WO2ENHXQ.js} +1 -1
- package/dist/bundle/chunks/{find-74OP3M7S.js → find-6U6YYAEP.js} +1 -1
- package/dist/bundle/chunks/{flag-coverage-KCADAH3N.js → flag-coverage-ZCNVOYRY.js} +1 -1
- package/dist/bundle/chunks/{grep-BPEMMINR.js → grep-LXKUQUAE.js} +1 -1
- package/dist/bundle/chunks/{jq-OJYNICKX.js → jq-YDGLHC7M.js} +1 -1
- package/dist/bundle/chunks/{printf-KGN6BDCY.js → printf-IO3EBW5H.js} +1 -1
- package/dist/bundle/chunks/{rg-ORQK4GVH.js → rg-4YNHHQAE.js} +1 -1
- package/dist/bundle/chunks/{sed-7HX4RAZG.js → sed-2K6ULZ6P.js} +1 -1
- package/dist/bundle/chunks/{sleep-JHK4I472.js → sleep-U2ORRQJB.js} +1 -1
- package/dist/bundle/chunks/{split-EZOC5IIZ.js → split-SITCSYCZ.js} +1 -1
- package/dist/bundle/chunks/tac-SJGXQ4T2.js +1 -0
- package/dist/bundle/chunks/{tr-RYO2EDCA.js → tr-2N7Q3KKJ.js} +1 -1
- package/dist/bundle/chunks/{which-NCIYTMAT.js → which-XZHEH76L.js} +1 -1
- package/dist/bundle/chunks/{xan-Z6KVJKEE.js → xan-Y62IEVU4.js} +1 -1
- package/dist/bundle/chunks/{yq-FD5F3WOJ.js → yq-CESEW5B3.js} +1 -1
- package/dist/bundle/index.cjs +603 -601
- package/dist/bundle/index.js +1 -1
- package/dist/commands/sed/types.d.ts +1 -0
- package/package.json +1 -1
- package/dist/bin/chunks/chunk-4PS5JJDT.js +0 -8
- package/dist/bin/chunks/chunk-4U7XM2O3.js +0 -100
- package/dist/bin/chunks/chunk-6VUEI2GS.js +0 -9
- package/dist/bin/chunks/chunk-BDSRLH5T.js +0 -20
- package/dist/bin/chunks/chunk-NFZDITRV.js +0 -10
- package/dist/bin/chunks/chunk-WT2HWDDA.js +0 -9
- package/dist/bin/chunks/tac-TZBNTR4K.js +0 -2
- package/dist/bin/shell/chunks/chunk-4PS5JJDT.js +0 -8
- package/dist/bin/shell/chunks/chunk-4U7XM2O3.js +0 -100
- package/dist/bin/shell/chunks/chunk-6VUEI2GS.js +0 -9
- package/dist/bin/shell/chunks/chunk-BDSRLH5T.js +0 -20
- package/dist/bin/shell/chunks/chunk-NFZDITRV.js +0 -10
- package/dist/bin/shell/chunks/chunk-WT2HWDDA.js +0 -9
- package/dist/bin/shell/chunks/tac-TZBNTR4K.js +0 -2
- package/dist/bundle/chunks/chunk-K3PAWJ7V.js +0 -7
- package/dist/bundle/chunks/chunk-MZLOTDD7.js +0 -99
- package/dist/bundle/chunks/chunk-NQOQ2Q77.js +0 -8
- package/dist/bundle/chunks/chunk-S6BBC45K.js +0 -8
- package/dist/bundle/chunks/chunk-WMLBQOWO.js +0 -9
- package/dist/bundle/chunks/chunk-X6JMGGW2.js +0 -19
- package/dist/bundle/chunks/tac-T7YAU2Y6.js +0 -1
package/dist/bundle/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{B as Ir,C as Rr,D as he,E as Ue,F as te,G as Pe,H as It,I as Lr,J as I,K as Fr,L as Mr,M as _e,N as ws,O as Rt,P as H,a as kr,b as ds,c as _r,d as Tt,e as Q,f as B,g as de,h as re,i as ke,j as Me,k as hs,l as Dt,m as Cr,n as ps,o as Or,p as we,q as Te,r as xr,s as Nr,t as ms,u as ys,v as ze,w as Tr,x as Dr,y as Se,z as gs}from"./chunks/chunk-V4CDPGZH.js";import{a as Ye,b as W,c as Ne,d as Ot,e as xt,f as Nt,g as z,h as Ar}from"./chunks/chunk-YYAPW4OA.js";import{a as Fe,b as $e}from"./chunks/chunk-OJDRYQWQ.js";import{a as mt}from"./chunks/chunk-YNYSPYQ5.js";import{a as me,b as ye,c as fe,d as ge,e as Sr,f as j,g as je,h as kt,i as _t,j as Pr,k as ae,l as Le,m as Ct,n as Ee}from"./chunks/chunk-PSW6BMXW.js";import"./chunks/chunk-NUFRM6SI.js";import{a as xe}from"./chunks/chunk-44UOCSGV.js";import{a as pt}from"./chunks/chunk-DXB73IDG.js";var He=[{name:"echo",load:async()=>(await import("./chunks/echo-O45JWWI2.js")).echoCommand},{name:"cat",load:async()=>(await import("./chunks/cat-C2OBLGHA.js")).catCommand},{name:"printf",load:async()=>(await import("./chunks/printf-KGN6BDCY.js")).printfCommand},{name:"ls",load:async()=>(await import("./chunks/ls-KSXFZCWH.js")).lsCommand},{name:"mkdir",load:async()=>(await import("./chunks/mkdir-QWGXDWUS.js")).mkdirCommand},{name:"rmdir",load:async()=>(await import("./chunks/rmdir-XTQXT7RK.js")).rmdirCommand},{name:"touch",load:async()=>(await import("./chunks/touch-DX2IJOQ4.js")).touchCommand},{name:"rm",load:async()=>(await import("./chunks/rm-KPTLPKPH.js")).rmCommand},{name:"cp",load:async()=>(await import("./chunks/cp-XOYR4ABJ.js")).cpCommand},{name:"mv",load:async()=>(await import("./chunks/mv-Z6MORUFL.js")).mvCommand},{name:"ln",load:async()=>(await import("./chunks/ln-YAIFIHCT.js")).lnCommand},{name:"chmod",load:async()=>(await import("./chunks/chmod-MIKE3OIT.js")).chmodCommand},{name:"pwd",load:async()=>(await import("./chunks/pwd-D4OZ7N27.js")).pwdCommand},{name:"readlink",load:async()=>(await import("./chunks/readlink-IEQO24KU.js")).readlinkCommand},{name:"head",load:async()=>(await import("./chunks/head-HT2B6D2J.js")).headCommand},{name:"tail",load:async()=>(await import("./chunks/tail-S5ULNTJU.js")).tailCommand},{name:"wc",load:async()=>(await import("./chunks/wc-TQB3VNOX.js")).wcCommand},{name:"stat",load:async()=>(await import("./chunks/stat-74KBZFAX.js")).statCommand},{name:"grep",load:async()=>(await import("./chunks/grep-BPEMMINR.js")).grepCommand},{name:"fgrep",load:async()=>(await import("./chunks/grep-BPEMMINR.js")).fgrepCommand},{name:"egrep",load:async()=>(await import("./chunks/grep-BPEMMINR.js")).egrepCommand},{name:"rg",load:async()=>(await import("./chunks/rg-ORQK4GVH.js")).rgCommand},{name:"sed",load:async()=>(await import("./chunks/sed-7HX4RAZG.js")).sedCommand},{name:"awk",load:async()=>(await import("./chunks/awk2-BDPR2JPZ.js")).awkCommand2},{name:"sort",load:async()=>(await import("./chunks/sort-T7TNLWXL.js")).sortCommand},{name:"uniq",load:async()=>(await import("./chunks/uniq-ZXE4O5XB.js")).uniqCommand},{name:"comm",load:async()=>(await import("./chunks/comm-5SLSESQG.js")).commCommand},{name:"cut",load:async()=>(await import("./chunks/cut-LO6YYY5P.js")).cutCommand},{name:"paste",load:async()=>(await import("./chunks/paste-7N6AFSDS.js")).pasteCommand},{name:"tr",load:async()=>(await import("./chunks/tr-RYO2EDCA.js")).trCommand},{name:"rev",load:async()=>(await import("./chunks/rev-XOSYPP45.js")).rev},{name:"nl",load:async()=>(await import("./chunks/nl-U5YJDM32.js")).nl},{name:"fold",load:async()=>(await import("./chunks/fold-LDSORVYE.js")).fold},{name:"expand",load:async()=>(await import("./chunks/expand-DTNXU4LQ.js")).expand},{name:"unexpand",load:async()=>(await import("./chunks/unexpand-RGTMIGZM.js")).unexpand},{name:"strings",load:async()=>(await import("./chunks/strings-7PLOGTPD.js")).strings},{name:"split",load:async()=>(await import("./chunks/split-EZOC5IIZ.js")).split},{name:"column",load:async()=>(await import("./chunks/column-WLPMMSTS.js")).column},{name:"join",load:async()=>(await import("./chunks/join-GG2LDHE5.js")).join},{name:"tee",load:async()=>(await import("./chunks/tee-O7VXZDCO.js")).teeCommand},{name:"find",load:async()=>(await import("./chunks/find-74OP3M7S.js")).findCommand},{name:"basename",load:async()=>(await import("./chunks/basename-AA2KJYZQ.js")).basenameCommand},{name:"dirname",load:async()=>(await import("./chunks/dirname-LEMTZZFS.js")).dirnameCommand},{name:"tree",load:async()=>(await import("./chunks/tree-LYXBS7DC.js")).treeCommand},{name:"du",load:async()=>(await import("./chunks/du-DM4QX4XA.js")).duCommand},{name:"env",load:async()=>(await import("./chunks/env-S547XMN7.js")).envCommand},{name:"printenv",load:async()=>(await import("./chunks/env-S547XMN7.js")).printenvCommand},{name:"alias",load:async()=>(await import("./chunks/alias-JE7RI5QX.js")).aliasCommand},{name:"unalias",load:async()=>(await import("./chunks/alias-JE7RI5QX.js")).unaliasCommand},{name:"history",load:async()=>(await import("./chunks/history-J4QRNGRO.js")).historyCommand},{name:"xargs",load:async()=>(await import("./chunks/xargs-OGI2NN6J.js")).xargsCommand},{name:"true",load:async()=>(await import("./chunks/true-WHJNXCHG.js")).trueCommand},{name:"false",load:async()=>(await import("./chunks/true-WHJNXCHG.js")).falseCommand},{name:"clear",load:async()=>(await import("./chunks/clear-5CZ5X4YR.js")).clearCommand},{name:"bash",load:async()=>(await import("./chunks/bash-DYXMG247.js")).bashCommand},{name:"sh",load:async()=>(await import("./chunks/bash-DYXMG247.js")).shCommand},{name:"jq",load:async()=>(await import("./chunks/jq-OJYNICKX.js")).jqCommand},{name:"base64",load:async()=>(await import("./chunks/base64-A3SGWC34.js")).base64Command},{name:"diff",load:async()=>(await import("./chunks/diff-HJF2MPDN.js")).diffCommand},{name:"date",load:async()=>(await import("./chunks/date-DD7FVA2V.js")).dateCommand},{name:"sleep",load:async()=>(await import("./chunks/sleep-JHK4I472.js")).sleepCommand},{name:"timeout",load:async()=>(await import("./chunks/timeout-5UJUQXOE.js")).timeoutCommand},{name:"time",load:async()=>(await import("./chunks/time-BPT76IHZ.js")).timeCommand},{name:"seq",load:async()=>(await import("./chunks/seq-RN5ZUASB.js")).seqCommand},{name:"expr",load:async()=>(await import("./chunks/expr-3572LAOT.js")).exprCommand},{name:"md5sum",load:async()=>(await import("./chunks/md5sum-INMIK4DX.js")).md5sumCommand},{name:"sha1sum",load:async()=>(await import("./chunks/sha1sum-VJPNLNU6.js")).sha1sumCommand},{name:"sha256sum",load:async()=>(await import("./chunks/sha256sum-PI32XWXY.js")).sha256sumCommand},{name:"file",load:async()=>(await import("./chunks/file-ZIGAJ4YS.js")).fileCommand},{name:"html-to-markdown",load:async()=>(await import("./chunks/html-to-markdown-TFCECAGV.js")).htmlToMarkdownCommand},{name:"help",load:async()=>(await import("./chunks/help-T2NGLTSG.js")).helpCommand},{name:"which",load:async()=>(await import("./chunks/which-NCIYTMAT.js")).whichCommand},{name:"tac",load:async()=>(await import("./chunks/tac-T7YAU2Y6.js")).tac},{name:"hostname",load:async()=>(await import("./chunks/hostname-BK6HG2DE.js")).hostname},{name:"whoami",load:async()=>(await import("./chunks/whoami-DGKU3D2X.js")).whoami},{name:"od",load:async()=>(await import("./chunks/od-VJEF2UR5.js")).od},{name:"gzip",load:async()=>(await import("./chunks/gzip-UTSGNF5Z.js")).gzipCommand},{name:"gunzip",load:async()=>(await import("./chunks/gzip-UTSGNF5Z.js")).gunzipCommand},{name:"zcat",load:async()=>(await import("./chunks/gzip-UTSGNF5Z.js")).zcatCommand}];(typeof __BROWSER__>"u"||!__BROWSER__)&&(He.push({name:"tar",load:async()=>(await import("./chunks/tar-K7K7BL55.js")).tarCommand}),He.push({name:"yq",load:async()=>(await import("./chunks/yq-FD5F3WOJ.js")).yqCommand}),He.push({name:"xan",load:async()=>(await import("./chunks/xan-Z6KVJKEE.js")).xanCommand}),He.push({name:"sqlite3",load:async()=>(await import("./chunks/sqlite3-Z2IGWYCE.js")).sqlite3Command}));var Lt=[];(typeof __BROWSER__>"u"||!__BROWSER__)&&(Lt.push({name:"python3",load:async()=>(await import("./chunks/python3-6Y4Z63NZ.js")).python3Command}),Lt.push({name:"python",load:async()=>(await import("./chunks/python3-6Y4Z63NZ.js")).pythonCommand}));var Wr=[{name:"curl",load:async()=>(await import("./chunks/curl-6L7YZUIH.js")).curlCommand}],zr=new Map;function vs(e){return{name:e.name,async execute(t,s){let r=zr.get(e.name);if(r||(r=await e.load(),zr.set(e.name,r)),s.coverage&&(typeof __BROWSER__>"u"||!__BROWSER__)){let{emitFlagCoverage:n}=await import("./chunks/flag-coverage-KCADAH3N.js");n(s.coverage,e.name,t)}return r.execute(t,s)}}}function _i(){return He.map(e=>e.name)}function Ci(){return Wr.map(e=>e.name)}function Vr(e){return(e?He.filter(s=>e.includes(s.name)):He).map(vs)}function Br(){return Wr.map(vs)}function Oi(){return Lt.map(e=>e.name)}function jr(){return Lt.map(vs)}function Ur(e){return"load"in e&&typeof e.load=="function"}function xi(e,t){return{name:e,execute:t}}function Hr(e){let t=null;return{name:e.name,async execute(s,r){return t||(t=await e.load()),t.execute(s,r)}}}var Ni=new TextEncoder,Ti=new TextDecoder;function De(e,t){if(e instanceof Uint8Array)return e;if(t==="base64")return Uint8Array.from(atob(e),s=>s.charCodeAt(0));if(t==="hex"){let s=new Uint8Array(e.length/2);for(let r=0;r<e.length;r+=2)s[r/2]=parseInt(e.slice(r,r+2),16);return s}if(t==="binary"||t==="latin1"){if(e.length<=65536)return Uint8Array.from(e,n=>n.charCodeAt(0));let r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r}return Ni.encode(e)}function Qe(e,t){if(t==="base64"){if(typeof Buffer<"u")return Buffer.from(e).toString("base64");let s=65536,r="";for(let n=0;n<e.length;n+=s){let i=e.subarray(n,n+s);r+=String.fromCharCode(...i)}return btoa(r)}if(t==="hex")return Array.from(e).map(s=>s.toString(16).padStart(2,"0")).join("");if(t==="binary"||t==="latin1"){if(typeof Buffer<"u")return Buffer.from(e).toString(t);let s=65536;if(e.length<=s)return String.fromCharCode(...e);let r="";for(let n=0;n<e.length;n+=s){let i=e.subarray(n,n+s);r+=String.fromCharCode(...i)}return r}return Ti.decode(e)}function ve(e){if(e!=null)return typeof e=="string"?e:e.encoding??void 0}var Je=new TextEncoder;function Di(e){return typeof e=="object"&&e!==null&&!(e instanceof Uint8Array)&&"content"in e}function ne(e,t){if(e.includes("\0"))throw new Error(`ENOENT: path contains null byte, ${t} '${e}'`)}var Ie=class{data=new Map;constructor(t){if(this.data.set("/",{type:"directory",mode:493,mtime:new Date}),t)for(let[s,r]of Object.entries(t))typeof r=="function"?this.writeFileLazy(s,r):Di(r)?this.writeFileSync(s,r.content,void 0,{mode:r.mode,mtime:r.mtime}):this.writeFileSync(s,r)}normalizePath(t){if(!t||t==="/")return"/";let s=t.endsWith("/")&&t!=="/"?t.slice(0,-1):t;s.startsWith("/")||(s=`/${s}`);let r=s.split("/").filter(i=>i&&i!=="."),n=[];for(let i of r)i===".."?n.pop():n.push(i);return`/${n.join("/")}`||"/"}dirname(t){let s=this.normalizePath(t);if(s==="/")return"/";let r=s.lastIndexOf("/");return r===0?"/":s.slice(0,r)}ensureParentDirs(t){let s=this.dirname(t);s!=="/"&&(this.data.has(s)||(this.ensureParentDirs(s),this.data.set(s,{type:"directory",mode:493,mtime:new Date})))}writeFileSync(t,s,r,n){ne(t,"write");let i=this.normalizePath(t);this.ensureParentDirs(i);let o=ve(r),a=De(s,o);this.data.set(i,{type:"file",content:a,mode:n?.mode??420,mtime:n?.mtime??new Date})}writeFileLazy(t,s,r){ne(t,"write");let n=this.normalizePath(t);this.ensureParentDirs(n),this.data.set(n,{type:"file",lazy:s,mode:r?.mode??420,mtime:r?.mtime??new Date})}async materializeLazy(t,s){let r=await s.lazy(),i={type:"file",content:typeof r=="string"?Je.encode(r):r,mode:s.mode,mtime:s.mtime};return this.data.set(t,i),i}async readFile(t,s){let r=await this.readFileBuffer(t),n=ve(s);return Qe(r,n)}async readFileBuffer(t){ne(t,"open");let s=this.resolvePathWithSymlinks(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, open '${t}'`);if(r.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);if("lazy"in r){let n=await this.materializeLazy(s,r);return n.content instanceof Uint8Array?n.content:Je.encode(n.content)}return r.content instanceof Uint8Array?r.content:Je.encode(r.content)}async writeFile(t,s,r){this.writeFileSync(t,s,r)}async appendFile(t,s,r){ne(t,"append");let n=this.normalizePath(t),i=this.data.get(n);if(i&&i.type==="directory")throw new Error(`EISDIR: illegal operation on a directory, write '${t}'`);let o=ve(r),a=De(s,o);if(i?.type==="file"){let l=i;"lazy"in l&&(l=await this.materializeLazy(n,l));let c="content"in l&&l.content instanceof Uint8Array?l.content:Je.encode("content"in l?l.content:""),u=new Uint8Array(c.length+a.length);u.set(c),u.set(a,c.length),this.data.set(n,{type:"file",content:u,mode:l.mode,mtime:new Date})}else this.writeFileSync(t,s,r)}async exists(t){if(t.includes("\0"))return!1;try{let s=this.resolvePathWithSymlinks(t);return this.data.has(s)}catch{return!1}}async stat(t){ne(t,"stat");let s=this.resolvePathWithSymlinks(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, stat '${t}'`);r.type==="file"&&"lazy"in r&&(r=await this.materializeLazy(s,r));let n=0;return r.type==="file"&&"content"in r&&r.content&&(r.content instanceof Uint8Array?n=r.content.length:n=Je.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:n,mtime:r.mtime||new Date}}async lstat(t){ne(t,"lstat");let s=this.resolveIntermediateSymlinks(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, lstat '${t}'`);if(r.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:r.mode,size:r.target.length,mtime:r.mtime||new Date};r.type==="file"&&"lazy"in r&&(r=await this.materializeLazy(s,r));let n=0;return r.type==="file"&&"content"in r&&r.content&&(r.content instanceof Uint8Array?n=r.content.length:n=Je.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:n,mtime:r.mtime||new Date}}resolveSymlink(t,s){if(s.startsWith("/"))return this.normalizePath(s);let r=this.dirname(t);return this.normalizePath(r==="/"?`/${s}`:`${r}/${s}`)}resolveIntermediateSymlinks(t){let s=this.normalizePath(t);if(s==="/")return"/";let r=s.slice(1).split("/");if(r.length<=1)return s;let n="",i=new Set;for(let o=0;o<r.length-1;o++){let a=r[o];n=`${n}/${a}`;let l=this.data.get(n),c=0,u=40;for(;l&&l.type==="symlink"&&c<u;){if(i.has(n))throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`);i.add(n),n=this.resolveSymlink(n,l.target),l=this.data.get(n),c++}if(c>=u)throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`)}return`${n}/${r[r.length-1]}`}resolvePathWithSymlinks(t){let s=this.normalizePath(t);if(s==="/")return"/";let r=s.slice(1).split("/"),n="",i=new Set;for(let o of r){n=`${n}/${o}`;let a=this.data.get(n),l=0,c=40;for(;a&&a.type==="symlink"&&l<c;){if(i.has(n))throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`);i.add(n),n=this.resolveSymlink(n,a.target),a=this.data.get(n),l++}if(l>=c)throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`)}return n}async mkdir(t,s){this.mkdirSync(t,s)}mkdirSync(t,s){ne(t,"mkdir");let r=this.normalizePath(t);if(this.data.has(r)){if(this.data.get(r)?.type==="file")throw new Error(`EEXIST: file already exists, mkdir '${t}'`);if(!s?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${t}'`);return}let n=this.dirname(r);if(n!=="/"&&!this.data.has(n))if(s?.recursive)this.mkdirSync(n,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${t}'`);this.data.set(r,{type:"directory",mode:493,mtime:new Date})}async readdir(t){return(await this.readdirWithFileTypes(t)).map(r=>r.name)}async readdirWithFileTypes(t){ne(t,"scandir");let s=this.normalizePath(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);let n=new Set;for(;r&&r.type==="symlink";){if(n.has(s))throw new Error(`ELOOP: too many levels of symbolic links, scandir '${t}'`);n.add(s),s=this.resolveSymlink(s,r.target),r=this.data.get(s)}if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);if(r.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${t}'`);let i=s==="/"?"/":`${s}/`,o=new Map;for(let[a,l]of this.data.entries())if(a!==s&&a.startsWith(i)){let c=a.slice(i.length),u=c.split("/")[0];u&&!c.includes("/",u.length)&&!o.has(u)&&o.set(u,{name:u,isFile:l.type==="file",isDirectory:l.type==="directory",isSymbolicLink:l.type==="symlink"})}return Array.from(o.values()).sort((a,l)=>a.name<l.name?-1:a.name>l.name?1:0)}async rm(t,s){ne(t,"rm");let r=this.normalizePath(t),n=this.data.get(r);if(!n){if(s?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${t}'`)}if(n.type==="directory"){let i=await this.readdir(r);if(i.length>0){if(!s?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${t}'`);for(let o of i){let a=r==="/"?`/${o}`:`${r}/${o}`;await this.rm(a,s)}}}this.data.delete(r)}async cp(t,s,r){ne(t,"cp"),ne(s,"cp");let n=this.normalizePath(t),i=this.normalizePath(s),o=this.data.get(n);if(!o)throw new Error(`ENOENT: no such file or directory, cp '${t}'`);if(o.type==="file")if(this.ensureParentDirs(i),"content"in o){let a=o.content instanceof Uint8Array?new Uint8Array(o.content):o.content;this.data.set(i,{...o,content:a})}else this.data.set(i,{...o});else if(o.type==="symlink")this.ensureParentDirs(i),this.data.set(i,{...o});else if(o.type==="directory"){if(!r?.recursive)throw new Error(`EISDIR: is a directory, cp '${t}'`);await this.mkdir(i,{recursive:!0});let a=await this.readdir(n);for(let l of a){let c=n==="/"?`/${l}`:`${n}/${l}`,u=i==="/"?`/${l}`:`${i}/${l}`;await this.cp(c,u,r)}}}async mv(t,s){await this.cp(t,s,{recursive:!0}),await this.rm(t,{recursive:!0})}getAllPaths(){return Array.from(this.data.keys())}resolvePath(t,s){if(s.startsWith("/"))return this.normalizePath(s);let r=t==="/"?`/${s}`:`${t}/${s}`;return this.normalizePath(r)}async chmod(t,s){ne(t,"chmod");let r=this.normalizePath(t),n=this.data.get(r);if(!n)throw new Error(`ENOENT: no such file or directory, chmod '${t}'`);n.mode=s}async symlink(t,s){ne(s,"symlink");let r=this.normalizePath(s);if(this.data.has(r))throw new Error(`EEXIST: file already exists, symlink '${s}'`);this.ensureParentDirs(r),this.data.set(r,{type:"symlink",target:t,mode:511,mtime:new Date})}async link(t,s){ne(t,"link"),ne(s,"link");let r=this.normalizePath(t),n=this.normalizePath(s),i=this.data.get(r);if(!i)throw new Error(`ENOENT: no such file or directory, link '${t}'`);if(i.type!=="file")throw new Error(`EPERM: operation not permitted, link '${t}'`);if(this.data.has(n))throw new Error(`EEXIST: file already exists, link '${s}'`);let o=i;"lazy"in o&&(o=await this.materializeLazy(r,o)),this.ensureParentDirs(n),this.data.set(n,{type:"file",content:o.content,mode:o.mode,mtime:o.mtime})}async readlink(t){ne(t,"readlink");let s=this.normalizePath(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, readlink '${t}'`);if(r.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${t}'`);return r.target}async realpath(t){ne(t,"realpath");let s=this.resolvePathWithSymlinks(t);if(!this.data.has(s))throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);return s}async utimes(t,s,r){ne(t,"utimes");let n=this.normalizePath(t),i=this.resolvePathWithSymlinks(n),o=this.data.get(i);if(!o)throw new Error(`ENOENT: no such file or directory, utimes '${t}'`);o.mtime=r}};function Ii(e){let t=e;return typeof t.mkdirSync=="function"&&typeof t.writeFileSync=="function"}function Ri(e,t){e.mkdirSync("/bin",{recursive:!0}),e.mkdirSync("/usr/bin",{recursive:!0}),t&&(e.mkdirSync("/home/user",{recursive:!0}),e.mkdirSync("/tmp",{recursive:!0}))}function Li(e){e.mkdirSync("/dev",{recursive:!0}),e.writeFileSync("/dev/null",""),e.writeFileSync("/dev/zero",new Uint8Array(0)),e.writeFileSync("/dev/stdin",""),e.writeFileSync("/dev/stdout",""),e.writeFileSync("/dev/stderr","")}function Fi(e,t){e.mkdirSync("/proc/self/fd",{recursive:!0}),e.writeFileSync("/proc/version",`${kr}
|
|
1
|
+
import{B as Ir,C as Rr,D as he,E as Ue,F as te,G as Pe,H as It,I as Lr,J as I,K as Fr,L as Mr,M as _e,N as ws,O as Rt,P as H,a as kr,b as ds,c as _r,d as Tt,e as Q,f as B,g as de,h as re,i as ke,j as Me,k as hs,l as Dt,m as Cr,n as ps,o as Or,p as we,q as Te,r as xr,s as Nr,t as ms,u as ys,v as ze,w as Tr,x as Dr,y as Se,z as gs}from"./chunks/chunk-V4CDPGZH.js";import{a as Ye,b as W,c as Ne,d as Ot,e as xt,f as Nt,g as z,h as Ar}from"./chunks/chunk-YYAPW4OA.js";import{a as Fe,b as $e}from"./chunks/chunk-OJDRYQWQ.js";import{a as mt}from"./chunks/chunk-YNYSPYQ5.js";import{a as me,b as ye,c as fe,d as ge,e as Sr,f as j,g as je,h as kt,i as _t,j as Pr,k as ae,l as Le,m as Ct,n as Ee}from"./chunks/chunk-PSW6BMXW.js";import"./chunks/chunk-NUFRM6SI.js";import{a as xe}from"./chunks/chunk-44UOCSGV.js";import{a as pt}from"./chunks/chunk-DXB73IDG.js";var He=[{name:"echo",load:async()=>(await import("./chunks/echo-O45JWWI2.js")).echoCommand},{name:"cat",load:async()=>(await import("./chunks/cat-C2OBLGHA.js")).catCommand},{name:"printf",load:async()=>(await import("./chunks/printf-IO3EBW5H.js")).printfCommand},{name:"ls",load:async()=>(await import("./chunks/ls-KSXFZCWH.js")).lsCommand},{name:"mkdir",load:async()=>(await import("./chunks/mkdir-QWGXDWUS.js")).mkdirCommand},{name:"rmdir",load:async()=>(await import("./chunks/rmdir-XTQXT7RK.js")).rmdirCommand},{name:"touch",load:async()=>(await import("./chunks/touch-DX2IJOQ4.js")).touchCommand},{name:"rm",load:async()=>(await import("./chunks/rm-KPTLPKPH.js")).rmCommand},{name:"cp",load:async()=>(await import("./chunks/cp-XOYR4ABJ.js")).cpCommand},{name:"mv",load:async()=>(await import("./chunks/mv-Z6MORUFL.js")).mvCommand},{name:"ln",load:async()=>(await import("./chunks/ln-YAIFIHCT.js")).lnCommand},{name:"chmod",load:async()=>(await import("./chunks/chmod-MIKE3OIT.js")).chmodCommand},{name:"pwd",load:async()=>(await import("./chunks/pwd-D4OZ7N27.js")).pwdCommand},{name:"readlink",load:async()=>(await import("./chunks/readlink-IEQO24KU.js")).readlinkCommand},{name:"head",load:async()=>(await import("./chunks/head-HT2B6D2J.js")).headCommand},{name:"tail",load:async()=>(await import("./chunks/tail-S5ULNTJU.js")).tailCommand},{name:"wc",load:async()=>(await import("./chunks/wc-TQB3VNOX.js")).wcCommand},{name:"stat",load:async()=>(await import("./chunks/stat-74KBZFAX.js")).statCommand},{name:"grep",load:async()=>(await import("./chunks/grep-LXKUQUAE.js")).grepCommand},{name:"fgrep",load:async()=>(await import("./chunks/grep-LXKUQUAE.js")).fgrepCommand},{name:"egrep",load:async()=>(await import("./chunks/grep-LXKUQUAE.js")).egrepCommand},{name:"rg",load:async()=>(await import("./chunks/rg-4YNHHQAE.js")).rgCommand},{name:"sed",load:async()=>(await import("./chunks/sed-2K6ULZ6P.js")).sedCommand},{name:"awk",load:async()=>(await import("./chunks/awk2-BDPR2JPZ.js")).awkCommand2},{name:"sort",load:async()=>(await import("./chunks/sort-T7TNLWXL.js")).sortCommand},{name:"uniq",load:async()=>(await import("./chunks/uniq-ZXE4O5XB.js")).uniqCommand},{name:"comm",load:async()=>(await import("./chunks/comm-5SLSESQG.js")).commCommand},{name:"cut",load:async()=>(await import("./chunks/cut-LO6YYY5P.js")).cutCommand},{name:"paste",load:async()=>(await import("./chunks/paste-7N6AFSDS.js")).pasteCommand},{name:"tr",load:async()=>(await import("./chunks/tr-2N7Q3KKJ.js")).trCommand},{name:"rev",load:async()=>(await import("./chunks/rev-XOSYPP45.js")).rev},{name:"nl",load:async()=>(await import("./chunks/nl-U5YJDM32.js")).nl},{name:"fold",load:async()=>(await import("./chunks/fold-LDSORVYE.js")).fold},{name:"expand",load:async()=>(await import("./chunks/expand-DTNXU4LQ.js")).expand},{name:"unexpand",load:async()=>(await import("./chunks/unexpand-RGTMIGZM.js")).unexpand},{name:"strings",load:async()=>(await import("./chunks/strings-7PLOGTPD.js")).strings},{name:"split",load:async()=>(await import("./chunks/split-SITCSYCZ.js")).split},{name:"column",load:async()=>(await import("./chunks/column-WLPMMSTS.js")).column},{name:"join",load:async()=>(await import("./chunks/join-GG2LDHE5.js")).join},{name:"tee",load:async()=>(await import("./chunks/tee-O7VXZDCO.js")).teeCommand},{name:"find",load:async()=>(await import("./chunks/find-6U6YYAEP.js")).findCommand},{name:"basename",load:async()=>(await import("./chunks/basename-AA2KJYZQ.js")).basenameCommand},{name:"dirname",load:async()=>(await import("./chunks/dirname-LEMTZZFS.js")).dirnameCommand},{name:"tree",load:async()=>(await import("./chunks/tree-LYXBS7DC.js")).treeCommand},{name:"du",load:async()=>(await import("./chunks/du-WO2ENHXQ.js")).duCommand},{name:"env",load:async()=>(await import("./chunks/env-S547XMN7.js")).envCommand},{name:"printenv",load:async()=>(await import("./chunks/env-S547XMN7.js")).printenvCommand},{name:"alias",load:async()=>(await import("./chunks/alias-JE7RI5QX.js")).aliasCommand},{name:"unalias",load:async()=>(await import("./chunks/alias-JE7RI5QX.js")).unaliasCommand},{name:"history",load:async()=>(await import("./chunks/history-J4QRNGRO.js")).historyCommand},{name:"xargs",load:async()=>(await import("./chunks/xargs-OGI2NN6J.js")).xargsCommand},{name:"true",load:async()=>(await import("./chunks/true-WHJNXCHG.js")).trueCommand},{name:"false",load:async()=>(await import("./chunks/true-WHJNXCHG.js")).falseCommand},{name:"clear",load:async()=>(await import("./chunks/clear-5CZ5X4YR.js")).clearCommand},{name:"bash",load:async()=>(await import("./chunks/bash-DYXMG247.js")).bashCommand},{name:"sh",load:async()=>(await import("./chunks/bash-DYXMG247.js")).shCommand},{name:"jq",load:async()=>(await import("./chunks/jq-YDGLHC7M.js")).jqCommand},{name:"base64",load:async()=>(await import("./chunks/base64-A3SGWC34.js")).base64Command},{name:"diff",load:async()=>(await import("./chunks/diff-HJF2MPDN.js")).diffCommand},{name:"date",load:async()=>(await import("./chunks/date-DD7FVA2V.js")).dateCommand},{name:"sleep",load:async()=>(await import("./chunks/sleep-U2ORRQJB.js")).sleepCommand},{name:"timeout",load:async()=>(await import("./chunks/timeout-5UJUQXOE.js")).timeoutCommand},{name:"time",load:async()=>(await import("./chunks/time-BPT76IHZ.js")).timeCommand},{name:"seq",load:async()=>(await import("./chunks/seq-RN5ZUASB.js")).seqCommand},{name:"expr",load:async()=>(await import("./chunks/expr-3572LAOT.js")).exprCommand},{name:"md5sum",load:async()=>(await import("./chunks/md5sum-INMIK4DX.js")).md5sumCommand},{name:"sha1sum",load:async()=>(await import("./chunks/sha1sum-VJPNLNU6.js")).sha1sumCommand},{name:"sha256sum",load:async()=>(await import("./chunks/sha256sum-PI32XWXY.js")).sha256sumCommand},{name:"file",load:async()=>(await import("./chunks/file-ZIGAJ4YS.js")).fileCommand},{name:"html-to-markdown",load:async()=>(await import("./chunks/html-to-markdown-TFCECAGV.js")).htmlToMarkdownCommand},{name:"help",load:async()=>(await import("./chunks/help-T2NGLTSG.js")).helpCommand},{name:"which",load:async()=>(await import("./chunks/which-XZHEH76L.js")).whichCommand},{name:"tac",load:async()=>(await import("./chunks/tac-SJGXQ4T2.js")).tac},{name:"hostname",load:async()=>(await import("./chunks/hostname-BK6HG2DE.js")).hostname},{name:"whoami",load:async()=>(await import("./chunks/whoami-DGKU3D2X.js")).whoami},{name:"od",load:async()=>(await import("./chunks/od-VJEF2UR5.js")).od},{name:"gzip",load:async()=>(await import("./chunks/gzip-UTSGNF5Z.js")).gzipCommand},{name:"gunzip",load:async()=>(await import("./chunks/gzip-UTSGNF5Z.js")).gunzipCommand},{name:"zcat",load:async()=>(await import("./chunks/gzip-UTSGNF5Z.js")).zcatCommand}];(typeof __BROWSER__>"u"||!__BROWSER__)&&(He.push({name:"tar",load:async()=>(await import("./chunks/tar-K7K7BL55.js")).tarCommand}),He.push({name:"yq",load:async()=>(await import("./chunks/yq-CESEW5B3.js")).yqCommand}),He.push({name:"xan",load:async()=>(await import("./chunks/xan-Y62IEVU4.js")).xanCommand}),He.push({name:"sqlite3",load:async()=>(await import("./chunks/sqlite3-Z2IGWYCE.js")).sqlite3Command}));var Lt=[];(typeof __BROWSER__>"u"||!__BROWSER__)&&(Lt.push({name:"python3",load:async()=>(await import("./chunks/python3-6Y4Z63NZ.js")).python3Command}),Lt.push({name:"python",load:async()=>(await import("./chunks/python3-6Y4Z63NZ.js")).pythonCommand}));var Wr=[{name:"curl",load:async()=>(await import("./chunks/curl-6L7YZUIH.js")).curlCommand}],zr=new Map;function vs(e){return{name:e.name,async execute(t,s){let r=zr.get(e.name);if(r||(r=await e.load(),zr.set(e.name,r)),s.coverage&&(typeof __BROWSER__>"u"||!__BROWSER__)){let{emitFlagCoverage:n}=await import("./chunks/flag-coverage-ZCNVOYRY.js");n(s.coverage,e.name,t)}return r.execute(t,s)}}}function _i(){return He.map(e=>e.name)}function Ci(){return Wr.map(e=>e.name)}function Vr(e){return(e?He.filter(s=>e.includes(s.name)):He).map(vs)}function Br(){return Wr.map(vs)}function Oi(){return Lt.map(e=>e.name)}function jr(){return Lt.map(vs)}function Ur(e){return"load"in e&&typeof e.load=="function"}function xi(e,t){return{name:e,execute:t}}function Hr(e){let t=null;return{name:e.name,async execute(s,r){return t||(t=await e.load()),t.execute(s,r)}}}var Ni=new TextEncoder,Ti=new TextDecoder;function De(e,t){if(e instanceof Uint8Array)return e;if(t==="base64")return Uint8Array.from(atob(e),s=>s.charCodeAt(0));if(t==="hex"){let s=new Uint8Array(e.length/2);for(let r=0;r<e.length;r+=2)s[r/2]=parseInt(e.slice(r,r+2),16);return s}if(t==="binary"||t==="latin1"){if(e.length<=65536)return Uint8Array.from(e,n=>n.charCodeAt(0));let r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r}return Ni.encode(e)}function Qe(e,t){if(t==="base64"){if(typeof Buffer<"u")return Buffer.from(e).toString("base64");let s=65536,r="";for(let n=0;n<e.length;n+=s){let i=e.subarray(n,n+s);r+=String.fromCharCode(...i)}return btoa(r)}if(t==="hex")return Array.from(e).map(s=>s.toString(16).padStart(2,"0")).join("");if(t==="binary"||t==="latin1"){if(typeof Buffer<"u")return Buffer.from(e).toString(t);let s=65536;if(e.length<=s)return String.fromCharCode(...e);let r="";for(let n=0;n<e.length;n+=s){let i=e.subarray(n,n+s);r+=String.fromCharCode(...i)}return r}return Ti.decode(e)}function ve(e){if(e!=null)return typeof e=="string"?e:e.encoding??void 0}var Je=new TextEncoder;function Di(e){return typeof e=="object"&&e!==null&&!(e instanceof Uint8Array)&&"content"in e}function ne(e,t){if(e.includes("\0"))throw new Error(`ENOENT: path contains null byte, ${t} '${e}'`)}var Ie=class{data=new Map;constructor(t){if(this.data.set("/",{type:"directory",mode:493,mtime:new Date}),t)for(let[s,r]of Object.entries(t))typeof r=="function"?this.writeFileLazy(s,r):Di(r)?this.writeFileSync(s,r.content,void 0,{mode:r.mode,mtime:r.mtime}):this.writeFileSync(s,r)}normalizePath(t){if(!t||t==="/")return"/";let s=t.endsWith("/")&&t!=="/"?t.slice(0,-1):t;s.startsWith("/")||(s=`/${s}`);let r=s.split("/").filter(i=>i&&i!=="."),n=[];for(let i of r)i===".."?n.pop():n.push(i);return`/${n.join("/")}`||"/"}dirname(t){let s=this.normalizePath(t);if(s==="/")return"/";let r=s.lastIndexOf("/");return r===0?"/":s.slice(0,r)}ensureParentDirs(t){let s=this.dirname(t);s!=="/"&&(this.data.has(s)||(this.ensureParentDirs(s),this.data.set(s,{type:"directory",mode:493,mtime:new Date})))}writeFileSync(t,s,r,n){ne(t,"write");let i=this.normalizePath(t);this.ensureParentDirs(i);let o=ve(r),a=De(s,o);this.data.set(i,{type:"file",content:a,mode:n?.mode??420,mtime:n?.mtime??new Date})}writeFileLazy(t,s,r){ne(t,"write");let n=this.normalizePath(t);this.ensureParentDirs(n),this.data.set(n,{type:"file",lazy:s,mode:r?.mode??420,mtime:r?.mtime??new Date})}async materializeLazy(t,s){let r=await s.lazy(),i={type:"file",content:typeof r=="string"?Je.encode(r):r,mode:s.mode,mtime:s.mtime};return this.data.set(t,i),i}async readFile(t,s){let r=await this.readFileBuffer(t),n=ve(s);return Qe(r,n)}async readFileBuffer(t){ne(t,"open");let s=this.resolvePathWithSymlinks(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, open '${t}'`);if(r.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);if("lazy"in r){let n=await this.materializeLazy(s,r);return n.content instanceof Uint8Array?n.content:Je.encode(n.content)}return r.content instanceof Uint8Array?r.content:Je.encode(r.content)}async writeFile(t,s,r){this.writeFileSync(t,s,r)}async appendFile(t,s,r){ne(t,"append");let n=this.normalizePath(t),i=this.data.get(n);if(i&&i.type==="directory")throw new Error(`EISDIR: illegal operation on a directory, write '${t}'`);let o=ve(r),a=De(s,o);if(i?.type==="file"){let l=i;"lazy"in l&&(l=await this.materializeLazy(n,l));let c="content"in l&&l.content instanceof Uint8Array?l.content:Je.encode("content"in l?l.content:""),u=new Uint8Array(c.length+a.length);u.set(c),u.set(a,c.length),this.data.set(n,{type:"file",content:u,mode:l.mode,mtime:new Date})}else this.writeFileSync(t,s,r)}async exists(t){if(t.includes("\0"))return!1;try{let s=this.resolvePathWithSymlinks(t);return this.data.has(s)}catch{return!1}}async stat(t){ne(t,"stat");let s=this.resolvePathWithSymlinks(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, stat '${t}'`);r.type==="file"&&"lazy"in r&&(r=await this.materializeLazy(s,r));let n=0;return r.type==="file"&&"content"in r&&r.content&&(r.content instanceof Uint8Array?n=r.content.length:n=Je.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:n,mtime:r.mtime||new Date}}async lstat(t){ne(t,"lstat");let s=this.resolveIntermediateSymlinks(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, lstat '${t}'`);if(r.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:r.mode,size:r.target.length,mtime:r.mtime||new Date};r.type==="file"&&"lazy"in r&&(r=await this.materializeLazy(s,r));let n=0;return r.type==="file"&&"content"in r&&r.content&&(r.content instanceof Uint8Array?n=r.content.length:n=Je.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:n,mtime:r.mtime||new Date}}resolveSymlink(t,s){if(s.startsWith("/"))return this.normalizePath(s);let r=this.dirname(t);return this.normalizePath(r==="/"?`/${s}`:`${r}/${s}`)}resolveIntermediateSymlinks(t){let s=this.normalizePath(t);if(s==="/")return"/";let r=s.slice(1).split("/");if(r.length<=1)return s;let n="",i=new Set;for(let o=0;o<r.length-1;o++){let a=r[o];n=`${n}/${a}`;let l=this.data.get(n),c=0,u=40;for(;l&&l.type==="symlink"&&c<u;){if(i.has(n))throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`);i.add(n),n=this.resolveSymlink(n,l.target),l=this.data.get(n),c++}if(c>=u)throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`)}return`${n}/${r[r.length-1]}`}resolvePathWithSymlinks(t){let s=this.normalizePath(t);if(s==="/")return"/";let r=s.slice(1).split("/"),n="",i=new Set;for(let o of r){n=`${n}/${o}`;let a=this.data.get(n),l=0,c=40;for(;a&&a.type==="symlink"&&l<c;){if(i.has(n))throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`);i.add(n),n=this.resolveSymlink(n,a.target),a=this.data.get(n),l++}if(l>=c)throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`)}return n}async mkdir(t,s){this.mkdirSync(t,s)}mkdirSync(t,s){ne(t,"mkdir");let r=this.normalizePath(t);if(this.data.has(r)){if(this.data.get(r)?.type==="file")throw new Error(`EEXIST: file already exists, mkdir '${t}'`);if(!s?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${t}'`);return}let n=this.dirname(r);if(n!=="/"&&!this.data.has(n))if(s?.recursive)this.mkdirSync(n,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${t}'`);this.data.set(r,{type:"directory",mode:493,mtime:new Date})}async readdir(t){return(await this.readdirWithFileTypes(t)).map(r=>r.name)}async readdirWithFileTypes(t){ne(t,"scandir");let s=this.normalizePath(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);let n=new Set;for(;r&&r.type==="symlink";){if(n.has(s))throw new Error(`ELOOP: too many levels of symbolic links, scandir '${t}'`);n.add(s),s=this.resolveSymlink(s,r.target),r=this.data.get(s)}if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);if(r.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${t}'`);let i=s==="/"?"/":`${s}/`,o=new Map;for(let[a,l]of this.data.entries())if(a!==s&&a.startsWith(i)){let c=a.slice(i.length),u=c.split("/")[0];u&&!c.includes("/",u.length)&&!o.has(u)&&o.set(u,{name:u,isFile:l.type==="file",isDirectory:l.type==="directory",isSymbolicLink:l.type==="symlink"})}return Array.from(o.values()).sort((a,l)=>a.name<l.name?-1:a.name>l.name?1:0)}async rm(t,s){ne(t,"rm");let r=this.normalizePath(t),n=this.data.get(r);if(!n){if(s?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${t}'`)}if(n.type==="directory"){let i=await this.readdir(r);if(i.length>0){if(!s?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${t}'`);for(let o of i){let a=r==="/"?`/${o}`:`${r}/${o}`;await this.rm(a,s)}}}this.data.delete(r)}async cp(t,s,r){ne(t,"cp"),ne(s,"cp");let n=this.normalizePath(t),i=this.normalizePath(s),o=this.data.get(n);if(!o)throw new Error(`ENOENT: no such file or directory, cp '${t}'`);if(o.type==="file")if(this.ensureParentDirs(i),"content"in o){let a=o.content instanceof Uint8Array?new Uint8Array(o.content):o.content;this.data.set(i,{...o,content:a})}else this.data.set(i,{...o});else if(o.type==="symlink")this.ensureParentDirs(i),this.data.set(i,{...o});else if(o.type==="directory"){if(!r?.recursive)throw new Error(`EISDIR: is a directory, cp '${t}'`);await this.mkdir(i,{recursive:!0});let a=await this.readdir(n);for(let l of a){let c=n==="/"?`/${l}`:`${n}/${l}`,u=i==="/"?`/${l}`:`${i}/${l}`;await this.cp(c,u,r)}}}async mv(t,s){await this.cp(t,s,{recursive:!0}),await this.rm(t,{recursive:!0})}getAllPaths(){return Array.from(this.data.keys())}resolvePath(t,s){if(s.startsWith("/"))return this.normalizePath(s);let r=t==="/"?`/${s}`:`${t}/${s}`;return this.normalizePath(r)}async chmod(t,s){ne(t,"chmod");let r=this.normalizePath(t),n=this.data.get(r);if(!n)throw new Error(`ENOENT: no such file or directory, chmod '${t}'`);n.mode=s}async symlink(t,s){ne(s,"symlink");let r=this.normalizePath(s);if(this.data.has(r))throw new Error(`EEXIST: file already exists, symlink '${s}'`);this.ensureParentDirs(r),this.data.set(r,{type:"symlink",target:t,mode:511,mtime:new Date})}async link(t,s){ne(t,"link"),ne(s,"link");let r=this.normalizePath(t),n=this.normalizePath(s),i=this.data.get(r);if(!i)throw new Error(`ENOENT: no such file or directory, link '${t}'`);if(i.type!=="file")throw new Error(`EPERM: operation not permitted, link '${t}'`);if(this.data.has(n))throw new Error(`EEXIST: file already exists, link '${s}'`);let o=i;"lazy"in o&&(o=await this.materializeLazy(r,o)),this.ensureParentDirs(n),this.data.set(n,{type:"file",content:o.content,mode:o.mode,mtime:o.mtime})}async readlink(t){ne(t,"readlink");let s=this.normalizePath(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, readlink '${t}'`);if(r.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${t}'`);return r.target}async realpath(t){ne(t,"realpath");let s=this.resolvePathWithSymlinks(t);if(!this.data.has(s))throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);return s}async utimes(t,s,r){ne(t,"utimes");let n=this.normalizePath(t),i=this.resolvePathWithSymlinks(n),o=this.data.get(i);if(!o)throw new Error(`ENOENT: no such file or directory, utimes '${t}'`);o.mtime=r}};function Ii(e){let t=e;return typeof t.mkdirSync=="function"&&typeof t.writeFileSync=="function"}function Ri(e,t){e.mkdirSync("/bin",{recursive:!0}),e.mkdirSync("/usr/bin",{recursive:!0}),t&&(e.mkdirSync("/home/user",{recursive:!0}),e.mkdirSync("/tmp",{recursive:!0}))}function Li(e){e.mkdirSync("/dev",{recursive:!0}),e.writeFileSync("/dev/null",""),e.writeFileSync("/dev/zero",new Uint8Array(0)),e.writeFileSync("/dev/stdin",""),e.writeFileSync("/dev/stdout",""),e.writeFileSync("/dev/stderr","")}function Fi(e,t){e.mkdirSync("/proc/self/fd",{recursive:!0}),e.writeFileSync("/proc/version",`${kr}
|
|
2
2
|
`),e.writeFileSync("/proc/self/exe","/bin/bash"),e.writeFileSync("/proc/self/cmdline","bash\0"),e.writeFileSync("/proc/self/comm",`bash
|
|
3
3
|
`),e.writeFileLazy?e.writeFileLazy("/proc/self/status",()=>ds(t)):e.writeFileSync("/proc/self/status",ds(t)),e.writeFileSync("/proc/self/fd/0","/dev/stdin"),e.writeFileSync("/proc/self/fd/1","/dev/stdout"),e.writeFileSync("/proc/self/fd/2","/dev/stderr")}function qr(e,t,s={pid:1,ppid:0,uid:1e3,gid:1e3}){Ii(e)&&(Ri(e,t),Li(e),Fi(e,s))}var Mi=["allexport","errexit","noglob","noclobber","noexec","nounset","pipefail","posix","verbose","xtrace"],zi=["braceexpand","hashall","interactive-comments"];function bs(e){let t=[],s=[...zi.map(r=>({name:r,enabled:!0})),...Mi.map(r=>({name:r,enabled:e[r]}))].sort((r,n)=>r.name.localeCompare(n.name));for(let r of s)r.enabled&&t.push(r.name);return t.join(":")}function et(e){e.state.env.set("SHELLOPTS",bs(e.state.options))}var Wi=["dotglob","expand_aliases","extglob","failglob","globskipdots","globstar","lastpipe","nocaseglob","nocasematch","nullglob","xpg_echo"];function Es(e){let t=[];for(let s of Wi)e[s]&&t.push(s);return t.join(":")}function $s(e){e.state.env.set("BASHOPTS",Es(e.state.shoptOptions))}var Vi="BASH_ALIAS_";function Gr(e){return e.parts.length!==1?!1:e.parts[0].type==="Literal"}function Zr(e){if(e.parts.length!==1)return null;let t=e.parts[0];return t.type==="Literal"?t.value:null}function Kr(e,t){return e.env.get(`${Vi}${t}`)}function Ss(e,t,s){if(!t.name||!Gr(t.name))return t;let r=Zr(t.name);if(!r)return t;let n=Kr(e,r);if(!n||s.has(r))return t;try{s.add(r);let i=new B,o=n,a=n.endsWith(" ");if(!a)for(let f of t.args){let d=Yr(f);o+=` ${d}`}let l;try{l=i.parse(o)}catch(f){if(f instanceof Tt)throw f;return t}if(l.statements.length!==1||l.statements[0].pipelines.length!==1||l.statements[0].pipelines[0].commands.length!==1)return Xr(t,n);let c=l.statements[0].pipelines[0].commands[0];if(c.type!=="SimpleCommand")return Xr(t,n);let u={...c,assignments:[...t.assignments,...c.assignments],redirections:[...c.redirections,...t.redirections],line:t.line};if(a&&t.args.length>0&&(u={...u,args:[...u.args,...t.args]},u.args.length>0)){let f=u.args[0];if(Gr(f)){let d=Zr(f);if(d&&Kr(e,d)){let h={type:"SimpleCommand",name:f,args:u.args.slice(1),assignments:[],redirections:[]},m=Ss(e,h,s);m!==h&&(u={...u,name:m.name,args:[...m.args]})}}}return u}catch(i){throw s.delete(r),i}}function Xr(e,t){let s=t;for(let o of e.args){let a=Yr(o);s+=` ${a}`}let r=new B,n=r.parseWordFromString("eval",!1,!1),i=r.parseWordFromString(`'${s.replace(/'/g,"'\\''")}'`,!1,!1);return{type:"SimpleCommand",name:n,args:[i],assignments:e.assignments,redirections:e.redirections,line:e.line}}function Yr(e){let t="";for(let s of e.parts)switch(s.type){case"Literal":t+=s.value.replace(/([\s"'$`\\*?[\]{}()<>|&;#!])/g,"\\$1");break;case"SingleQuoted":t+=`'${s.value}'`;break;case"DoubleQuoted":t+=`"${s.parts.map(r=>r.type==="Literal"?r.value:`$${r.type}`).join("")}"`;break;case"ParameterExpansion":t+=`\${${s.parameter}}`;break;case"CommandSubstitution":t+="$(...)";break;case"ArithmeticExpansion":t+=`$((${s.expression}))`;break;case"Glob":t+=s.pattern;break;default:break}return t}async function Qr(e,t){let s=t.parts.map(u=>u.type==="Literal"?u.value:"\0").join(""),r=s.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\(/);if(!r||!s.endsWith(")"))return null;let n=r[1],i=[],o=!1,a="",l=!1;for(let u of t.parts)if(u.type==="Literal"){let f=u.value;if(!o){let d=f.indexOf("=(");d!==-1&&(o=!0,f=f.slice(d+2))}if(o){f.endsWith(")")&&(f=f.slice(0,-1));let d=f.split(/(\s+)/);for(let h of d)/^\s+$/.test(h)?(a||l)&&(i.push(a),a="",l=!1):h&&(a+=h)}}else if(o)if(u.type==="BraceExpansion")if(/^\[.+\]=/.test(a))a+=Dt({type:"Word",parts:[u]});else{(a||l)&&(i.push(a),a="",l=!1);let d=await _e(e,{type:"Word",parts:[u]});i.push(...d.values)}else{(u.type==="SingleQuoted"||u.type==="DoubleQuoted"||u.type==="Escaped")&&(l=!0);let f=await I(e,{type:"Word",parts:[u]});a+=f}(a||l)&&i.push(a);let c=i.map(u=>/^\[.+\]=/.test(u)?u:u===""?"''":/[\s"'\\$`!*?[\]{}|&;<>()]/.test(u)&&!u.startsWith("'")&&!u.startsWith('"')?`'${u.replace(/'/g,"'\\''")}'`:u);return`${n}=(${c.join(" ")})`}async function Jr(e,t){let s=-1,r=-1,n=!1;for(let p=0;p<t.parts.length;p++){let g=t.parts[p];if(g.type==="Literal"){let S=g.value.indexOf("+=");if(S!==-1){let P=g.value.slice(0,S);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(P)){s=p,r=S,n=!0;break}if(/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(P)){s=p,r=S,n=!0;break}}let v=g.value.indexOf("=");if(v!==-1&&(v===0||g.value[v-1]!=="+")){let P=g.value.slice(0,v);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(P)||/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(P)){s=p,r=v;break}}}}if(s===-1)return null;let i=t.parts.slice(0,s),o=t.parts[s];if(o.type!=="Literal")return null;let a=n?2:1,l=o.value.slice(0,r),c=o.value.slice(r+a),u=t.parts.slice(s+1),f="";for(let p of i)f+=await I(e,{type:"Word",parts:[p]});f+=l;let d={type:"Word",parts:c!==""?[{type:"Literal",value:c},...u]:u},h=d.parts.length>0?await I(e,d):"";return`${f}${n?"+=":"="}${h}`}var Bi=["tar","yq","xan","sqlite3","python3","python"];function en(e){return Bi.includes(e)}var F=Object.freeze({stdout:"",stderr:"",exitCode:0});function M(e=""){return{stdout:e,stderr:"",exitCode:0}}function A(e,t=1){return{stdout:"",stderr:e,exitCode:t}}function _(e,t,s){return{stdout:e,stderr:t,exitCode:s}}function Y(e){return{stdout:"",stderr:"",exitCode:e?0:1}}function Re(e,t,s="",r=""){throw new ae(e,t,s,r)}function Ps(e,t){if(e.state.loopDepth===0){if(e.state.parentHasLoopContext)throw new Le;return F}if(t.length>1)throw new j(1,"",`bash: break: too many arguments
|
|
4
4
|
`);let s=1;if(t.length>0){let r=Number.parseInt(t[0],10);if(Number.isNaN(r)||r<1)throw new j(128,"",`bash: break: ${t[0]}: numeric argument required
|
package/package.json
CHANGED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{a as b}from"./chunk-JBABAK44.js";import{a as $,b as F}from"./chunk-GTNBSMZR.js";var x={name:"du",summary:"estimate file space usage",usage:"du [OPTION]... [FILE]...",options:["-a write counts for all files, not just directories","-h print sizes in human readable format","-s display only a total for each argument","-c produce a grand total","--max-depth=N print total for directory only if N or fewer levels deep"," --help display this help and exit"]},R={allFiles:{short:"a",type:"boolean"},humanReadable:{short:"h",type:"boolean"},summarize:{short:"s",type:"boolean"},grandTotal:{short:"c",type:"boolean"},maxDepth:{long:"max-depth",type:"number"}},H={name:"du",async execute(a,s){if(F(a))return $(x);let n=b("du",a,R);if(!n.ok)return n.error;let r={allFiles:n.result.flags.allFiles,humanReadable:n.result.flags.humanReadable,summarize:n.result.flags.summarize,grandTotal:n.result.flags.grandTotal,maxDepth:n.result.flags.maxDepth??null},c=n.result.positional;c.length===0&&c.push(".");let i="",m="",p=0;for(let l of c){let z=s.fs.resolvePath(s.cwd,l);try{await s.fs.stat(z);let h=await w(s,z,l,r,0);i+=h.output,p+=h.totalSize,m+=h.stderr}catch{m+=`du: cannot access '${l}': No such file or directory
|
|
3
|
-
`}}return r.grandTotal&&c.length>0&&(i+=`${D(p,r.humanReadable)} total
|
|
4
|
-
`),{stdout:i,stderr:m,exitCode:m?1:0}}};async function w(a,s,n,r,c){let i={output:"",totalSize:0,stderr:""};try{let m=await a.fs.stat(s);if(!m.isDirectory)return i.totalSize=m.size,(r.allFiles||c===0)&&(i.output=D(m.size,r.humanReadable)+" "+n+`
|
|
5
|
-
`),i;let p=0,l=[];if(a.fs.readdirWithFileTypes){let t=await a.fs.readdirWithFileTypes(s),o=t.filter(e=>e.isFile),f=t.filter(e=>e.isDirectory);for(let e=0;e<o.length;e+=100){let u=o.slice(e,e+100),y=await Promise.all(u.map(async d=>{let T=s==="/"?`/${d.name}`:`${s}/${d.name}`;try{let S=await a.fs.stat(T);return{name:d.name,isDirectory:!1,size:S.size}}catch{return{name:d.name,isDirectory:!1,size:0}}}));l.push(...y)}l.push(...f.map(e=>({name:e.name,isDirectory:!0})))}else{let t=await a.fs.readdir(s);for(let o=0;o<t.length;o+=100){let f=t.slice(o,o+100),e=await Promise.all(f.map(async u=>{let y=s==="/"?`/${u}`:`${s}/${u}`;try{let d=await a.fs.stat(y);return{name:u,isDirectory:d.isDirectory,size:d.isDirectory?void 0:d.size}}catch{return{name:u,isDirectory:!1,size:0}}}));l.push(...e)}}l.sort((t,o)=>t.name.localeCompare(o.name));let z=l.filter(t=>!t.isDirectory);for(let t of z){let o=t.size??0;if(p+=o,r.allFiles&&!r.summarize){let f=n==="."?t.name:`${n}/${t.name}`;i.output+=D(o,r.humanReadable)+" "+f+`
|
|
6
|
-
`}}let h=l.filter(t=>t.isDirectory);for(let t=0;t<h.length;t+=100){let o=h.slice(t,t+100),f=await Promise.all(o.map(async e=>{let u=s==="/"?`/${e.name}`:`${s}/${e.name}`,y=n==="."?e.name:`${n}/${e.name}`;return{name:e.name,result:await w(a,u,y,r,c+1)}}));f.sort((e,u)=>e.name.localeCompare(u.name));for(let{result:e}of f)p+=e.totalSize,r.summarize||(r.maxDepth===null||c+1<=r.maxDepth)&&(i.output+=e.output)}i.totalSize=p,(r.summarize||r.maxDepth===null||c<=r.maxDepth)&&(i.output+=`${D(p,r.humanReadable)} ${n}
|
|
7
|
-
`)}catch{i.stderr=`du: cannot read directory '${n}': Permission denied
|
|
8
|
-
`}return i}function D(a,s){return s?a<1024?`${a}`:a<1024*1024?`${(a/1024).toFixed(1)}K`:a<1024*1024*1024?`${(a/(1024*1024)).toFixed(1)}M`:`${(a/(1024*1024*1024)).toFixed(1)}G`:String(Math.ceil(a/1024)||1)}var v={name:"du",flags:[{flag:"-a",type:"boolean"},{flag:"-h",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-c",type:"boolean"},{flag:"--max-depth",type:"value",valueHint:"number"}],needsFiles:!0};export{H as a,v as b};
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{a as N}from"./chunk-SE4C7FJY.js";import{k as x}from"./chunk-K5IXNHO5.js";import{a as G,b as j,c as T}from"./chunk-GTNBSMZR.js";var B=new Map([["alnum","a-zA-Z0-9"],["alpha","a-zA-Z"],["ascii","\\x00-\\x7F"],["blank"," \\t"],["cntrl","\\x00-\\x1F\\x7F"],["digit","0-9"],["graph","!-~"],["lower","a-z"],["print"," -~"],["punct","!-/:-@\\[-`{-~"],["space"," \\t\\n\\r\\f\\v"],["upper","A-Z"],["word","a-zA-Z0-9_"],["xdigit","0-9A-Fa-f"]]);function P(i){let e="",t=0,n=!1;for(;t<i.length;){if(i[t]==="["&&!n){if(i[t+1]==="["&&i[t+2]===":"){let s=i.indexOf(":]]",t+3);if(s!==-1){let r=i.slice(t+3,s),a=B.get(r);if(a){e+=`[${a}]`,t=s+3;continue}}}if(i[t+1]==="^"&&i[t+2]==="["&&i[t+3]===":"){let s=i.indexOf(":]]",t+4);if(s!==-1){let r=i.slice(t+4,s),a=B.get(r);if(a){e+=`[^${a}]`,t=s+3;continue}}}e+="[",t++,n=!0,t<i.length&&i[t]==="^"&&(e+="^",t++),t<i.length&&i[t]==="]"&&(e+="\\]",t++);continue}if(n){if(i[t]==="]"){e+="]",t++,n=!1;continue}if(i[t]==="["&&i[t+1]===":"){let s=i.indexOf(":]",t+2);if(s!==-1){let r=i.slice(t+2,s),a=B.get(r);if(a){e+=a,t=s+2;continue}}}if(i[t]==="\\"&&t+1<i.length){e+=i[t]+i[t+1],t+=2;continue}e+=i[t],t++;continue}if(i[t]==="\\"&&t+1<i.length){let s=i[t+1];if(s==="+"||s==="?"||s==="|"){e+=s,t+=2;continue}if(s==="("||s===")"){e+=s,t+=2;continue}if(s==="{"||s==="}"){e+=s,t+=2;continue}if(s==="t"){e+=" ",t+=2;continue}if(s==="n"){e+=`
|
|
3
|
-
`,t+=2;continue}if(s==="r"){e+="\r",t+=2;continue}e+=i[t]+s,t+=2;continue}if(i[t]==="+"||i[t]==="?"||i[t]==="|"||i[t]==="("||i[t]===")"){e+=`\\${i[t]}`,t++;continue}if(i[t]==="^"&&!(e===""||e.endsWith("("))){e+="\\^",t++;continue}if(i[t]==="$"){let s=t===i.length-1,r=t+2<i.length&&i[t+1]==="\\"&&i[t+2]===")";if(!s&&!r){e+="\\$",t++;continue}}e+=i[t],t++}return e}function D(i){let e="",t=!1;for(let n=0;n<i.length;n++)i[n]==="["&&!t?(t=!0,e+="[",n++,n<i.length&&i[n]==="^"&&(e+="^",n++),n<i.length&&i[n]==="]"&&(e+="]",n++),n--):i[n]==="]"&&t?(t=!1,e+="]"):!t&&i[n]==="{"&&i[n+1]===","?(e+="{0,",n++):e+=i[n];return e}function Z(i){let e="";for(let t=0;t<i.length;t++){let n=i[t],s=n.charCodeAt(0);n==="\\"?e+="\\\\":n===" "?e+="\\t":n===`
|
|
4
|
-
`?e+=`$
|
|
5
|
-
`:n==="\r"?e+="\\r":n==="\x07"?e+="\\a":n==="\b"?e+="\\b":n==="\f"?e+="\\f":n==="\v"?e+="\\v":s<32||s>=127?e+=`\\${s.toString(8).padStart(3,"0")}`:e+=n}return`${e}$`}var ae=1e4;function K(i,e,t){return{patternSpace:"",holdSpace:"",lineNumber:0,totalLines:i,deleted:!1,printed:!1,quit:!1,quitSilent:!1,exitCode:void 0,errorMessage:void 0,appendBuffer:[],substitutionMade:!1,lineNumberOutput:[],nCommandOutput:[],restartCycle:!1,inDRestartedCycle:!1,currentFilename:e,pendingFileReads:[],pendingFileWrites:[],pendingExecute:void 0,rangeStates:t||new Map,linesConsumedInCycle:0}}function ce(i){return typeof i=="object"&&"first"in i&&"step"in i}function le(i){return typeof i=="object"&&"offset"in i}function O(i,e,t,n,s){if(i==="$")return e===t;if(typeof i=="number")return e===i;if(ce(i)){let{first:r,step:a}=i;return a===0?e===r:(e-r)%a===0&&e>=r}if(typeof i=="object"&&"pattern"in i)try{let r=i.pattern;r===""&&s?.lastPattern?r=s.lastPattern:r!==""&&s&&(s.lastPattern=r);let a=D(P(r));return N(a).test(n)}catch{return!1}return!1}function W(i){let e=t=>t===void 0?"undefined":t==="$"?"$":typeof t=="number"?String(t):"pattern"in t?`/${t.pattern}/`:"first"in t?`${t.first}~${t.step}`:"unknown";return`${e(i.start)},${e(i.end)}`}function oe(i,e,t,n,s,r){if(!i||!i.start&&!i.end)return!0;let a=i.start,c=i.end;if(a!==void 0&&c===void 0)return O(a,e,t,n,r);if(a!==void 0&&c!==void 0){let o=typeof a=="object"&&"pattern"in a,d=typeof c=="object"&&"pattern"in c,p=le(c);if(p&&s){let m=W(i),f=s.get(m);if(f||(f={active:!1},s.set(m,f)),f.active){let u=f.startLine||e;return e>=u+c.offset&&(f.active=!1,s.set(m,f)),!0}else return O(a,e,t,n,r)?(f.active=!0,f.startLine=e,s.set(m,f),c.offset===0&&(f.active=!1,s.set(m,f)),!0):!1}if(!o&&!d&&!p){let m=typeof a=="number"?a:a==="$"?t:1,f=typeof c=="number"?c:t;if(m<=f)return e>=m&&e<=f;if(s){let u=W(i),h=s.get(u);return h||(h={active:!1},s.set(u,h)),!h.completed&&e>=m?(h.completed=!0,s.set(u,h),!0):!1}return!1}if(s){let m=W(i),f=s.get(m);if(f||(f={active:!1},s.set(m,f)),f.active)return O(c,e,t,n,r)&&(f.active=!1,typeof a=="number"&&(f.completed=!0),s.set(m,f)),!0;{if(f.completed)return!1;let u=!1;return typeof a=="number"?u=e>=a:u=O(a,e,t,n,r),u?(f.active=!0,f.startLine=e,s.set(m,f),O(c,e,t,n,r)&&(f.active=!1,typeof a=="number"&&(f.completed=!0),s.set(m,f)),!0):!1}}return O(a,e,t,n,r)}return!0}function I(i,e,t,n,s,r){let a=oe(i,e,t,n,s,r);return i?.negated?!a:a}function ue(i,e,t,n){let s="",r=0,a=!1;for(;r<=i.length;){e.lastIndex=r;let c=e.exec(i);if(!c){s+=i.slice(r);break}if(c.index!==r){s+=i.slice(r,c.index),r=c.index,a=!1;continue}let o=c[0],d=c.slice(1);if(a&&o.length===0){if(r<i.length)s+=i[r],r++;else break;a=!1;continue}if(s+=n(o,d),a=!1,o.length===0)if(r<i.length)s+=i[r],r++;else break;else r+=o.length,a=!0}return s}function q(i,e,t){let n="",s=0;for(;s<i.length;){if(i[s]==="\\"&&s+1<i.length){let r=i[s+1];if(r==="&"){n+="&",s+=2;continue}if(r==="n"){n+=`
|
|
6
|
-
`,s+=2;continue}if(r==="t"){n+=" ",s+=2;continue}if(r==="r"){n+="\r",s+=2;continue}let a=parseInt(r,10);if(a===0){n+=e,s+=2;continue}if(a>=1&&a<=9){n+=t[a-1]||"",s+=2;continue}n+=r,s+=2;continue}if(i[s]==="&"){n+=e,s++;continue}n+=i[s],s++}return n}function he(i,e){let{lineNumber:t,totalLines:n,patternSpace:s}=e;if(i.type==="label"){e.coverage?.hit(`sed:cmd:${i.type}`);return}if(I(i.address,t,n,s,e.rangeStates,e))switch(e.coverage?.hit(`sed:cmd:${i.type}`),i.type){case"substitute":{let r=i,a="";r.global&&(a+="g"),r.ignoreCase&&(a+="i");let c=r.pattern;c===""&&e.lastPattern?c=e.lastPattern:c!==""&&(e.lastPattern=c);let o=D(r.extendedRegex?c:P(c));try{let d=N(o,a),p=d.test(e.patternSpace);if(d.lastIndex=0,p){if(e.substitutionMade=!0,r.nthOccurrence&&r.nthOccurrence>0&&!r.global){let E=0,m=r.nthOccurrence,f=N(o,`g${r.ignoreCase?"i":""}`);e.patternSpace=f.replace(e.patternSpace,(u,...h)=>{if(E++,E===m){let b=h.slice(0,-2);return q(r.replacement,u,b)}return u})}else if(r.global){let E=N(o,`g${r.ignoreCase?"i":""}`);e.patternSpace=ue(e.patternSpace,E,r.replacement,(m,f)=>q(r.replacement,m,f))}else e.patternSpace=d.replace(e.patternSpace,(E,...m)=>{let f=m.slice(0,-2);return q(r.replacement,E,f)});r.printOnMatch&&e.lineNumberOutput.push(e.patternSpace)}}catch{}break}case"print":e.lineNumberOutput.push(e.patternSpace);break;case"printFirstLine":{let r=e.patternSpace.indexOf(`
|
|
7
|
-
`);r!==-1?e.lineNumberOutput.push(e.patternSpace.slice(0,r)):e.lineNumberOutput.push(e.patternSpace);break}case"delete":e.deleted=!0;break;case"deleteFirstLine":{let r=e.patternSpace.indexOf(`
|
|
8
|
-
`);r!==-1?(e.patternSpace=e.patternSpace.slice(r+1),e.restartCycle=!0,e.inDRestartedCycle=!0):e.deleted=!0;break}case"zap":e.patternSpace="";break;case"append":e.appendBuffer.push(i.text);break;case"insert":e.appendBuffer.unshift(`__INSERT__${i.text}`);break;case"change":e.deleted=!0,e.changedText=i.text;break;case"hold":e.holdSpace=e.patternSpace;break;case"holdAppend":e.holdSpace?e.holdSpace+=`
|
|
9
|
-
${e.patternSpace}`:e.holdSpace=e.patternSpace;break;case"get":e.patternSpace=e.holdSpace;break;case"getAppend":e.patternSpace+=`
|
|
10
|
-
${e.holdSpace}`;break;case"exchange":{let r=e.patternSpace;e.patternSpace=e.holdSpace,e.holdSpace=r;break}case"next":e.printed=!0;break;case"quit":e.quit=!0,i.exitCode!==void 0&&(e.exitCode=i.exitCode);break;case"quitSilent":e.quit=!0,e.quitSilent=!0,i.exitCode!==void 0&&(e.exitCode=i.exitCode);break;case"list":{let r=Z(e.patternSpace);e.lineNumberOutput.push(r);break}case"printFilename":e.currentFilename&&e.lineNumberOutput.push(e.currentFilename);break;case"version":{let r=[4,8,0];if(i.minVersion){let a=i.minVersion.split("."),c=[],o=!1;for(let d of a){let p=parseInt(d,10);if(Number.isNaN(p)||p<0){e.quit=!0,e.exitCode=1,e.errorMessage=`sed: invalid version string: ${i.minVersion}`,o=!0;break}c.push(p)}if(!o){for(;c.length<3;)c.push(0);for(let d=0;d<3;d++){if(c[d]>r[d]){e.quit=!0,e.exitCode=1,e.errorMessage=`sed: this is not GNU sed version ${i.minVersion}`;break}if(c[d]<r[d])break}}}break}case"readFile":e.pendingFileReads.push({filename:i.filename,wholeFile:!0});break;case"readFileLine":e.pendingFileReads.push({filename:i.filename,wholeFile:!1});break;case"writeFile":e.pendingFileWrites.push({filename:i.filename,content:`${e.patternSpace}
|
|
11
|
-
`});break;case"writeFirstLine":{let r=e.patternSpace.indexOf(`
|
|
12
|
-
`),a=r!==-1?e.patternSpace.slice(0,r):e.patternSpace;e.pendingFileWrites.push({filename:i.filename,content:`${a}
|
|
13
|
-
`});break}case"execute":i.command?e.pendingExecute={command:i.command,replacePattern:!1}:e.pendingExecute={command:e.patternSpace,replacePattern:!0};break;case"transliterate":e.patternSpace=de(e.patternSpace,i);break;case"lineNumber":e.lineNumberOutput.push(String(e.lineNumber));break;case"branch":break;case"branchOnSubst":break;case"branchOnNoSubst":break;case"group":break}}function de(i,e){let t="";for(let n of i){let s=e.source.indexOf(n);s!==-1?t+=e.dest[s]:t+=n}return t}function U(i,e,t,n){let s=new Map;for(let o=0;o<i.length;o++){let d=i[o];d.type==="label"&&s.set(d.name,o)}let r=n?.maxIterations??ae,a=0,c=0;for(;c<i.length;){if(a++,a>r)throw new x(`sed: command execution exceeded maximum iterations (${r})`,"iterations");if(e.deleted||e.quit||e.quitSilent||e.restartCycle)break;let o=i[c];if(o.type==="next"){if(I(o.address,e.lineNumber,e.totalLines,e.patternSpace,e.rangeStates,e))if(e.coverage?.hit("sed:cmd:next"),e.nCommandOutput.push(e.patternSpace),t&&t.currentLineIndex+e.linesConsumedInCycle+1<t.lines.length){e.linesConsumedInCycle++;let d=t.lines[t.currentLineIndex+e.linesConsumedInCycle];e.patternSpace=d,e.lineNumber=t.currentLineIndex+e.linesConsumedInCycle+1,e.substitutionMade=!1}else{e.quit=!0,e.deleted=!0;break}c++;continue}if(o.type==="nextAppend"){if(I(o.address,e.lineNumber,e.totalLines,e.patternSpace,e.rangeStates,e))if(e.coverage?.hit("sed:cmd:nextAppend"),t&&t.currentLineIndex+e.linesConsumedInCycle+1<t.lines.length){e.linesConsumedInCycle++;let d=t.lines[t.currentLineIndex+e.linesConsumedInCycle];e.patternSpace+=`
|
|
14
|
-
${d}`,e.lineNumber=t.currentLineIndex+e.linesConsumedInCycle+1}else{e.quit=!0;break}c++;continue}if(o.type==="branch"){let d=o;if(I(d.address,e.lineNumber,e.totalLines,e.patternSpace,e.rangeStates,e)){if(e.coverage?.hit("sed:cmd:branch"),d.label){let p=s.get(d.label);if(p!==void 0){c=p;continue}e.branchRequest=d.label;break}break}c++;continue}if(o.type==="branchOnSubst"){let d=o;if(I(d.address,e.lineNumber,e.totalLines,e.patternSpace,e.rangeStates,e)&&(e.coverage?.hit("sed:cmd:branchOnSubst"),e.substitutionMade)){if(e.substitutionMade=!1,d.label){let p=s.get(d.label);if(p!==void 0){c=p;continue}e.branchRequest=d.label;break}break}c++;continue}if(o.type==="branchOnNoSubst"){let d=o;if(I(d.address,e.lineNumber,e.totalLines,e.patternSpace,e.rangeStates,e)&&(e.coverage?.hit("sed:cmd:branchOnNoSubst"),!e.substitutionMade)){if(d.label){let p=s.get(d.label);if(p!==void 0){c=p;continue}e.branchRequest=d.label;break}break}c++;continue}if(o.type==="group"){let d=o;if(I(d.address,e.lineNumber,e.totalLines,e.patternSpace,e.rangeStates,e)&&(e.coverage?.hit("sed:cmd:group"),U(d.commands,e,t,n),e.branchRequest)){let p=s.get(e.branchRequest);if(p!==void 0){e.branchRequest=void 0,c=p;continue}break}c++;continue}he(o,e),c++}return e.linesConsumedInCycle}var l;(function(i){i.NUMBER="NUMBER",i.DOLLAR="DOLLAR",i.PATTERN="PATTERN",i.STEP="STEP",i.RELATIVE_OFFSET="RELATIVE_OFFSET",i.LBRACE="LBRACE",i.RBRACE="RBRACE",i.SEMICOLON="SEMICOLON",i.NEWLINE="NEWLINE",i.COMMA="COMMA",i.NEGATION="NEGATION",i.COMMAND="COMMAND",i.SUBSTITUTE="SUBSTITUTE",i.TRANSLITERATE="TRANSLITERATE",i.LABEL_DEF="LABEL_DEF",i.BRANCH="BRANCH",i.BRANCH_ON_SUBST="BRANCH_ON_SUBST",i.BRANCH_ON_NO_SUBST="BRANCH_ON_NO_SUBST",i.TEXT_CMD="TEXT_CMD",i.FILE_READ="FILE_READ",i.FILE_READ_LINE="FILE_READ_LINE",i.FILE_WRITE="FILE_WRITE",i.FILE_WRITE_LINE="FILE_WRITE_LINE",i.EXECUTE="EXECUTE",i.VERSION="VERSION",i.EOF="EOF",i.ERROR="ERROR"})(l||(l={}));var w=class{input;pos=0;line=1;column=1;constructor(e){this.input=e}tokenize(){let e=[];for(;this.pos<this.input.length;){let t=this.nextToken();t&&e.push(t)}return e.push(this.makeToken(l.EOF,"")),e}makeToken(e,t,n){return{type:e,value:t,line:this.line,column:this.column,...n}}peek(e=0){return this.input[this.pos+e]||""}advance(){let e=this.input[this.pos++]||"";return e===`
|
|
15
|
-
`?(this.line++,this.column=1):this.column++,e}readEscapedString(e){let t="";for(;this.pos<this.input.length&&this.peek()!==e;)if(this.peek()==="\\"){this.advance();let n=this.advance();n==="n"?t+=`
|
|
16
|
-
`:n==="t"?t+=" ":t+=n}else{if(this.peek()===`
|
|
17
|
-
`)return null;t+=this.advance()}return t}skipWhitespace(){for(;this.pos<this.input.length;){let e=this.peek();if(e===" "||e===" "||e==="\r")this.advance();else if(e==="#")for(;this.pos<this.input.length&&this.peek()!==`
|
|
18
|
-
`;)this.advance();else break}}nextToken(){if(this.skipWhitespace(),this.pos>=this.input.length)return null;let e=this.line,t=this.column,n=this.peek();return n===`
|
|
19
|
-
`?(this.advance(),{type:l.NEWLINE,value:`
|
|
20
|
-
`,line:e,column:t}):n===";"?(this.advance(),{type:l.SEMICOLON,value:";",line:e,column:t}):n==="{"?(this.advance(),{type:l.LBRACE,value:"{",line:e,column:t}):n==="}"?(this.advance(),{type:l.RBRACE,value:"}",line:e,column:t}):n===","?(this.advance(),{type:l.COMMA,value:",",line:e,column:t}):n==="!"?(this.advance(),{type:l.NEGATION,value:"!",line:e,column:t}):n==="$"?(this.advance(),{type:l.DOLLAR,value:"$",line:e,column:t}):this.isDigit(n)?this.readNumber():n==="+"&&this.isDigit(this.input[this.pos+1]||"")?this.readRelativeOffset():n==="/"?this.readPattern():n===":"?this.readLabelDef():this.readCommand()}readNumber(){let e=this.line,t=this.column,n="";for(;this.isDigit(this.peek());)n+=this.advance();if(this.peek()==="~"){this.advance();let s="";for(;this.isDigit(this.peek());)s+=this.advance();let r=parseInt(n,10),a=parseInt(s,10)||0;return{type:l.STEP,value:`${r}~${a}`,first:r,step:a,line:e,column:t}}return{type:l.NUMBER,value:parseInt(n,10),line:e,column:t}}readRelativeOffset(){let e=this.line,t=this.column;this.advance();let n="";for(;this.isDigit(this.peek());)n+=this.advance();let s=parseInt(n,10)||0;return{type:l.RELATIVE_OFFSET,value:`+${s}`,offset:s,line:e,column:t}}readPattern(){let e=this.line,t=this.column;this.advance();let n="",s=!1;for(;this.pos<this.input.length;){let r=this.peek();if(r==="/"&&!s)break;if(r==="\\")n+=this.advance(),this.pos<this.input.length&&this.peek()!==`
|
|
21
|
-
`&&(n+=this.advance());else{if(r===`
|
|
22
|
-
`)break;r==="["&&!s?(s=!0,n+=this.advance(),this.peek()==="^"&&(n+=this.advance()),this.peek()==="]"&&(n+=this.advance())):r==="]"&&s?(s=!1,n+=this.advance()):n+=this.advance()}}return this.peek()==="/"&&this.advance(),{type:l.PATTERN,value:n,pattern:n,line:e,column:t}}readLabelDef(){let e=this.line,t=this.column;for(this.advance();this.peek()===" "||this.peek()===" ";)this.advance();let n="";for(;this.pos<this.input.length;){let s=this.peek();if(s===" "||s===" "||s===`
|
|
23
|
-
`||s===";"||s==="}"||s==="{")break;n+=this.advance()}return{type:l.LABEL_DEF,value:n,label:n,line:e,column:t}}readCommand(){let e=this.line,t=this.column,n=this.advance();switch(n){case"s":return this.readSubstitute(e,t);case"y":return this.readTransliterate(e,t);case"a":case"i":case"c":return this.readTextCommand(n,e,t);case"b":return this.readBranch(l.BRANCH,"b",e,t);case"t":return this.readBranch(l.BRANCH_ON_SUBST,"t",e,t);case"T":return this.readBranch(l.BRANCH_ON_NO_SUBST,"T",e,t);case"r":return this.readFileCommand(l.FILE_READ,"r",e,t);case"R":return this.readFileCommand(l.FILE_READ_LINE,"R",e,t);case"w":return this.readFileCommand(l.FILE_WRITE,"w",e,t);case"W":return this.readFileCommand(l.FILE_WRITE_LINE,"W",e,t);case"e":return this.readExecute(e,t);case"p":case"P":case"d":case"D":case"h":case"H":case"g":case"G":case"x":case"n":case"N":case"q":case"Q":case"z":case"=":case"l":case"F":return{type:l.COMMAND,value:n,line:e,column:t};case"v":return this.readVersion(e,t);default:return{type:l.ERROR,value:n,line:e,column:t}}}readSubstitute(e,t){let n=this.advance();if(!n||n===`
|
|
24
|
-
`)return{type:l.ERROR,value:"s",line:e,column:t};let s="",r=!1;for(;this.pos<this.input.length;){let o=this.peek();if(o===n&&!r)break;if(o==="\\")this.advance(),this.pos<this.input.length&&this.peek()!==`
|
|
25
|
-
`?this.peek()===n&&!r?s+=this.advance():(s+="\\",s+=this.advance()):s+="\\";else{if(o===`
|
|
26
|
-
`)break;o==="["&&!r?(r=!0,s+=this.advance(),this.peek()==="^"&&(s+=this.advance()),this.peek()==="]"&&(s+=this.advance())):o==="]"&&r?(r=!1,s+=this.advance()):s+=this.advance()}}if(this.peek()!==n)return{type:l.ERROR,value:"unterminated substitution pattern",line:e,column:t};this.advance();let a="";for(;this.pos<this.input.length&&this.peek()!==n;)if(this.peek()==="\\")if(this.advance(),this.pos<this.input.length){let o=this.peek();o==="\\"?(this.advance(),this.pos<this.input.length&&this.peek()===`
|
|
27
|
-
`?(a+=`
|
|
28
|
-
`,this.advance()):a+="\\"):o===`
|
|
29
|
-
`?(a+=`
|
|
30
|
-
`,this.advance()):a+=`\\${this.advance()}`}else a+="\\";else{if(this.peek()===`
|
|
31
|
-
`)break;a+=this.advance()}this.peek()===n&&this.advance();let c="";for(;this.pos<this.input.length;){let o=this.peek();if(o==="g"||o==="i"||o==="p"||o==="I"||this.isDigit(o))c+=this.advance();else break}return{type:l.SUBSTITUTE,value:`s${n}${s}${n}${a}${n}${c}`,pattern:s,replacement:a,flags:c,line:e,column:t}}readTransliterate(e,t){let n=this.advance();if(!n||n===`
|
|
32
|
-
`)return{type:l.ERROR,value:"y",line:e,column:t};let s=this.readEscapedString(n);if(s===null||this.peek()!==n)return{type:l.ERROR,value:"unterminated transliteration source",line:e,column:t};this.advance();let r=this.readEscapedString(n);if(r===null||this.peek()!==n)return{type:l.ERROR,value:"unterminated transliteration dest",line:e,column:t};this.advance();let a=this.peek();for(;a===" "||a===" ";)this.advance(),a=this.peek();return a!==""&&a!==";"&&a!==`
|
|
33
|
-
`&&a!=="}"?{type:l.ERROR,value:"extra text at the end of a transform command",line:e,column:t}:{type:l.TRANSLITERATE,value:`y${n}${s}${n}${r}${n}`,source:s,dest:r,line:e,column:t}}readTextCommand(e,t,n){let s=!1;this.peek()==="\\"&&this.pos+1<this.input.length&&(this.input[this.pos+1]===`
|
|
34
|
-
`||this.input[this.pos+1]===" "||this.input[this.pos+1]===" ")&&(s=!0,this.advance()),(this.peek()===" "||this.peek()===" ")&&this.advance(),this.peek()==="\\"&&this.pos+1<this.input.length&&(this.input[this.pos+1]===" "||this.input[this.pos+1]===" ")&&this.advance(),s&&this.peek()===`
|
|
35
|
-
`&&this.advance();let r="";for(;this.pos<this.input.length;){let a=this.peek();if(a===`
|
|
36
|
-
`){if(r.endsWith("\\")){r=`${r.slice(0,-1)}
|
|
37
|
-
`,this.advance();continue}break}if(a==="\\"&&this.pos+1<this.input.length){let c=this.input[this.pos+1];if(c==="n"){r+=`
|
|
38
|
-
`,this.advance(),this.advance();continue}if(c==="t"){r+=" ",this.advance(),this.advance();continue}if(c==="r"){r+="\r",this.advance(),this.advance();continue}}r+=this.advance()}return{type:l.TEXT_CMD,value:e,text:r,line:t,column:n}}readBranch(e,t,n,s){for(;this.peek()===" "||this.peek()===" ";)this.advance();let r="";for(;this.pos<this.input.length;){let a=this.peek();if(a===" "||a===" "||a===`
|
|
39
|
-
`||a===";"||a==="}"||a==="{")break;r+=this.advance()}return{type:e,value:t,label:r||void 0,line:n,column:s}}readVersion(e,t){for(;this.peek()===" "||this.peek()===" ";)this.advance();let n="";for(;this.pos<this.input.length;){let s=this.peek();if(s===" "||s===" "||s===`
|
|
40
|
-
`||s===";"||s==="}"||s==="{")break;n+=this.advance()}return{type:l.VERSION,value:"v",label:n||void 0,line:e,column:t}}readFileCommand(e,t,n,s){for(;this.peek()===" "||this.peek()===" ";)this.advance();let r="";for(;this.pos<this.input.length;){let a=this.peek();if(a===`
|
|
41
|
-
`||a===";")break;r+=this.advance()}return{type:e,value:t,filename:r.trim(),line:n,column:s}}readExecute(e,t){for(;this.peek()===" "||this.peek()===" ";)this.advance();let n="";for(;this.pos<this.input.length;){let s=this.peek();if(s===`
|
|
42
|
-
`||s===";")break;n+=this.advance()}return{type:l.EXECUTE,value:"e",command:n.trim()||void 0,line:e,column:t}}isDigit(e){return e>="0"&&e<="9"}};var H=class{scripts;tokens=[];pos=0;extendedRegex=!1;constructor(e,t=!1){this.scripts=e,this.extendedRegex=t}parse(){let e=[];for(let t of this.scripts){let n=new w(t);for(this.tokens=n.tokenize(),this.pos=0;!this.isAtEnd();){if(this.check(l.NEWLINE)||this.check(l.SEMICOLON)){this.advance();continue}let s=this.pos,r=this.parseCommand();if(r.error)return{commands:[],error:r.error};if(r.command&&e.push(r.command),this.pos===s&&!this.isAtEnd())return{commands:[],error:`unknown command: '${this.peek()?.value??this.peek()?.type}'`}}}return{commands:e}}parseCommand(){let e=this.parseAddressRange();if(e?.error)return{command:null,error:e.error};let t=e?.address;for(this.check(l.NEGATION)&&(this.advance(),t&&(t.negated=!0));this.check(l.NEWLINE)||this.check(l.SEMICOLON);)this.advance();if(this.isAtEnd())return t&&(t.start!==void 0||t.end!==void 0)?{command:null,error:"command expected"}:{command:null};let n=this.peek();switch(n.type){case l.COMMAND:return this.parseSimpleCommand(n,t);case l.SUBSTITUTE:return this.parseSubstituteFromToken(n,t);case l.TRANSLITERATE:return this.parseTransliterateFromToken(n,t);case l.LABEL_DEF:return this.advance(),{command:{type:"label",name:n.label||""}};case l.BRANCH:return this.advance(),{command:{type:"branch",address:t,label:n.label}};case l.BRANCH_ON_SUBST:return this.advance(),{command:{type:"branchOnSubst",address:t,label:n.label}};case l.BRANCH_ON_NO_SUBST:return this.advance(),{command:{type:"branchOnNoSubst",address:t,label:n.label}};case l.TEXT_CMD:return this.advance(),this.parseTextCommand(n,t);case l.FILE_READ:return this.advance(),{command:{type:"readFile",address:t,filename:n.filename||""}};case l.FILE_READ_LINE:return this.advance(),{command:{type:"readFileLine",address:t,filename:n.filename||""}};case l.FILE_WRITE:return this.advance(),{command:{type:"writeFile",address:t,filename:n.filename||""}};case l.FILE_WRITE_LINE:return this.advance(),{command:{type:"writeFirstLine",address:t,filename:n.filename||""}};case l.EXECUTE:return this.advance(),{command:{type:"execute",address:t,command:n.command}};case l.VERSION:return this.advance(),{command:{type:"version",address:t,minVersion:n.label}};case l.LBRACE:return this.parseGroup(t);case l.RBRACE:return{command:null};case l.ERROR:return{command:null,error:`invalid command: ${n.value}`};default:return t&&(t.start!==void 0||t.end!==void 0)?{command:null,error:"command expected"}:{command:null}}}parseSimpleCommand(e,t){this.advance();let n=e.value;switch(n){case"p":return{command:{type:"print",address:t}};case"P":return{command:{type:"printFirstLine",address:t}};case"d":return{command:{type:"delete",address:t}};case"D":return{command:{type:"deleteFirstLine",address:t}};case"h":return{command:{type:"hold",address:t}};case"H":return{command:{type:"holdAppend",address:t}};case"g":return{command:{type:"get",address:t}};case"G":return{command:{type:"getAppend",address:t}};case"x":return{command:{type:"exchange",address:t}};case"n":return{command:{type:"next",address:t}};case"N":return{command:{type:"nextAppend",address:t}};case"q":return{command:{type:"quit",address:t}};case"Q":return{command:{type:"quitSilent",address:t}};case"z":return{command:{type:"zap",address:t}};case"=":return{command:{type:"lineNumber",address:t}};case"l":return{command:{type:"list",address:t}};case"F":return{command:{type:"printFilename",address:t}};default:return{command:null,error:`unknown command: ${n}`}}}parseSubstituteFromToken(e,t){this.advance();let n=e.flags||"",s,r=n.match(/(\d+)/);return r&&(s=parseInt(r[1],10)),{command:{type:"substitute",address:t,pattern:e.pattern||"",replacement:e.replacement||"",global:n.includes("g"),ignoreCase:n.includes("i")||n.includes("I"),printOnMatch:n.includes("p"),nthOccurrence:s,extendedRegex:this.extendedRegex}}}parseTransliterateFromToken(e,t){this.advance();let n=e.source||"",s=e.dest||"";return n.length!==s.length?{command:null,error:"transliteration sets must have same length"}:{command:{type:"transliterate",address:t,source:n,dest:s}}}parseTextCommand(e,t){let n=e.value,s=e.text||"";switch(n){case"a":return{command:{type:"append",address:t,text:s}};case"i":return{command:{type:"insert",address:t,text:s}};case"c":return{command:{type:"change",address:t,text:s}};default:return{command:null,error:`unknown text command: ${n}`}}}parseGroup(e){this.advance();let t=[];for(;!this.isAtEnd()&&!this.check(l.RBRACE);){if(this.check(l.NEWLINE)||this.check(l.SEMICOLON)){this.advance();continue}let n=this.pos,s=this.parseCommand();if(s.error)return{command:null,error:s.error};if(s.command&&t.push(s.command),this.pos===n&&!this.isAtEnd())return{command:null,error:`unknown command: '${this.peek()?.value??this.peek()?.type}'`}}return this.check(l.RBRACE)?(this.advance(),{command:{type:"group",address:e,commands:t}}):{command:null,error:"unmatched brace in grouped commands"}}parseAddressRange(){if(this.check(l.COMMA))return{error:"expected context address"};let e=this.parseAddress();if(e===void 0)return;let t;if(this.check(l.RELATIVE_OFFSET))t={offset:this.advance().offset||0};else if(this.check(l.COMMA)&&(this.advance(),t=this.parseAddress(),t===void 0))return{error:"expected context address"};return{address:{start:e,end:t}}}parseAddress(){let e=this.peek();switch(e.type){case l.NUMBER:return this.advance(),e.value;case l.DOLLAR:return this.advance(),"$";case l.PATTERN:return this.advance(),{pattern:e.pattern||e.value};case l.STEP:return this.advance(),{first:e.first||0,step:e.step||0};case l.RELATIVE_OFFSET:return this.advance(),{offset:e.offset||0};default:return}}peek(){return this.tokens[this.pos]||{type:l.EOF,value:"",line:0,column:0}}advance(){return this.isAtEnd()||this.pos++,this.tokens[this.pos-1]}check(e){return this.peek().type===e}isAtEnd(){return this.peek().type===l.EOF}};function Q(i,e=!1){let t=!1,n=!1,s=[];for(let o=0;o<i.length;o++){let d=i[o];if(s.length===0&&o===0){let p=d.match(/^#([nr]+)\s*(?:\n|$)/i);if(p){let E=p[1].toLowerCase();E.includes("n")&&(t=!0),E.includes("r")&&(n=!0),d=d.slice(p[0].length)}}if(s.length>0&&s[s.length-1].endsWith("\\")){let p=s[s.length-1];s[s.length-1]=`${p}
|
|
43
|
-
${d}`}else s.push(d)}let r=s.join(`
|
|
44
|
-
`),c=new H([r],e||n).parse();if(!c.error&&c.commands.length>0){let o=fe(c.commands);if(o)return{commands:[],error:o,silentMode:t,extendedRegexMode:n}}return{...c,silentMode:t,extendedRegexMode:n}}function fe(i){let e=new Set;J(i,e);let t=Y(i,e);if(t)return`undefined label '${t}'`}function J(i,e){for(let t of i)t.type==="label"?e.add(t.name):t.type==="group"&&J(t.commands,e)}function Y(i,e){for(let t of i){if((t.type==="branch"||t.type==="branchOnSubst"||t.type==="branchOnNoSubst")&&t.label&&!e.has(t.label))return t.label;if(t.type==="group"){let n=Y(t.commands,e);if(n)return n}}}var pe={name:"sed",summary:"stream editor for filtering and transforming text",usage:"sed [OPTION]... {script} [input-file]...",options:["-n, --quiet, --silent suppress automatic printing of pattern space","-e script add the script to commands to be executed","-f script-file read script from file","-i, --in-place edit files in place","-E, -r, --regexp-extended use extended regular expressions"," --help display this help and exit"],description:`Commands:
|
|
45
|
-
s/regexp/replacement/[flags] substitute
|
|
46
|
-
d delete pattern space
|
|
47
|
-
p print pattern space
|
|
48
|
-
a\\ text append text after line
|
|
49
|
-
i\\ text insert text before line
|
|
50
|
-
c\\ text change (replace) line with text
|
|
51
|
-
h copy pattern space to hold space
|
|
52
|
-
H append pattern space to hold space
|
|
53
|
-
g copy hold space to pattern space
|
|
54
|
-
G append hold space to pattern space
|
|
55
|
-
x exchange pattern and hold spaces
|
|
56
|
-
n read next line into pattern space
|
|
57
|
-
N append next line to pattern space
|
|
58
|
-
y/source/dest/ transliterate characters
|
|
59
|
-
= print line number
|
|
60
|
-
l list pattern space (escape special chars)
|
|
61
|
-
b [label] branch to label
|
|
62
|
-
t [label] branch on substitution
|
|
63
|
-
T [label] branch if no substitution
|
|
64
|
-
:label define label
|
|
65
|
-
q quit
|
|
66
|
-
Q quit without printing
|
|
67
|
-
|
|
68
|
-
Addresses:
|
|
69
|
-
N line number
|
|
70
|
-
$ last line
|
|
71
|
-
/regexp/ lines matching regexp
|
|
72
|
-
N,M range from line N to M
|
|
73
|
-
first~step every step-th line starting at first`};async function z(i,e,t,n={}){let{limits:s,filename:r,fs:a,cwd:c,coverage:o}=n,d=i.endsWith(`
|
|
74
|
-
`),p=i.split(`
|
|
75
|
-
`);p.length>0&&p[p.length-1]===""&&p.pop();let E=p.length,m="",f,u=!1,h=s?.maxStringLength??0,b=R=>{if(m+=R,h>0&&m.length>h)throw new x(`sed: output size limit exceeded (${h} bytes)`,"string_length")},C="",y,ee=new Map,F=new Map,$=new Map,M=new Map,te=s?{maxIterations:s.maxSedIterations}:void 0;for(let R=0;R<p.length;R++){let g={...K(E,r,ee),patternSpace:p[R],holdSpace:C,lastPattern:y,lineNumber:R+1,totalLines:E,substitutionMade:!1,coverage:o},ne={lines:p,currentLineIndex:R},V=0,ie=1e4;g.linesConsumedInCycle=0;do{if(V++,V>ie)break;if(g.restartCycle=!1,g.pendingFileReads=[],g.pendingFileWrites=[],U(e,g,ne,te),a&&c){for(let v of g.pendingFileReads){let k=a.resolvePath(c,v.filename);try{if(v.wholeFile){let S=await a.readFile(k);g.appendBuffer.push(S.replace(/\n$/,""))}else{if(!F.has(k)){let re=await a.readFile(k);F.set(k,re.split(`
|
|
76
|
-
`)),$.set(k,0)}let S=F.get(k),A=$.get(k);S&&A!==void 0&&A<S.length&&(g.appendBuffer.push(S[A]),$.set(k,A+1))}}catch{}}for(let v of g.pendingFileWrites){let k=a.resolvePath(c,v.filename),S=M.get(k)||"";M.set(k,S+v.content)}}}while(g.restartCycle&&!g.deleted&&!g.quit&&!g.quitSilent);if(R+=g.linesConsumedInCycle,C=g.holdSpace,y=g.lastPattern,!t)for(let v of g.nCommandOutput)b(`${v}
|
|
77
|
-
`);let se=g.lineNumberOutput.length>0;for(let v of g.lineNumberOutput)b(`${v}
|
|
78
|
-
`);let X=[],_=[];for(let v of g.appendBuffer)v.startsWith("__INSERT__")?X.push(v.slice(10)):_.push(v);for(let v of X)b(`${v}
|
|
79
|
-
`);let L=!1;!g.deleted&&!g.quitSilent?t?g.printed&&(b(`${g.patternSpace}
|
|
80
|
-
`),L=!0):(b(`${g.patternSpace}
|
|
81
|
-
`),L=!0):g.changedText!==void 0&&(b(`${g.changedText}
|
|
82
|
-
`),L=!0);for(let v of _)b(`${v}
|
|
83
|
-
`);if(u=(se||L)&&_.length===0,g.quit||g.quitSilent){if(g.exitCode!==void 0&&(f=g.exitCode),g.errorMessage)return{output:"",exitCode:f||1,errorMessage:g.errorMessage};break}}if(a&&c)for(let[R,g]of M)try{await a.writeFile(R,g)}catch{}return!d&&u&&m.endsWith(`
|
|
84
|
-
`)&&(m=m.slice(0,-1)),{output:m,exitCode:f}}var Ne={name:"sed",async execute(i,e){if(j(i))return G(pe);let t=[],n=[],s=!1,r=!1,a=!1,c=[];for(let u=0;u<i.length;u++){let h=i[u];if(h==="-n"||h==="--quiet"||h==="--silent")s=!0;else if(h==="-i"||h==="--in-place")r=!0;else if(h.startsWith("-i"))r=!0;else if(h==="-E"||h==="-r"||h==="--regexp-extended")a=!0;else if(h==="-e")u+1<i.length&&t.push(i[++u]);else if(h==="-f")u+1<i.length&&n.push(i[++u]);else{if(h.startsWith("--"))return T("sed",h);if(h==="-")c.push(h);else if(h.startsWith("-")&&h.length>1){for(let b of h.slice(1))if(b!=="n"&&b!=="e"&&b!=="f"&&b!=="i"&&b!=="E"&&b!=="r")return T("sed",`-${b}`);h.includes("n")&&(s=!0),h.includes("i")&&(r=!0),(h.includes("E")||h.includes("r"))&&(a=!0),h.includes("e")&&!h.includes("n")&&!h.includes("i")&&u+1<i.length&&t.push(i[++u]),h.includes("f")&&!h.includes("e")&&u+1<i.length&&n.push(i[++u])}else!h.startsWith("-")&&t.length===0&&n.length===0?t.push(h):h.startsWith("-")||c.push(h)}}for(let u of n){let h=e.fs.resolvePath(e.cwd,u);try{let b=await e.fs.readFile(h);for(let C of b.split(`
|
|
85
|
-
`)){let y=C.trim();y&&!y.startsWith("#")&&t.push(y)}}catch{return{stdout:"",stderr:`sed: couldn't open file ${u}: No such file or directory
|
|
86
|
-
`,exitCode:1}}}if(t.length===0)return{stdout:"",stderr:`sed: no script specified
|
|
87
|
-
`,exitCode:1};let{commands:o,error:d,silentMode:p}=Q(t,a);if(d)return{stdout:"",stderr:`sed: ${d}
|
|
88
|
-
`,exitCode:1};let E=!!(s||p);if(r){if(c.length===0)return{stdout:"",stderr:`sed: -i requires at least one file argument
|
|
89
|
-
`,exitCode:1};for(let u of c){if(u==="-")continue;let h=e.fs.resolvePath(e.cwd,u);try{let b=await e.fs.readFile(h),C=await z(b,o,E,{limits:e.limits,filename:u,fs:e.fs,cwd:e.cwd,coverage:e.coverage});if(C.errorMessage)return{stdout:"",stderr:`${C.errorMessage}
|
|
90
|
-
`,exitCode:C.exitCode??1};await e.fs.writeFile(h,C.output)}catch(b){return b instanceof x?{stdout:"",stderr:`sed: ${b.message}
|
|
91
|
-
`,exitCode:x.EXIT_CODE}:{stdout:"",stderr:`sed: ${u}: No such file or directory
|
|
92
|
-
`,exitCode:1}}}return{stdout:"",stderr:"",exitCode:0}}let m="";if(c.length===0){m=e.stdin;try{let u=await z(m,o,E,{limits:e.limits,fs:e.fs,cwd:e.cwd,coverage:e.coverage});return{stdout:u.output,stderr:u.errorMessage?`${u.errorMessage}
|
|
93
|
-
`:"",exitCode:u.exitCode??0}}catch(u){if(u instanceof x)return{stdout:"",stderr:`sed: ${u.message}
|
|
94
|
-
`,exitCode:x.EXIT_CODE};throw u}}let f=!1;for(let u of c){let h;if(u==="-")f?h="":(h=e.stdin,f=!0);else{let b=e.fs.resolvePath(e.cwd,u);try{h=await e.fs.readFile(b)}catch(C){return C instanceof x?{stdout:"",stderr:`sed: ${C.message}
|
|
95
|
-
`,exitCode:x.EXIT_CODE}:{stdout:"",stderr:`sed: ${u}: No such file or directory
|
|
96
|
-
`,exitCode:1}}}m.length>0&&h.length>0&&!m.endsWith(`
|
|
97
|
-
`)&&(m+=`
|
|
98
|
-
`),m+=h}try{let u=await z(m,o,E,{limits:e.limits,filename:c.length===1?c[0]:void 0,fs:e.fs,cwd:e.cwd,coverage:e.coverage});return{stdout:u.output,stderr:u.errorMessage?`${u.errorMessage}
|
|
99
|
-
`:"",exitCode:u.exitCode??0}}catch(u){if(u instanceof x)return{stdout:"",stderr:`sed: ${u.message}
|
|
100
|
-
`,exitCode:x.EXIT_CODE};throw u}}},Le={name:"sed",flags:[{flag:"-n",type:"boolean"},{flag:"-i",type:"boolean"},{flag:"-E",type:"boolean"},{flag:"-r",type:"boolean"},{flag:"-e",type:"value",valueHint:"string"}],stdinType:"text",needsArgs:!0};export{Ne as a,Le as b};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
async function c(t,s){if(t.length>0&&t[0]!=="-"){let i=t[0].startsWith("/")?t[0]:`${s.cwd}/${t[0]}`;try{let n=(await s.fs.readFile(i)).split(`
|
|
3
|
-
`);n[n.length-1]===""&&n.pop();let r=n.reverse();return{stdout:r.length>0?`${r.join(`
|
|
4
|
-
`)}
|
|
5
|
-
`:"",stderr:"",exitCode:0}}catch{return{stdout:"",stderr:`tac: ${t[0]}: No such file or directory
|
|
6
|
-
`,exitCode:1}}}let e=s.stdin.split(`
|
|
7
|
-
`);e[e.length-1]===""&&e.pop();let o=e.reverse();return{stdout:o.length>0?`${o.join(`
|
|
8
|
-
`)}
|
|
9
|
-
`:"",stderr:"",exitCode:0}}var l={name:"tac",execute:c},u={name:"tac",flags:[],stdinType:"text",needsFiles:!0};export{l as a,u as b};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{a as C}from"./chunk-JBABAK44.js";import{a as u,b as m}from"./chunk-GTNBSMZR.js";var y={name:"tr",summary:"translate or delete characters",usage:"tr [OPTION]... SET1 [SET2]",options:["-c, -C, --complement use the complement of SET1","-d, --delete delete characters in SET1","-s, --squeeze-repeats squeeze repeated characters"," --help display this help and exit"],description:`SET syntax:
|
|
3
|
-
a-z character range
|
|
4
|
-
[:alnum:] all letters and digits
|
|
5
|
-
[:alpha:] all letters
|
|
6
|
-
[:digit:] all digits
|
|
7
|
-
[:lower:] all lowercase letters
|
|
8
|
-
[:upper:] all uppercase letters
|
|
9
|
-
[:space:] all whitespace
|
|
10
|
-
[:blank:] horizontal whitespace
|
|
11
|
-
[:punct:] all punctuation
|
|
12
|
-
[:print:] all printable characters
|
|
13
|
-
[:graph:] all printable characters except space
|
|
14
|
-
[:cntrl:] all control characters
|
|
15
|
-
[:xdigit:] all hexadecimal digits
|
|
16
|
-
\\n, \\t, \\r escape sequences`},x=new Map([["[:alnum:]","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"],["[:alpha:]","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"],["[:blank:]"," "],["[:cntrl:]",Array.from({length:32},(r,n)=>String.fromCharCode(n)).join("").concat("\x7F")],["[:digit:]","0123456789"],["[:graph:]",Array.from({length:94},(r,n)=>String.fromCharCode(33+n)).join("")],["[:lower:]","abcdefghijklmnopqrstuvwxyz"],["[:print:]",Array.from({length:95},(r,n)=>String.fromCharCode(32+n)).join("")],["[:punct:]","!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"],["[:space:]",`
|
|
17
|
-
\r\f\v`],["[:upper:]","ABCDEFGHIJKLMNOPQRSTUVWXYZ"],["[:xdigit:]","0123456789ABCDEFabcdef"]]);function S(r){let n="",e=0;for(;e<r.length;){if(r[e]==="["&&r[e+1]===":"){let l=!1;for(let[i,a]of x)if(r.slice(e).startsWith(i)){n+=a,e+=i.length,l=!0;break}if(l)continue}if(r[e]==="\\"&&e+1<r.length){let l=r[e+1];l==="n"?n+=`
|
|
18
|
-
`:l==="t"?n+=" ":l==="r"?n+="\r":n+=l,e+=2;continue}if(e+2<r.length&&r[e+1]==="-"){let l=r.charCodeAt(e),i=r.charCodeAt(e+2);for(let a=l;a<=i;a++)n+=String.fromCharCode(a);e+=3;continue}n+=r[e],e++}return n}var b={complement:{short:"c",long:"complement",type:"boolean"},complementUpper:{short:"C",type:"boolean"},delete:{short:"d",long:"delete",type:"boolean"},squeeze:{short:"s",long:"squeeze-repeats",type:"boolean"}},A={name:"tr",async execute(r,n){if(m(r))return u(y);let e=C("tr",r,b);if(!e.ok)return e.error;let l=e.result.flags.complement||e.result.flags.complementUpper,i=e.result.flags.delete,a=e.result.flags.squeeze,p=e.result.positional;if(p.length<1)return{stdout:"",stderr:`tr: missing operand
|
|
19
|
-
`,exitCode:1};if(!i&&!a&&p.length<2)return{stdout:"",stderr:`tr: missing operand after SET1
|
|
20
|
-
`,exitCode:1};let d=S(p[0]),s=p.length>1?S(p[1]):"",h=n.stdin,g=o=>{let t=d.includes(o);return l?!t:t},c="";if(i)for(let o of h)g(o)||(c+=o);else if(a&&p.length===1){let o="";for(let t of h)g(t)&&t===o||(c+=t,o=t)}else{if(l){let o=s.length>0?s[s.length-1]:"";for(let t of h)d.includes(t)?c+=t:c+=o}else{let o=new Map;for(let t=0;t<d.length;t++){let f=t<s.length?s[t]:s[s.length-1];o.set(d[t],f)}for(let t of h)c+=o.get(t)??t}if(a){let o="",t="";for(let f of c)s.includes(f)&&f===t||(o+=f,t=f);c=o}}return{stdout:c,stderr:"",exitCode:0}}},q={name:"tr",flags:[{flag:"-c",type:"boolean"},{flag:"-C",type:"boolean"},{flag:"-d",type:"boolean"},{flag:"-s",type:"boolean"}],stdinType:"text",needsArgs:!0};export{A as a,q as b};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{a,b as o}from"./chunk-GTNBSMZR.js";var l={name:"sleep",summary:"delay for a specified amount of time",usage:"sleep NUMBER[SUFFIX]",description:`Pause for NUMBER seconds. SUFFIX may be:
|
|
3
|
-
s - seconds (default)
|
|
4
|
-
m - minutes
|
|
5
|
-
h - hours
|
|
6
|
-
d - days
|
|
7
|
-
|
|
8
|
-
NUMBER may be a decimal number.`,options:[" --help display this help and exit"]};function i(t){let s=t.match(/^(\d+\.?\d*)(s|m|h|d)?$/);if(!s)return null;let e=parseFloat(s[1]);switch(s[2]||"s"){case"s":return e*1e3;case"m":return e*60*1e3;case"h":return e*60*60*1e3;case"d":return e*24*60*60*1e3;default:return null}}var d={name:"sleep",async execute(t,s){if(o(t))return a(l);if(t.length===0)return{stdout:"",stderr:`sleep: missing operand
|
|
9
|
-
`,exitCode:1};let e=0;for(let n of t){let r=i(n);if(r===null)return{stdout:"",stderr:`sleep: invalid time interval '${n}'
|
|
10
|
-
`,exitCode:1};e+=r}return s.sleep?await s.sleep(e):await new Promise(n=>setTimeout(n,e)),{stdout:"",stderr:"",exitCode:0}}},m={name:"sleep",flags:[],needsArgs:!0};export{d as a,m as b};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{a as y}from"./chunk-GIFF636B.js";import{a as q,b as j}from"./chunk-G43H2WGH.js";import{a as Z,b as _,c as U}from"./chunk-GTNBSMZR.js";var te={name:"grep",summary:"print lines that match patterns",usage:"grep [OPTION]... PATTERN [FILE]...",options:["-E, --extended-regexp PATTERN is an extended regular expression","-P, --perl-regexp PATTERN is a Perl regular expression","-F, --fixed-strings PATTERN is a set of newline-separated strings","-i, --ignore-case ignore case distinctions","-v, --invert-match select non-matching lines","-w, --word-regexp match only whole words","-x, --line-regexp match only whole lines","-c, --count print only a count of matching lines","-l, --files-with-matches print only names of files with matches","-L, --files-without-match print names of files with no matches","-m NUM, --max-count=NUM stop after NUM matches","-n, --line-number print line number with output lines","-h, --no-filename suppress the file name prefix on output","-o, --only-matching show only nonempty parts of lines that match","-q, --quiet, --silent suppress all normal output","-r, -R, --recursive search directories recursively","-A NUM print NUM lines of trailing context","-B NUM print NUM lines of leading context","-C NUM print NUM lines of context","-e PATTERN use PATTERN for matching"," --include=GLOB search only files matching GLOB"," --exclude=GLOB skip files matching GLOB"," --exclude-dir=DIR skip directories matching DIR"," --help display this help and exit"]},J={name:"grep",async execute(t,s){if(_(t))return Z(te);let o=!1,f=!1,c=!1,h=!1,g=!1,l=!1,n=!1,d=!1,x=!1,u=!1,p=!1,b=!1,w=!1,z=!1,E=!1,$=0,P=0,T=0,M=[],W=[],H=[],C=null,B=[];for(let r=0;r<t.length;r++){let i=t[r];if(i.startsWith("-")&&i!=="-"){if(i==="-e"&&r+1<t.length){C=t[++r];continue}if(i.startsWith("--include=")){M.push(i.slice(10));continue}if(i.startsWith("--exclude=")){W.push(i.slice(10));continue}if(i.startsWith("--exclude-dir=")){H.push(i.slice(14));continue}if(i.startsWith("--max-count=")){$=parseInt(i.slice(12),10);continue}let F=i.match(/^-m(\d+)$/);if(F){$=parseInt(F[1],10);continue}if(i==="-m"&&r+1<t.length){$=parseInt(t[++r],10);continue}let a=i.match(/^-([ABC])(\d+)$/);if(a){let e=parseInt(a[2],10);a[1]==="A"?T=e:a[1]==="B"?P=e:a[1]==="C"&&(P=e,T=e);continue}if((i==="-A"||i==="-B"||i==="-C")&&r+1<t.length){let e=parseInt(t[++r],10);i==="-A"?T=e:i==="-B"?P=e:(P=e,T=e);continue}let m=i.startsWith("--")?[i]:i.slice(1).split("");for(let e of m)if(e==="i"||e==="--ignore-case")o=!0;else if(e==="n"||e==="--line-number")f=!0;else if(e==="v"||e==="--invert-match")c=!0;else if(e==="c"||e==="--count")h=!0;else if(e==="l"||e==="--files-with-matches")g=!0;else if(e==="L"||e==="--files-without-match")l=!0;else if(e==="r"||e==="R"||e==="--recursive")n=!0;else if(e==="w"||e==="--word-regexp")d=!0;else if(e==="x"||e==="--line-regexp")x=!0;else if(e==="E"||e==="--extended-regexp")u=!0;else if(e==="P"||e==="--perl-regexp")p=!0;else if(e==="F"||e==="--fixed-strings")b=!0;else if(e==="o"||e==="--only-matching")w=!0;else if(e==="h"||e==="--no-filename")z=!0;else if(e==="q"||e==="--quiet"||e==="--silent")E=!0;else{if(e.startsWith("--"))return U("grep",e);if(e.length===1)return U("grep",`-${e}`)}}else C===null?C=i:B.push(i)}if(C===null)return{stdout:"",stderr:`grep: missing pattern
|
|
3
|
-
`,exitCode:2};let V=b?"fixed":u?"extended":p?"perl":"basic",L,O;try{let r=j(C,{mode:V,ignoreCase:o,wholeWord:d,lineRegexp:x});L=r.regex,O=r.kResetGroup}catch{return{stdout:"",stderr:`grep: invalid regular expression: ${C}
|
|
4
|
-
`,exitCode:2}}if(B.length===0&&s.stdin!==void 0){let r=q(s.stdin,L,{invertMatch:c,showLineNumbers:f,countOnly:h,filename:"",onlyMatching:w,beforeContext:P,afterContext:T,maxCount:$,kResetGroup:O});return E?{stdout:"",stderr:"",exitCode:r.matched?0:1}:{stdout:r.output,stderr:"",exitCode:r.matched?0:1}}if(B.length===0)return{stdout:"",stderr:`grep: no input files
|
|
5
|
-
`,exitCode:2};let R="",G="",S=!1,D=!1,v=[];for(let r of B)if(r.includes("*")||r.includes("?")||r.includes("[")){let i=await se(r,s);if(n)for(let F of i){let a=await I(F.path,s,M,W,H,F.isFile);v.push(...a)}else v.push(...i)}else if(n){let i=await I(r,s,M,W,H);v.push(...i)}else v.push({path:r});let X=(v.length>1||n)&&!z,k=50;for(let r=0;r<v.length;r+=k){let i=v.slice(r,r+k),F=await Promise.all(i.map(async a=>{let m=a.path,e=m.split("/").pop()||m;if(W.length>0&&!n&&W.some(N=>y(e,N,{stripQuotes:!0}))||M.length>0&&!n&&!M.some(N=>y(e,N,{stripQuotes:!0})))return null;try{let N=s.fs.resolvePath(s.cwd,m),Q=!1;if(a.isFile===void 0?Q=(await s.fs.stat(N)).isDirectory:Q=!a.isFile,Q)return n?null:{error:`grep: ${m}: Is a directory
|
|
6
|
-
`};let Y=await s.fs.readFile(N),ee=q(Y,L,{invertMatch:c,showLineNumbers:f,countOnly:h,filename:X?m:"",onlyMatching:w,beforeContext:P,afterContext:T,maxCount:$,kResetGroup:O});return{file:m,result:ee}}catch{return{error:`grep: ${m}: No such file or directory
|
|
7
|
-
`}}}));for(let a of F){if(a===null)continue;if("error"in a&&a.error){G+=a.error,a.error.includes("Is a directory")||(D=!0);continue}if(!("file"in a)||!a.result)continue;let{file:m,result:e}=a;if(e.matched){if(S=!0,E)return{stdout:"",stderr:"",exitCode:0};g?R+=`${m}
|
|
8
|
-
`:l||(R+=e.output)}else l?R+=`${m}
|
|
9
|
-
`:h&&!g&&(R+=e.output)}}let A;return D?A=2:l?A=R.length>0?0:1:A=S?0:1,E?{stdout:"",stderr:"",exitCode:A}:{stdout:R,stderr:G,exitCode:A}}};async function K(t,s,o,f){let c=o.fs.resolvePath(o.cwd,t);try{if(!(await o.fs.stat(c)).isDirectory){let l=t.split("/").pop()||"";if(s){let n=s.replace(/^\//,"");y(l,n,{stripQuotes:!0})&&f.push(t)}return}let g=await o.fs.readdir(c);for(let l of g){let n=t==="."?l:`${t}/${l}`,d=o.fs.resolvePath(o.cwd,n);if((await o.fs.stat(d)).isDirectory)await K(n,s,o,f);else if(s){let u=s.replace(/^\//,"");y(l,u,{stripQuotes:!0})&&f.push(n)}}}catch{}}async function se(t,s){let o=[],f=t.lastIndexOf("/"),c,h;if(f===-1?(c=s.cwd,h=t):(c=t.slice(0,f)||"/",h=t.slice(f+1)),t.includes("**")){let l=[],n=t.split("**"),d=n[0].replace(/\/$/,"")||".",x=n[1]||"";return await K(d,x,s,l),l.map(u=>({path:u}))}let g=s.fs.resolvePath(s.cwd,c);try{if(s.fs.readdirWithFileTypes){let l=await s.fs.readdirWithFileTypes(g);for(let n of l)if(y(n.name,h,{stripQuotes:!0})){let d=f===-1?n.name:`${c}/${n.name}`;o.push({path:d,isFile:n.isFile})}}else{let l=await s.fs.readdir(g);for(let n of l)if(y(n,h,{stripQuotes:!0})){let d=f===-1?n:`${c}/${n}`;o.push({path:d})}}}catch{}return o.sort((l,n)=>l.path.localeCompare(n.path))}async function I(t,s,o=[],f=[],c=[],h){let g=s.fs.resolvePath(s.cwd,t),l=[];try{let n,d;if(h!==void 0)n=h,d=!h;else{let u=await s.fs.stat(g);n=u.isFile,d=u.isDirectory}if(n){let u=t.split("/").pop()||t;return f.length>0&&f.some(p=>y(u,p,{stripQuotes:!0}))?[]:o.length>0&&!o.some(p=>y(u,p,{stripQuotes:!0}))?[]:[{path:t,isFile:!0}]}if(!d)return[];let x=t.split("/").pop()||t;if(c.length>0&&c.some(u=>y(x,u,{stripQuotes:!0})))return[];if(s.fs.readdirWithFileTypes){let u=await s.fs.readdirWithFileTypes(g);for(let p of u){if(p.name.startsWith("."))continue;let b=t==="."?p.name:`${t}/${p.name}`,w=await I(b,s,o,f,c,p.isFile);l.push(...w)}}else{let u=await s.fs.readdir(g);for(let p of u){if(p.startsWith("."))continue;let b=t==="."?p:`${t}/${p}`,w=await I(b,s,o,f,c);l.push(...w)}}}catch{}return l}var oe={name:"fgrep",async execute(t,s){return J.execute(["-F",...t],s)}},ae={name:"egrep",async execute(t,s){return J.execute(["-E",...t],s)}},fe={name:"grep",flags:[{flag:"-E",type:"boolean"},{flag:"-F",type:"boolean"},{flag:"-P",type:"boolean"},{flag:"-i",type:"boolean"},{flag:"-v",type:"boolean"},{flag:"-w",type:"boolean"},{flag:"-x",type:"boolean"},{flag:"-c",type:"boolean"},{flag:"-l",type:"boolean"},{flag:"-L",type:"boolean"},{flag:"-n",type:"boolean"},{flag:"-h",type:"boolean"},{flag:"-o",type:"boolean"},{flag:"-q",type:"boolean"},{flag:"-r",type:"boolean"},{flag:"-m",type:"value",valueHint:"number"},{flag:"-A",type:"value",valueHint:"number"},{flag:"-B",type:"value",valueHint:"number"},{flag:"-C",type:"value",valueHint:"number"},{flag:"-e",type:"value",valueHint:"pattern"}],stdinType:"text",needsArgs:!0},ue={name:"fgrep",flags:[],stdinType:"text",needsArgs:!0},ce={name:"egrep",flags:[],stdinType:"text",needsArgs:!0};export{J as a,oe as b,ae as c,fe as d,ue as e,ce as f};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{a as b}from"./chunk-JBABAK44.js";import{a as $,b as F}from"./chunk-GTNBSMZR.js";var x={name:"du",summary:"estimate file space usage",usage:"du [OPTION]... [FILE]...",options:["-a write counts for all files, not just directories","-h print sizes in human readable format","-s display only a total for each argument","-c produce a grand total","--max-depth=N print total for directory only if N or fewer levels deep"," --help display this help and exit"]},R={allFiles:{short:"a",type:"boolean"},humanReadable:{short:"h",type:"boolean"},summarize:{short:"s",type:"boolean"},grandTotal:{short:"c",type:"boolean"},maxDepth:{long:"max-depth",type:"number"}},H={name:"du",async execute(a,s){if(F(a))return $(x);let n=b("du",a,R);if(!n.ok)return n.error;let r={allFiles:n.result.flags.allFiles,humanReadable:n.result.flags.humanReadable,summarize:n.result.flags.summarize,grandTotal:n.result.flags.grandTotal,maxDepth:n.result.flags.maxDepth??null},c=n.result.positional;c.length===0&&c.push(".");let i="",m="",p=0;for(let l of c){let z=s.fs.resolvePath(s.cwd,l);try{await s.fs.stat(z);let h=await w(s,z,l,r,0);i+=h.output,p+=h.totalSize,m+=h.stderr}catch{m+=`du: cannot access '${l}': No such file or directory
|
|
3
|
-
`}}return r.grandTotal&&c.length>0&&(i+=`${D(p,r.humanReadable)} total
|
|
4
|
-
`),{stdout:i,stderr:m,exitCode:m?1:0}}};async function w(a,s,n,r,c){let i={output:"",totalSize:0,stderr:""};try{let m=await a.fs.stat(s);if(!m.isDirectory)return i.totalSize=m.size,(r.allFiles||c===0)&&(i.output=D(m.size,r.humanReadable)+" "+n+`
|
|
5
|
-
`),i;let p=0,l=[];if(a.fs.readdirWithFileTypes){let t=await a.fs.readdirWithFileTypes(s),o=t.filter(e=>e.isFile),f=t.filter(e=>e.isDirectory);for(let e=0;e<o.length;e+=100){let u=o.slice(e,e+100),y=await Promise.all(u.map(async d=>{let T=s==="/"?`/${d.name}`:`${s}/${d.name}`;try{let S=await a.fs.stat(T);return{name:d.name,isDirectory:!1,size:S.size}}catch{return{name:d.name,isDirectory:!1,size:0}}}));l.push(...y)}l.push(...f.map(e=>({name:e.name,isDirectory:!0})))}else{let t=await a.fs.readdir(s);for(let o=0;o<t.length;o+=100){let f=t.slice(o,o+100),e=await Promise.all(f.map(async u=>{let y=s==="/"?`/${u}`:`${s}/${u}`;try{let d=await a.fs.stat(y);return{name:u,isDirectory:d.isDirectory,size:d.isDirectory?void 0:d.size}}catch{return{name:u,isDirectory:!1,size:0}}}));l.push(...e)}}l.sort((t,o)=>t.name.localeCompare(o.name));let z=l.filter(t=>!t.isDirectory);for(let t of z){let o=t.size??0;if(p+=o,r.allFiles&&!r.summarize){let f=n==="."?t.name:`${n}/${t.name}`;i.output+=D(o,r.humanReadable)+" "+f+`
|
|
6
|
-
`}}let h=l.filter(t=>t.isDirectory);for(let t=0;t<h.length;t+=100){let o=h.slice(t,t+100),f=await Promise.all(o.map(async e=>{let u=s==="/"?`/${e.name}`:`${s}/${e.name}`,y=n==="."?e.name:`${n}/${e.name}`;return{name:e.name,result:await w(a,u,y,r,c+1)}}));f.sort((e,u)=>e.name.localeCompare(u.name));for(let{result:e}of f)p+=e.totalSize,r.summarize||(r.maxDepth===null||c+1<=r.maxDepth)&&(i.output+=e.output)}i.totalSize=p,(r.summarize||r.maxDepth===null||c<=r.maxDepth)&&(i.output+=`${D(p,r.humanReadable)} ${n}
|
|
7
|
-
`)}catch{i.stderr=`du: cannot read directory '${n}': Permission denied
|
|
8
|
-
`}return i}function D(a,s){return s?a<1024?`${a}`:a<1024*1024?`${(a/1024).toFixed(1)}K`:a<1024*1024*1024?`${(a/(1024*1024)).toFixed(1)}M`:`${(a/(1024*1024*1024)).toFixed(1)}G`:String(Math.ceil(a/1024)||1)}var v={name:"du",flags:[{flag:"-a",type:"boolean"},{flag:"-h",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-c",type:"boolean"},{flag:"--max-depth",type:"value",valueHint:"number"}],needsFiles:!0};export{H as a,v as b};
|