import{a as u}from"./chunk-HWKDQ44K.js";import{a as f,b as h}from"./chunk-74CEPOFO.js";import"./chunk-DXB73IDG.js";var w={name:"which",summary:"locate a command",usage:"which [-as] program ...",options:["-a         List all instances of executables found","-s         No output, just return 0 if found, 1 if not","--help     display this help and exit"]},g={showAll:{short:"a",type:"boolean"},silent:{short:"s",type:"boolean"}},A={name:"which",async execute(e,s){if(h(e))return f(w);let t=u("which",e,g);if(!t.ok)return t.error;let c=t.result.flags.showAll,p=t.result.flags.silent,o=t.result.positional;if(o.length===0)return{stdout:"",stderr:"",exitCode:1};let d=(s.env.get("PATH")||"/usr/bin:/bin").split(":"),n="",r=!0;for(let m of o){let a=!1;for(let i of d){if(!i)continue;let l=`${i}/${m}`;if(await s.fs.exists(l)&&(a=!0,p||(n+=`${l}
`),!c))break}a||(r=!1)}return{stdout:n,stderr:"",exitCode:r?0:1}}};export{A as whichCommand};
