just-bash 1.4.1 → 1.5.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.
@@ -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 r=(Date.now()-s.mtime)/(1e3*60*60*24),t;return e.comparison==="more"?t=r>e.days:e.comparison==="less"?t=r<e.days:t=Math.floor(r)===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 r;return e.comparison==="more"?r=s.size>n:e.comparison==="less"?r=s.size<n:e.unit==="b"?r=Math.ceil(s.size/512)===e.value:r=s.size===n,{matches:r,pruned:!1,printed:!1}}case"perm":{let n=s.mode&511,r=e.mode&511,t;return e.matchType==="exact"?t=n===r:e.matchType==="all"?t=(n&r)===r:t=(n&r)!==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 r=w(e.right,s);return{matches:r.matches,pruned:n.pruned||r.pruned,printed:n.printed||r.printed}}case"or":{let n=w(e.left,s);if(n.matches)return n;let r=w(e.right,s);return{matches:r.matches,pruned:n.pruned||r.pruned,printed:r.printed}}}}function G(e){let s=[],n=r=>{r&&(r.type==="newer"?s.push(r.refPath):r.type==="not"?n(r.expr):(r.type==="and"||r.type==="or")&&(n(r.left),n(r.right)))};return n(e),s}function j(e,s){let n=[],r=[],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 i=e[++t];if(i==="f"||i==="d")n.push({type:"expr",expr:{type:"type",fileType:i}});else return{expr:null,pathIndex:t,error:`find: Unknown argument to -type: ${i}
3
- `,actions:[]}}else if(a==="-empty")n.push({type:"expr",expr:{type:"empty"}});else if(a==="-mtime"&&t+1<e.length){let i=e[++t],c="exact",o=i;i.startsWith("+")?(c="more",o=i.slice(1)):i.startsWith("-")&&(c="less",o=i.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 i=e[++t];n.push({type:"expr",expr:{type:"newer",refPath:i}})}else if(a==="-size"&&t+1<e.length){let i=e[++t],c="exact",o=i;i.startsWith("+")?(c="more",o=i.slice(1)):i.startsWith("-")&&(c="less",o=i.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 i=e[++t],c="exact",o=i;i.startsWith("-")?(c="all",o=i.slice(1)):i.startsWith("/")&&(c="any",o=i.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 i=[];for(t++;t<e.length&&e[t]!==";"&&e[t]!=="+";)i.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]==="+";r.push({type:"exec",command:i,batchMode:c})}else if(a==="-print")n.push({type:"expr",expr:{type:"print"}}),r.push({type:"print"});else if(a==="-print0")r.push({type:"print0"});else if(a==="-printf"&&t+1<e.length){let i=e[++t];r.push({type:"printf",format:i})}else if(a==="-delete")r.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:r};let m=_(n);return m.error?{expr:null,pathIndex:t,error:m.error,actions:r}:{expr:m.expr,pathIndex:t,actions:r}}function _(e){let s=0;function n(){let i=r();if(!i)return null;for(;s<e.length;){let c=e[s];if(c.type==="op"&&c.op==="or"){s++;let o=r();if(!o)return i;i={type:"or",left:i,right:o}}else break}return i}function r(){let i=t();if(!i)return null;for(;s<e.length;){let c=e[s];if(c.type==="op"&&c.op==="and"){s++;let o=t();if(!o)return i;i={type:"and",left:i,right:o}}else if(c.type==="expr"||c.type==="not"||c.type==="lparen"){let o=t();if(!o)return i;i={type:"and",left:i,right:o}}else break}return i}function t(){if(s<e.length&&e[s].type==="not"){s++;let i=t();return i?{type:"not",expr:i}:null}return m()}function m(){if(s>=e.length)return null;let i=e[s];if(i.type==="lparen"){s++;let c=n();return s<e.length&&e[s].type==="rparen"&&s++,c}return i.type==="expr"?(s++,i.expr):(i.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=[],r=null,t=null,m=!1,a=!1;for(let p=0;p<e.length;p++){let l=e[p];if(l==="-maxdepth"&&p+1<e.length)a=!0,r=parseInt(e[++p],10);else if(l==="-mindepth"&&p+1<e.length)a=!0,t=parseInt(e[++p],10);else if(l==="-depth")a=!0,m=!0;else if(l==="-exec")for(a=!0,p++;p<e.length&&e[p]!==";"&&e[p]!=="+";)p++;else!l.startsWith("-")&&l!==";"&&l!=="+"&&l!=="("&&l!==")"&&l!=="\\("&&l!=="\\)"&&l!=="!"?a||n.push(l):U.has(l)?(a=!0,p++):(l.startsWith("-")||l==="("||l==="\\("||l==="!")&&(a=!0)}n.length===0&&n.push(".");let{expr:i,error:c,actions:o}=j(e,0);if(c)return{stdout:"",stderr:c,exitCode:1};let h=o.some(p=>p.type==="print"),b=o.length===0,y=[],Y=o.some(p=>p.type==="printf"),F=[],T="",D=0,V=G(i),k=new Map;for(let p of V){let l=s.fs.resolvePath(s.cwd,p);try{let g=await s.fs.stat(l);k.set(p,g.mtime?.getTime()??Date.now())}catch{}}for(let p of n){let l=s.fs.resolvePath(s.cwd,p);try{await s.fs.stat(l)}catch{T+=`find: ${p}: No such file or directory
5
- `,D=1;continue}async function g(u,d){if(r!==null&&d>r)return;let f;try{f=await s.fs.stat(u)}catch{return}if(!f)return;let E;u===l?E=p.split("/").pop()||p:E=u.split("/").pop()||"";let $=u===l?p:p==="."?`./${u.slice(l.length+1)}`:p+u.slice(l.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&&i!==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},W=w(i,J);x=W.matches,h?v=W.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:p}))},A=async()=>{if(M!==null)for(let P of M){let x=u==="/"?`/${P}`:`${u}/${P}`;await g(x,d+1)}},z=!1;if(!m&&i!==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};z=w(i,P).pruned}m?(await A(),C()):(C(),z||await A())}await g(l,0)}let S="";if(o.length>0)for(let p of o)switch(p.type){case"print":S+=y.length>0?`${y.join(`
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 l=[...y].sort((g,u)=>u.length-g.length);for(let g of l){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 l of F)S+=q(p.format,l);break;case"exec":if(!s.exec)return{stdout:"",stderr:`find: -exec not supported in this context
9
- `,exitCode:1};if(p.batchMode){let l=[];for(let d of p.command)d==="{}"?l.push(...y):l.push(d);let g=l.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 l of y){let u=p.command.map(f=>f==="{}"?l: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(`
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),r="",t=0;for(;t<n.length;)if(n[t]==="%"&&t+1<n.length){if(t++,n[t]==="%"){r+="%",t++;continue}let[m,a,i]=B(n,t);if(t+=i,t>=n.length){r+="%";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:r+=`%${m!==0||a!==-1?`${m}.${a}`:""}${c}`,t++;continue}r+=L(o,m,a)}else r+=n[t],t++;return r}function Q(e,s){let n=e&511,r=s?"d":"-";return r+=n&256?"r":"-",r+=n&128?"w":"-",r+=n&64?"x":"-",r+=n&32?"r":"-",r+=n&16?"w":"-",r+=n&8?"x":"-",r+=n&4?"r":"-",r+=n&2?"w":"-",r+=n&1?"x":"-",r}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"],r=s[e.getDay()],t=n[e.getMonth()],m=String(e.getDate()).padStart(2," "),a=String(e.getHours()).padStart(2,"0"),i=String(e.getMinutes()).padStart(2,"0"),c=String(e.getSeconds()).padStart(2,"0"),o=e.getFullYear();return`${r} ${t} ${m} ${a}:${i}:${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};
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};
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env node
2
+ import{a as z}from"./chunk-TA7RUHGQ.js";import{a as w,b as $}from"./chunk-GTNBSMZR.js";import"./chunk-SJXDWN5X.js";import{constants as x,gunzipSync as C,gzipSync as b}from"node:zlib";var I={name:"gzip",summary:"compress or expand files",usage:"gzip [OPTION]... [FILE]...",description:`Compress FILEs (by default, in-place).
3
+
4
+ When no FILE is given, or when FILE is -, read from standard input.
5
+
6
+ With -d, decompress instead.`,options:["-c, --stdout write to standard output, keep original files","-d, --decompress decompress","-f, --force force overwrite of output file","-k, --keep keep (don't delete) input files","-l, --list list compressed file contents","-n, --no-name do not save or restore the original name and timestamp","-N, --name save or restore the original file name and timestamp","-q, --quiet suppress all warnings","-r, --recursive operate recursively on directories","-S, --suffix=SUF use suffix SUF on compressed files (default: .gz)","-t, --test test compressed file integrity","-v, --verbose verbose mode","-1, --fast compress faster","-9, --best compress better"," --help display this help and exit"]},q={name:"gunzip",summary:"decompress files",usage:"gunzip [OPTION]... [FILE]...",description:`Decompress FILEs (by default, in-place).
7
+
8
+ When no FILE is given, or when FILE is -, read from standard input.`,options:["-c, --stdout write to standard output, keep original files","-f, --force force overwrite of output file","-k, --keep keep (don't delete) input files","-l, --list list compressed file contents","-n, --no-name do not restore the original name and timestamp","-N, --name restore the original file name and timestamp","-q, --quiet suppress all warnings","-r, --recursive operate recursively on directories","-S, --suffix=SUF use suffix SUF on compressed files (default: .gz)","-t, --test test compressed file integrity","-v, --verbose verbose mode"," --help display this help and exit"]},P={name:"zcat",summary:"decompress files to stdout",usage:"zcat [OPTION]... [FILE]...",description:`Decompress FILEs to standard output.
9
+
10
+ When no FILE is given, or when FILE is -, read from standard input.`,options:["-f, --force force; read compressed data even from a terminal","-l, --list list compressed file contents","-q, --quiet suppress all warnings","-S, --suffix=SUF use suffix SUF on compressed files (default: .gz)","-t, --test test compressed file integrity","-v, --verbose verbose mode"," --help display this help and exit"]},D={stdout:{short:"c",long:"stdout",type:"boolean"},toStdout:{long:"to-stdout",type:"boolean"},decompress:{short:"d",long:"decompress",type:"boolean"},uncompress:{long:"uncompress",type:"boolean"},force:{short:"f",long:"force",type:"boolean"},keep:{short:"k",long:"keep",type:"boolean"},list:{short:"l",long:"list",type:"boolean"},noName:{short:"n",long:"no-name",type:"boolean"},name:{short:"N",long:"name",type:"boolean"},quiet:{short:"q",long:"quiet",type:"boolean"},recursive:{short:"r",long:"recursive",type:"boolean"},suffix:{short:"S",long:"suffix",type:"string",default:".gz"},test:{short:"t",long:"test",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"},fast:{short:"1",long:"fast",type:"boolean"},level2:{short:"2",type:"boolean"},level3:{short:"3",type:"boolean"},level4:{short:"4",type:"boolean"},level5:{short:"5",type:"boolean"},level6:{short:"6",type:"boolean"},level7:{short:"7",type:"boolean"},level8:{short:"8",type:"boolean"},best:{short:"9",long:"best",type:"boolean"}};function F(e){return e.best?x.Z_BEST_COMPRESSION:e.level8?8:e.level7?7:e.level6?6:e.level5?5:e.level4?4:e.level3?3:e.level2?2:e.fast?x.Z_BEST_SPEED:x.Z_DEFAULT_COMPRESSION}function S(e){if(e.length<10)return{originalName:null,mtime:null,headerSize:0};if(e[0]!==31||e[1]!==139)return{originalName:null,mtime:null,headerSize:0};let t=e[3],o=e[4]|e[5]<<8|e[6]<<16|e[7]<<24,r=10;if(t&4){if(r+2>e.length)return{originalName:null,mtime:null,headerSize:0};let n=e[r]|e[r+1]<<8;r+=2+n}let s=null;if(t&8){let n=r;for(;r<e.length&&e[r]!==0;)r++;r<e.length&&(s=new TextDecoder().decode(e.slice(n,r)),r++)}if(t&16){for(;r<e.length&&e[r]!==0;)r++;r++}return t&2&&(r+=2),{originalName:s,mtime:o>0?new Date(o*1e3):null,headerSize:r}}function L(e){if(e.length<4)return 0;let t=e.length;return e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24}function y(e){return e.length>=2&&e[0]===31&&e[1]===139}async function E(e,t,o,r,s,n){let u=o.suffix,c,p,d;if(t==="-"||t==="")if(d=new TextEncoder().encode(e.stdin),s){if(!y(d))return o.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: stdin: not in gzip format
11
+ `,exitCode:1};try{let l=C(d);return{stdout:new TextDecoder().decode(l),stderr:"",exitCode:0}}catch(l){let i=l instanceof Error?l.message:"unknown error";return{stdout:"",stderr:`${r}: stdin: ${i}
12
+ `,exitCode:1}}}else{let l=F(o),i=b(d,{level:l});return{stdout:String.fromCharCode(...i),stderr:"",exitCode:0}}c=e.fs.resolvePath(e.cwd,t);try{if((await e.fs.stat(c)).isDirectory)return o.recursive?await k(e,c,o,r,s,n):o.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: ${t}: is a directory -- ignored
13
+ `,exitCode:1}}catch{return{stdout:"",stderr:`${r}: ${t}: No such file or directory
14
+ `,exitCode:1}}try{d=await e.fs.readFileBuffer(c)}catch{return{stdout:"",stderr:`${r}: ${t}: No such file or directory
15
+ `,exitCode:1}}if(s){if(!t.endsWith(u))return o.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: ${t}: unknown suffix -- ignored
16
+ `,exitCode:1};if(!y(d))return o.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: ${t}: not in gzip format
17
+ `,exitCode:1};let l;try{l=C(d)}catch(i){let f=i instanceof Error?i.message:"unknown error";return{stdout:"",stderr:`${r}: ${t}: ${f}
18
+ `,exitCode:1}}if(n)return{stdout:new TextDecoder().decode(l),stderr:"",exitCode:0};if(o.name){let i=S(d);i.originalName?p=e.fs.resolvePath(e.cwd,i.originalName):p=c.slice(0,-u.length)}else p=c.slice(0,-u.length);if(!o.force)try{return await e.fs.stat(p),{stdout:"",stderr:`${r}: ${p} already exists; not overwritten
19
+ `,exitCode:1}}catch{}if(await e.fs.writeFile(p,l),!o.keep&&!n&&await e.fs.rm(c),o.verbose){let i=d.length>0?((1-d.length/l.length)*100).toFixed(1):"0.0";return{stdout:"",stderr:`${t}: ${i}% -- replaced with ${p.split("/").pop()}
20
+ `,exitCode:0}}return{stdout:"",stderr:"",exitCode:0}}else{if(t.endsWith(u))return o.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: ${t} already has ${u} suffix -- unchanged
21
+ `,exitCode:1};let l=F(o),i;try{i=b(d,{level:l})}catch(f){let a=f instanceof Error?f.message:"unknown error";return{stdout:"",stderr:`${r}: ${t}: ${a}
22
+ `,exitCode:1}}if(n)return{stdout:String.fromCharCode(...i),stderr:"",exitCode:0};if(p=c+u,!o.force)try{return await e.fs.stat(p),{stdout:"",stderr:`${r}: ${p} already exists; not overwritten
23
+ `,exitCode:1}}catch{}if(await e.fs.writeFile(p,i),!o.keep&&!n&&await e.fs.rm(c),o.verbose){let f=d.length>0?((1-i.length/d.length)*100).toFixed(1):"0.0";return{stdout:"",stderr:`${t}: ${f}% -- replaced with ${p.split("/").pop()}
24
+ `,exitCode:0}}return{stdout:"",stderr:"",exitCode:0}}}async function k(e,t,o,r,s,n){let u=await e.fs.readdir(t),c="",p="",d=0;for(let l of u){let i=e.fs.resolvePath(t,l),f=await e.fs.stat(i);if(f.isDirectory){let a=await k(e,i,o,r,s,n);c+=a.stdout,p+=a.stderr,a.exitCode!==0&&(d=a.exitCode)}else if(f.isFile){let a=o.suffix;if(s&&!l.endsWith(a)||!s&&l.endsWith(a))continue;let m=i.startsWith(`${e.cwd}/`)?i.slice(e.cwd.length+1):i,g=await E(e,m,o,r,s,n);c+=g.stdout,p+=g.stderr,g.exitCode!==0&&(d=g.exitCode)}}return{stdout:c,stderr:p,exitCode:d}}async function T(e,t,o,r){let s;if(t==="-"||t==="")s=new TextEncoder().encode(e.stdin);else{let i=e.fs.resolvePath(e.cwd,t);try{s=await e.fs.readFileBuffer(i)}catch{return{stdout:"",stderr:`${r}: ${t}: No such file or directory
25
+ `,exitCode:1}}}if(!y(s))return o.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: ${t}: not in gzip format
26
+ `,exitCode:1};let n=s.length,u=L(s),c=u>0?((1-n/u)*100).toFixed(1):"0.0",d=S(s).originalName||(t==="-"?"":t.replace(/\.gz$/,""));return{stdout:`${n.toString().padStart(10)} ${u.toString().padStart(10)} ${c.padStart(5)}% ${d}
27
+ `,stderr:"",exitCode:0}}async function O(e,t,o,r){let s;if(t==="-"||t==="")s=new TextEncoder().encode(e.stdin);else{let n=e.fs.resolvePath(e.cwd,t);try{s=await e.fs.readFileBuffer(n)}catch{return{stdout:"",stderr:`${r}: ${t}: No such file or directory
28
+ `,exitCode:1}}}if(!y(s))return o.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: ${t}: not in gzip format
29
+ `,exitCode:1};try{return C(s),o.verbose?{stdout:"",stderr:`${t}: OK
30
+ `,exitCode:0}:{stdout:"",stderr:"",exitCode:0}}catch(n){let u=n instanceof Error?n.message:"invalid";return{stdout:"",stderr:`${r}: ${t}: ${u}
31
+ `,exitCode:1}}}async function v(e,t,o){let r=o==="zcat"?P:o==="gunzip"?q:I;if($(e))return w(r);let s=z(o,e,D);if(!s.ok)return s.error.stderr.includes("unrecognized option"),s.error;let n=s.result.flags,u=s.result.positional,c=o==="gunzip"||o==="zcat"||n.decompress||n.uncompress,p=o==="zcat"||n.stdout||n.toStdout;if(n.list){u.length===0&&(u=["-"]);let f=` compressed uncompressed ratio uncompressed_name
32
+ `,a="",m=0;for(let g of u){let h=await T(t,g,n,o);f+=h.stdout,a+=h.stderr,h.exitCode!==0&&(m=h.exitCode)}return{stdout:f,stderr:a,exitCode:m}}if(n.test){u.length===0&&(u=["-"]);let f="",a="",m=0;for(let g of u){let h=await O(t,g,n,o);f+=h.stdout,a+=h.stderr,h.exitCode!==0&&(m=h.exitCode)}return{stdout:f,stderr:a,exitCode:m}}u.length===0&&(u=["-"]);let d="",l="",i=0;for(let f of u){let a=await E(t,f,n,o,c,p);d+=a.stdout,l+=a.stderr,a.exitCode!==0&&(i=a.exitCode)}return{stdout:d,stderr:l,exitCode:i}}var H={name:"gzip",async execute(e,t){return v(e,t,"gzip")}},B={name:"gunzip",async execute(e,t){return v(e,t,"gunzip")}},G={name:"zcat",async execute(e,t){return v(e,t,"zcat")}};export{B as gunzipCommand,H as gzipCommand,G as zcatCommand};
@@ -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},{name:"gzip",load:async()=>(await import("./chunks/gzip-VLTXZB2V.js")).gzipCommand},{name:"gunzip",load:async()=>(await import("./chunks/gzip-VLTXZB2V.js")).gunzipCommand},{name:"zcat",load:async()=>(await import("./chunks/gzip-VLTXZB2V.js")).zcatCommand}],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}