import{n as e,r as t,t as n}from"./chunk-74CEPOFO-V0JXh91S.mjs";var r={name:`readlink`,summary:`print resolved symbolic links or canonical file names`,usage:`readlink [OPTIONS] FILE...`,options:[`-f      canonicalize by following every symlink in every component of the given name recursively`,`    --help display this help and exit`]},i={name:`readlink`,async execute(i,a){if(n(i))return t(r);let o=!1,s=0;for(;s<i.length&&i[s].startsWith(`-`);){let t=i[s];if(t===`-f`||t===`--canonicalize`)o=!0,s++;else if(t===`--`){s++;break}else return e(`readlink`,t)}let c=i.slice(s);if(c.length===0)return{stdout:``,stderr:`readlink: missing operand
`,exitCode:1};let l=``,u=!1;for(let e of c){let t=a.fs.resolvePath(a.cwd,e);try{if(o){let e=t,n=new Set;for(;!n.has(e);){n.add(e);try{let t=await a.fs.readlink(e);if(t.startsWith(`/`))e=t;else{let n=e.substring(0,e.lastIndexOf(`/`))||`/`;e=a.fs.resolvePath(n,t)}}catch{break}}l+=`${e}
`}else{let e=await a.fs.readlink(t);l+=`${e}
`}}catch{o?l+=`${t}
`:u=!0}}return{stdout:l,stderr:``,exitCode:u?1:0}}},a={name:`readlink`,flags:[{flag:`-f`,type:`boolean`},{flag:`-e`,type:`boolean`}],needsArgs:!0};export{i as n,a as t};
//# sourceMappingURL=chunk-HJWBQKYG-DknkBuxy.mjs.map