@jerryan/just-bash 3.11.0 → 3.11.1

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.
@@ -1,6 +1,6 @@
1
1
  import{createRequire} from"node:module";const require=createRequire(import.meta.url);
2
- import{a as Zt,b as Qt,c as pt}from"./chunks/chunk-353VO5TF.js";import{b as Tt,c as rl,d as sl,e as il}from"./chunks/chunk-6L6OYVLY.js";import{a as es,b as Er}from"./chunks/chunk-5J4S2LP5.js";import{a as Kr,b as Xr,d as yr,e as gr}from"./chunks/chunk-SXQJYLP7.js";import{c as Li,e as tl,f as nl}from"./chunks/chunk-XZ34OGNM.js";import{a as ln}from"./chunks/chunk-SGX4WOAM.js";import{a as _i}from"./chunks/chunk-L2UW7DWF.js";import{a as an,b as Ye,c as Ar}from"./chunks/chunk-DLL7UR66.js";import{a as Sr,b as el}from"./chunks/chunk-654CJKE3.js";import{a as ge}from"./chunks/chunk-O5BHWBYH.js";import{a as ts,b as ns}from"./chunks/chunk-A3C4Z3Q3.js";import{a as Gn,b as Re}from"./chunks/chunk-A6SU3BZX.js";import"./chunks/chunk-57LGFT4S.js";import{d as rn,e as Qn}from"./chunks/chunk-ZUEPJPYA.js";import"./chunks/chunk-STHBFACM.js";import{a as Ja}from"./chunks/chunk-RK2WBVP4.js";import{a as br,b as vt,c as sn,d as rs,e as V,f as Gt,g as U,h as kt,i as on,j as On,k as ht,l as Kn}from"./chunks/chunk-BMBITA6Y.js";import{a as en,b as nt,c as rt,d as Ve,e as Ke,f as Xe,g as H,h as ce,i as st,j as tn,k as Yr,l as C,m as it,n as Oe,o as nn,p as Jr,q as dt}from"./chunks/chunk-TVCZIH6M.js";import{a as B,b as wr,c as Rn,d as _d,e as Jt,f as Ii,g as Zn,h as Ld,i as qt,j as Ti,k as Fd,l as Md}from"./chunks/chunk-GN6CQ3J4.js";import{a as x,b as Bd,c as De,d as Wd}from"./chunks/chunk-T5ZEIOJ3.js";import{a as Ht}from"./chunks/chunk-W5DWRFSU.js";import{a as It}from"./chunks/chunk-FOCWZZDE.js";import{a as Di}from"./chunks/chunk-NCUTH6QL.js";import*as Be from"node:path";var Dn=[{name:"echo",load:async()=>(await import("./chunks/echo-PLLZYM2L.js")).echoCommand},{name:"cat",load:async()=>(await import("./chunks/cat-LG4YGKUE.js")).catCommand},{name:"printf",load:async()=>(await import("./chunks/printf-B2NSYQ3N.js")).printfCommand},{name:"ls",load:async()=>(await import("./chunks/ls-FC3CSHKE.js")).lsCommand},{name:"mkdir",load:async()=>(await import("./chunks/mkdir-DPFWDY25.js")).mkdirCommand},{name:"mktemp",load:async()=>(await import("./chunks/mktemp-SW2AHXZW.js")).mktempCommand,handlesOwnVersion:!0},{name:"rmdir",load:async()=>(await import("./chunks/rmdir-YXYSZD4X.js")).rmdirCommand},{name:"touch",load:async()=>(await import("./chunks/touch-W4DF6Z4T.js")).touchCommand},{name:"rm",load:async()=>(await import("./chunks/rm-AZZM5DCE.js")).rmCommand},{name:"cp",load:async()=>(await import("./chunks/cp-ZDDVNITX.js")).cpCommand},{name:"mv",load:async()=>(await import("./chunks/mv-PWCFXEF2.js")).mvCommand},{name:"ln",load:async()=>(await import("./chunks/ln-CEM7GDB5.js")).lnCommand},{name:"chmod",load:async()=>(await import("./chunks/chmod-XUKPG2M4.js")).chmodCommand},{name:"pwd",load:async()=>(await import("./chunks/pwd-76BPYV5F.js")).pwdCommand},{name:"readlink",load:async()=>(await import("./chunks/readlink-7XGQ3PL7.js")).readlinkCommand},{name:"head",load:async()=>(await import("./chunks/head-VYXZQLPZ.js")).headCommand},{name:"tail",load:async()=>(await import("./chunks/tail-WK3WACZK.js")).tailCommand},{name:"wc",load:async()=>(await import("./chunks/wc-7WVM7GV4.js")).wcCommand},{name:"stat",load:async()=>(await import("./chunks/stat-I3FPUTR7.js")).statCommand},{name:"grep",load:async()=>(await import("./chunks/grep-WW5KJPUG.js")).grepCommand},{name:"fgrep",load:async()=>(await import("./chunks/grep-WW5KJPUG.js")).fgrepCommand},{name:"egrep",load:async()=>(await import("./chunks/grep-WW5KJPUG.js")).egrepCommand},{name:"rg",load:async()=>(await import("./chunks/rg-2OPJ5V3D.js")).rgCommand,handlesOwnVersion:!0},{name:"sed",load:async()=>(await import("./chunks/sed-HYSBLGO5.js")).sedCommand},{name:"awk",load:async()=>(await import("./chunks/awk2-TLK6FCHV.js")).awkCommand2},{name:"sort",load:async()=>(await import("./chunks/sort-CB5GO7XH.js")).sortCommand},{name:"uniq",load:async()=>(await import("./chunks/uniq-PAEPA27E.js")).uniqCommand},{name:"comm",load:async()=>(await import("./chunks/comm-DTWKU2MC.js")).commCommand},{name:"cut",load:async()=>(await import("./chunks/cut-35WER2E2.js")).cutCommand},{name:"paste",load:async()=>(await import("./chunks/paste-TIQETHSO.js")).pasteCommand},{name:"tr",load:async()=>(await import("./chunks/tr-VI5PIA4A.js")).trCommand},{name:"rev",load:async()=>(await import("./chunks/rev-EPOS3MFH.js")).rev},{name:"nl",load:async()=>(await import("./chunks/nl-IELOWYJG.js")).nl},{name:"fold",load:async()=>(await import("./chunks/fold-QJBPHRFJ.js")).fold},{name:"expand",load:async()=>(await import("./chunks/expand-J3VOSOMK.js")).expand},{name:"unexpand",load:async()=>(await import("./chunks/unexpand-YD5BWFH4.js")).unexpand},{name:"strings",load:async()=>(await import("./chunks/strings-VLFTYX2Z.js")).strings},{name:"split",load:async()=>(await import("./chunks/split-UOPIWKKE.js")).split},{name:"column",load:async()=>(await import("./chunks/column-T4LGMRJG.js")).column},{name:"join",load:async()=>(await import("./chunks/join-C2B6NGXH.js")).join},{name:"tee",load:async()=>(await import("./chunks/tee-OOWSWHRQ.js")).teeCommand},{name:"find",load:async()=>(await import("./chunks/find-3AONTPPM.js")).findCommand},{name:"basename",load:async()=>(await import("./chunks/basename-SJZQ5W65.js")).basenameCommand},{name:"dirname",load:async()=>(await import("./chunks/dirname-Z2ZMOOW2.js")).dirnameCommand},{name:"tree",load:async()=>(await import("./chunks/tree-7OOL2MH6.js")).treeCommand},{name:"du",load:async()=>(await import("./chunks/du-YBSJVBXP.js")).duCommand},{name:"env",load:async()=>(await import("./chunks/env-VUUMB47B.js")).envCommand},{name:"printenv",load:async()=>(await import("./chunks/env-VUUMB47B.js")).printenvCommand},{name:"alias",load:async()=>(await import("./chunks/alias-T5TO5GWK.js")).aliasCommand},{name:"unalias",load:async()=>(await import("./chunks/alias-T5TO5GWK.js")).unaliasCommand},{name:"history",load:async()=>(await import("./chunks/history-3N762S3K.js")).historyCommand},{name:"xargs",load:async()=>(await import("./chunks/xargs-VQEXRD3C.js")).xargsCommand},{name:"true",load:async()=>(await import("./chunks/true-QUBPEGGU.js")).trueCommand},{name:"false",load:async()=>(await import("./chunks/true-QUBPEGGU.js")).falseCommand},{name:"yes",load:async()=>(await import("./chunks/yes-OVJMX6NM.js")).yesCommand},{name:"clear",load:async()=>(await import("./chunks/clear-KPIUNI6K.js")).clearCommand},{name:"bash",load:async()=>(await import("./chunks/bash-HIEWVHJ2.js")).bashCommand},{name:"sh",load:async()=>(await import("./chunks/bash-HIEWVHJ2.js")).shCommand},{name:"jq",load:async()=>(await import("./chunks/jq-3IVOWP3G.js")).jqCommand},{name:"base64",load:async()=>(await import("./chunks/base64-GUZMZ645.js")).base64Command},{name:"diff",load:async()=>(await import("./chunks/diff-Z3XOLW44.js")).diffCommand,handlesOwnVersion:!0},{name:"date",load:async()=>(await import("./chunks/date-7OEDRA27.js")).dateCommand},{name:"sleep",load:async()=>(await import("./chunks/sleep-YC4HFEGC.js")).sleepCommand},{name:"timeout",load:async()=>(await import("./chunks/timeout-UDR5J2MP.js")).timeoutCommand},{name:"time",load:async()=>(await import("./chunks/time-N6J6DC6C.js")).timeCommand},{name:"seq",load:async()=>(await import("./chunks/seq-M2S4FRN4.js")).seqCommand},{name:"expr",load:async()=>(await import("./chunks/expr-KSNRNE7V.js")).exprCommand},{name:"md5sum",load:async()=>(await import("./chunks/md5sum-JEDX55KS.js")).md5sumCommand},{name:"sha1sum",load:async()=>(await import("./chunks/sha1sum-BLPZJ6MP.js")).sha1sumCommand},{name:"sha256sum",load:async()=>(await import("./chunks/sha256sum-VJZ4PHQ4.js")).sha256sumCommand},{name:"file",load:async()=>(await import("./chunks/file-XH37HMGV.js")).fileCommand},{name:"html-to-markdown",load:async()=>(await import("./chunks/html-to-markdown-4LXS3A44.js")).htmlToMarkdownCommand},{name:"help",load:async()=>(await import("./chunks/help-62M75TSG.js")).helpCommand},{name:"which",load:async()=>(await import("./chunks/which-BP5YY5BR.js")).whichCommand},{name:"tac",load:async()=>(await import("./chunks/tac-YXC4HBTR.js")).tac},{name:"hostname",load:async()=>(await import("./chunks/hostname-CESD3CQR.js")).hostname},{name:"whoami",load:async()=>(await import("./chunks/whoami-KR6E7UIR.js")).whoami},{name:"od",load:async()=>(await import("./chunks/od-VJ6PBBEI.js")).od},{name:"gzip",load:async()=>(await import("./chunks/gzip-ISZXQNJJ.js")).gzipCommand},{name:"gunzip",load:async()=>(await import("./chunks/gzip-ISZXQNJJ.js")).gunzipCommand},{name:"zcat",load:async()=>(await import("./chunks/gzip-ISZXQNJJ.js")).zcatCommand}];(typeof __BROWSER__>"u"||!__BROWSER__)&&(Dn.push({name:"tar",load:async()=>(await import("./chunks/tar-VZYMNZV2.js")).tarCommand}),Dn.push({name:"yq",load:async()=>(await import("./chunks/yq-KYPU4LQP.js")).yqCommand}),Dn.push({name:"xan",load:async()=>(await import("./chunks/xan-DL576EIT.js")).xanCommand}),Dn.push({name:"sqlite3",load:async()=>(await import("./chunks/sqlite3-XCROTL6G.js")).sqlite3Command}));var ss=[];(typeof __BROWSER__>"u"||!__BROWSER__)&&(ss.push({name:"python3",load:async()=>(await import("./chunks/python3-6JEP7ZZK.js")).python3Command,handlesOwnVersion:!0}),ss.push({name:"python",load:async()=>(await import("./chunks/python3-6JEP7ZZK.js")).pythonCommand,handlesOwnVersion:!0}));var is=[];(typeof __BROWSER__>"u"||!__BROWSER__)&&(is.push({name:"js-exec",load:async()=>(await import("./chunks/js-exec-T2WEE4KG.js")).jsExecCommand,handlesOwnVersion:!0}),is.push({name:"node",load:async()=>(await import("./chunks/js-exec-T2WEE4KG.js")).nodeStubCommand}));var al=[{name:"curl",load:async()=>(await import("./chunks/curl-RCRD36LD.js")).curlCommand}],ol=new Map;function os(e){return{name:e.name,handlesOwnVersion:e.handlesOwnVersion,async execute(t,n){let r=ol.get(e.name);if(r||(r=await Re.runTrustedAsync(()=>Er(e.load(),n.signal,`bash: ${e.name} was cancelled before it started
3
- `)),ol.set(e.name,r)),n.coverage&&(typeof __BROWSER__>"u"||!__BROWSER__)){let{emitFlagCoverage:s}=await Er(import("./chunks/flag-coverage-6YGO7STE.js"),n.signal,`bash: ${e.name} was cancelled before it started
2
+ import{a as Zt,b as Qt,c as pt}from"./chunks/chunk-353VO5TF.js";import{b as Tt,c as rl,d as sl,e as il}from"./chunks/chunk-6L6OYVLY.js";import{a as es,b as Er}from"./chunks/chunk-5J4S2LP5.js";import{a as Kr,b as Xr,d as yr,e as gr}from"./chunks/chunk-SXQJYLP7.js";import{c as Li,e as tl,f as nl}from"./chunks/chunk-XZ34OGNM.js";import{a as ln}from"./chunks/chunk-SGX4WOAM.js";import{a as _i}from"./chunks/chunk-L2UW7DWF.js";import{a as an,b as Ye,c as Ar}from"./chunks/chunk-DLL7UR66.js";import{a as Sr,b as el}from"./chunks/chunk-654CJKE3.js";import{a as ge}from"./chunks/chunk-O5BHWBYH.js";import{a as ts,b as ns}from"./chunks/chunk-A3C4Z3Q3.js";import{a as Gn,b as Re}from"./chunks/chunk-A6SU3BZX.js";import"./chunks/chunk-57LGFT4S.js";import{d as rn,e as Qn}from"./chunks/chunk-ZUEPJPYA.js";import"./chunks/chunk-STHBFACM.js";import{a as Ja}from"./chunks/chunk-RK2WBVP4.js";import{a as br,b as vt,c as sn,d as rs,e as V,f as Gt,g as U,h as kt,i as on,j as On,k as ht,l as Kn}from"./chunks/chunk-BMBITA6Y.js";import{a as en,b as nt,c as rt,d as Ve,e as Ke,f as Xe,g as H,h as ce,i as st,j as tn,k as Yr,l as C,m as it,n as Oe,o as nn,p as Jr,q as dt}from"./chunks/chunk-TVCZIH6M.js";import{a as B,b as wr,c as Rn,d as _d,e as Jt,f as Ii,g as Zn,h as Ld,i as qt,j as Ti,k as Fd,l as Md}from"./chunks/chunk-GN6CQ3J4.js";import{a as x,b as Bd,c as De,d as Wd}from"./chunks/chunk-T5ZEIOJ3.js";import{a as Ht}from"./chunks/chunk-W5DWRFSU.js";import{a as It}from"./chunks/chunk-FOCWZZDE.js";import{a as Di}from"./chunks/chunk-NCUTH6QL.js";import*as Be from"node:path";var Dn=[{name:"echo",load:async()=>(await import("./chunks/echo-PLLZYM2L.js")).echoCommand},{name:"cat",load:async()=>(await import("./chunks/cat-LG4YGKUE.js")).catCommand},{name:"printf",load:async()=>(await import("./chunks/printf-B2NSYQ3N.js")).printfCommand},{name:"ls",load:async()=>(await import("./chunks/ls-FC3CSHKE.js")).lsCommand},{name:"mkdir",load:async()=>(await import("./chunks/mkdir-DPFWDY25.js")).mkdirCommand},{name:"mktemp",load:async()=>(await import("./chunks/mktemp-SW2AHXZW.js")).mktempCommand,handlesOwnVersion:!0},{name:"rmdir",load:async()=>(await import("./chunks/rmdir-YXYSZD4X.js")).rmdirCommand},{name:"touch",load:async()=>(await import("./chunks/touch-W4DF6Z4T.js")).touchCommand},{name:"rm",load:async()=>(await import("./chunks/rm-AZZM5DCE.js")).rmCommand},{name:"cp",load:async()=>(await import("./chunks/cp-ZDDVNITX.js")).cpCommand},{name:"mv",load:async()=>(await import("./chunks/mv-PWCFXEF2.js")).mvCommand},{name:"ln",load:async()=>(await import("./chunks/ln-CEM7GDB5.js")).lnCommand},{name:"chmod",load:async()=>(await import("./chunks/chmod-XUKPG2M4.js")).chmodCommand},{name:"pwd",load:async()=>(await import("./chunks/pwd-76BPYV5F.js")).pwdCommand},{name:"readlink",load:async()=>(await import("./chunks/readlink-7XGQ3PL7.js")).readlinkCommand},{name:"head",load:async()=>(await import("./chunks/head-VYXZQLPZ.js")).headCommand},{name:"tail",load:async()=>(await import("./chunks/tail-WK3WACZK.js")).tailCommand},{name:"wc",load:async()=>(await import("./chunks/wc-7WVM7GV4.js")).wcCommand},{name:"stat",load:async()=>(await import("./chunks/stat-I3FPUTR7.js")).statCommand},{name:"grep",load:async()=>(await import("./chunks/grep-WW5KJPUG.js")).grepCommand},{name:"fgrep",load:async()=>(await import("./chunks/grep-WW5KJPUG.js")).fgrepCommand},{name:"egrep",load:async()=>(await import("./chunks/grep-WW5KJPUG.js")).egrepCommand},{name:"rg",load:async()=>(await import("./chunks/rg-2OPJ5V3D.js")).rgCommand,handlesOwnVersion:!0},{name:"sed",load:async()=>(await import("./chunks/sed-HYSBLGO5.js")).sedCommand},{name:"awk",load:async()=>(await import("./chunks/awk2-TLK6FCHV.js")).awkCommand2},{name:"sort",load:async()=>(await import("./chunks/sort-CB5GO7XH.js")).sortCommand},{name:"uniq",load:async()=>(await import("./chunks/uniq-PAEPA27E.js")).uniqCommand},{name:"comm",load:async()=>(await import("./chunks/comm-DTWKU2MC.js")).commCommand},{name:"cut",load:async()=>(await import("./chunks/cut-35WER2E2.js")).cutCommand},{name:"paste",load:async()=>(await import("./chunks/paste-TIQETHSO.js")).pasteCommand},{name:"tr",load:async()=>(await import("./chunks/tr-VI5PIA4A.js")).trCommand},{name:"rev",load:async()=>(await import("./chunks/rev-EPOS3MFH.js")).rev},{name:"nl",load:async()=>(await import("./chunks/nl-IELOWYJG.js")).nl},{name:"fold",load:async()=>(await import("./chunks/fold-QJBPHRFJ.js")).fold},{name:"expand",load:async()=>(await import("./chunks/expand-J3VOSOMK.js")).expand},{name:"unexpand",load:async()=>(await import("./chunks/unexpand-YD5BWFH4.js")).unexpand},{name:"strings",load:async()=>(await import("./chunks/strings-VLFTYX2Z.js")).strings},{name:"split",load:async()=>(await import("./chunks/split-UOPIWKKE.js")).split},{name:"column",load:async()=>(await import("./chunks/column-T4LGMRJG.js")).column},{name:"join",load:async()=>(await import("./chunks/join-C2B6NGXH.js")).join},{name:"tee",load:async()=>(await import("./chunks/tee-OOWSWHRQ.js")).teeCommand},{name:"find",load:async()=>(await import("./chunks/find-BFNQSA5B.js")).findCommand},{name:"basename",load:async()=>(await import("./chunks/basename-SJZQ5W65.js")).basenameCommand},{name:"dirname",load:async()=>(await import("./chunks/dirname-Z2ZMOOW2.js")).dirnameCommand},{name:"tree",load:async()=>(await import("./chunks/tree-7OOL2MH6.js")).treeCommand},{name:"du",load:async()=>(await import("./chunks/du-YBSJVBXP.js")).duCommand},{name:"env",load:async()=>(await import("./chunks/env-VUUMB47B.js")).envCommand},{name:"printenv",load:async()=>(await import("./chunks/env-VUUMB47B.js")).printenvCommand},{name:"alias",load:async()=>(await import("./chunks/alias-T5TO5GWK.js")).aliasCommand},{name:"unalias",load:async()=>(await import("./chunks/alias-T5TO5GWK.js")).unaliasCommand},{name:"history",load:async()=>(await import("./chunks/history-3N762S3K.js")).historyCommand},{name:"xargs",load:async()=>(await import("./chunks/xargs-VQEXRD3C.js")).xargsCommand},{name:"true",load:async()=>(await import("./chunks/true-QUBPEGGU.js")).trueCommand},{name:"false",load:async()=>(await import("./chunks/true-QUBPEGGU.js")).falseCommand},{name:"yes",load:async()=>(await import("./chunks/yes-OVJMX6NM.js")).yesCommand},{name:"clear",load:async()=>(await import("./chunks/clear-KPIUNI6K.js")).clearCommand},{name:"bash",load:async()=>(await import("./chunks/bash-HIEWVHJ2.js")).bashCommand},{name:"sh",load:async()=>(await import("./chunks/bash-HIEWVHJ2.js")).shCommand},{name:"jq",load:async()=>(await import("./chunks/jq-3IVOWP3G.js")).jqCommand},{name:"base64",load:async()=>(await import("./chunks/base64-GUZMZ645.js")).base64Command},{name:"diff",load:async()=>(await import("./chunks/diff-Z3XOLW44.js")).diffCommand,handlesOwnVersion:!0},{name:"date",load:async()=>(await import("./chunks/date-7OEDRA27.js")).dateCommand},{name:"sleep",load:async()=>(await import("./chunks/sleep-YC4HFEGC.js")).sleepCommand},{name:"timeout",load:async()=>(await import("./chunks/timeout-UDR5J2MP.js")).timeoutCommand},{name:"time",load:async()=>(await import("./chunks/time-N6J6DC6C.js")).timeCommand},{name:"seq",load:async()=>(await import("./chunks/seq-M2S4FRN4.js")).seqCommand},{name:"expr",load:async()=>(await import("./chunks/expr-KSNRNE7V.js")).exprCommand},{name:"md5sum",load:async()=>(await import("./chunks/md5sum-JEDX55KS.js")).md5sumCommand},{name:"sha1sum",load:async()=>(await import("./chunks/sha1sum-BLPZJ6MP.js")).sha1sumCommand},{name:"sha256sum",load:async()=>(await import("./chunks/sha256sum-VJZ4PHQ4.js")).sha256sumCommand},{name:"file",load:async()=>(await import("./chunks/file-XH37HMGV.js")).fileCommand},{name:"html-to-markdown",load:async()=>(await import("./chunks/html-to-markdown-4LXS3A44.js")).htmlToMarkdownCommand},{name:"help",load:async()=>(await import("./chunks/help-62M75TSG.js")).helpCommand},{name:"which",load:async()=>(await import("./chunks/which-BP5YY5BR.js")).whichCommand},{name:"tac",load:async()=>(await import("./chunks/tac-YXC4HBTR.js")).tac},{name:"hostname",load:async()=>(await import("./chunks/hostname-CESD3CQR.js")).hostname},{name:"whoami",load:async()=>(await import("./chunks/whoami-KR6E7UIR.js")).whoami},{name:"od",load:async()=>(await import("./chunks/od-VJ6PBBEI.js")).od},{name:"gzip",load:async()=>(await import("./chunks/gzip-ISZXQNJJ.js")).gzipCommand},{name:"gunzip",load:async()=>(await import("./chunks/gzip-ISZXQNJJ.js")).gunzipCommand},{name:"zcat",load:async()=>(await import("./chunks/gzip-ISZXQNJJ.js")).zcatCommand}];(typeof __BROWSER__>"u"||!__BROWSER__)&&(Dn.push({name:"tar",load:async()=>(await import("./chunks/tar-VZYMNZV2.js")).tarCommand}),Dn.push({name:"yq",load:async()=>(await import("./chunks/yq-KYPU4LQP.js")).yqCommand}),Dn.push({name:"xan",load:async()=>(await import("./chunks/xan-DL576EIT.js")).xanCommand}),Dn.push({name:"sqlite3",load:async()=>(await import("./chunks/sqlite3-XCROTL6G.js")).sqlite3Command}));var ss=[];(typeof __BROWSER__>"u"||!__BROWSER__)&&(ss.push({name:"python3",load:async()=>(await import("./chunks/python3-6JEP7ZZK.js")).python3Command,handlesOwnVersion:!0}),ss.push({name:"python",load:async()=>(await import("./chunks/python3-6JEP7ZZK.js")).pythonCommand,handlesOwnVersion:!0}));var is=[];(typeof __BROWSER__>"u"||!__BROWSER__)&&(is.push({name:"js-exec",load:async()=>(await import("./chunks/js-exec-T2WEE4KG.js")).jsExecCommand,handlesOwnVersion:!0}),is.push({name:"node",load:async()=>(await import("./chunks/js-exec-T2WEE4KG.js")).nodeStubCommand}));var al=[{name:"curl",load:async()=>(await import("./chunks/curl-RCRD36LD.js")).curlCommand}],ol=new Map;function os(e){return{name:e.name,handlesOwnVersion:e.handlesOwnVersion,async execute(t,n){let r=ol.get(e.name);if(r||(r=await Re.runTrustedAsync(()=>Er(e.load(),n.signal,`bash: ${e.name} was cancelled before it started
3
+ `)),ol.set(e.name,r)),n.coverage&&(typeof __BROWSER__>"u"||!__BROWSER__)){let{emitFlagCoverage:s}=await Er(import("./chunks/flag-coverage-7PBO3TUZ.js"),n.signal,`bash: ${e.name} was cancelled before it started
4
4
  `);s(n.coverage,e.name,t)}return r.execute(t,n)}}}function Vd(){return Dn.map(e=>e.name)}function zd(){return al.map(e=>e.name)}function ll(e){return(e?Dn.filter(n=>e.includes(n.name)):Dn).map(os)}function cl(){return al.map(os)}function Ud(){return ss.map(e=>e.name)}function ul(){return ss.map(os)}function jd(){return is.map(e=>e.name)}function fl(){return is.map(os)}var dl=new WeakMap,hl=new WeakSet;function as(e){let t=dl.get(e);return t===void 0&&(t=Object.freeze(Object.create(null)),dl.set(e,t),hl.add(t)),t}function pl(e){return hl.has(e)}var ml={maxSourceBytes:67108864,maxExecDepth:64,maxCallDepth:100,maxCommandCount:1e5,maxLoopIterations:1e5,maxAwkIterations:1e5,maxSedIterations:1e5,maxJqIterations:1e7,maxQueryTokens:1e5,maxQueryDepth:1e3,maxQueryElements:1e6,maxAwkParserTokens:1e5,maxAwkParserDepth:256,maxAwkParserOperations:1e6,maxCsvRows:1e6,maxCsvCells:1e7,maxWorkUnits:1e8,maxTraversalEntries:1e6,maxTraversalDepth:1e3,maxTraversalWork:1e6,maxLiveBytes:536870912,maxInputBytes:536870912,maxFileSystemBytes:1073741824,maxDatabaseBytes:1073741824,maxDatabaseResultBytes:268435456,maxArchiveBytes:1073741824,maxArchiveCompressedBytes:536870912,maxArchiveEntryBytes:536870912,maxArchiveEntries:1e6,maxWorkerMessageBytes:67108864,maxExecutionTimeMs:36e5,maxExtensionCleanupTimeMs:100,maxSqliteTimeoutMs:3e4,maxPythonTimeoutMs:3e4,maxJsTimeoutMs:3e4,maxJsMemoryBytes:67108864,maxGlobOperations:1e6,maxStringLength:67108864,maxArrayElements:1e6,maxHeredocSize:67108864,maxSubstitutionDepth:50,maxBraceExpansionResults:1e5,maxOutputSize:268435456,maxFileDescriptors:4096,maxSourceDepth:100},qd={...ml,maxSourceBytes:8*1024*1024,maxCommandCount:1e4,maxLoopIterations:1e4,maxAwkIterations:1e4,maxSedIterations:1e4,maxJqIterations:1e4,maxSqliteTimeoutMs:5e3,maxPythonTimeoutMs:1e4,maxJsTimeoutMs:1e4,maxExtensionCleanupTimeMs:25,maxGlobOperations:1e5,maxStringLength:10*1024*1024,maxArrayElements:1e5,maxHeredocSize:10*1024*1024,maxBraceExpansionResults:1e4,maxOutputSize:10*1024*1024,maxFileDescriptors:1024,maxQueryTokens:25e3,maxQueryDepth:256,maxQueryElements:1e5,maxAwkParserTokens:25e3,maxAwkParserDepth:128,maxAwkParserOperations:1e5,maxCsvRows:1e5,maxCsvCells:1e6,maxWorkUnits:1e5,maxTraversalEntries:1e5,maxTraversalDepth:256,maxTraversalWork:1e5,maxLiveBytes:64*1024*1024,maxInputBytes:32*1024*1024,maxFileSystemBytes:128*1024*1024,maxDatabaseBytes:64*1024*1024,maxDatabaseResultBytes:16*1024*1024,maxArchiveBytes:128*1024*1024,maxArchiveCompressedBytes:64*1024*1024,maxArchiveEntryBytes:64*1024*1024,maxArchiveEntries:1e5,maxWorkerMessageBytes:16*1024*1024,maxExecutionTimeMs:3e4};function Hd(e){return Number.isFinite(e)?Math.min(Math.max(0,Math.floor(e)),4294967295):4294967295}function ls(e,t="normal"){if(t!=="normal"&&t!=="hardened")throw new RangeError('executionLimitProfile must be "normal" or "hardened"');let n=t==="hardened"?qd:ml;if(!e)return{...n};let r={maxSourceBytes:e.maxSourceBytes??n.maxSourceBytes,maxExecDepth:e.maxExecDepth??n.maxExecDepth,maxCallDepth:e.maxCallDepth??n.maxCallDepth,maxCommandCount:e.maxCommandCount??n.maxCommandCount,maxLoopIterations:e.maxLoopIterations??n.maxLoopIterations,maxAwkIterations:e.maxAwkIterations??n.maxAwkIterations,maxSedIterations:e.maxSedIterations??n.maxSedIterations,maxJqIterations:e.maxJqIterations??n.maxJqIterations,maxQueryTokens:e.maxQueryTokens??n.maxQueryTokens,maxQueryDepth:e.maxQueryDepth??n.maxQueryDepth,maxQueryElements:e.maxQueryElements??n.maxQueryElements,maxAwkParserTokens:e.maxAwkParserTokens??n.maxAwkParserTokens,maxAwkParserDepth:e.maxAwkParserDepth??n.maxAwkParserDepth,maxAwkParserOperations:e.maxAwkParserOperations??n.maxAwkParserOperations,maxCsvRows:e.maxCsvRows??n.maxCsvRows,maxCsvCells:e.maxCsvCells??n.maxCsvCells,maxWorkUnits:e.maxWorkUnits??n.maxWorkUnits,maxTraversalEntries:e.maxTraversalEntries??n.maxTraversalEntries,maxTraversalDepth:e.maxTraversalDepth??n.maxTraversalDepth,maxTraversalWork:e.maxTraversalWork??n.maxTraversalWork,maxLiveBytes:e.maxLiveBytes??n.maxLiveBytes,maxInputBytes:e.maxInputBytes??n.maxInputBytes,maxFileSystemBytes:e.maxFileSystemBytes??n.maxFileSystemBytes,maxDatabaseBytes:e.maxDatabaseBytes??n.maxDatabaseBytes,maxDatabaseResultBytes:e.maxDatabaseResultBytes??n.maxDatabaseResultBytes,maxArchiveBytes:e.maxArchiveBytes??n.maxArchiveBytes,maxArchiveCompressedBytes:e.maxArchiveCompressedBytes??n.maxArchiveCompressedBytes,maxArchiveEntryBytes:e.maxArchiveEntryBytes??n.maxArchiveEntryBytes,maxArchiveEntries:e.maxArchiveEntries??n.maxArchiveEntries,maxWorkerMessageBytes:e.maxWorkerMessageBytes??n.maxWorkerMessageBytes,maxExecutionTimeMs:e.maxExecutionTimeMs??n.maxExecutionTimeMs,maxExtensionCleanupTimeMs:e.maxExtensionCleanupTimeMs??n.maxExtensionCleanupTimeMs,maxSqliteTimeoutMs:e.maxSqliteTimeoutMs??n.maxSqliteTimeoutMs,maxPythonTimeoutMs:e.maxPythonTimeoutMs??n.maxPythonTimeoutMs,maxJsTimeoutMs:e.maxJsTimeoutMs??n.maxJsTimeoutMs,maxJsMemoryBytes:Hd(e.maxJsMemoryBytes??n.maxJsMemoryBytes),maxGlobOperations:e.maxGlobOperations??n.maxGlobOperations,maxStringLength:e.maxStringLength??n.maxStringLength,maxArrayElements:e.maxArrayElements??n.maxArrayElements,maxHeredocSize:e.maxHeredocSize??n.maxHeredocSize,maxSubstitutionDepth:e.maxSubstitutionDepth??n.maxSubstitutionDepth,maxBraceExpansionResults:e.maxBraceExpansionResults??n.maxBraceExpansionResults,maxOutputSize:e.maxOutputSize??n.maxOutputSize,maxFileDescriptors:e.maxFileDescriptors??n.maxFileDescriptors,maxSourceDepth:e.maxSourceDepth??n.maxSourceDepth};for(let s of Object.keys(r)){let i=r[s];if(i!==Number.POSITIVE_INFINITY&&(!Number.isSafeInteger(i)||i<0))throw new RangeError(`${s} must be a non-negative safe integer or positive Infinity`)}return r}function Gd(e){let{executionLimits:t,executionLimitProfile:n,fs:r,stdin:s=Ii,...i}=e;return{fs:r,fsIdentity:i.fsIdentity??as(r),cwd:"/",env:new Map,stdin:s,limits:ls(t,n),...i}}function yl(e){return"load"in e&&typeof e.load=="function"}function Zd(e,t,n={}){return{name:e,trusted:n.trusted!==!1,execute:t}}function gl(e){let t=null,n=!1,r=new Set,s=a=>{t=a;for(let l of r)l.resolve(a);r.clear()},i=a=>{n=!1;for(let l of r)l.reject(a);r.clear()},o=()=>{n=!0;let a;try{a=Promise.resolve(e.load())}catch(l){i(l);return}nl.call(a,s,i)};return{name:e.name,trusted:e.trusted!==!1,handlesOwnVersion:e.handlesOwnVersion,async execute(a,l){if(!t){let u,f=new Promise((d,h)=>{u={resolve:d,reject:h},r.add(u)});n||o();try{t=await Er(f,l.signal,`bash: ${e.name} was cancelled before it started
5
5
  `)}finally{u&&r.delete(u)}}let c=t;if(!c)throw new Error(`Failed to load command: ${e.name}`);return c.execute(a,l)}}}var wl=Object.freeze(Object.create(null)),cs=class{limits;signal;abortOnUnresolvedCommands;commandCount=0;workUnits=0;liveBytes=0;inputBytes=0;outputBytes=0;countersByKind=new Map;bytesByKind=new Map;depthByKind=new Map;cleanupCallbacks=[];poisoned;closed=!1;startedAt=Date.now();unresolvedCommands=new Set;get remainingLiveBytes(){return Math.max(0,this.limits.maxLiveBytes-this.liveBytes)}get outputBytesUsed(){return this.outputBytes}constructor(t,n=void 0,r=!1){this.limits=t,this.signal=n,this.abortOnUnresolvedCommands=r}recordUnresolvedCommand(t){this.unresolvedCommands.add(t)}get unresolvedCommandNames(){return[...this.unresolvedCommands]}fail(t){throw this.poisoned??=t,this.poisoned}poisonAfterAbort(t){this.poisoned??=t}assertUsable(){if(this.poisoned)throw this.poisoned;if(this.closed)throw new Error("execution budget is already closed");this.throwIfAborted()}chargeCommand(){return this.consume("commands",1,"execution")}consumeWork(t=1,n="execution"){return this.consume("work",t,n)}consumeLimited(t,n,r,s=t){this.assertUsable();let i=this.countersByKind.get(t)??0;return(!Number.isSafeInteger(n)||n<0||!Number.isSafeInteger(r)||r<0||n>r-i)&&this.fail(new C(`${s}: ${t} work limit exceeded (${r})`,"iterations")),n>this.limits.maxWorkUnits-this.workUnits&&this.fail(new C(`${s}: aggregate work limit exceeded (${this.limits.maxWorkUnits})`,"iterations")),this.countersByKind.set(t,i+n),this.workUnits+=n,i+n}consumeInput(t,n="execution"){return this.assertUsable(),(!Number.isSafeInteger(t)||t<0||t>this.limits.maxInputBytes-this.inputBytes)&&this.fail(new C(`${n}: aggregate input size limit exceeded (${this.limits.maxInputBytes} bytes)`,"string_length")),this.inputBytes+=t,this.inputBytes}consume(t,n=1,r=t){this.assertUsable();let s=this.countersByKind.get(t)??0,i=t==="commands"?this.commandCount:this.workUnits,o=t==="commands"?this.limits.maxCommandCount:this.limits.maxWorkUnits;(!Number.isSafeInteger(n)||n<0||n>o-i)&&this.fail(new C(t==="commands"?`too many commands executed (>${o}), increase executionLimits.maxCommandCount`:`${r}: ${t} work limit exceeded (${o})`,t==="commands"?"commands":"iterations"));let a=i+n;return t==="commands"?this.commandCount=a:this.workUnits=a,this.countersByKind.set(t,s+n),a}reserveBytes(t,n,r){this.assertUsable();let s=typeof t=="string"?t:"live",i=typeof t=="string"?n:t,o=typeof t=="string"?r??s:n??"execution";(!Number.isSafeInteger(i)||i<0||i>this.limits.maxLiveBytes-this.liveBytes)&&this.fail(new C(`${o}: live byte limit exceeded (${this.limits.maxLiveBytes} bytes)`,"string_length")),this.liveBytes+=i,this.bytesByKind.set(s,(this.bytesByKind.get(s)??0)+i);let a=!1;return{release:()=>{if(a)return;a=!0,this.liveBytes-=i;let l=(this.bytesByKind.get(s)??i)-i;l<=0?this.bytesByKind.delete(s):this.bytesByKind.set(s,l)}}}appendOutput(t,n,r="execution",s=0,i="text"){this.assertUsable();let o=i==="bytes"?n.length:B(n);(!Number.isSafeInteger(s)||s<0||s>o)&&this.fail(new C(`${r}: invalid ${t} accounting`,"output_size"));let a=o-s;return a>this.limits.maxOutputSize-this.outputBytes&&this.fail(new C(`${r}: total output size exceeded (>${this.limits.maxOutputSize} bytes), increase executionLimits.maxOutputSize`,"output_size")),this.outputBytes+=a,o}accountResult(t,n="execution",r=Number.POSITIVE_INFINITY){let s=t.internalOutputAccounting,i=Math.min(s?.stdout??0,r),o=Math.min(s?.stderr??0,Math.max(0,r-i)),a=this.appendOutput("stdout",t.stdout,n,i,t.stdoutKind==="bytes"||t.stdoutEncoding==="binary"?"bytes":"text"),l=this.appendOutput("stderr",t.stderr,n,o);return Object.isExtensible(t)?(t.internalOutputAccounting={stdout:a,stderr:l},t):a===0&&l===0?t:{...t,internalOutputAccounting:{stdout:a,stderr:l}}}relinquishOutput(t,n,r){this.assertUsable(),r!==wl&&this.fail(new C(`${n}: unauthorized output accounting release`,"output_size")),(!Number.isSafeInteger(t)||t<0||t>this.outputBytes)&&this.fail(new C(`${n}: invalid output accounting release`,"output_size")),this.outputBytes-=t}enterDepth(t,n=this.limits.maxCallDepth,r){this.assertUsable();let s=typeof n=="number"?n:this.limits.maxCallDepth,i=typeof n=="string"?n:r??t,o=this.depthByKind.get(t)??0;o>=s&&this.fail(new C(`${i}: maximum depth (${s}) exceeded`,"recursion")),this.depthByKind.set(t,o+1);let a=!1;return{release:()=>{if(a)return;a=!0;let l=(this.depthByKind.get(t)??1)-1;l<=0?this.depthByKind.delete(t):this.depthByKind.set(t,l)}}}throwIfAborted(t="execution"){this.signal?.aborted&&this.fail(new it("",`bash: ${t} aborted
6
6
  `)),Date.now()-this.startedAt>this.limits.maxExecutionTimeMs&&this.fail(new it("",`bash: ${t} exceeded execution deadline (${this.limits.maxExecutionTimeMs}ms)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jerryan/just-bash",
3
- "version": "3.11.0",
3
+ "version": "3.11.1",
4
4
  "description": "A simulated bash environment with virtual filesystem",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,17 +0,0 @@
1
- #!/usr/bin/env node
2
- import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
- import{a as be}from"./chunk-BIJXTWZ4.js";import{a as Z}from"./chunk-BRB5PJ3E.js";import{a as oe}from"./chunk-3MRB66F4.js";import{a as Te}from"./chunk-K27FY3ES.js";import{a as le}from"./chunk-623Q77WZ.js";import{b as de,c as he,d as me}from"./chunk-YERKK5B3.js";import{d as we}from"./chunk-AIWBN36Z.js";import{l as ae}from"./chunk-FUT3X2GJ.js";import{a as ie}from"./chunk-CPKBPQ2C.js";import{a as ye,b as ge}from"./chunk-MUFNRCMY.js";function R(e,t){switch(e.type){case"name":{let n=e.pattern,s=n.match(/^\*(\.[a-zA-Z0-9]+)$/);if(s){let a=s[1],l=t.name;if(e.ignoreCase){if(!l.toLowerCase().endsWith(a.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!l.endsWith(a))return{matches:!1,pruned:!1,printed:!1};return{matches:!0,pruned:!1,printed:!1}}return{matches:Z(t.name,n,e.ignoreCase),pruned:!1,printed:!1}}case"path":{let n=e.pattern,s=t.relativePath,a=n.split("/");for(let d=0;d<a.length-1;d++){let r=a[d];if(r&&r!=="."&&r!==".."&&!r.includes("*")&&!r.includes("?")&&!r.includes("[")){let i=`/${r}/`;if(e.ignoreCase){if(!s.toLowerCase().includes(i.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!s.includes(i))return{matches:!1,pruned:!1,printed:!1}}}let l=n.match(/\*(\.[a-zA-Z0-9]+)$/);if(l){let d=l[1];if(e.ignoreCase){if(!s.toLowerCase().endsWith(d.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!s.endsWith(d))return{matches:!1,pruned:!1,printed:!1}}return{matches:Z(s,n,e.ignoreCase),pruned:!1,printed:!1}}case"regex":try{let n=e.ignoreCase?"i":"";return{matches:le(e.pattern,n).test(t.relativePath),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:t.isFile,pruned:!1,printed:!1}:e.fileType==="d"?{matches:t.isDirectory,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"empty":return{matches:t.isEmpty,pruned:!1,printed:!1};case"mtime":{let s=(Date.now()-t.mtime)/(1e3*60*60*24),a;return e.comparison==="more"?a=s>e.days:e.comparison==="less"?a=s<e.days:a=Math.floor(s)===e.days,{matches:a,pruned:!1,printed:!1}}case"newer":{let n=t.newerRefTimes.get(e.refPath);return n===void 0?{matches:!1,pruned:!1,printed:!1}:{matches:t.mtime>n,pruned:!1,printed:!1}}case"size":{let n=e.value;switch(e.unit){case"c":n=e.value;break;case"k":n=e.value*1024;break;case"M":n=e.value*1024*1024;break;case"G":n=e.value*1024*1024*1024;break;case"b":n=e.value*512;break}let s;return e.comparison==="more"?s=t.size>n:e.comparison==="less"?s=t.size<n:e.unit==="b"?s=Math.ceil(t.size/512)===e.value:s=t.size===n,{matches:s,pruned:!1,printed:!1}}case"perm":{let n=t.mode&511,s=e.mode&511,a;return e.matchType==="exact"?a=n===s:e.matchType==="all"?a=(n&s)===s:a=(n&s)!==0,{matches:a,pruned:!1,printed:!1}}case"prune":return{matches:!0,pruned:!0,printed:!1};case"action":return{matches:!0,pruned:!1,printed:!1,actions:[e.action]};case"not":{let n=R(e.expr,t);return{matches:!n.matches,pruned:n.pruned,printed:!1,actions:n.actions}}case"and":{let n=R(e.left,t);if(!n.matches)return{matches:!1,pruned:n.pruned,printed:!1,actions:n.actions};let s=R(e.right,t);return{matches:s.matches,pruned:n.pruned||s.pruned,printed:n.printed||s.printed,actions:[...n.actions??[],...s.actions??[]]}}case"or":{let n=R(e.left,t);if(n.matches)return n;let s=R(e.right,t);return{matches:s.matches,pruned:n.pruned||s.pruned,printed:s.printed,actions:[...n.actions??[],...s.actions??[]]}}}}function _(e){if(!e)return!1;switch(e.type){case"name":case"path":case"regex":case"type":case"prune":return!1;case"action":return!1;case"empty":case"mtime":case"newer":case"size":case"perm":return!0;case"not":return _(e.expr);case"and":case"or":return _(e.left)||_(e.right)}}function j(e){if(!e)return!1;switch(e.type){case"empty":return!0;case"not":return j(e.expr);case"and":case"or":return j(e.left)||j(e.right);default:return!1}}function Se(e){let t=[],n=s=>{s&&(s.type==="newer"?t.push(s.refPath):s.type==="not"?n(s.expr):(s.type==="and"||s.type==="or")&&(n(s.left),n(s.right)))};return n(e),t}function J(e){if(!e)return!0;switch(e.type){case"name":case"path":case"regex":case"type":case"prune":return!0;case"action":return!1;case"empty":case"mtime":case"newer":case"size":case"perm":return!1;case"not":return J(e.expr);case"and":case"or":return J(e.left)&&J(e.right)}}function B(e,t,n,s,a){switch(e.type){case"name":{let l=e.pattern,d=l.match(/^\*(\.[a-zA-Z0-9]+)$/);if(d){let r=d[1];if(e.ignoreCase){if(!t.toLowerCase().endsWith(r.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!t.endsWith(r))return{matches:!1,pruned:!1,printed:!1};return{matches:!0,pruned:!1,printed:!1}}return{matches:Z(t,l,e.ignoreCase),pruned:!1,printed:!1}}case"path":{let l=e.pattern,d=l.split("/");for(let i=0;i<d.length-1;i++){let o=d[i];if(o&&o!=="."&&o!==".."&&!o.includes("*")&&!o.includes("?")&&!o.includes("[")){let u=`/${o}/`;if(e.ignoreCase){if(!n.toLowerCase().includes(u.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!n.includes(u))return{matches:!1,pruned:!1,printed:!1}}}let r=l.match(/\*(\.[a-zA-Z0-9]+)$/);if(r){let i=r[1];if(e.ignoreCase){if(!n.toLowerCase().endsWith(i.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!n.endsWith(i))return{matches:!1,pruned:!1,printed:!1}}return{matches:Z(n,l,e.ignoreCase),pruned:!1,printed:!1}}case"regex":try{let l=e.ignoreCase?"i":"";return{matches:le(e.pattern,l).test(n),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:s,pruned:!1,printed:!1}:e.fileType==="d"?{matches:a,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"prune":return{matches:!0,pruned:!0,printed:!1};case"action":return{matches:!0,pruned:!1,printed:!1,actions:[e.action]};case"not":{let l=B(e.expr,t,n,s,a);return{matches:!l.matches,pruned:l.pruned,printed:!1,actions:l.actions}}case"and":{let l=B(e.left,t,n,s,a);if(!l.matches)return{matches:!1,pruned:l.pruned,printed:!1,actions:l.actions};let d=B(e.right,t,n,s,a);return{matches:d.matches,pruned:l.pruned||d.pruned,printed:l.printed||d.printed,actions:[...l.actions??[],...d.actions??[]]}}case"or":{let l=B(e.left,t,n,s,a);if(l.matches)return l;let d=B(e.right,t,n,s,a);return{matches:d.matches,pruned:l.pruned||d.pruned,printed:d.printed,actions:[...l.actions??[],...d.actions??[]]}}default:return{matches:!1,pruned:!1,printed:!1}}}function U(e){if(!e)return!1;switch(e.type){case"prune":return!0;case"not":return U(e.expr);case"and":case"or":return U(e.left)||U(e.right);default:return!1}}function L(e){switch(e.type){case"name":case"path":case"regex":case"type":case"prune":return!0;case"action":return!1;case"empty":case"mtime":case"newer":case"size":case"perm":return!1;case"not":return L(e.expr);case"and":case"or":return L(e.left)&&L(e.right)}}function Ce(e,t){if(!e||!t.isDirectory)return{shouldPrune:!1};if(!L(e))return ce(e,t);let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return{shouldPrune:R(e,n).pruned}}function ce(e,t){switch(e.type){case"or":{if(L(e.left)){let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};if(R(e.left,n).pruned)return{shouldPrune:!0}}return ce(e.right,t)}case"and":{if(L(e.left)&&L(e.right)){let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return{shouldPrune:R(e,n).pruned}}if(L(e.left)){let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return R(e.left,n).matches?ce(e.right,t):{shouldPrune:!1}}return{shouldPrune:!1}}case"not":return{shouldPrune:!1};default:return{shouldPrune:!1}}}function Ee(e,t){let n=[],s=t,a=r=>({expr:null,pathIndex:s,error:`find: missing argument to \`${r}'
4
- `}),l=(r,i)=>({expr:null,pathIndex:s,error:`find: invalid argument \`${i}' to \`${r}'
5
- `});for(;s<e.length;){let r=e[s];if(r==="("||r==="\\("){n.push({type:"lparen"}),s++;continue}if(r===")"||r==="\\)"){n.push({type:"rparen"}),s++;continue}if(r==="-name"){if(s+1>=e.length)return a(r);n.push({type:"expr",expr:{type:"name",pattern:e[++s]}})}else if(r==="-iname"){if(s+1>=e.length)return a(r);n.push({type:"expr",expr:{type:"name",pattern:e[++s],ignoreCase:!0}})}else if(r==="-path"){if(s+1>=e.length)return a(r);n.push({type:"expr",expr:{type:"path",pattern:e[++s]}})}else if(r==="-ipath"){if(s+1>=e.length)return a(r);n.push({type:"expr",expr:{type:"path",pattern:e[++s],ignoreCase:!0}})}else if(r==="-regex"){if(s+1>=e.length)return a(r);n.push({type:"expr",expr:{type:"regex",pattern:e[++s]}})}else if(r==="-iregex"){if(s+1>=e.length)return a(r);n.push({type:"expr",expr:{type:"regex",pattern:e[++s],ignoreCase:!0}})}else if(r==="-type"){if(s+1>=e.length)return a(r);let i=e[++s];if(i==="f"||i==="d")n.push({type:"expr",expr:{type:"type",fileType:i}});else return{expr:null,pathIndex:s,error:`find: Unknown argument to -type: ${i}
6
- `}}else if(r==="-empty")n.push({type:"expr",expr:{type:"empty"}});else if(r==="-mtime"){if(s+1>=e.length)return a(r);let i=e[++s],o="exact",u=i;if(i.startsWith("+")?(o="more",u=i.slice(1)):i.startsWith("-")&&(o="less",u=i.slice(1)),!/^\d+$/.test(u))return l(r,i);let N=Number(u);if(!Number.isSafeInteger(N))return l(r,i);n.push({type:"expr",expr:{type:"mtime",days:N,comparison:o}})}else if(r==="-newer"){if(s+1>=e.length)return a(r);let i=e[++s];n.push({type:"expr",expr:{type:"newer",refPath:i}})}else if(r==="-size"){if(s+1>=e.length)return a(r);let i=e[++s],o="exact",u=i;i.startsWith("+")?(o="more",u=i.slice(1)):i.startsWith("-")&&(o="less",u=i.slice(1));let N=u.match(/^(\d+)([ckMGb])?$/);if(!N)return l(r,i);let F=Number(N[1]);if(!Number.isSafeInteger(F))return l(r,i);let M=N[2]||"b",V=M==="G"?1024**3:M==="M"?1024**2:M==="k"?1024:M==="b"?512:1;if(!Number.isSafeInteger(F*V))return l(r,i);n.push({type:"expr",expr:{type:"size",value:F,unit:M,comparison:o}})}else if(r==="-perm"){if(s+1>=e.length)return a(r);let i=e[++s],o="exact",u=i;if(i.startsWith("-")?(o="all",u=i.slice(1)):i.startsWith("/")&&(o="any",u=i.slice(1)),!/^[0-7]{1,4}$/.test(u))return l(r,i);let N=Number.parseInt(u,8);n.push({type:"expr",expr:{type:"perm",mode:N,matchType:o}})}else if(r==="-prune")n.push({type:"expr",expr:{type:"prune"}});else if(r==="-not"||r==="!")n.push({type:"not"});else if(r==="-o"||r==="-or")n.push({type:"op",op:"or"});else if(r==="-a"||r==="-and")n.push({type:"op",op:"and"});else if(r==="-maxdepth"||r==="-mindepth"){if(s+1>=e.length)return a(r);s++}else if(r!=="-depth")if(r==="-exec"){let i=[];for(s++;s<e.length&&e[s]!==";"&&e[s]!=="+";)i.push(e[s]),s++;if(s>=e.length)return{expr:null,pathIndex:s,error:"find: missing argument to `-exec'\n"};if(i.length===0)return a("-exec");let o=e[s]==="+";if(o&&(i.at(-1)!=="{}"||i.filter(u=>u==="{}").length!==1))return l("-exec","+");n.push({type:"expr",expr:{type:"action",action:{type:"exec",command:i,batchMode:o}}})}else if(r==="-print")n.push({type:"expr",expr:{type:"action",action:{type:"print"}}});else if(r==="-print0")n.push({type:"expr",expr:{type:"action",action:{type:"print0"}}});else if(r==="-printf"){if(s+1>=e.length)return a(r);let i=e[++s];n.push({type:"expr",expr:{type:"action",action:{type:"printf",format:i}}})}else if(r==="-delete")n.push({type:"expr",expr:{type:"action",action:{type:"delete"}}});else return r.startsWith("-")?{expr:null,pathIndex:s,error:`find: unknown predicate '${r}'
7
- `}:{expr:null,pathIndex:s,error:`find: paths must precede expression: \`${r}'
8
- `};s++}if(n.length===0)return{expr:null,pathIndex:s};let d=Ne(n);return d.error?{expr:null,pathIndex:s,error:d.error}:{expr:d.expr,pathIndex:s}}function Ne(e){let t=0,n;function s(){let i=a();if(!i)return null;for(;t<e.length;){let o=e[t];if(o.type==="op"&&o.op==="or"){t++;let u=a();if(!u)return n="find: expected an expression after `-o'\n",null;i={type:"or",left:i,right:u}}else break}return i}function a(){let i=l();if(!i)return null;for(;t<e.length;){let o=e[t];if(o.type==="op"&&o.op==="and"){t++;let u=l();if(!u)return n="find: expected an expression after `-a'\n",null;i={type:"and",left:i,right:u}}else if(o.type==="expr"||o.type==="not"||o.type==="lparen"){let u=l();if(!u)return i;i={type:"and",left:i,right:u}}else break}return i}function l(){if(t<e.length&&e[t].type==="not"){t++;let i=l();return i?{type:"not",expr:i}:(n="find: expected an expression after `!'\n",null)}return d()}function d(){if(t>=e.length)return null;let i=e[t];if(i.type==="lparen"){t++;let o=s();return!o||t>=e.length||e[t].type!=="rparen"?(n="find: missing closing `)'\n",null):(t++,o)}return i.type==="expr"?(t++,i.expr):(i.type==="rparen",null)}let r=s();return!n&&t<e.length&&(n=e[t].type==="rparen"?"find: unexpected `)'\n":`find: invalid expression
9
- `),!n&&r&&ee(r)&&(n="find: refusing to evaluate `-delete' under negation\n"),{expr:n?null:r,error:n}}function ee(e,t=!1){return e.type==="action"?t&&e.action.type==="delete":e.type==="not"?ee(e.expr,!t):e.type==="and"||e.type==="or"?ee(e.left,t)||ee(e.right,t):!1}var ve=500;function Re(){return{readdirCalls:0,readdirTime:0,statCalls:0,statTime:0,evalCalls:0,evalTime:0,nodeCount:0,batchCount:0,batchTime:0,earlyPrunes:0}}function Fe(e,t,n){e({category:"find",name:"summary",durationMs:n,details:{readdirCalls:t.readdirCalls,readdirTimeMs:t.readdirTime,statCalls:t.statCalls,statTimeMs:t.statTime,evalCalls:t.evalCalls,evalTimeMs:t.evalTime,nodeCount:t.nodeCount,batchCount:t.batchCount,batchTimeMs:t.batchTime,earlyPrunes:t.earlyPrunes,otherTimeMs:n-t.readdirTime-t.statTime-t.evalTime-t.batchTime}})}var ze={name:"find",summary:"search for files in a directory hierarchy",usage:"find [path...] [expression]",options:["-name PATTERN file name matches shell pattern PATTERN","-iname PATTERN like -name but case insensitive","-path PATTERN file path matches shell pattern PATTERN","-ipath PATTERN like -path but case insensitive","-regex PATTERN file path matches regular expression PATTERN","-iregex PATTERN like -regex but case insensitive","-type TYPE file is of type: f (regular file), d (directory)","-empty file is empty or directory is empty","-mtime N file's data was modified N*24 hours ago","-newer FILE file was modified more recently than FILE","-size N[ckMGb] file uses N units of space (c=bytes, k=KB, M=MB, G=GB, b=512B blocks)","-perm MODE file's permission bits are exactly MODE (octal)","-perm -MODE all permission bits MODE are set","-perm /MODE any permission bits MODE are set","-maxdepth LEVELS descend at most LEVELS directories","-mindepth LEVELS do not apply tests at levels less than LEVELS","-depth process directory contents before directory itself","-prune do not descend into this directory","-not, ! negate the following expression","-a, -and logical AND (default)","-o, -or logical OR","-exec CMD {} ; execute CMD on each file ({} is replaced by filename)","-exec CMD {} + execute CMD with multiple files at once","-print print the full file name (default action)","-print0 print the full file name followed by a null character","-printf FORMAT print FORMAT with directives: %f %h %p %P %s %d %m %M %t","-delete delete found files/directories"," --help display this help and exit"]},nt={name:"find",async execute(e,t){if(ge(e))return ye(ze);let n=[],s=null,a=null,l=!1,d=e.length;for(let c=0;c<e.length;c++){let f=e[c];if(f.startsWith("-")||f==="("||f==="\\("||f===")"||f==="\\)"||f==="!"){d=c;break}n.push(f)}n.length===0&&n.push(".");for(let c=d;c<e.length;c++){let f=e[c];if(f==="-exec")for(c++;c<e.length&&e[c]!==";"&&e[c]!=="+";)c++;else if(f==="-maxdepth"||f==="-mindepth"){let p=e[c+1];if(p===void 0||!/^\d+$/.test(p))return{stdout:"",stderr:p===void 0?`find: missing argument to \`${f}'
10
- `:`find: invalid argument \`${p}' to \`${f}'
11
- `,exitCode:1};let v=Number(p);if(!Number.isSafeInteger(v))return{stdout:"",stderr:`find: invalid argument \`${p}' to \`${f}'
12
- `,exitCode:1};f==="-maxdepth"?s=v:a=v,c++}else f==="-depth"&&(l=!0)}let{expr:r,error:i}=Ee(e,d);if(i)return{stdout:"",stderr:i,exitCode:1};let o=te(r),u=o.length>0;o.some(c=>c.type==="delete")&&(l=!0);let N=[],F=0,M=t.executionScope?new Te(t.executionScope,"find"):void 0,V=[],fe=[],Q=0,O=new we({limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:"find"}),G=c=>{if(M)M.append("stdout",c);else{let f=ie(c);if(f>t.limits.maxOutputSize-Q)throw new ae(`find: output size limit exceeded (${t.limits.maxOutputSize} bytes)`,"output_size");c&&V.push(c),Q+=f}},q=c=>{if(M)M.append("stderr",c);else{let f=ie(c);if(f>t.limits.maxOutputSize-Q)throw new ae(`find: output size limit exceeded (${t.limits.maxOutputSize} bytes)`,"output_size");c&&fe.push(c),Q+=f}},De=Se(r),ne=new Map;for(let c of De){let f=t.fs.resolvePath(t.cwd,c);try{let p=await t.fs.stat(f);ne.set(c,p.mtime?.getTime()??Date.now())}catch{}}let Me=o.some(c=>{if(c.type!=="printf")return!1;let f=c.format.replace(/%%/g,"");return/%[-+]?[0-9]*\.?[0-9]*(s|m|M|t|T)/.test(f)}),Pe=_(r)||Me,xe=j(r),ue=U(r),$e=J(r),Ie=typeof t.fs.readdirWithFileTypes=="function";for(let c of n){let z=function(h){let y={path:h.relativePath,name:h.name,size:h.stat?.size??0,mtime:h.stat?.mtime?.getTime()??Date.now(),mode:h.stat?.mode??420,isDirectory:h.isDirectory,depth:h.depth,startingPoint:c},C=h.unreadable===void 0?[]:[{action:{type:"diagnostic",message:`find: ${h.relativePath}: ${h.unreadable}
13
- `},path:h.relativePath,printfData:y}],I=w=>l?[...C,...w]:[...w,...C];if(!(a===null||h.depth>=a))return C;let g=!0,m=[];if(r!==null){let w=Date.now(),T;if($e)T=B(r,h.name,h.relativePath,h.isFile,h.isDirectory);else{let S={name:h.name,relativePath:h.relativePath,isFile:h.isFile,isDirectory:h.isDirectory,isEmpty:h.isEmpty,mtime:h.stat?.mtime?.getTime()??Date.now(),size:h.stat?.size??0,mode:h.stat?.mode??420,newerRefTimes:ne};T=R(r,S)}g=T.matches,m=T.actions??[],p.evalCalls++,p.evalTime+=Date.now()-w}if(!u&&g&&(m=[{type:"print"}]),m.length===0)return C;O.checkpoint(m.length);let b=[];for(let w of m)b.push({action:w,path:h.relativePath,printfData:y});return I(b)};var He=z;c.length>1&&c.endsWith("/")&&(c=c.slice(0,-1));let f=t.fs.resolvePath(t.cwd,c);try{await t.fs.stat(f)}catch{q(`find: ${c}: No such file or directory
14
- `),F=1;continue}let p=Re(),v=Date.now();async function P(h){let{path:y,depth:C,typeInfo:I}=h;if(O.visit(C),p.nodeCount++,C>(s??t.limits.maxTraversalDepth))return null;let x,g,m;if(I&&!Pe)x=I.isFile,g=I.isDirectory;else{try{let W=Date.now();m=await t.fs.lstat(y),p.statCalls++,p.statTime+=Date.now()-W}catch{return null}if(!m)return null;x=m.isFile,g=m.isDirectory}let b;y===f?b=c.split("/").pop()||c:b=y.split("/").pop()||"";let w=y===f?c:c==="."?`./${y.slice(f==="/"?f.length:f.length+1)}`:c+y.slice(f.length),T=[],S=null,E=null,$=!1;g&&ue&&!l&&($=Ce(r,{name:b,relativePath:w,isFile:x,isDirectory:g}).shouldPrune,$&&p.earlyPrunes++);let H=!(C>=(s??t.limits.maxTraversalDepth))&&!$,K=(H||xe)&&!$,X;if(g&&K){let W=Date.now();try{Ie&&t.fs.readdirWithFileTypes?S=await t.fs.readdirWithFileTypes(y):E=await t.fs.readdir(y)}catch(D){let A=Le(D);if(A===null)throw D;X=A,p.readdirCalls++,p.readdirTime+=Date.now()-W}if(S!==null){O.checkpoint(),O.discover(S.length),E=[];for(let D of S)E.push(D.name);if(p.readdirCalls++,p.readdirTime+=Date.now()-W,H)for(let D=0;D<S.length;D++){let A=S[D];T.push({path:y==="/"?`/${A.name}`:`${y}/${A.name}`,depth:C+1,typeInfo:{isFile:A.isFile,isDirectory:A.isDirectory},resultIndex:D})}}else if(E!==null&&(O.checkpoint(),O.discover(E.length),p.readdirCalls++,p.readdirTime+=Date.now()-W,H))for(let D=0;D<E.length;D++){let A=E[D];T.push({path:y==="/"?`/${A}`:`${y}/${A}`,depth:C+1,resultIndex:D})}}let Y=x?(m?.size??0)===0:E!==null&&E.length===0,re=$;if(!l&&r!==null&&!$&&ue){let W=Date.now(),D={name:b,relativePath:w,isFile:x,isDirectory:g,isEmpty:Y,mtime:m?.mtime?.getTime()??Date.now(),size:m?.size??0,mode:m?.mode??420,newerRefTimes:ne};re=R(r,D).pruned,p.evalCalls++,p.evalTime+=Date.now()-W}return{relativePath:w,name:b,isFile:x,isDirectory:g,isEmpty:Y,stat:m,depth:C,children:re?[]:T,pruned:re,unreadable:X}}async function ke(){let h={effects:[]};if(l){let y=[],C=[{item:{path:f,depth:0,resultIndex:0},parentIndex:-1,childOrderInParent:0}],I=new Map,x=0;for(;x<C.length;){let g=Date.now(),m=Math.min(C.length,x+ve),b=C.slice(x,m);x=m;let w=await Promise.all(b.map(T=>P(T.item)));p.batchCount++,p.batchTime+=Date.now()-g;for(let T=0;T<b.length;T++){let S=w[T],E=b[T];if(!S)continue;let $=y.length;if(E.parentIndex>=0){let k=I.get(E.parentIndex)||[];k.push($),I.set(E.parentIndex,k)}y.push({node:S,parentIndex:E.parentIndex,childIndices:[]});for(let k=0;k<S.children.length;k++)C.push({item:S.children[k],parentIndex:$,childOrderInParent:k})}}for(let[g,m]of I)g>=0&&g<y.length&&(y[g].childIndices=m);if(y.length>0){let g=[{index:0,visited:!1}];for(;g.length>0;){O.checkpoint();let m=g.pop();if(!m)break;let b=y[m.index];if(b){if(m.visited){for(let w of z(b.node))h.effects.push(w);continue}g.push({index:m.index,visited:!0});for(let w=b.childIndices.length-1;w>=0;w--)g.push({index:b.childIndices[w],visited:!1})}}}}else{let y=new Map,C=0,I=[{item:{path:f,depth:0,resultIndex:0},orderIndex:C++}],x=new Map,g=0;for(;g<I.length;){let b=Date.now(),w=Math.min(I.length,g+ve),T=I.slice(g,w);g=w;let S=await Promise.all(T.map(async({item:E,orderIndex:$})=>{let k=await P(E);return k?{node:k,orderIndex:$}:null}));p.batchCount++,p.batchTime+=Date.now()-b;for(let E of S){if(!E)continue;let{node:$,orderIndex:k}=E,H=z($);if(H.length>0&&y.set(k,H),$.children.length>0){let K=[];for(let X of $.children){let Y=C++;K.push(Y),I.push({item:X,orderIndex:Y})}x.set(k,K)}}}let m=[0];for(;m.length>0;){O.checkpoint();let b=m.pop();if(b===void 0)break;let w=y.get(b);if(w)for(let S of w)h.effects.push(S);let T=x.get(b);if(T)for(let S=T.length-1;S>=0;S--)m.push(T[S])}}return h}let pe=await ke();for(let h of pe.effects)N.push(h);if(t.trace){let h=Date.now()-v;Fe(t.trace,p,h),t.trace({category:"find",name:"searchPath",durationMs:h,details:{path:c,resultsFound:pe.effects.filter(y=>y.action.type!=="diagnostic").length}})}}let se=new Map;for(let c of N){let{action:f,path:p}=c;switch(f.type){case"diagnostic":q(f.message),F=1;break;case"print":G(`${p}
15
- `);break;case"print0":G(`${p}\0`);break;case"printf":G(Ae(f.format,c.printfData));break;case"delete":{let v=t.fs.resolvePath(t.cwd,p);try{await t.fs.rm(v,{recursive:!1})}catch(P){let z=P instanceof Error?P.message:String(P);q(`find: cannot delete '${p}': ${z}
16
- `),F=1}break}case"exec":{if(!t.exec)return{stdout:"",stderr:`find: -exec not supported in this context
17
- `,exitCode:1};if(f.batchMode){let z=se.get(f)??[];z.push(p),se.set(f,z);break}let v=f.command.map(z=>z==="{}"?p:z),P=await t.exec(oe([v[0]]),{cwd:t.cwd,signal:t.signal,args:v.slice(1)});M?M.appendResult(P):(G(P.stdout),q(P.stderr)),P.exitCode!==0&&(F=P.exitCode);break}}}for(let[c,f]of se){if(c.type!=="exec"||!t.exec||f.length===0)continue;let p=[];for(let P of c.command)P==="{}"?p.push(...f):p.push(P);let v=await t.exec(oe([p[0]]),{cwd:t.cwd,signal:t.signal,args:p.slice(1)});M?M.appendResult(v):(G(v.stdout),q(v.stderr)),v.exitCode!==0&&(F=v.exitCode)}return M?.build(F)??{stdout:V.join(""),stderr:fe.join(""),exitCode:F}}};function te(e){return e?e.type==="action"?[e.action]:e.type==="not"?te(e.expr):e.type==="and"||e.type==="or"?[...te(e.left),...te(e.right)]:[]:[]}function Ae(e,t){let n=me(e),s="",a=0;for(;a<n.length;)if(n[a]==="%"&&a+1<n.length){if(a++,n[a]==="%"){s+="%",a++;continue}let[l,d,r]=he(n,a);if(a+=r,a>=n.length){s+="%";break}let i=n[a],o;switch(i){case"f":o=t.name,a++;break;case"h":{let u=t.path.lastIndexOf("/");o=u>0?t.path.slice(0,u):".",a++;break}case"p":o=t.path,a++;break;case"P":{let u=t.startingPoint;t.path===u?o="":t.path.startsWith(`${u}/`)?o=t.path.slice(u.length+1):u==="."&&t.path.startsWith("./")?o=t.path.slice(2):o=t.path,a++;break}case"s":o=String(t.size),a++;break;case"d":o=String(t.depth),a++;break;case"m":o=(t.mode&511).toString(8),a++;break;case"M":o=be(t.mode,t.isDirectory),a++;break;case"t":{let u=new Date(t.mtime);o=Oe(u),a++;break}case"T":{if(a+1<n.length){let u=n[a+1],N=new Date(t.mtime);o=Be(N,u),a+=2}else o="%T",a++;break}default:s+=`%${l!==0||d!==-1?`${l}.${d}`:""}${i}`,a++;continue}s+=de(o,l,d)}else s+=n[a],a++;return s}function Oe(e){let t=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],s=t[e.getDay()],a=n[e.getMonth()],l=String(e.getDate()).padStart(2," "),d=String(e.getHours()).padStart(2,"0"),r=String(e.getMinutes()).padStart(2,"0"),i=String(e.getSeconds()).padStart(2,"0"),o=e.getFullYear();return`${s} ${a} ${l} ${d}:${r}:${i} ${o}`}var We=new Map([["EACCES","Permission denied"],["EIO","Input/output error"],["ELOOP","Too many levels of symbolic links"],["ENAMETOOLONG","File name too long"],["ENOENT","No such file or directory"],["ENOTDIR","Not a directory"],["EPERM","Permission denied"]]);function Le(e){let t=typeof e=="object"&&e!==null&&"code"in e&&typeof e.code=="string"?e.code:e instanceof Error?/^(E[A-Z]+)\b/.exec(e.message)?.[1]:void 0;return t===void 0?null:We.get(t)??null}function Be(e,t){switch(t){case"@":return String(e.getTime()/1e3);case"Y":return String(e.getFullYear());case"m":return String(e.getMonth()+1).padStart(2,"0");case"d":return String(e.getDate()).padStart(2,"0");case"H":return String(e.getHours()).padStart(2,"0");case"M":return String(e.getMinutes()).padStart(2,"0");case"S":return String(e.getSeconds()).padStart(2,"0");case"T":return`${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}:${String(e.getSeconds()).padStart(2,"0")}`;case"F":return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`;default:return`%T${t}`}}var st={name:"find",flags:[{flag:"-name",type:"value",valueHint:"pattern"},{flag:"-iname",type:"value",valueHint:"pattern"},{flag:"-type",type:"value",valueHint:"string"},{flag:"-maxdepth",type:"value",valueHint:"number"},{flag:"-mindepth",type:"value",valueHint:"number"},{flag:"-empty",type:"boolean"},{flag:"-print",type:"boolean"},{flag:"-print0",type:"boolean"}],needsFiles:!0};export{nt as a,st as b};
@@ -1,17 +0,0 @@
1
- #!/usr/bin/env node
2
- import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
- import{a as be}from"./chunk-BIJXTWZ4.js";import{a as Z}from"./chunk-BRB5PJ3E.js";import{a as oe}from"./chunk-3MRB66F4.js";import{a as Te}from"./chunk-K27FY3ES.js";import{a as le}from"./chunk-623Q77WZ.js";import{b as de,c as he,d as me}from"./chunk-YERKK5B3.js";import{d as we}from"./chunk-AIWBN36Z.js";import{l as ae}from"./chunk-FUT3X2GJ.js";import{a as ie}from"./chunk-CPKBPQ2C.js";import{a as ye,b as ge}from"./chunk-MUFNRCMY.js";function R(e,t){switch(e.type){case"name":{let n=e.pattern,s=n.match(/^\*(\.[a-zA-Z0-9]+)$/);if(s){let a=s[1],l=t.name;if(e.ignoreCase){if(!l.toLowerCase().endsWith(a.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!l.endsWith(a))return{matches:!1,pruned:!1,printed:!1};return{matches:!0,pruned:!1,printed:!1}}return{matches:Z(t.name,n,e.ignoreCase),pruned:!1,printed:!1}}case"path":{let n=e.pattern,s=t.relativePath,a=n.split("/");for(let d=0;d<a.length-1;d++){let r=a[d];if(r&&r!=="."&&r!==".."&&!r.includes("*")&&!r.includes("?")&&!r.includes("[")){let i=`/${r}/`;if(e.ignoreCase){if(!s.toLowerCase().includes(i.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!s.includes(i))return{matches:!1,pruned:!1,printed:!1}}}let l=n.match(/\*(\.[a-zA-Z0-9]+)$/);if(l){let d=l[1];if(e.ignoreCase){if(!s.toLowerCase().endsWith(d.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!s.endsWith(d))return{matches:!1,pruned:!1,printed:!1}}return{matches:Z(s,n,e.ignoreCase),pruned:!1,printed:!1}}case"regex":try{let n=e.ignoreCase?"i":"";return{matches:le(e.pattern,n).test(t.relativePath),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:t.isFile,pruned:!1,printed:!1}:e.fileType==="d"?{matches:t.isDirectory,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"empty":return{matches:t.isEmpty,pruned:!1,printed:!1};case"mtime":{let s=(Date.now()-t.mtime)/(1e3*60*60*24),a;return e.comparison==="more"?a=s>e.days:e.comparison==="less"?a=s<e.days:a=Math.floor(s)===e.days,{matches:a,pruned:!1,printed:!1}}case"newer":{let n=t.newerRefTimes.get(e.refPath);return n===void 0?{matches:!1,pruned:!1,printed:!1}:{matches:t.mtime>n,pruned:!1,printed:!1}}case"size":{let n=e.value;switch(e.unit){case"c":n=e.value;break;case"k":n=e.value*1024;break;case"M":n=e.value*1024*1024;break;case"G":n=e.value*1024*1024*1024;break;case"b":n=e.value*512;break}let s;return e.comparison==="more"?s=t.size>n:e.comparison==="less"?s=t.size<n:e.unit==="b"?s=Math.ceil(t.size/512)===e.value:s=t.size===n,{matches:s,pruned:!1,printed:!1}}case"perm":{let n=t.mode&511,s=e.mode&511,a;return e.matchType==="exact"?a=n===s:e.matchType==="all"?a=(n&s)===s:a=(n&s)!==0,{matches:a,pruned:!1,printed:!1}}case"prune":return{matches:!0,pruned:!0,printed:!1};case"action":return{matches:!0,pruned:!1,printed:!1,actions:[e.action]};case"not":{let n=R(e.expr,t);return{matches:!n.matches,pruned:n.pruned,printed:!1,actions:n.actions}}case"and":{let n=R(e.left,t);if(!n.matches)return{matches:!1,pruned:n.pruned,printed:!1,actions:n.actions};let s=R(e.right,t);return{matches:s.matches,pruned:n.pruned||s.pruned,printed:n.printed||s.printed,actions:[...n.actions??[],...s.actions??[]]}}case"or":{let n=R(e.left,t);if(n.matches)return n;let s=R(e.right,t);return{matches:s.matches,pruned:n.pruned||s.pruned,printed:s.printed,actions:[...n.actions??[],...s.actions??[]]}}}}function _(e){if(!e)return!1;switch(e.type){case"name":case"path":case"regex":case"type":case"prune":return!1;case"action":return!1;case"empty":case"mtime":case"newer":case"size":case"perm":return!0;case"not":return _(e.expr);case"and":case"or":return _(e.left)||_(e.right)}}function j(e){if(!e)return!1;switch(e.type){case"empty":return!0;case"not":return j(e.expr);case"and":case"or":return j(e.left)||j(e.right);default:return!1}}function Se(e){let t=[],n=s=>{s&&(s.type==="newer"?t.push(s.refPath):s.type==="not"?n(s.expr):(s.type==="and"||s.type==="or")&&(n(s.left),n(s.right)))};return n(e),t}function J(e){if(!e)return!0;switch(e.type){case"name":case"path":case"regex":case"type":case"prune":return!0;case"action":return!1;case"empty":case"mtime":case"newer":case"size":case"perm":return!1;case"not":return J(e.expr);case"and":case"or":return J(e.left)&&J(e.right)}}function B(e,t,n,s,a){switch(e.type){case"name":{let l=e.pattern,d=l.match(/^\*(\.[a-zA-Z0-9]+)$/);if(d){let r=d[1];if(e.ignoreCase){if(!t.toLowerCase().endsWith(r.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!t.endsWith(r))return{matches:!1,pruned:!1,printed:!1};return{matches:!0,pruned:!1,printed:!1}}return{matches:Z(t,l,e.ignoreCase),pruned:!1,printed:!1}}case"path":{let l=e.pattern,d=l.split("/");for(let i=0;i<d.length-1;i++){let o=d[i];if(o&&o!=="."&&o!==".."&&!o.includes("*")&&!o.includes("?")&&!o.includes("[")){let u=`/${o}/`;if(e.ignoreCase){if(!n.toLowerCase().includes(u.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!n.includes(u))return{matches:!1,pruned:!1,printed:!1}}}let r=l.match(/\*(\.[a-zA-Z0-9]+)$/);if(r){let i=r[1];if(e.ignoreCase){if(!n.toLowerCase().endsWith(i.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!n.endsWith(i))return{matches:!1,pruned:!1,printed:!1}}return{matches:Z(n,l,e.ignoreCase),pruned:!1,printed:!1}}case"regex":try{let l=e.ignoreCase?"i":"";return{matches:le(e.pattern,l).test(n),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:s,pruned:!1,printed:!1}:e.fileType==="d"?{matches:a,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"prune":return{matches:!0,pruned:!0,printed:!1};case"action":return{matches:!0,pruned:!1,printed:!1,actions:[e.action]};case"not":{let l=B(e.expr,t,n,s,a);return{matches:!l.matches,pruned:l.pruned,printed:!1,actions:l.actions}}case"and":{let l=B(e.left,t,n,s,a);if(!l.matches)return{matches:!1,pruned:l.pruned,printed:!1,actions:l.actions};let d=B(e.right,t,n,s,a);return{matches:d.matches,pruned:l.pruned||d.pruned,printed:l.printed||d.printed,actions:[...l.actions??[],...d.actions??[]]}}case"or":{let l=B(e.left,t,n,s,a);if(l.matches)return l;let d=B(e.right,t,n,s,a);return{matches:d.matches,pruned:l.pruned||d.pruned,printed:d.printed,actions:[...l.actions??[],...d.actions??[]]}}default:return{matches:!1,pruned:!1,printed:!1}}}function U(e){if(!e)return!1;switch(e.type){case"prune":return!0;case"not":return U(e.expr);case"and":case"or":return U(e.left)||U(e.right);default:return!1}}function L(e){switch(e.type){case"name":case"path":case"regex":case"type":case"prune":return!0;case"action":return!1;case"empty":case"mtime":case"newer":case"size":case"perm":return!1;case"not":return L(e.expr);case"and":case"or":return L(e.left)&&L(e.right)}}function Ce(e,t){if(!e||!t.isDirectory)return{shouldPrune:!1};if(!L(e))return ce(e,t);let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return{shouldPrune:R(e,n).pruned}}function ce(e,t){switch(e.type){case"or":{if(L(e.left)){let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};if(R(e.left,n).pruned)return{shouldPrune:!0}}return ce(e.right,t)}case"and":{if(L(e.left)&&L(e.right)){let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return{shouldPrune:R(e,n).pruned}}if(L(e.left)){let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return R(e.left,n).matches?ce(e.right,t):{shouldPrune:!1}}return{shouldPrune:!1}}case"not":return{shouldPrune:!1};default:return{shouldPrune:!1}}}function Ee(e,t){let n=[],s=t,a=r=>({expr:null,pathIndex:s,error:`find: missing argument to \`${r}'
4
- `}),l=(r,i)=>({expr:null,pathIndex:s,error:`find: invalid argument \`${i}' to \`${r}'
5
- `});for(;s<e.length;){let r=e[s];if(r==="("||r==="\\("){n.push({type:"lparen"}),s++;continue}if(r===")"||r==="\\)"){n.push({type:"rparen"}),s++;continue}if(r==="-name"){if(s+1>=e.length)return a(r);n.push({type:"expr",expr:{type:"name",pattern:e[++s]}})}else if(r==="-iname"){if(s+1>=e.length)return a(r);n.push({type:"expr",expr:{type:"name",pattern:e[++s],ignoreCase:!0}})}else if(r==="-path"){if(s+1>=e.length)return a(r);n.push({type:"expr",expr:{type:"path",pattern:e[++s]}})}else if(r==="-ipath"){if(s+1>=e.length)return a(r);n.push({type:"expr",expr:{type:"path",pattern:e[++s],ignoreCase:!0}})}else if(r==="-regex"){if(s+1>=e.length)return a(r);n.push({type:"expr",expr:{type:"regex",pattern:e[++s]}})}else if(r==="-iregex"){if(s+1>=e.length)return a(r);n.push({type:"expr",expr:{type:"regex",pattern:e[++s],ignoreCase:!0}})}else if(r==="-type"){if(s+1>=e.length)return a(r);let i=e[++s];if(i==="f"||i==="d")n.push({type:"expr",expr:{type:"type",fileType:i}});else return{expr:null,pathIndex:s,error:`find: Unknown argument to -type: ${i}
6
- `}}else if(r==="-empty")n.push({type:"expr",expr:{type:"empty"}});else if(r==="-mtime"){if(s+1>=e.length)return a(r);let i=e[++s],o="exact",u=i;if(i.startsWith("+")?(o="more",u=i.slice(1)):i.startsWith("-")&&(o="less",u=i.slice(1)),!/^\d+$/.test(u))return l(r,i);let N=Number(u);if(!Number.isSafeInteger(N))return l(r,i);n.push({type:"expr",expr:{type:"mtime",days:N,comparison:o}})}else if(r==="-newer"){if(s+1>=e.length)return a(r);let i=e[++s];n.push({type:"expr",expr:{type:"newer",refPath:i}})}else if(r==="-size"){if(s+1>=e.length)return a(r);let i=e[++s],o="exact",u=i;i.startsWith("+")?(o="more",u=i.slice(1)):i.startsWith("-")&&(o="less",u=i.slice(1));let N=u.match(/^(\d+)([ckMGb])?$/);if(!N)return l(r,i);let F=Number(N[1]);if(!Number.isSafeInteger(F))return l(r,i);let M=N[2]||"b",V=M==="G"?1024**3:M==="M"?1024**2:M==="k"?1024:M==="b"?512:1;if(!Number.isSafeInteger(F*V))return l(r,i);n.push({type:"expr",expr:{type:"size",value:F,unit:M,comparison:o}})}else if(r==="-perm"){if(s+1>=e.length)return a(r);let i=e[++s],o="exact",u=i;if(i.startsWith("-")?(o="all",u=i.slice(1)):i.startsWith("/")&&(o="any",u=i.slice(1)),!/^[0-7]{1,4}$/.test(u))return l(r,i);let N=Number.parseInt(u,8);n.push({type:"expr",expr:{type:"perm",mode:N,matchType:o}})}else if(r==="-prune")n.push({type:"expr",expr:{type:"prune"}});else if(r==="-not"||r==="!")n.push({type:"not"});else if(r==="-o"||r==="-or")n.push({type:"op",op:"or"});else if(r==="-a"||r==="-and")n.push({type:"op",op:"and"});else if(r==="-maxdepth"||r==="-mindepth"){if(s+1>=e.length)return a(r);s++}else if(r!=="-depth")if(r==="-exec"){let i=[];for(s++;s<e.length&&e[s]!==";"&&e[s]!=="+";)i.push(e[s]),s++;if(s>=e.length)return{expr:null,pathIndex:s,error:"find: missing argument to `-exec'\n"};if(i.length===0)return a("-exec");let o=e[s]==="+";if(o&&(i.at(-1)!=="{}"||i.filter(u=>u==="{}").length!==1))return l("-exec","+");n.push({type:"expr",expr:{type:"action",action:{type:"exec",command:i,batchMode:o}}})}else if(r==="-print")n.push({type:"expr",expr:{type:"action",action:{type:"print"}}});else if(r==="-print0")n.push({type:"expr",expr:{type:"action",action:{type:"print0"}}});else if(r==="-printf"){if(s+1>=e.length)return a(r);let i=e[++s];n.push({type:"expr",expr:{type:"action",action:{type:"printf",format:i}}})}else if(r==="-delete")n.push({type:"expr",expr:{type:"action",action:{type:"delete"}}});else return r.startsWith("-")?{expr:null,pathIndex:s,error:`find: unknown predicate '${r}'
7
- `}:{expr:null,pathIndex:s,error:`find: paths must precede expression: \`${r}'
8
- `};s++}if(n.length===0)return{expr:null,pathIndex:s};let d=Ne(n);return d.error?{expr:null,pathIndex:s,error:d.error}:{expr:d.expr,pathIndex:s}}function Ne(e){let t=0,n;function s(){let i=a();if(!i)return null;for(;t<e.length;){let o=e[t];if(o.type==="op"&&o.op==="or"){t++;let u=a();if(!u)return n="find: expected an expression after `-o'\n",null;i={type:"or",left:i,right:u}}else break}return i}function a(){let i=l();if(!i)return null;for(;t<e.length;){let o=e[t];if(o.type==="op"&&o.op==="and"){t++;let u=l();if(!u)return n="find: expected an expression after `-a'\n",null;i={type:"and",left:i,right:u}}else if(o.type==="expr"||o.type==="not"||o.type==="lparen"){let u=l();if(!u)return i;i={type:"and",left:i,right:u}}else break}return i}function l(){if(t<e.length&&e[t].type==="not"){t++;let i=l();return i?{type:"not",expr:i}:(n="find: expected an expression after `!'\n",null)}return d()}function d(){if(t>=e.length)return null;let i=e[t];if(i.type==="lparen"){t++;let o=s();return!o||t>=e.length||e[t].type!=="rparen"?(n="find: missing closing `)'\n",null):(t++,o)}return i.type==="expr"?(t++,i.expr):(i.type==="rparen",null)}let r=s();return!n&&t<e.length&&(n=e[t].type==="rparen"?"find: unexpected `)'\n":`find: invalid expression
9
- `),!n&&r&&ee(r)&&(n="find: refusing to evaluate `-delete' under negation\n"),{expr:n?null:r,error:n}}function ee(e,t=!1){return e.type==="action"?t&&e.action.type==="delete":e.type==="not"?ee(e.expr,!t):e.type==="and"||e.type==="or"?ee(e.left,t)||ee(e.right,t):!1}var ve=500;function Re(){return{readdirCalls:0,readdirTime:0,statCalls:0,statTime:0,evalCalls:0,evalTime:0,nodeCount:0,batchCount:0,batchTime:0,earlyPrunes:0}}function Fe(e,t,n){e({category:"find",name:"summary",durationMs:n,details:{readdirCalls:t.readdirCalls,readdirTimeMs:t.readdirTime,statCalls:t.statCalls,statTimeMs:t.statTime,evalCalls:t.evalCalls,evalTimeMs:t.evalTime,nodeCount:t.nodeCount,batchCount:t.batchCount,batchTimeMs:t.batchTime,earlyPrunes:t.earlyPrunes,otherTimeMs:n-t.readdirTime-t.statTime-t.evalTime-t.batchTime}})}var ze={name:"find",summary:"search for files in a directory hierarchy",usage:"find [path...] [expression]",options:["-name PATTERN file name matches shell pattern PATTERN","-iname PATTERN like -name but case insensitive","-path PATTERN file path matches shell pattern PATTERN","-ipath PATTERN like -path but case insensitive","-regex PATTERN file path matches regular expression PATTERN","-iregex PATTERN like -regex but case insensitive","-type TYPE file is of type: f (regular file), d (directory)","-empty file is empty or directory is empty","-mtime N file's data was modified N*24 hours ago","-newer FILE file was modified more recently than FILE","-size N[ckMGb] file uses N units of space (c=bytes, k=KB, M=MB, G=GB, b=512B blocks)","-perm MODE file's permission bits are exactly MODE (octal)","-perm -MODE all permission bits MODE are set","-perm /MODE any permission bits MODE are set","-maxdepth LEVELS descend at most LEVELS directories","-mindepth LEVELS do not apply tests at levels less than LEVELS","-depth process directory contents before directory itself","-prune do not descend into this directory","-not, ! negate the following expression","-a, -and logical AND (default)","-o, -or logical OR","-exec CMD {} ; execute CMD on each file ({} is replaced by filename)","-exec CMD {} + execute CMD with multiple files at once","-print print the full file name (default action)","-print0 print the full file name followed by a null character","-printf FORMAT print FORMAT with directives: %f %h %p %P %s %d %m %M %t","-delete delete found files/directories"," --help display this help and exit"]},nt={name:"find",async execute(e,t){if(ge(e))return ye(ze);let n=[],s=null,a=null,l=!1,d=e.length;for(let c=0;c<e.length;c++){let f=e[c];if(f.startsWith("-")||f==="("||f==="\\("||f===")"||f==="\\)"||f==="!"){d=c;break}n.push(f)}n.length===0&&n.push(".");for(let c=d;c<e.length;c++){let f=e[c];if(f==="-exec")for(c++;c<e.length&&e[c]!==";"&&e[c]!=="+";)c++;else if(f==="-maxdepth"||f==="-mindepth"){let p=e[c+1];if(p===void 0||!/^\d+$/.test(p))return{stdout:"",stderr:p===void 0?`find: missing argument to \`${f}'
10
- `:`find: invalid argument \`${p}' to \`${f}'
11
- `,exitCode:1};let v=Number(p);if(!Number.isSafeInteger(v))return{stdout:"",stderr:`find: invalid argument \`${p}' to \`${f}'
12
- `,exitCode:1};f==="-maxdepth"?s=v:a=v,c++}else f==="-depth"&&(l=!0)}let{expr:r,error:i}=Ee(e,d);if(i)return{stdout:"",stderr:i,exitCode:1};let o=te(r),u=o.length>0;o.some(c=>c.type==="delete")&&(l=!0);let N=[],F=0,M=t.executionScope?new Te(t.executionScope,"find"):void 0,V=[],fe=[],Q=0,O=new we({limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:"find"}),G=c=>{if(M)M.append("stdout",c);else{let f=ie(c);if(f>t.limits.maxOutputSize-Q)throw new ae(`find: output size limit exceeded (${t.limits.maxOutputSize} bytes)`,"output_size");c&&V.push(c),Q+=f}},q=c=>{if(M)M.append("stderr",c);else{let f=ie(c);if(f>t.limits.maxOutputSize-Q)throw new ae(`find: output size limit exceeded (${t.limits.maxOutputSize} bytes)`,"output_size");c&&fe.push(c),Q+=f}},De=Se(r),ne=new Map;for(let c of De){let f=t.fs.resolvePath(t.cwd,c);try{let p=await t.fs.stat(f);ne.set(c,p.mtime?.getTime()??Date.now())}catch{}}let Me=o.some(c=>{if(c.type!=="printf")return!1;let f=c.format.replace(/%%/g,"");return/%[-+]?[0-9]*\.?[0-9]*(s|m|M|t|T)/.test(f)}),Pe=_(r)||Me,xe=j(r),ue=U(r),$e=J(r),Ie=typeof t.fs.readdirWithFileTypes=="function";for(let c of n){let z=function(h){let y={path:h.relativePath,name:h.name,size:h.stat?.size??0,mtime:h.stat?.mtime?.getTime()??Date.now(),mode:h.stat?.mode??420,isDirectory:h.isDirectory,depth:h.depth,startingPoint:c},C=h.unreadable===void 0?[]:[{action:{type:"diagnostic",message:`find: ${h.relativePath}: ${h.unreadable}
13
- `},path:h.relativePath,printfData:y}],I=w=>l?[...C,...w]:[...w,...C];if(!(a===null||h.depth>=a))return C;let g=!0,m=[];if(r!==null){let w=Date.now(),T;if($e)T=B(r,h.name,h.relativePath,h.isFile,h.isDirectory);else{let S={name:h.name,relativePath:h.relativePath,isFile:h.isFile,isDirectory:h.isDirectory,isEmpty:h.isEmpty,mtime:h.stat?.mtime?.getTime()??Date.now(),size:h.stat?.size??0,mode:h.stat?.mode??420,newerRefTimes:ne};T=R(r,S)}g=T.matches,m=T.actions??[],p.evalCalls++,p.evalTime+=Date.now()-w}if(!u&&g&&(m=[{type:"print"}]),m.length===0)return C;O.checkpoint(m.length);let b=[];for(let w of m)b.push({action:w,path:h.relativePath,printfData:y});return I(b)};var He=z;c.length>1&&c.endsWith("/")&&(c=c.slice(0,-1));let f=t.fs.resolvePath(t.cwd,c);try{await t.fs.stat(f)}catch{q(`find: ${c}: No such file or directory
14
- `),F=1;continue}let p=Re(),v=Date.now();async function P(h){let{path:y,depth:C,typeInfo:I}=h;if(O.visit(C),p.nodeCount++,C>(s??t.limits.maxTraversalDepth))return null;let x,g,m;if(I&&!Pe)x=I.isFile,g=I.isDirectory;else{try{let W=Date.now();m=await t.fs.lstat(y),p.statCalls++,p.statTime+=Date.now()-W}catch{return null}if(!m)return null;x=m.isFile,g=m.isDirectory}let b;y===f?b=c.split("/").pop()||c:b=y.split("/").pop()||"";let w=y===f?c:c==="."?`./${y.slice(f==="/"?f.length:f.length+1)}`:c+y.slice(f.length),T=[],S=null,E=null,$=!1;g&&ue&&!l&&($=Ce(r,{name:b,relativePath:w,isFile:x,isDirectory:g}).shouldPrune,$&&p.earlyPrunes++);let H=!(C>=(s??t.limits.maxTraversalDepth))&&!$,K=(H||xe)&&!$,X;if(g&&K){let W=Date.now();try{Ie&&t.fs.readdirWithFileTypes?S=await t.fs.readdirWithFileTypes(y):E=await t.fs.readdir(y)}catch(D){let A=Le(D);if(A===null)throw D;X=A,p.readdirCalls++,p.readdirTime+=Date.now()-W}if(S!==null){O.checkpoint(),O.discover(S.length),E=[];for(let D of S)E.push(D.name);if(p.readdirCalls++,p.readdirTime+=Date.now()-W,H)for(let D=0;D<S.length;D++){let A=S[D];T.push({path:y==="/"?`/${A.name}`:`${y}/${A.name}`,depth:C+1,typeInfo:{isFile:A.isFile,isDirectory:A.isDirectory},resultIndex:D})}}else if(E!==null&&(O.checkpoint(),O.discover(E.length),p.readdirCalls++,p.readdirTime+=Date.now()-W,H))for(let D=0;D<E.length;D++){let A=E[D];T.push({path:y==="/"?`/${A}`:`${y}/${A}`,depth:C+1,resultIndex:D})}}let Y=x?(m?.size??0)===0:E!==null&&E.length===0,re=$;if(!l&&r!==null&&!$&&ue){let W=Date.now(),D={name:b,relativePath:w,isFile:x,isDirectory:g,isEmpty:Y,mtime:m?.mtime?.getTime()??Date.now(),size:m?.size??0,mode:m?.mode??420,newerRefTimes:ne};re=R(r,D).pruned,p.evalCalls++,p.evalTime+=Date.now()-W}return{relativePath:w,name:b,isFile:x,isDirectory:g,isEmpty:Y,stat:m,depth:C,children:re?[]:T,pruned:re,unreadable:X}}async function ke(){let h={effects:[]};if(l){let y=[],C=[{item:{path:f,depth:0,resultIndex:0},parentIndex:-1,childOrderInParent:0}],I=new Map,x=0;for(;x<C.length;){let g=Date.now(),m=Math.min(C.length,x+ve),b=C.slice(x,m);x=m;let w=await Promise.all(b.map(T=>P(T.item)));p.batchCount++,p.batchTime+=Date.now()-g;for(let T=0;T<b.length;T++){let S=w[T],E=b[T];if(!S)continue;let $=y.length;if(E.parentIndex>=0){let k=I.get(E.parentIndex)||[];k.push($),I.set(E.parentIndex,k)}y.push({node:S,parentIndex:E.parentIndex,childIndices:[]});for(let k=0;k<S.children.length;k++)C.push({item:S.children[k],parentIndex:$,childOrderInParent:k})}}for(let[g,m]of I)g>=0&&g<y.length&&(y[g].childIndices=m);if(y.length>0){let g=[{index:0,visited:!1}];for(;g.length>0;){O.checkpoint();let m=g.pop();if(!m)break;let b=y[m.index];if(b){if(m.visited){for(let w of z(b.node))h.effects.push(w);continue}g.push({index:m.index,visited:!0});for(let w=b.childIndices.length-1;w>=0;w--)g.push({index:b.childIndices[w],visited:!1})}}}}else{let y=new Map,C=0,I=[{item:{path:f,depth:0,resultIndex:0},orderIndex:C++}],x=new Map,g=0;for(;g<I.length;){let b=Date.now(),w=Math.min(I.length,g+ve),T=I.slice(g,w);g=w;let S=await Promise.all(T.map(async({item:E,orderIndex:$})=>{let k=await P(E);return k?{node:k,orderIndex:$}:null}));p.batchCount++,p.batchTime+=Date.now()-b;for(let E of S){if(!E)continue;let{node:$,orderIndex:k}=E,H=z($);if(H.length>0&&y.set(k,H),$.children.length>0){let K=[];for(let X of $.children){let Y=C++;K.push(Y),I.push({item:X,orderIndex:Y})}x.set(k,K)}}}let m=[0];for(;m.length>0;){O.checkpoint();let b=m.pop();if(b===void 0)break;let w=y.get(b);if(w)for(let S of w)h.effects.push(S);let T=x.get(b);if(T)for(let S=T.length-1;S>=0;S--)m.push(T[S])}}return h}let pe=await ke();for(let h of pe.effects)N.push(h);if(t.trace){let h=Date.now()-v;Fe(t.trace,p,h),t.trace({category:"find",name:"searchPath",durationMs:h,details:{path:c,resultsFound:pe.effects.filter(y=>y.action.type!=="diagnostic").length}})}}let se=new Map;for(let c of N){let{action:f,path:p}=c;switch(f.type){case"diagnostic":q(f.message),F=1;break;case"print":G(`${p}
15
- `);break;case"print0":G(`${p}\0`);break;case"printf":G(Ae(f.format,c.printfData));break;case"delete":{let v=t.fs.resolvePath(t.cwd,p);try{await t.fs.rm(v,{recursive:!1})}catch(P){let z=P instanceof Error?P.message:String(P);q(`find: cannot delete '${p}': ${z}
16
- `),F=1}break}case"exec":{if(!t.exec)return{stdout:"",stderr:`find: -exec not supported in this context
17
- `,exitCode:1};if(f.batchMode){let z=se.get(f)??[];z.push(p),se.set(f,z);break}let v=f.command.map(z=>z==="{}"?p:z),P=await t.exec(oe([v[0]]),{cwd:t.cwd,signal:t.signal,args:v.slice(1)});M?M.appendResult(P):(G(P.stdout),q(P.stderr)),P.exitCode!==0&&(F=P.exitCode);break}}}for(let[c,f]of se){if(c.type!=="exec"||!t.exec||f.length===0)continue;let p=[];for(let P of c.command)P==="{}"?p.push(...f):p.push(P);let v=await t.exec(oe([p[0]]),{cwd:t.cwd,signal:t.signal,args:p.slice(1)});M?M.appendResult(v):(G(v.stdout),q(v.stderr)),v.exitCode!==0&&(F=v.exitCode)}return M?.build(F)??{stdout:V.join(""),stderr:fe.join(""),exitCode:F}}};function te(e){return e?e.type==="action"?[e.action]:e.type==="not"?te(e.expr):e.type==="and"||e.type==="or"?[...te(e.left),...te(e.right)]:[]:[]}function Ae(e,t){let n=me(e),s="",a=0;for(;a<n.length;)if(n[a]==="%"&&a+1<n.length){if(a++,n[a]==="%"){s+="%",a++;continue}let[l,d,r]=he(n,a);if(a+=r,a>=n.length){s+="%";break}let i=n[a],o;switch(i){case"f":o=t.name,a++;break;case"h":{let u=t.path.lastIndexOf("/");o=u>0?t.path.slice(0,u):".",a++;break}case"p":o=t.path,a++;break;case"P":{let u=t.startingPoint;t.path===u?o="":t.path.startsWith(`${u}/`)?o=t.path.slice(u.length+1):u==="."&&t.path.startsWith("./")?o=t.path.slice(2):o=t.path,a++;break}case"s":o=String(t.size),a++;break;case"d":o=String(t.depth),a++;break;case"m":o=(t.mode&511).toString(8),a++;break;case"M":o=be(t.mode,t.isDirectory),a++;break;case"t":{let u=new Date(t.mtime);o=Oe(u),a++;break}case"T":{if(a+1<n.length){let u=n[a+1],N=new Date(t.mtime);o=Be(N,u),a+=2}else o="%T",a++;break}default:s+=`%${l!==0||d!==-1?`${l}.${d}`:""}${i}`,a++;continue}s+=de(o,l,d)}else s+=n[a],a++;return s}function Oe(e){let t=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],s=t[e.getDay()],a=n[e.getMonth()],l=String(e.getDate()).padStart(2," "),d=String(e.getHours()).padStart(2,"0"),r=String(e.getMinutes()).padStart(2,"0"),i=String(e.getSeconds()).padStart(2,"0"),o=e.getFullYear();return`${s} ${a} ${l} ${d}:${r}:${i} ${o}`}var We=new Map([["EACCES","Permission denied"],["EIO","Input/output error"],["ELOOP","Too many levels of symbolic links"],["ENAMETOOLONG","File name too long"],["ENOENT","No such file or directory"],["ENOTDIR","Not a directory"],["EPERM","Permission denied"]]);function Le(e){let t=typeof e=="object"&&e!==null&&"code"in e&&typeof e.code=="string"?e.code:e instanceof Error?/^(E[A-Z]+)\b/.exec(e.message)?.[1]:void 0;return t===void 0?null:We.get(t)??null}function Be(e,t){switch(t){case"@":return String(e.getTime()/1e3);case"Y":return String(e.getFullYear());case"m":return String(e.getMonth()+1).padStart(2,"0");case"d":return String(e.getDate()).padStart(2,"0");case"H":return String(e.getHours()).padStart(2,"0");case"M":return String(e.getMinutes()).padStart(2,"0");case"S":return String(e.getSeconds()).padStart(2,"0");case"T":return`${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}:${String(e.getSeconds()).padStart(2,"0")}`;case"F":return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`;default:return`%T${t}`}}var st={name:"find",flags:[{flag:"-name",type:"value",valueHint:"pattern"},{flag:"-iname",type:"value",valueHint:"pattern"},{flag:"-type",type:"value",valueHint:"string"},{flag:"-maxdepth",type:"value",valueHint:"number"},{flag:"-mindepth",type:"value",valueHint:"number"},{flag:"-empty",type:"boolean"},{flag:"-print",type:"boolean"},{flag:"-print0",type:"boolean"}],needsFiles:!0};export{nt as a,st as b};
@@ -1,16 +0,0 @@
1
- import{createRequire} from"node:module";const require=createRequire(import.meta.url);
2
- import{a as be}from"./chunk-TDD4NFYE.js";import{a as Z}from"./chunk-6P2DITXT.js";import{a as Te}from"./chunk-SGX4WOAM.js";import{a as oe}from"./chunk-L2UW7DWF.js";import{a as le}from"./chunk-O5BHWBYH.js";import{b as de,c as he,d as me}from"./chunk-57LGFT4S.js";import{d as we}from"./chunk-CM4T4GB4.js";import{l as ae}from"./chunk-TVCZIH6M.js";import{a as ie}from"./chunk-GN6CQ3J4.js";import{a as ye,b as ge}from"./chunk-QAYAQNCG.js";function R(e,t){switch(e.type){case"name":{let n=e.pattern,s=n.match(/^\*(\.[a-zA-Z0-9]+)$/);if(s){let a=s[1],l=t.name;if(e.ignoreCase){if(!l.toLowerCase().endsWith(a.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!l.endsWith(a))return{matches:!1,pruned:!1,printed:!1};return{matches:!0,pruned:!1,printed:!1}}return{matches:Z(t.name,n,e.ignoreCase),pruned:!1,printed:!1}}case"path":{let n=e.pattern,s=t.relativePath,a=n.split("/");for(let d=0;d<a.length-1;d++){let r=a[d];if(r&&r!=="."&&r!==".."&&!r.includes("*")&&!r.includes("?")&&!r.includes("[")){let i=`/${r}/`;if(e.ignoreCase){if(!s.toLowerCase().includes(i.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!s.includes(i))return{matches:!1,pruned:!1,printed:!1}}}let l=n.match(/\*(\.[a-zA-Z0-9]+)$/);if(l){let d=l[1];if(e.ignoreCase){if(!s.toLowerCase().endsWith(d.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!s.endsWith(d))return{matches:!1,pruned:!1,printed:!1}}return{matches:Z(s,n,e.ignoreCase),pruned:!1,printed:!1}}case"regex":try{let n=e.ignoreCase?"i":"";return{matches:le(e.pattern,n).test(t.relativePath),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:t.isFile,pruned:!1,printed:!1}:e.fileType==="d"?{matches:t.isDirectory,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"empty":return{matches:t.isEmpty,pruned:!1,printed:!1};case"mtime":{let s=(Date.now()-t.mtime)/(1e3*60*60*24),a;return e.comparison==="more"?a=s>e.days:e.comparison==="less"?a=s<e.days:a=Math.floor(s)===e.days,{matches:a,pruned:!1,printed:!1}}case"newer":{let n=t.newerRefTimes.get(e.refPath);return n===void 0?{matches:!1,pruned:!1,printed:!1}:{matches:t.mtime>n,pruned:!1,printed:!1}}case"size":{let n=e.value;switch(e.unit){case"c":n=e.value;break;case"k":n=e.value*1024;break;case"M":n=e.value*1024*1024;break;case"G":n=e.value*1024*1024*1024;break;case"b":n=e.value*512;break}let s;return e.comparison==="more"?s=t.size>n:e.comparison==="less"?s=t.size<n:e.unit==="b"?s=Math.ceil(t.size/512)===e.value:s=t.size===n,{matches:s,pruned:!1,printed:!1}}case"perm":{let n=t.mode&511,s=e.mode&511,a;return e.matchType==="exact"?a=n===s:e.matchType==="all"?a=(n&s)===s:a=(n&s)!==0,{matches:a,pruned:!1,printed:!1}}case"prune":return{matches:!0,pruned:!0,printed:!1};case"action":return{matches:!0,pruned:!1,printed:!1,actions:[e.action]};case"not":{let n=R(e.expr,t);return{matches:!n.matches,pruned:n.pruned,printed:!1,actions:n.actions}}case"and":{let n=R(e.left,t);if(!n.matches)return{matches:!1,pruned:n.pruned,printed:!1,actions:n.actions};let s=R(e.right,t);return{matches:s.matches,pruned:n.pruned||s.pruned,printed:n.printed||s.printed,actions:[...n.actions??[],...s.actions??[]]}}case"or":{let n=R(e.left,t);if(n.matches)return n;let s=R(e.right,t);return{matches:s.matches,pruned:n.pruned||s.pruned,printed:s.printed,actions:[...n.actions??[],...s.actions??[]]}}}}function _(e){if(!e)return!1;switch(e.type){case"name":case"path":case"regex":case"type":case"prune":return!1;case"action":return!1;case"empty":case"mtime":case"newer":case"size":case"perm":return!0;case"not":return _(e.expr);case"and":case"or":return _(e.left)||_(e.right)}}function j(e){if(!e)return!1;switch(e.type){case"empty":return!0;case"not":return j(e.expr);case"and":case"or":return j(e.left)||j(e.right);default:return!1}}function Se(e){let t=[],n=s=>{s&&(s.type==="newer"?t.push(s.refPath):s.type==="not"?n(s.expr):(s.type==="and"||s.type==="or")&&(n(s.left),n(s.right)))};return n(e),t}function J(e){if(!e)return!0;switch(e.type){case"name":case"path":case"regex":case"type":case"prune":return!0;case"action":return!1;case"empty":case"mtime":case"newer":case"size":case"perm":return!1;case"not":return J(e.expr);case"and":case"or":return J(e.left)&&J(e.right)}}function B(e,t,n,s,a){switch(e.type){case"name":{let l=e.pattern,d=l.match(/^\*(\.[a-zA-Z0-9]+)$/);if(d){let r=d[1];if(e.ignoreCase){if(!t.toLowerCase().endsWith(r.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!t.endsWith(r))return{matches:!1,pruned:!1,printed:!1};return{matches:!0,pruned:!1,printed:!1}}return{matches:Z(t,l,e.ignoreCase),pruned:!1,printed:!1}}case"path":{let l=e.pattern,d=l.split("/");for(let i=0;i<d.length-1;i++){let o=d[i];if(o&&o!=="."&&o!==".."&&!o.includes("*")&&!o.includes("?")&&!o.includes("[")){let u=`/${o}/`;if(e.ignoreCase){if(!n.toLowerCase().includes(u.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!n.includes(u))return{matches:!1,pruned:!1,printed:!1}}}let r=l.match(/\*(\.[a-zA-Z0-9]+)$/);if(r){let i=r[1];if(e.ignoreCase){if(!n.toLowerCase().endsWith(i.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!n.endsWith(i))return{matches:!1,pruned:!1,printed:!1}}return{matches:Z(n,l,e.ignoreCase),pruned:!1,printed:!1}}case"regex":try{let l=e.ignoreCase?"i":"";return{matches:le(e.pattern,l).test(n),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:s,pruned:!1,printed:!1}:e.fileType==="d"?{matches:a,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"prune":return{matches:!0,pruned:!0,printed:!1};case"action":return{matches:!0,pruned:!1,printed:!1,actions:[e.action]};case"not":{let l=B(e.expr,t,n,s,a);return{matches:!l.matches,pruned:l.pruned,printed:!1,actions:l.actions}}case"and":{let l=B(e.left,t,n,s,a);if(!l.matches)return{matches:!1,pruned:l.pruned,printed:!1,actions:l.actions};let d=B(e.right,t,n,s,a);return{matches:d.matches,pruned:l.pruned||d.pruned,printed:l.printed||d.printed,actions:[...l.actions??[],...d.actions??[]]}}case"or":{let l=B(e.left,t,n,s,a);if(l.matches)return l;let d=B(e.right,t,n,s,a);return{matches:d.matches,pruned:l.pruned||d.pruned,printed:d.printed,actions:[...l.actions??[],...d.actions??[]]}}default:return{matches:!1,pruned:!1,printed:!1}}}function U(e){if(!e)return!1;switch(e.type){case"prune":return!0;case"not":return U(e.expr);case"and":case"or":return U(e.left)||U(e.right);default:return!1}}function L(e){switch(e.type){case"name":case"path":case"regex":case"type":case"prune":return!0;case"action":return!1;case"empty":case"mtime":case"newer":case"size":case"perm":return!1;case"not":return L(e.expr);case"and":case"or":return L(e.left)&&L(e.right)}}function Ce(e,t){if(!e||!t.isDirectory)return{shouldPrune:!1};if(!L(e))return ce(e,t);let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return{shouldPrune:R(e,n).pruned}}function ce(e,t){switch(e.type){case"or":{if(L(e.left)){let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};if(R(e.left,n).pruned)return{shouldPrune:!0}}return ce(e.right,t)}case"and":{if(L(e.left)&&L(e.right)){let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return{shouldPrune:R(e,n).pruned}}if(L(e.left)){let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return R(e.left,n).matches?ce(e.right,t):{shouldPrune:!1}}return{shouldPrune:!1}}case"not":return{shouldPrune:!1};default:return{shouldPrune:!1}}}function Ee(e,t){let n=[],s=t,a=r=>({expr:null,pathIndex:s,error:`find: missing argument to \`${r}'
3
- `}),l=(r,i)=>({expr:null,pathIndex:s,error:`find: invalid argument \`${i}' to \`${r}'
4
- `});for(;s<e.length;){let r=e[s];if(r==="("||r==="\\("){n.push({type:"lparen"}),s++;continue}if(r===")"||r==="\\)"){n.push({type:"rparen"}),s++;continue}if(r==="-name"){if(s+1>=e.length)return a(r);n.push({type:"expr",expr:{type:"name",pattern:e[++s]}})}else if(r==="-iname"){if(s+1>=e.length)return a(r);n.push({type:"expr",expr:{type:"name",pattern:e[++s],ignoreCase:!0}})}else if(r==="-path"){if(s+1>=e.length)return a(r);n.push({type:"expr",expr:{type:"path",pattern:e[++s]}})}else if(r==="-ipath"){if(s+1>=e.length)return a(r);n.push({type:"expr",expr:{type:"path",pattern:e[++s],ignoreCase:!0}})}else if(r==="-regex"){if(s+1>=e.length)return a(r);n.push({type:"expr",expr:{type:"regex",pattern:e[++s]}})}else if(r==="-iregex"){if(s+1>=e.length)return a(r);n.push({type:"expr",expr:{type:"regex",pattern:e[++s],ignoreCase:!0}})}else if(r==="-type"){if(s+1>=e.length)return a(r);let i=e[++s];if(i==="f"||i==="d")n.push({type:"expr",expr:{type:"type",fileType:i}});else return{expr:null,pathIndex:s,error:`find: Unknown argument to -type: ${i}
5
- `}}else if(r==="-empty")n.push({type:"expr",expr:{type:"empty"}});else if(r==="-mtime"){if(s+1>=e.length)return a(r);let i=e[++s],o="exact",u=i;if(i.startsWith("+")?(o="more",u=i.slice(1)):i.startsWith("-")&&(o="less",u=i.slice(1)),!/^\d+$/.test(u))return l(r,i);let N=Number(u);if(!Number.isSafeInteger(N))return l(r,i);n.push({type:"expr",expr:{type:"mtime",days:N,comparison:o}})}else if(r==="-newer"){if(s+1>=e.length)return a(r);let i=e[++s];n.push({type:"expr",expr:{type:"newer",refPath:i}})}else if(r==="-size"){if(s+1>=e.length)return a(r);let i=e[++s],o="exact",u=i;i.startsWith("+")?(o="more",u=i.slice(1)):i.startsWith("-")&&(o="less",u=i.slice(1));let N=u.match(/^(\d+)([ckMGb])?$/);if(!N)return l(r,i);let F=Number(N[1]);if(!Number.isSafeInteger(F))return l(r,i);let M=N[2]||"b",V=M==="G"?1024**3:M==="M"?1024**2:M==="k"?1024:M==="b"?512:1;if(!Number.isSafeInteger(F*V))return l(r,i);n.push({type:"expr",expr:{type:"size",value:F,unit:M,comparison:o}})}else if(r==="-perm"){if(s+1>=e.length)return a(r);let i=e[++s],o="exact",u=i;if(i.startsWith("-")?(o="all",u=i.slice(1)):i.startsWith("/")&&(o="any",u=i.slice(1)),!/^[0-7]{1,4}$/.test(u))return l(r,i);let N=Number.parseInt(u,8);n.push({type:"expr",expr:{type:"perm",mode:N,matchType:o}})}else if(r==="-prune")n.push({type:"expr",expr:{type:"prune"}});else if(r==="-not"||r==="!")n.push({type:"not"});else if(r==="-o"||r==="-or")n.push({type:"op",op:"or"});else if(r==="-a"||r==="-and")n.push({type:"op",op:"and"});else if(r==="-maxdepth"||r==="-mindepth"){if(s+1>=e.length)return a(r);s++}else if(r!=="-depth")if(r==="-exec"){let i=[];for(s++;s<e.length&&e[s]!==";"&&e[s]!=="+";)i.push(e[s]),s++;if(s>=e.length)return{expr:null,pathIndex:s,error:"find: missing argument to `-exec'\n"};if(i.length===0)return a("-exec");let o=e[s]==="+";if(o&&(i.at(-1)!=="{}"||i.filter(u=>u==="{}").length!==1))return l("-exec","+");n.push({type:"expr",expr:{type:"action",action:{type:"exec",command:i,batchMode:o}}})}else if(r==="-print")n.push({type:"expr",expr:{type:"action",action:{type:"print"}}});else if(r==="-print0")n.push({type:"expr",expr:{type:"action",action:{type:"print0"}}});else if(r==="-printf"){if(s+1>=e.length)return a(r);let i=e[++s];n.push({type:"expr",expr:{type:"action",action:{type:"printf",format:i}}})}else if(r==="-delete")n.push({type:"expr",expr:{type:"action",action:{type:"delete"}}});else return r.startsWith("-")?{expr:null,pathIndex:s,error:`find: unknown predicate '${r}'
6
- `}:{expr:null,pathIndex:s,error:`find: paths must precede expression: \`${r}'
7
- `};s++}if(n.length===0)return{expr:null,pathIndex:s};let d=Ne(n);return d.error?{expr:null,pathIndex:s,error:d.error}:{expr:d.expr,pathIndex:s}}function Ne(e){let t=0,n;function s(){let i=a();if(!i)return null;for(;t<e.length;){let o=e[t];if(o.type==="op"&&o.op==="or"){t++;let u=a();if(!u)return n="find: expected an expression after `-o'\n",null;i={type:"or",left:i,right:u}}else break}return i}function a(){let i=l();if(!i)return null;for(;t<e.length;){let o=e[t];if(o.type==="op"&&o.op==="and"){t++;let u=l();if(!u)return n="find: expected an expression after `-a'\n",null;i={type:"and",left:i,right:u}}else if(o.type==="expr"||o.type==="not"||o.type==="lparen"){let u=l();if(!u)return i;i={type:"and",left:i,right:u}}else break}return i}function l(){if(t<e.length&&e[t].type==="not"){t++;let i=l();return i?{type:"not",expr:i}:(n="find: expected an expression after `!'\n",null)}return d()}function d(){if(t>=e.length)return null;let i=e[t];if(i.type==="lparen"){t++;let o=s();return!o||t>=e.length||e[t].type!=="rparen"?(n="find: missing closing `)'\n",null):(t++,o)}return i.type==="expr"?(t++,i.expr):(i.type==="rparen",null)}let r=s();return!n&&t<e.length&&(n=e[t].type==="rparen"?"find: unexpected `)'\n":`find: invalid expression
8
- `),!n&&r&&ee(r)&&(n="find: refusing to evaluate `-delete' under negation\n"),{expr:n?null:r,error:n}}function ee(e,t=!1){return e.type==="action"?t&&e.action.type==="delete":e.type==="not"?ee(e.expr,!t):e.type==="and"||e.type==="or"?ee(e.left,t)||ee(e.right,t):!1}var ve=500;function Re(){return{readdirCalls:0,readdirTime:0,statCalls:0,statTime:0,evalCalls:0,evalTime:0,nodeCount:0,batchCount:0,batchTime:0,earlyPrunes:0}}function Fe(e,t,n){e({category:"find",name:"summary",durationMs:n,details:{readdirCalls:t.readdirCalls,readdirTimeMs:t.readdirTime,statCalls:t.statCalls,statTimeMs:t.statTime,evalCalls:t.evalCalls,evalTimeMs:t.evalTime,nodeCount:t.nodeCount,batchCount:t.batchCount,batchTimeMs:t.batchTime,earlyPrunes:t.earlyPrunes,otherTimeMs:n-t.readdirTime-t.statTime-t.evalTime-t.batchTime}})}var ze={name:"find",summary:"search for files in a directory hierarchy",usage:"find [path...] [expression]",options:["-name PATTERN file name matches shell pattern PATTERN","-iname PATTERN like -name but case insensitive","-path PATTERN file path matches shell pattern PATTERN","-ipath PATTERN like -path but case insensitive","-regex PATTERN file path matches regular expression PATTERN","-iregex PATTERN like -regex but case insensitive","-type TYPE file is of type: f (regular file), d (directory)","-empty file is empty or directory is empty","-mtime N file's data was modified N*24 hours ago","-newer FILE file was modified more recently than FILE","-size N[ckMGb] file uses N units of space (c=bytes, k=KB, M=MB, G=GB, b=512B blocks)","-perm MODE file's permission bits are exactly MODE (octal)","-perm -MODE all permission bits MODE are set","-perm /MODE any permission bits MODE are set","-maxdepth LEVELS descend at most LEVELS directories","-mindepth LEVELS do not apply tests at levels less than LEVELS","-depth process directory contents before directory itself","-prune do not descend into this directory","-not, ! negate the following expression","-a, -and logical AND (default)","-o, -or logical OR","-exec CMD {} ; execute CMD on each file ({} is replaced by filename)","-exec CMD {} + execute CMD with multiple files at once","-print print the full file name (default action)","-print0 print the full file name followed by a null character","-printf FORMAT print FORMAT with directives: %f %h %p %P %s %d %m %M %t","-delete delete found files/directories"," --help display this help and exit"]},nt={name:"find",async execute(e,t){if(ge(e))return ye(ze);let n=[],s=null,a=null,l=!1,d=e.length;for(let c=0;c<e.length;c++){let f=e[c];if(f.startsWith("-")||f==="("||f==="\\("||f===")"||f==="\\)"||f==="!"){d=c;break}n.push(f)}n.length===0&&n.push(".");for(let c=d;c<e.length;c++){let f=e[c];if(f==="-exec")for(c++;c<e.length&&e[c]!==";"&&e[c]!=="+";)c++;else if(f==="-maxdepth"||f==="-mindepth"){let p=e[c+1];if(p===void 0||!/^\d+$/.test(p))return{stdout:"",stderr:p===void 0?`find: missing argument to \`${f}'
9
- `:`find: invalid argument \`${p}' to \`${f}'
10
- `,exitCode:1};let v=Number(p);if(!Number.isSafeInteger(v))return{stdout:"",stderr:`find: invalid argument \`${p}' to \`${f}'
11
- `,exitCode:1};f==="-maxdepth"?s=v:a=v,c++}else f==="-depth"&&(l=!0)}let{expr:r,error:i}=Ee(e,d);if(i)return{stdout:"",stderr:i,exitCode:1};let o=te(r),u=o.length>0;o.some(c=>c.type==="delete")&&(l=!0);let N=[],F=0,M=t.executionScope?new Te(t.executionScope,"find"):void 0,V=[],fe=[],Q=0,O=new we({limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:"find"}),G=c=>{if(M)M.append("stdout",c);else{let f=ie(c);if(f>t.limits.maxOutputSize-Q)throw new ae(`find: output size limit exceeded (${t.limits.maxOutputSize} bytes)`,"output_size");c&&V.push(c),Q+=f}},q=c=>{if(M)M.append("stderr",c);else{let f=ie(c);if(f>t.limits.maxOutputSize-Q)throw new ae(`find: output size limit exceeded (${t.limits.maxOutputSize} bytes)`,"output_size");c&&fe.push(c),Q+=f}},De=Se(r),ne=new Map;for(let c of De){let f=t.fs.resolvePath(t.cwd,c);try{let p=await t.fs.stat(f);ne.set(c,p.mtime?.getTime()??Date.now())}catch{}}let Me=o.some(c=>{if(c.type!=="printf")return!1;let f=c.format.replace(/%%/g,"");return/%[-+]?[0-9]*\.?[0-9]*(s|m|M|t|T)/.test(f)}),Pe=_(r)||Me,xe=j(r),ue=U(r),$e=J(r),Ie=typeof t.fs.readdirWithFileTypes=="function";for(let c of n){let z=function(h){let y={path:h.relativePath,name:h.name,size:h.stat?.size??0,mtime:h.stat?.mtime?.getTime()??Date.now(),mode:h.stat?.mode??420,isDirectory:h.isDirectory,depth:h.depth,startingPoint:c},C=h.unreadable===void 0?[]:[{action:{type:"diagnostic",message:`find: ${h.relativePath}: ${h.unreadable}
12
- `},path:h.relativePath,printfData:y}],I=w=>l?[...C,...w]:[...w,...C];if(!(a===null||h.depth>=a))return C;let g=!0,m=[];if(r!==null){let w=Date.now(),T;if($e)T=B(r,h.name,h.relativePath,h.isFile,h.isDirectory);else{let S={name:h.name,relativePath:h.relativePath,isFile:h.isFile,isDirectory:h.isDirectory,isEmpty:h.isEmpty,mtime:h.stat?.mtime?.getTime()??Date.now(),size:h.stat?.size??0,mode:h.stat?.mode??420,newerRefTimes:ne};T=R(r,S)}g=T.matches,m=T.actions??[],p.evalCalls++,p.evalTime+=Date.now()-w}if(!u&&g&&(m=[{type:"print"}]),m.length===0)return C;O.checkpoint(m.length);let b=[];for(let w of m)b.push({action:w,path:h.relativePath,printfData:y});return I(b)};var He=z;c.length>1&&c.endsWith("/")&&(c=c.slice(0,-1));let f=t.fs.resolvePath(t.cwd,c);try{await t.fs.stat(f)}catch{q(`find: ${c}: No such file or directory
13
- `),F=1;continue}let p=Re(),v=Date.now();async function P(h){let{path:y,depth:C,typeInfo:I}=h;if(O.visit(C),p.nodeCount++,C>(s??t.limits.maxTraversalDepth))return null;let x,g,m;if(I&&!Pe)x=I.isFile,g=I.isDirectory;else{try{let W=Date.now();m=await t.fs.lstat(y),p.statCalls++,p.statTime+=Date.now()-W}catch{return null}if(!m)return null;x=m.isFile,g=m.isDirectory}let b;y===f?b=c.split("/").pop()||c:b=y.split("/").pop()||"";let w=y===f?c:c==="."?`./${y.slice(f==="/"?f.length:f.length+1)}`:c+y.slice(f.length),T=[],S=null,E=null,$=!1;g&&ue&&!l&&($=Ce(r,{name:b,relativePath:w,isFile:x,isDirectory:g}).shouldPrune,$&&p.earlyPrunes++);let H=!(C>=(s??t.limits.maxTraversalDepth))&&!$,K=(H||xe)&&!$,X;if(g&&K){let W=Date.now();try{Ie&&t.fs.readdirWithFileTypes?S=await t.fs.readdirWithFileTypes(y):E=await t.fs.readdir(y)}catch(D){let A=Le(D);if(A===null)throw D;X=A,p.readdirCalls++,p.readdirTime+=Date.now()-W}if(S!==null){O.checkpoint(),O.discover(S.length),E=[];for(let D of S)E.push(D.name);if(p.readdirCalls++,p.readdirTime+=Date.now()-W,H)for(let D=0;D<S.length;D++){let A=S[D];T.push({path:y==="/"?`/${A.name}`:`${y}/${A.name}`,depth:C+1,typeInfo:{isFile:A.isFile,isDirectory:A.isDirectory},resultIndex:D})}}else if(E!==null&&(O.checkpoint(),O.discover(E.length),p.readdirCalls++,p.readdirTime+=Date.now()-W,H))for(let D=0;D<E.length;D++){let A=E[D];T.push({path:y==="/"?`/${A}`:`${y}/${A}`,depth:C+1,resultIndex:D})}}let Y=x?(m?.size??0)===0:E!==null&&E.length===0,re=$;if(!l&&r!==null&&!$&&ue){let W=Date.now(),D={name:b,relativePath:w,isFile:x,isDirectory:g,isEmpty:Y,mtime:m?.mtime?.getTime()??Date.now(),size:m?.size??0,mode:m?.mode??420,newerRefTimes:ne};re=R(r,D).pruned,p.evalCalls++,p.evalTime+=Date.now()-W}return{relativePath:w,name:b,isFile:x,isDirectory:g,isEmpty:Y,stat:m,depth:C,children:re?[]:T,pruned:re,unreadable:X}}async function ke(){let h={effects:[]};if(l){let y=[],C=[{item:{path:f,depth:0,resultIndex:0},parentIndex:-1,childOrderInParent:0}],I=new Map,x=0;for(;x<C.length;){let g=Date.now(),m=Math.min(C.length,x+ve),b=C.slice(x,m);x=m;let w=await Promise.all(b.map(T=>P(T.item)));p.batchCount++,p.batchTime+=Date.now()-g;for(let T=0;T<b.length;T++){let S=w[T],E=b[T];if(!S)continue;let $=y.length;if(E.parentIndex>=0){let k=I.get(E.parentIndex)||[];k.push($),I.set(E.parentIndex,k)}y.push({node:S,parentIndex:E.parentIndex,childIndices:[]});for(let k=0;k<S.children.length;k++)C.push({item:S.children[k],parentIndex:$,childOrderInParent:k})}}for(let[g,m]of I)g>=0&&g<y.length&&(y[g].childIndices=m);if(y.length>0){let g=[{index:0,visited:!1}];for(;g.length>0;){O.checkpoint();let m=g.pop();if(!m)break;let b=y[m.index];if(b){if(m.visited){for(let w of z(b.node))h.effects.push(w);continue}g.push({index:m.index,visited:!0});for(let w=b.childIndices.length-1;w>=0;w--)g.push({index:b.childIndices[w],visited:!1})}}}}else{let y=new Map,C=0,I=[{item:{path:f,depth:0,resultIndex:0},orderIndex:C++}],x=new Map,g=0;for(;g<I.length;){let b=Date.now(),w=Math.min(I.length,g+ve),T=I.slice(g,w);g=w;let S=await Promise.all(T.map(async({item:E,orderIndex:$})=>{let k=await P(E);return k?{node:k,orderIndex:$}:null}));p.batchCount++,p.batchTime+=Date.now()-b;for(let E of S){if(!E)continue;let{node:$,orderIndex:k}=E,H=z($);if(H.length>0&&y.set(k,H),$.children.length>0){let K=[];for(let X of $.children){let Y=C++;K.push(Y),I.push({item:X,orderIndex:Y})}x.set(k,K)}}}let m=[0];for(;m.length>0;){O.checkpoint();let b=m.pop();if(b===void 0)break;let w=y.get(b);if(w)for(let S of w)h.effects.push(S);let T=x.get(b);if(T)for(let S=T.length-1;S>=0;S--)m.push(T[S])}}return h}let pe=await ke();for(let h of pe.effects)N.push(h);if(t.trace){let h=Date.now()-v;Fe(t.trace,p,h),t.trace({category:"find",name:"searchPath",durationMs:h,details:{path:c,resultsFound:pe.effects.filter(y=>y.action.type!=="diagnostic").length}})}}let se=new Map;for(let c of N){let{action:f,path:p}=c;switch(f.type){case"diagnostic":q(f.message),F=1;break;case"print":G(`${p}
14
- `);break;case"print0":G(`${p}\0`);break;case"printf":G(Ae(f.format,c.printfData));break;case"delete":{let v=t.fs.resolvePath(t.cwd,p);try{await t.fs.rm(v,{recursive:!1})}catch(P){let z=P instanceof Error?P.message:String(P);q(`find: cannot delete '${p}': ${z}
15
- `),F=1}break}case"exec":{if(!t.exec)return{stdout:"",stderr:`find: -exec not supported in this context
16
- `,exitCode:1};if(f.batchMode){let z=se.get(f)??[];z.push(p),se.set(f,z);break}let v=f.command.map(z=>z==="{}"?p:z),P=await t.exec(oe([v[0]]),{cwd:t.cwd,signal:t.signal,args:v.slice(1)});M?M.appendResult(P):(G(P.stdout),q(P.stderr)),P.exitCode!==0&&(F=P.exitCode);break}}}for(let[c,f]of se){if(c.type!=="exec"||!t.exec||f.length===0)continue;let p=[];for(let P of c.command)P==="{}"?p.push(...f):p.push(P);let v=await t.exec(oe([p[0]]),{cwd:t.cwd,signal:t.signal,args:p.slice(1)});M?M.appendResult(v):(G(v.stdout),q(v.stderr)),v.exitCode!==0&&(F=v.exitCode)}return M?.build(F)??{stdout:V.join(""),stderr:fe.join(""),exitCode:F}}};function te(e){return e?e.type==="action"?[e.action]:e.type==="not"?te(e.expr):e.type==="and"||e.type==="or"?[...te(e.left),...te(e.right)]:[]:[]}function Ae(e,t){let n=me(e),s="",a=0;for(;a<n.length;)if(n[a]==="%"&&a+1<n.length){if(a++,n[a]==="%"){s+="%",a++;continue}let[l,d,r]=he(n,a);if(a+=r,a>=n.length){s+="%";break}let i=n[a],o;switch(i){case"f":o=t.name,a++;break;case"h":{let u=t.path.lastIndexOf("/");o=u>0?t.path.slice(0,u):".",a++;break}case"p":o=t.path,a++;break;case"P":{let u=t.startingPoint;t.path===u?o="":t.path.startsWith(`${u}/`)?o=t.path.slice(u.length+1):u==="."&&t.path.startsWith("./")?o=t.path.slice(2):o=t.path,a++;break}case"s":o=String(t.size),a++;break;case"d":o=String(t.depth),a++;break;case"m":o=(t.mode&511).toString(8),a++;break;case"M":o=be(t.mode,t.isDirectory),a++;break;case"t":{let u=new Date(t.mtime);o=Oe(u),a++;break}case"T":{if(a+1<n.length){let u=n[a+1],N=new Date(t.mtime);o=Be(N,u),a+=2}else o="%T",a++;break}default:s+=`%${l!==0||d!==-1?`${l}.${d}`:""}${i}`,a++;continue}s+=de(o,l,d)}else s+=n[a],a++;return s}function Oe(e){let t=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],s=t[e.getDay()],a=n[e.getMonth()],l=String(e.getDate()).padStart(2," "),d=String(e.getHours()).padStart(2,"0"),r=String(e.getMinutes()).padStart(2,"0"),i=String(e.getSeconds()).padStart(2,"0"),o=e.getFullYear();return`${s} ${a} ${l} ${d}:${r}:${i} ${o}`}var We=new Map([["EACCES","Permission denied"],["EIO","Input/output error"],["ELOOP","Too many levels of symbolic links"],["ENAMETOOLONG","File name too long"],["ENOENT","No such file or directory"],["ENOTDIR","Not a directory"],["EPERM","Permission denied"]]);function Le(e){let t=typeof e=="object"&&e!==null&&"code"in e&&typeof e.code=="string"?e.code:e instanceof Error?/^(E[A-Z]+)\b/.exec(e.message)?.[1]:void 0;return t===void 0?null:We.get(t)??null}function Be(e,t){switch(t){case"@":return String(e.getTime()/1e3);case"Y":return String(e.getFullYear());case"m":return String(e.getMonth()+1).padStart(2,"0");case"d":return String(e.getDate()).padStart(2,"0");case"H":return String(e.getHours()).padStart(2,"0");case"M":return String(e.getMinutes()).padStart(2,"0");case"S":return String(e.getSeconds()).padStart(2,"0");case"T":return`${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}:${String(e.getSeconds()).padStart(2,"0")}`;case"F":return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`;default:return`%T${t}`}}var st={name:"find",flags:[{flag:"-name",type:"value",valueHint:"pattern"},{flag:"-iname",type:"value",valueHint:"pattern"},{flag:"-type",type:"value",valueHint:"string"},{flag:"-maxdepth",type:"value",valueHint:"number"},{flag:"-mindepth",type:"value",valueHint:"number"},{flag:"-empty",type:"boolean"},{flag:"-print",type:"boolean"},{flag:"-print0",type:"boolean"}],needsFiles:!0};export{nt as a,st as b};