just-bash-nx 3.0.6 → 3.0.8
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-PPE7NSB2.js → chunk-O3SBI3K7.js} +5 -5
- package/dist/bin/chunks/{expansion-FIY4KMS5.js → expansion-E23BQBTL.js} +1 -1
- package/dist/bin/default-init.sh +12 -71
- package/dist/bin/just-bash.js +7 -7
- package/dist/bin/shell/chunks/{chunk-PPE7NSB2.js → chunk-O3SBI3K7.js} +5 -5
- package/dist/bin/shell/chunks/{expansion-FIY4KMS5.js → expansion-E23BQBTL.js} +1 -1
- package/dist/bin/shell/shell.js +7 -7
- package/dist/bundle/browser.js +77 -77
- package/dist/bundle/chunks/{chunk-4XUQHQ6I.js → chunk-P7XJZDHE.js} +5 -5
- package/dist/bundle/chunks/{expansion-XT73ZVQC.js → expansion-SYCUAUC5.js} +1 -1
- package/dist/bundle/index.cjs +87 -87
- package/dist/bundle/index.js +7 -7
- package/dist/interpreter/builtins/source.d.ts +1 -1
- package/package.json +32 -33
- package/vendor/cpython-emscripten/python.wasm +0 -0
package/dist/bundle/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{B as on,C as an,D as de,E as et,F as se,G as ke,H as Kt,I as ln,J as F,K as cn,L as un,M as _e,N as Us,O as Xt,P as H,a as Yr,b as Ms,c as Qr,d as qt,e as ee,f as B,g as fe,h as ne,i as xe,j as He,k as Ws,l as Gt,m as Jr,n as zs,o as en,p as Ee,q as We,r as tn,s as sn,t as Vs,u as Bs,v as Ze,w as rn,x as nn,y as Ae,z as js}from"./chunks/chunk-4XUQHQ6I.js";import{a as Fe,b as Me,c as be}from"./chunks/chunk-R6VWJ2ZL.js";import{c as Fs}from"./chunks/chunk-CWQS3NFK.js";import{a as Mt,b as Wt}from"./chunks/chunk-A5O5YHGN.js";import{a as Ls}from"./chunks/chunk-IPJHKYVM.js";import{a as Ue,b as ve,c as Ct}from"./chunks/chunk-OJDRYQWQ.js";import{a as _t,b as Xr}from"./chunks/chunk-24IMIIXA.js";import{a as Ve,b as me}from"./chunks/chunk-5QMZ5MUS.js";import{a as kt}from"./chunks/chunk-B74TABJS.js";import{a as At,b as zt,c as io,d as Be,e as oo,f as Vt,g as ao,h as Bt,i as lo,j as co}from"./chunks/chunk-AH77CRWX.js";import{a as ye,b as ge,c as ue,d as we,e as Gr,f as j,g as Je,h as jt,i as Ut,j as Kr,k as J,l as Ht,m as je,n as Zt,o as Pe}from"./chunks/chunk-57MC5FQY.js";import"./chunks/chunk-NUFRM6SI.js";import{a as Le}from"./chunks/chunk-3THT3N7L.js";import{a as Ie}from"./chunks/chunk-44UOCSGV.js";import{a as Is}from"./chunks/chunk-DXB73IDG.js";var tt=[{name:"echo",load:async()=>(await import("./chunks/echo-O45JWWI2.js")).echoCommand},{name:"cat",load:async()=>(await import("./chunks/cat-VQEWZT5O.js")).catCommand},{name:"printf",load:async()=>(await import("./chunks/printf-CEKOHUH5.js")).printfCommand},{name:"ls",load:async()=>(await import("./chunks/ls-KSXFZCWH.js")).lsCommand},{name:"mkdir",load:async()=>(await import("./chunks/mkdir-TDEMSB6C.js")).mkdirCommand},{name:"rmdir",load:async()=>(await import("./chunks/rmdir-XTQXT7RK.js")).rmdirCommand},{name:"touch",load:async()=>(await import("./chunks/touch-DX2IJOQ4.js")).touchCommand},{name:"rm",load:async()=>(await import("./chunks/rm-RTZG23RL.js")).rmCommand},{name:"cp",load:async()=>(await import("./chunks/cp-XOYR4ABJ.js")).cpCommand},{name:"mv",load:async()=>(await import("./chunks/mv-Z6MORUFL.js")).mvCommand},{name:"ln",load:async()=>(await import("./chunks/ln-4TRFBYAT.js")).lnCommand},{name:"chmod",load:async()=>(await import("./chunks/chmod-SYMGL4JA.js")).chmodCommand},{name:"pwd",load:async()=>(await import("./chunks/pwd-D4OZ7N27.js")).pwdCommand},{name:"readlink",load:async()=>(await import("./chunks/readlink-MI4GCHJF.js")).readlinkCommand},{name:"head",load:async()=>(await import("./chunks/head-FG33BE3W.js")).headCommand},{name:"tail",load:async()=>(await import("./chunks/tail-EDLAF4WW.js")).tailCommand},{name:"wc",load:async()=>(await import("./chunks/wc-J6YO4AFR.js")).wcCommand},{name:"stat",load:async()=>(await import("./chunks/stat-BT5A227F.js")).statCommand},{name:"grep",load:async()=>(await import("./chunks/grep-7CE2SS3X.js")).grepCommand},{name:"fgrep",load:async()=>(await import("./chunks/grep-7CE2SS3X.js")).fgrepCommand},{name:"egrep",load:async()=>(await import("./chunks/grep-7CE2SS3X.js")).egrepCommand},{name:"rg",load:async()=>(await import("./chunks/rg-GMXITNCP.js")).rgCommand},{name:"sed",load:async()=>(await import("./chunks/sed-HKXUNRIZ.js")).sedCommand},{name:"awk",load:async()=>(await import("./chunks/awk2-IW7TXS45.js")).awkCommand2},{name:"sort",load:async()=>(await import("./chunks/sort-5KALNK6P.js")).sortCommand},{name:"uniq",load:async()=>(await import("./chunks/uniq-DCP6SV3B.js")).uniqCommand},{name:"comm",load:async()=>(await import("./chunks/comm-AXP77KC4.js")).commCommand},{name:"cut",load:async()=>(await import("./chunks/cut-RBX7IXC7.js")).cutCommand},{name:"paste",load:async()=>(await import("./chunks/paste-HIF3YKHC.js")).pasteCommand},{name:"tr",load:async()=>(await import("./chunks/tr-2QSZN4JB.js")).trCommand},{name:"rev",load:async()=>(await import("./chunks/rev-SKETTPXH.js")).rev},{name:"nl",load:async()=>(await import("./chunks/nl-LBU6FPPF.js")).nl},{name:"fold",load:async()=>(await import("./chunks/fold-V23GDLZD.js")).fold},{name:"expand",load:async()=>(await import("./chunks/expand-UMGRCDTC.js")).expand},{name:"unexpand",load:async()=>(await import("./chunks/unexpand-ZTD2RXS2.js")).unexpand},{name:"strings",load:async()=>(await import("./chunks/strings-7VYWRFIZ.js")).strings},{name:"split",load:async()=>(await import("./chunks/split-4CXZNBGE.js")).split},{name:"column",load:async()=>(await import("./chunks/column-DCCLCHUR.js")).column},{name:"join",load:async()=>(await import("./chunks/join-TLHD7S7W.js")).join},{name:"tee",load:async()=>(await import("./chunks/tee-DUMXETDQ.js")).teeCommand},{name:"find",load:async()=>(await import("./chunks/find-DH2ALKQS.js")).findCommand},{name:"basename",load:async()=>(await import("./chunks/basename-AA2KJYZQ.js")).basenameCommand},{name:"dirname",load:async()=>(await import("./chunks/dirname-LEMTZZFS.js")).dirnameCommand},{name:"tree",load:async()=>(await import("./chunks/tree-LYXBS7DC.js")).treeCommand},{name:"du",load:async()=>(await import("./chunks/du-WO2ENHXQ.js")).duCommand},{name:"env",load:async()=>(await import("./chunks/env-GBSZDQLS.js")).envCommand},{name:"printenv",load:async()=>(await import("./chunks/env-GBSZDQLS.js")).printenvCommand},{name:"alias",load:async()=>(await import("./chunks/alias-JE7RI5QX.js")).aliasCommand},{name:"unalias",load:async()=>(await import("./chunks/alias-JE7RI5QX.js")).unaliasCommand},{name:"history",load:async()=>(await import("./chunks/history-J4QRNGRO.js")).historyCommand},{name:"xargs",load:async()=>(await import("./chunks/xargs-LB2QOP6N.js")).xargsCommand},{name:"true",load:async()=>(await import("./chunks/true-WHJNXCHG.js")).trueCommand},{name:"false",load:async()=>(await import("./chunks/true-WHJNXCHG.js")).falseCommand},{name:"clear",load:async()=>(await import("./chunks/clear-5CZ5X4YR.js")).clearCommand},{name:"bash",load:async()=>(await import("./chunks/bash-4WLDO24C.js")).bashCommand},{name:"sh",load:async()=>(await import("./chunks/bash-4WLDO24C.js")).shCommand},{name:"jq",load:async()=>(await import("./chunks/jq-EQZB7JUS.js")).jqCommand},{name:"base64",load:async()=>(await import("./chunks/base64-FJOOBRMC.js")).base64Command},{name:"diff",load:async()=>(await import("./chunks/diff-AYXX5MI5.js")).diffCommand},{name:"date",load:async()=>(await import("./chunks/date-DD7FVA2V.js")).dateCommand},{name:"sleep",load:async()=>(await import("./chunks/sleep-VZFPZFWA.js")).sleepCommand},{name:"timeout",load:async()=>(await import("./chunks/timeout-PWE4AOYD.js")).timeoutCommand},{name:"time",load:async()=>(await import("./chunks/time-U22WPHDM.js")).timeCommand},{name:"seq",load:async()=>(await import("./chunks/seq-RN5ZUASB.js")).seqCommand},{name:"expr",load:async()=>(await import("./chunks/expr-YYCVMXE3.js")).exprCommand},{name:"md5sum",load:async()=>(await import("./chunks/md5sum-XMCB7L5Z.js")).md5sumCommand},{name:"sha1sum",load:async()=>(await import("./chunks/sha1sum-ZHNS7PS4.js")).sha1sumCommand},{name:"sha256sum",load:async()=>(await import("./chunks/sha256sum-YWE2HB65.js")).sha256sumCommand},{name:"file",load:async()=>(await import("./chunks/file-IGDTDPLG.js")).fileCommand},{name:"html-to-markdown",load:async()=>(await import("./chunks/html-to-markdown-AQHC3PHD.js")).htmlToMarkdownCommand},{name:"help",load:async()=>(await import("./chunks/help-VVWX7SA5.js")).helpCommand},{name:"which",load:async()=>(await import("./chunks/which-AFLRHHI7.js")).whichCommand},{name:"tac",load:async()=>(await import("./chunks/tac-74F3WHUM.js")).tac},{name:"hostname",load:async()=>(await import("./chunks/hostname-BK6HG2DE.js")).hostname},{name:"whoami",load:async()=>(await import("./chunks/whoami-DGKU3D2X.js")).whoami},{name:"od",load:async()=>(await import("./chunks/od-O6TPXWVX.js")).od},{name:"gzip",load:async()=>(await import("./chunks/gzip-EVI6YRMT.js")).gzipCommand},{name:"gunzip",load:async()=>(await import("./chunks/gzip-EVI6YRMT.js")).gunzipCommand},{name:"zcat",load:async()=>(await import("./chunks/gzip-EVI6YRMT.js")).zcatCommand}];(typeof __BROWSER__>"u"||!__BROWSER__)&&(tt.push({name:"tar",load:async()=>(await import("./chunks/tar-RKYTUGDT.js")).tarCommand}),tt.push({name:"yq",load:async()=>(await import("./chunks/yq-HBHRGN4X.js")).yqCommand}),tt.push({name:"xan",load:async()=>(await import("./chunks/xan-X7AV7KKG.js")).xanCommand}),tt.push({name:"sqlite3",load:async()=>(await import("./chunks/sqlite3-FXN2MHWU.js")).sqlite3Command}));var Yt=[];(typeof __BROWSER__>"u"||!__BROWSER__)&&(Yt.push({name:"python3",load:async()=>(await import("./chunks/python3-ZR6W2FR3.js")).python3Command}),Yt.push({name:"python",load:async()=>(await import("./chunks/python3-ZR6W2FR3.js")).pythonCommand}));var Qt=[];(typeof __BROWSER__>"u"||!__BROWSER__)&&(Qt.push({name:"js-exec",load:async()=>(await import("./chunks/js-exec-2U7NEXAP.js")).jsExecCommand}),Qt.push({name:"node",load:async()=>(await import("./chunks/js-exec-2U7NEXAP.js")).nodeStubCommand}));var dn=[{name:"curl",load:async()=>(await import("./chunks/curl-47BFPSFW.js")).curlCommand}],fn=new Map;function Jt(e){return{name:e.name,async execute(t,s){let r=fn.get(e.name);if(r||(r=await me.runTrustedAsync(()=>e.load()),fn.set(e.name,r)),s.coverage&&(typeof __BROWSER__>"u"||!__BROWSER__)){let{emitFlagCoverage:n}=await import("./chunks/flag-coverage-Z434UZKN.js");n(s.coverage,e.name,t)}return r.execute(t,s)}}}function uo(){return tt.map(e=>e.name)}function fo(){return dn.map(e=>e.name)}function hn(e){return(e?tt.filter(s=>e.includes(s.name)):tt).map(Jt)}function pn(){return dn.map(Jt)}function ho(){return Yt.map(e=>e.name)}function mn(){return Yt.map(Jt)}function po(){return Qt.map(e=>e.name)}function yn(){return Qt.map(Jt)}function gn(e){return"load"in e&&typeof e.load=="function"}function mo(e,t){return{name:e,trusted:!0,execute:t}}function wn(e){let t=null;return{name:e.name,trusted:!0,async execute(s,r){return t||(t=await e.load()),t.execute(s,r)}}}function T(e){if(!e||e==="/")return"/";let t=e.endsWith("/")&&e!=="/"?e.slice(0,-1):e;t.startsWith("/")||(t=`/${t}`);let s=t.split("/").filter(n=>n&&n!=="."),r=[];for(let n of s)n===".."?r.pop():r.push(n);return`/${r.join("/")}`||"/"}function D(e,t){if(e.includes("\0"))throw new Error(`ENOENT: path contains null byte, ${t} '${e}'`)}function st(e){let t=T(e);if(t==="/")return"/";let s=t.lastIndexOf("/");return s===0?"/":t.slice(0,s)}function qe(e,t){if(t.startsWith("/"))return T(t);let s=e==="/"?`/${t}`:`${e}/${t}`;return T(s)}function Ge(e,t){return e==="/"?`/${t}`:`${e}/${t}`}function ct(e,t){if(t.startsWith("/"))return T(t);let s=st(e);return T(Ge(s,t))}var ut=new TextEncoder;function yo(e){return typeof e=="object"&&e!==null&&!(e instanceof Uint8Array)&&"content"in e}var ze=class{data=new Map;constructor(t){if(this.data.set("/",{type:"directory",mode:493,mtime:new Date}),t)for(let[s,r]of Object.entries(t))typeof r=="function"?this.writeFileLazy(s,r):yo(r)?this.writeFileSync(s,r.content,void 0,{mode:r.mode,mtime:r.mtime}):this.writeFileSync(s,r)}ensureParentDirs(t){let s=st(t);s!=="/"&&(this.data.has(s)||(this.ensureParentDirs(s),this.data.set(s,{type:"directory",mode:493,mtime:new Date})))}writeFileSync(t,s,r,n){D(t,"write");let i=T(t);this.ensureParentDirs(i);let o=be(r),a=Fe(s,o);this.data.set(i,{type:"file",content:a,mode:n?.mode??420,mtime:n?.mtime??new Date})}writeFileLazy(t,s,r){D(t,"write");let n=T(t);this.ensureParentDirs(n),this.data.set(n,{type:"file",lazy:s,mode:r?.mode??420,mtime:r?.mtime??new Date})}async materializeLazy(t,s){let r=await s.lazy(),i={type:"file",content:typeof r=="string"?ut.encode(r):r,mode:s.mode,mtime:s.mtime};return this.data.set(t,i),i}async readFile(t,s){let r=await this.readFileBuffer(t),n=be(s);return Me(r,n)}async readFileBytes(t){let s=await this.readFileBuffer(t);return Me(s,"binary")}async readFileBuffer(t){D(t,"open");let s=this.resolvePathWithSymlinks(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, open '${t}'`);if(r.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);if("lazy"in r){let n=await this.materializeLazy(s,r);return n.content instanceof Uint8Array?n.content:ut.encode(n.content)}return r.content instanceof Uint8Array?r.content:ut.encode(r.content)}async writeFile(t,s,r){this.writeFileSync(t,s,r)}async appendFile(t,s,r){D(t,"append");let n=T(t),i=this.data.get(n);if(i&&i.type==="directory")throw new Error(`EISDIR: illegal operation on a directory, write '${t}'`);let o=be(r),a=Fe(s,o);if(i?.type==="file"){let l=i;"lazy"in l&&(l=await this.materializeLazy(n,l));let c="content"in l&&l.content instanceof Uint8Array?l.content:ut.encode("content"in l?l.content:""),u=new Uint8Array(c.length+a.length);u.set(c),u.set(a,c.length),this.data.set(n,{type:"file",content:u,mode:l.mode,mtime:new Date})}else this.writeFileSync(t,s,r)}async exists(t){if(t.includes("\0"))return!1;try{let s=this.resolvePathWithSymlinks(t);return this.data.has(s)}catch{return!1}}async stat(t){D(t,"stat");let s=this.resolvePathWithSymlinks(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, stat '${t}'`);r.type==="file"&&"lazy"in r&&(r=await this.materializeLazy(s,r));let n=0;return r.type==="file"&&"content"in r&&r.content&&(r.content instanceof Uint8Array?n=r.content.length:n=ut.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:n,mtime:r.mtime||new Date}}async lstat(t){D(t,"lstat");let s=this.resolveIntermediateSymlinks(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, lstat '${t}'`);if(r.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:r.mode,size:r.target.length,mtime:r.mtime||new Date};r.type==="file"&&"lazy"in r&&(r=await this.materializeLazy(s,r));let n=0;return r.type==="file"&&"content"in r&&r.content&&(r.content instanceof Uint8Array?n=r.content.length:n=ut.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:n,mtime:r.mtime||new Date}}resolveIntermediateSymlinks(t){let s=T(t);if(s==="/")return"/";let r=s.slice(1).split("/");if(r.length<=1)return s;let n="",i=new Set;for(let o=0;o<r.length-1;o++){let a=r[o];n=`${n}/${a}`;let l=this.data.get(n),c=0,u=40;for(;l&&l.type==="symlink"&&c<u;){if(i.has(n))throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`);i.add(n),n=ct(n,l.target),l=this.data.get(n),c++}if(c>=u)throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`)}return`${n}/${r[r.length-1]}`}resolvePathWithSymlinks(t){let s=T(t);if(s==="/")return"/";let r=s.slice(1).split("/"),n="",i=new Set;for(let o of r){n=`${n}/${o}`;let a=this.data.get(n),l=0,c=40;for(;a&&a.type==="symlink"&&l<c;){if(i.has(n))throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`);i.add(n),n=ct(n,a.target),a=this.data.get(n),l++}if(l>=c)throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`)}return n}async mkdir(t,s){this.mkdirSync(t,s)}mkdirSync(t,s){D(t,"mkdir");let r=T(t);if(this.data.has(r)){if(this.data.get(r)?.type==="file")throw new Error(`EEXIST: file already exists, mkdir '${t}'`);if(!s?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${t}'`);return}let n=st(r);if(n!=="/"&&!this.data.has(n))if(s?.recursive)this.mkdirSync(n,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${t}'`);this.data.set(r,{type:"directory",mode:493,mtime:new Date})}async readdir(t){return(await this.readdirWithFileTypes(t)).map(r=>r.name)}async readdirWithFileTypes(t){D(t,"scandir");let s=T(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);let n=new Set;for(;r&&r.type==="symlink";){if(n.has(s))throw new Error(`ELOOP: too many levels of symbolic links, scandir '${t}'`);n.add(s),s=ct(s,r.target),r=this.data.get(s)}if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);if(r.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${t}'`);let i=s==="/"?"/":`${s}/`,o=new Map;for(let[a,l]of this.data.entries())if(a!==s&&a.startsWith(i)){let c=a.slice(i.length),u=c.split("/")[0];u&&!c.includes("/",u.length)&&!o.has(u)&&o.set(u,{name:u,isFile:l.type==="file",isDirectory:l.type==="directory",isSymbolicLink:l.type==="symlink"})}return Array.from(o.values()).sort((a,l)=>a.name<l.name?-1:a.name>l.name?1:0)}async rm(t,s){D(t,"rm");let r=T(t),n=this.data.get(r);if(!n){if(s?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${t}'`)}if(n.type==="directory"){let i=await this.readdir(r);if(i.length>0){if(!s?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${t}'`);for(let o of i){let a=Ge(r,o);await this.rm(a,s)}}}this.data.delete(r)}async cp(t,s,r){D(t,"cp"),D(s,"cp");let n=T(t),i=T(s),o=this.data.get(n);if(!o)throw new Error(`ENOENT: no such file or directory, cp '${t}'`);if(o.type==="file")if(this.ensureParentDirs(i),"content"in o){let a=o.content instanceof Uint8Array?new Uint8Array(o.content):o.content;this.data.set(i,{...o,content:a})}else this.data.set(i,{...o});else if(o.type==="symlink")this.ensureParentDirs(i),this.data.set(i,{...o});else if(o.type==="directory"){if(!r?.recursive)throw new Error(`EISDIR: is a directory, cp '${t}'`);await this.mkdir(i,{recursive:!0});let a=await this.readdir(n);for(let l of a){let c=Ge(n,l),u=Ge(i,l);await this.cp(c,u,r)}}}async mv(t,s){await this.cp(t,s,{recursive:!0}),await this.rm(t,{recursive:!0})}getAllPaths(){return Array.from(this.data.keys())}resolvePath(t,s){return qe(t,s)}async chmod(t,s){D(t,"chmod");let r=T(t),n=this.data.get(r);if(!n)throw new Error(`ENOENT: no such file or directory, chmod '${t}'`);n.mode=s}async symlink(t,s){D(s,"symlink");let r=T(s);if(this.data.has(r))throw new Error(`EEXIST: file already exists, symlink '${s}'`);this.ensureParentDirs(r),this.data.set(r,{type:"symlink",target:t,mode:511,mtime:new Date})}async link(t,s){D(t,"link"),D(s,"link");let r=T(t),n=T(s),i=this.data.get(r);if(!i)throw new Error(`ENOENT: no such file or directory, link '${t}'`);if(i.type!=="file")throw new Error(`EPERM: operation not permitted, link '${t}'`);if(this.data.has(n))throw new Error(`EEXIST: file already exists, link '${s}'`);let o=i;"lazy"in o&&(o=await this.materializeLazy(r,o)),this.ensureParentDirs(n),this.data.set(n,{type:"file",content:o.content,mode:o.mode,mtime:o.mtime})}async readlink(t){D(t,"readlink");let s=T(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, readlink '${t}'`);if(r.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${t}'`);return r.target}async realpath(t){D(t,"realpath");let s=this.resolvePathWithSymlinks(t);if(!this.data.has(s))throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);return s}async utimes(t,s,r){D(t,"utimes");let n=T(t),i=this.resolvePathWithSymlinks(n),o=this.data.get(i);if(!o)throw new Error(`ENOENT: no such file or directory, utimes '${t}'`);o.mtime=r}};function go(e){let t=e;return typeof t.mkdirSync=="function"&&typeof t.writeFileSync=="function"}function wo(e,t){e.mkdirSync("/bin",{recursive:!0}),e.mkdirSync("/usr/bin",{recursive:!0}),t&&(e.mkdirSync("/home/user",{recursive:!0}),e.mkdirSync("/tmp",{recursive:!0}))}function vo(e){e.mkdirSync("/dev",{recursive:!0}),e.writeFileSync("/dev/null",""),e.writeFileSync("/dev/zero",new Uint8Array(0)),e.writeFileSync("/dev/stdin",""),e.writeFileSync("/dev/stdout",""),e.writeFileSync("/dev/stderr","")}function bo(e,t){e.mkdirSync("/proc/self/fd",{recursive:!0}),e.writeFileSync("/proc/version",`${Yr}
|
|
1
|
+
import{B as on,C as an,D as de,E as et,F as se,G as ke,H as Kt,I as ln,J as F,K as cn,L as un,M as _e,N as Us,O as Xt,P as H,a as Yr,b as Ms,c as Qr,d as qt,e as ee,f as B,g as fe,h as ne,i as xe,j as He,k as Ws,l as Gt,m as Jr,n as zs,o as en,p as Ee,q as We,r as tn,s as sn,t as Vs,u as Bs,v as Ze,w as rn,x as nn,y as Ae,z as js}from"./chunks/chunk-P7XJZDHE.js";import{a as Fe,b as Me,c as be}from"./chunks/chunk-R6VWJ2ZL.js";import{c as Fs}from"./chunks/chunk-CWQS3NFK.js";import{a as Mt,b as Wt}from"./chunks/chunk-A5O5YHGN.js";import{a as Ls}from"./chunks/chunk-IPJHKYVM.js";import{a as Ue,b as ve,c as Ct}from"./chunks/chunk-OJDRYQWQ.js";import{a as _t,b as Xr}from"./chunks/chunk-24IMIIXA.js";import{a as Ve,b as me}from"./chunks/chunk-5QMZ5MUS.js";import{a as kt}from"./chunks/chunk-B74TABJS.js";import{a as At,b as zt,c as io,d as Be,e as oo,f as Vt,g as ao,h as Bt,i as lo,j as co}from"./chunks/chunk-AH77CRWX.js";import{a as ye,b as ge,c as ue,d as we,e as Gr,f as j,g as Je,h as jt,i as Ut,j as Kr,k as J,l as Ht,m as je,n as Zt,o as Pe}from"./chunks/chunk-57MC5FQY.js";import"./chunks/chunk-NUFRM6SI.js";import{a as Le}from"./chunks/chunk-3THT3N7L.js";import{a as Ie}from"./chunks/chunk-44UOCSGV.js";import{a as Is}from"./chunks/chunk-DXB73IDG.js";var tt=[{name:"echo",load:async()=>(await import("./chunks/echo-O45JWWI2.js")).echoCommand},{name:"cat",load:async()=>(await import("./chunks/cat-VQEWZT5O.js")).catCommand},{name:"printf",load:async()=>(await import("./chunks/printf-CEKOHUH5.js")).printfCommand},{name:"ls",load:async()=>(await import("./chunks/ls-KSXFZCWH.js")).lsCommand},{name:"mkdir",load:async()=>(await import("./chunks/mkdir-TDEMSB6C.js")).mkdirCommand},{name:"rmdir",load:async()=>(await import("./chunks/rmdir-XTQXT7RK.js")).rmdirCommand},{name:"touch",load:async()=>(await import("./chunks/touch-DX2IJOQ4.js")).touchCommand},{name:"rm",load:async()=>(await import("./chunks/rm-RTZG23RL.js")).rmCommand},{name:"cp",load:async()=>(await import("./chunks/cp-XOYR4ABJ.js")).cpCommand},{name:"mv",load:async()=>(await import("./chunks/mv-Z6MORUFL.js")).mvCommand},{name:"ln",load:async()=>(await import("./chunks/ln-4TRFBYAT.js")).lnCommand},{name:"chmod",load:async()=>(await import("./chunks/chmod-SYMGL4JA.js")).chmodCommand},{name:"pwd",load:async()=>(await import("./chunks/pwd-D4OZ7N27.js")).pwdCommand},{name:"readlink",load:async()=>(await import("./chunks/readlink-MI4GCHJF.js")).readlinkCommand},{name:"head",load:async()=>(await import("./chunks/head-FG33BE3W.js")).headCommand},{name:"tail",load:async()=>(await import("./chunks/tail-EDLAF4WW.js")).tailCommand},{name:"wc",load:async()=>(await import("./chunks/wc-J6YO4AFR.js")).wcCommand},{name:"stat",load:async()=>(await import("./chunks/stat-BT5A227F.js")).statCommand},{name:"grep",load:async()=>(await import("./chunks/grep-7CE2SS3X.js")).grepCommand},{name:"fgrep",load:async()=>(await import("./chunks/grep-7CE2SS3X.js")).fgrepCommand},{name:"egrep",load:async()=>(await import("./chunks/grep-7CE2SS3X.js")).egrepCommand},{name:"rg",load:async()=>(await import("./chunks/rg-GMXITNCP.js")).rgCommand},{name:"sed",load:async()=>(await import("./chunks/sed-HKXUNRIZ.js")).sedCommand},{name:"awk",load:async()=>(await import("./chunks/awk2-IW7TXS45.js")).awkCommand2},{name:"sort",load:async()=>(await import("./chunks/sort-5KALNK6P.js")).sortCommand},{name:"uniq",load:async()=>(await import("./chunks/uniq-DCP6SV3B.js")).uniqCommand},{name:"comm",load:async()=>(await import("./chunks/comm-AXP77KC4.js")).commCommand},{name:"cut",load:async()=>(await import("./chunks/cut-RBX7IXC7.js")).cutCommand},{name:"paste",load:async()=>(await import("./chunks/paste-HIF3YKHC.js")).pasteCommand},{name:"tr",load:async()=>(await import("./chunks/tr-2QSZN4JB.js")).trCommand},{name:"rev",load:async()=>(await import("./chunks/rev-SKETTPXH.js")).rev},{name:"nl",load:async()=>(await import("./chunks/nl-LBU6FPPF.js")).nl},{name:"fold",load:async()=>(await import("./chunks/fold-V23GDLZD.js")).fold},{name:"expand",load:async()=>(await import("./chunks/expand-UMGRCDTC.js")).expand},{name:"unexpand",load:async()=>(await import("./chunks/unexpand-ZTD2RXS2.js")).unexpand},{name:"strings",load:async()=>(await import("./chunks/strings-7VYWRFIZ.js")).strings},{name:"split",load:async()=>(await import("./chunks/split-4CXZNBGE.js")).split},{name:"column",load:async()=>(await import("./chunks/column-DCCLCHUR.js")).column},{name:"join",load:async()=>(await import("./chunks/join-TLHD7S7W.js")).join},{name:"tee",load:async()=>(await import("./chunks/tee-DUMXETDQ.js")).teeCommand},{name:"find",load:async()=>(await import("./chunks/find-DH2ALKQS.js")).findCommand},{name:"basename",load:async()=>(await import("./chunks/basename-AA2KJYZQ.js")).basenameCommand},{name:"dirname",load:async()=>(await import("./chunks/dirname-LEMTZZFS.js")).dirnameCommand},{name:"tree",load:async()=>(await import("./chunks/tree-LYXBS7DC.js")).treeCommand},{name:"du",load:async()=>(await import("./chunks/du-WO2ENHXQ.js")).duCommand},{name:"env",load:async()=>(await import("./chunks/env-GBSZDQLS.js")).envCommand},{name:"printenv",load:async()=>(await import("./chunks/env-GBSZDQLS.js")).printenvCommand},{name:"alias",load:async()=>(await import("./chunks/alias-JE7RI5QX.js")).aliasCommand},{name:"unalias",load:async()=>(await import("./chunks/alias-JE7RI5QX.js")).unaliasCommand},{name:"history",load:async()=>(await import("./chunks/history-J4QRNGRO.js")).historyCommand},{name:"xargs",load:async()=>(await import("./chunks/xargs-LB2QOP6N.js")).xargsCommand},{name:"true",load:async()=>(await import("./chunks/true-WHJNXCHG.js")).trueCommand},{name:"false",load:async()=>(await import("./chunks/true-WHJNXCHG.js")).falseCommand},{name:"clear",load:async()=>(await import("./chunks/clear-5CZ5X4YR.js")).clearCommand},{name:"bash",load:async()=>(await import("./chunks/bash-4WLDO24C.js")).bashCommand},{name:"sh",load:async()=>(await import("./chunks/bash-4WLDO24C.js")).shCommand},{name:"jq",load:async()=>(await import("./chunks/jq-EQZB7JUS.js")).jqCommand},{name:"base64",load:async()=>(await import("./chunks/base64-FJOOBRMC.js")).base64Command},{name:"diff",load:async()=>(await import("./chunks/diff-AYXX5MI5.js")).diffCommand},{name:"date",load:async()=>(await import("./chunks/date-DD7FVA2V.js")).dateCommand},{name:"sleep",load:async()=>(await import("./chunks/sleep-VZFPZFWA.js")).sleepCommand},{name:"timeout",load:async()=>(await import("./chunks/timeout-PWE4AOYD.js")).timeoutCommand},{name:"time",load:async()=>(await import("./chunks/time-U22WPHDM.js")).timeCommand},{name:"seq",load:async()=>(await import("./chunks/seq-RN5ZUASB.js")).seqCommand},{name:"expr",load:async()=>(await import("./chunks/expr-YYCVMXE3.js")).exprCommand},{name:"md5sum",load:async()=>(await import("./chunks/md5sum-XMCB7L5Z.js")).md5sumCommand},{name:"sha1sum",load:async()=>(await import("./chunks/sha1sum-ZHNS7PS4.js")).sha1sumCommand},{name:"sha256sum",load:async()=>(await import("./chunks/sha256sum-YWE2HB65.js")).sha256sumCommand},{name:"file",load:async()=>(await import("./chunks/file-IGDTDPLG.js")).fileCommand},{name:"html-to-markdown",load:async()=>(await import("./chunks/html-to-markdown-AQHC3PHD.js")).htmlToMarkdownCommand},{name:"help",load:async()=>(await import("./chunks/help-VVWX7SA5.js")).helpCommand},{name:"which",load:async()=>(await import("./chunks/which-AFLRHHI7.js")).whichCommand},{name:"tac",load:async()=>(await import("./chunks/tac-74F3WHUM.js")).tac},{name:"hostname",load:async()=>(await import("./chunks/hostname-BK6HG2DE.js")).hostname},{name:"whoami",load:async()=>(await import("./chunks/whoami-DGKU3D2X.js")).whoami},{name:"od",load:async()=>(await import("./chunks/od-O6TPXWVX.js")).od},{name:"gzip",load:async()=>(await import("./chunks/gzip-EVI6YRMT.js")).gzipCommand},{name:"gunzip",load:async()=>(await import("./chunks/gzip-EVI6YRMT.js")).gunzipCommand},{name:"zcat",load:async()=>(await import("./chunks/gzip-EVI6YRMT.js")).zcatCommand}];(typeof __BROWSER__>"u"||!__BROWSER__)&&(tt.push({name:"tar",load:async()=>(await import("./chunks/tar-RKYTUGDT.js")).tarCommand}),tt.push({name:"yq",load:async()=>(await import("./chunks/yq-HBHRGN4X.js")).yqCommand}),tt.push({name:"xan",load:async()=>(await import("./chunks/xan-X7AV7KKG.js")).xanCommand}),tt.push({name:"sqlite3",load:async()=>(await import("./chunks/sqlite3-FXN2MHWU.js")).sqlite3Command}));var Yt=[];(typeof __BROWSER__>"u"||!__BROWSER__)&&(Yt.push({name:"python3",load:async()=>(await import("./chunks/python3-ZR6W2FR3.js")).python3Command}),Yt.push({name:"python",load:async()=>(await import("./chunks/python3-ZR6W2FR3.js")).pythonCommand}));var Qt=[];(typeof __BROWSER__>"u"||!__BROWSER__)&&(Qt.push({name:"js-exec",load:async()=>(await import("./chunks/js-exec-2U7NEXAP.js")).jsExecCommand}),Qt.push({name:"node",load:async()=>(await import("./chunks/js-exec-2U7NEXAP.js")).nodeStubCommand}));var dn=[{name:"curl",load:async()=>(await import("./chunks/curl-47BFPSFW.js")).curlCommand}],fn=new Map;function Jt(e){return{name:e.name,async execute(t,s){let r=fn.get(e.name);if(r||(r=await me.runTrustedAsync(()=>e.load()),fn.set(e.name,r)),s.coverage&&(typeof __BROWSER__>"u"||!__BROWSER__)){let{emitFlagCoverage:n}=await import("./chunks/flag-coverage-Z434UZKN.js");n(s.coverage,e.name,t)}return r.execute(t,s)}}}function uo(){return tt.map(e=>e.name)}function fo(){return dn.map(e=>e.name)}function hn(e){return(e?tt.filter(s=>e.includes(s.name)):tt).map(Jt)}function pn(){return dn.map(Jt)}function ho(){return Yt.map(e=>e.name)}function mn(){return Yt.map(Jt)}function po(){return Qt.map(e=>e.name)}function yn(){return Qt.map(Jt)}function gn(e){return"load"in e&&typeof e.load=="function"}function mo(e,t){return{name:e,trusted:!0,execute:t}}function wn(e){let t=null;return{name:e.name,trusted:!0,async execute(s,r){return t||(t=await e.load()),t.execute(s,r)}}}function T(e){if(!e||e==="/")return"/";let t=e.endsWith("/")&&e!=="/"?e.slice(0,-1):e;t.startsWith("/")||(t=`/${t}`);let s=t.split("/").filter(n=>n&&n!=="."),r=[];for(let n of s)n===".."?r.pop():r.push(n);return`/${r.join("/")}`||"/"}function D(e,t){if(e.includes("\0"))throw new Error(`ENOENT: path contains null byte, ${t} '${e}'`)}function st(e){let t=T(e);if(t==="/")return"/";let s=t.lastIndexOf("/");return s===0?"/":t.slice(0,s)}function qe(e,t){if(t.startsWith("/"))return T(t);let s=e==="/"?`/${t}`:`${e}/${t}`;return T(s)}function Ge(e,t){return e==="/"?`/${t}`:`${e}/${t}`}function ct(e,t){if(t.startsWith("/"))return T(t);let s=st(e);return T(Ge(s,t))}var ut=new TextEncoder;function yo(e){return typeof e=="object"&&e!==null&&!(e instanceof Uint8Array)&&"content"in e}var ze=class{data=new Map;constructor(t){if(this.data.set("/",{type:"directory",mode:493,mtime:new Date}),t)for(let[s,r]of Object.entries(t))typeof r=="function"?this.writeFileLazy(s,r):yo(r)?this.writeFileSync(s,r.content,void 0,{mode:r.mode,mtime:r.mtime}):this.writeFileSync(s,r)}ensureParentDirs(t){let s=st(t);s!=="/"&&(this.data.has(s)||(this.ensureParentDirs(s),this.data.set(s,{type:"directory",mode:493,mtime:new Date})))}writeFileSync(t,s,r,n){D(t,"write");let i=T(t);this.ensureParentDirs(i);let o=be(r),a=Fe(s,o);this.data.set(i,{type:"file",content:a,mode:n?.mode??420,mtime:n?.mtime??new Date})}writeFileLazy(t,s,r){D(t,"write");let n=T(t);this.ensureParentDirs(n),this.data.set(n,{type:"file",lazy:s,mode:r?.mode??420,mtime:r?.mtime??new Date})}async materializeLazy(t,s){let r=await s.lazy(),i={type:"file",content:typeof r=="string"?ut.encode(r):r,mode:s.mode,mtime:s.mtime};return this.data.set(t,i),i}async readFile(t,s){let r=await this.readFileBuffer(t),n=be(s);return Me(r,n)}async readFileBytes(t){let s=await this.readFileBuffer(t);return Me(s,"binary")}async readFileBuffer(t){D(t,"open");let s=this.resolvePathWithSymlinks(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, open '${t}'`);if(r.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);if("lazy"in r){let n=await this.materializeLazy(s,r);return n.content instanceof Uint8Array?n.content:ut.encode(n.content)}return r.content instanceof Uint8Array?r.content:ut.encode(r.content)}async writeFile(t,s,r){this.writeFileSync(t,s,r)}async appendFile(t,s,r){D(t,"append");let n=T(t),i=this.data.get(n);if(i&&i.type==="directory")throw new Error(`EISDIR: illegal operation on a directory, write '${t}'`);let o=be(r),a=Fe(s,o);if(i?.type==="file"){let l=i;"lazy"in l&&(l=await this.materializeLazy(n,l));let c="content"in l&&l.content instanceof Uint8Array?l.content:ut.encode("content"in l?l.content:""),u=new Uint8Array(c.length+a.length);u.set(c),u.set(a,c.length),this.data.set(n,{type:"file",content:u,mode:l.mode,mtime:new Date})}else this.writeFileSync(t,s,r)}async exists(t){if(t.includes("\0"))return!1;try{let s=this.resolvePathWithSymlinks(t);return this.data.has(s)}catch{return!1}}async stat(t){D(t,"stat");let s=this.resolvePathWithSymlinks(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, stat '${t}'`);r.type==="file"&&"lazy"in r&&(r=await this.materializeLazy(s,r));let n=0;return r.type==="file"&&"content"in r&&r.content&&(r.content instanceof Uint8Array?n=r.content.length:n=ut.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:n,mtime:r.mtime||new Date}}async lstat(t){D(t,"lstat");let s=this.resolveIntermediateSymlinks(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, lstat '${t}'`);if(r.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:r.mode,size:r.target.length,mtime:r.mtime||new Date};r.type==="file"&&"lazy"in r&&(r=await this.materializeLazy(s,r));let n=0;return r.type==="file"&&"content"in r&&r.content&&(r.content instanceof Uint8Array?n=r.content.length:n=ut.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:n,mtime:r.mtime||new Date}}resolveIntermediateSymlinks(t){let s=T(t);if(s==="/")return"/";let r=s.slice(1).split("/");if(r.length<=1)return s;let n="",i=new Set;for(let o=0;o<r.length-1;o++){let a=r[o];n=`${n}/${a}`;let l=this.data.get(n),c=0,u=40;for(;l&&l.type==="symlink"&&c<u;){if(i.has(n))throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`);i.add(n),n=ct(n,l.target),l=this.data.get(n),c++}if(c>=u)throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`)}return`${n}/${r[r.length-1]}`}resolvePathWithSymlinks(t){let s=T(t);if(s==="/")return"/";let r=s.slice(1).split("/"),n="",i=new Set;for(let o of r){n=`${n}/${o}`;let a=this.data.get(n),l=0,c=40;for(;a&&a.type==="symlink"&&l<c;){if(i.has(n))throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`);i.add(n),n=ct(n,a.target),a=this.data.get(n),l++}if(l>=c)throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`)}return n}async mkdir(t,s){this.mkdirSync(t,s)}mkdirSync(t,s){D(t,"mkdir");let r=T(t);if(this.data.has(r)){if(this.data.get(r)?.type==="file")throw new Error(`EEXIST: file already exists, mkdir '${t}'`);if(!s?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${t}'`);return}let n=st(r);if(n!=="/"&&!this.data.has(n))if(s?.recursive)this.mkdirSync(n,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${t}'`);this.data.set(r,{type:"directory",mode:493,mtime:new Date})}async readdir(t){return(await this.readdirWithFileTypes(t)).map(r=>r.name)}async readdirWithFileTypes(t){D(t,"scandir");let s=T(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);let n=new Set;for(;r&&r.type==="symlink";){if(n.has(s))throw new Error(`ELOOP: too many levels of symbolic links, scandir '${t}'`);n.add(s),s=ct(s,r.target),r=this.data.get(s)}if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);if(r.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${t}'`);let i=s==="/"?"/":`${s}/`,o=new Map;for(let[a,l]of this.data.entries())if(a!==s&&a.startsWith(i)){let c=a.slice(i.length),u=c.split("/")[0];u&&!c.includes("/",u.length)&&!o.has(u)&&o.set(u,{name:u,isFile:l.type==="file",isDirectory:l.type==="directory",isSymbolicLink:l.type==="symlink"})}return Array.from(o.values()).sort((a,l)=>a.name<l.name?-1:a.name>l.name?1:0)}async rm(t,s){D(t,"rm");let r=T(t),n=this.data.get(r);if(!n){if(s?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${t}'`)}if(n.type==="directory"){let i=await this.readdir(r);if(i.length>0){if(!s?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${t}'`);for(let o of i){let a=Ge(r,o);await this.rm(a,s)}}}this.data.delete(r)}async cp(t,s,r){D(t,"cp"),D(s,"cp");let n=T(t),i=T(s),o=this.data.get(n);if(!o)throw new Error(`ENOENT: no such file or directory, cp '${t}'`);if(o.type==="file")if(this.ensureParentDirs(i),"content"in o){let a=o.content instanceof Uint8Array?new Uint8Array(o.content):o.content;this.data.set(i,{...o,content:a})}else this.data.set(i,{...o});else if(o.type==="symlink")this.ensureParentDirs(i),this.data.set(i,{...o});else if(o.type==="directory"){if(!r?.recursive)throw new Error(`EISDIR: is a directory, cp '${t}'`);await this.mkdir(i,{recursive:!0});let a=await this.readdir(n);for(let l of a){let c=Ge(n,l),u=Ge(i,l);await this.cp(c,u,r)}}}async mv(t,s){await this.cp(t,s,{recursive:!0}),await this.rm(t,{recursive:!0})}getAllPaths(){return Array.from(this.data.keys())}resolvePath(t,s){return qe(t,s)}async chmod(t,s){D(t,"chmod");let r=T(t),n=this.data.get(r);if(!n)throw new Error(`ENOENT: no such file or directory, chmod '${t}'`);n.mode=s}async symlink(t,s){D(s,"symlink");let r=T(s);if(this.data.has(r))throw new Error(`EEXIST: file already exists, symlink '${s}'`);this.ensureParentDirs(r),this.data.set(r,{type:"symlink",target:t,mode:511,mtime:new Date})}async link(t,s){D(t,"link"),D(s,"link");let r=T(t),n=T(s),i=this.data.get(r);if(!i)throw new Error(`ENOENT: no such file or directory, link '${t}'`);if(i.type!=="file")throw new Error(`EPERM: operation not permitted, link '${t}'`);if(this.data.has(n))throw new Error(`EEXIST: file already exists, link '${s}'`);let o=i;"lazy"in o&&(o=await this.materializeLazy(r,o)),this.ensureParentDirs(n),this.data.set(n,{type:"file",content:o.content,mode:o.mode,mtime:o.mtime})}async readlink(t){D(t,"readlink");let s=T(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, readlink '${t}'`);if(r.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${t}'`);return r.target}async realpath(t){D(t,"realpath");let s=this.resolvePathWithSymlinks(t);if(!this.data.has(s))throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);return s}async utimes(t,s,r){D(t,"utimes");let n=T(t),i=this.resolvePathWithSymlinks(n),o=this.data.get(i);if(!o)throw new Error(`ENOENT: no such file or directory, utimes '${t}'`);o.mtime=r}};function go(e){let t=e;return typeof t.mkdirSync=="function"&&typeof t.writeFileSync=="function"}function wo(e,t){e.mkdirSync("/bin",{recursive:!0}),e.mkdirSync("/usr/bin",{recursive:!0}),t&&(e.mkdirSync("/home/user",{recursive:!0}),e.mkdirSync("/tmp",{recursive:!0}))}function vo(e){e.mkdirSync("/dev",{recursive:!0}),e.writeFileSync("/dev/null",""),e.writeFileSync("/dev/zero",new Uint8Array(0)),e.writeFileSync("/dev/stdin",""),e.writeFileSync("/dev/stdout",""),e.writeFileSync("/dev/stderr","")}function bo(e,t){e.mkdirSync("/proc/self/fd",{recursive:!0}),e.writeFileSync("/proc/version",`${Yr}
|
|
2
2
|
`),e.writeFileSync("/proc/self/exe","/bin/bash"),e.writeFileSync("/proc/self/cmdline","bash\0"),e.writeFileSync("/proc/self/comm",`bash
|
|
3
3
|
`),e.writeFileLazy?e.writeFileLazy("/proc/self/status",()=>Ms(t)):e.writeFileSync("/proc/self/status",Ms(t)),e.writeFileSync("/proc/self/fd/0","/dev/stdin"),e.writeFileSync("/proc/self/fd/1","/dev/stdout"),e.writeFileSync("/proc/self/fd/2","/dev/stderr")}function vn(e,t,s={pid:1,ppid:0,uid:1e3,gid:1e3}){go(e)&&(wo(e,t),vo(e),bo(e,s))}var Eo=["allexport","errexit","noglob","noclobber","noexec","nounset","pipefail","posix","verbose","xtrace"],$o=["braceexpand","hashall","interactive-comments"];function Zs(e){let t=[],s=[...$o.map(r=>({name:r,enabled:!0})),...Eo.map(r=>({name:r,enabled:e[r]}))].sort((r,n)=>r.name.localeCompare(n.name));for(let r of s)r.enabled&&t.push(r.name);return t.join(":")}function dt(e){e.state.env.set("SHELLOPTS",Zs(e.state.options))}var So=["dotglob","expand_aliases","extglob","failglob","globskipdots","globstar","lastpipe","nocaseglob","nocasematch","nullglob","xpg_echo"];function qs(e){let t=[];for(let s of So)e[s]&&t.push(s);return t.join(":")}function Gs(e){e.state.env.set("BASHOPTS",qs(e.state.shoptOptions))}var Po="BASH_ALIAS_";function bn(e){return e.parts.length!==1?!1:e.parts[0].type==="Literal"}function En(e){if(e.parts.length!==1)return null;let t=e.parts[0];return t.type==="Literal"?t.value:null}function $n(e,t){return e.env.get(`${Po}${t}`)}function Ks(e,t,s){if(!t.name||!bn(t.name))return t;let r=En(t.name);if(!r)return t;let n=$n(e,r);if(!n||s.has(r))return t;try{s.add(r);let i=new B,o=n,a=n.endsWith(" ");if(!a)for(let f of t.args){let d=Pn(f);o+=` ${d}`}let l;try{l=i.parse(o)}catch(f){if(f instanceof qt)throw f;return t}if(l.statements.length!==1||l.statements[0].pipelines.length!==1||l.statements[0].pipelines[0].commands.length!==1)return Sn(t,n);let c=l.statements[0].pipelines[0].commands[0];if(c.type!=="SimpleCommand")return Sn(t,n);let u={...c,assignments:[...t.assignments,...c.assignments],redirections:[...c.redirections,...t.redirections],line:t.line};if(a&&t.args.length>0&&(u={...u,args:[...u.args,...t.args]},u.args.length>0)){let f=u.args[0];if(bn(f)){let d=En(f);if(d&&$n(e,d)){let h={type:"SimpleCommand",name:f,args:u.args.slice(1),assignments:[],redirections:[]},m=Ks(e,h,s);m!==h&&(u={...u,name:m.name,args:[...m.args]})}}}return u}catch(i){throw s.delete(r),i}}function Sn(e,t){let s=t;for(let o of e.args){let a=Pn(o);s+=` ${a}`}let r=new B,n=r.parseWordFromString("eval",!1,!1),i=r.parseWordFromString(`'${s.replace(/'/g,"'\\''")}'`,!1,!1);return{type:"SimpleCommand",name:n,args:[i],assignments:e.assignments,redirections:e.redirections,line:e.line}}function Pn(e){let t="";for(let s of e.parts)switch(s.type){case"Literal":t+=s.value.replace(/([\s"'$`\\*?[\]{}()<>|&;#!])/g,"\\$1");break;case"SingleQuoted":t+=`'${s.value}'`;break;case"DoubleQuoted":t+=`"${s.parts.map(r=>r.type==="Literal"?r.value:`$${r.type}`).join("")}"`;break;case"ParameterExpansion":t+=`\${${s.parameter}}`;break;case"CommandSubstitution":t+="$(...)";break;case"ArithmeticExpansion":t+=`$((${s.expression}))`;break;case"Glob":t+=s.pattern;break;default:break}return t}async function An(e,t){let s=t.parts.map(u=>u.type==="Literal"?u.value:"\0").join(""),r=s.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\(/);if(!r||!s.endsWith(")"))return null;let n=r[1],i=[],o=!1,a="",l=!1;for(let u of t.parts)if(u.type==="Literal"){let f=u.value;if(!o){let d=f.indexOf("=(");d!==-1&&(o=!0,f=f.slice(d+2))}if(o){f.endsWith(")")&&(f=f.slice(0,-1));let d=f.split(/(\s+)/);for(let h of d)/^\s+$/.test(h)?(a||l)&&(i.push(a),a="",l=!1):h&&(a+=h)}}else if(o)if(u.type==="BraceExpansion")if(/^\[.+\]=/.test(a))a+=Gt({type:"Word",parts:[u]});else{(a||l)&&(i.push(a),a="",l=!1);let d=await _e(e,{type:"Word",parts:[u]});i.push(...d.values)}else{(u.type==="SingleQuoted"||u.type==="DoubleQuoted"||u.type==="Escaped")&&(l=!0);let f=await F(e,{type:"Word",parts:[u]});a+=f}(a||l)&&i.push(a);let c=i.map(u=>/^\[.+\]=/.test(u)?u:u===""?"''":/[\s"'\\$`!*?[\]{}|&;<>()]/.test(u)&&!u.startsWith("'")&&!u.startsWith('"')?`'${u.replace(/'/g,"'\\''")}'`:u);return`${n}=(${c.join(" ")})`}async function kn(e,t){let s=-1,r=-1,n=!1;for(let p=0;p<t.parts.length;p++){let g=t.parts[p];if(g.type==="Literal"){let w=g.value.indexOf("+=");if(w!==-1){let v=g.value.slice(0,w);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(v)){s=p,r=w,n=!0;break}if(/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(v)){s=p,r=w,n=!0;break}}let y=g.value.indexOf("=");if(y!==-1&&(y===0||g.value[y-1]!=="+")){let v=g.value.slice(0,y);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(v)||/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(v)){s=p,r=y;break}}}}if(s===-1)return null;let i=t.parts.slice(0,s),o=t.parts[s];if(o.type!=="Literal")return null;let a=n?2:1,l=o.value.slice(0,r),c=o.value.slice(r+a),u=t.parts.slice(s+1),f="";for(let p of i)f+=await F(e,{type:"Word",parts:[p]});f+=l;let d={type:"Word",parts:c!==""?[{type:"Literal",value:c},...u]:u},h=d.parts.length>0?await F(e,d):"";return`${f}${n?"+=":"="}${h}`}var Ao=["tar","yq","xan","sqlite3","python3","python"];function _n(e){return Ao.includes(e)}var W=Object.freeze({stdout:"",stderr:"",exitCode:0});function z(e=""){return{stdout:e,stderr:"",exitCode:0}}function _(e,t=1){return{stdout:"",stderr:e,exitCode:t}}function C(e,t,s){return{stdout:e,stderr:t,exitCode:s}}function Q(e){return{stdout:"",stderr:"",exitCode:e?0:1}}function Te(e,t,s="",r=""){throw new J(e,t,s,r)}function le(e){let t=e.state.fileDescriptors;if(t&&t.size>=e.limits.maxFileDescriptors)throw new J(`too many open file descriptors (max ${e.limits.maxFileDescriptors})`,"file_descriptors")}function Xs(e,t){if(e.state.loopDepth===0){if(e.state.parentHasLoopContext)throw new je;return W}if(t.length>1)throw new j(1,"",`bash: break: too many arguments
|
|
4
4
|
`);let s=1;if(t.length>0){let r=Number.parseInt(t[0],10);if(Number.isNaN(r)||r<1)throw new j(128,"",`bash: break: ${t[0]}: numeric argument required
|
|
@@ -548,10 +548,10 @@ ${bs}`;if(e.state.options.posix)throw new Pe(1,"",i);return _(i)}ii(e,si.get(n)?
|
|
|
548
548
|
${bs}`;if(e.state.options.posix)throw new Pe(1,"",a);return _(a)}ii(e,ti.get(o)??null,n)}s++;continue}if(r==="--")return Tr(e,t.slice(s+1)),W;if(r==="-"){if(e.state.options.xtrace=!1,e.state.options.verbose=!1,dt(e),s+1<t.length)return Tr(e,t.slice(s+1)),W;s++;continue}if(r==="+"){s++;continue}if(r.startsWith("-")||r.startsWith("+")){let n=`bash: set: ${r}: invalid option
|
|
549
549
|
${bs}`;if(e.state.options.posix)throw new Pe(1,"",n);return _(n)}return Tr(e,t.slice(s)),W}return W}function Tr(e,t){let s=1;for(;e.state.env.has(String(s));)e.state.env.delete(String(s)),s++;for(let r=0;r<t.length;r++)e.state.env.set(String(r+1),t[r]);e.state.env.set("#",String(t.length)),e.state.env.set("@",t.join(" ")),e.state.env.set("*",t.join(" "))}function Rr(e,t){let s=1;if(t.length>0){let o=Number.parseInt(t[0],10);if(Number.isNaN(o)||o<0){let a=`bash: shift: ${t[0]}: numeric argument required
|
|
550
550
|
`;if(e.state.options.posix)throw new Pe(1,"",a);return _(a)}s=o}let r=Number.parseInt(e.state.env.get("#")||"0",10);if(s>r){let o=`bash: shift: shift count out of range
|
|
551
|
-
`;if(e.state.options.posix)throw new Pe(1,"",o);return _(o)}if(s===0)return W;let n=[];for(let o=1;o<=r;o++)n.push(e.state.env.get(String(o))||"");let i=n.slice(s);for(let o=1;o<=r;o++)e.state.env.delete(String(o));for(let o=0;o<i.length;o++)e.state.env.set(String(o+1),i[o]);return e.state.env.set("#",String(i.length)),e.state.env.set("@",i.join(" ")),W}async function Ir(e,t){let
|
|
552
|
-
`,2);let r
|
|
553
|
-
`);let
|
|
554
|
-
`);throw
|
|
551
|
+
`;if(e.state.options.posix)throw new Pe(1,"",o);return _(o)}if(s===0)return W;let n=[];for(let o=1;o<=r;o++)n.push(e.state.env.get(String(o))||"");let i=n.slice(s);for(let o=1;o<=r;o++)e.state.env.delete(String(o));for(let o=0;o<i.length;o++)e.state.env.set(String(o+1),i[o]);return e.state.env.set("#",String(i.length)),e.state.env.set("@",i.join(" ")),W}async function Ir(e,t,s){let r=t;if(r.length>0&&r[0]==="--"&&(r=r.slice(1)),r.length===0)return C("",`bash: source: filename argument required
|
|
552
|
+
`,2);let n=r[0],i=null,o=null;if(n.includes("/")){let d=e.fs.resolvePath(e.state.cwd,n);try{o=await e.fs.readFile(d),i=d}catch{}}else{let h=(e.state.env.get("PATH")||"").split(":").filter(m=>m);for(let m of h){let p=e.fs.resolvePath(e.state.cwd,`${m}/${n}`);try{if((await e.fs.stat(p)).isDirectory)continue;o=await e.fs.readFile(p),i=p;break}catch{}}if(o===null){let m=e.fs.resolvePath(e.state.cwd,n);try{o=await e.fs.readFile(m),i=m}catch{}}}if(o===null)return _(`bash: ${n}: No such file or directory
|
|
553
|
+
`);let a=new Map;if(r.length>1){for(let h=1;h<=9;h++)a.set(String(h),e.state.env.get(String(h)));a.set("#",e.state.env.get("#")),a.set("@",e.state.env.get("@"));let d=r.slice(1);e.state.env.set("#",String(d.length)),e.state.env.set("@",d.join(" "));for(let h=0;h<d.length&&h<9;h++)e.state.env.set(String(h+1),d[h]);for(let h=d.length+1;h<=9;h++)e.state.env.delete(String(h))}let l=e.state.currentSource,c=()=>{if(e.state.sourceDepth--,e.state.currentSource=l,r.length>1)for(let[d,h]of a)h===void 0?e.state.env.delete(d):e.state.env.set(d,h)};if(e.state.sourceDepth++,e.state.sourceDepth>e.limits.maxSourceDepth)throw e.state.sourceDepth--,new J(`source: maximum nesting depth (${e.limits.maxSourceDepth}) exceeded, increase executionLimits.maxSourceDepth`,"recursion");e.state.currentSource=n;let u=e.state.groupStdin,f=s??e.state.groupStdin;f!==void 0&&(e.state.groupStdin=f);try{let d=fe(o),h=await e.executeScript(d);return c(),h}catch(d){if(c(),d instanceof j)throw d;if(d instanceof ue)return C(d.stdout,d.stderr,d.exitCode);if(d.name==="ParseException")return _(`bash: ${n}: ${d.message}
|
|
554
|
+
`);throw d}finally{e.state.groupStdin=u}}function oi(e){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)}function ga(e){return e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"')}async function ai(e,t){if(ga(t))return null;try{let s=new B,r=ee(s,t);return await H(e,r.expression)}catch{let s=parseInt(t,10);return Number.isNaN(s)?0:s}}function li(e,t){if(e.state.localVarStack?.has(t)){let r=ps(e,t);if(r){r.value===void 0?e.state.env.delete(t):e.state.env.set(t,r.value);let n=e.state.localVarStack?.get(t);if(!n||n.length===0)hs(e,t),e.state.localVarStack?.delete(t),e.state.fullyUnsetLocals=e.state.fullyUnsetLocals||new Map,e.state.fullyUnsetLocals.set(t,r.scopeIndex),Lr(e,t);else{let i=n[n.length-1];e.state.localVarDepth=e.state.localVarDepth||new Map,e.state.localVarDepth.set(t,i.scopeIndex+1)}return!0}return e.state.env.delete(t),hs(e,t),e.state.localVarStack?.delete(t),e.state.fullyUnsetLocals=e.state.fullyUnsetLocals||new Map,e.state.fullyUnsetLocals.set(t,0),!0}for(let r=e.state.localScopes.length-1;r>=0;r--){let n=e.state.localScopes[r];if(n.has(t)){let i=n.get(t);i===void 0?e.state.env.delete(t):e.state.env.set(t,i),n.delete(t);let o=!1;for(let a=r-1;a>=0;a--)if(e.state.localScopes[a].has(t)){e.state.localVarDepth&&e.state.localVarDepth.set(t,a+1),o=!0;break}return o||hs(e,t),!0}}return!1}function Lr(e,t){if(!e.state.tempEnvBindings||e.state.tempEnvBindings.length===0)return!1;for(let s=e.state.tempEnvBindings.length-1;s>=0;s--){let r=e.state.tempEnvBindings[s];if(r.has(t)){let n=r.get(t);return n===void 0?e.state.env.delete(t):e.state.env.set(t,n),r.delete(t),!0}}return!1}async function ci(e,t){if(t.startsWith("'")&&t.endsWith("'"))return t.slice(1,-1);if(t.startsWith('"')&&t.endsWith('"')){let s=t.slice(1,-1),n=new B().parseWordFromString(s,!0,!1);return F(e,n)}if(t.includes("$")){let r=new B().parseWordFromString(t,!1,!1);return F(e,r)}return t}async function Fr(e,t){let s="both",r="",n=0;for(let i of t){if(i==="-v"){s="variable";continue}if(i==="-f"){s="function";continue}if(s==="function"){e.state.functions.delete(i);continue}if(s==="variable"){let c=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(c){let d=c[1],h=c[2];if(h==="@"||h==="*"){let v=Ae(e,d);for(let[b]of v)e.state.env.delete(`${d}_${b}`);e.state.env.delete(d);continue}let m=e.state.associativeArrays?.has(d);if(m){let v=await ci(e,h);e.state.env.delete(`${d}_${v}`);continue}let p=js(e,d),g=e.state.declaredVars?.has(d);if((e.state.env.has(d)||g)&&!p&&!m){r+=`bash: unset: ${d}: not an array variable
|
|
555
555
|
`,n=1;continue}let y=await ai(e,h);if(y===null&&p){r+=`bash: unset: ${h}: not a valid identifier
|
|
556
556
|
`,n=1;continue}if(y===null)continue;if(y<0){let v=Ae(e,d),b=v.length,S=e.state.currentLine;if(b===0){r+=`bash: line ${S}: unset: [${y}]: bad array subscript
|
|
557
557
|
`,n=1;continue}let E=b+y;if(E<0){r+=`bash: line ${S}: unset: [${y}]: bad array subscript
|
|
@@ -615,7 +615,7 @@ ${e} ()
|
|
|
615
615
|
`),o=1)}else if(e.commands.has(a)){let u=(e.state.env.get("PATH")??"/usr/bin:/bin").split(":"),f=null;for(let d of u){if(!d)continue;let h=`${d}/${a}`;try{let m=await e.fs.stat(h);if(!m.isDirectory&&(m.mode&73)!==0){f=h;break}}catch{}}f||(f=`/usr/bin/${a}`),r?n+=`${a} is ${f}
|
|
616
616
|
`:n+=`${f}
|
|
617
617
|
`}else r&&(i+=`${a}: not found
|
|
618
|
-
`),o=1}return C(n,i,o)}async function wi(e,t){if(t.includes("/")){let n=e.fs.resolvePath(e.state.cwd,t);if(await e.fs.exists(n)){try{let i=await e.fs.stat(n);if(i.isDirectory||!((i.mode&73)!==0))return null}catch{return null}return t}return null}let r=(e.state.env.get("PATH")??"/usr/bin:/bin").split(":");for(let n of r){if(!n)continue;let o=`${n.startsWith("/")?n:e.fs.resolvePath(e.state.cwd,n)}/${t}`;if(await e.fs.exists(o)){try{if((await e.fs.stat(o)).isDirectory)continue}catch{continue}return`${n}/${t}`}}if(e.commands.has(t)){for(let n of r)if(n==="/usr/bin"||n==="/bin")return`${n}/${t}`;return`/usr/bin/${t}`}return null}async function vi(e,t,s,r,n,i,o,a){let{ctx:l,runCommand:c}=e;if(l.coverage&&mt.has(t)&&l.coverage.hit(`bash:builtin:${t}`),t==="export")return Pr(l,s);if(t==="unset")return Fr(l,s);if(t==="exit")return Sr(l,s);if(t==="local")return Cr(l,s);if(t==="set")return Dr(l,s);if(t==="break")return Xs(l,s);if(t==="continue")return cr(l,s);if(t==="return")return xr(l,s);if(t==="eval"&&l.state.options.posix)return ws(l,s,n);if(t==="shift")return Rr(l,s);if(t==="getopts")return vs(l,s);if(t==="compgen")return ir(l,s);if(t==="complete")return ar(l,s);if(t==="compopt")return lr(l,s);if(t==="pushd")return await br(l,s);if(t==="popd")return Er(l,s);if(t==="dirs")return $r(l,s);if(t==="source"||t===".")return Ir(l,s);if(t==="read")return Or(l,s,n,a);if(t==="mapfile"||t==="readarray")return Nr(l,s,n);if(t==="declare"||t==="typeset")return gr(l,s);if(t==="readonly")return wr(l,s);if(!i){let u=l.state.functions.get(t);if(u)return ys(l,u,s,n)}if(t==="eval")return ws(l,s,n);if(t==="cd")return await Ys(l,s);if(t===":"||t==="true")return W;if(t==="false")return Q(!1);if(t==="let")return _r(l,s);if(t==="command")return Pa(e,s,n);if(t==="builtin")return Aa(e,s,n);if(t==="shopt")return ui(l,s);if(t==="exec"){if(s.length===0)return W;let[u,...f]=s;return c(u,f,[],n,!1,!1,-1)}if(t==="wait")return W;if(t==="type")return await yi(l,s,u=>wi(l,u),u=>$s(l,u));if(t==="hash")return Ar(l,s);if(t==="help")return kr(l,s);if(t==="["||t==="test"){let u=s;if(t==="["){if(s[s.length-1]!=="]")return _("[: missing `]'\n",2);u=s.slice(0,-1)}return Ot(l,u)}return null}async function Pa(e,t,s){let{ctx:r,runCommand:n}=e;if(t.length===0)return W;let i=!1,o=!1,a=!1,l=t;for(;l.length>0&&l[0].startsWith("-");){let f=l[0];if(f==="--"){l=l.slice(1);break}for(let d of f.slice(1))d==="p"?i=!0:d==="V"?o=!0:d==="v"&&(a=!0);l=l.slice(1)}if(l.length===0)return W;if(a||o)return await gi(r,l,a,o);let[c,...u]=l;return n(c,u,[],s,!0,i,-1)}async function Aa(e,t,s){let{runCommand:r}=e;if(t.length===0)return W;let n=t;if(n[0]==="--"&&(n=n.slice(1),n.length===0))return W;let i=n[0];if(!mt.has(i))return _(`bash: builtin: ${i}: not a shell builtin
|
|
618
|
+
`),o=1}return C(n,i,o)}async function wi(e,t){if(t.includes("/")){let n=e.fs.resolvePath(e.state.cwd,t);if(await e.fs.exists(n)){try{let i=await e.fs.stat(n);if(i.isDirectory||!((i.mode&73)!==0))return null}catch{return null}return t}return null}let r=(e.state.env.get("PATH")??"/usr/bin:/bin").split(":");for(let n of r){if(!n)continue;let o=`${n.startsWith("/")?n:e.fs.resolvePath(e.state.cwd,n)}/${t}`;if(await e.fs.exists(o)){try{if((await e.fs.stat(o)).isDirectory)continue}catch{continue}return`${n}/${t}`}}if(e.commands.has(t)){for(let n of r)if(n==="/usr/bin"||n==="/bin")return`${n}/${t}`;return`/usr/bin/${t}`}return null}async function vi(e,t,s,r,n,i,o,a){let{ctx:l,runCommand:c}=e;if(l.coverage&&mt.has(t)&&l.coverage.hit(`bash:builtin:${t}`),t==="export")return Pr(l,s);if(t==="unset")return Fr(l,s);if(t==="exit")return Sr(l,s);if(t==="local")return Cr(l,s);if(t==="set")return Dr(l,s);if(t==="break")return Xs(l,s);if(t==="continue")return cr(l,s);if(t==="return")return xr(l,s);if(t==="eval"&&l.state.options.posix)return ws(l,s,n);if(t==="shift")return Rr(l,s);if(t==="getopts")return vs(l,s);if(t==="compgen")return ir(l,s);if(t==="complete")return ar(l,s);if(t==="compopt")return lr(l,s);if(t==="pushd")return await br(l,s);if(t==="popd")return Er(l,s);if(t==="dirs")return $r(l,s);if(t==="source"||t===".")return Ir(l,s,n);if(t==="read")return Or(l,s,n,a);if(t==="mapfile"||t==="readarray")return Nr(l,s,n);if(t==="declare"||t==="typeset")return gr(l,s);if(t==="readonly")return wr(l,s);if(!i){let u=l.state.functions.get(t);if(u)return ys(l,u,s,n)}if(t==="eval")return ws(l,s,n);if(t==="cd")return await Ys(l,s);if(t===":"||t==="true")return W;if(t==="false")return Q(!1);if(t==="let")return _r(l,s);if(t==="command")return Pa(e,s,n);if(t==="builtin")return Aa(e,s,n);if(t==="shopt")return ui(l,s);if(t==="exec"){if(s.length===0)return W;let[u,...f]=s;return c(u,f,[],n,!1,!1,-1)}if(t==="wait")return W;if(t==="type")return await yi(l,s,u=>wi(l,u),u=>$s(l,u));if(t==="hash")return Ar(l,s);if(t==="help")return kr(l,s);if(t==="["||t==="test"){let u=s;if(t==="["){if(s[s.length-1]!=="]")return _("[: missing `]'\n",2);u=s.slice(0,-1)}return Ot(l,u)}return null}async function Pa(e,t,s){let{ctx:r,runCommand:n}=e;if(t.length===0)return W;let i=!1,o=!1,a=!1,l=t;for(;l.length>0&&l[0].startsWith("-");){let f=l[0];if(f==="--"){l=l.slice(1);break}for(let d of f.slice(1))d==="p"?i=!0:d==="V"?o=!0:d==="v"&&(a=!0);l=l.slice(1)}if(l.length===0)return W;if(a||o)return await gi(r,l,a,o);let[c,...u]=l;return n(c,u,[],s,!0,i,-1)}async function Aa(e,t,s){let{runCommand:r}=e;if(t.length===0)return W;let n=t;if(n[0]==="--"&&(n=n.slice(1),n.length===0))return W;let i=n[0];if(!mt.has(i))return _(`bash: builtin: ${i}: not a shell builtin
|
|
619
619
|
`);let[,...o]=n;return r(i,o,[],s,!0,!1,-1)}async function bi(e,t,s,r,n){let{ctx:i,buildExportedEnv:o,executeUserScript:a}=e,c=await fi(i,t,n?"/usr/bin:/bin":void 0);if(!c)return _n(t)?_(`bash: ${t}: command not available in browser environments. Exclude '${t}' from your commands or use the Node.js bundle.
|
|
620
620
|
`,127):_(`bash: ${t}: command not found
|
|
621
621
|
`,127);if("error"in c)return c.error==="permission_denied"?_(`bash: ${t}: Permission denied
|
|
@@ -651,7 +651,7 @@ sys 0m0.000s
|
|
|
651
651
|
`,1)}}if(n=Math.max(...i.map(([a])=>typeof a=="number"?a:0))+1+n,n<0){let a=e.state.currentLine;return{index:0,error:C("",`bash: line ${a}: ${t}[${s}]: bad array subscript
|
|
652
652
|
`,1)}}}return{index:n}}async function Ia(e,t,s,r,n,i){let o="",a=s,l=null;if(Ee(e,s)){let f=nn(e,s,r);if(f===void 0)return{continueToNext:!1,xtraceOutput:"",error:C("",`bash: ${s}: circular name reference
|
|
653
653
|
`,1)};if(f===null)return{continueToNext:!0,xtraceOutput:""};a=f;let d=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);d&&(l={arrayName:d[1],subscriptExpr:d[2]},a=d[1])}if(et(e,a)){if(t.name)return o+=`bash: ${a}: readonly variable
|
|
654
|
-
`,{continueToNext:!0,xtraceOutput:o};let f=se(e,a);if(f)return{continueToNext:!1,xtraceOutput:"",error:f}}let c;if(xt(e,a))try{let f=new B;if(n){let h=`(${e.state.env.get(a)||"0"}) + (${r})`,m=ee(f,h);c=String(await H(e,m.expression))}else{let d=ee(f,r);c=String(await H(e,d.expression))}}catch{c="0"}else{let{isArray:f}=await import("./chunks/expansion-
|
|
654
|
+
`,{continueToNext:!0,xtraceOutput:o};let f=se(e,a);if(f)return{continueToNext:!1,xtraceOutput:"",error:f}}let c;if(xt(e,a))try{let f=new B;if(n){let h=`(${e.state.env.get(a)||"0"}) + (${r})`,m=ee(f,h);c=String(await H(e,m.expression))}else{let d=ee(f,r);c=String(await H(e,d.expression))}}catch{c="0"}else{let{isArray:f}=await import("./chunks/expansion-SYCUAUC5.js"),d=f(e,a)?`${a}_0`:a;c=n?(e.state.env.get(d)||"")+r:r}c=gt(e,a,c),o+=await xi(e,a,c);let u=a;if(l)u=await La(e,l);else{let{isArray:f}=await import("./chunks/expansion-SYCUAUC5.js");f(e,a)&&(u=`${a}_0`)}return t.name?(i.set(u,e.state.env.get(u)),e.state.env.set(u,c)):(e.state.env.set(u,c),e.state.options.allexport&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(a)),e.state.tempEnvBindings?.some(f=>f.has(a))&&(e.state.mutatedTempEnvVars=e.state.mutatedTempEnvVars||new Set,e.state.mutatedTempEnvVars.add(a))),{continueToNext:!1,xtraceOutput:o}}async function La(e,t){let{arrayName:s,subscriptExpr:r}=t;if(e.state.associativeArrays?.has(s))return Ri(e,s,r);let i;if(/^-?\d+$/.test(r))i=Number.parseInt(r,10);else{try{let o=new B,a=ee(o,r);i=await H(e,a.expression,!1)}catch{let o=e.state.env.get(r);i=o?Number.parseInt(o,10):0}Number.isNaN(i)&&(i=0)}if(i<0){let o=Ae(e,s);o.length>0&&(i=Math.max(...o.map(l=>l[0]))+1+i)}return`${s}_${i}`}async function Ii(e,t,s,r){let n=await Re(e,t.redirections);if(n)return n;let i=new Map(e.state.env),o=e.state.cwd,a={...e.state.options},l=new Map(e.state.functions),c=e.state.localScopes,u=e.state.localVarStack,f=e.state.localVarDepth,d=e.state.fullyUnsetLocals;if(e.state.localScopes=c.map($=>new Map($)),u){e.state.localVarStack=new Map;for(let[$,O]of u.entries())e.state.localVarStack.set($,O.map(A=>({...A})))}f&&(e.state.localVarDepth=new Map(f)),d&&(e.state.fullyUnsetLocals=new Map(d));let h=e.state.loopDepth,m=e.state.parentHasLoopContext;e.state.parentHasLoopContext=h>0,e.state.loopDepth=0;let p=e.state.lastArg,g=e.state.bashPid;e.state.bashPid=e.state.nextVirtualPid++;let w=e.state.groupStdin;s&&(e.state.groupStdin=s);let y="",v="",b=0,S=()=>{e.state.env=i,e.state.cwd=o,e.state.options=a,e.state.functions=l,e.state.localScopes=c,e.state.localVarStack=u,e.state.localVarDepth=f,e.state.fullyUnsetLocals=d,e.state.loopDepth=h,e.state.parentHasLoopContext=m,e.state.groupStdin=w,e.state.bashPid=g,e.state.lastArg=p};try{for(let $ of t.body){let O=await r($);y+=O.stdout,v+=O.stderr,b=O.exitCode}}catch($){if(S(),$ instanceof J)throw $;if($ instanceof je){y+=$.stdout,v+=$.stderr;let A=C(y,v,0);return K(e,A,t.redirections)}if($ instanceof ye||$ instanceof ge){y+=$.stdout,v+=$.stderr;let A=C(y,v,0);return K(e,A,t.redirections)}if($ instanceof j){y+=$.stdout,v+=$.stderr;let A=C(y,v,$.exitCode);return K(e,A,t.redirections)}if($ instanceof ue){y+=$.stdout,v+=$.stderr;let A=C(y,v,$.exitCode);return K(e,A,t.redirections)}if($ instanceof we){let A=C(y+$.stdout,v+$.stderr,$.exitCode);return K(e,A,t.redirections)}let O=C(y,`${v}${Ie($)}
|
|
655
655
|
`,1);return K(e,O,t.redirections)}S();let E=C(y,v,b);return K(e,E,t.redirections)}async function Li(e,t,s,r){let n="",i="",o=0,a=await ms(e,t.redirections);if(a)return a;let l=s;for(let f of t.redirections)if((f.operator==="<<"||f.operator==="<<-")&&f.target.type==="HereDoc"){let d=f.target,h=await F(e,d.content);d.stripTabs&&(h=h.split(`
|
|
656
656
|
`).map(p=>p.replace(/^\t+/,"")).join(`
|
|
657
657
|
`));let m=f.fd??0;m!==0?(e.state.fileDescriptors||(e.state.fileDescriptors=new Map),le(e),e.state.fileDescriptors.set(m,h)):l=h}else if(f.operator==="<<<"&&f.target.type==="Word")l=`${await F(e,f.target)}
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { ExecResult } from "../../types.js";
|
|
5
5
|
import type { InterpreterContext } from "../types.js";
|
|
6
|
-
export declare function handleSource(ctx: InterpreterContext, args: string[]): Promise<ExecResult>;
|
|
6
|
+
export declare function handleSource(ctx: InterpreterContext, args: string[], stdin?: string): Promise<ExecResult>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "just-bash-nx",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.8",
|
|
4
4
|
"description": "A simulated bash environment with virtual filesystem",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -56,37 +56,6 @@
|
|
|
56
56
|
"publishConfig": {
|
|
57
57
|
"access": "public"
|
|
58
58
|
},
|
|
59
|
-
"scripts": {
|
|
60
|
-
"build": "rm -rf dist && tsc && pnpm build:lib && pnpm build:lib:cjs && pnpm build:browser && pnpm build:cli && pnpm build:shell && pnpm build:worker && pnpm build:clean && cp dist/index.d.ts dist/index.d.cts && sed '1,/^-->/d' AGENTS.npm.md > dist/AGENTS.md",
|
|
61
|
-
"build:clean": "find dist -name '*.test.js' -delete && find dist -name '*.test.d.ts' -delete",
|
|
62
|
-
"build:worker": "esbuild src/commands/python3/worker.ts --bundle --platform=node --format=esm --outfile=src/commands/python3/worker.js --external:../../../vendor/cpython-emscripten/* && cp src/commands/python3/worker.js dist/commands/python3/worker.js && mkdir -p dist/bin/chunks && cp src/commands/python3/worker.js dist/bin/chunks/worker.js && mkdir -p dist/bundle/chunks && cp src/commands/python3/worker.js dist/bundle/chunks/worker.js && esbuild src/commands/js-exec/js-exec-worker.ts --bundle --platform=node --format=esm --outfile=src/commands/js-exec/js-exec-worker.js --external:quickjs-emscripten && cp src/commands/js-exec/js-exec-worker.js dist/commands/js-exec/js-exec-worker.js && cp src/commands/js-exec/js-exec-worker.js dist/bin/chunks/js-exec-worker.js && cp src/commands/js-exec/js-exec-worker.js dist/bundle/chunks/js-exec-worker.js && esbuild src/commands/sqlite3/worker.ts --bundle --platform=node --format=esm --outfile=src/commands/sqlite3/worker.js --external:sql.js && mkdir -p dist/commands/sqlite3 && cp src/commands/sqlite3/worker.js dist/commands/sqlite3/worker.js && cp src/commands/sqlite3/worker.js dist/bin/chunks/sqlite3-worker.js && cp src/commands/sqlite3/worker.js dist/bundle/chunks/sqlite3-worker.js",
|
|
63
|
-
"build:lib": "esbuild dist/index.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bundle --chunk-names=chunks/[name]-[hash] --external:diff --external:minimatch --external:sprintf-js --external:turndown --external:sql.js --external:quickjs-emscripten --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip",
|
|
64
|
-
"build:lib:cjs": "esbuild dist/index.js --bundle --platform=node --format=cjs --minify --outfile=dist/bundle/index.cjs --external:diff --external:minimatch --external:sprintf-js --external:turndown --external:sql.js --external:quickjs-emscripten --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip",
|
|
65
|
-
"build:browser": "esbuild dist/browser.js --bundle --platform=browser --format=esm --minify --outfile=dist/bundle/browser.js --external:diff --external:minimatch --external:sprintf-js --external:turndown --external:node:zlib --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip --define:__BROWSER__=true --alias:node:dns=./src/shims/browser-unsupported.js",
|
|
66
|
-
"build:cli": "mkdir -p dist/cli dist/bin && cp src/cli/default-init.sh dist/cli/default-init.sh && cp src/cli/default-init.sh dist/bin/default-init.sh && esbuild dist/cli/just-bash.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bin --entry-names=[name] --chunk-names=chunks/[name]-[hash] --banner:js='#!/usr/bin/env node' --external:sql.js --external:quickjs-emscripten --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip",
|
|
67
|
-
"build:shell": "esbuild dist/cli/shell.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bin/shell --entry-names=[name] --chunk-names=chunks/[name]-[hash] --banner:js='#!/usr/bin/env node' --external:sql.js --external:quickjs-emscripten --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip",
|
|
68
|
-
"prepublishOnly": "pnpm test:dist",
|
|
69
|
-
"validate": "pnpm lint && pnpm knip && pnpm typecheck && pnpm build && pnpm check:worker-sync && pnpm test:run && pnpm test:wasm && pnpm test:dist",
|
|
70
|
-
"typecheck": "tsc --noEmit",
|
|
71
|
-
"lint": "pnpm lint:banned",
|
|
72
|
-
"check:worker-sync": "node scripts/check-worker-sync.js",
|
|
73
|
-
"lint:banned": "node scripts/check-banned-patterns.js",
|
|
74
|
-
"lint:fix": "pnpm --workspace-root lint:fix",
|
|
75
|
-
"knip": "knip",
|
|
76
|
-
"test": "vitest",
|
|
77
|
-
"test:run": "vitest run --exclude src/security/fuzzing/ --exclude src/commands/python3/ --exclude src/commands/sqlite3/ --exclude src/commands/js-exec/ --exclude src/agent-examples/python-scripting.test.ts",
|
|
78
|
-
"test:dist": "vitest run src/cli/just-bash.bundle.test.ts",
|
|
79
|
-
"test:unit": "vitest run --config vitest.unit.config.ts",
|
|
80
|
-
"test:wasm": "vitest run --config vitest.wasm.config.ts",
|
|
81
|
-
"test:comparison": "vitest run --config vitest.comparison.config.ts",
|
|
82
|
-
"test:comparison:record": "RECORD_FIXTURES=1 vitest run --config vitest.comparison.config.ts",
|
|
83
|
-
"test:coverage": "vitest run --coverage",
|
|
84
|
-
"test:coverage:unit": "vitest run --config vitest.unit.config.ts --coverage",
|
|
85
|
-
"test:fuzz": "vitest run src/security/fuzzing/",
|
|
86
|
-
"test:fuzz:long": "FUZZ_RUNS=10000 vitest run src/security/fuzzing/",
|
|
87
|
-
"shell": "npx tsx src/cli/shell.ts",
|
|
88
|
-
"dev:exec": "npx tsx src/cli/exec.ts"
|
|
89
|
-
},
|
|
90
59
|
"keywords": [],
|
|
91
60
|
"author": "Malte and Claude",
|
|
92
61
|
"license": "Apache-2.0",
|
|
@@ -124,5 +93,35 @@
|
|
|
124
93
|
"optionalDependencies": {
|
|
125
94
|
"@mongodb-js/zstd": "^7.0.0",
|
|
126
95
|
"node-liblzma": "^2.0.3"
|
|
96
|
+
},
|
|
97
|
+
"scripts": {
|
|
98
|
+
"build": "rm -rf dist && tsc && pnpm build:lib && pnpm build:lib:cjs && pnpm build:browser && pnpm build:cli && pnpm build:shell && pnpm build:worker && pnpm build:clean && cp dist/index.d.ts dist/index.d.cts && sed '1,/^-->/d' AGENTS.npm.md > dist/AGENTS.md",
|
|
99
|
+
"build:clean": "find dist -name '*.test.js' -delete && find dist -name '*.test.d.ts' -delete",
|
|
100
|
+
"build:worker": "esbuild src/commands/python3/worker.ts --bundle --platform=node --format=esm --outfile=src/commands/python3/worker.js --external:../../../vendor/cpython-emscripten/* && cp src/commands/python3/worker.js dist/commands/python3/worker.js && mkdir -p dist/bin/chunks && cp src/commands/python3/worker.js dist/bin/chunks/worker.js && mkdir -p dist/bundle/chunks && cp src/commands/python3/worker.js dist/bundle/chunks/worker.js && esbuild src/commands/js-exec/js-exec-worker.ts --bundle --platform=node --format=esm --outfile=src/commands/js-exec/js-exec-worker.js --external:quickjs-emscripten && cp src/commands/js-exec/js-exec-worker.js dist/commands/js-exec/js-exec-worker.js && cp src/commands/js-exec/js-exec-worker.js dist/bin/chunks/js-exec-worker.js && cp src/commands/js-exec/js-exec-worker.js dist/bundle/chunks/js-exec-worker.js && esbuild src/commands/sqlite3/worker.ts --bundle --platform=node --format=esm --outfile=src/commands/sqlite3/worker.js --external:sql.js && mkdir -p dist/commands/sqlite3 && cp src/commands/sqlite3/worker.js dist/commands/sqlite3/worker.js && cp src/commands/sqlite3/worker.js dist/bin/chunks/sqlite3-worker.js && cp src/commands/sqlite3/worker.js dist/bundle/chunks/sqlite3-worker.js",
|
|
101
|
+
"build:lib": "esbuild dist/index.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bundle --chunk-names=chunks/[name]-[hash] --external:diff --external:minimatch --external:sprintf-js --external:turndown --external:sql.js --external:quickjs-emscripten --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip",
|
|
102
|
+
"build:lib:cjs": "esbuild dist/index.js --bundle --platform=node --format=cjs --minify --outfile=dist/bundle/index.cjs --external:diff --external:minimatch --external:sprintf-js --external:turndown --external:sql.js --external:quickjs-emscripten --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip",
|
|
103
|
+
"build:browser": "esbuild dist/browser.js --bundle --platform=browser --format=esm --minify --outfile=dist/bundle/browser.js --external:diff --external:minimatch --external:sprintf-js --external:turndown --external:node:zlib --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip --define:__BROWSER__=true --alias:node:dns=./src/shims/browser-unsupported.js",
|
|
104
|
+
"build:cli": "mkdir -p dist/cli dist/bin && cp src/cli/default-init.sh dist/cli/default-init.sh && cp src/cli/default-init.sh dist/bin/default-init.sh && esbuild dist/cli/just-bash.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bin --entry-names=[name] --chunk-names=chunks/[name]-[hash] --banner:js='#!/usr/bin/env node' --external:sql.js --external:quickjs-emscripten --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip",
|
|
105
|
+
"build:shell": "esbuild dist/cli/shell.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bin/shell --entry-names=[name] --chunk-names=chunks/[name]-[hash] --banner:js='#!/usr/bin/env node' --external:sql.js --external:quickjs-emscripten --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip",
|
|
106
|
+
"validate": "pnpm lint && pnpm knip && pnpm typecheck && pnpm build && pnpm check:worker-sync && pnpm test:run && pnpm test:wasm && pnpm test:dist",
|
|
107
|
+
"typecheck": "tsc --noEmit",
|
|
108
|
+
"lint": "pnpm lint:banned",
|
|
109
|
+
"check:worker-sync": "node scripts/check-worker-sync.js",
|
|
110
|
+
"lint:banned": "node scripts/check-banned-patterns.js",
|
|
111
|
+
"lint:fix": "pnpm --workspace-root lint:fix",
|
|
112
|
+
"knip": "knip",
|
|
113
|
+
"test": "vitest",
|
|
114
|
+
"test:run": "vitest run --exclude src/security/fuzzing/ --exclude src/commands/python3/ --exclude src/commands/sqlite3/ --exclude src/commands/js-exec/ --exclude src/agent-examples/python-scripting.test.ts",
|
|
115
|
+
"test:dist": "vitest run src/cli/just-bash.bundle.test.ts",
|
|
116
|
+
"test:unit": "vitest run --config vitest.unit.config.ts",
|
|
117
|
+
"test:wasm": "vitest run --config vitest.wasm.config.ts",
|
|
118
|
+
"test:comparison": "vitest run --config vitest.comparison.config.ts",
|
|
119
|
+
"test:comparison:record": "RECORD_FIXTURES=1 vitest run --config vitest.comparison.config.ts",
|
|
120
|
+
"test:coverage": "vitest run --coverage",
|
|
121
|
+
"test:coverage:unit": "vitest run --config vitest.unit.config.ts --coverage",
|
|
122
|
+
"test:fuzz": "vitest run src/security/fuzzing/",
|
|
123
|
+
"test:fuzz:long": "FUZZ_RUNS=10000 vitest run src/security/fuzzing/",
|
|
124
|
+
"shell": "npx tsx src/cli/shell.ts",
|
|
125
|
+
"dev:exec": "npx tsx src/cli/exec.ts"
|
|
127
126
|
}
|
|
128
|
-
}
|
|
127
|
+
}
|
|
File without changes
|