just-bash 1.2.3 → 1.2.4
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/chunk-6QUZ7QML.js +3 -0
- package/dist/bin/chunks/find-AMA6ABN5.js +11 -0
- package/dist/bin/chunks/find-NCI6KGUI.js +11 -0
- package/dist/bin/chunks/find-QEYP42JQ.js +11 -0
- package/dist/bin/chunks/printf-ASOYDPIK.js +14 -0
- package/dist/bin/just-bash.js +1 -1
- package/dist/bin/shell/chunks/chunk-6QUZ7QML.js +3 -0
- package/dist/bin/shell/chunks/find-AMA6ABN5.js +11 -0
- package/dist/bin/shell/chunks/find-NCI6KGUI.js +11 -0
- package/dist/bin/shell/chunks/find-QEYP42JQ.js +11 -0
- package/dist/bin/shell/chunks/printf-ASOYDPIK.js +14 -0
- package/dist/bin/shell/shell.js +1 -1
- package/dist/bundle/ai/index.js +286 -286
- package/dist/bundle/chunks/chunk-TDJNT32M.js +2 -0
- package/dist/bundle/chunks/find-3O5V74IR.js +10 -0
- package/dist/bundle/chunks/find-522XP4ZY.js +10 -0
- package/dist/bundle/chunks/find-JXG2HF6L.js +10 -0
- package/dist/bundle/chunks/printf-G2SBUNW3.js +13 -0
- package/dist/bundle/index.js +1 -1
- package/dist/commands/find/types.d.ts +5 -0
- package/dist/commands/printf/escapes.d.ts +24 -0
- package/package.json +1 -1
package/dist/bin/shell/shell.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as U,b as K,c as H,d as ee,e as Y,f as k,g as F,h as me,i as z,j as oe,k as Fe}from"./chunks/chunk-NWWB2XRE.js";import{a as X}from"./chunks/chunk-4VDEBYW7.js";import"./chunks/chunk-5KNEBKYN.js";import*as On from"node:fs";import*as _n from"node:readline";var ur=[{name:"echo",load:async()=>(await import("./chunks/echo-DEUIS5JO.js")).echoCommand},{name:"cat",load:async()=>(await import("./chunks/cat-YZXBF5YF.js")).catCommand},{name:"printf",load:async()=>(await import("./chunks/printf-BOFQVMMK.js")).printfCommand},{name:"ls",load:async()=>(await import("./chunks/ls-C4MPAF3H.js")).lsCommand},{name:"mkdir",load:async()=>(await import("./chunks/mkdir-LWULWDHP.js")).mkdirCommand},{name:"touch",load:async()=>(await import("./chunks/touch-XCIAYF5I.js")).touchCommand},{name:"rm",load:async()=>(await import("./chunks/rm-W6CCBEMG.js")).rmCommand},{name:"cp",load:async()=>(await import("./chunks/cp-77UY7PGN.js")).cpCommand},{name:"mv",load:async()=>(await import("./chunks/mv-TDYCNSIQ.js")).mvCommand},{name:"ln",load:async()=>(await import("./chunks/ln-DB7J2W5X.js")).lnCommand},{name:"chmod",load:async()=>(await import("./chunks/chmod-3G4LK462.js")).chmodCommand},{name:"pwd",load:async()=>(await import("./chunks/pwd-X4MWD4JP.js")).pwdCommand},{name:"readlink",load:async()=>(await import("./chunks/readlink-DPNOQY67.js")).readlinkCommand},{name:"head",load:async()=>(await import("./chunks/head-VGXR3WWL.js")).headCommand},{name:"tail",load:async()=>(await import("./chunks/tail-YSVKBQ77.js")).tailCommand},{name:"wc",load:async()=>(await import("./chunks/wc-CNJ3QDRA.js")).wcCommand},{name:"stat",load:async()=>(await import("./chunks/stat-3PHITCPO.js")).statCommand},{name:"grep",load:async()=>(await import("./chunks/grep-PHBFGJCV.js")).grepCommand},{name:"fgrep",load:async()=>(await import("./chunks/grep-PHBFGJCV.js")).fgrepCommand},{name:"egrep",load:async()=>(await import("./chunks/grep-PHBFGJCV.js")).egrepCommand},{name:"sed",load:async()=>(await import("./chunks/sed-LTCVBSRV.js")).sedCommand},{name:"awk",load:async()=>(await import("./chunks/awk2-4DKPX43H.js")).awkCommand2},{name:"sort",load:async()=>(await import("./chunks/sort-UJP353TM.js")).sortCommand},{name:"uniq",load:async()=>(await import("./chunks/uniq-W4HF6YSB.js")).uniqCommand},{name:"cut",load:async()=>(await import("./chunks/cut-UYV3FM7R.js")).cutCommand},{name:"paste",load:async()=>(await import("./chunks/paste-R36J3G4K.js")).pasteCommand},{name:"tr",load:async()=>(await import("./chunks/tr-2EEKHHO6.js")).trCommand},{name:"tee",load:async()=>(await import("./chunks/tee-UU2VS3OM.js")).teeCommand},{name:"find",load:async()=>(await import("./chunks/find-HW2TUO6B.js")).findCommand},{name:"basename",load:async()=>(await import("./chunks/basename-Y7JDBYHN.js")).basenameCommand},{name:"dirname",load:async()=>(await import("./chunks/dirname-VLHP44TU.js")).dirnameCommand},{name:"tree",load:async()=>(await import("./chunks/tree-4247W67O.js")).treeCommand},{name:"du",load:async()=>(await import("./chunks/du-4FZ7WF2P.js")).duCommand},{name:"env",load:async()=>(await import("./chunks/env-AKGX6HSG.js")).envCommand},{name:"printenv",load:async()=>(await import("./chunks/env-AKGX6HSG.js")).printenvCommand},{name:"alias",load:async()=>(await import("./chunks/alias-74DFXE2E.js")).aliasCommand},{name:"unalias",load:async()=>(await import("./chunks/alias-74DFXE2E.js")).unaliasCommand},{name:"history",load:async()=>(await import("./chunks/history-PRQ4B6N2.js")).historyCommand},{name:"xargs",load:async()=>(await import("./chunks/xargs-DKUAYNEK.js")).xargsCommand},{name:"true",load:async()=>(await import("./chunks/true-JCX733LK.js")).trueCommand},{name:"false",load:async()=>(await import("./chunks/true-JCX733LK.js")).falseCommand},{name:"clear",load:async()=>(await import("./chunks/clear-GTCFHSB2.js")).clearCommand},{name:"bash",load:async()=>(await import("./chunks/bash-5IWSVGHN.js")).bashCommand},{name:"sh",load:async()=>(await import("./chunks/bash-5IWSVGHN.js")).shCommand},{name:"jq",load:async()=>(await import("./chunks/jq-EYSXBSCP.js")).jqCommand},{name:"base64",load:async()=>(await import("./chunks/base64-NC7HTKLZ.js")).base64Command},{name:"diff",load:async()=>(await import("./chunks/diff-TG2NXCX2.js")).diffCommand},{name:"date",load:async()=>(await import("./chunks/date-7NBRXV2Z.js")).dateCommand},{name:"sleep",load:async()=>(await import("./chunks/sleep-E4DIYGTT.js")).sleepCommand},{name:"timeout",load:async()=>(await import("./chunks/timeout-RP2AJGMV.js")).timeoutCommand},{name:"seq",load:async()=>(await import("./chunks/seq-DGJILX2Q.js")).seqCommand},{name:"expr",load:async()=>(await import("./chunks/expr-HA2ZNL6S.js")).exprCommand},{name:"html-to-markdown",load:async()=>(await import("./chunks/html-to-markdown-L4UWMK4S.js")).htmlToMarkdownCommand},{name:"help",load:async()=>(await import("./chunks/help-YQGNAT2T.js")).helpCommand},{name:"which",load:async()=>(await import("./chunks/which-HX2NMOP3.js")).whichCommand}],Ln=[{name:"curl",load:async()=>(await import("./chunks/curl-NE7XEWMN.js")).curlCommand}],hr=new Map;function dr(t){return{name:t.name,async execute(e,n){let r=hr.get(t.name);return r||(r=await t.load(),hr.set(t.name,r)),r.execute(e,n)}}}function mr(t){return(t?ur.filter(n=>t.includes(n.name)):ur).map(dr)}function pr(){return Ln.map(dr)}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 Tn=new TextEncoder,Wn=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 Tn.encode(t)}}function Me(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 Wn.decode(t)}}function ae(t){if(t!=null)return typeof t=="string"?t:t.encoding??void 0}var Be=new TextEncoder;function Fn(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))Fn(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 Me(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:Be.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:Be.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=Be.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=Be.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}};function L(t,e){return{type:"ArithmeticExpression",expression:te(t,e,0).expr}}function te(t,e,n){return Mn(t,e,n)}function Mn(t,e,n){let{expr:r,pos:s}=Ue(t,e,n);for(s=D(e,s);e[s]===",";){s++;let{expr:o,pos:i}=Ue(t,e,s);r={type:"ArithBinary",operator:",",left:r,right:o},s=D(e,i)}return{expr:r,pos:s}}function Ue(t,e,n){let{expr:r,pos:s}=Bn(t,e,n);if(s=D(e,s),e[s]==="?"){s++;let{expr:o,pos:i}=te(t,e,s);if(s=D(e,i),e[s]===":"){s++;let{expr:a,pos:l}=te(t,e,s);return{expr:{type:"ArithTernary",condition:r,consequent:o,alternate:a},pos:l}}}return{expr:r,pos:s}}function Bn(t,e,n){let{expr:r,pos:s}=wr(t,e,n);for(;s=D(e,s),e.slice(s,s+2)==="||";){s+=2;let{expr:o,pos:i}=wr(t,e,s);r={type:"ArithBinary",operator:"||",left:r,right:o},s=i}return{expr:r,pos:s}}function wr(t,e,n){let{expr:r,pos:s}=gr(t,e,n);for(;s=D(e,s),e.slice(s,s+2)==="&&";){s+=2;let{expr:o,pos:i}=gr(t,e,s);r={type:"ArithBinary",operator:"&&",left:r,right:o},s=i}return{expr:r,pos:s}}function gr(t,e,n){let{expr:r,pos:s}=Ar(t,e,n);for(;s=D(e,s),e[s]==="|"&&e[s+1]!=="|";){s++;let{expr:o,pos:i}=Ar(t,e,s);r={type:"ArithBinary",operator:"|",left:r,right:o},s=i}return{expr:r,pos:s}}function Ar(t,e,n){let{expr:r,pos:s}=xr(t,e,n);for(;s=D(e,s),e[s]==="^";){s++;let{expr:o,pos:i}=xr(t,e,s);r={type:"ArithBinary",operator:"^",left:r,right:o},s=i}return{expr:r,pos:s}}function xr(t,e,n){let{expr:r,pos:s}=Sr(t,e,n);for(;s=D(e,s),e[s]==="&"&&e[s+1]!=="&";){s++;let{expr:o,pos:i}=Sr(t,e,s);r={type:"ArithBinary",operator:"&",left:r,right:o},s=i}return{expr:r,pos:s}}function Sr(t,e,n){let{expr:r,pos:s}=br(t,e,n);for(;s=D(e,s),e.slice(s,s+2)==="=="||e.slice(s,s+2)==="!=";){let o=e.slice(s,s+2);s+=2;let{expr:i,pos:a}=br(t,e,s);r={type:"ArithBinary",operator:o,left:r,right:i},s=a}return{expr:r,pos:s}}function br(t,e,n){let{expr:r,pos:s}=yt(t,e,n);for(;;)if(s=D(e,s),e.slice(s,s+2)==="<="||e.slice(s,s+2)===">="){let o=e.slice(s,s+2);s+=2;let{expr:i,pos:a}=yt(t,e,s);r={type:"ArithBinary",operator:o,left:r,right:i},s=a}else if(e[s]==="<"||e[s]===">"){let o=e[s];s++;let{expr:i,pos:a}=yt(t,e,s);r={type:"ArithBinary",operator:o,left:r,right:i},s=a}else break;return{expr:r,pos:s}}function yt(t,e,n){let{expr:r,pos:s}=Cr(t,e,n);for(;s=D(e,s),e.slice(s,s+2)==="<<"||e.slice(s,s+2)===">>";){let o=e.slice(s,s+2);s+=2;let{expr:i,pos:a}=Cr(t,e,s);r={type:"ArithBinary",operator:o,left:r,right:i},s=a}return{expr:r,pos:s}}function Cr(t,e,n){let{expr:r,pos:s}=Nr(t,e,n);for(;s=D(e,s),(e[s]==="+"||e[s]==="-")&&e[s+1]!==e[s];){let o=e[s];s++;let{expr:i,pos:a}=Nr(t,e,s);r={type:"ArithBinary",operator:o,left:r,right:i},s=a}return{expr:r,pos:s}}function Nr(t,e,n){let{expr:r,pos:s}=ze(t,e,n);for(;;)if(s=D(e,s),e[s]==="*"&&e[s+1]!=="*"){s++;let{expr:o,pos:i}=ze(t,e,s);r={type:"ArithBinary",operator:"*",left:r,right:o},s=i}else if(e[s]==="/"||e[s]==="%"){let o=e[s];s++;let{expr:i,pos:a}=ze(t,e,s);r={type:"ArithBinary",operator:o,left:r,right:i},s=a}else break;return{expr:r,pos:s}}function ze(t,e,n){let{expr:r,pos:s}=Et(t,e,n),o=D(e,s);if(e.slice(o,o+2)==="**"){o+=2;let{expr:i,pos:a}=ze(t,e,o);return{expr:{type:"ArithBinary",operator:"**",left:r,right:i},pos:a}}return{expr:r,pos:s}}function Et(t,e,n){let r=D(e,n);if(e.slice(r,r+2)==="++"||e.slice(r,r+2)==="--"){let s=e.slice(r,r+2);r+=2;let{expr:o,pos:i}=Et(t,e,r);return{expr:{type:"ArithUnary",operator:s,operand:o,prefix:!0},pos:i}}if(e[r]==="+"||e[r]==="-"||e[r]==="!"||e[r]==="~"){let s=e[r];r++;let{expr:o,pos:i}=Et(t,e,r);return{expr:{type:"ArithUnary",operator:s,operand:o,prefix:!0},pos:i}}return Un(t,e,r)}function zn(t,e){let n=t[e];return n==="$"||n==="`"}function Un(t,e,n){let{expr:r,pos:s}=$r(t,e,n),o=[r];for(;zn(e,s);){let{expr:i,pos:a}=$r(t,e,s);o.push(i),s=a}if(o.length>1&&(r={type:"ArithConcat",parts:o}),s=D(e,s),e.slice(s,s+2)==="++"||e.slice(s,s+2)==="--"){let i=e.slice(s,s+2);return s+=2,{expr:{type:"ArithUnary",operator:i,operand:r,prefix:!1},pos:s}}return{expr:r,pos:s}}function $r(t,e,n){let r=D(e,n);if(e.slice(r,r+3)==="$(("){r+=3;let s=1,o=r;for(;r<e.length-1&&s>0;)e[r]==="("&&e[r+1]==="("?(s++,r+=2):e[r]===")"&&e[r+1]===")"?(s--,s>0&&(r+=2)):r++;let i=e.slice(o,r),{expr:a}=te(t,i,0);return r+=2,{expr:{type:"ArithNested",expression:a},pos:r}}if(e.slice(r,r+2)==="$("&&e[r+2]!=="("){r+=2;let s=1,o=r;for(;r<e.length&&s>0;)e[r]==="("?s++:e[r]===")"&&s--,s>0&&r++;let i=e.slice(o,r);return r++,{expr:{type:"ArithCommandSubst",command:i},pos:r}}if(e[r]==="`"){r++;let s=r;for(;r<e.length&&e[r]!=="`";)r++;let o=e.slice(s,r);return e[r]==="`"&&r++,{expr:{type:"ArithCommandSubst",command:o},pos:r}}if(e[r]==="("){r++;let{expr:s,pos:o}=te(t,e,r);return r=D(e,o),e[r]===")"&&r++,{expr:{type:"ArithGroup",expression:s},pos:r}}if(/[0-9]/.test(e[r])){let s="",o=!1;for(;r<e.length;){let a=e[r];if(o)if(/[0-9a-zA-Z@_]/.test(a))s+=a,r++;else break;else if(a==="#")o=!0,s+=a,r++;else if(/[0-9a-fA-FxX]/.test(a))s+=a,r++;else break}if(e[r]==="."&&/[0-9]/.test(e[r+1]))throw new F(`${s}.${e[r+1]}...: syntax error: invalid arithmetic operator`);if(e[r]==="["){let a=e.slice(r).trim();return{expr:{type:"ArithNumberSubscript",number:s,errorToken:a},pos:e.length}}return{expr:{type:"ArithNumber",value:xe(s)},pos:r}}if(e[r]==="$"&&e[r+1]==="{"){let s=r+2,o=1,i=s;for(;i<e.length&&o>0;)e[i]==="{"?o++:e[i]==="}"&&o--,o>0&&i++;let a=e.slice(s,i),l=i+1;if(e[l]==="#"){let c=l+1;for(;c<e.length&&/[0-9a-zA-Z@_]/.test(e[c]);)c++;let f=e.slice(l+1,c);return{expr:{type:"ArithDynamicBase",baseExpr:a,value:f},pos:c}}if(/[0-9]/.test(e[l])||e[l]==="x"||e[l]==="X"){let c=l;if(e[l]==="x"||e[l]==="X")for(c++;c<e.length&&/[0-9a-fA-F]/.test(e[c]);)c++;else for(;c<e.length&&/[0-9]/.test(e[c]);)c++;let f=e.slice(l,c);return{expr:{type:"ArithDynamicNumber",prefix:a,suffix:f},pos:c}}return r=l,{expr:{type:"ArithBracedExpansion",content:a},pos:r}}if(e[r]==="$"&&r+1<e.length&&/[0-9]/.test(e[r+1])){r++;let s="";for(;r<e.length&&/[0-9]/.test(e[r]);)s+=e[r],r++;return{expr:{type:"ArithVariable",name:s},pos:r}}if(e[r]==="$"&&r+1<e.length&&/[a-zA-Z_]/.test(e[r+1])&&r++,/[a-zA-Z_]/.test(e[r])){let s="";for(;r<e.length&&/[a-zA-Z0-9_]/.test(e[r]);)s+=e[r],r++;if(e[r]==="["){r++;let i;if(e[r]==="'"||e[r]==='"'){let c=e[r];for(r++,i="";r<e.length&&e[r]!==c;)i+=e[r],r++;e[r]===c&&r++,r=D(e,r),e[r]==="]"&&r++}let a;if(i===void 0){let{expr:c,pos:f}=te(t,e,r);a=c,r=f,e[r]==="]"&&r++}if(r=D(e,r),e[r]==="["&&a)return{expr:{type:"ArithDoubleSubscript",array:s,index:a},pos:r};let l=["=","+=","-=","*=","/=","%=","<<=",">>=","&=","|=","^="];for(let c of l)if(e.slice(r,r+c.length)===c&&e.slice(r,r+c.length+1)!=="=="){r+=c.length;let{expr:f,pos:h}=Ue(t,e,r);return{expr:{type:"ArithAssignment",operator:c,variable:s,subscript:a,stringKey:i,value:f},pos:h}}return{expr:{type:"ArithArrayElement",array:s,index:a,stringKey:i},pos:r}}r=D(e,r);let o=["=","+=","-=","*=","/=","%=","<<=",">>=","&=","|=","^="];for(let i of o)if(e.slice(r,r+i.length)===i&&e.slice(r,r+i.length+1)!=="=="){r+=i.length;let{expr:a,pos:l}=Ue(t,e,r);return{expr:{type:"ArithAssignment",operator:i,variable:s,value:a},pos:l}}return{expr:{type:"ArithVariable",name:s},pos:r}}return{expr:{type:"ArithNumber",value:0},pos:r}}function xe(t){if(t.includes("#")){let[e,n]=t.split("#"),r=Number.parseInt(e,10);if(r<2||r>64)return Number.NaN;if(r<=36)return Number.parseInt(n,r);let s=0;for(let o of n){let i;if(o>="0"&&o<="9")i=o.charCodeAt(0)-48;else if(o>="a"&&o<="z")i=o.charCodeAt(0)-97+10;else if(o>="A"&&o<="Z")i=o.charCodeAt(0)-65+36;else if(o==="@")i=62;else if(o==="_")i=63;else return Number.NaN;if(i>=r)return Number.NaN;s=s*r+i}return s}return t.startsWith("0x")||t.startsWith("0X")?Number.parseInt(t.slice(2),16):t.startsWith("0")&&t.length>1&&/^[0-9]+$/.test(t)?/[89]/.test(t)?Number.NaN:Number.parseInt(t,8):Number.parseInt(t,10)}function D(t,e){for(;e<t.length;){if(t[e]==="\\"&&t[e+1]===`
|
|
2
|
+
import{a as U,b as K,c as H,d as ee,e as Y,f as k,g as F,h as me,i as z,j as oe,k as Fe}from"./chunks/chunk-NWWB2XRE.js";import{a as X}from"./chunks/chunk-4VDEBYW7.js";import"./chunks/chunk-5KNEBKYN.js";import*as On from"node:fs";import*as _n from"node:readline";var ur=[{name:"echo",load:async()=>(await import("./chunks/echo-DEUIS5JO.js")).echoCommand},{name:"cat",load:async()=>(await import("./chunks/cat-YZXBF5YF.js")).catCommand},{name:"printf",load:async()=>(await import("./chunks/printf-ASOYDPIK.js")).printfCommand},{name:"ls",load:async()=>(await import("./chunks/ls-C4MPAF3H.js")).lsCommand},{name:"mkdir",load:async()=>(await import("./chunks/mkdir-LWULWDHP.js")).mkdirCommand},{name:"touch",load:async()=>(await import("./chunks/touch-XCIAYF5I.js")).touchCommand},{name:"rm",load:async()=>(await import("./chunks/rm-W6CCBEMG.js")).rmCommand},{name:"cp",load:async()=>(await import("./chunks/cp-77UY7PGN.js")).cpCommand},{name:"mv",load:async()=>(await import("./chunks/mv-TDYCNSIQ.js")).mvCommand},{name:"ln",load:async()=>(await import("./chunks/ln-DB7J2W5X.js")).lnCommand},{name:"chmod",load:async()=>(await import("./chunks/chmod-3G4LK462.js")).chmodCommand},{name:"pwd",load:async()=>(await import("./chunks/pwd-X4MWD4JP.js")).pwdCommand},{name:"readlink",load:async()=>(await import("./chunks/readlink-DPNOQY67.js")).readlinkCommand},{name:"head",load:async()=>(await import("./chunks/head-VGXR3WWL.js")).headCommand},{name:"tail",load:async()=>(await import("./chunks/tail-YSVKBQ77.js")).tailCommand},{name:"wc",load:async()=>(await import("./chunks/wc-CNJ3QDRA.js")).wcCommand},{name:"stat",load:async()=>(await import("./chunks/stat-3PHITCPO.js")).statCommand},{name:"grep",load:async()=>(await import("./chunks/grep-PHBFGJCV.js")).grepCommand},{name:"fgrep",load:async()=>(await import("./chunks/grep-PHBFGJCV.js")).fgrepCommand},{name:"egrep",load:async()=>(await import("./chunks/grep-PHBFGJCV.js")).egrepCommand},{name:"sed",load:async()=>(await import("./chunks/sed-LTCVBSRV.js")).sedCommand},{name:"awk",load:async()=>(await import("./chunks/awk2-4DKPX43H.js")).awkCommand2},{name:"sort",load:async()=>(await import("./chunks/sort-UJP353TM.js")).sortCommand},{name:"uniq",load:async()=>(await import("./chunks/uniq-W4HF6YSB.js")).uniqCommand},{name:"cut",load:async()=>(await import("./chunks/cut-UYV3FM7R.js")).cutCommand},{name:"paste",load:async()=>(await import("./chunks/paste-R36J3G4K.js")).pasteCommand},{name:"tr",load:async()=>(await import("./chunks/tr-2EEKHHO6.js")).trCommand},{name:"tee",load:async()=>(await import("./chunks/tee-UU2VS3OM.js")).teeCommand},{name:"find",load:async()=>(await import("./chunks/find-NCI6KGUI.js")).findCommand},{name:"basename",load:async()=>(await import("./chunks/basename-Y7JDBYHN.js")).basenameCommand},{name:"dirname",load:async()=>(await import("./chunks/dirname-VLHP44TU.js")).dirnameCommand},{name:"tree",load:async()=>(await import("./chunks/tree-4247W67O.js")).treeCommand},{name:"du",load:async()=>(await import("./chunks/du-4FZ7WF2P.js")).duCommand},{name:"env",load:async()=>(await import("./chunks/env-AKGX6HSG.js")).envCommand},{name:"printenv",load:async()=>(await import("./chunks/env-AKGX6HSG.js")).printenvCommand},{name:"alias",load:async()=>(await import("./chunks/alias-74DFXE2E.js")).aliasCommand},{name:"unalias",load:async()=>(await import("./chunks/alias-74DFXE2E.js")).unaliasCommand},{name:"history",load:async()=>(await import("./chunks/history-PRQ4B6N2.js")).historyCommand},{name:"xargs",load:async()=>(await import("./chunks/xargs-DKUAYNEK.js")).xargsCommand},{name:"true",load:async()=>(await import("./chunks/true-JCX733LK.js")).trueCommand},{name:"false",load:async()=>(await import("./chunks/true-JCX733LK.js")).falseCommand},{name:"clear",load:async()=>(await import("./chunks/clear-GTCFHSB2.js")).clearCommand},{name:"bash",load:async()=>(await import("./chunks/bash-5IWSVGHN.js")).bashCommand},{name:"sh",load:async()=>(await import("./chunks/bash-5IWSVGHN.js")).shCommand},{name:"jq",load:async()=>(await import("./chunks/jq-EYSXBSCP.js")).jqCommand},{name:"base64",load:async()=>(await import("./chunks/base64-NC7HTKLZ.js")).base64Command},{name:"diff",load:async()=>(await import("./chunks/diff-TG2NXCX2.js")).diffCommand},{name:"date",load:async()=>(await import("./chunks/date-7NBRXV2Z.js")).dateCommand},{name:"sleep",load:async()=>(await import("./chunks/sleep-E4DIYGTT.js")).sleepCommand},{name:"timeout",load:async()=>(await import("./chunks/timeout-RP2AJGMV.js")).timeoutCommand},{name:"seq",load:async()=>(await import("./chunks/seq-DGJILX2Q.js")).seqCommand},{name:"expr",load:async()=>(await import("./chunks/expr-HA2ZNL6S.js")).exprCommand},{name:"html-to-markdown",load:async()=>(await import("./chunks/html-to-markdown-L4UWMK4S.js")).htmlToMarkdownCommand},{name:"help",load:async()=>(await import("./chunks/help-YQGNAT2T.js")).helpCommand},{name:"which",load:async()=>(await import("./chunks/which-HX2NMOP3.js")).whichCommand}],Ln=[{name:"curl",load:async()=>(await import("./chunks/curl-NE7XEWMN.js")).curlCommand}],hr=new Map;function dr(t){return{name:t.name,async execute(e,n){let r=hr.get(t.name);return r||(r=await t.load(),hr.set(t.name,r)),r.execute(e,n)}}}function mr(t){return(t?ur.filter(n=>t.includes(n.name)):ur).map(dr)}function pr(){return Ln.map(dr)}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 Tn=new TextEncoder,Wn=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 Tn.encode(t)}}function Me(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 Wn.decode(t)}}function ae(t){if(t!=null)return typeof t=="string"?t:t.encoding??void 0}var Be=new TextEncoder;function Fn(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))Fn(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 Me(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:Be.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:Be.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=Be.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=Be.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}};function L(t,e){return{type:"ArithmeticExpression",expression:te(t,e,0).expr}}function te(t,e,n){return Mn(t,e,n)}function Mn(t,e,n){let{expr:r,pos:s}=Ue(t,e,n);for(s=D(e,s);e[s]===",";){s++;let{expr:o,pos:i}=Ue(t,e,s);r={type:"ArithBinary",operator:",",left:r,right:o},s=D(e,i)}return{expr:r,pos:s}}function Ue(t,e,n){let{expr:r,pos:s}=Bn(t,e,n);if(s=D(e,s),e[s]==="?"){s++;let{expr:o,pos:i}=te(t,e,s);if(s=D(e,i),e[s]===":"){s++;let{expr:a,pos:l}=te(t,e,s);return{expr:{type:"ArithTernary",condition:r,consequent:o,alternate:a},pos:l}}}return{expr:r,pos:s}}function Bn(t,e,n){let{expr:r,pos:s}=wr(t,e,n);for(;s=D(e,s),e.slice(s,s+2)==="||";){s+=2;let{expr:o,pos:i}=wr(t,e,s);r={type:"ArithBinary",operator:"||",left:r,right:o},s=i}return{expr:r,pos:s}}function wr(t,e,n){let{expr:r,pos:s}=gr(t,e,n);for(;s=D(e,s),e.slice(s,s+2)==="&&";){s+=2;let{expr:o,pos:i}=gr(t,e,s);r={type:"ArithBinary",operator:"&&",left:r,right:o},s=i}return{expr:r,pos:s}}function gr(t,e,n){let{expr:r,pos:s}=Ar(t,e,n);for(;s=D(e,s),e[s]==="|"&&e[s+1]!=="|";){s++;let{expr:o,pos:i}=Ar(t,e,s);r={type:"ArithBinary",operator:"|",left:r,right:o},s=i}return{expr:r,pos:s}}function Ar(t,e,n){let{expr:r,pos:s}=xr(t,e,n);for(;s=D(e,s),e[s]==="^";){s++;let{expr:o,pos:i}=xr(t,e,s);r={type:"ArithBinary",operator:"^",left:r,right:o},s=i}return{expr:r,pos:s}}function xr(t,e,n){let{expr:r,pos:s}=Sr(t,e,n);for(;s=D(e,s),e[s]==="&"&&e[s+1]!=="&";){s++;let{expr:o,pos:i}=Sr(t,e,s);r={type:"ArithBinary",operator:"&",left:r,right:o},s=i}return{expr:r,pos:s}}function Sr(t,e,n){let{expr:r,pos:s}=br(t,e,n);for(;s=D(e,s),e.slice(s,s+2)==="=="||e.slice(s,s+2)==="!=";){let o=e.slice(s,s+2);s+=2;let{expr:i,pos:a}=br(t,e,s);r={type:"ArithBinary",operator:o,left:r,right:i},s=a}return{expr:r,pos:s}}function br(t,e,n){let{expr:r,pos:s}=yt(t,e,n);for(;;)if(s=D(e,s),e.slice(s,s+2)==="<="||e.slice(s,s+2)===">="){let o=e.slice(s,s+2);s+=2;let{expr:i,pos:a}=yt(t,e,s);r={type:"ArithBinary",operator:o,left:r,right:i},s=a}else if(e[s]==="<"||e[s]===">"){let o=e[s];s++;let{expr:i,pos:a}=yt(t,e,s);r={type:"ArithBinary",operator:o,left:r,right:i},s=a}else break;return{expr:r,pos:s}}function yt(t,e,n){let{expr:r,pos:s}=Cr(t,e,n);for(;s=D(e,s),e.slice(s,s+2)==="<<"||e.slice(s,s+2)===">>";){let o=e.slice(s,s+2);s+=2;let{expr:i,pos:a}=Cr(t,e,s);r={type:"ArithBinary",operator:o,left:r,right:i},s=a}return{expr:r,pos:s}}function Cr(t,e,n){let{expr:r,pos:s}=Nr(t,e,n);for(;s=D(e,s),(e[s]==="+"||e[s]==="-")&&e[s+1]!==e[s];){let o=e[s];s++;let{expr:i,pos:a}=Nr(t,e,s);r={type:"ArithBinary",operator:o,left:r,right:i},s=a}return{expr:r,pos:s}}function Nr(t,e,n){let{expr:r,pos:s}=ze(t,e,n);for(;;)if(s=D(e,s),e[s]==="*"&&e[s+1]!=="*"){s++;let{expr:o,pos:i}=ze(t,e,s);r={type:"ArithBinary",operator:"*",left:r,right:o},s=i}else if(e[s]==="/"||e[s]==="%"){let o=e[s];s++;let{expr:i,pos:a}=ze(t,e,s);r={type:"ArithBinary",operator:o,left:r,right:i},s=a}else break;return{expr:r,pos:s}}function ze(t,e,n){let{expr:r,pos:s}=Et(t,e,n),o=D(e,s);if(e.slice(o,o+2)==="**"){o+=2;let{expr:i,pos:a}=ze(t,e,o);return{expr:{type:"ArithBinary",operator:"**",left:r,right:i},pos:a}}return{expr:r,pos:s}}function Et(t,e,n){let r=D(e,n);if(e.slice(r,r+2)==="++"||e.slice(r,r+2)==="--"){let s=e.slice(r,r+2);r+=2;let{expr:o,pos:i}=Et(t,e,r);return{expr:{type:"ArithUnary",operator:s,operand:o,prefix:!0},pos:i}}if(e[r]==="+"||e[r]==="-"||e[r]==="!"||e[r]==="~"){let s=e[r];r++;let{expr:o,pos:i}=Et(t,e,r);return{expr:{type:"ArithUnary",operator:s,operand:o,prefix:!0},pos:i}}return Un(t,e,r)}function zn(t,e){let n=t[e];return n==="$"||n==="`"}function Un(t,e,n){let{expr:r,pos:s}=$r(t,e,n),o=[r];for(;zn(e,s);){let{expr:i,pos:a}=$r(t,e,s);o.push(i),s=a}if(o.length>1&&(r={type:"ArithConcat",parts:o}),s=D(e,s),e.slice(s,s+2)==="++"||e.slice(s,s+2)==="--"){let i=e.slice(s,s+2);return s+=2,{expr:{type:"ArithUnary",operator:i,operand:r,prefix:!1},pos:s}}return{expr:r,pos:s}}function $r(t,e,n){let r=D(e,n);if(e.slice(r,r+3)==="$(("){r+=3;let s=1,o=r;for(;r<e.length-1&&s>0;)e[r]==="("&&e[r+1]==="("?(s++,r+=2):e[r]===")"&&e[r+1]===")"?(s--,s>0&&(r+=2)):r++;let i=e.slice(o,r),{expr:a}=te(t,i,0);return r+=2,{expr:{type:"ArithNested",expression:a},pos:r}}if(e.slice(r,r+2)==="$("&&e[r+2]!=="("){r+=2;let s=1,o=r;for(;r<e.length&&s>0;)e[r]==="("?s++:e[r]===")"&&s--,s>0&&r++;let i=e.slice(o,r);return r++,{expr:{type:"ArithCommandSubst",command:i},pos:r}}if(e[r]==="`"){r++;let s=r;for(;r<e.length&&e[r]!=="`";)r++;let o=e.slice(s,r);return e[r]==="`"&&r++,{expr:{type:"ArithCommandSubst",command:o},pos:r}}if(e[r]==="("){r++;let{expr:s,pos:o}=te(t,e,r);return r=D(e,o),e[r]===")"&&r++,{expr:{type:"ArithGroup",expression:s},pos:r}}if(/[0-9]/.test(e[r])){let s="",o=!1;for(;r<e.length;){let a=e[r];if(o)if(/[0-9a-zA-Z@_]/.test(a))s+=a,r++;else break;else if(a==="#")o=!0,s+=a,r++;else if(/[0-9a-fA-FxX]/.test(a))s+=a,r++;else break}if(e[r]==="."&&/[0-9]/.test(e[r+1]))throw new F(`${s}.${e[r+1]}...: syntax error: invalid arithmetic operator`);if(e[r]==="["){let a=e.slice(r).trim();return{expr:{type:"ArithNumberSubscript",number:s,errorToken:a},pos:e.length}}return{expr:{type:"ArithNumber",value:xe(s)},pos:r}}if(e[r]==="$"&&e[r+1]==="{"){let s=r+2,o=1,i=s;for(;i<e.length&&o>0;)e[i]==="{"?o++:e[i]==="}"&&o--,o>0&&i++;let a=e.slice(s,i),l=i+1;if(e[l]==="#"){let c=l+1;for(;c<e.length&&/[0-9a-zA-Z@_]/.test(e[c]);)c++;let f=e.slice(l+1,c);return{expr:{type:"ArithDynamicBase",baseExpr:a,value:f},pos:c}}if(/[0-9]/.test(e[l])||e[l]==="x"||e[l]==="X"){let c=l;if(e[l]==="x"||e[l]==="X")for(c++;c<e.length&&/[0-9a-fA-F]/.test(e[c]);)c++;else for(;c<e.length&&/[0-9]/.test(e[c]);)c++;let f=e.slice(l,c);return{expr:{type:"ArithDynamicNumber",prefix:a,suffix:f},pos:c}}return r=l,{expr:{type:"ArithBracedExpansion",content:a},pos:r}}if(e[r]==="$"&&r+1<e.length&&/[0-9]/.test(e[r+1])){r++;let s="";for(;r<e.length&&/[0-9]/.test(e[r]);)s+=e[r],r++;return{expr:{type:"ArithVariable",name:s},pos:r}}if(e[r]==="$"&&r+1<e.length&&/[a-zA-Z_]/.test(e[r+1])&&r++,/[a-zA-Z_]/.test(e[r])){let s="";for(;r<e.length&&/[a-zA-Z0-9_]/.test(e[r]);)s+=e[r],r++;if(e[r]==="["){r++;let i;if(e[r]==="'"||e[r]==='"'){let c=e[r];for(r++,i="";r<e.length&&e[r]!==c;)i+=e[r],r++;e[r]===c&&r++,r=D(e,r),e[r]==="]"&&r++}let a;if(i===void 0){let{expr:c,pos:f}=te(t,e,r);a=c,r=f,e[r]==="]"&&r++}if(r=D(e,r),e[r]==="["&&a)return{expr:{type:"ArithDoubleSubscript",array:s,index:a},pos:r};let l=["=","+=","-=","*=","/=","%=","<<=",">>=","&=","|=","^="];for(let c of l)if(e.slice(r,r+c.length)===c&&e.slice(r,r+c.length+1)!=="=="){r+=c.length;let{expr:f,pos:h}=Ue(t,e,r);return{expr:{type:"ArithAssignment",operator:c,variable:s,subscript:a,stringKey:i,value:f},pos:h}}return{expr:{type:"ArithArrayElement",array:s,index:a,stringKey:i},pos:r}}r=D(e,r);let o=["=","+=","-=","*=","/=","%=","<<=",">>=","&=","|=","^="];for(let i of o)if(e.slice(r,r+i.length)===i&&e.slice(r,r+i.length+1)!=="=="){r+=i.length;let{expr:a,pos:l}=Ue(t,e,r);return{expr:{type:"ArithAssignment",operator:i,variable:s,value:a},pos:l}}return{expr:{type:"ArithVariable",name:s},pos:r}}return{expr:{type:"ArithNumber",value:0},pos:r}}function xe(t){if(t.includes("#")){let[e,n]=t.split("#"),r=Number.parseInt(e,10);if(r<2||r>64)return Number.NaN;if(r<=36)return Number.parseInt(n,r);let s=0;for(let o of n){let i;if(o>="0"&&o<="9")i=o.charCodeAt(0)-48;else if(o>="a"&&o<="z")i=o.charCodeAt(0)-97+10;else if(o>="A"&&o<="Z")i=o.charCodeAt(0)-65+36;else if(o==="@")i=62;else if(o==="_")i=63;else return Number.NaN;if(i>=r)return Number.NaN;s=s*r+i}return s}return t.startsWith("0x")||t.startsWith("0X")?Number.parseInt(t.slice(2),16):t.startsWith("0")&&t.length>1&&/^[0-9]+$/.test(t)?/[89]/.test(t)?Number.NaN:Number.parseInt(t,8):Number.parseInt(t,10)}function D(t,e){for(;e<t.length;){if(t[e]==="\\"&&t[e+1]===`
|
|
3
3
|
`){e+=2;continue}if(/\s/.test(t[e])){e++;continue}break}return e}var A={script(t){return{type:"Script",statements:t}},statement(t,e=[],n=!1){return{type:"Statement",pipelines:t,operators:e,background:n}},pipeline(t,e=!1){return{type:"Pipeline",commands:t,negated:e}},simpleCommand(t,e=[],n=[],r=[]){return{type:"SimpleCommand",name:t,args:e,assignments:n,redirections:r}},word(t){return{type:"Word",parts:t}},literal(t){return{type:"Literal",value:t}},singleQuoted(t){return{type:"SingleQuoted",value:t}},doubleQuoted(t){return{type:"DoubleQuoted",parts:t}},escaped(t){return{type:"Escaped",value:t}},parameterExpansion(t,e=null){return{type:"ParameterExpansion",parameter:t,operation:e}},commandSubstitution(t,e=!1){return{type:"CommandSubstitution",body:t,legacy:e}},arithmeticExpansion(t){return{type:"ArithmeticExpansion",expression:t}},assignment(t,e,n=!1,r=null){return{type:"Assignment",name:t,value:e,append:n,array:r}},redirection(t,e,n=null){return{type:"Redirection",fd:n,operator:t,target:e}},hereDoc(t,e,n=!1,r=!1){return{type:"HereDoc",delimiter:t,content:e,stripTabs:n,quoted:r}},ifNode(t,e=null,n=[]){return{type:"If",clauses:t,elseBody:e,redirections:n}},forNode(t,e,n,r=[]){return{type:"For",variable:t,words:e,body:n,redirections:r}},whileNode(t,e,n=[]){return{type:"While",condition:t,body:e,redirections:n}},untilNode(t,e,n=[]){return{type:"Until",condition:t,body:e,redirections:n}},caseNode(t,e,n=[]){return{type:"Case",word:t,items:e,redirections:n}},caseItem(t,e,n=";;"){return{type:"CaseItem",patterns:t,body:e,terminator:n}},subshell(t,e=[]){return{type:"Subshell",body:t,redirections:e}},group(t,e=[]){return{type:"Group",body:t,redirections:e}},functionDef(t,e,n=[]){return{type:"FunctionDef",name:t,body:e,redirections:n}},conditionalCommand(t,e=[]){return{type:"ConditionalCommand",expression:t,redirections:e}},arithmeticCommand(t,e=[]){return{type:"ArithmeticCommand",expression:t,redirections:e}}};var u;(function(t){t.EOF="EOF",t.NEWLINE="NEWLINE",t.SEMICOLON="SEMICOLON",t.AMP="AMP",t.PIPE="PIPE",t.PIPE_AMP="PIPE_AMP",t.AND_AND="AND_AND",t.OR_OR="OR_OR",t.BANG="BANG",t.LESS="LESS",t.GREAT="GREAT",t.DLESS="DLESS",t.DGREAT="DGREAT",t.LESSAND="LESSAND",t.GREATAND="GREATAND",t.LESSGREAT="LESSGREAT",t.DLESSDASH="DLESSDASH",t.CLOBBER="CLOBBER",t.TLESS="TLESS",t.AND_GREAT="AND_GREAT",t.AND_DGREAT="AND_DGREAT",t.LPAREN="LPAREN",t.RPAREN="RPAREN",t.LBRACE="LBRACE",t.RBRACE="RBRACE",t.DSEMI="DSEMI",t.SEMI_AND="SEMI_AND",t.SEMI_SEMI_AND="SEMI_SEMI_AND",t.DBRACK_START="DBRACK_START",t.DBRACK_END="DBRACK_END",t.DPAREN_START="DPAREN_START",t.DPAREN_END="DPAREN_END",t.IF="IF",t.THEN="THEN",t.ELSE="ELSE",t.ELIF="ELIF",t.FI="FI",t.FOR="FOR",t.WHILE="WHILE",t.UNTIL="UNTIL",t.DO="DO",t.DONE="DONE",t.CASE="CASE",t.ESAC="ESAC",t.IN="IN",t.FUNCTION="FUNCTION",t.SELECT="SELECT",t.TIME="TIME",t.COPROC="COPROC",t.WORD="WORD",t.NAME="NAME",t.NUMBER="NUMBER",t.ASSIGNMENT_WORD="ASSIGNMENT_WORD",t.COMMENT="COMMENT",t.HEREDOC_CONTENT="HEREDOC_CONTENT"})(u||(u={}));var He={if:u.IF,then:u.THEN,else:u.ELSE,elif:u.ELIF,fi:u.FI,for:u.FOR,while:u.WHILE,until:u.UNTIL,do:u.DO,done:u.DONE,case:u.CASE,esac:u.ESAC,in:u.IN,function:u.FUNCTION,select:u.SELECT,time:u.TIME,coproc:u.COPROC};function Pr(t){let e=t.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);if(!e)return!1;let n=t.slice(e[0].length);if(n===""||n==="+")return!0;if(n[0]==="["){let r=0,s=0;for(;s<n.length;s++)if(n[s]==="[")r++;else if(n[s]==="]"&&(r--,r===0))break;if(r!==0||s>=n.length)return!1;let o=n.slice(s+1);return o===""||o==="+"}return!1}var Hn=[[";",";","&",u.SEMI_SEMI_AND],["<","<","<",u.TLESS],["&",">",">",u.AND_DGREAT]],Gn=[["[","[",u.DBRACK_START],["]","]",u.DBRACK_END],["(","(",u.DPAREN_START],[")",")",u.DPAREN_END],["&","&",u.AND_AND],["|","|",u.OR_OR],[";",";",u.DSEMI],[";","&",u.SEMI_AND],["|","&",u.PIPE_AMP],[">",">",u.DGREAT],["<","&",u.LESSAND],[">","&",u.GREATAND],["<",">",u.LESSGREAT],[">","|",u.CLOBBER],["&",">",u.AND_GREAT]],Vn={"|":u.PIPE,"&":u.AMP,";":u.SEMICOLON,"(":u.LPAREN,")":u.RPAREN,"<":u.LESS,">":u.GREAT};function Zn(t){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t)}var Ge=class{input;pos=0;line=1;column=1;tokens=[];pendingHeredocs=[];constructor(e){this.input=e}tokenize(){let n=this.input.length,r=this.tokens,s=this.pendingHeredocs;for(;this.pos<n&&(this.skipWhitespace(),!(this.pos>=n));){if(s.length>0&&r.length>0&&r[r.length-1].type===u.NEWLINE){this.readHeredocContent();continue}let o=this.nextToken();o&&r.push(o)}return r.push({type:u.EOF,value:"",start:this.pos,end:this.pos,line:this.line,column:this.column}),r}skipWhitespace(){let e=this.input,n=e.length,r=this.pos,s=this.column,o=this.line;for(;r<n;){let i=e[r];if(i===" "||i===" ")r++,s++;else if(i==="\\"&&e[r+1]===`
|
|
4
4
|
`)r+=2,o++,s=1;else break}this.pos=r,this.column=s,this.line=o}nextToken(){let e=this.input,n=this.pos,r=this.line,s=this.column,o=e[n],i=e[n+1],a=e[n+2];if(o==="#")return this.readComment(n,r,s);if(o===`
|
|
5
5
|
`)return this.pos=n+1,this.line++,this.column=1,{type:u.NEWLINE,value:`
|