just-bash 1.4.1 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/chunks/{find-D3ZC5DXH.js → find-TRBVCSI6.js} +8 -8
- package/dist/bin/just-bash.js +1 -1
- package/dist/bin/shell/chunks/{find-D3ZC5DXH.js → find-TRBVCSI6.js} +8 -8
- package/dist/bin/shell/shell.js +1 -1
- package/dist/bundle/ai/index.js +2 -2
- package/dist/bundle/chunks/{find-R6LJIRBI.js → find-GM7FJ4D3.js} +8 -8
- package/dist/bundle/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as N}from"./chunk-26Q3PZQ6.js";import{a as L,b as B,c as H}from"./chunk-PM2DS2YW.js";import{a as I,b as O}from"./chunk-GTNBSMZR.js";import"./chunk-SJXDWN5X.js";function w(e,s){switch(e.type){case"name":return{matches:N(s.name,e.pattern,e.ignoreCase),pruned:!1,printed:!1};case"path":return{matches:N(s.relativePath,e.pattern,e.ignoreCase),pruned:!1,printed:!1};case"regex":try{let n=e.ignoreCase?"i":"";return{matches:new RegExp(e.pattern,n).test(s.relativePath),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:s.isFile,pruned:!1,printed:!1}:e.fileType==="d"?{matches:s.isDirectory,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"empty":return{matches:s.isEmpty,pruned:!1,printed:!1};case"mtime":{let
|
|
3
|
-
`,actions:[]}}else if(a==="-empty")n.push({type:"expr",expr:{type:"empty"}});else if(a==="-mtime"&&t+1<e.length){let
|
|
4
|
-
`,actions:[]};if(n.length===0){t++;continue}break}t++}if(n.length===0)return{expr:null,pathIndex:t,actions:
|
|
5
|
-
`,D=1;continue}async function g(u,d){if(
|
|
2
|
+
import{a as N}from"./chunk-26Q3PZQ6.js";import{a as L,b as B,c as H}from"./chunk-PM2DS2YW.js";import{a as I,b as O}from"./chunk-GTNBSMZR.js";import"./chunk-SJXDWN5X.js";function w(e,s){switch(e.type){case"name":return{matches:N(s.name,e.pattern,e.ignoreCase),pruned:!1,printed:!1};case"path":return{matches:N(s.relativePath,e.pattern,e.ignoreCase),pruned:!1,printed:!1};case"regex":try{let n=e.ignoreCase?"i":"";return{matches:new RegExp(e.pattern,n).test(s.relativePath),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:s.isFile,pruned:!1,printed:!1}:e.fileType==="d"?{matches:s.isDirectory,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"empty":return{matches:s.isEmpty,pruned:!1,printed:!1};case"mtime":{let i=(Date.now()-s.mtime)/(1e3*60*60*24),t;return e.comparison==="more"?t=i>e.days:e.comparison==="less"?t=i<e.days:t=Math.floor(i)===e.days,{matches:t,pruned:!1,printed:!1}}case"newer":{let n=s.newerRefTimes.get(e.refPath);return n===void 0?{matches:!1,pruned:!1,printed:!1}:{matches:s.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 i;return e.comparison==="more"?i=s.size>n:e.comparison==="less"?i=s.size<n:e.unit==="b"?i=Math.ceil(s.size/512)===e.value:i=s.size===n,{matches:i,pruned:!1,printed:!1}}case"perm":{let n=s.mode&511,i=e.mode&511,t;return e.matchType==="exact"?t=n===i:e.matchType==="all"?t=(n&i)===i:t=(n&i)!==0,{matches:t,pruned:!1,printed:!1}}case"prune":return{matches:!0,pruned:!0,printed:!1};case"print":return{matches:!0,pruned:!1,printed:!0};case"not":{let n=w(e.expr,s);return{matches:!n.matches,pruned:n.pruned,printed:!1}}case"and":{let n=w(e.left,s);if(!n.matches)return{matches:!1,pruned:n.pruned,printed:!1};let i=w(e.right,s);return{matches:i.matches,pruned:n.pruned||i.pruned,printed:n.printed||i.printed}}case"or":{let n=w(e.left,s);if(n.matches)return n;let i=w(e.right,s);return{matches:i.matches,pruned:n.pruned||i.pruned,printed:i.printed}}}}function G(e){let s=[],n=i=>{i&&(i.type==="newer"?s.push(i.refPath):i.type==="not"?n(i.expr):(i.type==="and"||i.type==="or")&&(n(i.left),n(i.right)))};return n(e),s}function j(e,s){let n=[],i=[],t=s;for(;t<e.length;){let a=e[t];if(a==="("||a==="\\("){n.push({type:"lparen"}),t++;continue}if(a===")"||a==="\\)"){n.push({type:"rparen"}),t++;continue}if(a==="-name"&&t+1<e.length)n.push({type:"expr",expr:{type:"name",pattern:e[++t]}});else if(a==="-iname"&&t+1<e.length)n.push({type:"expr",expr:{type:"name",pattern:e[++t],ignoreCase:!0}});else if(a==="-path"&&t+1<e.length)n.push({type:"expr",expr:{type:"path",pattern:e[++t]}});else if(a==="-ipath"&&t+1<e.length)n.push({type:"expr",expr:{type:"path",pattern:e[++t],ignoreCase:!0}});else if(a==="-regex"&&t+1<e.length)n.push({type:"expr",expr:{type:"regex",pattern:e[++t]}});else if(a==="-iregex"&&t+1<e.length)n.push({type:"expr",expr:{type:"regex",pattern:e[++t],ignoreCase:!0}});else if(a==="-type"&&t+1<e.length){let r=e[++t];if(r==="f"||r==="d")n.push({type:"expr",expr:{type:"type",fileType:r}});else return{expr:null,pathIndex:t,error:`find: Unknown argument to -type: ${r}
|
|
3
|
+
`,actions:[]}}else if(a==="-empty")n.push({type:"expr",expr:{type:"empty"}});else if(a==="-mtime"&&t+1<e.length){let r=e[++t],c="exact",o=r;r.startsWith("+")?(c="more",o=r.slice(1)):r.startsWith("-")&&(c="less",o=r.slice(1));let h=parseInt(o,10);Number.isNaN(h)||n.push({type:"expr",expr:{type:"mtime",days:h,comparison:c}})}else if(a==="-newer"&&t+1<e.length){let r=e[++t];n.push({type:"expr",expr:{type:"newer",refPath:r}})}else if(a==="-size"&&t+1<e.length){let r=e[++t],c="exact",o=r;r.startsWith("+")?(c="more",o=r.slice(1)):r.startsWith("-")&&(c="less",o=r.slice(1));let h=o.match(/^(\d+)([ckMGb])?$/);if(h){let b=parseInt(h[1],10),y=h[2]||"b";n.push({type:"expr",expr:{type:"size",value:b,unit:y,comparison:c}})}}else if(a==="-perm"&&t+1<e.length){let r=e[++t],c="exact",o=r;r.startsWith("-")?(c="all",o=r.slice(1)):r.startsWith("/")&&(c="any",o=r.slice(1));let h=parseInt(o,8);Number.isNaN(h)||n.push({type:"expr",expr:{type:"perm",mode:h,matchType:c}})}else if(a==="-prune")n.push({type:"expr",expr:{type:"prune"}});else if(a==="-not"||a==="!")n.push({type:"not"});else if(a==="-o"||a==="-or")n.push({type:"op",op:"or"});else if(a==="-a"||a==="-and")n.push({type:"op",op:"and"});else if(a==="-maxdepth"||a==="-mindepth")t++;else if(a!=="-depth")if(a==="-exec"){let r=[];for(t++;t<e.length&&e[t]!==";"&&e[t]!=="+";)r.push(e[t]),t++;if(t>=e.length)return{expr:null,pathIndex:t,error:"find: missing argument to `-exec'\n",actions:[]};let c=e[t]==="+";i.push({type:"exec",command:r,batchMode:c})}else if(a==="-print")n.push({type:"expr",expr:{type:"print"}}),i.push({type:"print"});else if(a==="-print0")i.push({type:"print0"});else if(a==="-printf"&&t+1<e.length){let r=e[++t];i.push({type:"printf",format:r})}else if(a==="-delete")i.push({type:"delete"});else{if(a.startsWith("-"))return{expr:null,pathIndex:t,error:`find: unknown predicate '${a}'
|
|
4
|
+
`,actions:[]};if(n.length===0){t++;continue}break}t++}if(n.length===0)return{expr:null,pathIndex:t,actions:i};let m=_(n);return m.error?{expr:null,pathIndex:t,error:m.error,actions:i}:{expr:m.expr,pathIndex:t,actions:i}}function _(e){let s=0;function n(){let r=i();if(!r)return null;for(;s<e.length;){let c=e[s];if(c.type==="op"&&c.op==="or"){s++;let o=i();if(!o)return r;r={type:"or",left:r,right:o}}else break}return r}function i(){let r=t();if(!r)return null;for(;s<e.length;){let c=e[s];if(c.type==="op"&&c.op==="and"){s++;let o=t();if(!o)return r;r={type:"and",left:r,right:o}}else if(c.type==="expr"||c.type==="not"||c.type==="lparen"){let o=t();if(!o)return r;r={type:"and",left:r,right:o}}else break}return r}function t(){if(s<e.length&&e[s].type==="not"){s++;let r=t();return r?{type:"not",expr:r}:null}return m()}function m(){if(s>=e.length)return null;let r=e[s];if(r.type==="lparen"){s++;let c=n();return s<e.length&&e[s].type==="rparen"&&s++,c}return r.type==="expr"?(s++,r.expr):(r.type==="rparen",null)}return{expr:n()}}var K={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"]},U=new Set(["-name","-iname","-path","-ipath","-regex","-iregex","-type","-maxdepth","-mindepth","-mtime","-newer","-size","-perm"]),oe={name:"find",async execute(e,s){if(O(e))return I(K);let n=[],i=null,t=null,m=!1,a=!1;for(let l=0;l<e.length;l++){let p=e[l];if(p==="-maxdepth"&&l+1<e.length)a=!0,i=parseInt(e[++l],10);else if(p==="-mindepth"&&l+1<e.length)a=!0,t=parseInt(e[++l],10);else if(p==="-depth")a=!0,m=!0;else if(p==="-exec")for(a=!0,l++;l<e.length&&e[l]!==";"&&e[l]!=="+";)l++;else!p.startsWith("-")&&p!==";"&&p!=="+"&&p!=="("&&p!==")"&&p!=="\\("&&p!=="\\)"&&p!=="!"?a||n.push(p):U.has(p)?(a=!0,l++):(p.startsWith("-")||p==="("||p==="\\("||p==="!")&&(a=!0)}n.length===0&&n.push(".");let{expr:r,error:c,actions:o}=j(e,0);if(c)return{stdout:"",stderr:c,exitCode:1};let h=o.some(l=>l.type==="print"),b=o.length===0,y=[],Y=o.some(l=>l.type==="printf"),F=[],T="",D=0,V=G(r),k=new Map;for(let l of V){let p=s.fs.resolvePath(s.cwd,l);try{let g=await s.fs.stat(p);k.set(l,g.mtime?.getTime()??Date.now())}catch{}}for(let l of n){l.length>1&&l.endsWith("/")&&(l=l.slice(0,-1));let p=s.fs.resolvePath(s.cwd,l);try{await s.fs.stat(p)}catch{T+=`find: ${l}: No such file or directory
|
|
5
|
+
`,D=1;continue}async function g(u,d){if(i!==null&&d>i)return;let f;try{f=await s.fs.stat(u)}catch{return}if(!f)return;let E;u===p?E=l.split("/").pop()||l:E=u.split("/").pop()||"";let $=u===p?l:l==="."?`./${u.slice(p==="/"?p.length:p.length+1)}`:l+u.slice(p.length),M=null;f.isDirectory&&(M=await s.fs.readdir(u));let R=f.isFile?f.size===0:M!==null&&M.length===0,C=()=>{let x=t===null||d>=t,v=!1;if(x&&r!==null){let J={name:E,relativePath:$,isFile:f.isFile,isDirectory:f.isDirectory,isEmpty:R,mtime:f.mtime?.getTime()??Date.now(),size:f.size??0,mode:f.mode??420,newerRefTimes:k},z=w(r,J);x=z.matches,h?v=z.printed:v=x}else x&&(v=!0);v&&(y.push($),Y&&F.push({path:$,name:E,size:f.size??0,mtime:f.mtime?.getTime()??Date.now(),mode:f.mode??420,isDirectory:f.isDirectory,depth:d,startingPoint:l}))},A=async()=>{if(M!==null)for(let P of M){let x=u==="/"?`/${P}`:`${u}/${P}`;await g(x,d+1)}},W=!1;if(!m&&r!==null){let P={name:E,relativePath:$,isFile:f.isFile,isDirectory:f.isDirectory,isEmpty:R,mtime:f.mtime?.getTime()??Date.now(),size:f.size??0,mode:f.mode??420,newerRefTimes:k};W=w(r,P).pruned}m?(await A(),C()):(C(),W||await A())}await g(p,0)}let S="";if(o.length>0)for(let l of o)switch(l.type){case"print":S+=y.length>0?`${y.join(`
|
|
6
6
|
`)}
|
|
7
|
-
`:"";break;case"print0":S+=y.length>0?`${y.join("\0")}\0`:"";break;case"delete":{let
|
|
8
|
-
`,D=1}}break}case"printf":for(let
|
|
9
|
-
`,exitCode:1};if(
|
|
7
|
+
`:"";break;case"print0":S+=y.length>0?`${y.join("\0")}\0`:"";break;case"delete":{let p=[...y].sort((g,u)=>u.length-g.length);for(let g of p){let u=s.fs.resolvePath(s.cwd,g);try{await s.fs.rm(u,{recursive:!1})}catch(d){let f=d instanceof Error?d.message:String(d);T+=`find: cannot delete '${g}': ${f}
|
|
8
|
+
`,D=1}}break}case"printf":for(let p of F)S+=q(l.format,p);break;case"exec":if(!s.exec)return{stdout:"",stderr:`find: -exec not supported in this context
|
|
9
|
+
`,exitCode:1};if(l.batchMode){let p=[];for(let d of l.command)d==="{}"?p.push(...y):p.push(d);let g=p.map(d=>`"${d}"`).join(" "),u=await s.exec(g,{cwd:s.cwd});S+=u.stdout,T+=u.stderr,u.exitCode!==0&&(D=u.exitCode)}else for(let p of y){let u=l.command.map(f=>f==="{}"?p:f).map(f=>`"${f}"`).join(" "),d=await s.exec(u,{cwd:s.cwd});S+=d.stdout,T+=d.stderr,d.exitCode!==0&&(D=d.exitCode)}break}else b&&(S=y.length>0?`${y.join(`
|
|
10
10
|
`)}
|
|
11
|
-
`:"");return{stdout:S,stderr:T,exitCode:D}}};function q(e,s){let n=H(e),
|
|
11
|
+
`:"");return{stdout:S,stderr:T,exitCode:D}}};function q(e,s){let n=H(e),i="",t=0;for(;t<n.length;)if(n[t]==="%"&&t+1<n.length){if(t++,n[t]==="%"){i+="%",t++;continue}let[m,a,r]=B(n,t);if(t+=r,t>=n.length){i+="%";break}let c=n[t],o;switch(c){case"f":o=s.name,t++;break;case"h":{let h=s.path.lastIndexOf("/");o=h>0?s.path.slice(0,h):".",t++;break}case"p":o=s.path,t++;break;case"P":{let h=s.startingPoint;s.path===h?o="":s.path.startsWith(`${h}/`)?o=s.path.slice(h.length+1):h==="."&&s.path.startsWith("./")?o=s.path.slice(2):o=s.path,t++;break}case"s":o=String(s.size),t++;break;case"d":o=String(s.depth),t++;break;case"m":o=(s.mode&511).toString(8),t++;break;case"M":o=Q(s.mode,s.isDirectory),t++;break;case"t":{let h=new Date(s.mtime);o=X(h),t++;break}case"T":{if(t+1<n.length){let h=n[t+1],b=new Date(s.mtime);o=Z(b,h),t+=2}else o="%T",t++;break}default:i+=`%${m!==0||a!==-1?`${m}.${a}`:""}${c}`,t++;continue}i+=L(o,m,a)}else i+=n[t],t++;return i}function Q(e,s){let n=e&511,i=s?"d":"-";return i+=n&256?"r":"-",i+=n&128?"w":"-",i+=n&64?"x":"-",i+=n&32?"r":"-",i+=n&16?"w":"-",i+=n&8?"x":"-",i+=n&4?"r":"-",i+=n&2?"w":"-",i+=n&1?"x":"-",i}function X(e){let s=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],i=s[e.getDay()],t=n[e.getMonth()],m=String(e.getDate()).padStart(2," "),a=String(e.getHours()).padStart(2,"0"),r=String(e.getMinutes()).padStart(2,"0"),c=String(e.getSeconds()).padStart(2,"0"),o=e.getFullYear();return`${i} ${t} ${m} ${a}:${r}:${c} ${o}`}function Z(e,s){switch(s){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${s}`}}export{oe as findCommand};
|
package/dist/bin/just-bash.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as z,b as K,c as U,d as Y,e as X,f as k,g as W,h as he,i as B,j as ie,k as Be}from"./chunks/chunk-NWWB2XRE.js";import{a as se}from"./chunks/chunk-4VDEBYW7.js";import"./chunks/chunk-SJXDWN5X.js";import{resolve as Wn}from"node:path";var ur=[{name:"echo",load:async()=>(await import("./chunks/echo-HKLPYMNC.js")).echoCommand},{name:"cat",load:async()=>(await import("./chunks/cat-XILYL7NW.js")).catCommand},{name:"printf",load:async()=>(await import("./chunks/printf-2JFCUFOA.js")).printfCommand},{name:"ls",load:async()=>(await import("./chunks/ls-GU5227KE.js")).lsCommand},{name:"mkdir",load:async()=>(await import("./chunks/mkdir-4OYU22AA.js")).mkdirCommand},{name:"touch",load:async()=>(await import("./chunks/touch-3ZANYAXI.js")).touchCommand},{name:"rm",load:async()=>(await import("./chunks/rm-R4M647EC.js")).rmCommand},{name:"cp",load:async()=>(await import("./chunks/cp-HES4UN7K.js")).cpCommand},{name:"mv",load:async()=>(await import("./chunks/mv-H3S4FEWR.js")).mvCommand},{name:"ln",load:async()=>(await import("./chunks/ln-RUR4ALOJ.js")).lnCommand},{name:"chmod",load:async()=>(await import("./chunks/chmod-EXWX4N7Y.js")).chmodCommand},{name:"pwd",load:async()=>(await import("./chunks/pwd-T5Q3JEBO.js")).pwdCommand},{name:"readlink",load:async()=>(await import("./chunks/readlink-M44TLMFS.js")).readlinkCommand},{name:"head",load:async()=>(await import("./chunks/head-YGMY3DHE.js")).headCommand},{name:"tail",load:async()=>(await import("./chunks/tail-BYPLMYMZ.js")).tailCommand},{name:"wc",load:async()=>(await import("./chunks/wc-NBMNJDZL.js")).wcCommand},{name:"stat",load:async()=>(await import("./chunks/stat-CR2INBC2.js")).statCommand},{name:"grep",load:async()=>(await import("./chunks/grep-BEZRXAWL.js")).grepCommand},{name:"fgrep",load:async()=>(await import("./chunks/grep-BEZRXAWL.js")).fgrepCommand},{name:"egrep",load:async()=>(await import("./chunks/grep-BEZRXAWL.js")).egrepCommand},{name:"sed",load:async()=>(await import("./chunks/sed-QLLAZYHH.js")).sedCommand},{name:"awk",load:async()=>(await import("./chunks/awk2-A73ZNFXJ.js")).awkCommand2},{name:"sort",load:async()=>(await import("./chunks/sort-JL33INQB.js")).sortCommand},{name:"uniq",load:async()=>(await import("./chunks/uniq-F5NP3LLU.js")).uniqCommand},{name:"comm",load:async()=>(await import("./chunks/comm-KY3COLF5.js")).commCommand},{name:"cut",load:async()=>(await import("./chunks/cut-JSIPAKOX.js")).cutCommand},{name:"paste",load:async()=>(await import("./chunks/paste-HHCFASL4.js")).pasteCommand},{name:"tr",load:async()=>(await import("./chunks/tr-E66N7IS2.js")).trCommand},{name:"tee",load:async()=>(await import("./chunks/tee-HOMRRC3X.js")).teeCommand},{name:"find",load:async()=>(await import("./chunks/find-D3ZC5DXH.js")).findCommand},{name:"basename",load:async()=>(await import("./chunks/basename-IYEP3AMY.js")).basenameCommand},{name:"dirname",load:async()=>(await import("./chunks/dirname-UTCUUILN.js")).dirnameCommand},{name:"tree",load:async()=>(await import("./chunks/tree-EE2PYIMV.js")).treeCommand},{name:"du",load:async()=>(await import("./chunks/du-2JU3PUTM.js")).duCommand},{name:"env",load:async()=>(await import("./chunks/env-2SBJNP7X.js")).envCommand},{name:"printenv",load:async()=>(await import("./chunks/env-2SBJNP7X.js")).printenvCommand},{name:"alias",load:async()=>(await import("./chunks/alias-ZAQAKC5X.js")).aliasCommand},{name:"unalias",load:async()=>(await import("./chunks/alias-ZAQAKC5X.js")).unaliasCommand},{name:"history",load:async()=>(await import("./chunks/history-OGBCIAR5.js")).historyCommand},{name:"xargs",load:async()=>(await import("./chunks/xargs-EMY5BOJ2.js")).xargsCommand},{name:"true",load:async()=>(await import("./chunks/true-OWPVS7U4.js")).trueCommand},{name:"false",load:async()=>(await import("./chunks/true-OWPVS7U4.js")).falseCommand},{name:"clear",load:async()=>(await import("./chunks/clear-2APRIRCF.js")).clearCommand},{name:"bash",load:async()=>(await import("./chunks/bash-WZYHIZP6.js")).bashCommand},{name:"sh",load:async()=>(await import("./chunks/bash-WZYHIZP6.js")).shCommand},{name:"jq",load:async()=>(await import("./chunks/jq-TRAUXD47.js")).jqCommand},{name:"base64",load:async()=>(await import("./chunks/base64-JPITV4MD.js")).base64Command},{name:"diff",load:async()=>(await import("./chunks/diff-W4JRNHXW.js")).diffCommand},{name:"date",load:async()=>(await import("./chunks/date-CU4J7GHI.js")).dateCommand},{name:"sleep",load:async()=>(await import("./chunks/sleep-OJPODQGM.js")).sleepCommand},{name:"timeout",load:async()=>(await import("./chunks/timeout-MYKG34DQ.js")).timeoutCommand},{name:"seq",load:async()=>(await import("./chunks/seq-GJMQM7SP.js")).seqCommand},{name:"expr",load:async()=>(await import("./chunks/expr-M74QZQ6C.js")).exprCommand},{name:"md5sum",load:async()=>(await import("./chunks/md5sum-C7WDEYN5.js")).md5sumCommand},{name:"sha1sum",load:async()=>(await import("./chunks/sha1sum-WKCGV66X.js")).sha1sumCommand},{name:"sha256sum",load:async()=>(await import("./chunks/sha256sum-3ZDGP5WC.js")).sha256sumCommand},{name:"file",load:async()=>(await import("./chunks/file-QPD3U2H7.js")).fileCommand},{name:"html-to-markdown",load:async()=>(await import("./chunks/html-to-markdown-HTGML4TH.js")).htmlToMarkdownCommand},{name:"help",load:async()=>(await import("./chunks/help-UEF7LW7F.js")).helpCommand},{name:"which",load:async()=>(await import("./chunks/which-6MRG2UCF.js")).whichCommand},{name:"tac",load:async()=>(await import("./chunks/tac-F4GC3MAI.js")).tac},{name:"hostname",load:async()=>(await import("./chunks/hostname-CV7CGKRN.js")).hostname},{name:"od",load:async()=>(await import("./chunks/od-TXTSFFJY.js")).od}],Mn=[{name:"curl",load:async()=>(await import("./chunks/curl-BN5M3BUX.js")).curlCommand}],dr=new Map;function hr(t){return{name:t.name,async execute(e,n){let r=dr.get(t.name);return r||(r=await t.load(),dr.set(t.name,r)),r.execute(e,n)}}}function pr(t){return(t?ur.filter(n=>t.includes(n.name)):ur).map(hr)}function mr(){return Mn.map(hr)}function yr(t){return"load"in t&&typeof t.load=="function"}function Er(t){let e=null;return{name:t.name,async execute(n,r){return e||(e=await t.load()),e.execute(n,r)}}}var Bn=new TextEncoder,zn=new TextDecoder;function ge(t,e){if(t instanceof Uint8Array)return t;switch(e){case"base64":return Uint8Array.from(atob(t),n=>n.charCodeAt(0));case"hex":{let n=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2)n[r/2]=parseInt(t.slice(r,r+2),16);return n}case"binary":case"latin1":return Uint8Array.from(t,n=>n.charCodeAt(0));default:return Bn.encode(t)}}function ze(t,e){switch(e){case"base64":return btoa(String.fromCharCode(...t));case"hex":return Array.from(t).map(n=>n.toString(16).padStart(2,"0")).join("");case"binary":case"latin1":return String.fromCharCode(...t);default:return zn.decode(t)}}function oe(t){if(t!=null)return typeof t=="string"?t:t.encoding??void 0}var Ue=new TextEncoder;function Un(t){return typeof t=="object"&&t!==null&&!(t instanceof Uint8Array)&&"content"in t}var Pe=class{data=new Map;constructor(e){if(this.data.set("/",{type:"directory",mode:493,mtime:new Date}),e)for(let[n,r]of Object.entries(e))Un(r)?this.writeFileSync(n,r.content,void 0,{mode:r.mode,mtime:r.mtime}):this.writeFileSync(n,r)}normalizePath(e){if(!e||e==="/")return"/";let n=e.endsWith("/")&&e!=="/"?e.slice(0,-1):e;n.startsWith("/")||(n=`/${n}`);let r=n.split("/").filter(o=>o&&o!=="."),s=[];for(let o of r)o===".."?s.pop():s.push(o);return`/${s.join("/")}`||"/"}dirname(e){let n=this.normalizePath(e);if(n==="/")return"/";let r=n.lastIndexOf("/");return r===0?"/":n.slice(0,r)}ensureParentDirs(e){let n=this.dirname(e);n!=="/"&&(this.data.has(n)||(this.ensureParentDirs(n),this.data.set(n,{type:"directory",mode:493,mtime:new Date})))}writeFileSync(e,n,r,s){let o=this.normalizePath(e);this.ensureParentDirs(o);let i=oe(r),a=ge(n,i);this.data.set(o,{type:"file",content:a,mode:s?.mode??420,mtime:s?.mtime??new Date})}async readFile(e,n){let r=await this.readFileBuffer(e),s=oe(n);return ze(r,s)}async readFileBuffer(e){let n=this.normalizePath(e),r=this.data.get(n),s=n;if(!r)throw new Error(`ENOENT: no such file or directory, open '${e}'`);let o=new Set;for(;r&&r.type==="symlink";){if(o.has(s))throw new Error(`ELOOP: too many levels of symbolic links, open '${e}'`);o.add(s),s=this.resolveSymlink(s,r.target),r=this.data.get(s)}if(!r)throw new Error(`ENOENT: no such file or directory, open '${e}'`);if(r.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${e}'`);return r.content instanceof Uint8Array?r.content:Ue.encode(r.content)}async writeFile(e,n,r){this.writeFileSync(e,n,r)}async appendFile(e,n,r){let s=this.normalizePath(e),o=this.data.get(s);if(o&&o.type==="directory")throw new Error(`EISDIR: illegal operation on a directory, write '${e}'`);let i=oe(r),a=ge(n,i);if(o?.type==="file"){let l=o.content instanceof Uint8Array?o.content:Ue.encode(o.content),c=new Uint8Array(l.length+a.length);c.set(l),c.set(a,l.length),this.data.set(s,{type:"file",content:c,mode:o.mode,mtime:new Date})}else this.writeFileSync(e,n,r)}async exists(e){return this.data.has(this.normalizePath(e))}async stat(e){let n=this.normalizePath(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, stat '${e}'`);if(r.type==="symlink"){let o=this.resolveSymlink(n,r.target),i=this.data.get(o);if(!i)throw new Error(`ENOENT: no such file or directory, stat '${e}'`);r=i}let s=0;return r.type==="file"&&r.content&&(r.content instanceof Uint8Array?s=r.content.length:s=Ue.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:s,mtime:r.mtime||new Date}}async lstat(e){let n=this.normalizePath(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, lstat '${e}'`);if(r.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:r.mode,size:r.target.length,mtime:r.mtime||new Date};let s=0;return r.type==="file"&&r.content&&(r.content instanceof Uint8Array?s=r.content.length:s=Ue.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:s,mtime:r.mtime||new Date}}resolveSymlink(e,n){if(n.startsWith("/"))return this.normalizePath(n);let r=this.dirname(e);return this.normalizePath(r==="/"?`/${n}`:`${r}/${n}`)}async mkdir(e,n){this.mkdirSync(e,n)}mkdirSync(e,n){let r=this.normalizePath(e);if(this.data.has(r)){if(this.data.get(r)?.type==="file")throw new Error(`EEXIST: file already exists, mkdir '${e}'`);if(!n?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${e}'`);return}let s=this.dirname(r);if(s!=="/"&&!this.data.has(s))if(n?.recursive)this.mkdirSync(s,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${e}'`);this.data.set(r,{type:"directory",mode:493,mtime:new Date})}async readdir(e){let n=this.normalizePath(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);if(r.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${e}'`);let s=n==="/"?"/":`${n}/`,o=[];for(let i of this.data.keys())if(i!==n&&i.startsWith(s)){let l=i.slice(s.length).split("/")[0];l&&!o.includes(l)&&o.push(l)}return o.sort()}async rm(e,n){let r=this.normalizePath(e),s=this.data.get(r);if(!s){if(n?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${e}'`)}if(s.type==="directory"){let o=await this.readdir(r);if(o.length>0){if(!n?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${e}'`);for(let i of o){let a=r==="/"?`/${i}`:`${r}/${i}`;await this.rm(a,n)}}}this.data.delete(r)}async cp(e,n,r){let s=this.normalizePath(e),o=this.normalizePath(n),i=this.data.get(s);if(!i)throw new Error(`ENOENT: no such file or directory, cp '${e}'`);if(i.type==="file")this.ensureParentDirs(o),this.data.set(o,{...i});else if(i.type==="directory"){if(!r?.recursive)throw new Error(`EISDIR: is a directory, cp '${e}'`);await this.mkdir(o,{recursive:!0});let a=await this.readdir(s);for(let l of a){let c=s==="/"?`/${l}`:`${s}/${l}`,f=o==="/"?`/${l}`:`${o}/${l}`;await this.cp(c,f,r)}}}async mv(e,n){await this.cp(e,n,{recursive:!0}),await this.rm(e,{recursive:!0})}getAllPaths(){return Array.from(this.data.keys())}resolvePath(e,n){if(n.startsWith("/"))return this.normalizePath(n);let r=e==="/"?`/${n}`:`${e}/${n}`;return this.normalizePath(r)}async chmod(e,n){let r=this.normalizePath(e),s=this.data.get(r);if(!s)throw new Error(`ENOENT: no such file or directory, chmod '${e}'`);s.mode=n}async symlink(e,n){let r=this.normalizePath(n);if(this.data.has(r))throw new Error(`EEXIST: file already exists, symlink '${n}'`);this.ensureParentDirs(r),this.data.set(r,{type:"symlink",target:e,mode:511,mtime:new Date})}async link(e,n){let r=this.normalizePath(e),s=this.normalizePath(n),o=this.data.get(r);if(!o)throw new Error(`ENOENT: no such file or directory, link '${e}'`);if(o.type!=="file")throw new Error(`EPERM: operation not permitted, link '${e}'`);if(this.data.has(s))throw new Error(`EEXIST: file already exists, link '${n}'`);this.ensureParentDirs(s),this.data.set(s,{type:"file",content:o.content,mode:o.mode,mtime:o.mtime})}async readlink(e){let n=this.normalizePath(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, readlink '${e}'`);if(r.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${e}'`);return r.target}};var wr="5.1.0(1)-release",gr="Linux version 5.15.0-generic (just-bash) #1 SMP PREEMPT";function Ie(){return{pid:process.pid,ppid:process.ppid,uid:process.getuid?.()??1e3,gid:process.getgid?.()??1e3}}function Ar(){let{pid:t,ppid:e,uid:n,gid:r}=Ie();return`Name: bash
|
|
2
|
+
import{a as z,b as K,c as U,d as Y,e as X,f as k,g as W,h as he,i as B,j as ie,k as Be}from"./chunks/chunk-NWWB2XRE.js";import{a as se}from"./chunks/chunk-4VDEBYW7.js";import"./chunks/chunk-SJXDWN5X.js";import{resolve as Wn}from"node:path";var ur=[{name:"echo",load:async()=>(await import("./chunks/echo-HKLPYMNC.js")).echoCommand},{name:"cat",load:async()=>(await import("./chunks/cat-XILYL7NW.js")).catCommand},{name:"printf",load:async()=>(await import("./chunks/printf-2JFCUFOA.js")).printfCommand},{name:"ls",load:async()=>(await import("./chunks/ls-GU5227KE.js")).lsCommand},{name:"mkdir",load:async()=>(await import("./chunks/mkdir-4OYU22AA.js")).mkdirCommand},{name:"touch",load:async()=>(await import("./chunks/touch-3ZANYAXI.js")).touchCommand},{name:"rm",load:async()=>(await import("./chunks/rm-R4M647EC.js")).rmCommand},{name:"cp",load:async()=>(await import("./chunks/cp-HES4UN7K.js")).cpCommand},{name:"mv",load:async()=>(await import("./chunks/mv-H3S4FEWR.js")).mvCommand},{name:"ln",load:async()=>(await import("./chunks/ln-RUR4ALOJ.js")).lnCommand},{name:"chmod",load:async()=>(await import("./chunks/chmod-EXWX4N7Y.js")).chmodCommand},{name:"pwd",load:async()=>(await import("./chunks/pwd-T5Q3JEBO.js")).pwdCommand},{name:"readlink",load:async()=>(await import("./chunks/readlink-M44TLMFS.js")).readlinkCommand},{name:"head",load:async()=>(await import("./chunks/head-YGMY3DHE.js")).headCommand},{name:"tail",load:async()=>(await import("./chunks/tail-BYPLMYMZ.js")).tailCommand},{name:"wc",load:async()=>(await import("./chunks/wc-NBMNJDZL.js")).wcCommand},{name:"stat",load:async()=>(await import("./chunks/stat-CR2INBC2.js")).statCommand},{name:"grep",load:async()=>(await import("./chunks/grep-BEZRXAWL.js")).grepCommand},{name:"fgrep",load:async()=>(await import("./chunks/grep-BEZRXAWL.js")).fgrepCommand},{name:"egrep",load:async()=>(await import("./chunks/grep-BEZRXAWL.js")).egrepCommand},{name:"sed",load:async()=>(await import("./chunks/sed-QLLAZYHH.js")).sedCommand},{name:"awk",load:async()=>(await import("./chunks/awk2-A73ZNFXJ.js")).awkCommand2},{name:"sort",load:async()=>(await import("./chunks/sort-JL33INQB.js")).sortCommand},{name:"uniq",load:async()=>(await import("./chunks/uniq-F5NP3LLU.js")).uniqCommand},{name:"comm",load:async()=>(await import("./chunks/comm-KY3COLF5.js")).commCommand},{name:"cut",load:async()=>(await import("./chunks/cut-JSIPAKOX.js")).cutCommand},{name:"paste",load:async()=>(await import("./chunks/paste-HHCFASL4.js")).pasteCommand},{name:"tr",load:async()=>(await import("./chunks/tr-E66N7IS2.js")).trCommand},{name:"tee",load:async()=>(await import("./chunks/tee-HOMRRC3X.js")).teeCommand},{name:"find",load:async()=>(await import("./chunks/find-TRBVCSI6.js")).findCommand},{name:"basename",load:async()=>(await import("./chunks/basename-IYEP3AMY.js")).basenameCommand},{name:"dirname",load:async()=>(await import("./chunks/dirname-UTCUUILN.js")).dirnameCommand},{name:"tree",load:async()=>(await import("./chunks/tree-EE2PYIMV.js")).treeCommand},{name:"du",load:async()=>(await import("./chunks/du-2JU3PUTM.js")).duCommand},{name:"env",load:async()=>(await import("./chunks/env-2SBJNP7X.js")).envCommand},{name:"printenv",load:async()=>(await import("./chunks/env-2SBJNP7X.js")).printenvCommand},{name:"alias",load:async()=>(await import("./chunks/alias-ZAQAKC5X.js")).aliasCommand},{name:"unalias",load:async()=>(await import("./chunks/alias-ZAQAKC5X.js")).unaliasCommand},{name:"history",load:async()=>(await import("./chunks/history-OGBCIAR5.js")).historyCommand},{name:"xargs",load:async()=>(await import("./chunks/xargs-EMY5BOJ2.js")).xargsCommand},{name:"true",load:async()=>(await import("./chunks/true-OWPVS7U4.js")).trueCommand},{name:"false",load:async()=>(await import("./chunks/true-OWPVS7U4.js")).falseCommand},{name:"clear",load:async()=>(await import("./chunks/clear-2APRIRCF.js")).clearCommand},{name:"bash",load:async()=>(await import("./chunks/bash-WZYHIZP6.js")).bashCommand},{name:"sh",load:async()=>(await import("./chunks/bash-WZYHIZP6.js")).shCommand},{name:"jq",load:async()=>(await import("./chunks/jq-TRAUXD47.js")).jqCommand},{name:"base64",load:async()=>(await import("./chunks/base64-JPITV4MD.js")).base64Command},{name:"diff",load:async()=>(await import("./chunks/diff-W4JRNHXW.js")).diffCommand},{name:"date",load:async()=>(await import("./chunks/date-CU4J7GHI.js")).dateCommand},{name:"sleep",load:async()=>(await import("./chunks/sleep-OJPODQGM.js")).sleepCommand},{name:"timeout",load:async()=>(await import("./chunks/timeout-MYKG34DQ.js")).timeoutCommand},{name:"seq",load:async()=>(await import("./chunks/seq-GJMQM7SP.js")).seqCommand},{name:"expr",load:async()=>(await import("./chunks/expr-M74QZQ6C.js")).exprCommand},{name:"md5sum",load:async()=>(await import("./chunks/md5sum-C7WDEYN5.js")).md5sumCommand},{name:"sha1sum",load:async()=>(await import("./chunks/sha1sum-WKCGV66X.js")).sha1sumCommand},{name:"sha256sum",load:async()=>(await import("./chunks/sha256sum-3ZDGP5WC.js")).sha256sumCommand},{name:"file",load:async()=>(await import("./chunks/file-QPD3U2H7.js")).fileCommand},{name:"html-to-markdown",load:async()=>(await import("./chunks/html-to-markdown-HTGML4TH.js")).htmlToMarkdownCommand},{name:"help",load:async()=>(await import("./chunks/help-UEF7LW7F.js")).helpCommand},{name:"which",load:async()=>(await import("./chunks/which-6MRG2UCF.js")).whichCommand},{name:"tac",load:async()=>(await import("./chunks/tac-F4GC3MAI.js")).tac},{name:"hostname",load:async()=>(await import("./chunks/hostname-CV7CGKRN.js")).hostname},{name:"od",load:async()=>(await import("./chunks/od-TXTSFFJY.js")).od}],Mn=[{name:"curl",load:async()=>(await import("./chunks/curl-BN5M3BUX.js")).curlCommand}],dr=new Map;function hr(t){return{name:t.name,async execute(e,n){let r=dr.get(t.name);return r||(r=await t.load(),dr.set(t.name,r)),r.execute(e,n)}}}function pr(t){return(t?ur.filter(n=>t.includes(n.name)):ur).map(hr)}function mr(){return Mn.map(hr)}function yr(t){return"load"in t&&typeof t.load=="function"}function Er(t){let e=null;return{name:t.name,async execute(n,r){return e||(e=await t.load()),e.execute(n,r)}}}var Bn=new TextEncoder,zn=new TextDecoder;function ge(t,e){if(t instanceof Uint8Array)return t;switch(e){case"base64":return Uint8Array.from(atob(t),n=>n.charCodeAt(0));case"hex":{let n=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2)n[r/2]=parseInt(t.slice(r,r+2),16);return n}case"binary":case"latin1":return Uint8Array.from(t,n=>n.charCodeAt(0));default:return Bn.encode(t)}}function ze(t,e){switch(e){case"base64":return btoa(String.fromCharCode(...t));case"hex":return Array.from(t).map(n=>n.toString(16).padStart(2,"0")).join("");case"binary":case"latin1":return String.fromCharCode(...t);default:return zn.decode(t)}}function oe(t){if(t!=null)return typeof t=="string"?t:t.encoding??void 0}var Ue=new TextEncoder;function Un(t){return typeof t=="object"&&t!==null&&!(t instanceof Uint8Array)&&"content"in t}var Pe=class{data=new Map;constructor(e){if(this.data.set("/",{type:"directory",mode:493,mtime:new Date}),e)for(let[n,r]of Object.entries(e))Un(r)?this.writeFileSync(n,r.content,void 0,{mode:r.mode,mtime:r.mtime}):this.writeFileSync(n,r)}normalizePath(e){if(!e||e==="/")return"/";let n=e.endsWith("/")&&e!=="/"?e.slice(0,-1):e;n.startsWith("/")||(n=`/${n}`);let r=n.split("/").filter(o=>o&&o!=="."),s=[];for(let o of r)o===".."?s.pop():s.push(o);return`/${s.join("/")}`||"/"}dirname(e){let n=this.normalizePath(e);if(n==="/")return"/";let r=n.lastIndexOf("/");return r===0?"/":n.slice(0,r)}ensureParentDirs(e){let n=this.dirname(e);n!=="/"&&(this.data.has(n)||(this.ensureParentDirs(n),this.data.set(n,{type:"directory",mode:493,mtime:new Date})))}writeFileSync(e,n,r,s){let o=this.normalizePath(e);this.ensureParentDirs(o);let i=oe(r),a=ge(n,i);this.data.set(o,{type:"file",content:a,mode:s?.mode??420,mtime:s?.mtime??new Date})}async readFile(e,n){let r=await this.readFileBuffer(e),s=oe(n);return ze(r,s)}async readFileBuffer(e){let n=this.normalizePath(e),r=this.data.get(n),s=n;if(!r)throw new Error(`ENOENT: no such file or directory, open '${e}'`);let o=new Set;for(;r&&r.type==="symlink";){if(o.has(s))throw new Error(`ELOOP: too many levels of symbolic links, open '${e}'`);o.add(s),s=this.resolveSymlink(s,r.target),r=this.data.get(s)}if(!r)throw new Error(`ENOENT: no such file or directory, open '${e}'`);if(r.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${e}'`);return r.content instanceof Uint8Array?r.content:Ue.encode(r.content)}async writeFile(e,n,r){this.writeFileSync(e,n,r)}async appendFile(e,n,r){let s=this.normalizePath(e),o=this.data.get(s);if(o&&o.type==="directory")throw new Error(`EISDIR: illegal operation on a directory, write '${e}'`);let i=oe(r),a=ge(n,i);if(o?.type==="file"){let l=o.content instanceof Uint8Array?o.content:Ue.encode(o.content),c=new Uint8Array(l.length+a.length);c.set(l),c.set(a,l.length),this.data.set(s,{type:"file",content:c,mode:o.mode,mtime:new Date})}else this.writeFileSync(e,n,r)}async exists(e){return this.data.has(this.normalizePath(e))}async stat(e){let n=this.normalizePath(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, stat '${e}'`);if(r.type==="symlink"){let o=this.resolveSymlink(n,r.target),i=this.data.get(o);if(!i)throw new Error(`ENOENT: no such file or directory, stat '${e}'`);r=i}let s=0;return r.type==="file"&&r.content&&(r.content instanceof Uint8Array?s=r.content.length:s=Ue.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:s,mtime:r.mtime||new Date}}async lstat(e){let n=this.normalizePath(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, lstat '${e}'`);if(r.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:r.mode,size:r.target.length,mtime:r.mtime||new Date};let s=0;return r.type==="file"&&r.content&&(r.content instanceof Uint8Array?s=r.content.length:s=Ue.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:s,mtime:r.mtime||new Date}}resolveSymlink(e,n){if(n.startsWith("/"))return this.normalizePath(n);let r=this.dirname(e);return this.normalizePath(r==="/"?`/${n}`:`${r}/${n}`)}async mkdir(e,n){this.mkdirSync(e,n)}mkdirSync(e,n){let r=this.normalizePath(e);if(this.data.has(r)){if(this.data.get(r)?.type==="file")throw new Error(`EEXIST: file already exists, mkdir '${e}'`);if(!n?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${e}'`);return}let s=this.dirname(r);if(s!=="/"&&!this.data.has(s))if(n?.recursive)this.mkdirSync(s,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${e}'`);this.data.set(r,{type:"directory",mode:493,mtime:new Date})}async readdir(e){let n=this.normalizePath(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);if(r.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${e}'`);let s=n==="/"?"/":`${n}/`,o=[];for(let i of this.data.keys())if(i!==n&&i.startsWith(s)){let l=i.slice(s.length).split("/")[0];l&&!o.includes(l)&&o.push(l)}return o.sort()}async rm(e,n){let r=this.normalizePath(e),s=this.data.get(r);if(!s){if(n?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${e}'`)}if(s.type==="directory"){let o=await this.readdir(r);if(o.length>0){if(!n?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${e}'`);for(let i of o){let a=r==="/"?`/${i}`:`${r}/${i}`;await this.rm(a,n)}}}this.data.delete(r)}async cp(e,n,r){let s=this.normalizePath(e),o=this.normalizePath(n),i=this.data.get(s);if(!i)throw new Error(`ENOENT: no such file or directory, cp '${e}'`);if(i.type==="file")this.ensureParentDirs(o),this.data.set(o,{...i});else if(i.type==="directory"){if(!r?.recursive)throw new Error(`EISDIR: is a directory, cp '${e}'`);await this.mkdir(o,{recursive:!0});let a=await this.readdir(s);for(let l of a){let c=s==="/"?`/${l}`:`${s}/${l}`,f=o==="/"?`/${l}`:`${o}/${l}`;await this.cp(c,f,r)}}}async mv(e,n){await this.cp(e,n,{recursive:!0}),await this.rm(e,{recursive:!0})}getAllPaths(){return Array.from(this.data.keys())}resolvePath(e,n){if(n.startsWith("/"))return this.normalizePath(n);let r=e==="/"?`/${n}`:`${e}/${n}`;return this.normalizePath(r)}async chmod(e,n){let r=this.normalizePath(e),s=this.data.get(r);if(!s)throw new Error(`ENOENT: no such file or directory, chmod '${e}'`);s.mode=n}async symlink(e,n){let r=this.normalizePath(n);if(this.data.has(r))throw new Error(`EEXIST: file already exists, symlink '${n}'`);this.ensureParentDirs(r),this.data.set(r,{type:"symlink",target:e,mode:511,mtime:new Date})}async link(e,n){let r=this.normalizePath(e),s=this.normalizePath(n),o=this.data.get(r);if(!o)throw new Error(`ENOENT: no such file or directory, link '${e}'`);if(o.type!=="file")throw new Error(`EPERM: operation not permitted, link '${e}'`);if(this.data.has(s))throw new Error(`EEXIST: file already exists, link '${n}'`);this.ensureParentDirs(s),this.data.set(s,{type:"file",content:o.content,mode:o.mode,mtime:o.mtime})}async readlink(e){let n=this.normalizePath(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, readlink '${e}'`);if(r.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${e}'`);return r.target}};var wr="5.1.0(1)-release",gr="Linux version 5.15.0-generic (just-bash) #1 SMP PREEMPT";function Ie(){return{pid:process.pid,ppid:process.ppid,uid:process.getuid?.()??1e3,gid:process.getgid?.()??1e3}}function Ar(){let{pid:t,ppid:e,uid:n,gid:r}=Ie();return`Name: bash
|
|
3
3
|
State: R (running)
|
|
4
4
|
Pid: ${t}
|
|
5
5
|
PPid: ${e}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as N}from"./chunk-26Q3PZQ6.js";import{a as L,b as B,c as H}from"./chunk-PM2DS2YW.js";import{a as I,b as O}from"./chunk-GTNBSMZR.js";import"./chunk-SJXDWN5X.js";function w(e,s){switch(e.type){case"name":return{matches:N(s.name,e.pattern,e.ignoreCase),pruned:!1,printed:!1};case"path":return{matches:N(s.relativePath,e.pattern,e.ignoreCase),pruned:!1,printed:!1};case"regex":try{let n=e.ignoreCase?"i":"";return{matches:new RegExp(e.pattern,n).test(s.relativePath),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:s.isFile,pruned:!1,printed:!1}:e.fileType==="d"?{matches:s.isDirectory,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"empty":return{matches:s.isEmpty,pruned:!1,printed:!1};case"mtime":{let
|
|
3
|
-
`,actions:[]}}else if(a==="-empty")n.push({type:"expr",expr:{type:"empty"}});else if(a==="-mtime"&&t+1<e.length){let
|
|
4
|
-
`,actions:[]};if(n.length===0){t++;continue}break}t++}if(n.length===0)return{expr:null,pathIndex:t,actions:
|
|
5
|
-
`,D=1;continue}async function g(u,d){if(
|
|
2
|
+
import{a as N}from"./chunk-26Q3PZQ6.js";import{a as L,b as B,c as H}from"./chunk-PM2DS2YW.js";import{a as I,b as O}from"./chunk-GTNBSMZR.js";import"./chunk-SJXDWN5X.js";function w(e,s){switch(e.type){case"name":return{matches:N(s.name,e.pattern,e.ignoreCase),pruned:!1,printed:!1};case"path":return{matches:N(s.relativePath,e.pattern,e.ignoreCase),pruned:!1,printed:!1};case"regex":try{let n=e.ignoreCase?"i":"";return{matches:new RegExp(e.pattern,n).test(s.relativePath),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:s.isFile,pruned:!1,printed:!1}:e.fileType==="d"?{matches:s.isDirectory,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"empty":return{matches:s.isEmpty,pruned:!1,printed:!1};case"mtime":{let i=(Date.now()-s.mtime)/(1e3*60*60*24),t;return e.comparison==="more"?t=i>e.days:e.comparison==="less"?t=i<e.days:t=Math.floor(i)===e.days,{matches:t,pruned:!1,printed:!1}}case"newer":{let n=s.newerRefTimes.get(e.refPath);return n===void 0?{matches:!1,pruned:!1,printed:!1}:{matches:s.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 i;return e.comparison==="more"?i=s.size>n:e.comparison==="less"?i=s.size<n:e.unit==="b"?i=Math.ceil(s.size/512)===e.value:i=s.size===n,{matches:i,pruned:!1,printed:!1}}case"perm":{let n=s.mode&511,i=e.mode&511,t;return e.matchType==="exact"?t=n===i:e.matchType==="all"?t=(n&i)===i:t=(n&i)!==0,{matches:t,pruned:!1,printed:!1}}case"prune":return{matches:!0,pruned:!0,printed:!1};case"print":return{matches:!0,pruned:!1,printed:!0};case"not":{let n=w(e.expr,s);return{matches:!n.matches,pruned:n.pruned,printed:!1}}case"and":{let n=w(e.left,s);if(!n.matches)return{matches:!1,pruned:n.pruned,printed:!1};let i=w(e.right,s);return{matches:i.matches,pruned:n.pruned||i.pruned,printed:n.printed||i.printed}}case"or":{let n=w(e.left,s);if(n.matches)return n;let i=w(e.right,s);return{matches:i.matches,pruned:n.pruned||i.pruned,printed:i.printed}}}}function G(e){let s=[],n=i=>{i&&(i.type==="newer"?s.push(i.refPath):i.type==="not"?n(i.expr):(i.type==="and"||i.type==="or")&&(n(i.left),n(i.right)))};return n(e),s}function j(e,s){let n=[],i=[],t=s;for(;t<e.length;){let a=e[t];if(a==="("||a==="\\("){n.push({type:"lparen"}),t++;continue}if(a===")"||a==="\\)"){n.push({type:"rparen"}),t++;continue}if(a==="-name"&&t+1<e.length)n.push({type:"expr",expr:{type:"name",pattern:e[++t]}});else if(a==="-iname"&&t+1<e.length)n.push({type:"expr",expr:{type:"name",pattern:e[++t],ignoreCase:!0}});else if(a==="-path"&&t+1<e.length)n.push({type:"expr",expr:{type:"path",pattern:e[++t]}});else if(a==="-ipath"&&t+1<e.length)n.push({type:"expr",expr:{type:"path",pattern:e[++t],ignoreCase:!0}});else if(a==="-regex"&&t+1<e.length)n.push({type:"expr",expr:{type:"regex",pattern:e[++t]}});else if(a==="-iregex"&&t+1<e.length)n.push({type:"expr",expr:{type:"regex",pattern:e[++t],ignoreCase:!0}});else if(a==="-type"&&t+1<e.length){let r=e[++t];if(r==="f"||r==="d")n.push({type:"expr",expr:{type:"type",fileType:r}});else return{expr:null,pathIndex:t,error:`find: Unknown argument to -type: ${r}
|
|
3
|
+
`,actions:[]}}else if(a==="-empty")n.push({type:"expr",expr:{type:"empty"}});else if(a==="-mtime"&&t+1<e.length){let r=e[++t],c="exact",o=r;r.startsWith("+")?(c="more",o=r.slice(1)):r.startsWith("-")&&(c="less",o=r.slice(1));let h=parseInt(o,10);Number.isNaN(h)||n.push({type:"expr",expr:{type:"mtime",days:h,comparison:c}})}else if(a==="-newer"&&t+1<e.length){let r=e[++t];n.push({type:"expr",expr:{type:"newer",refPath:r}})}else if(a==="-size"&&t+1<e.length){let r=e[++t],c="exact",o=r;r.startsWith("+")?(c="more",o=r.slice(1)):r.startsWith("-")&&(c="less",o=r.slice(1));let h=o.match(/^(\d+)([ckMGb])?$/);if(h){let b=parseInt(h[1],10),y=h[2]||"b";n.push({type:"expr",expr:{type:"size",value:b,unit:y,comparison:c}})}}else if(a==="-perm"&&t+1<e.length){let r=e[++t],c="exact",o=r;r.startsWith("-")?(c="all",o=r.slice(1)):r.startsWith("/")&&(c="any",o=r.slice(1));let h=parseInt(o,8);Number.isNaN(h)||n.push({type:"expr",expr:{type:"perm",mode:h,matchType:c}})}else if(a==="-prune")n.push({type:"expr",expr:{type:"prune"}});else if(a==="-not"||a==="!")n.push({type:"not"});else if(a==="-o"||a==="-or")n.push({type:"op",op:"or"});else if(a==="-a"||a==="-and")n.push({type:"op",op:"and"});else if(a==="-maxdepth"||a==="-mindepth")t++;else if(a!=="-depth")if(a==="-exec"){let r=[];for(t++;t<e.length&&e[t]!==";"&&e[t]!=="+";)r.push(e[t]),t++;if(t>=e.length)return{expr:null,pathIndex:t,error:"find: missing argument to `-exec'\n",actions:[]};let c=e[t]==="+";i.push({type:"exec",command:r,batchMode:c})}else if(a==="-print")n.push({type:"expr",expr:{type:"print"}}),i.push({type:"print"});else if(a==="-print0")i.push({type:"print0"});else if(a==="-printf"&&t+1<e.length){let r=e[++t];i.push({type:"printf",format:r})}else if(a==="-delete")i.push({type:"delete"});else{if(a.startsWith("-"))return{expr:null,pathIndex:t,error:`find: unknown predicate '${a}'
|
|
4
|
+
`,actions:[]};if(n.length===0){t++;continue}break}t++}if(n.length===0)return{expr:null,pathIndex:t,actions:i};let m=_(n);return m.error?{expr:null,pathIndex:t,error:m.error,actions:i}:{expr:m.expr,pathIndex:t,actions:i}}function _(e){let s=0;function n(){let r=i();if(!r)return null;for(;s<e.length;){let c=e[s];if(c.type==="op"&&c.op==="or"){s++;let o=i();if(!o)return r;r={type:"or",left:r,right:o}}else break}return r}function i(){let r=t();if(!r)return null;for(;s<e.length;){let c=e[s];if(c.type==="op"&&c.op==="and"){s++;let o=t();if(!o)return r;r={type:"and",left:r,right:o}}else if(c.type==="expr"||c.type==="not"||c.type==="lparen"){let o=t();if(!o)return r;r={type:"and",left:r,right:o}}else break}return r}function t(){if(s<e.length&&e[s].type==="not"){s++;let r=t();return r?{type:"not",expr:r}:null}return m()}function m(){if(s>=e.length)return null;let r=e[s];if(r.type==="lparen"){s++;let c=n();return s<e.length&&e[s].type==="rparen"&&s++,c}return r.type==="expr"?(s++,r.expr):(r.type==="rparen",null)}return{expr:n()}}var K={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"]},U=new Set(["-name","-iname","-path","-ipath","-regex","-iregex","-type","-maxdepth","-mindepth","-mtime","-newer","-size","-perm"]),oe={name:"find",async execute(e,s){if(O(e))return I(K);let n=[],i=null,t=null,m=!1,a=!1;for(let l=0;l<e.length;l++){let p=e[l];if(p==="-maxdepth"&&l+1<e.length)a=!0,i=parseInt(e[++l],10);else if(p==="-mindepth"&&l+1<e.length)a=!0,t=parseInt(e[++l],10);else if(p==="-depth")a=!0,m=!0;else if(p==="-exec")for(a=!0,l++;l<e.length&&e[l]!==";"&&e[l]!=="+";)l++;else!p.startsWith("-")&&p!==";"&&p!=="+"&&p!=="("&&p!==")"&&p!=="\\("&&p!=="\\)"&&p!=="!"?a||n.push(p):U.has(p)?(a=!0,l++):(p.startsWith("-")||p==="("||p==="\\("||p==="!")&&(a=!0)}n.length===0&&n.push(".");let{expr:r,error:c,actions:o}=j(e,0);if(c)return{stdout:"",stderr:c,exitCode:1};let h=o.some(l=>l.type==="print"),b=o.length===0,y=[],Y=o.some(l=>l.type==="printf"),F=[],T="",D=0,V=G(r),k=new Map;for(let l of V){let p=s.fs.resolvePath(s.cwd,l);try{let g=await s.fs.stat(p);k.set(l,g.mtime?.getTime()??Date.now())}catch{}}for(let l of n){l.length>1&&l.endsWith("/")&&(l=l.slice(0,-1));let p=s.fs.resolvePath(s.cwd,l);try{await s.fs.stat(p)}catch{T+=`find: ${l}: No such file or directory
|
|
5
|
+
`,D=1;continue}async function g(u,d){if(i!==null&&d>i)return;let f;try{f=await s.fs.stat(u)}catch{return}if(!f)return;let E;u===p?E=l.split("/").pop()||l:E=u.split("/").pop()||"";let $=u===p?l:l==="."?`./${u.slice(p==="/"?p.length:p.length+1)}`:l+u.slice(p.length),M=null;f.isDirectory&&(M=await s.fs.readdir(u));let R=f.isFile?f.size===0:M!==null&&M.length===0,C=()=>{let x=t===null||d>=t,v=!1;if(x&&r!==null){let J={name:E,relativePath:$,isFile:f.isFile,isDirectory:f.isDirectory,isEmpty:R,mtime:f.mtime?.getTime()??Date.now(),size:f.size??0,mode:f.mode??420,newerRefTimes:k},z=w(r,J);x=z.matches,h?v=z.printed:v=x}else x&&(v=!0);v&&(y.push($),Y&&F.push({path:$,name:E,size:f.size??0,mtime:f.mtime?.getTime()??Date.now(),mode:f.mode??420,isDirectory:f.isDirectory,depth:d,startingPoint:l}))},A=async()=>{if(M!==null)for(let P of M){let x=u==="/"?`/${P}`:`${u}/${P}`;await g(x,d+1)}},W=!1;if(!m&&r!==null){let P={name:E,relativePath:$,isFile:f.isFile,isDirectory:f.isDirectory,isEmpty:R,mtime:f.mtime?.getTime()??Date.now(),size:f.size??0,mode:f.mode??420,newerRefTimes:k};W=w(r,P).pruned}m?(await A(),C()):(C(),W||await A())}await g(p,0)}let S="";if(o.length>0)for(let l of o)switch(l.type){case"print":S+=y.length>0?`${y.join(`
|
|
6
6
|
`)}
|
|
7
|
-
`:"";break;case"print0":S+=y.length>0?`${y.join("\0")}\0`:"";break;case"delete":{let
|
|
8
|
-
`,D=1}}break}case"printf":for(let
|
|
9
|
-
`,exitCode:1};if(
|
|
7
|
+
`:"";break;case"print0":S+=y.length>0?`${y.join("\0")}\0`:"";break;case"delete":{let p=[...y].sort((g,u)=>u.length-g.length);for(let g of p){let u=s.fs.resolvePath(s.cwd,g);try{await s.fs.rm(u,{recursive:!1})}catch(d){let f=d instanceof Error?d.message:String(d);T+=`find: cannot delete '${g}': ${f}
|
|
8
|
+
`,D=1}}break}case"printf":for(let p of F)S+=q(l.format,p);break;case"exec":if(!s.exec)return{stdout:"",stderr:`find: -exec not supported in this context
|
|
9
|
+
`,exitCode:1};if(l.batchMode){let p=[];for(let d of l.command)d==="{}"?p.push(...y):p.push(d);let g=p.map(d=>`"${d}"`).join(" "),u=await s.exec(g,{cwd:s.cwd});S+=u.stdout,T+=u.stderr,u.exitCode!==0&&(D=u.exitCode)}else for(let p of y){let u=l.command.map(f=>f==="{}"?p:f).map(f=>`"${f}"`).join(" "),d=await s.exec(u,{cwd:s.cwd});S+=d.stdout,T+=d.stderr,d.exitCode!==0&&(D=d.exitCode)}break}else b&&(S=y.length>0?`${y.join(`
|
|
10
10
|
`)}
|
|
11
|
-
`:"");return{stdout:S,stderr:T,exitCode:D}}};function q(e,s){let n=H(e),
|
|
11
|
+
`:"");return{stdout:S,stderr:T,exitCode:D}}};function q(e,s){let n=H(e),i="",t=0;for(;t<n.length;)if(n[t]==="%"&&t+1<n.length){if(t++,n[t]==="%"){i+="%",t++;continue}let[m,a,r]=B(n,t);if(t+=r,t>=n.length){i+="%";break}let c=n[t],o;switch(c){case"f":o=s.name,t++;break;case"h":{let h=s.path.lastIndexOf("/");o=h>0?s.path.slice(0,h):".",t++;break}case"p":o=s.path,t++;break;case"P":{let h=s.startingPoint;s.path===h?o="":s.path.startsWith(`${h}/`)?o=s.path.slice(h.length+1):h==="."&&s.path.startsWith("./")?o=s.path.slice(2):o=s.path,t++;break}case"s":o=String(s.size),t++;break;case"d":o=String(s.depth),t++;break;case"m":o=(s.mode&511).toString(8),t++;break;case"M":o=Q(s.mode,s.isDirectory),t++;break;case"t":{let h=new Date(s.mtime);o=X(h),t++;break}case"T":{if(t+1<n.length){let h=n[t+1],b=new Date(s.mtime);o=Z(b,h),t+=2}else o="%T",t++;break}default:i+=`%${m!==0||a!==-1?`${m}.${a}`:""}${c}`,t++;continue}i+=L(o,m,a)}else i+=n[t],t++;return i}function Q(e,s){let n=e&511,i=s?"d":"-";return i+=n&256?"r":"-",i+=n&128?"w":"-",i+=n&64?"x":"-",i+=n&32?"r":"-",i+=n&16?"w":"-",i+=n&8?"x":"-",i+=n&4?"r":"-",i+=n&2?"w":"-",i+=n&1?"x":"-",i}function X(e){let s=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],i=s[e.getDay()],t=n[e.getMonth()],m=String(e.getDate()).padStart(2," "),a=String(e.getHours()).padStart(2,"0"),r=String(e.getMinutes()).padStart(2,"0"),c=String(e.getSeconds()).padStart(2,"0"),o=e.getFullYear();return`${i} ${t} ${m} ${a}:${r}:${c} ${o}`}function Z(e,s){switch(s){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${s}`}}export{oe as findCommand};
|
package/dist/bin/shell/shell.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as U,b as X,c as G,d as ee,e as J,f as k,g as F,h as me,i as z,j as oe,k as Be}from"./chunks/chunk-NWWB2XRE.js";import{a as Y}from"./chunks/chunk-4VDEBYW7.js";import"./chunks/chunk-SJXDWN5X.js";import*as Mn from"node:fs";import*as Bn from"node:readline";var hr=[{name:"echo",load:async()=>(await import("./chunks/echo-HKLPYMNC.js")).echoCommand},{name:"cat",load:async()=>(await import("./chunks/cat-XILYL7NW.js")).catCommand},{name:"printf",load:async()=>(await import("./chunks/printf-2JFCUFOA.js")).printfCommand},{name:"ls",load:async()=>(await import("./chunks/ls-GU5227KE.js")).lsCommand},{name:"mkdir",load:async()=>(await import("./chunks/mkdir-4OYU22AA.js")).mkdirCommand},{name:"touch",load:async()=>(await import("./chunks/touch-3ZANYAXI.js")).touchCommand},{name:"rm",load:async()=>(await import("./chunks/rm-R4M647EC.js")).rmCommand},{name:"cp",load:async()=>(await import("./chunks/cp-HES4UN7K.js")).cpCommand},{name:"mv",load:async()=>(await import("./chunks/mv-H3S4FEWR.js")).mvCommand},{name:"ln",load:async()=>(await import("./chunks/ln-RUR4ALOJ.js")).lnCommand},{name:"chmod",load:async()=>(await import("./chunks/chmod-EXWX4N7Y.js")).chmodCommand},{name:"pwd",load:async()=>(await import("./chunks/pwd-T5Q3JEBO.js")).pwdCommand},{name:"readlink",load:async()=>(await import("./chunks/readlink-M44TLMFS.js")).readlinkCommand},{name:"head",load:async()=>(await import("./chunks/head-YGMY3DHE.js")).headCommand},{name:"tail",load:async()=>(await import("./chunks/tail-BYPLMYMZ.js")).tailCommand},{name:"wc",load:async()=>(await import("./chunks/wc-NBMNJDZL.js")).wcCommand},{name:"stat",load:async()=>(await import("./chunks/stat-CR2INBC2.js")).statCommand},{name:"grep",load:async()=>(await import("./chunks/grep-BEZRXAWL.js")).grepCommand},{name:"fgrep",load:async()=>(await import("./chunks/grep-BEZRXAWL.js")).fgrepCommand},{name:"egrep",load:async()=>(await import("./chunks/grep-BEZRXAWL.js")).egrepCommand},{name:"sed",load:async()=>(await import("./chunks/sed-QLLAZYHH.js")).sedCommand},{name:"awk",load:async()=>(await import("./chunks/awk2-A73ZNFXJ.js")).awkCommand2},{name:"sort",load:async()=>(await import("./chunks/sort-JL33INQB.js")).sortCommand},{name:"uniq",load:async()=>(await import("./chunks/uniq-F5NP3LLU.js")).uniqCommand},{name:"comm",load:async()=>(await import("./chunks/comm-KY3COLF5.js")).commCommand},{name:"cut",load:async()=>(await import("./chunks/cut-JSIPAKOX.js")).cutCommand},{name:"paste",load:async()=>(await import("./chunks/paste-HHCFASL4.js")).pasteCommand},{name:"tr",load:async()=>(await import("./chunks/tr-E66N7IS2.js")).trCommand},{name:"tee",load:async()=>(await import("./chunks/tee-HOMRRC3X.js")).teeCommand},{name:"find",load:async()=>(await import("./chunks/find-D3ZC5DXH.js")).findCommand},{name:"basename",load:async()=>(await import("./chunks/basename-IYEP3AMY.js")).basenameCommand},{name:"dirname",load:async()=>(await import("./chunks/dirname-UTCUUILN.js")).dirnameCommand},{name:"tree",load:async()=>(await import("./chunks/tree-EE2PYIMV.js")).treeCommand},{name:"du",load:async()=>(await import("./chunks/du-2JU3PUTM.js")).duCommand},{name:"env",load:async()=>(await import("./chunks/env-2SBJNP7X.js")).envCommand},{name:"printenv",load:async()=>(await import("./chunks/env-2SBJNP7X.js")).printenvCommand},{name:"alias",load:async()=>(await import("./chunks/alias-ZAQAKC5X.js")).aliasCommand},{name:"unalias",load:async()=>(await import("./chunks/alias-ZAQAKC5X.js")).unaliasCommand},{name:"history",load:async()=>(await import("./chunks/history-OGBCIAR5.js")).historyCommand},{name:"xargs",load:async()=>(await import("./chunks/xargs-EMY5BOJ2.js")).xargsCommand},{name:"true",load:async()=>(await import("./chunks/true-OWPVS7U4.js")).trueCommand},{name:"false",load:async()=>(await import("./chunks/true-OWPVS7U4.js")).falseCommand},{name:"clear",load:async()=>(await import("./chunks/clear-2APRIRCF.js")).clearCommand},{name:"bash",load:async()=>(await import("./chunks/bash-WZYHIZP6.js")).bashCommand},{name:"sh",load:async()=>(await import("./chunks/bash-WZYHIZP6.js")).shCommand},{name:"jq",load:async()=>(await import("./chunks/jq-TRAUXD47.js")).jqCommand},{name:"base64",load:async()=>(await import("./chunks/base64-JPITV4MD.js")).base64Command},{name:"diff",load:async()=>(await import("./chunks/diff-W4JRNHXW.js")).diffCommand},{name:"date",load:async()=>(await import("./chunks/date-CU4J7GHI.js")).dateCommand},{name:"sleep",load:async()=>(await import("./chunks/sleep-OJPODQGM.js")).sleepCommand},{name:"timeout",load:async()=>(await import("./chunks/timeout-MYKG34DQ.js")).timeoutCommand},{name:"seq",load:async()=>(await import("./chunks/seq-GJMQM7SP.js")).seqCommand},{name:"expr",load:async()=>(await import("./chunks/expr-M74QZQ6C.js")).exprCommand},{name:"md5sum",load:async()=>(await import("./chunks/md5sum-C7WDEYN5.js")).md5sumCommand},{name:"sha1sum",load:async()=>(await import("./chunks/sha1sum-WKCGV66X.js")).sha1sumCommand},{name:"sha256sum",load:async()=>(await import("./chunks/sha256sum-3ZDGP5WC.js")).sha256sumCommand},{name:"file",load:async()=>(await import("./chunks/file-QPD3U2H7.js")).fileCommand},{name:"html-to-markdown",load:async()=>(await import("./chunks/html-to-markdown-HTGML4TH.js")).htmlToMarkdownCommand},{name:"help",load:async()=>(await import("./chunks/help-UEF7LW7F.js")).helpCommand},{name:"which",load:async()=>(await import("./chunks/which-6MRG2UCF.js")).whichCommand},{name:"tac",load:async()=>(await import("./chunks/tac-F4GC3MAI.js")).tac},{name:"hostname",load:async()=>(await import("./chunks/hostname-CV7CGKRN.js")).hostname},{name:"od",load:async()=>(await import("./chunks/od-TXTSFFJY.js")).od}],zn=[{name:"curl",load:async()=>(await import("./chunks/curl-BN5M3BUX.js")).curlCommand}],mr=new Map;function pr(t){return{name:t.name,async execute(e,n){let r=mr.get(t.name);return r||(r=await t.load(),mr.set(t.name,r)),r.execute(e,n)}}}function yr(t){return(t?hr.filter(n=>t.includes(n.name)):hr).map(pr)}function Er(){return zn.map(pr)}function wr(t){return"load"in t&&typeof t.load=="function"}function gr(t){let e=null;return{name:t.name,async execute(n,r){return e||(e=await t.load()),e.execute(n,r)}}}var Un=new TextEncoder,Gn=new TextDecoder;function Ae(t,e){if(t instanceof Uint8Array)return t;switch(e){case"base64":return Uint8Array.from(atob(t),n=>n.charCodeAt(0));case"hex":{let n=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2)n[r/2]=parseInt(t.slice(r,r+2),16);return n}case"binary":case"latin1":return Uint8Array.from(t,n=>n.charCodeAt(0));default:return Un.encode(t)}}function ze(t,e){switch(e){case"base64":return btoa(String.fromCharCode(...t));case"hex":return Array.from(t).map(n=>n.toString(16).padStart(2,"0")).join("");case"binary":case"latin1":return String.fromCharCode(...t);default:return Gn.decode(t)}}function ae(t){if(t!=null)return typeof t=="string"?t:t.encoding??void 0}var Ue=new TextEncoder;function Hn(t){return typeof t=="object"&&t!==null&&!(t instanceof Uint8Array)&&"content"in t}var Pe=class{data=new Map;constructor(e){if(this.data.set("/",{type:"directory",mode:493,mtime:new Date}),e)for(let[n,r]of Object.entries(e))Hn(r)?this.writeFileSync(n,r.content,void 0,{mode:r.mode,mtime:r.mtime}):this.writeFileSync(n,r)}normalizePath(e){if(!e||e==="/")return"/";let n=e.endsWith("/")&&e!=="/"?e.slice(0,-1):e;n.startsWith("/")||(n=`/${n}`);let r=n.split("/").filter(o=>o&&o!=="."),s=[];for(let o of r)o===".."?s.pop():s.push(o);return`/${s.join("/")}`||"/"}dirname(e){let n=this.normalizePath(e);if(n==="/")return"/";let r=n.lastIndexOf("/");return r===0?"/":n.slice(0,r)}ensureParentDirs(e){let n=this.dirname(e);n!=="/"&&(this.data.has(n)||(this.ensureParentDirs(n),this.data.set(n,{type:"directory",mode:493,mtime:new Date})))}writeFileSync(e,n,r,s){let o=this.normalizePath(e);this.ensureParentDirs(o);let i=ae(r),a=Ae(n,i);this.data.set(o,{type:"file",content:a,mode:s?.mode??420,mtime:s?.mtime??new Date})}async readFile(e,n){let r=await this.readFileBuffer(e),s=ae(n);return ze(r,s)}async readFileBuffer(e){let n=this.normalizePath(e),r=this.data.get(n),s=n;if(!r)throw new Error(`ENOENT: no such file or directory, open '${e}'`);let o=new Set;for(;r&&r.type==="symlink";){if(o.has(s))throw new Error(`ELOOP: too many levels of symbolic links, open '${e}'`);o.add(s),s=this.resolveSymlink(s,r.target),r=this.data.get(s)}if(!r)throw new Error(`ENOENT: no such file or directory, open '${e}'`);if(r.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${e}'`);return r.content instanceof Uint8Array?r.content:Ue.encode(r.content)}async writeFile(e,n,r){this.writeFileSync(e,n,r)}async appendFile(e,n,r){let s=this.normalizePath(e),o=this.data.get(s);if(o&&o.type==="directory")throw new Error(`EISDIR: illegal operation on a directory, write '${e}'`);let i=ae(r),a=Ae(n,i);if(o?.type==="file"){let l=o.content instanceof Uint8Array?o.content:Ue.encode(o.content),c=new Uint8Array(l.length+a.length);c.set(l),c.set(a,l.length),this.data.set(s,{type:"file",content:c,mode:o.mode,mtime:new Date})}else this.writeFileSync(e,n,r)}async exists(e){return this.data.has(this.normalizePath(e))}async stat(e){let n=this.normalizePath(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, stat '${e}'`);if(r.type==="symlink"){let o=this.resolveSymlink(n,r.target),i=this.data.get(o);if(!i)throw new Error(`ENOENT: no such file or directory, stat '${e}'`);r=i}let s=0;return r.type==="file"&&r.content&&(r.content instanceof Uint8Array?s=r.content.length:s=Ue.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:s,mtime:r.mtime||new Date}}async lstat(e){let n=this.normalizePath(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, lstat '${e}'`);if(r.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:r.mode,size:r.target.length,mtime:r.mtime||new Date};let s=0;return r.type==="file"&&r.content&&(r.content instanceof Uint8Array?s=r.content.length:s=Ue.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:s,mtime:r.mtime||new Date}}resolveSymlink(e,n){if(n.startsWith("/"))return this.normalizePath(n);let r=this.dirname(e);return this.normalizePath(r==="/"?`/${n}`:`${r}/${n}`)}async mkdir(e,n){this.mkdirSync(e,n)}mkdirSync(e,n){let r=this.normalizePath(e);if(this.data.has(r)){if(this.data.get(r)?.type==="file")throw new Error(`EEXIST: file already exists, mkdir '${e}'`);if(!n?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${e}'`);return}let s=this.dirname(r);if(s!=="/"&&!this.data.has(s))if(n?.recursive)this.mkdirSync(s,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${e}'`);this.data.set(r,{type:"directory",mode:493,mtime:new Date})}async readdir(e){let n=this.normalizePath(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);if(r.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${e}'`);let s=n==="/"?"/":`${n}/`,o=[];for(let i of this.data.keys())if(i!==n&&i.startsWith(s)){let l=i.slice(s.length).split("/")[0];l&&!o.includes(l)&&o.push(l)}return o.sort()}async rm(e,n){let r=this.normalizePath(e),s=this.data.get(r);if(!s){if(n?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${e}'`)}if(s.type==="directory"){let o=await this.readdir(r);if(o.length>0){if(!n?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${e}'`);for(let i of o){let a=r==="/"?`/${i}`:`${r}/${i}`;await this.rm(a,n)}}}this.data.delete(r)}async cp(e,n,r){let s=this.normalizePath(e),o=this.normalizePath(n),i=this.data.get(s);if(!i)throw new Error(`ENOENT: no such file or directory, cp '${e}'`);if(i.type==="file")this.ensureParentDirs(o),this.data.set(o,{...i});else if(i.type==="directory"){if(!r?.recursive)throw new Error(`EISDIR: is a directory, cp '${e}'`);await this.mkdir(o,{recursive:!0});let a=await this.readdir(s);for(let l of a){let c=s==="/"?`/${l}`:`${s}/${l}`,f=o==="/"?`/${l}`:`${o}/${l}`;await this.cp(c,f,r)}}}async mv(e,n){await this.cp(e,n,{recursive:!0}),await this.rm(e,{recursive:!0})}getAllPaths(){return Array.from(this.data.keys())}resolvePath(e,n){if(n.startsWith("/"))return this.normalizePath(n);let r=e==="/"?`/${n}`:`${e}/${n}`;return this.normalizePath(r)}async chmod(e,n){let r=this.normalizePath(e),s=this.data.get(r);if(!s)throw new Error(`ENOENT: no such file or directory, chmod '${e}'`);s.mode=n}async symlink(e,n){let r=this.normalizePath(n);if(this.data.has(r))throw new Error(`EEXIST: file already exists, symlink '${n}'`);this.ensureParentDirs(r),this.data.set(r,{type:"symlink",target:e,mode:511,mtime:new Date})}async link(e,n){let r=this.normalizePath(e),s=this.normalizePath(n),o=this.data.get(r);if(!o)throw new Error(`ENOENT: no such file or directory, link '${e}'`);if(o.type!=="file")throw new Error(`EPERM: operation not permitted, link '${e}'`);if(this.data.has(s))throw new Error(`EEXIST: file already exists, link '${n}'`);this.ensureParentDirs(s),this.data.set(s,{type:"file",content:o.content,mode:o.mode,mtime:o.mtime})}async readlink(e){let n=this.normalizePath(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, readlink '${e}'`);if(r.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${e}'`);return r.target}};var Ar="5.1.0(1)-release",Sr="Linux version 5.15.0-generic (just-bash) #1 SMP PREEMPT";function Ie(){return{pid:process.pid,ppid:process.ppid,uid:process.getuid?.()??1e3,gid:process.getgid?.()??1e3}}function xr(){let{pid:t,ppid:e,uid:n,gid:r}=Ie();return`Name: bash
|
|
2
|
+
import{a as U,b as X,c as G,d as ee,e as J,f as k,g as F,h as me,i as z,j as oe,k as Be}from"./chunks/chunk-NWWB2XRE.js";import{a as Y}from"./chunks/chunk-4VDEBYW7.js";import"./chunks/chunk-SJXDWN5X.js";import*as Mn from"node:fs";import*as Bn from"node:readline";var hr=[{name:"echo",load:async()=>(await import("./chunks/echo-HKLPYMNC.js")).echoCommand},{name:"cat",load:async()=>(await import("./chunks/cat-XILYL7NW.js")).catCommand},{name:"printf",load:async()=>(await import("./chunks/printf-2JFCUFOA.js")).printfCommand},{name:"ls",load:async()=>(await import("./chunks/ls-GU5227KE.js")).lsCommand},{name:"mkdir",load:async()=>(await import("./chunks/mkdir-4OYU22AA.js")).mkdirCommand},{name:"touch",load:async()=>(await import("./chunks/touch-3ZANYAXI.js")).touchCommand},{name:"rm",load:async()=>(await import("./chunks/rm-R4M647EC.js")).rmCommand},{name:"cp",load:async()=>(await import("./chunks/cp-HES4UN7K.js")).cpCommand},{name:"mv",load:async()=>(await import("./chunks/mv-H3S4FEWR.js")).mvCommand},{name:"ln",load:async()=>(await import("./chunks/ln-RUR4ALOJ.js")).lnCommand},{name:"chmod",load:async()=>(await import("./chunks/chmod-EXWX4N7Y.js")).chmodCommand},{name:"pwd",load:async()=>(await import("./chunks/pwd-T5Q3JEBO.js")).pwdCommand},{name:"readlink",load:async()=>(await import("./chunks/readlink-M44TLMFS.js")).readlinkCommand},{name:"head",load:async()=>(await import("./chunks/head-YGMY3DHE.js")).headCommand},{name:"tail",load:async()=>(await import("./chunks/tail-BYPLMYMZ.js")).tailCommand},{name:"wc",load:async()=>(await import("./chunks/wc-NBMNJDZL.js")).wcCommand},{name:"stat",load:async()=>(await import("./chunks/stat-CR2INBC2.js")).statCommand},{name:"grep",load:async()=>(await import("./chunks/grep-BEZRXAWL.js")).grepCommand},{name:"fgrep",load:async()=>(await import("./chunks/grep-BEZRXAWL.js")).fgrepCommand},{name:"egrep",load:async()=>(await import("./chunks/grep-BEZRXAWL.js")).egrepCommand},{name:"sed",load:async()=>(await import("./chunks/sed-QLLAZYHH.js")).sedCommand},{name:"awk",load:async()=>(await import("./chunks/awk2-A73ZNFXJ.js")).awkCommand2},{name:"sort",load:async()=>(await import("./chunks/sort-JL33INQB.js")).sortCommand},{name:"uniq",load:async()=>(await import("./chunks/uniq-F5NP3LLU.js")).uniqCommand},{name:"comm",load:async()=>(await import("./chunks/comm-KY3COLF5.js")).commCommand},{name:"cut",load:async()=>(await import("./chunks/cut-JSIPAKOX.js")).cutCommand},{name:"paste",load:async()=>(await import("./chunks/paste-HHCFASL4.js")).pasteCommand},{name:"tr",load:async()=>(await import("./chunks/tr-E66N7IS2.js")).trCommand},{name:"tee",load:async()=>(await import("./chunks/tee-HOMRRC3X.js")).teeCommand},{name:"find",load:async()=>(await import("./chunks/find-TRBVCSI6.js")).findCommand},{name:"basename",load:async()=>(await import("./chunks/basename-IYEP3AMY.js")).basenameCommand},{name:"dirname",load:async()=>(await import("./chunks/dirname-UTCUUILN.js")).dirnameCommand},{name:"tree",load:async()=>(await import("./chunks/tree-EE2PYIMV.js")).treeCommand},{name:"du",load:async()=>(await import("./chunks/du-2JU3PUTM.js")).duCommand},{name:"env",load:async()=>(await import("./chunks/env-2SBJNP7X.js")).envCommand},{name:"printenv",load:async()=>(await import("./chunks/env-2SBJNP7X.js")).printenvCommand},{name:"alias",load:async()=>(await import("./chunks/alias-ZAQAKC5X.js")).aliasCommand},{name:"unalias",load:async()=>(await import("./chunks/alias-ZAQAKC5X.js")).unaliasCommand},{name:"history",load:async()=>(await import("./chunks/history-OGBCIAR5.js")).historyCommand},{name:"xargs",load:async()=>(await import("./chunks/xargs-EMY5BOJ2.js")).xargsCommand},{name:"true",load:async()=>(await import("./chunks/true-OWPVS7U4.js")).trueCommand},{name:"false",load:async()=>(await import("./chunks/true-OWPVS7U4.js")).falseCommand},{name:"clear",load:async()=>(await import("./chunks/clear-2APRIRCF.js")).clearCommand},{name:"bash",load:async()=>(await import("./chunks/bash-WZYHIZP6.js")).bashCommand},{name:"sh",load:async()=>(await import("./chunks/bash-WZYHIZP6.js")).shCommand},{name:"jq",load:async()=>(await import("./chunks/jq-TRAUXD47.js")).jqCommand},{name:"base64",load:async()=>(await import("./chunks/base64-JPITV4MD.js")).base64Command},{name:"diff",load:async()=>(await import("./chunks/diff-W4JRNHXW.js")).diffCommand},{name:"date",load:async()=>(await import("./chunks/date-CU4J7GHI.js")).dateCommand},{name:"sleep",load:async()=>(await import("./chunks/sleep-OJPODQGM.js")).sleepCommand},{name:"timeout",load:async()=>(await import("./chunks/timeout-MYKG34DQ.js")).timeoutCommand},{name:"seq",load:async()=>(await import("./chunks/seq-GJMQM7SP.js")).seqCommand},{name:"expr",load:async()=>(await import("./chunks/expr-M74QZQ6C.js")).exprCommand},{name:"md5sum",load:async()=>(await import("./chunks/md5sum-C7WDEYN5.js")).md5sumCommand},{name:"sha1sum",load:async()=>(await import("./chunks/sha1sum-WKCGV66X.js")).sha1sumCommand},{name:"sha256sum",load:async()=>(await import("./chunks/sha256sum-3ZDGP5WC.js")).sha256sumCommand},{name:"file",load:async()=>(await import("./chunks/file-QPD3U2H7.js")).fileCommand},{name:"html-to-markdown",load:async()=>(await import("./chunks/html-to-markdown-HTGML4TH.js")).htmlToMarkdownCommand},{name:"help",load:async()=>(await import("./chunks/help-UEF7LW7F.js")).helpCommand},{name:"which",load:async()=>(await import("./chunks/which-6MRG2UCF.js")).whichCommand},{name:"tac",load:async()=>(await import("./chunks/tac-F4GC3MAI.js")).tac},{name:"hostname",load:async()=>(await import("./chunks/hostname-CV7CGKRN.js")).hostname},{name:"od",load:async()=>(await import("./chunks/od-TXTSFFJY.js")).od}],zn=[{name:"curl",load:async()=>(await import("./chunks/curl-BN5M3BUX.js")).curlCommand}],mr=new Map;function pr(t){return{name:t.name,async execute(e,n){let r=mr.get(t.name);return r||(r=await t.load(),mr.set(t.name,r)),r.execute(e,n)}}}function yr(t){return(t?hr.filter(n=>t.includes(n.name)):hr).map(pr)}function Er(){return zn.map(pr)}function wr(t){return"load"in t&&typeof t.load=="function"}function gr(t){let e=null;return{name:t.name,async execute(n,r){return e||(e=await t.load()),e.execute(n,r)}}}var Un=new TextEncoder,Gn=new TextDecoder;function Ae(t,e){if(t instanceof Uint8Array)return t;switch(e){case"base64":return Uint8Array.from(atob(t),n=>n.charCodeAt(0));case"hex":{let n=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2)n[r/2]=parseInt(t.slice(r,r+2),16);return n}case"binary":case"latin1":return Uint8Array.from(t,n=>n.charCodeAt(0));default:return Un.encode(t)}}function ze(t,e){switch(e){case"base64":return btoa(String.fromCharCode(...t));case"hex":return Array.from(t).map(n=>n.toString(16).padStart(2,"0")).join("");case"binary":case"latin1":return String.fromCharCode(...t);default:return Gn.decode(t)}}function ae(t){if(t!=null)return typeof t=="string"?t:t.encoding??void 0}var Ue=new TextEncoder;function Hn(t){return typeof t=="object"&&t!==null&&!(t instanceof Uint8Array)&&"content"in t}var Pe=class{data=new Map;constructor(e){if(this.data.set("/",{type:"directory",mode:493,mtime:new Date}),e)for(let[n,r]of Object.entries(e))Hn(r)?this.writeFileSync(n,r.content,void 0,{mode:r.mode,mtime:r.mtime}):this.writeFileSync(n,r)}normalizePath(e){if(!e||e==="/")return"/";let n=e.endsWith("/")&&e!=="/"?e.slice(0,-1):e;n.startsWith("/")||(n=`/${n}`);let r=n.split("/").filter(o=>o&&o!=="."),s=[];for(let o of r)o===".."?s.pop():s.push(o);return`/${s.join("/")}`||"/"}dirname(e){let n=this.normalizePath(e);if(n==="/")return"/";let r=n.lastIndexOf("/");return r===0?"/":n.slice(0,r)}ensureParentDirs(e){let n=this.dirname(e);n!=="/"&&(this.data.has(n)||(this.ensureParentDirs(n),this.data.set(n,{type:"directory",mode:493,mtime:new Date})))}writeFileSync(e,n,r,s){let o=this.normalizePath(e);this.ensureParentDirs(o);let i=ae(r),a=Ae(n,i);this.data.set(o,{type:"file",content:a,mode:s?.mode??420,mtime:s?.mtime??new Date})}async readFile(e,n){let r=await this.readFileBuffer(e),s=ae(n);return ze(r,s)}async readFileBuffer(e){let n=this.normalizePath(e),r=this.data.get(n),s=n;if(!r)throw new Error(`ENOENT: no such file or directory, open '${e}'`);let o=new Set;for(;r&&r.type==="symlink";){if(o.has(s))throw new Error(`ELOOP: too many levels of symbolic links, open '${e}'`);o.add(s),s=this.resolveSymlink(s,r.target),r=this.data.get(s)}if(!r)throw new Error(`ENOENT: no such file or directory, open '${e}'`);if(r.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${e}'`);return r.content instanceof Uint8Array?r.content:Ue.encode(r.content)}async writeFile(e,n,r){this.writeFileSync(e,n,r)}async appendFile(e,n,r){let s=this.normalizePath(e),o=this.data.get(s);if(o&&o.type==="directory")throw new Error(`EISDIR: illegal operation on a directory, write '${e}'`);let i=ae(r),a=Ae(n,i);if(o?.type==="file"){let l=o.content instanceof Uint8Array?o.content:Ue.encode(o.content),c=new Uint8Array(l.length+a.length);c.set(l),c.set(a,l.length),this.data.set(s,{type:"file",content:c,mode:o.mode,mtime:new Date})}else this.writeFileSync(e,n,r)}async exists(e){return this.data.has(this.normalizePath(e))}async stat(e){let n=this.normalizePath(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, stat '${e}'`);if(r.type==="symlink"){let o=this.resolveSymlink(n,r.target),i=this.data.get(o);if(!i)throw new Error(`ENOENT: no such file or directory, stat '${e}'`);r=i}let s=0;return r.type==="file"&&r.content&&(r.content instanceof Uint8Array?s=r.content.length:s=Ue.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:s,mtime:r.mtime||new Date}}async lstat(e){let n=this.normalizePath(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, lstat '${e}'`);if(r.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:r.mode,size:r.target.length,mtime:r.mtime||new Date};let s=0;return r.type==="file"&&r.content&&(r.content instanceof Uint8Array?s=r.content.length:s=Ue.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:s,mtime:r.mtime||new Date}}resolveSymlink(e,n){if(n.startsWith("/"))return this.normalizePath(n);let r=this.dirname(e);return this.normalizePath(r==="/"?`/${n}`:`${r}/${n}`)}async mkdir(e,n){this.mkdirSync(e,n)}mkdirSync(e,n){let r=this.normalizePath(e);if(this.data.has(r)){if(this.data.get(r)?.type==="file")throw new Error(`EEXIST: file already exists, mkdir '${e}'`);if(!n?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${e}'`);return}let s=this.dirname(r);if(s!=="/"&&!this.data.has(s))if(n?.recursive)this.mkdirSync(s,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${e}'`);this.data.set(r,{type:"directory",mode:493,mtime:new Date})}async readdir(e){let n=this.normalizePath(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);if(r.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${e}'`);let s=n==="/"?"/":`${n}/`,o=[];for(let i of this.data.keys())if(i!==n&&i.startsWith(s)){let l=i.slice(s.length).split("/")[0];l&&!o.includes(l)&&o.push(l)}return o.sort()}async rm(e,n){let r=this.normalizePath(e),s=this.data.get(r);if(!s){if(n?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${e}'`)}if(s.type==="directory"){let o=await this.readdir(r);if(o.length>0){if(!n?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${e}'`);for(let i of o){let a=r==="/"?`/${i}`:`${r}/${i}`;await this.rm(a,n)}}}this.data.delete(r)}async cp(e,n,r){let s=this.normalizePath(e),o=this.normalizePath(n),i=this.data.get(s);if(!i)throw new Error(`ENOENT: no such file or directory, cp '${e}'`);if(i.type==="file")this.ensureParentDirs(o),this.data.set(o,{...i});else if(i.type==="directory"){if(!r?.recursive)throw new Error(`EISDIR: is a directory, cp '${e}'`);await this.mkdir(o,{recursive:!0});let a=await this.readdir(s);for(let l of a){let c=s==="/"?`/${l}`:`${s}/${l}`,f=o==="/"?`/${l}`:`${o}/${l}`;await this.cp(c,f,r)}}}async mv(e,n){await this.cp(e,n,{recursive:!0}),await this.rm(e,{recursive:!0})}getAllPaths(){return Array.from(this.data.keys())}resolvePath(e,n){if(n.startsWith("/"))return this.normalizePath(n);let r=e==="/"?`/${n}`:`${e}/${n}`;return this.normalizePath(r)}async chmod(e,n){let r=this.normalizePath(e),s=this.data.get(r);if(!s)throw new Error(`ENOENT: no such file or directory, chmod '${e}'`);s.mode=n}async symlink(e,n){let r=this.normalizePath(n);if(this.data.has(r))throw new Error(`EEXIST: file already exists, symlink '${n}'`);this.ensureParentDirs(r),this.data.set(r,{type:"symlink",target:e,mode:511,mtime:new Date})}async link(e,n){let r=this.normalizePath(e),s=this.normalizePath(n),o=this.data.get(r);if(!o)throw new Error(`ENOENT: no such file or directory, link '${e}'`);if(o.type!=="file")throw new Error(`EPERM: operation not permitted, link '${e}'`);if(this.data.has(s))throw new Error(`EEXIST: file already exists, link '${n}'`);this.ensureParentDirs(s),this.data.set(s,{type:"file",content:o.content,mode:o.mode,mtime:o.mtime})}async readlink(e){let n=this.normalizePath(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, readlink '${e}'`);if(r.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${e}'`);return r.target}};var Ar="5.1.0(1)-release",Sr="Linux version 5.15.0-generic (just-bash) #1 SMP PREEMPT";function Ie(){return{pid:process.pid,ppid:process.ppid,uid:process.getuid?.()??1e3,gid:process.getgid?.()??1e3}}function xr(){let{pid:t,ppid:e,uid:n,gid:r}=Ie();return`Name: bash
|
|
3
3
|
State: R (running)
|
|
4
4
|
Pid: ${t}
|
|
5
5
|
PPid: ${e}
|
package/dist/bundle/ai/index.js
CHANGED
|
@@ -305,8 +305,8 @@ Try 'comm --help' for more information.
|
|
|
305
305
|
`,exitCode:1};let a=pa(o[0]),c=o.length>1?pa(o[1]):"",l=e.stdin,u=p=>{let d=a.includes(p);return n?!d:d},f="";if(s)for(let p of l)u(p)||(f+=p);else if(i&&o.length===1){let p="";for(let d of l)u(d)&&d===p||(f+=d,p=d)}else{if(n){let p=c.length>0?c[c.length-1]:"";for(let d of l)a.includes(d)?f+=d:f+=p}else{let p=new Map;for(let d=0;d<a.length;d++){let h=d<c.length?c[d]:c[c.length-1];p.set(a[d],h)}for(let d of l)f+=p.get(d)??d}if(i){let p="",d="";for(let h of f)c.includes(h)&&h===d||(p+=h,d=h);f=p}}return{stdout:f,stderr:"",exitCode:0}}}});var ma={};$(ma,{teeCommand:()=>zd});var Hd,jd,zd,ya=A(()=>{"use strict";fe();_();Hd={name:"tee",summary:"read from stdin and write to stdout and files",usage:"tee [OPTION]... [FILE]...",options:["-a, --append append to the given FILEs, do not overwrite"," --help display this help and exit"]},jd={append:{short:"a",long:"append",type:"boolean"}},zd={name:"tee",async execute(t,e){if(I(t))return N(Hd);let r=G("tee",t,jd);if(!r.ok)return r.error;let{append:n}=r.result.flags,s=r.result.positional,i=e.stdin,o="",a=0;for(let c of s)try{let l=e.fs.resolvePath(e.cwd,c);n?await e.fs.appendFile(l,i):await e.fs.writeFile(l,i)}catch{o+=`tee: ${c}: No such file or directory
|
|
306
306
|
`,a=1}return{stdout:i,stderr:o,exitCode:a}}}});function tt(t,e){switch(t.type){case"name":return{matches:$e(e.name,t.pattern,t.ignoreCase),pruned:!1,printed:!1};case"path":return{matches:$e(e.relativePath,t.pattern,t.ignoreCase),pruned:!1,printed:!1};case"regex":try{let r=t.ignoreCase?"i":"";return{matches:new RegExp(t.pattern,r).test(e.relativePath),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return t.fileType==="f"?{matches:e.isFile,pruned:!1,printed:!1}:t.fileType==="d"?{matches:e.isDirectory,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"empty":return{matches:e.isEmpty,pruned:!1,printed:!1};case"mtime":{let n=(Date.now()-e.mtime)/(1e3*60*60*24),s;return t.comparison==="more"?s=n>t.days:t.comparison==="less"?s=n<t.days:s=Math.floor(n)===t.days,{matches:s,pruned:!1,printed:!1}}case"newer":{let r=e.newerRefTimes.get(t.refPath);return r===void 0?{matches:!1,pruned:!1,printed:!1}:{matches:e.mtime>r,pruned:!1,printed:!1}}case"size":{let r=t.value;switch(t.unit){case"c":r=t.value;break;case"k":r=t.value*1024;break;case"M":r=t.value*1024*1024;break;case"G":r=t.value*1024*1024*1024;break;case"b":r=t.value*512;break}let n;return t.comparison==="more"?n=e.size>r:t.comparison==="less"?n=e.size<r:t.unit==="b"?n=Math.ceil(e.size/512)===t.value:n=e.size===r,{matches:n,pruned:!1,printed:!1}}case"perm":{let r=e.mode&511,n=t.mode&511,s;return t.matchType==="exact"?s=r===n:t.matchType==="all"?s=(r&n)===n:s=(r&n)!==0,{matches:s,pruned:!1,printed:!1}}case"prune":return{matches:!0,pruned:!0,printed:!1};case"print":return{matches:!0,pruned:!1,printed:!0};case"not":{let r=tt(t.expr,e);return{matches:!r.matches,pruned:r.pruned,printed:!1}}case"and":{let r=tt(t.left,e);if(!r.matches)return{matches:!1,pruned:r.pruned,printed:!1};let n=tt(t.right,e);return{matches:n.matches,pruned:r.pruned||n.pruned,printed:r.printed||n.printed}}case"or":{let r=tt(t.left,e);if(r.matches)return r;let n=tt(t.right,e);return{matches:n.matches,pruned:r.pruned||n.pruned,printed:n.printed}}}}function ga(t){let e=[],r=n=>{n&&(n.type==="newer"?e.push(n.refPath):n.type==="not"?r(n.expr):(n.type==="and"||n.type==="or")&&(r(n.left),r(n.right)))};return r(t),e}var xa=A(()=>{"use strict";Pn()});function wa(t,e){let r=[],n=[],s=e;for(;s<t.length;){let o=t[s];if(o==="("||o==="\\("){r.push({type:"lparen"}),s++;continue}if(o===")"||o==="\\)"){r.push({type:"rparen"}),s++;continue}if(o==="-name"&&s+1<t.length)r.push({type:"expr",expr:{type:"name",pattern:t[++s]}});else if(o==="-iname"&&s+1<t.length)r.push({type:"expr",expr:{type:"name",pattern:t[++s],ignoreCase:!0}});else if(o==="-path"&&s+1<t.length)r.push({type:"expr",expr:{type:"path",pattern:t[++s]}});else if(o==="-ipath"&&s+1<t.length)r.push({type:"expr",expr:{type:"path",pattern:t[++s],ignoreCase:!0}});else if(o==="-regex"&&s+1<t.length)r.push({type:"expr",expr:{type:"regex",pattern:t[++s]}});else if(o==="-iregex"&&s+1<t.length)r.push({type:"expr",expr:{type:"regex",pattern:t[++s],ignoreCase:!0}});else if(o==="-type"&&s+1<t.length){let a=t[++s];if(a==="f"||a==="d")r.push({type:"expr",expr:{type:"type",fileType:a}});else return{expr:null,pathIndex:s,error:`find: Unknown argument to -type: ${a}
|
|
307
307
|
`,actions:[]}}else if(o==="-empty")r.push({type:"expr",expr:{type:"empty"}});else if(o==="-mtime"&&s+1<t.length){let a=t[++s],c="exact",l=a;a.startsWith("+")?(c="more",l=a.slice(1)):a.startsWith("-")&&(c="less",l=a.slice(1));let u=parseInt(l,10);Number.isNaN(u)||r.push({type:"expr",expr:{type:"mtime",days:u,comparison:c}})}else if(o==="-newer"&&s+1<t.length){let a=t[++s];r.push({type:"expr",expr:{type:"newer",refPath:a}})}else if(o==="-size"&&s+1<t.length){let a=t[++s],c="exact",l=a;a.startsWith("+")?(c="more",l=a.slice(1)):a.startsWith("-")&&(c="less",l=a.slice(1));let u=l.match(/^(\d+)([ckMGb])?$/);if(u){let f=parseInt(u[1],10),p=u[2]||"b";r.push({type:"expr",expr:{type:"size",value:f,unit:p,comparison:c}})}}else if(o==="-perm"&&s+1<t.length){let a=t[++s],c="exact",l=a;a.startsWith("-")?(c="all",l=a.slice(1)):a.startsWith("/")&&(c="any",l=a.slice(1));let u=parseInt(l,8);Number.isNaN(u)||r.push({type:"expr",expr:{type:"perm",mode:u,matchType:c}})}else if(o==="-prune")r.push({type:"expr",expr:{type:"prune"}});else if(o==="-not"||o==="!")r.push({type:"not"});else if(o==="-o"||o==="-or")r.push({type:"op",op:"or"});else if(o==="-a"||o==="-and")r.push({type:"op",op:"and"});else if(o==="-maxdepth"||o==="-mindepth")s++;else if(o!=="-depth")if(o==="-exec"){let a=[];for(s++;s<t.length&&t[s]!==";"&&t[s]!=="+";)a.push(t[s]),s++;if(s>=t.length)return{expr:null,pathIndex:s,error:"find: missing argument to `-exec'\n",actions:[]};let c=t[s]==="+";n.push({type:"exec",command:a,batchMode:c})}else if(o==="-print")r.push({type:"expr",expr:{type:"print"}}),n.push({type:"print"});else if(o==="-print0")n.push({type:"print0"});else if(o==="-printf"&&s+1<t.length){let a=t[++s];n.push({type:"printf",format:a})}else if(o==="-delete")n.push({type:"delete"});else{if(o.startsWith("-"))return{expr:null,pathIndex:s,error:`find: unknown predicate '${o}'
|
|
308
|
-
`,actions:[]};if(r.length===0){s++;continue}break}s++}if(r.length===0)return{expr:null,pathIndex:s,actions:n};let i=Gd(r);return i.error?{expr:null,pathIndex:s,error:i.error,actions:n}:{expr:i.expr,pathIndex:s,actions:n}}function Gd(t){let e=0;function r(){let a=n();if(!a)return null;for(;e<t.length;){let c=t[e];if(c.type==="op"&&c.op==="or"){e++;let l=n();if(!l)return a;a={type:"or",left:a,right:l}}else break}return a}function n(){let a=s();if(!a)return null;for(;e<t.length;){let c=t[e];if(c.type==="op"&&c.op==="and"){e++;let l=s();if(!l)return a;a={type:"and",left:a,right:l}}else if(c.type==="expr"||c.type==="not"||c.type==="lparen"){let l=s();if(!l)return a;a={type:"and",left:a,right:l}}else break}return a}function s(){if(e<t.length&&t[e].type==="not"){e++;let a=s();return a?{type:"not",expr:a}:null}return i()}function i(){if(e>=t.length)return null;let a=t[e];if(a.type==="lparen"){e++;let c=r();return e<t.length&&t[e].type==="rparen"&&e++,c}return a.type==="expr"?(e++,a.expr):(a.type==="rparen",null)}return{expr:r()}}var Ea=A(()=>{"use strict"});var ba={};$(ba,{findCommand:()=>Kd});function Zd(t,e){let r=xr(t),n="",s=0;for(;s<r.length;)if(r[s]==="%"&&s+1<r.length){if(s++,r[s]==="%"){n+="%",s++;continue}let[i,o,a]=Ii(r,s);if(s+=a,s>=r.length){n+="%";break}let c=r[s],l;switch(c){case"f":l=e.name,s++;break;case"h":{let u=e.path.lastIndexOf("/");l=u>0?e.path.slice(0,u):".",s++;break}case"p":l=e.path,s++;break;case"P":{let u=e.startingPoint;e.path===u?l="":e.path.startsWith(`${u}/`)?l=e.path.slice(u.length+1):u==="."&&e.path.startsWith("./")?l=e.path.slice(2):l=e.path,s++;break}case"s":l=String(e.size),s++;break;case"d":l=String(e.depth),s++;break;case"m":l=(e.mode&511).toString(8),s++;break;case"M":l=Qd(e.mode,e.isDirectory),s++;break;case"t":{let u=new Date(e.mtime);l=Xd(u),s++;break}case"T":{if(s+1<r.length){let u=r[s+1],f=new Date(e.mtime);l=Jd(f,u),s+=2}else l="%T",s++;break}default:n+=`%${i!==0||o!==-1?`${i}.${o}`:""}${c}`,s++;continue}n+=gr(l,i,o)}else n+=r[s],s++;return n}function Qd(t,e){let r=t&511,n=e?"d":"-";return n+=r&256?"r":"-",n+=r&128?"w":"-",n+=r&64?"x":"-",n+=r&32?"r":"-",n+=r&16?"w":"-",n+=r&8?"x":"-",n+=r&4?"r":"-",n+=r&2?"w":"-",n+=r&1?"x":"-",n}function Xd(t){let e=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],n=e[t.getDay()],s=r[t.getMonth()],i=String(t.getDate()).padStart(2," "),o=String(t.getHours()).padStart(2,"0"),a=String(t.getMinutes()).padStart(2,"0"),c=String(t.getSeconds()).padStart(2,"0"),l=t.getFullYear();return`${n} ${s} ${i} ${o}:${a}:${c} ${l}`}function Jd(t,e){switch(e){case"@":return String(t.getTime()/1e3);case"Y":return String(t.getFullYear());case"m":return String(t.getMonth()+1).padStart(2,"0");case"d":return String(t.getDate()).padStart(2,"0");case"H":return String(t.getHours()).padStart(2,"0");case"M":return String(t.getMinutes()).padStart(2,"0");case"S":return String(t.getSeconds()).padStart(2,"0");case"T":return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}`;case"F":return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`;default:return`%T${e}`}}var qd,Vd,Kd,Sa=A(()=>{"use strict";_();Rn();xa();Ea();qd={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"]},Vd=new Set(["-name","-iname","-path","-ipath","-regex","-iregex","-type","-maxdepth","-mindepth","-mtime","-newer","-size","-perm"]),Kd={name:"find",async execute(t,e){if(I(t))return N(qd);let r=[],n=null,s=null,i=!1,o=!1;for(let S=0;S<t.length;S++){let C=t[S];if(C==="-maxdepth"&&S+1<t.length)o=!0,n=parseInt(t[++S],10);else if(C==="-mindepth"&&S+1<t.length)o=!0,s=parseInt(t[++S],10);else if(C==="-depth")o=!0,i=!0;else if(C==="-exec")for(o=!0,S++;S<t.length&&t[S]!==";"&&t[S]!=="+";)S++;else!C.startsWith("-")&&C!==";"&&C!=="+"&&C!=="("&&C!==")"&&C!=="\\("&&C!=="\\)"&&C!=="!"?o||r.push(C):Vd.has(C)?(o=!0,S++):(C.startsWith("-")||C==="("||C==="\\("||C==="!")&&(o=!0)}r.length===0&&r.push(".");let{expr:a,error:c,actions:l}=wa(t,0);if(c)return{stdout:"",stderr:c,exitCode:1};let u=l.some(S=>S.type==="print"),f=l.length===0,p=[],d=l.some(S=>S.type==="printf"),h=[],g="",y=0,w=ga(a),E=new Map;for(let S of w){let C=e.fs.resolvePath(e.cwd,S);try{let O=await e.fs.stat(C);E.set(S,O.mtime?.getTime()??Date.now())}catch{}}for(let S of r){let C=e.fs.resolvePath(e.cwd,S);try{await e.fs.stat(C)}catch{g+=`find: ${S}: No such file or directory
|
|
309
|
-
`,y=1;continue}async function O(D,F){if(n!==null&&F>n)return;let U;try{U=await e.fs.stat(D)}catch{return}if(!U)return;let te;D===C?te=S.split("/").pop()||S:te=D.split("/").pop()||"";let de=D===C?S:S==="."?`./${D.slice(C.length+1)}`:S+D.slice(C.length),se=null;U.isDirectory&&(se=await e.fs.readdir(D));let Ce=U.isFile?U.size===0:se!==null&&se.length===0,ze=()=>{let H=s===null||F>=s,j=!1;if(H&&a!==null){let ke={name:te,relativePath:de,isFile:U.isFile,isDirectory:U.isDirectory,isEmpty:Ce,mtime:U.mtime?.getTime()??Date.now(),size:U.size??0,mode:U.mode??420,newerRefTimes:E},Be=tt(a,ke);H=Be.matches,u?j=Be.printed:j=H}else H&&(j=!0);j&&(p.push(de),d&&h.push({path:de,name:te,size:U.size??0,mtime:U.mtime?.getTime()??Date.now(),mode:U.mode??420,isDirectory:U.isDirectory,depth:F,startingPoint:S}))},Me=async()=>{if(se!==null)for(let _e of se){let H=D==="/"?`/${_e}`:`${D}/${_e}`;await O(H,F+1)}},yr=!1;if(!i&&a!==null){let _e={name:te,relativePath:de,isFile:U.isFile,isDirectory:U.isDirectory,isEmpty:Ce,mtime:U.mtime?.getTime()??Date.now(),size:U.size??0,mode:U.mode??420,newerRefTimes:E};yr=tt(a,_e).pruned}i?(await Me(),ze()):(ze(),yr||await Me())}await O(C,0)}let b="";if(l.length>0)for(let S of l)switch(S.type){case"print":b+=p.length>0?`${p.join(`
|
|
308
|
+
`,actions:[]};if(r.length===0){s++;continue}break}s++}if(r.length===0)return{expr:null,pathIndex:s,actions:n};let i=Gd(r);return i.error?{expr:null,pathIndex:s,error:i.error,actions:n}:{expr:i.expr,pathIndex:s,actions:n}}function Gd(t){let e=0;function r(){let a=n();if(!a)return null;for(;e<t.length;){let c=t[e];if(c.type==="op"&&c.op==="or"){e++;let l=n();if(!l)return a;a={type:"or",left:a,right:l}}else break}return a}function n(){let a=s();if(!a)return null;for(;e<t.length;){let c=t[e];if(c.type==="op"&&c.op==="and"){e++;let l=s();if(!l)return a;a={type:"and",left:a,right:l}}else if(c.type==="expr"||c.type==="not"||c.type==="lparen"){let l=s();if(!l)return a;a={type:"and",left:a,right:l}}else break}return a}function s(){if(e<t.length&&t[e].type==="not"){e++;let a=s();return a?{type:"not",expr:a}:null}return i()}function i(){if(e>=t.length)return null;let a=t[e];if(a.type==="lparen"){e++;let c=r();return e<t.length&&t[e].type==="rparen"&&e++,c}return a.type==="expr"?(e++,a.expr):(a.type==="rparen",null)}return{expr:r()}}var Ea=A(()=>{"use strict"});var ba={};$(ba,{findCommand:()=>Kd});function Zd(t,e){let r=xr(t),n="",s=0;for(;s<r.length;)if(r[s]==="%"&&s+1<r.length){if(s++,r[s]==="%"){n+="%",s++;continue}let[i,o,a]=Ii(r,s);if(s+=a,s>=r.length){n+="%";break}let c=r[s],l;switch(c){case"f":l=e.name,s++;break;case"h":{let u=e.path.lastIndexOf("/");l=u>0?e.path.slice(0,u):".",s++;break}case"p":l=e.path,s++;break;case"P":{let u=e.startingPoint;e.path===u?l="":e.path.startsWith(`${u}/`)?l=e.path.slice(u.length+1):u==="."&&e.path.startsWith("./")?l=e.path.slice(2):l=e.path,s++;break}case"s":l=String(e.size),s++;break;case"d":l=String(e.depth),s++;break;case"m":l=(e.mode&511).toString(8),s++;break;case"M":l=Qd(e.mode,e.isDirectory),s++;break;case"t":{let u=new Date(e.mtime);l=Xd(u),s++;break}case"T":{if(s+1<r.length){let u=r[s+1],f=new Date(e.mtime);l=Jd(f,u),s+=2}else l="%T",s++;break}default:n+=`%${i!==0||o!==-1?`${i}.${o}`:""}${c}`,s++;continue}n+=gr(l,i,o)}else n+=r[s],s++;return n}function Qd(t,e){let r=t&511,n=e?"d":"-";return n+=r&256?"r":"-",n+=r&128?"w":"-",n+=r&64?"x":"-",n+=r&32?"r":"-",n+=r&16?"w":"-",n+=r&8?"x":"-",n+=r&4?"r":"-",n+=r&2?"w":"-",n+=r&1?"x":"-",n}function Xd(t){let e=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],n=e[t.getDay()],s=r[t.getMonth()],i=String(t.getDate()).padStart(2," "),o=String(t.getHours()).padStart(2,"0"),a=String(t.getMinutes()).padStart(2,"0"),c=String(t.getSeconds()).padStart(2,"0"),l=t.getFullYear();return`${n} ${s} ${i} ${o}:${a}:${c} ${l}`}function Jd(t,e){switch(e){case"@":return String(t.getTime()/1e3);case"Y":return String(t.getFullYear());case"m":return String(t.getMonth()+1).padStart(2,"0");case"d":return String(t.getDate()).padStart(2,"0");case"H":return String(t.getHours()).padStart(2,"0");case"M":return String(t.getMinutes()).padStart(2,"0");case"S":return String(t.getSeconds()).padStart(2,"0");case"T":return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}`;case"F":return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`;default:return`%T${e}`}}var qd,Vd,Kd,Sa=A(()=>{"use strict";_();Rn();xa();Ea();qd={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"]},Vd=new Set(["-name","-iname","-path","-ipath","-regex","-iregex","-type","-maxdepth","-mindepth","-mtime","-newer","-size","-perm"]),Kd={name:"find",async execute(t,e){if(I(t))return N(qd);let r=[],n=null,s=null,i=!1,o=!1;for(let S=0;S<t.length;S++){let C=t[S];if(C==="-maxdepth"&&S+1<t.length)o=!0,n=parseInt(t[++S],10);else if(C==="-mindepth"&&S+1<t.length)o=!0,s=parseInt(t[++S],10);else if(C==="-depth")o=!0,i=!0;else if(C==="-exec")for(o=!0,S++;S<t.length&&t[S]!==";"&&t[S]!=="+";)S++;else!C.startsWith("-")&&C!==";"&&C!=="+"&&C!=="("&&C!==")"&&C!=="\\("&&C!=="\\)"&&C!=="!"?o||r.push(C):Vd.has(C)?(o=!0,S++):(C.startsWith("-")||C==="("||C==="\\("||C==="!")&&(o=!0)}r.length===0&&r.push(".");let{expr:a,error:c,actions:l}=wa(t,0);if(c)return{stdout:"",stderr:c,exitCode:1};let u=l.some(S=>S.type==="print"),f=l.length===0,p=[],d=l.some(S=>S.type==="printf"),h=[],g="",y=0,w=ga(a),E=new Map;for(let S of w){let C=e.fs.resolvePath(e.cwd,S);try{let O=await e.fs.stat(C);E.set(S,O.mtime?.getTime()??Date.now())}catch{}}for(let S of r){S.length>1&&S.endsWith("/")&&(S=S.slice(0,-1));let C=e.fs.resolvePath(e.cwd,S);try{await e.fs.stat(C)}catch{g+=`find: ${S}: No such file or directory
|
|
309
|
+
`,y=1;continue}async function O(D,F){if(n!==null&&F>n)return;let U;try{U=await e.fs.stat(D)}catch{return}if(!U)return;let te;D===C?te=S.split("/").pop()||S:te=D.split("/").pop()||"";let de=D===C?S:S==="."?`./${D.slice(C==="/"?C.length:C.length+1)}`:S+D.slice(C.length),se=null;U.isDirectory&&(se=await e.fs.readdir(D));let Ce=U.isFile?U.size===0:se!==null&&se.length===0,ze=()=>{let H=s===null||F>=s,j=!1;if(H&&a!==null){let ke={name:te,relativePath:de,isFile:U.isFile,isDirectory:U.isDirectory,isEmpty:Ce,mtime:U.mtime?.getTime()??Date.now(),size:U.size??0,mode:U.mode??420,newerRefTimes:E},Be=tt(a,ke);H=Be.matches,u?j=Be.printed:j=H}else H&&(j=!0);j&&(p.push(de),d&&h.push({path:de,name:te,size:U.size??0,mtime:U.mtime?.getTime()??Date.now(),mode:U.mode??420,isDirectory:U.isDirectory,depth:F,startingPoint:S}))},Me=async()=>{if(se!==null)for(let _e of se){let H=D==="/"?`/${_e}`:`${D}/${_e}`;await O(H,F+1)}},yr=!1;if(!i&&a!==null){let _e={name:te,relativePath:de,isFile:U.isFile,isDirectory:U.isDirectory,isEmpty:Ce,mtime:U.mtime?.getTime()??Date.now(),size:U.size??0,mode:U.mode??420,newerRefTimes:E};yr=tt(a,_e).pruned}i?(await Me(),ze()):(ze(),yr||await Me())}await O(C,0)}let b="";if(l.length>0)for(let S of l)switch(S.type){case"print":b+=p.length>0?`${p.join(`
|
|
310
310
|
`)}
|
|
311
311
|
`:"";break;case"print0":b+=p.length>0?`${p.join("\0")}\0`:"";break;case"delete":{let C=[...p].sort((O,D)=>D.length-O.length);for(let O of C){let D=e.fs.resolvePath(e.cwd,O);try{await e.fs.rm(D,{recursive:!1})}catch(F){let U=F instanceof Error?F.message:String(F);g+=`find: cannot delete '${O}': ${U}
|
|
312
312
|
`,y=1}}break}case"printf":for(let C of h)b+=Zd(S.format,C);break;case"exec":if(!e.exec)return{stdout:"",stderr:`find: -exec not supported in this context
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{a as N}from"./chunk-UJMN5NLH.js";import{a as L,b as B,c as H}from"./chunk-NWEGHOXL.js";import{a as I,b as O}from"./chunk-74CEPOFO.js";import"./chunk-2RUN43TJ.js";function w(e,s){switch(e.type){case"name":return{matches:N(s.name,e.pattern,e.ignoreCase),pruned:!1,printed:!1};case"path":return{matches:N(s.relativePath,e.pattern,e.ignoreCase),pruned:!1,printed:!1};case"regex":try{let n=e.ignoreCase?"i":"";return{matches:new RegExp(e.pattern,n).test(s.relativePath),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:s.isFile,pruned:!1,printed:!1}:e.fileType==="d"?{matches:s.isDirectory,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"empty":return{matches:s.isEmpty,pruned:!1,printed:!1};case"mtime":{let
|
|
2
|
-
`,actions:[]}}else if(a==="-empty")n.push({type:"expr",expr:{type:"empty"}});else if(a==="-mtime"&&t+1<e.length){let
|
|
3
|
-
`,actions:[]};if(n.length===0){t++;continue}break}t++}if(n.length===0)return{expr:null,pathIndex:t,actions:
|
|
4
|
-
`,D=1;continue}async function g(u,d){if(
|
|
1
|
+
import{a as N}from"./chunk-UJMN5NLH.js";import{a as L,b as B,c as H}from"./chunk-NWEGHOXL.js";import{a as I,b as O}from"./chunk-74CEPOFO.js";import"./chunk-2RUN43TJ.js";function w(e,s){switch(e.type){case"name":return{matches:N(s.name,e.pattern,e.ignoreCase),pruned:!1,printed:!1};case"path":return{matches:N(s.relativePath,e.pattern,e.ignoreCase),pruned:!1,printed:!1};case"regex":try{let n=e.ignoreCase?"i":"";return{matches:new RegExp(e.pattern,n).test(s.relativePath),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:s.isFile,pruned:!1,printed:!1}:e.fileType==="d"?{matches:s.isDirectory,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"empty":return{matches:s.isEmpty,pruned:!1,printed:!1};case"mtime":{let i=(Date.now()-s.mtime)/(1e3*60*60*24),t;return e.comparison==="more"?t=i>e.days:e.comparison==="less"?t=i<e.days:t=Math.floor(i)===e.days,{matches:t,pruned:!1,printed:!1}}case"newer":{let n=s.newerRefTimes.get(e.refPath);return n===void 0?{matches:!1,pruned:!1,printed:!1}:{matches:s.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 i;return e.comparison==="more"?i=s.size>n:e.comparison==="less"?i=s.size<n:e.unit==="b"?i=Math.ceil(s.size/512)===e.value:i=s.size===n,{matches:i,pruned:!1,printed:!1}}case"perm":{let n=s.mode&511,i=e.mode&511,t;return e.matchType==="exact"?t=n===i:e.matchType==="all"?t=(n&i)===i:t=(n&i)!==0,{matches:t,pruned:!1,printed:!1}}case"prune":return{matches:!0,pruned:!0,printed:!1};case"print":return{matches:!0,pruned:!1,printed:!0};case"not":{let n=w(e.expr,s);return{matches:!n.matches,pruned:n.pruned,printed:!1}}case"and":{let n=w(e.left,s);if(!n.matches)return{matches:!1,pruned:n.pruned,printed:!1};let i=w(e.right,s);return{matches:i.matches,pruned:n.pruned||i.pruned,printed:n.printed||i.printed}}case"or":{let n=w(e.left,s);if(n.matches)return n;let i=w(e.right,s);return{matches:i.matches,pruned:n.pruned||i.pruned,printed:i.printed}}}}function G(e){let s=[],n=i=>{i&&(i.type==="newer"?s.push(i.refPath):i.type==="not"?n(i.expr):(i.type==="and"||i.type==="or")&&(n(i.left),n(i.right)))};return n(e),s}function j(e,s){let n=[],i=[],t=s;for(;t<e.length;){let a=e[t];if(a==="("||a==="\\("){n.push({type:"lparen"}),t++;continue}if(a===")"||a==="\\)"){n.push({type:"rparen"}),t++;continue}if(a==="-name"&&t+1<e.length)n.push({type:"expr",expr:{type:"name",pattern:e[++t]}});else if(a==="-iname"&&t+1<e.length)n.push({type:"expr",expr:{type:"name",pattern:e[++t],ignoreCase:!0}});else if(a==="-path"&&t+1<e.length)n.push({type:"expr",expr:{type:"path",pattern:e[++t]}});else if(a==="-ipath"&&t+1<e.length)n.push({type:"expr",expr:{type:"path",pattern:e[++t],ignoreCase:!0}});else if(a==="-regex"&&t+1<e.length)n.push({type:"expr",expr:{type:"regex",pattern:e[++t]}});else if(a==="-iregex"&&t+1<e.length)n.push({type:"expr",expr:{type:"regex",pattern:e[++t],ignoreCase:!0}});else if(a==="-type"&&t+1<e.length){let r=e[++t];if(r==="f"||r==="d")n.push({type:"expr",expr:{type:"type",fileType:r}});else return{expr:null,pathIndex:t,error:`find: Unknown argument to -type: ${r}
|
|
2
|
+
`,actions:[]}}else if(a==="-empty")n.push({type:"expr",expr:{type:"empty"}});else if(a==="-mtime"&&t+1<e.length){let r=e[++t],c="exact",o=r;r.startsWith("+")?(c="more",o=r.slice(1)):r.startsWith("-")&&(c="less",o=r.slice(1));let h=parseInt(o,10);Number.isNaN(h)||n.push({type:"expr",expr:{type:"mtime",days:h,comparison:c}})}else if(a==="-newer"&&t+1<e.length){let r=e[++t];n.push({type:"expr",expr:{type:"newer",refPath:r}})}else if(a==="-size"&&t+1<e.length){let r=e[++t],c="exact",o=r;r.startsWith("+")?(c="more",o=r.slice(1)):r.startsWith("-")&&(c="less",o=r.slice(1));let h=o.match(/^(\d+)([ckMGb])?$/);if(h){let b=parseInt(h[1],10),y=h[2]||"b";n.push({type:"expr",expr:{type:"size",value:b,unit:y,comparison:c}})}}else if(a==="-perm"&&t+1<e.length){let r=e[++t],c="exact",o=r;r.startsWith("-")?(c="all",o=r.slice(1)):r.startsWith("/")&&(c="any",o=r.slice(1));let h=parseInt(o,8);Number.isNaN(h)||n.push({type:"expr",expr:{type:"perm",mode:h,matchType:c}})}else if(a==="-prune")n.push({type:"expr",expr:{type:"prune"}});else if(a==="-not"||a==="!")n.push({type:"not"});else if(a==="-o"||a==="-or")n.push({type:"op",op:"or"});else if(a==="-a"||a==="-and")n.push({type:"op",op:"and"});else if(a==="-maxdepth"||a==="-mindepth")t++;else if(a!=="-depth")if(a==="-exec"){let r=[];for(t++;t<e.length&&e[t]!==";"&&e[t]!=="+";)r.push(e[t]),t++;if(t>=e.length)return{expr:null,pathIndex:t,error:"find: missing argument to `-exec'\n",actions:[]};let c=e[t]==="+";i.push({type:"exec",command:r,batchMode:c})}else if(a==="-print")n.push({type:"expr",expr:{type:"print"}}),i.push({type:"print"});else if(a==="-print0")i.push({type:"print0"});else if(a==="-printf"&&t+1<e.length){let r=e[++t];i.push({type:"printf",format:r})}else if(a==="-delete")i.push({type:"delete"});else{if(a.startsWith("-"))return{expr:null,pathIndex:t,error:`find: unknown predicate '${a}'
|
|
3
|
+
`,actions:[]};if(n.length===0){t++;continue}break}t++}if(n.length===0)return{expr:null,pathIndex:t,actions:i};let m=_(n);return m.error?{expr:null,pathIndex:t,error:m.error,actions:i}:{expr:m.expr,pathIndex:t,actions:i}}function _(e){let s=0;function n(){let r=i();if(!r)return null;for(;s<e.length;){let c=e[s];if(c.type==="op"&&c.op==="or"){s++;let o=i();if(!o)return r;r={type:"or",left:r,right:o}}else break}return r}function i(){let r=t();if(!r)return null;for(;s<e.length;){let c=e[s];if(c.type==="op"&&c.op==="and"){s++;let o=t();if(!o)return r;r={type:"and",left:r,right:o}}else if(c.type==="expr"||c.type==="not"||c.type==="lparen"){let o=t();if(!o)return r;r={type:"and",left:r,right:o}}else break}return r}function t(){if(s<e.length&&e[s].type==="not"){s++;let r=t();return r?{type:"not",expr:r}:null}return m()}function m(){if(s>=e.length)return null;let r=e[s];if(r.type==="lparen"){s++;let c=n();return s<e.length&&e[s].type==="rparen"&&s++,c}return r.type==="expr"?(s++,r.expr):(r.type==="rparen",null)}return{expr:n()}}var K={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"]},U=new Set(["-name","-iname","-path","-ipath","-regex","-iregex","-type","-maxdepth","-mindepth","-mtime","-newer","-size","-perm"]),oe={name:"find",async execute(e,s){if(O(e))return I(K);let n=[],i=null,t=null,m=!1,a=!1;for(let l=0;l<e.length;l++){let p=e[l];if(p==="-maxdepth"&&l+1<e.length)a=!0,i=parseInt(e[++l],10);else if(p==="-mindepth"&&l+1<e.length)a=!0,t=parseInt(e[++l],10);else if(p==="-depth")a=!0,m=!0;else if(p==="-exec")for(a=!0,l++;l<e.length&&e[l]!==";"&&e[l]!=="+";)l++;else!p.startsWith("-")&&p!==";"&&p!=="+"&&p!=="("&&p!==")"&&p!=="\\("&&p!=="\\)"&&p!=="!"?a||n.push(p):U.has(p)?(a=!0,l++):(p.startsWith("-")||p==="("||p==="\\("||p==="!")&&(a=!0)}n.length===0&&n.push(".");let{expr:r,error:c,actions:o}=j(e,0);if(c)return{stdout:"",stderr:c,exitCode:1};let h=o.some(l=>l.type==="print"),b=o.length===0,y=[],Y=o.some(l=>l.type==="printf"),F=[],T="",D=0,V=G(r),k=new Map;for(let l of V){let p=s.fs.resolvePath(s.cwd,l);try{let g=await s.fs.stat(p);k.set(l,g.mtime?.getTime()??Date.now())}catch{}}for(let l of n){l.length>1&&l.endsWith("/")&&(l=l.slice(0,-1));let p=s.fs.resolvePath(s.cwd,l);try{await s.fs.stat(p)}catch{T+=`find: ${l}: No such file or directory
|
|
4
|
+
`,D=1;continue}async function g(u,d){if(i!==null&&d>i)return;let f;try{f=await s.fs.stat(u)}catch{return}if(!f)return;let E;u===p?E=l.split("/").pop()||l:E=u.split("/").pop()||"";let $=u===p?l:l==="."?`./${u.slice(p==="/"?p.length:p.length+1)}`:l+u.slice(p.length),M=null;f.isDirectory&&(M=await s.fs.readdir(u));let R=f.isFile?f.size===0:M!==null&&M.length===0,C=()=>{let x=t===null||d>=t,v=!1;if(x&&r!==null){let J={name:E,relativePath:$,isFile:f.isFile,isDirectory:f.isDirectory,isEmpty:R,mtime:f.mtime?.getTime()??Date.now(),size:f.size??0,mode:f.mode??420,newerRefTimes:k},z=w(r,J);x=z.matches,h?v=z.printed:v=x}else x&&(v=!0);v&&(y.push($),Y&&F.push({path:$,name:E,size:f.size??0,mtime:f.mtime?.getTime()??Date.now(),mode:f.mode??420,isDirectory:f.isDirectory,depth:d,startingPoint:l}))},A=async()=>{if(M!==null)for(let P of M){let x=u==="/"?`/${P}`:`${u}/${P}`;await g(x,d+1)}},W=!1;if(!m&&r!==null){let P={name:E,relativePath:$,isFile:f.isFile,isDirectory:f.isDirectory,isEmpty:R,mtime:f.mtime?.getTime()??Date.now(),size:f.size??0,mode:f.mode??420,newerRefTimes:k};W=w(r,P).pruned}m?(await A(),C()):(C(),W||await A())}await g(p,0)}let S="";if(o.length>0)for(let l of o)switch(l.type){case"print":S+=y.length>0?`${y.join(`
|
|
5
5
|
`)}
|
|
6
|
-
`:"";break;case"print0":S+=y.length>0?`${y.join("\0")}\0`:"";break;case"delete":{let
|
|
7
|
-
`,D=1}}break}case"printf":for(let
|
|
8
|
-
`,exitCode:1};if(
|
|
6
|
+
`:"";break;case"print0":S+=y.length>0?`${y.join("\0")}\0`:"";break;case"delete":{let p=[...y].sort((g,u)=>u.length-g.length);for(let g of p){let u=s.fs.resolvePath(s.cwd,g);try{await s.fs.rm(u,{recursive:!1})}catch(d){let f=d instanceof Error?d.message:String(d);T+=`find: cannot delete '${g}': ${f}
|
|
7
|
+
`,D=1}}break}case"printf":for(let p of F)S+=q(l.format,p);break;case"exec":if(!s.exec)return{stdout:"",stderr:`find: -exec not supported in this context
|
|
8
|
+
`,exitCode:1};if(l.batchMode){let p=[];for(let d of l.command)d==="{}"?p.push(...y):p.push(d);let g=p.map(d=>`"${d}"`).join(" "),u=await s.exec(g,{cwd:s.cwd});S+=u.stdout,T+=u.stderr,u.exitCode!==0&&(D=u.exitCode)}else for(let p of y){let u=l.command.map(f=>f==="{}"?p:f).map(f=>`"${f}"`).join(" "),d=await s.exec(u,{cwd:s.cwd});S+=d.stdout,T+=d.stderr,d.exitCode!==0&&(D=d.exitCode)}break}else b&&(S=y.length>0?`${y.join(`
|
|
9
9
|
`)}
|
|
10
|
-
`:"");return{stdout:S,stderr:T,exitCode:D}}};function q(e,s){let n=H(e),
|
|
10
|
+
`:"");return{stdout:S,stderr:T,exitCode:D}}};function q(e,s){let n=H(e),i="",t=0;for(;t<n.length;)if(n[t]==="%"&&t+1<n.length){if(t++,n[t]==="%"){i+="%",t++;continue}let[m,a,r]=B(n,t);if(t+=r,t>=n.length){i+="%";break}let c=n[t],o;switch(c){case"f":o=s.name,t++;break;case"h":{let h=s.path.lastIndexOf("/");o=h>0?s.path.slice(0,h):".",t++;break}case"p":o=s.path,t++;break;case"P":{let h=s.startingPoint;s.path===h?o="":s.path.startsWith(`${h}/`)?o=s.path.slice(h.length+1):h==="."&&s.path.startsWith("./")?o=s.path.slice(2):o=s.path,t++;break}case"s":o=String(s.size),t++;break;case"d":o=String(s.depth),t++;break;case"m":o=(s.mode&511).toString(8),t++;break;case"M":o=Q(s.mode,s.isDirectory),t++;break;case"t":{let h=new Date(s.mtime);o=X(h),t++;break}case"T":{if(t+1<n.length){let h=n[t+1],b=new Date(s.mtime);o=Z(b,h),t+=2}else o="%T",t++;break}default:i+=`%${m!==0||a!==-1?`${m}.${a}`:""}${c}`,t++;continue}i+=L(o,m,a)}else i+=n[t],t++;return i}function Q(e,s){let n=e&511,i=s?"d":"-";return i+=n&256?"r":"-",i+=n&128?"w":"-",i+=n&64?"x":"-",i+=n&32?"r":"-",i+=n&16?"w":"-",i+=n&8?"x":"-",i+=n&4?"r":"-",i+=n&2?"w":"-",i+=n&1?"x":"-",i}function X(e){let s=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],i=s[e.getDay()],t=n[e.getMonth()],m=String(e.getDate()).padStart(2," "),a=String(e.getHours()).padStart(2,"0"),r=String(e.getMinutes()).padStart(2,"0"),c=String(e.getSeconds()).padStart(2,"0"),o=e.getFullYear();return`${i} ${t} ${m} ${a}:${r}:${c} ${o}`}function Z(e,s){switch(s){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${s}`}}export{oe as findCommand};
|
package/dist/bundle/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as U,b as Y,c as G,d as te,e as J,f as k,g as W,h as ye,i as z,j as le,k as He}from"./chunks/chunk-CG2HXOFG.js";import{a as ce}from"./chunks/chunk-44UOCSGV.js";import"./chunks/chunk-2RUN43TJ.js";var St=[{name:"echo",load:async()=>(await import("./chunks/echo-WUKBESC7.js")).echoCommand},{name:"cat",load:async()=>(await import("./chunks/cat-47EP4IAV.js")).catCommand},{name:"printf",load:async()=>(await import("./chunks/printf-HBP44PXI.js")).printfCommand},{name:"ls",load:async()=>(await import("./chunks/ls-JGYJQA2Y.js")).lsCommand},{name:"mkdir",load:async()=>(await import("./chunks/mkdir-HA2FJX4O.js")).mkdirCommand},{name:"touch",load:async()=>(await import("./chunks/touch-FOE745V2.js")).touchCommand},{name:"rm",load:async()=>(await import("./chunks/rm-NF3FNLAY.js")).rmCommand},{name:"cp",load:async()=>(await import("./chunks/cp-37OVLNLD.js")).cpCommand},{name:"mv",load:async()=>(await import("./chunks/mv-7I62SB3I.js")).mvCommand},{name:"ln",load:async()=>(await import("./chunks/ln-XFYHBIFL.js")).lnCommand},{name:"chmod",load:async()=>(await import("./chunks/chmod-XJXFAD4M.js")).chmodCommand},{name:"pwd",load:async()=>(await import("./chunks/pwd-CEF235GL.js")).pwdCommand},{name:"readlink",load:async()=>(await import("./chunks/readlink-MQIMKDSA.js")).readlinkCommand},{name:"head",load:async()=>(await import("./chunks/head-6PAUYCDP.js")).headCommand},{name:"tail",load:async()=>(await import("./chunks/tail-QXKYHAML.js")).tailCommand},{name:"wc",load:async()=>(await import("./chunks/wc-GV5WUREX.js")).wcCommand},{name:"stat",load:async()=>(await import("./chunks/stat-FVFLDQGP.js")).statCommand},{name:"grep",load:async()=>(await import("./chunks/grep-ZJVDG3FA.js")).grepCommand},{name:"fgrep",load:async()=>(await import("./chunks/grep-ZJVDG3FA.js")).fgrepCommand},{name:"egrep",load:async()=>(await import("./chunks/grep-ZJVDG3FA.js")).egrepCommand},{name:"sed",load:async()=>(await import("./chunks/sed-H2RWPMTM.js")).sedCommand},{name:"awk",load:async()=>(await import("./chunks/awk2-QWBT4IFJ.js")).awkCommand2},{name:"sort",load:async()=>(await import("./chunks/sort-XODGFZC4.js")).sortCommand},{name:"uniq",load:async()=>(await import("./chunks/uniq-7PFWPNWK.js")).uniqCommand},{name:"comm",load:async()=>(await import("./chunks/comm-KSJ4BBRQ.js")).commCommand},{name:"cut",load:async()=>(await import("./chunks/cut-FIZRELKC.js")).cutCommand},{name:"paste",load:async()=>(await import("./chunks/paste-QBGVCQFT.js")).pasteCommand},{name:"tr",load:async()=>(await import("./chunks/tr-LMLGE4IE.js")).trCommand},{name:"tee",load:async()=>(await import("./chunks/tee-W5HCCBPO.js")).teeCommand},{name:"find",load:async()=>(await import("./chunks/find-R6LJIRBI.js")).findCommand},{name:"basename",load:async()=>(await import("./chunks/basename-5UVU5RXR.js")).basenameCommand},{name:"dirname",load:async()=>(await import("./chunks/dirname-U2KVUSQY.js")).dirnameCommand},{name:"tree",load:async()=>(await import("./chunks/tree-WBUGLVP5.js")).treeCommand},{name:"du",load:async()=>(await import("./chunks/du-KRAFOIQK.js")).duCommand},{name:"env",load:async()=>(await import("./chunks/env-MSPSPGCD.js")).envCommand},{name:"printenv",load:async()=>(await import("./chunks/env-MSPSPGCD.js")).printenvCommand},{name:"alias",load:async()=>(await import("./chunks/alias-JFIUWFGE.js")).aliasCommand},{name:"unalias",load:async()=>(await import("./chunks/alias-JFIUWFGE.js")).unaliasCommand},{name:"history",load:async()=>(await import("./chunks/history-SG6VRATI.js")).historyCommand},{name:"xargs",load:async()=>(await import("./chunks/xargs-NQBNFMCT.js")).xargsCommand},{name:"true",load:async()=>(await import("./chunks/true-6LGCG4EY.js")).trueCommand},{name:"false",load:async()=>(await import("./chunks/true-6LGCG4EY.js")).falseCommand},{name:"clear",load:async()=>(await import("./chunks/clear-XD3TJRVQ.js")).clearCommand},{name:"bash",load:async()=>(await import("./chunks/bash-BASUPKHJ.js")).bashCommand},{name:"sh",load:async()=>(await import("./chunks/bash-BASUPKHJ.js")).shCommand},{name:"jq",load:async()=>(await import("./chunks/jq-PO3DWIV2.js")).jqCommand},{name:"base64",load:async()=>(await import("./chunks/base64-TUA2XORD.js")).base64Command},{name:"diff",load:async()=>(await import("./chunks/diff-GLRVCAKJ.js")).diffCommand},{name:"date",load:async()=>(await import("./chunks/date-NN5C354M.js")).dateCommand},{name:"sleep",load:async()=>(await import("./chunks/sleep-AFN3PHJW.js")).sleepCommand},{name:"timeout",load:async()=>(await import("./chunks/timeout-XAA3N7CF.js")).timeoutCommand},{name:"seq",load:async()=>(await import("./chunks/seq-VKYIUOPJ.js")).seqCommand},{name:"expr",load:async()=>(await import("./chunks/expr-HYOCSWK6.js")).exprCommand},{name:"md5sum",load:async()=>(await import("./chunks/md5sum-PIH6F3O3.js")).md5sumCommand},{name:"sha1sum",load:async()=>(await import("./chunks/sha1sum-HVHNZSEC.js")).sha1sumCommand},{name:"sha256sum",load:async()=>(await import("./chunks/sha256sum-REOOJORK.js")).sha256sumCommand},{name:"file",load:async()=>(await import("./chunks/file-LQXX6P4Y.js")).fileCommand},{name:"html-to-markdown",load:async()=>(await import("./chunks/html-to-markdown-ZSZ34PAN.js")).htmlToMarkdownCommand},{name:"help",load:async()=>(await import("./chunks/help-5E6PYJWQ.js")).helpCommand},{name:"which",load:async()=>(await import("./chunks/which-KHFYPBWW.js")).whichCommand},{name:"tac",load:async()=>(await import("./chunks/tac-VIFKNLII.js")).tac},{name:"hostname",load:async()=>(await import("./chunks/hostname-K4BA3P6X.js")).hostname},{name:"od",load:async()=>(await import("./chunks/od-SOCTFI2F.js")).od}],wr=[{name:"curl",load:async()=>(await import("./chunks/curl-C43O5WQS.js")).curlCommand}],Er=new Map;function gr(t){return{name:t.name,async execute(e,n){let r=Er.get(t.name);return r||(r=await t.load(),Er.set(t.name,r)),r.execute(e,n)}}}function Gn(){return St.map(t=>t.name)}function Vn(){return wr.map(t=>t.name)}function Ar(t){return(t?St.filter(n=>t.includes(n.name)):St).map(gr)}function xr(){return wr.map(gr)}function Sr(t){return"load"in t&&typeof t.load=="function"}function Hn(t,e){return{name:t,execute:e}}function br(t){let e=null;return{name:t.name,async execute(n,r){return e||(e=await t.load()),e.execute(n,r)}}}var jn=new TextEncoder,Zn=new TextDecoder;function re(t,e){if(t instanceof Uint8Array)return t;switch(e){case"base64":return Uint8Array.from(atob(t),n=>n.charCodeAt(0));case"hex":{let n=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2)n[r/2]=parseInt(t.slice(r,r+2),16);return n}case"binary":case"latin1":return Uint8Array.from(t,n=>n.charCodeAt(0));default:return jn.encode(t)}}function be(t,e){switch(e){case"base64":return btoa(String.fromCharCode(...t));case"hex":return Array.from(t).map(n=>n.toString(16).padStart(2,"0")).join("");case"binary":case"latin1":return String.fromCharCode(...t);default:return Zn.decode(t)}}function Z(t){if(t!=null)return typeof t=="string"?t:t.encoding??void 0}var je=new TextEncoder;function qn(t){return typeof t=="object"&&t!==null&&!(t instanceof Uint8Array)&&"content"in t}var Ee=class{data=new Map;constructor(e){if(this.data.set("/",{type:"directory",mode:493,mtime:new Date}),e)for(let[n,r]of Object.entries(e))qn(r)?this.writeFileSync(n,r.content,void 0,{mode:r.mode,mtime:r.mtime}):this.writeFileSync(n,r)}normalizePath(e){if(!e||e==="/")return"/";let n=e.endsWith("/")&&e!=="/"?e.slice(0,-1):e;n.startsWith("/")||(n=`/${n}`);let r=n.split("/").filter(o=>o&&o!=="."),s=[];for(let o of r)o===".."?s.pop():s.push(o);return`/${s.join("/")}`||"/"}dirname(e){let n=this.normalizePath(e);if(n==="/")return"/";let r=n.lastIndexOf("/");return r===0?"/":n.slice(0,r)}ensureParentDirs(e){let n=this.dirname(e);n!=="/"&&(this.data.has(n)||(this.ensureParentDirs(n),this.data.set(n,{type:"directory",mode:493,mtime:new Date})))}writeFileSync(e,n,r,s){let o=this.normalizePath(e);this.ensureParentDirs(o);let i=Z(r),a=re(n,i);this.data.set(o,{type:"file",content:a,mode:s?.mode??420,mtime:s?.mtime??new Date})}async readFile(e,n){let r=await this.readFileBuffer(e),s=Z(n);return be(r,s)}async readFileBuffer(e){let n=this.normalizePath(e),r=this.data.get(n),s=n;if(!r)throw new Error(`ENOENT: no such file or directory, open '${e}'`);let o=new Set;for(;r&&r.type==="symlink";){if(o.has(s))throw new Error(`ELOOP: too many levels of symbolic links, open '${e}'`);o.add(s),s=this.resolveSymlink(s,r.target),r=this.data.get(s)}if(!r)throw new Error(`ENOENT: no such file or directory, open '${e}'`);if(r.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${e}'`);return r.content instanceof Uint8Array?r.content:je.encode(r.content)}async writeFile(e,n,r){this.writeFileSync(e,n,r)}async appendFile(e,n,r){let s=this.normalizePath(e),o=this.data.get(s);if(o&&o.type==="directory")throw new Error(`EISDIR: illegal operation on a directory, write '${e}'`);let i=Z(r),a=re(n,i);if(o?.type==="file"){let l=o.content instanceof Uint8Array?o.content:je.encode(o.content),c=new Uint8Array(l.length+a.length);c.set(l),c.set(a,l.length),this.data.set(s,{type:"file",content:c,mode:o.mode,mtime:new Date})}else this.writeFileSync(e,n,r)}async exists(e){return this.data.has(this.normalizePath(e))}async stat(e){let n=this.normalizePath(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, stat '${e}'`);if(r.type==="symlink"){let o=this.resolveSymlink(n,r.target),i=this.data.get(o);if(!i)throw new Error(`ENOENT: no such file or directory, stat '${e}'`);r=i}let s=0;return r.type==="file"&&r.content&&(r.content instanceof Uint8Array?s=r.content.length:s=je.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:s,mtime:r.mtime||new Date}}async lstat(e){let n=this.normalizePath(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, lstat '${e}'`);if(r.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:r.mode,size:r.target.length,mtime:r.mtime||new Date};let s=0;return r.type==="file"&&r.content&&(r.content instanceof Uint8Array?s=r.content.length:s=je.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:s,mtime:r.mtime||new Date}}resolveSymlink(e,n){if(n.startsWith("/"))return this.normalizePath(n);let r=this.dirname(e);return this.normalizePath(r==="/"?`/${n}`:`${r}/${n}`)}async mkdir(e,n){this.mkdirSync(e,n)}mkdirSync(e,n){let r=this.normalizePath(e);if(this.data.has(r)){if(this.data.get(r)?.type==="file")throw new Error(`EEXIST: file already exists, mkdir '${e}'`);if(!n?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${e}'`);return}let s=this.dirname(r);if(s!=="/"&&!this.data.has(s))if(n?.recursive)this.mkdirSync(s,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${e}'`);this.data.set(r,{type:"directory",mode:493,mtime:new Date})}async readdir(e){let n=this.normalizePath(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);if(r.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${e}'`);let s=n==="/"?"/":`${n}/`,o=[];for(let i of this.data.keys())if(i!==n&&i.startsWith(s)){let l=i.slice(s.length).split("/")[0];l&&!o.includes(l)&&o.push(l)}return o.sort()}async rm(e,n){let r=this.normalizePath(e),s=this.data.get(r);if(!s){if(n?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${e}'`)}if(s.type==="directory"){let o=await this.readdir(r);if(o.length>0){if(!n?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${e}'`);for(let i of o){let a=r==="/"?`/${i}`:`${r}/${i}`;await this.rm(a,n)}}}this.data.delete(r)}async cp(e,n,r){let s=this.normalizePath(e),o=this.normalizePath(n),i=this.data.get(s);if(!i)throw new Error(`ENOENT: no such file or directory, cp '${e}'`);if(i.type==="file")this.ensureParentDirs(o),this.data.set(o,{...i});else if(i.type==="directory"){if(!r?.recursive)throw new Error(`EISDIR: is a directory, cp '${e}'`);await this.mkdir(o,{recursive:!0});let a=await this.readdir(s);for(let l of a){let c=s==="/"?`/${l}`:`${s}/${l}`,f=o==="/"?`/${l}`:`${o}/${l}`;await this.cp(c,f,r)}}}async mv(e,n){await this.cp(e,n,{recursive:!0}),await this.rm(e,{recursive:!0})}getAllPaths(){return Array.from(this.data.keys())}resolvePath(e,n){if(n.startsWith("/"))return this.normalizePath(n);let r=e==="/"?`/${n}`:`${e}/${n}`;return this.normalizePath(r)}async chmod(e,n){let r=this.normalizePath(e),s=this.data.get(r);if(!s)throw new Error(`ENOENT: no such file or directory, chmod '${e}'`);s.mode=n}async symlink(e,n){let r=this.normalizePath(n);if(this.data.has(r))throw new Error(`EEXIST: file already exists, symlink '${n}'`);this.ensureParentDirs(r),this.data.set(r,{type:"symlink",target:e,mode:511,mtime:new Date})}async link(e,n){let r=this.normalizePath(e),s=this.normalizePath(n),o=this.data.get(r);if(!o)throw new Error(`ENOENT: no such file or directory, link '${e}'`);if(o.type!=="file")throw new Error(`EPERM: operation not permitted, link '${e}'`);if(this.data.has(s))throw new Error(`EEXIST: file already exists, link '${n}'`);this.ensureParentDirs(s),this.data.set(s,{type:"file",content:o.content,mode:o.mode,mtime:o.mtime})}async readlink(e){let n=this.normalizePath(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, readlink '${e}'`);if(r.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${e}'`);return r.target}};var Nr="5.1.0(1)-release",Cr="Linux version 5.15.0-generic (just-bash) #1 SMP PREEMPT";function Te(){return{pid:process.pid,ppid:process.ppid,uid:process.getuid?.()??1e3,gid:process.getgid?.()??1e3}}function $r(){let{pid:t,ppid:e,uid:n,gid:r}=Te();return`Name: bash
|
|
1
|
+
import{a as U,b as Y,c as G,d as te,e as J,f as k,g as W,h as ye,i as z,j as le,k as He}from"./chunks/chunk-CG2HXOFG.js";import{a as ce}from"./chunks/chunk-44UOCSGV.js";import"./chunks/chunk-2RUN43TJ.js";var St=[{name:"echo",load:async()=>(await import("./chunks/echo-WUKBESC7.js")).echoCommand},{name:"cat",load:async()=>(await import("./chunks/cat-47EP4IAV.js")).catCommand},{name:"printf",load:async()=>(await import("./chunks/printf-HBP44PXI.js")).printfCommand},{name:"ls",load:async()=>(await import("./chunks/ls-JGYJQA2Y.js")).lsCommand},{name:"mkdir",load:async()=>(await import("./chunks/mkdir-HA2FJX4O.js")).mkdirCommand},{name:"touch",load:async()=>(await import("./chunks/touch-FOE745V2.js")).touchCommand},{name:"rm",load:async()=>(await import("./chunks/rm-NF3FNLAY.js")).rmCommand},{name:"cp",load:async()=>(await import("./chunks/cp-37OVLNLD.js")).cpCommand},{name:"mv",load:async()=>(await import("./chunks/mv-7I62SB3I.js")).mvCommand},{name:"ln",load:async()=>(await import("./chunks/ln-XFYHBIFL.js")).lnCommand},{name:"chmod",load:async()=>(await import("./chunks/chmod-XJXFAD4M.js")).chmodCommand},{name:"pwd",load:async()=>(await import("./chunks/pwd-CEF235GL.js")).pwdCommand},{name:"readlink",load:async()=>(await import("./chunks/readlink-MQIMKDSA.js")).readlinkCommand},{name:"head",load:async()=>(await import("./chunks/head-6PAUYCDP.js")).headCommand},{name:"tail",load:async()=>(await import("./chunks/tail-QXKYHAML.js")).tailCommand},{name:"wc",load:async()=>(await import("./chunks/wc-GV5WUREX.js")).wcCommand},{name:"stat",load:async()=>(await import("./chunks/stat-FVFLDQGP.js")).statCommand},{name:"grep",load:async()=>(await import("./chunks/grep-ZJVDG3FA.js")).grepCommand},{name:"fgrep",load:async()=>(await import("./chunks/grep-ZJVDG3FA.js")).fgrepCommand},{name:"egrep",load:async()=>(await import("./chunks/grep-ZJVDG3FA.js")).egrepCommand},{name:"sed",load:async()=>(await import("./chunks/sed-H2RWPMTM.js")).sedCommand},{name:"awk",load:async()=>(await import("./chunks/awk2-QWBT4IFJ.js")).awkCommand2},{name:"sort",load:async()=>(await import("./chunks/sort-XODGFZC4.js")).sortCommand},{name:"uniq",load:async()=>(await import("./chunks/uniq-7PFWPNWK.js")).uniqCommand},{name:"comm",load:async()=>(await import("./chunks/comm-KSJ4BBRQ.js")).commCommand},{name:"cut",load:async()=>(await import("./chunks/cut-FIZRELKC.js")).cutCommand},{name:"paste",load:async()=>(await import("./chunks/paste-QBGVCQFT.js")).pasteCommand},{name:"tr",load:async()=>(await import("./chunks/tr-LMLGE4IE.js")).trCommand},{name:"tee",load:async()=>(await import("./chunks/tee-W5HCCBPO.js")).teeCommand},{name:"find",load:async()=>(await import("./chunks/find-GM7FJ4D3.js")).findCommand},{name:"basename",load:async()=>(await import("./chunks/basename-5UVU5RXR.js")).basenameCommand},{name:"dirname",load:async()=>(await import("./chunks/dirname-U2KVUSQY.js")).dirnameCommand},{name:"tree",load:async()=>(await import("./chunks/tree-WBUGLVP5.js")).treeCommand},{name:"du",load:async()=>(await import("./chunks/du-KRAFOIQK.js")).duCommand},{name:"env",load:async()=>(await import("./chunks/env-MSPSPGCD.js")).envCommand},{name:"printenv",load:async()=>(await import("./chunks/env-MSPSPGCD.js")).printenvCommand},{name:"alias",load:async()=>(await import("./chunks/alias-JFIUWFGE.js")).aliasCommand},{name:"unalias",load:async()=>(await import("./chunks/alias-JFIUWFGE.js")).unaliasCommand},{name:"history",load:async()=>(await import("./chunks/history-SG6VRATI.js")).historyCommand},{name:"xargs",load:async()=>(await import("./chunks/xargs-NQBNFMCT.js")).xargsCommand},{name:"true",load:async()=>(await import("./chunks/true-6LGCG4EY.js")).trueCommand},{name:"false",load:async()=>(await import("./chunks/true-6LGCG4EY.js")).falseCommand},{name:"clear",load:async()=>(await import("./chunks/clear-XD3TJRVQ.js")).clearCommand},{name:"bash",load:async()=>(await import("./chunks/bash-BASUPKHJ.js")).bashCommand},{name:"sh",load:async()=>(await import("./chunks/bash-BASUPKHJ.js")).shCommand},{name:"jq",load:async()=>(await import("./chunks/jq-PO3DWIV2.js")).jqCommand},{name:"base64",load:async()=>(await import("./chunks/base64-TUA2XORD.js")).base64Command},{name:"diff",load:async()=>(await import("./chunks/diff-GLRVCAKJ.js")).diffCommand},{name:"date",load:async()=>(await import("./chunks/date-NN5C354M.js")).dateCommand},{name:"sleep",load:async()=>(await import("./chunks/sleep-AFN3PHJW.js")).sleepCommand},{name:"timeout",load:async()=>(await import("./chunks/timeout-XAA3N7CF.js")).timeoutCommand},{name:"seq",load:async()=>(await import("./chunks/seq-VKYIUOPJ.js")).seqCommand},{name:"expr",load:async()=>(await import("./chunks/expr-HYOCSWK6.js")).exprCommand},{name:"md5sum",load:async()=>(await import("./chunks/md5sum-PIH6F3O3.js")).md5sumCommand},{name:"sha1sum",load:async()=>(await import("./chunks/sha1sum-HVHNZSEC.js")).sha1sumCommand},{name:"sha256sum",load:async()=>(await import("./chunks/sha256sum-REOOJORK.js")).sha256sumCommand},{name:"file",load:async()=>(await import("./chunks/file-LQXX6P4Y.js")).fileCommand},{name:"html-to-markdown",load:async()=>(await import("./chunks/html-to-markdown-ZSZ34PAN.js")).htmlToMarkdownCommand},{name:"help",load:async()=>(await import("./chunks/help-5E6PYJWQ.js")).helpCommand},{name:"which",load:async()=>(await import("./chunks/which-KHFYPBWW.js")).whichCommand},{name:"tac",load:async()=>(await import("./chunks/tac-VIFKNLII.js")).tac},{name:"hostname",load:async()=>(await import("./chunks/hostname-K4BA3P6X.js")).hostname},{name:"od",load:async()=>(await import("./chunks/od-SOCTFI2F.js")).od}],wr=[{name:"curl",load:async()=>(await import("./chunks/curl-C43O5WQS.js")).curlCommand}],Er=new Map;function gr(t){return{name:t.name,async execute(e,n){let r=Er.get(t.name);return r||(r=await t.load(),Er.set(t.name,r)),r.execute(e,n)}}}function Gn(){return St.map(t=>t.name)}function Vn(){return wr.map(t=>t.name)}function Ar(t){return(t?St.filter(n=>t.includes(n.name)):St).map(gr)}function xr(){return wr.map(gr)}function Sr(t){return"load"in t&&typeof t.load=="function"}function Hn(t,e){return{name:t,execute:e}}function br(t){let e=null;return{name:t.name,async execute(n,r){return e||(e=await t.load()),e.execute(n,r)}}}var jn=new TextEncoder,Zn=new TextDecoder;function re(t,e){if(t instanceof Uint8Array)return t;switch(e){case"base64":return Uint8Array.from(atob(t),n=>n.charCodeAt(0));case"hex":{let n=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2)n[r/2]=parseInt(t.slice(r,r+2),16);return n}case"binary":case"latin1":return Uint8Array.from(t,n=>n.charCodeAt(0));default:return jn.encode(t)}}function be(t,e){switch(e){case"base64":return btoa(String.fromCharCode(...t));case"hex":return Array.from(t).map(n=>n.toString(16).padStart(2,"0")).join("");case"binary":case"latin1":return String.fromCharCode(...t);default:return Zn.decode(t)}}function Z(t){if(t!=null)return typeof t=="string"?t:t.encoding??void 0}var je=new TextEncoder;function qn(t){return typeof t=="object"&&t!==null&&!(t instanceof Uint8Array)&&"content"in t}var Ee=class{data=new Map;constructor(e){if(this.data.set("/",{type:"directory",mode:493,mtime:new Date}),e)for(let[n,r]of Object.entries(e))qn(r)?this.writeFileSync(n,r.content,void 0,{mode:r.mode,mtime:r.mtime}):this.writeFileSync(n,r)}normalizePath(e){if(!e||e==="/")return"/";let n=e.endsWith("/")&&e!=="/"?e.slice(0,-1):e;n.startsWith("/")||(n=`/${n}`);let r=n.split("/").filter(o=>o&&o!=="."),s=[];for(let o of r)o===".."?s.pop():s.push(o);return`/${s.join("/")}`||"/"}dirname(e){let n=this.normalizePath(e);if(n==="/")return"/";let r=n.lastIndexOf("/");return r===0?"/":n.slice(0,r)}ensureParentDirs(e){let n=this.dirname(e);n!=="/"&&(this.data.has(n)||(this.ensureParentDirs(n),this.data.set(n,{type:"directory",mode:493,mtime:new Date})))}writeFileSync(e,n,r,s){let o=this.normalizePath(e);this.ensureParentDirs(o);let i=Z(r),a=re(n,i);this.data.set(o,{type:"file",content:a,mode:s?.mode??420,mtime:s?.mtime??new Date})}async readFile(e,n){let r=await this.readFileBuffer(e),s=Z(n);return be(r,s)}async readFileBuffer(e){let n=this.normalizePath(e),r=this.data.get(n),s=n;if(!r)throw new Error(`ENOENT: no such file or directory, open '${e}'`);let o=new Set;for(;r&&r.type==="symlink";){if(o.has(s))throw new Error(`ELOOP: too many levels of symbolic links, open '${e}'`);o.add(s),s=this.resolveSymlink(s,r.target),r=this.data.get(s)}if(!r)throw new Error(`ENOENT: no such file or directory, open '${e}'`);if(r.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${e}'`);return r.content instanceof Uint8Array?r.content:je.encode(r.content)}async writeFile(e,n,r){this.writeFileSync(e,n,r)}async appendFile(e,n,r){let s=this.normalizePath(e),o=this.data.get(s);if(o&&o.type==="directory")throw new Error(`EISDIR: illegal operation on a directory, write '${e}'`);let i=Z(r),a=re(n,i);if(o?.type==="file"){let l=o.content instanceof Uint8Array?o.content:je.encode(o.content),c=new Uint8Array(l.length+a.length);c.set(l),c.set(a,l.length),this.data.set(s,{type:"file",content:c,mode:o.mode,mtime:new Date})}else this.writeFileSync(e,n,r)}async exists(e){return this.data.has(this.normalizePath(e))}async stat(e){let n=this.normalizePath(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, stat '${e}'`);if(r.type==="symlink"){let o=this.resolveSymlink(n,r.target),i=this.data.get(o);if(!i)throw new Error(`ENOENT: no such file or directory, stat '${e}'`);r=i}let s=0;return r.type==="file"&&r.content&&(r.content instanceof Uint8Array?s=r.content.length:s=je.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:s,mtime:r.mtime||new Date}}async lstat(e){let n=this.normalizePath(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, lstat '${e}'`);if(r.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:r.mode,size:r.target.length,mtime:r.mtime||new Date};let s=0;return r.type==="file"&&r.content&&(r.content instanceof Uint8Array?s=r.content.length:s=je.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:s,mtime:r.mtime||new Date}}resolveSymlink(e,n){if(n.startsWith("/"))return this.normalizePath(n);let r=this.dirname(e);return this.normalizePath(r==="/"?`/${n}`:`${r}/${n}`)}async mkdir(e,n){this.mkdirSync(e,n)}mkdirSync(e,n){let r=this.normalizePath(e);if(this.data.has(r)){if(this.data.get(r)?.type==="file")throw new Error(`EEXIST: file already exists, mkdir '${e}'`);if(!n?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${e}'`);return}let s=this.dirname(r);if(s!=="/"&&!this.data.has(s))if(n?.recursive)this.mkdirSync(s,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${e}'`);this.data.set(r,{type:"directory",mode:493,mtime:new Date})}async readdir(e){let n=this.normalizePath(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);if(r.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${e}'`);let s=n==="/"?"/":`${n}/`,o=[];for(let i of this.data.keys())if(i!==n&&i.startsWith(s)){let l=i.slice(s.length).split("/")[0];l&&!o.includes(l)&&o.push(l)}return o.sort()}async rm(e,n){let r=this.normalizePath(e),s=this.data.get(r);if(!s){if(n?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${e}'`)}if(s.type==="directory"){let o=await this.readdir(r);if(o.length>0){if(!n?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${e}'`);for(let i of o){let a=r==="/"?`/${i}`:`${r}/${i}`;await this.rm(a,n)}}}this.data.delete(r)}async cp(e,n,r){let s=this.normalizePath(e),o=this.normalizePath(n),i=this.data.get(s);if(!i)throw new Error(`ENOENT: no such file or directory, cp '${e}'`);if(i.type==="file")this.ensureParentDirs(o),this.data.set(o,{...i});else if(i.type==="directory"){if(!r?.recursive)throw new Error(`EISDIR: is a directory, cp '${e}'`);await this.mkdir(o,{recursive:!0});let a=await this.readdir(s);for(let l of a){let c=s==="/"?`/${l}`:`${s}/${l}`,f=o==="/"?`/${l}`:`${o}/${l}`;await this.cp(c,f,r)}}}async mv(e,n){await this.cp(e,n,{recursive:!0}),await this.rm(e,{recursive:!0})}getAllPaths(){return Array.from(this.data.keys())}resolvePath(e,n){if(n.startsWith("/"))return this.normalizePath(n);let r=e==="/"?`/${n}`:`${e}/${n}`;return this.normalizePath(r)}async chmod(e,n){let r=this.normalizePath(e),s=this.data.get(r);if(!s)throw new Error(`ENOENT: no such file or directory, chmod '${e}'`);s.mode=n}async symlink(e,n){let r=this.normalizePath(n);if(this.data.has(r))throw new Error(`EEXIST: file already exists, symlink '${n}'`);this.ensureParentDirs(r),this.data.set(r,{type:"symlink",target:e,mode:511,mtime:new Date})}async link(e,n){let r=this.normalizePath(e),s=this.normalizePath(n),o=this.data.get(r);if(!o)throw new Error(`ENOENT: no such file or directory, link '${e}'`);if(o.type!=="file")throw new Error(`EPERM: operation not permitted, link '${e}'`);if(this.data.has(s))throw new Error(`EEXIST: file already exists, link '${n}'`);this.ensureParentDirs(s),this.data.set(s,{type:"file",content:o.content,mode:o.mode,mtime:o.mtime})}async readlink(e){let n=this.normalizePath(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, readlink '${e}'`);if(r.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${e}'`);return r.target}};var Nr="5.1.0(1)-release",Cr="Linux version 5.15.0-generic (just-bash) #1 SMP PREEMPT";function Te(){return{pid:process.pid,ppid:process.ppid,uid:process.getuid?.()??1e3,gid:process.getgid?.()??1e3}}function $r(){let{pid:t,ppid:e,uid:n,gid:r}=Te();return`Name: bash
|
|
2
2
|
State: R (running)
|
|
3
3
|
Pid: ${t}
|
|
4
4
|
PPid: ${e}
|