just-bash 2.12.0 → 2.12.1

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.
Files changed (113) hide show
  1. package/dist/Bash.d.ts +5 -0
  2. package/dist/bin/chunks/{awk2-YRDDZZBN.js → awk2-ZE5HJBNV.js} +1 -1
  3. package/dist/bin/chunks/chunk-253LRF5J.js +11 -0
  4. package/dist/bin/chunks/chunk-2BC3N3L2.js +16 -0
  5. package/dist/bin/chunks/{chunk-D2VMRCQU.js → chunk-35JD7YEM.js} +12 -12
  6. package/dist/bin/chunks/{chunk-CPL5P744.js → chunk-45MJQ2LX.js} +3 -3
  7. package/dist/bin/{shell/chunks/chunk-JXC25GVQ.js → chunks/chunk-47HZU3SY.js} +1 -1
  8. package/dist/bin/chunks/chunk-4OALHZXB.js +2 -0
  9. package/dist/bin/chunks/chunk-C7TH4MVZ.js +14 -0
  10. package/dist/bin/{shell/chunks/chunk-27KQPTIX.js → chunks/chunk-H7Y3TH22.js} +6 -6
  11. package/dist/bin/chunks/{chunk-HA4QZ6XJ.js → chunk-JWVOLGWZ.js} +4 -4
  12. package/dist/bin/chunks/chunk-N4EU64Y4.js +9 -0
  13. package/dist/bin/{shell/chunks/chunk-6SAF32NO.js → chunks/chunk-VZKEP45B.js} +13 -13
  14. package/dist/bin/chunks/env-HOVBNLUR.js +2 -0
  15. package/dist/bin/chunks/{expansion-HLAOHDFJ.js → expansion-QVHAYGVZ.js} +1 -1
  16. package/dist/bin/chunks/find-4YAO7JQS.js +2 -0
  17. package/dist/bin/chunks/flag-coverage-F4EAJUHL.js +2 -0
  18. package/dist/bin/chunks/help-4H52JYYC.js +2 -0
  19. package/dist/bin/chunks/rg-34GE6REQ.js +2 -0
  20. package/dist/bin/chunks/sqlite3-ZUGDKEIT.js +2 -0
  21. package/dist/bin/chunks/time-E5YULACD.js +2 -0
  22. package/dist/bin/chunks/timeout-TCIINQNA.js +2 -0
  23. package/dist/bin/{shell/chunks/xargs-YWPEV2QC.js → chunks/xargs-GBL6PZ2K.js} +1 -1
  24. package/dist/bin/just-bash.js +3 -3
  25. package/dist/bin/shell/chunks/{awk2-YRDDZZBN.js → awk2-ZE5HJBNV.js} +1 -1
  26. package/dist/bin/shell/chunks/chunk-253LRF5J.js +11 -0
  27. package/dist/bin/shell/chunks/chunk-2BC3N3L2.js +16 -0
  28. package/dist/bin/shell/chunks/{chunk-D2VMRCQU.js → chunk-35JD7YEM.js} +12 -12
  29. package/dist/bin/shell/chunks/{chunk-CPL5P744.js → chunk-45MJQ2LX.js} +3 -3
  30. package/dist/bin/{chunks/chunk-JXC25GVQ.js → shell/chunks/chunk-47HZU3SY.js} +1 -1
  31. package/dist/bin/shell/chunks/chunk-4OALHZXB.js +2 -0
  32. package/dist/bin/shell/chunks/chunk-C7TH4MVZ.js +14 -0
  33. package/dist/bin/{chunks/chunk-27KQPTIX.js → shell/chunks/chunk-H7Y3TH22.js} +6 -6
  34. package/dist/bin/shell/chunks/{chunk-HA4QZ6XJ.js → chunk-JWVOLGWZ.js} +4 -4
  35. package/dist/bin/shell/chunks/chunk-N4EU64Y4.js +9 -0
  36. package/dist/bin/{chunks/chunk-6SAF32NO.js → shell/chunks/chunk-VZKEP45B.js} +13 -13
  37. package/dist/bin/shell/chunks/env-HOVBNLUR.js +2 -0
  38. package/dist/bin/shell/chunks/{expansion-HLAOHDFJ.js → expansion-QVHAYGVZ.js} +1 -1
  39. package/dist/bin/shell/chunks/find-4YAO7JQS.js +2 -0
  40. package/dist/bin/shell/chunks/flag-coverage-F4EAJUHL.js +2 -0
  41. package/dist/bin/shell/chunks/help-4H52JYYC.js +2 -0
  42. package/dist/bin/shell/chunks/rg-34GE6REQ.js +2 -0
  43. package/dist/bin/shell/chunks/sqlite3-ZUGDKEIT.js +2 -0
  44. package/dist/bin/shell/chunks/time-E5YULACD.js +2 -0
  45. package/dist/bin/shell/chunks/timeout-TCIINQNA.js +2 -0
  46. package/dist/bin/{chunks/xargs-YWPEV2QC.js → shell/chunks/xargs-GBL6PZ2K.js} +1 -1
  47. package/dist/bin/shell/shell.js +3 -3
  48. package/dist/bundle/browser.js +519 -519
  49. package/dist/bundle/chunks/{awk2-66MVVLQI.js → awk2-T6LHPVZE.js} +1 -1
  50. package/dist/bundle/chunks/chunk-2GOYXRRP.js +15 -0
  51. package/dist/bundle/chunks/chunk-3RA5L262.js +8 -0
  52. package/dist/bundle/chunks/{chunk-RARYJBGX.js → chunk-BAAVD5NO.js} +13 -13
  53. package/dist/bundle/chunks/{chunk-K4OVSVUA.js → chunk-BNVESM72.js} +6 -6
  54. package/dist/bundle/chunks/{chunk-S7ED3RD5.js → chunk-DKOIE53N.js} +4 -4
  55. package/dist/bundle/chunks/{chunk-FJNVFD75.js → chunk-HBB2R24Y.js} +12 -12
  56. package/dist/bundle/chunks/chunk-IPJHKYVM.js +1 -0
  57. package/dist/bundle/chunks/chunk-JOVMV4XV.js +13 -0
  58. package/dist/bundle/chunks/{chunk-CCCK5QHL.js → chunk-WCVBECE6.js} +3 -3
  59. package/dist/bundle/chunks/chunk-YCABLDKV.js +10 -0
  60. package/dist/bundle/chunks/{chunk-SXR3EI72.js → chunk-ZSJYNBAF.js} +1 -1
  61. package/dist/bundle/chunks/env-XZY4LKEO.js +1 -0
  62. package/dist/bundle/chunks/{expansion-GY7U2FC2.js → expansion-NCEBD7KB.js} +1 -1
  63. package/dist/bundle/chunks/find-DQFMWHAC.js +1 -0
  64. package/dist/bundle/chunks/flag-coverage-U322DJFL.js +1 -0
  65. package/dist/bundle/chunks/help-IA5CMGR4.js +1 -0
  66. package/dist/bundle/chunks/rg-DMOXE47H.js +1 -0
  67. package/dist/bundle/chunks/sqlite3-ZGX3YFJB.js +1 -0
  68. package/dist/bundle/chunks/time-ZEEYNXNZ.js +1 -0
  69. package/dist/bundle/chunks/timeout-LYYTWG45.js +1 -0
  70. package/dist/bundle/chunks/{xargs-OGI2NN6J.js → xargs-2BBAQDTC.js} +1 -1
  71. package/dist/bundle/index.cjs +676 -676
  72. package/dist/bundle/index.js +3 -3
  73. package/dist/commands/sqlite3/sqlite3.d.ts +6 -0
  74. package/dist/interpreter/interpreter.d.ts +2 -0
  75. package/dist/interpreter/types.d.ts +2 -0
  76. package/dist/types.d.ts +5 -0
  77. package/package.json +1 -1
  78. package/dist/bin/chunks/chunk-5UH3Q7QT.js +0 -11
  79. package/dist/bin/chunks/chunk-KLMOJKL4.js +0 -16
  80. package/dist/bin/chunks/chunk-N73TVRMN.js +0 -14
  81. package/dist/bin/chunks/chunk-W2FKF3MM.js +0 -9
  82. package/dist/bin/chunks/env-EVLPSWFF.js +0 -2
  83. package/dist/bin/chunks/find-PHHSZYDL.js +0 -2
  84. package/dist/bin/chunks/flag-coverage-GZCUF7B4.js +0 -2
  85. package/dist/bin/chunks/help-JF5TTAKQ.js +0 -2
  86. package/dist/bin/chunks/rg-EJJ3ILD5.js +0 -2
  87. package/dist/bin/chunks/sqlite3-2UNB5OLS.js +0 -2
  88. package/dist/bin/chunks/time-4C3A4THJ.js +0 -2
  89. package/dist/bin/chunks/timeout-QMKFLOWX.js +0 -2
  90. package/dist/bin/shell/chunks/chunk-5UH3Q7QT.js +0 -11
  91. package/dist/bin/shell/chunks/chunk-KLMOJKL4.js +0 -16
  92. package/dist/bin/shell/chunks/chunk-N73TVRMN.js +0 -14
  93. package/dist/bin/shell/chunks/chunk-W2FKF3MM.js +0 -9
  94. package/dist/bin/shell/chunks/env-EVLPSWFF.js +0 -2
  95. package/dist/bin/shell/chunks/find-PHHSZYDL.js +0 -2
  96. package/dist/bin/shell/chunks/flag-coverage-GZCUF7B4.js +0 -2
  97. package/dist/bin/shell/chunks/help-JF5TTAKQ.js +0 -2
  98. package/dist/bin/shell/chunks/rg-EJJ3ILD5.js +0 -2
  99. package/dist/bin/shell/chunks/sqlite3-2UNB5OLS.js +0 -2
  100. package/dist/bin/shell/chunks/time-4C3A4THJ.js +0 -2
  101. package/dist/bin/shell/chunks/timeout-QMKFLOWX.js +0 -2
  102. package/dist/bundle/chunks/chunk-73RYQHTW.js +0 -10
  103. package/dist/bundle/chunks/chunk-CSBFBYLD.js +0 -13
  104. package/dist/bundle/chunks/chunk-OGDTSM2Q.js +0 -8
  105. package/dist/bundle/chunks/chunk-ZKLK6C7H.js +0 -15
  106. package/dist/bundle/chunks/env-S547XMN7.js +0 -1
  107. package/dist/bundle/chunks/find-6U6YYAEP.js +0 -1
  108. package/dist/bundle/chunks/flag-coverage-25MQKYJJ.js +0 -1
  109. package/dist/bundle/chunks/help-T2NGLTSG.js +0 -1
  110. package/dist/bundle/chunks/rg-4YNHHQAE.js +0 -1
  111. package/dist/bundle/chunks/sqlite3-TLIZUW3F.js +0 -1
  112. package/dist/bundle/chunks/time-BPT76IHZ.js +0 -1
  113. package/dist/bundle/chunks/timeout-QDZFJCOQ.js +0 -1
@@ -45,9 +45,9 @@ import{a as O}from"./chunk-SE4C7FJY.js";import{e as j,f as K,g as C,h as re,i as
45
45
  `:g==="$"||g==="`"||g==='"'||g==="'"||g===`
46
46
  `||c&&g==="}",A=i?"*?[]\\".includes(g):"*?[]\\(){}.^+".includes(g);E?h+=g:A?(d(),u.push(w.escaped(g))):h+=`\\${g}`,f+=2;continue}if(m==="'"&&!i&&!a){d();let g=t.indexOf("'",f+1);if(g===-1){h+=t.slice(f);break}u.push(w.singleQuoted(t.slice(f+1,g))),f=g+1;continue}if(m==='"'&&!a){d();let{part:g,endIndex:E}=jr(e,t,f+1);u.push(g),f=E+1;continue}if(m==="$"&&t[f+1]==="'"){d();let{part:g,endIndex:E}=Jt(e,t,f+2);u.push(g),f=E;continue}if(m==="$"){d();let{part:g,endIndex:E}=ot(e,t,f);g&&u.push(g),f=E;continue}if(m==="`"){d();let{part:g,endIndex:E}=e.parseBacktickSubstitution(t,f);u.push(g),f=E;continue}if(m==="~"){let g=f>0?t[f-1]:"";if(f===0||g==="="||n&&g===":"){let A=jt(e,t,f),S=t[A];if(S===void 0||S==="/"||S===":"){d();let y=t.slice(f+1,A)||null;u.push({type:"TildeExpansion",user:y}),f=A;continue}}}if("@*+?!".includes(m)&&f+1<t.length&&t[f+1]==="("){let g=Zr(t,f+1);if(g!==-1){d();let E=t.slice(f,g+1);u.push({type:"Glob",pattern:E}),f=g+1;continue}}if(m==="*"||m==="?"||m==="["){d();let{pattern:g,endIndex:E}=Xt(e,t,f);u.push({type:"Glob",pattern:g}),f=E;continue}if(m==="{"&&!n&&!l){let g=Yt(e,t,f,ae);if(g){d(),u.push(g.part),f=g.endIndex;continue}}h+=m,f++}return d(),u}function ln(e,t){let r=e.length,s=t+3,n=2,a=!1,i=!1;for(;s<r&&n>0;){let l=e[s];if(a){l==="'"&&(a=!1),s++;continue}if(i){if(l==="\\"){s+=2;continue}l==='"'&&(i=!1),s++;continue}if(l==="'"){a=!0,s++;continue}if(l==='"'){i=!0,s++;continue}if(l==="\\"){s+=2;continue}if(l==="("){n++,s++;continue}if(l===")"){if(n--,n===1){let o=s+1;return!(o<r&&e[o]===")")}if(n===0)return!1;s++;continue}if(n===1&&(l==="|"&&s+1<r&&e[s+1]==="|"||l==="&"&&s+1<r&&e[s+1]==="&"||l==="|"&&s+1<r&&e[s+1]!=="|"))return!0;s++}return!1}function un(e,t,r,s){let n=t+2,a=1,i=n,l=!1,o=!1,c=0,u=!1,f="";for(;i<e.length&&a>0;){let g=e[i];l?g==="'"&&(l=!1):o?g==="\\"&&i+1<e.length?i++:g==='"'&&(o=!1):g==="'"?(l=!0,f=""):g==='"'?(o=!0,f=""):g==="\\"&&i+1<e.length?(i++,f=""):/[a-zA-Z_]/.test(g)?f+=g:(f==="case"?(c++,u=!1):f==="in"&&c>0?u=!0:f==="esac"&&c>0&&(c--,u=!1),f="",g==="("?i>0&&e[i-1]==="$"?a++:u||a++:g===")"?u?u=!1:a--:g===";"&&c>0&&i+1<e.length&&e[i+1]===";"&&(u=!0)),a>0&&i++}a>0&&s("unexpected EOF while looking for matching `)'");let h=e.slice(n,i),m=r().parse(h);return{part:w.commandSubstitution(m,!1),endIndex:i+1}}function cn(e,t,r,s,n){let i=t+1,l="";for(;i<e.length&&e[i]!=="`";)if(e[i]==="\\"){let u=e[i+1];u==="$"||u==="`"||u==="\\"||u===`
47
47
  `||r&&u==='"'?(u!==`
48
- `&&(l+=u),i+=2):(l+=e[i],i++)}else l+=e[i],i++;i>=e.length&&n("unexpected EOF while looking for matching ``'");let c=s().parse(l);return{part:w.commandSubstitution(c,!0),endIndex:i+1}}var V=class e{tokens=[];pos=0;pendingHeredocs=[];parseIterations=0;parseDepth=0;_input="";getInput(){return this._input}checkIterationLimit(){if(this.parseIterations++,this.parseIterations>Qt)throw new Q("Maximum parse iterations exceeded (possible infinite loop)",this.current().line,this.current().column)}enterDepth(){if(this.parseDepth++,this.parseDepth>Ze)throw new Q(`Maximum parser nesting depth exceeded (${Ze})`,this.current().line,this.current().column);return()=>{this.parseDepth--}}parse(t,r){if(t.length>Qe)throw new Q(`Input too large: ${t.length} bytes exceeds limit of ${Qe}`,1,1);this._input=t;let s=new Ie(t,r);if(this.tokens=s.tokenize(),this.tokens.length>Ge)throw new Q(`Too many tokens: ${this.tokens.length} exceeds limit of ${Ge}`,1,1);return this.pos=0,this.pendingHeredocs=[],this.parseIterations=0,this.parseDepth=0,this.parseScript()}parseTokens(t){return this.tokens=t,this.pos=0,this.pendingHeredocs=[],this.parseIterations=0,this.parseDepth=0,this.parseScript()}current(){return this.tokens[this.pos]||this.tokens[this.tokens.length-1]}peek(t=0){return this.tokens[this.pos+t]||this.tokens[this.tokens.length-1]}advance(){let t=this.current();return this.pos<this.tokens.length-1&&this.pos++,t}getPos(){return this.pos}check(t,r,s,n,...a){let i=this.tokens[this.pos]?.type;return i===t||r!==void 0&&i===r||s!==void 0&&i===s||n!==void 0&&i===n?!0:a.length>0?a.includes(i):!1}expect(t,r){if(this.check(t))return this.advance();let s=this.current();throw new Q(r||`Expected ${t}, got ${s.type}`,s.line,s.column,s)}error(t){let r=this.current();throw new Q(t,r.line,r.column,r)}skipNewlines(){for(;this.check(p.NEWLINE,p.COMMENT);)this.check(p.NEWLINE)?(this.advance(),this.processHeredocs()):this.advance()}skipSeparators(t=!0){for(;;){if(this.check(p.NEWLINE)){this.advance(),this.processHeredocs();continue}if(this.check(p.SEMICOLON,p.COMMENT)){this.advance();continue}if(t&&this.check(p.DSEMI,p.SEMI_AND,p.SEMI_SEMI_AND)){this.advance();continue}break}}addPendingHeredoc(t,r,s,n){this.pendingHeredocs.push({redirect:t,delimiter:r,stripTabs:s,quoted:n})}processHeredocs(){for(let t of this.pendingHeredocs)if(this.check(p.HEREDOC_CONTENT)){let r=this.advance(),s;t.quoted?s=w.word([w.literal(r.value)]):s=this.parseWordFromString(r.value,!1,!1,!1,!0),t.redirect.target=w.hereDoc(t.delimiter,s,t.stripTabs,t.quoted)}this.pendingHeredocs=[]}isStatementEnd(){return this.check(p.EOF,p.NEWLINE,p.SEMICOLON,p.AMP,p.AND_AND,p.OR_OR,p.RPAREN,p.RBRACE,p.DSEMI,p.SEMI_AND,p.SEMI_SEMI_AND)}isCommandStart(){let t=this.current().type;return t===p.WORD||t===p.NAME||t===p.NUMBER||t===p.ASSIGNMENT_WORD||t===p.IF||t===p.FOR||t===p.WHILE||t===p.UNTIL||t===p.CASE||t===p.LPAREN||t===p.LBRACE||t===p.DPAREN_START||t===p.DBRACK_START||t===p.FUNCTION||t===p.BANG||t===p.TIME||t===p.IN||t===p.LESS||t===p.GREAT||t===p.DLESS||t===p.DGREAT||t===p.LESSAND||t===p.GREATAND||t===p.LESSGREAT||t===p.DLESSDASH||t===p.CLOBBER||t===p.TLESS||t===p.AND_GREAT||t===p.AND_DGREAT}parseScript(){let t=[],s=0;for(this.skipNewlines();!this.check(p.EOF);){s++,s>1e4&&this.error("Parser stuck: too many iterations (>10000)");let n=this.checkUnexpectedToken();if(n){t.push(n),this.skipSeparators(!1);continue}let a=this.pos,i=this.parseStatement();i&&t.push(i),this.skipSeparators(!1),this.check(p.DSEMI,p.SEMI_AND,p.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${this.current().value}'`),this.pos===a&&!this.check(p.EOF)&&this.advance()}return w.script(t)}checkUnexpectedToken(){let t=this.current().type,r=this.current().value;if((t===p.DO||t===p.DONE||t===p.THEN||t===p.ELSE||t===p.ELIF||t===p.FI||t===p.ESAC)&&this.error(`syntax error near unexpected token \`${r}'`),t===p.RBRACE||t===p.RPAREN){let s=`syntax error near unexpected token \`${r}'`;return this.advance(),w.statement([w.pipeline([w.simpleCommand(null,[],[],[])])],[],!1,{message:s,token:r})}return(t===p.DSEMI||t===p.SEMI_AND||t===p.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${r}'`),t===p.SEMICOLON&&this.error(`syntax error near unexpected token \`${r}'`),(t===p.PIPE||t===p.PIPE_AMP)&&this.error(`syntax error near unexpected token \`${r}'`),null}parseStatement(){if(this.skipNewlines(),!this.isCommandStart())return null;let t=this.current().start,r=[],s=[],n=!1,a=this.parsePipeline();for(r.push(a);this.check(p.AND_AND,p.OR_OR);){let o=this.advance();s.push(o.type===p.AND_AND?"&&":"||"),this.skipNewlines();let c=this.parsePipeline();r.push(c)}this.check(p.AMP)&&(this.advance(),n=!0);let i=this.pos>0?this.tokens[this.pos-1].end:t,l=this._input.slice(t,i);return w.statement(r,s,n,void 0,l)}parsePipeline(){let t=!1,r=!1;this.check(p.TIME)&&(this.advance(),t=!0,this.check(p.WORD,p.NAME)&&this.current().value==="-p"&&(this.advance(),r=!0));let s=0;for(;this.check(p.BANG);)this.advance(),s++;let n=s%2===1,a=[],i=[],l=this.parseCommand();for(a.push(l);this.check(p.PIPE,p.PIPE_AMP);){let o=this.advance();this.skipNewlines(),i.push(o.type===p.PIPE_AMP);let c=this.parseCommand();a.push(c)}return w.pipeline(a,n,t,r,i.length>0?i:void 0)}parseCommand(){return this.check(p.IF)?Xe(this):this.check(p.FOR)?Je(this):this.check(p.WHILE)?Ye(this):this.check(p.UNTIL)?et(this):this.check(p.CASE)?tt(this):this.check(p.LPAREN)?nt(this):this.check(p.LBRACE)?rt(this):this.check(p.DPAREN_START)?this.dparenClosesWithSpacedParens()?this.parseNestedSubshellsFromDparen():this.parseArithmeticCommand():this.check(p.DBRACK_START)?this.parseConditionalCommand():this.check(p.FUNCTION)?this.parseFunctionDef():this.check(p.NAME,p.WORD)&&this.peek(1).type===p.LPAREN&&this.peek(2).type===p.RPAREN?this.parseFunctionDef():nn(this)}dparenClosesWithSpacedParens(){let t=1,r=1;for(;r<this.tokens.length-this.pos;){let s=this.peek(r);if(s.type===p.EOF)return!1;if(s.type===p.DPAREN_START||s.type===p.LPAREN)t++;else if(s.type===p.DPAREN_END){if(t-=2,t<=0)return!1}else if(s.type===p.RPAREN&&(t--,t===0&&this.peek(r+1).type===p.RPAREN))return!0;r++}return!1}parseNestedSubshellsFromDparen(){this.advance();let t=this.parseCompoundList();this.expect(p.RPAREN),this.expect(p.RPAREN);let r=this.parseOptionalRedirections(),s=w.subshell(t,[]);return w.subshell([w.statement([w.pipeline([s],!1,!1,!1)])],r)}isWord(){let t=this.current().type;return t===p.WORD||t===p.NAME||t===p.NUMBER||t===p.IF||t===p.FOR||t===p.WHILE||t===p.UNTIL||t===p.CASE||t===p.FUNCTION||t===p.ELSE||t===p.ELIF||t===p.FI||t===p.THEN||t===p.DO||t===p.DONE||t===p.ESAC||t===p.IN||t===p.SELECT||t===p.TIME||t===p.COPROC||t===p.BANG}parseWord(){let t=this.advance();return this.parseWordFromString(t.value,t.quoted,t.singleQuoted)}parseWordNoBraceExpansion(){let t=this.advance();return this.parseWordFromString(t.value,t.quoted,t.singleQuoted,!1,!1,!0)}parseWordForRegex(){let t=this.advance();return this.parseWordFromString(t.value,t.quoted,t.singleQuoted,!1,!1,!0,!0)}parseWordFromString(t,r=!1,s=!1,n=!1,a=!1,i=!1,l=!1){let o=ae(this,t,r,s,n,a,!1,i,l);return w.word(o)}parseCommandSubstitution(t,r){return un(t,r,()=>new e,s=>this.error(s))}parseBacktickSubstitution(t,r,s=!1){return cn(t,r,s,()=>new e,n=>this.error(n))}isDollarDparenSubshell(t,r){return ln(t,r)}parseArithmeticExpansion(t,r){let s=r+3,n=1,a=0,i=s;for(;i<t.length-1&&n>0;)t[i]==="$"&&t[i+1]==="("?t[i+2]==="("?(n++,i+=3):(a++,i+=2):t[i]==="("&&t[i+1]==="("?(n++,i+=2):t[i]===")"&&t[i+1]===")"?a>0?(a--,i++):(n--,n>0&&(i+=2)):t[i]==="("?(a++,i++):(t[i]===")"&&a>0&&a--,i++);let l=t.slice(s,i),o=this.parseArithmeticExpression(l);return{part:w.arithmeticExpansion(o),endIndex:i+2}}parseArithmeticCommand(){let t=this.expect(p.DPAREN_START),r="",s=1,n=0,a=!1,i=!1;for(;s>0&&!this.check(p.EOF);){if(a){if(a=!1,n>0){n--,r+=")";continue}if(this.check(p.RPAREN)){s--,i=!0,this.advance();continue}if(this.check(p.DPAREN_END)){s--,i=!0;continue}r+=")";continue}if(this.check(p.DPAREN_START))s++,r+="((",this.advance();else if(this.check(p.DPAREN_END))n>=2?(n-=2,r+="))",this.advance()):n===1?(n--,r+=")",a=!0,this.advance()):(s--,i=!0,s>0&&(r+="))"),this.advance());else if(this.check(p.LPAREN))n++,r+="(",this.advance();else if(this.check(p.RPAREN))n>0&&n--,r+=")",this.advance();else{let c=this.current().value,u=r.length>0?r[r.length-1]:"";r.length>0&&!r.endsWith(" ")&&!(c==="="&&/[|&^+\-*/%<>]$/.test(r))&&!(c==="<"&&u==="<")&&!(c===">"&&u===">")&&(r+=" "),r+=c,this.advance()}}i||this.expect(p.DPAREN_END);let l=this.parseArithmeticExpression(r.trim()),o=this.parseOptionalRedirections();return w.arithmeticCommand(l,o,t.line)}parseConditionalCommand(){let t=this.expect(p.DBRACK_START),r=it(this);this.expect(p.DBRACK_END);let s=this.parseOptionalRedirections();return w.conditionalCommand(r,s,t.line)}parseFunctionDef(){let t;if(this.check(p.FUNCTION)){if(this.advance(),this.check(p.NAME)||this.check(p.WORD))t=this.advance().value;else{let n=this.current();throw new Q("Expected function name",n.line,n.column,n)}this.check(p.LPAREN)&&(this.advance(),this.expect(p.RPAREN))}else t=this.advance().value,t.includes("$")&&this.error(`\`${t}': not a valid identifier`),this.expect(p.LPAREN),this.expect(p.RPAREN);this.skipNewlines();let r=this.parseCompoundCommandBody({forFunctionBody:!0}),s=this.parseOptionalRedirections();return w.functionDef(t,r,s)}parseCompoundCommandBody(t){let r=t?.forFunctionBody;if(this.check(p.LBRACE))return rt(this,{skipRedirections:r});if(this.check(p.LPAREN))return nt(this,{skipRedirections:r});if(this.check(p.IF))return Xe(this,{skipRedirections:r});if(this.check(p.FOR))return Je(this,{skipRedirections:r});if(this.check(p.WHILE))return Ye(this,{skipRedirections:r});if(this.check(p.UNTIL))return et(this,{skipRedirections:r});if(this.check(p.CASE))return tt(this,{skipRedirections:r});this.error("Expected compound command for function body")}parseCompoundList(){let t=this.enterDepth(),r=[];for(this.skipNewlines();!this.check(p.EOF,p.FI,p.ELSE,p.ELIF,p.THEN,p.DO,p.DONE,p.ESAC,p.RPAREN,p.RBRACE,p.DSEMI,p.SEMI_AND,p.SEMI_SEMI_AND)&&this.isCommandStart();){this.checkIterationLimit();let s=this.pos,n=this.parseStatement();if(n&&r.push(n),this.skipSeparators(),this.pos===s&&!n)break}return t(),r}parseOptionalRedirections(){let t=[];for(;ve(this);){this.checkIterationLimit();let r=this.pos;if(t.push(De(this)),this.pos===r)break}return t}parseArithmeticExpression(t){return M(this,t)}};function hi(e,t){return new V().parse(e,t)}var Xr=new Map([["alnum","a-zA-Z0-9"],["alpha","a-zA-Z"],["ascii","\\x00-\\x7F"],["blank"," \\t"],["cntrl","\\x00-\\x1F\\x7F"],["digit","0-9"],["graph","!-~"],["lower","a-z"],["print"," -~"],["punct","!-/:-@\\[-`{-~"],["space"," \\t\\n\\r\\f\\v"],["upper","A-Z"],["word","a-zA-Z0-9_"],["xdigit","0-9a-fA-F"]]);function lt(e){return Xr.get(e)??""}function fn(e){let t=[],r="",s=0;for(;s<e.length;){let n=e[s];if(n==="["){for(r+=n,s++,s<e.length&&(e[s]==="!"||e[s]==="^")&&(r+=e[s],s++),s<e.length&&e[s]==="]"&&(r+=e[s],s++);s<e.length&&e[s]!=="]";){if(e[s]==="["&&s+1<e.length&&e[s+1]===":"){let a=e.indexOf(":]",s+2);if(a!==-1){r+=e.slice(s,a+2),s=a+2;continue}}if(e[s]==="\\"&&s+1<e.length){r+=e[s]+e[s+1],s+=2;continue}r+=e[s],s++}s<e.length&&e[s]==="]"&&(r+=e[s],s++)}else n===":"?(r!==""&&t.push(r),r="",s++):n==="\\"&&s+1<e.length?(r+=n+e[s+1],s+=2):(r+=n,s++)}return r!==""&&t.push(r),t}function hn(e){let t="^";for(let r=0;r<e.length;r++){let s=e[r];if(s==="*")t+="[^/]*";else if(s==="?")t+="[^/]";else if(s==="["){let n=r+1,a="[";n<e.length&&(e[n]==="^"||e[n]==="!")&&(a+="^",n++),n<e.length&&e[n]==="]"&&(a+="\\]",n++);let i=n;for(;i<e.length;){if(e[i]==="\\"&&i+1<e.length){i+=2;continue}if(e[i]==="["&&i+1<e.length&&e[i+1]===":"){let o=e.indexOf(":]",i+2);if(o!==-1){i=o+2;continue}}if(e[i]==="]")break;i++}let l=n;for(;n<e.length&&e[n]!=="]";){if(e[n]==="["&&n+1<e.length&&e[n+1]===":"){let o=e.indexOf(":]",n+2);if(o!==-1){let c=e.slice(n+2,o),u=lt(c);a+=u,n=o+2;continue}}if(e[n]==="\\"&&n+1<e.length){a+=`\\${e[n+1]}`,n+=2;continue}if(e[n]==="-"){let o=n===l,c=n+1===i;o||c?a+="\\-":a+="-"}else a+=e[n];n++}a+="]",t+=a,r=n}else if(s==="\\"&&r+1<e.length){let n=e[r+1];/[.+^${}()|\\*?[\]]/.test(n)?t+=`\\${n}`:t+=n,r++}else/[.+^${}()|]/.test(s)?t+=`\\${s}`:t+=s}return t+="$",O(t)}function ut(e,t){let r=1,s=t+1;for(;s<e.length&&r>0;){let n=e[s];if(n==="\\"){s+=2;continue}if(n==="(")r++;else if(n===")"&&(r--,r===0))return s;s++}return-1}function ct(e){let t=[],r="",s=0,n=!1,a=0;for(;a<e.length;){let i=e[a];if(i==="'"&&!n){n=!0,r+="\0QUOTE_START\0",a++;continue}if(i==="'"&&n){n=!1,r+="\0QUOTE_END\0",a++;continue}if(n){r+=i,a++;continue}if(i==="\\"){r+=i,a+1<e.length?(r+=e[a+1],a+=2):a++;continue}i==="("?(s++,r+=i):i===")"?(s--,r+=i):i==="|"&&s===0?(t.push(r),r=""):r+=i,a++}return t.push(r),t}var oe=class{fs;cwd;globignorePatterns=[];hasGlobignore=!1;globstar=!1;nullglob=!1;failglob=!1;dotglob=!1;extglob=!1;globskipdots=!0;ops={count:0};maxOps;constructor(t,r,s,n){this.fs=t,this.cwd=r,typeof n=="boolean"?(this.globstar=n,this.maxOps=1e5):n?(this.globstar=n.globstar??!1,this.nullglob=n.nullglob??!1,this.failglob=n.failglob??!1,this.dotglob=n.dotglob??!1,this.extglob=n.extglob??!1,this.globskipdots=n.globskipdots??!0,this.maxOps=n.maxGlobOperations??1e5):this.maxOps=1e5;let a=s?.get("GLOBIGNORE");a!==void 0&&a!==""&&(this.hasGlobignore=!0,this.globignorePatterns=fn(a))}checkOpsLimit(){if(++this.ops.count>this.maxOps)throw new W(`Glob operation limit exceeded (${this.maxOps})`,"glob_operations")}hasNullglob(){return this.nullglob}hasFailglob(){return this.failglob}filterGlobignore(t){return!this.hasGlobignore&&!this.globskipdots?t:t.filter(r=>{let s=r.split("/").pop()||r;if((this.hasGlobignore||this.globskipdots)&&(s==="."||s===".."))return!1;if(this.hasGlobignore){for(let n of this.globignorePatterns)if(this.matchGlobignorePattern(r,n))return!1}return!0})}matchGlobignorePattern(t,r){return hn(r).test(t)}isGlobPattern(t){return!!(t.includes("*")||t.includes("?")||/\[.*\]/.test(t)||this.extglob&&/[@*+?!]\(/.test(t))}async expandArgs(t,r){let s=t.map((i,l)=>(r?.[l]??!1)||!this.isGlobPattern(i)?null:this.expand(i)),n=await Promise.all(s.map(i=>i||Promise.resolve(null))),a=[];for(let i=0;i<t.length;i++){let l=n[i];l===null?a.push(t[i]):l.length>0?a.push(...l):a.push(t[i])}return a}async expand(t){let r;if(t.includes("**")&&this.globstar&&this.isGlobstarValid(t))r=await this.expandRecursive(t);else{let s=t.replace(/\*\*+/g,"*");r=await this.expandSimple(s)}return this.filterGlobignore(r)}isGlobstarValid(t){let r=t.split("/");for(let s of r)if(s.includes("**")&&s!=="**")return!1;return!0}hasGlobChars(t){return!!(t.includes("*")||t.includes("?")||/\[.*\]/.test(t)||this.extglob&&/[@*+?!]\(/.test(t))}async expandSimple(t){let r=t.startsWith("/"),s=t.split("/").filter(c=>c!==""),n=-1;for(let c=0;c<s.length;c++)if(this.hasGlobChars(s[c])){n=c;break}if(n===-1)return[t];let a,i;if(n===0)r?(a="/",i="/"):(a=this.cwd,i="");else{let c=s.slice(0,n);r?(a=`/${c.join("/")}`,i=`/${c.join("/")}`):(a=this.fs.resolvePath(this.cwd,c.join("/")),i=c.join("/"))}let l=s.slice(n);return(await this.expandSegments(a,i,l)).sort()}async expandSegments(t,r,s){if(this.checkOpsLimit(),s.length===0)return[r];let[n,...a]=s,i=[];try{if(this.fs.readdirWithFileTypes){this.checkOpsLimit();let l=await this.fs.readdirWithFileTypes(t),o=[],c=[...l],u=this.dotglob||this.hasGlobignore;if(n.startsWith(".")||this.dotglob){let h=l.some(m=>m.name==="."),d=l.some(m=>m.name==="..");h||c.push({name:".",isFile:!1,isDirectory:!0,isSymbolicLink:!1}),d||c.push({name:"..",isFile:!1,isDirectory:!0,isSymbolicLink:!1})}for(let h of c)if(!(h.name.startsWith(".")&&!n.startsWith(".")&&!u)&&this.matchPattern(h.name,n)){let d=t==="/"?`/${h.name}`:`${t}/${h.name}`,m;r===""?m=h.name:r==="/"?m=`/${h.name}`:m=`${r}/${h.name}`,a.length===0?o.push(Promise.resolve([m])):h.isDirectory&&o.push(this.expandSegments(d,m,a))}let f=await Promise.all(o);for(let h of f)i.push(...h)}else{this.checkOpsLimit();let l=await this.fs.readdir(t),o=[],c=[...l],u=this.dotglob||this.hasGlobignore;(n.startsWith(".")||this.dotglob)&&(l.includes(".")||c.push("."),l.includes("..")||c.push(".."));for(let h of c)if(!(h.startsWith(".")&&!n.startsWith(".")&&!u)&&this.matchPattern(h,n)){let d=t==="/"?`/${h}`:`${t}/${h}`,m;r===""?m=h:r==="/"?m=`/${h}`:m=`${r}/${h}`,a.length===0?o.push(Promise.resolve([m])):o.push((async()=>{try{if(this.checkOpsLimit(),(await this.fs.stat(d)).isDirectory)return this.expandSegments(d,m,a)}catch(g){if(g instanceof W)throw g}return[]})())}let f=await Promise.all(o);for(let h of f)i.push(...h)}}catch(l){if(l instanceof W)throw l}return i}async expandRecursive(t){let r=[],s=t.indexOf("**"),n=t.slice(0,s).replace(/\/$/,"")||".",i=t.slice(s+2).replace(/^\//,"");return i.includes("**")&&this.isGlobstarValid(i)?(await this.walkDirectoryMultiGlobstar(n,i,r),[...new Set(r)].sort()):(await this.walkDirectory(n,i,r),r.sort())}async walkDirectoryMultiGlobstar(t,r,s){this.checkOpsLimit();let n=this.fs.resolvePath(this.cwd,t);try{this.checkOpsLimit();let a=this.fs.readdirWithFileTypes?await this.fs.readdirWithFileTypes(n):null;if(a){let i=[];for(let c of a){let u=t==="."?c.name:`${t}/${c.name}`;c.isDirectory&&i.push(u)}let l=t==="."?r:`${t}/${r}`,o=await this.expandRecursive(l);s.push(...o);for(let c=0;c<i.length;c+=100){let u=i.slice(c,c+100);await Promise.all(u.map(f=>this.walkDirectoryMultiGlobstar(f,r,s)))}}else{this.checkOpsLimit();let i=await this.fs.readdir(n),l=[];for(let u of i){let f=t==="."?u:`${t}/${u}`,h=this.fs.resolvePath(this.cwd,f);try{this.checkOpsLimit(),(await this.fs.stat(h)).isDirectory&&l.push(f)}catch(d){if(d instanceof W)throw d}}let o=t==="."?r:`${t}/${r}`,c=await this.expandRecursive(o);s.push(...c);for(let u=0;u<l.length;u+=100){let f=l.slice(u,u+100);await Promise.all(f.map(h=>this.walkDirectoryMultiGlobstar(h,r,s)))}}}catch(a){if(a instanceof W)throw a}}async walkDirectory(t,r,s){this.checkOpsLimit();let n=this.fs.resolvePath(this.cwd,t);try{if(this.fs.readdirWithFileTypes){this.checkOpsLimit();let a=await this.fs.readdirWithFileTypes(n),i=[],l=[];for(let o of a){let c=t==="."?o.name:`${t}/${o.name}`;o.isDirectory?l.push(c):r&&this.matchPattern(o.name,r)&&i.push(c)}s.push(...i);for(let o=0;o<l.length;o+=100){let c=l.slice(o,o+100);await Promise.all(c.map(u=>this.walkDirectory(u,r,s)))}}else{this.checkOpsLimit();let a=await this.fs.readdir(n),i=[];for(let o=0;o<a.length;o+=100){let c=a.slice(o,o+100),u=await Promise.all(c.map(async f=>{let h=t==="."?f:`${t}/${f}`,d=this.fs.resolvePath(this.cwd,h);try{this.checkOpsLimit();let m=await this.fs.stat(d);return{name:f,path:h,isDirectory:m.isDirectory}}catch(m){if(m instanceof W)throw m;return null}}));i.push(...u.filter(f=>f!==null))}for(let o of i)!o.isDirectory&&r&&this.matchPattern(o.name,r)&&s.push(o.path);let l=i.filter(o=>o.isDirectory);for(let o=0;o<l.length;o+=100){let c=l.slice(o,o+100);await Promise.all(c.map(u=>this.walkDirectory(u.path,r,s)))}}}catch(a){if(a instanceof W)throw a}}matchPattern(t,r){return this.patternToRegex(r).test(t)}patternToRegex(t){let r=this.patternToRegexStr(t);return O(`^${r}$`)}patternToRegexStr(t){let r="",s=!1;for(let n=0;n<t.length;n++){if(t.slice(n,n+13)==="\0QUOTE_START\0"){s=!0,n+=12;continue}if(t.slice(n,n+11)==="\0QUOTE_END\0"){s=!1,n+=10;continue}let a=t[n];if(s){/[.+^${}()|\\*?[\]]/.test(a)?r+=`\\${a}`:r+=a;continue}if(this.extglob&&(a==="@"||a==="*"||a==="+"||a==="?"||a==="!")&&n+1<t.length&&t[n+1]==="("){let i=ut(t,n+1);if(i!==-1){let l=t.slice(n+2,i),o=ct(l),c=o.map(f=>this.patternToRegexStr(f)),u=c.length>0?c.join("|"):"(?:)";if(a==="@")r+=`(?:${u})`;else if(a==="*")r+=`(?:${u})*`;else if(a==="+")r+=`(?:${u})+`;else if(a==="?")r+=`(?:${u})?`;else if(a==="!")if(i<t.length-1){let h=o.map(m=>this.computePatternLength(m));if(h.every(m=>m!==null)&&h.every(m=>m===h[0])&&h[0]!==null){let m=h[0];if(m===0)r+="(?:.+)";else{let g=[];m>0&&g.push(`.{0,${m-1}}`),g.push(`.{${m+1},}`),g.push(`(?!(?:${u})).{${m}}`),r+=`(?:${g.join("|")})`}}else r+=`(?:(?!(?:${u})).)*?`}else r+=`(?!(?:${u})$).*`;n=i;continue}}if(a==="*")r+=".*";else if(a==="?")r+=".";else if(a==="["){let i=n+1,l="[";i<t.length&&(t[i]==="^"||t[i]==="!")&&(l+="^",i++),i<t.length&&t[i]==="]"&&(l+="\\]",i++);let o=i;for(;o<t.length;){if(t[o]==="\\"&&o+1<t.length){o+=2;continue}if(t[o]==="["&&o+1<t.length&&t[o+1]===":"){let u=t.indexOf(":]",o+2);if(u!==-1){o=u+2;continue}}if(t[o]==="]")break;o++}let c=i;for(;i<t.length&&t[i]!=="]";){if(t[i]==="["&&i+1<t.length&&t[i+1]===":"){let u=t.indexOf(":]",i+2);if(u!==-1){let f=t.slice(i+2,u),h=lt(f);l+=h,i=u+2;continue}}if(t[i]==="\\"&&i+1<t.length){l+=`\\${t[i+1]}`,i+=2;continue}if(t[i]==="-"){let u=i===c,f=i+1===o;u||f?l+="\\-":l+="-"}else l+=t[i];i++}l+="]",r+=l,n=i}else if(a==="\\"&&n+1<t.length){let i=t[n+1];/[.+^${}()|\\*?[\]]/.test(i)?r+=`\\${i}`:r+=i,n++}else/[.+^${}()|]/.test(a)?r+=`\\${a}`:r+=a}return r}computePatternLength(t){let r=0,s=0,n=!1;for(;s<t.length;){if(t.slice(s,s+13)==="\0QUOTE_START\0"){n=!0,s+=13;continue}if(t.slice(s,s+11)==="\0QUOTE_END\0"){n=!1,s+=11;continue}let a=t[s];if(n){r+=1,s++;continue}if((a==="@"||a==="*"||a==="+"||a==="?"||a==="!")&&s+1<t.length&&t[s+1]==="("){let i=ut(t,s+1);if(i!==-1){if(a==="@"){let l=t.slice(s+2,i),c=ct(l).map(u=>this.computePatternLength(u));if(c.every(u=>u!==null)&&c.every(u=>u===c[0])){r+=c[0],s=i+1;continue}return null}return null}}if(a==="*")return null;if(a==="?"){r+=1,s++;continue}if(a==="["){let i=t.indexOf("]",s+1);if(i!==-1){r+=1,s=i+1;continue}r+=1,s++;continue}if(a==="\\"){r+=1,s+=2;continue}r+=1,s++}return r}};function Jr(e,t,r){switch(r){case"+":return e+t;case"-":return e-t;case"*":return e*t;case"/":if(t===0)throw new C("division by 0");return Math.trunc(e/t);case"%":if(t===0)throw new C("division by 0");return e%t;case"**":if(t<0)throw new C("exponent less than 0");return e**t;case"<<":return e<<t;case">>":return e>>t;case"<":return e<t?1:0;case"<=":return e<=t?1:0;case">":return e>t?1:0;case">=":return e>=t?1:0;case"==":return e===t?1:0;case"!=":return e!==t?1:0;case"&":return e&t;case"|":return e|t;case"^":return e^t;case",":return t;default:return 0}}function pn(e,t,r){switch(r){case"=":return t;case"+=":return e+t;case"-=":return e-t;case"*=":return e*t;case"/=":return t!==0?Math.trunc(e/t):0;case"%=":return t!==0?e%t:0;case"<<=":return e<<t;case">>=":return e>>t;case"&=":return e&t;case"|=":return e|t;case"^=":return e^t;default:return t}}function Yr(e,t){switch(t){case"-":return-e;case"+":return+e;case"!":return e===0?1:0;case"~":return~e;default:return e}}async function es(e,t){let r=e.state.env.get(t);if(r!==void 0)return r;let s=e.state.env.get(`${t}_0`);return s!==void 0?s:await v(e,t)}function ts(e){if(!e)return 0;let t=Number.parseInt(e,10);if(!Number.isNaN(t)&&/^-?\d+$/.test(e.trim()))return t;let r=e.trim();if(!r)return 0;try{let s=new V,{expr:n,pos:a}=Z(s,r,0);if(a<r.length){let i=r.slice(a).trim().split(/\s+/)[0];throw new C(`${r}: syntax error in expression (error token is "${i}")`)}return n.type==="ArithNumber"?n.value:t||0}catch(s){if(s instanceof C)throw s;let n=r.split(/\s+/).slice(1)[0]||r;throw new C(`${r}: syntax error in expression (error token is "${n}")`)}}async function ft(e,t){if(!t)return 0;let r=Number.parseInt(t,10);if(!Number.isNaN(r)&&/^-?\d+$/.test(t.trim()))return r;let s=t.trim();if(!s)return 0;let n=new V,{expr:a,pos:i}=Z(n,s,0);if(i<s.length){let l=s.slice(i).trim(),o=l.split(/\s+/)[0]||l;throw new C(`syntax error in expression (error token is "${o}")`,"","")}return await R(e,a)}async function ht(e,t,r=new Set,s=0){if(s>100)throw new C("maximum variable indirection depth exceeded");if(r.has(t))return 0;r.add(t);let n=await es(e,t);if(!n)return 0;let a=Number.parseInt(n,10);if(!Number.isNaN(a)&&/^-?\d+$/.test(n.trim()))return a;let i=n.trim();if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i))return await ht(e,i,r,s+1);let l=new V,{expr:o,pos:c}=Z(l,i,0);if(c<i.length){let u=i.slice(c).trim(),f=u.split(/\s+/)[0]||u;throw new C(`${i}: syntax error in expression (error token is "${f}")`)}return await R(e,o)}async function xe(e,t){if(t.startsWith("#")){let f=t.slice(1),h=f.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(h){let m=h[1],g=P(e,m);return String(g.length)}let d=e.state.env.get(f)||"";return String(d.length)}if(t.startsWith("!")){let f=t.slice(1),h=e.state.env.get(f)||"";return e.state.env.get(h)||""}let r=[":-",":=",":?",":+","-","=","?","+"],s=-1,n="";for(let f of r){let h=t.indexOf(f);h>0&&(s===-1||h<s)&&(s=h,n=f)}if(s===-1)return await v(e,t);let a=t.slice(0,s),i=t.slice(s+n.length),l=e.state.env.get(a),o=l===void 0,c=l==="",u=n.startsWith(":");switch(n){case":-":case"-":return o||u&&c?i:l||"";case":=":case"=":return o||u&&c?(e.state.env.set(a,i),i):l||"";case":+":case"+":return!(o||u&&c)?i:"";case":?":case"?":{if(o||u&&c)throw new Error(i||`${a}: parameter null or not set`);return l||""}default:return l||""}}async function R(e,t,r=!1){switch(t.type){case"ArithNumber":if(Number.isNaN(t.value))throw new C("value too great for base");return t.value;case"ArithVariable":return await ht(e,t.name);case"ArithSpecialVar":{let n=(await v(e,t.name)).trim();if(!n)return 0;let a=Number.parseInt(n,10);if(!Number.isNaN(a)&&/^-?\d+$/.test(n))return a;let i=new V,{expr:l}=Z(i,n,0);return await R(e,l)}case"ArithNested":return await R(e,t.expression);case"ArithCommandSubst":{if(e.execFn){let s=await e.execFn(t.command);s.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||"")+s.stderr);let n=s.stdout.trim();return Number.parseInt(n,10)||0}return 0}case"ArithBracedExpansion":{let s=await xe(e,t.content);return Number.parseInt(s,10)||0}case"ArithDynamicBase":{let s=await xe(e,t.baseExpr),n=Number.parseInt(s,10);if(n<2||n>64)return 0;let a=`${n}#${t.value}`;return ge(a)}case"ArithDynamicNumber":{let n=await xe(e,t.prefix)+t.suffix;return ge(n)}case"ArithArrayElement":{let s=e.state.associativeArrays?.has(t.array),n=async a=>{let i=e.state.env.get(a);return i!==void 0?await ft(e,i):0};if(t.stringKey!==void 0)return await n(`${t.array}_${t.stringKey}`);if(s&&t.index?.type==="ArithVariable"&&!t.index.hasDollarPrefix)return await n(`${t.array}_${t.index.name}`);if(s&&t.index?.type==="ArithVariable"&&t.index.hasDollarPrefix){let a=await v(e,t.index.name);return await n(`${t.array}_${a}`)}if(t.index){let a=await R(e,t.index,r);if(a<0){let o=P(e,t.array),c=e.state.currentLine;if(o.length===0)return e.state.expansionStderr=(e.state.expansionStderr||"")+`bash: line ${c}: ${t.array}: bad array subscript
48
+ `&&(l+=u),i+=2):(l+=e[i],i++)}else l+=e[i],i++;i>=e.length&&n("unexpected EOF while looking for matching ``'");let c=s().parse(l);return{part:w.commandSubstitution(c,!0),endIndex:i+1}}var V=class e{tokens=[];pos=0;pendingHeredocs=[];parseIterations=0;parseDepth=0;_input="";getInput(){return this._input}checkIterationLimit(){if(this.parseIterations++,this.parseIterations>Qt)throw new Q("Maximum parse iterations exceeded (possible infinite loop)",this.current().line,this.current().column)}enterDepth(){if(this.parseDepth++,this.parseDepth>Ze)throw new Q(`Maximum parser nesting depth exceeded (${Ze})`,this.current().line,this.current().column);return()=>{this.parseDepth--}}parse(t,r){if(t.length>Qe)throw new Q(`Input too large: ${t.length} bytes exceeds limit of ${Qe}`,1,1);this._input=t;let s=new Ie(t,r);if(this.tokens=s.tokenize(),this.tokens.length>Ge)throw new Q(`Too many tokens: ${this.tokens.length} exceeds limit of ${Ge}`,1,1);return this.pos=0,this.pendingHeredocs=[],this.parseIterations=0,this.parseDepth=0,this.parseScript()}parseTokens(t){return this.tokens=t,this.pos=0,this.pendingHeredocs=[],this.parseIterations=0,this.parseDepth=0,this.parseScript()}current(){return this.tokens[this.pos]||this.tokens[this.tokens.length-1]}peek(t=0){return this.tokens[this.pos+t]||this.tokens[this.tokens.length-1]}advance(){let t=this.current();return this.pos<this.tokens.length-1&&this.pos++,t}getPos(){return this.pos}check(t,r,s,n,...a){let i=this.tokens[this.pos]?.type;return i===t||r!==void 0&&i===r||s!==void 0&&i===s||n!==void 0&&i===n?!0:a.length>0?a.includes(i):!1}expect(t,r){if(this.check(t))return this.advance();let s=this.current();throw new Q(r||`Expected ${t}, got ${s.type}`,s.line,s.column,s)}error(t){let r=this.current();throw new Q(t,r.line,r.column,r)}skipNewlines(){for(;this.check(p.NEWLINE,p.COMMENT);)this.check(p.NEWLINE)?(this.advance(),this.processHeredocs()):this.advance()}skipSeparators(t=!0){for(;;){if(this.check(p.NEWLINE)){this.advance(),this.processHeredocs();continue}if(this.check(p.SEMICOLON,p.COMMENT)){this.advance();continue}if(t&&this.check(p.DSEMI,p.SEMI_AND,p.SEMI_SEMI_AND)){this.advance();continue}break}}addPendingHeredoc(t,r,s,n){this.pendingHeredocs.push({redirect:t,delimiter:r,stripTabs:s,quoted:n})}processHeredocs(){for(let t of this.pendingHeredocs)if(this.check(p.HEREDOC_CONTENT)){let r=this.advance(),s;t.quoted?s=w.word([w.literal(r.value)]):s=this.parseWordFromString(r.value,!1,!1,!1,!0),t.redirect.target=w.hereDoc(t.delimiter,s,t.stripTabs,t.quoted)}this.pendingHeredocs=[]}isStatementEnd(){return this.check(p.EOF,p.NEWLINE,p.SEMICOLON,p.AMP,p.AND_AND,p.OR_OR,p.RPAREN,p.RBRACE,p.DSEMI,p.SEMI_AND,p.SEMI_SEMI_AND)}isCommandStart(){let t=this.current().type;return t===p.WORD||t===p.NAME||t===p.NUMBER||t===p.ASSIGNMENT_WORD||t===p.IF||t===p.FOR||t===p.WHILE||t===p.UNTIL||t===p.CASE||t===p.LPAREN||t===p.LBRACE||t===p.DPAREN_START||t===p.DBRACK_START||t===p.FUNCTION||t===p.BANG||t===p.TIME||t===p.IN||t===p.LESS||t===p.GREAT||t===p.DLESS||t===p.DGREAT||t===p.LESSAND||t===p.GREATAND||t===p.LESSGREAT||t===p.DLESSDASH||t===p.CLOBBER||t===p.TLESS||t===p.AND_GREAT||t===p.AND_DGREAT}parseScript(){let t=[],s=0;for(this.skipNewlines();!this.check(p.EOF);){s++,s>1e4&&this.error("Parser stuck: too many iterations (>10000)");let n=this.checkUnexpectedToken();if(n){t.push(n),this.skipSeparators(!1);continue}let a=this.pos,i=this.parseStatement();i&&t.push(i),this.skipSeparators(!1),this.check(p.DSEMI,p.SEMI_AND,p.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${this.current().value}'`),this.pos===a&&!this.check(p.EOF)&&this.advance()}return w.script(t)}checkUnexpectedToken(){let t=this.current().type,r=this.current().value;if((t===p.DO||t===p.DONE||t===p.THEN||t===p.ELSE||t===p.ELIF||t===p.FI||t===p.ESAC)&&this.error(`syntax error near unexpected token \`${r}'`),t===p.RBRACE||t===p.RPAREN){let s=`syntax error near unexpected token \`${r}'`;return this.advance(),w.statement([w.pipeline([w.simpleCommand(null,[],[],[])])],[],!1,{message:s,token:r})}return(t===p.DSEMI||t===p.SEMI_AND||t===p.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${r}'`),t===p.SEMICOLON&&this.error(`syntax error near unexpected token \`${r}'`),(t===p.PIPE||t===p.PIPE_AMP)&&this.error(`syntax error near unexpected token \`${r}'`),null}parseStatement(){if(this.skipNewlines(),!this.isCommandStart())return null;let t=this.current().start,r=[],s=[],n=!1,a=this.parsePipeline();for(r.push(a);this.check(p.AND_AND,p.OR_OR);){let o=this.advance();s.push(o.type===p.AND_AND?"&&":"||"),this.skipNewlines();let c=this.parsePipeline();r.push(c)}this.check(p.AMP)&&(this.advance(),n=!0);let i=this.pos>0?this.tokens[this.pos-1].end:t,l=this._input.slice(t,i);return w.statement(r,s,n,void 0,l)}parsePipeline(){let t=!1,r=!1;this.check(p.TIME)&&(this.advance(),t=!0,this.check(p.WORD,p.NAME)&&this.current().value==="-p"&&(this.advance(),r=!0));let s=0;for(;this.check(p.BANG);)this.advance(),s++;let n=s%2===1,a=[],i=[],l=this.parseCommand();for(a.push(l);this.check(p.PIPE,p.PIPE_AMP);){let o=this.advance();this.skipNewlines(),i.push(o.type===p.PIPE_AMP);let c=this.parseCommand();a.push(c)}return w.pipeline(a,n,t,r,i.length>0?i:void 0)}parseCommand(){return this.check(p.IF)?Xe(this):this.check(p.FOR)?Je(this):this.check(p.WHILE)?Ye(this):this.check(p.UNTIL)?et(this):this.check(p.CASE)?tt(this):this.check(p.LPAREN)?nt(this):this.check(p.LBRACE)?rt(this):this.check(p.DPAREN_START)?this.dparenClosesWithSpacedParens()?this.parseNestedSubshellsFromDparen():this.parseArithmeticCommand():this.check(p.DBRACK_START)?this.parseConditionalCommand():this.check(p.FUNCTION)?this.parseFunctionDef():this.check(p.NAME,p.WORD)&&this.peek(1).type===p.LPAREN&&this.peek(2).type===p.RPAREN?this.parseFunctionDef():nn(this)}dparenClosesWithSpacedParens(){let t=1,r=1;for(;r<this.tokens.length-this.pos;){let s=this.peek(r);if(s.type===p.EOF)return!1;if(s.type===p.DPAREN_START||s.type===p.LPAREN)t++;else if(s.type===p.DPAREN_END){if(t-=2,t<=0)return!1}else if(s.type===p.RPAREN&&(t--,t===0&&this.peek(r+1).type===p.RPAREN))return!0;r++}return!1}parseNestedSubshellsFromDparen(){this.advance();let t=this.parseCompoundList();this.expect(p.RPAREN),this.expect(p.RPAREN);let r=this.parseOptionalRedirections(),s=w.subshell(t,[]);return w.subshell([w.statement([w.pipeline([s],!1,!1,!1)])],r)}isWord(){let t=this.current().type;return t===p.WORD||t===p.NAME||t===p.NUMBER||t===p.IF||t===p.FOR||t===p.WHILE||t===p.UNTIL||t===p.CASE||t===p.FUNCTION||t===p.ELSE||t===p.ELIF||t===p.FI||t===p.THEN||t===p.DO||t===p.DONE||t===p.ESAC||t===p.IN||t===p.SELECT||t===p.TIME||t===p.COPROC||t===p.BANG}parseWord(){let t=this.advance();return this.parseWordFromString(t.value,t.quoted,t.singleQuoted)}parseWordNoBraceExpansion(){let t=this.advance();return this.parseWordFromString(t.value,t.quoted,t.singleQuoted,!1,!1,!0)}parseWordForRegex(){let t=this.advance();return this.parseWordFromString(t.value,t.quoted,t.singleQuoted,!1,!1,!0,!0)}parseWordFromString(t,r=!1,s=!1,n=!1,a=!1,i=!1,l=!1){let o=ae(this,t,r,s,n,a,!1,i,l);return w.word(o)}parseCommandSubstitution(t,r){return un(t,r,()=>new e,s=>this.error(s))}parseBacktickSubstitution(t,r,s=!1){return cn(t,r,s,()=>new e,n=>this.error(n))}isDollarDparenSubshell(t,r){return ln(t,r)}parseArithmeticExpansion(t,r){let s=r+3,n=1,a=0,i=s;for(;i<t.length-1&&n>0;)t[i]==="$"&&t[i+1]==="("?t[i+2]==="("?(n++,i+=3):(a++,i+=2):t[i]==="("&&t[i+1]==="("?(n++,i+=2):t[i]===")"&&t[i+1]===")"?a>0?(a--,i++):(n--,n>0&&(i+=2)):t[i]==="("?(a++,i++):(t[i]===")"&&a>0&&a--,i++);let l=t.slice(s,i),o=this.parseArithmeticExpression(l);return{part:w.arithmeticExpansion(o),endIndex:i+2}}parseArithmeticCommand(){let t=this.expect(p.DPAREN_START),r="",s=1,n=0,a=!1,i=!1;for(;s>0&&!this.check(p.EOF);){if(a){if(a=!1,n>0){n--,r+=")";continue}if(this.check(p.RPAREN)){s--,i=!0,this.advance();continue}if(this.check(p.DPAREN_END)){s--,i=!0;continue}r+=")";continue}if(this.check(p.DPAREN_START))s++,r+="((",this.advance();else if(this.check(p.DPAREN_END))n>=2?(n-=2,r+="))",this.advance()):n===1?(n--,r+=")",a=!0,this.advance()):(s--,i=!0,s>0&&(r+="))"),this.advance());else if(this.check(p.LPAREN))n++,r+="(",this.advance();else if(this.check(p.RPAREN))n>0&&n--,r+=")",this.advance();else{let c=this.current().value,u=r.length>0?r[r.length-1]:"";r.length>0&&!r.endsWith(" ")&&!(c==="="&&/[|&^+\-*/%<>]$/.test(r))&&!(c==="<"&&u==="<")&&!(c===">"&&u===">")&&(r+=" "),r+=c,this.advance()}}i||this.expect(p.DPAREN_END);let l=this.parseArithmeticExpression(r.trim()),o=this.parseOptionalRedirections();return w.arithmeticCommand(l,o,t.line)}parseConditionalCommand(){let t=this.expect(p.DBRACK_START),r=it(this);this.expect(p.DBRACK_END);let s=this.parseOptionalRedirections();return w.conditionalCommand(r,s,t.line)}parseFunctionDef(){let t;if(this.check(p.FUNCTION)){if(this.advance(),this.check(p.NAME)||this.check(p.WORD))t=this.advance().value;else{let n=this.current();throw new Q("Expected function name",n.line,n.column,n)}this.check(p.LPAREN)&&(this.advance(),this.expect(p.RPAREN))}else t=this.advance().value,t.includes("$")&&this.error(`\`${t}': not a valid identifier`),this.expect(p.LPAREN),this.expect(p.RPAREN);this.skipNewlines();let r=this.parseCompoundCommandBody({forFunctionBody:!0}),s=this.parseOptionalRedirections();return w.functionDef(t,r,s)}parseCompoundCommandBody(t){let r=t?.forFunctionBody;if(this.check(p.LBRACE))return rt(this,{skipRedirections:r});if(this.check(p.LPAREN))return nt(this,{skipRedirections:r});if(this.check(p.IF))return Xe(this,{skipRedirections:r});if(this.check(p.FOR))return Je(this,{skipRedirections:r});if(this.check(p.WHILE))return Ye(this,{skipRedirections:r});if(this.check(p.UNTIL))return et(this,{skipRedirections:r});if(this.check(p.CASE))return tt(this,{skipRedirections:r});this.error("Expected compound command for function body")}parseCompoundList(){let t=this.enterDepth(),r=[];for(this.skipNewlines();!this.check(p.EOF,p.FI,p.ELSE,p.ELIF,p.THEN,p.DO,p.DONE,p.ESAC,p.RPAREN,p.RBRACE,p.DSEMI,p.SEMI_AND,p.SEMI_SEMI_AND)&&this.isCommandStart();){this.checkIterationLimit();let s=this.pos,n=this.parseStatement();if(n&&r.push(n),this.skipSeparators(),this.pos===s&&!n)break}return t(),r}parseOptionalRedirections(){let t=[];for(;ve(this);){this.checkIterationLimit();let r=this.pos;if(t.push(De(this)),this.pos===r)break}return t}parseArithmeticExpression(t){return M(this,t)}};function hi(e,t){return new V().parse(e,t)}var Xr=new Map([["alnum","a-zA-Z0-9"],["alpha","a-zA-Z"],["ascii","\\x00-\\x7F"],["blank"," \\t"],["cntrl","\\x00-\\x1F\\x7F"],["digit","0-9"],["graph","!-~"],["lower","a-z"],["print"," -~"],["punct","!-/:-@\\[-`{-~"],["space"," \\t\\n\\r\\f\\v"],["upper","A-Z"],["word","a-zA-Z0-9_"],["xdigit","0-9a-fA-F"]]);function lt(e){return Xr.get(e)??""}function fn(e){let t=[],r="",s=0;for(;s<e.length;){let n=e[s];if(n==="["){for(r+=n,s++,s<e.length&&(e[s]==="!"||e[s]==="^")&&(r+=e[s],s++),s<e.length&&e[s]==="]"&&(r+=e[s],s++);s<e.length&&e[s]!=="]";){if(e[s]==="["&&s+1<e.length&&e[s+1]===":"){let a=e.indexOf(":]",s+2);if(a!==-1){r+=e.slice(s,a+2),s=a+2;continue}}if(e[s]==="\\"&&s+1<e.length){r+=e[s]+e[s+1],s+=2;continue}r+=e[s],s++}s<e.length&&e[s]==="]"&&(r+=e[s],s++)}else n===":"?(r!==""&&t.push(r),r="",s++):n==="\\"&&s+1<e.length?(r+=n+e[s+1],s+=2):(r+=n,s++)}return r!==""&&t.push(r),t}function hn(e){let t="^";for(let r=0;r<e.length;r++){let s=e[r];if(s==="*")t+="[^/]*";else if(s==="?")t+="[^/]";else if(s==="["){let n=r+1,a="[";n<e.length&&(e[n]==="^"||e[n]==="!")&&(a+="^",n++),n<e.length&&e[n]==="]"&&(a+="\\]",n++);let i=n;for(;i<e.length;){if(e[i]==="\\"&&i+1<e.length){i+=2;continue}if(e[i]==="["&&i+1<e.length&&e[i+1]===":"){let o=e.indexOf(":]",i+2);if(o!==-1){i=o+2;continue}}if(e[i]==="]")break;i++}let l=n;for(;n<e.length&&e[n]!=="]";){if(e[n]==="["&&n+1<e.length&&e[n+1]===":"){let o=e.indexOf(":]",n+2);if(o!==-1){let c=e.slice(n+2,o),u=lt(c);a+=u,n=o+2;continue}}if(e[n]==="\\"&&n+1<e.length){a+=`\\${e[n+1]}`,n+=2;continue}if(e[n]==="-"){let o=n===l,c=n+1===i;o||c?a+="\\-":a+="-"}else a+=e[n];n++}a+="]",t+=a,r=n}else if(s==="\\"&&r+1<e.length){let n=e[r+1];/[.+^${}()|\\*?[\]]/.test(n)?t+=`\\${n}`:t+=n,r++}else/[.+^${}()|]/.test(s)?t+=`\\${s}`:t+=s}return t+="$",O(t)}function ut(e,t){let r=1,s=t+1;for(;s<e.length&&r>0;){let n=e[s];if(n==="\\"){s+=2;continue}if(n==="(")r++;else if(n===")"&&(r--,r===0))return s;s++}return-1}function ct(e){let t=[],r="",s=0,n=!1,a=0;for(;a<e.length;){let i=e[a];if(i==="'"&&!n){n=!0,r+="\0QUOTE_START\0",a++;continue}if(i==="'"&&n){n=!1,r+="\0QUOTE_END\0",a++;continue}if(n){r+=i,a++;continue}if(i==="\\"){r+=i,a+1<e.length?(r+=e[a+1],a+=2):a++;continue}i==="("?(s++,r+=i):i===")"?(s--,r+=i):i==="|"&&s===0?(t.push(r),r=""):r+=i,a++}return t.push(r),t}var oe=class{fs;cwd;globignorePatterns=[];hasGlobignore=!1;globstar=!1;nullglob=!1;failglob=!1;dotglob=!1;extglob=!1;globskipdots=!0;ops={count:0};maxOps;constructor(t,r,s,n){this.fs=t,this.cwd=r,typeof n=="boolean"?(this.globstar=n,this.maxOps=1e5):n?(this.globstar=n.globstar??!1,this.nullglob=n.nullglob??!1,this.failglob=n.failglob??!1,this.dotglob=n.dotglob??!1,this.extglob=n.extglob??!1,this.globskipdots=n.globskipdots??!0,this.maxOps=n.maxGlobOperations??1e5):this.maxOps=1e5;let a=s?.get("GLOBIGNORE");a!==void 0&&a!==""&&(this.hasGlobignore=!0,this.globignorePatterns=fn(a))}checkOpsLimit(){if(++this.ops.count>this.maxOps)throw new W(`Glob operation limit exceeded (${this.maxOps})`,"glob_operations")}hasNullglob(){return this.nullglob}hasFailglob(){return this.failglob}filterGlobignore(t){return!this.hasGlobignore&&!this.globskipdots?t:t.filter(r=>{let s=r.split("/").pop()||r;if((this.hasGlobignore||this.globskipdots)&&(s==="."||s===".."))return!1;if(this.hasGlobignore){for(let n of this.globignorePatterns)if(this.matchGlobignorePattern(r,n))return!1}return!0})}matchGlobignorePattern(t,r){return hn(r).test(t)}isGlobPattern(t){return!!(t.includes("*")||t.includes("?")||/\[.*\]/.test(t)||this.extglob&&/[@*+?!]\(/.test(t))}async expandArgs(t,r){let s=t.map((i,l)=>(r?.[l]??!1)||!this.isGlobPattern(i)?null:this.expand(i)),n=await Promise.all(s.map(i=>i||Promise.resolve(null))),a=[];for(let i=0;i<t.length;i++){let l=n[i];l===null?a.push(t[i]):l.length>0?a.push(...l):a.push(t[i])}return a}async expand(t){let r;if(t.includes("**")&&this.globstar&&this.isGlobstarValid(t))r=await this.expandRecursive(t);else{let s=t.replace(/\*\*+/g,"*");r=await this.expandSimple(s)}return this.filterGlobignore(r)}isGlobstarValid(t){let r=t.split("/");for(let s of r)if(s.includes("**")&&s!=="**")return!1;return!0}hasGlobChars(t){return!!(t.includes("*")||t.includes("?")||/\[.*\]/.test(t)||this.extglob&&/[@*+?!]\(/.test(t))}async expandSimple(t){let r=t.startsWith("/"),s=t.split("/").filter(c=>c!==""),n=-1;for(let c=0;c<s.length;c++)if(this.hasGlobChars(s[c])){n=c;break}if(n===-1)return[t];let a,i;if(n===0)r?(a="/",i="/"):(a=this.cwd,i="");else{let c=s.slice(0,n);r?(a=`/${c.join("/")}`,i=`/${c.join("/")}`):(a=this.fs.resolvePath(this.cwd,c.join("/")),i=c.join("/"))}let l=s.slice(n);return(await this.expandSegments(a,i,l)).sort()}async expandSegments(t,r,s){if(this.checkOpsLimit(),s.length===0)return[r];let[n,...a]=s,i=[];try{if(this.fs.readdirWithFileTypes){this.checkOpsLimit();let l=await this.fs.readdirWithFileTypes(t),o=[],c=[...l],u=this.dotglob||this.hasGlobignore;if(n.startsWith(".")||this.dotglob){let h=l.some(m=>m.name==="."),d=l.some(m=>m.name==="..");h||c.push({name:".",isFile:!1,isDirectory:!0,isSymbolicLink:!1}),d||c.push({name:"..",isFile:!1,isDirectory:!0,isSymbolicLink:!1})}for(let h of c)if(!(h.name.startsWith(".")&&!n.startsWith(".")&&!u)&&this.matchPattern(h.name,n)){let d=t==="/"?`/${h.name}`:`${t}/${h.name}`,m;r===""?m=h.name:r==="/"?m=`/${h.name}`:m=`${r}/${h.name}`,a.length===0?o.push(Promise.resolve([m])):h.isDirectory&&o.push(this.expandSegments(d,m,a))}let f=await Promise.all(o);for(let h of f)i.push(...h)}else{this.checkOpsLimit();let l=await this.fs.readdir(t),o=[],c=[...l],u=this.dotglob||this.hasGlobignore;(n.startsWith(".")||this.dotglob)&&(l.includes(".")||c.push("."),l.includes("..")||c.push(".."));for(let h of c)if(!(h.startsWith(".")&&!n.startsWith(".")&&!u)&&this.matchPattern(h,n)){let d=t==="/"?`/${h}`:`${t}/${h}`,m;r===""?m=h:r==="/"?m=`/${h}`:m=`${r}/${h}`,a.length===0?o.push(Promise.resolve([m])):o.push((async()=>{try{if(this.checkOpsLimit(),(await this.fs.stat(d)).isDirectory)return this.expandSegments(d,m,a)}catch(g){if(g instanceof W)throw g}return[]})())}let f=await Promise.all(o);for(let h of f)i.push(...h)}}catch(l){if(l instanceof W)throw l}return i}async expandRecursive(t){let r=[],s=t.indexOf("**"),n=t.slice(0,s).replace(/\/$/,"")||".",i=t.slice(s+2).replace(/^\//,"");return i.includes("**")&&this.isGlobstarValid(i)?(await this.walkDirectoryMultiGlobstar(n,i,r),[...new Set(r)].sort()):(await this.walkDirectory(n,i,r),r.sort())}async walkDirectoryMultiGlobstar(t,r,s){this.checkOpsLimit();let n=this.fs.resolvePath(this.cwd,t);try{this.checkOpsLimit();let a=this.fs.readdirWithFileTypes?await this.fs.readdirWithFileTypes(n):null;if(a){let i=[];for(let c of a){let u=t==="."?c.name:`${t}/${c.name}`;c.isDirectory&&i.push(u)}let l=t==="."?r:`${t}/${r}`,o=await this.expandRecursive(l);s.push(...o);for(let c=0;c<i.length;c+=100){let u=i.slice(c,c+100);await Promise.all(u.map(f=>this.walkDirectoryMultiGlobstar(f,r,s)))}}else{this.checkOpsLimit();let i=await this.fs.readdir(n),l=[];for(let u of i){let f=t==="."?u:`${t}/${u}`,h=this.fs.resolvePath(this.cwd,f);try{this.checkOpsLimit(),(await this.fs.stat(h)).isDirectory&&l.push(f)}catch(d){if(d instanceof W)throw d}}let o=t==="."?r:`${t}/${r}`,c=await this.expandRecursive(o);s.push(...c);for(let u=0;u<l.length;u+=100){let f=l.slice(u,u+100);await Promise.all(f.map(h=>this.walkDirectoryMultiGlobstar(h,r,s)))}}}catch(a){if(a instanceof W)throw a}}async walkDirectory(t,r,s){this.checkOpsLimit();let n=this.fs.resolvePath(this.cwd,t);try{if(this.fs.readdirWithFileTypes){this.checkOpsLimit();let a=await this.fs.readdirWithFileTypes(n),i=[],l=[];for(let o of a){let c=t==="."?o.name:`${t}/${o.name}`;o.isDirectory?l.push(c):r&&this.matchPattern(o.name,r)&&i.push(c)}s.push(...i);for(let o=0;o<l.length;o+=100){let c=l.slice(o,o+100);await Promise.all(c.map(u=>this.walkDirectory(u,r,s)))}}else{this.checkOpsLimit();let a=await this.fs.readdir(n),i=[];for(let o=0;o<a.length;o+=100){let c=a.slice(o,o+100),u=await Promise.all(c.map(async f=>{let h=t==="."?f:`${t}/${f}`,d=this.fs.resolvePath(this.cwd,h);try{this.checkOpsLimit();let m=await this.fs.stat(d);return{name:f,path:h,isDirectory:m.isDirectory}}catch(m){if(m instanceof W)throw m;return null}}));i.push(...u.filter(f=>f!==null))}for(let o of i)!o.isDirectory&&r&&this.matchPattern(o.name,r)&&s.push(o.path);let l=i.filter(o=>o.isDirectory);for(let o=0;o<l.length;o+=100){let c=l.slice(o,o+100);await Promise.all(c.map(u=>this.walkDirectory(u.path,r,s)))}}}catch(a){if(a instanceof W)throw a}}matchPattern(t,r){return this.patternToRegex(r).test(t)}patternToRegex(t){let r=this.patternToRegexStr(t);return O(`^${r}$`)}patternToRegexStr(t){let r="",s=!1;for(let n=0;n<t.length;n++){if(t.slice(n,n+13)==="\0QUOTE_START\0"){s=!0,n+=12;continue}if(t.slice(n,n+11)==="\0QUOTE_END\0"){s=!1,n+=10;continue}let a=t[n];if(s){/[.+^${}()|\\*?[\]]/.test(a)?r+=`\\${a}`:r+=a;continue}if(this.extglob&&(a==="@"||a==="*"||a==="+"||a==="?"||a==="!")&&n+1<t.length&&t[n+1]==="("){let i=ut(t,n+1);if(i!==-1){let l=t.slice(n+2,i),o=ct(l),c=o.map(f=>this.patternToRegexStr(f)),u=c.length>0?c.join("|"):"(?:)";if(a==="@")r+=`(?:${u})`;else if(a==="*")r+=`(?:${u})*`;else if(a==="+")r+=`(?:${u})+`;else if(a==="?")r+=`(?:${u})?`;else if(a==="!")if(i<t.length-1){let h=o.map(m=>this.computePatternLength(m));if(h.every(m=>m!==null)&&h.every(m=>m===h[0])&&h[0]!==null){let m=h[0];if(m===0)r+="(?:.+)";else{let g=[];m>0&&g.push(`.{0,${m-1}}`),g.push(`.{${m+1},}`),g.push(`(?!(?:${u})).{${m}}`),r+=`(?:${g.join("|")})`}}else r+=`(?:(?!(?:${u})).)*?`}else r+=`(?!(?:${u})$).*`;n=i;continue}}if(a==="*")r+=".*";else if(a==="?")r+=".";else if(a==="["){let i=n+1,l="[";i<t.length&&(t[i]==="^"||t[i]==="!")&&(l+="^",i++),i<t.length&&t[i]==="]"&&(l+="\\]",i++);let o=i;for(;o<t.length;){if(t[o]==="\\"&&o+1<t.length){o+=2;continue}if(t[o]==="["&&o+1<t.length&&t[o+1]===":"){let u=t.indexOf(":]",o+2);if(u!==-1){o=u+2;continue}}if(t[o]==="]")break;o++}let c=i;for(;i<t.length&&t[i]!=="]";){if(t[i]==="["&&i+1<t.length&&t[i+1]===":"){let u=t.indexOf(":]",i+2);if(u!==-1){let f=t.slice(i+2,u),h=lt(f);l+=h,i=u+2;continue}}if(t[i]==="\\"&&i+1<t.length){l+=`\\${t[i+1]}`,i+=2;continue}if(t[i]==="-"){let u=i===c,f=i+1===o;u||f?l+="\\-":l+="-"}else l+=t[i];i++}l+="]",r+=l,n=i}else if(a==="\\"&&n+1<t.length){let i=t[n+1];/[.+^${}()|\\*?[\]]/.test(i)?r+=`\\${i}`:r+=i,n++}else/[.+^${}()|]/.test(a)?r+=`\\${a}`:r+=a}return r}computePatternLength(t){let r=0,s=0,n=!1;for(;s<t.length;){if(t.slice(s,s+13)==="\0QUOTE_START\0"){n=!0,s+=13;continue}if(t.slice(s,s+11)==="\0QUOTE_END\0"){n=!1,s+=11;continue}let a=t[s];if(n){r+=1,s++;continue}if((a==="@"||a==="*"||a==="+"||a==="?"||a==="!")&&s+1<t.length&&t[s+1]==="("){let i=ut(t,s+1);if(i!==-1){if(a==="@"){let l=t.slice(s+2,i),c=ct(l).map(u=>this.computePatternLength(u));if(c.every(u=>u!==null)&&c.every(u=>u===c[0])){r+=c[0],s=i+1;continue}return null}return null}}if(a==="*")return null;if(a==="?"){r+=1,s++;continue}if(a==="["){let i=t.indexOf("]",s+1);if(i!==-1){r+=1,s=i+1;continue}r+=1,s++;continue}if(a==="\\"){r+=1,s+=2;continue}r+=1,s++}return r}};function Jr(e,t,r){switch(r){case"+":return e+t;case"-":return e-t;case"*":return e*t;case"/":if(t===0)throw new C("division by 0");return Math.trunc(e/t);case"%":if(t===0)throw new C("division by 0");return e%t;case"**":if(t<0)throw new C("exponent less than 0");return e**t;case"<<":return e<<t;case">>":return e>>t;case"<":return e<t?1:0;case"<=":return e<=t?1:0;case">":return e>t?1:0;case">=":return e>=t?1:0;case"==":return e===t?1:0;case"!=":return e!==t?1:0;case"&":return e&t;case"|":return e|t;case"^":return e^t;case",":return t;default:return 0}}function pn(e,t,r){switch(r){case"=":return t;case"+=":return e+t;case"-=":return e-t;case"*=":return e*t;case"/=":return t!==0?Math.trunc(e/t):0;case"%=":return t!==0?e%t:0;case"<<=":return e<<t;case">>=":return e>>t;case"&=":return e&t;case"|=":return e|t;case"^=":return e^t;default:return t}}function Yr(e,t){switch(t){case"-":return-e;case"+":return+e;case"!":return e===0?1:0;case"~":return~e;default:return e}}async function es(e,t){let r=e.state.env.get(t);if(r!==void 0)return r;let s=e.state.env.get(`${t}_0`);return s!==void 0?s:await v(e,t)}function ts(e){if(!e)return 0;let t=Number.parseInt(e,10);if(!Number.isNaN(t)&&/^-?\d+$/.test(e.trim()))return t;let r=e.trim();if(!r)return 0;try{let s=new V,{expr:n,pos:a}=Z(s,r,0);if(a<r.length){let i=r.slice(a).trim().split(/\s+/)[0];throw new C(`${r}: syntax error in expression (error token is "${i}")`)}return n.type==="ArithNumber"?n.value:t||0}catch(s){if(s instanceof C)throw s;let n=r.split(/\s+/).slice(1)[0]||r;throw new C(`${r}: syntax error in expression (error token is "${n}")`)}}async function ft(e,t){if(!t)return 0;let r=Number.parseInt(t,10);if(!Number.isNaN(r)&&/^-?\d+$/.test(t.trim()))return r;let s=t.trim();if(!s)return 0;let n=new V,{expr:a,pos:i}=Z(n,s,0);if(i<s.length){let l=s.slice(i).trim(),o=l.split(/\s+/)[0]||l;throw new C(`syntax error in expression (error token is "${o}")`,"","")}return await R(e,a)}async function ht(e,t,r=new Set,s=0){if(s>100)throw new C("maximum variable indirection depth exceeded");if(r.has(t))return 0;r.add(t);let n=await es(e,t);if(!n)return 0;let a=Number.parseInt(n,10);if(!Number.isNaN(a)&&/^-?\d+$/.test(n.trim()))return a;let i=n.trim();if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i))return await ht(e,i,r,s+1);let l=new V,{expr:o,pos:c}=Z(l,i,0);if(c<i.length){let u=i.slice(c).trim(),f=u.split(/\s+/)[0]||u;throw new C(`${i}: syntax error in expression (error token is "${f}")`)}return await R(e,o)}async function xe(e,t){if(t.startsWith("#")){let f=t.slice(1),h=f.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(h){let m=h[1],g=P(e,m);return String(g.length)}let d=e.state.env.get(f)||"";return String(d.length)}if(t.startsWith("!")){let f=t.slice(1),h=e.state.env.get(f)||"";return e.state.env.get(h)||""}let r=[":-",":=",":?",":+","-","=","?","+"],s=-1,n="";for(let f of r){let h=t.indexOf(f);h>0&&(s===-1||h<s)&&(s=h,n=f)}if(s===-1)return await v(e,t);let a=t.slice(0,s),i=t.slice(s+n.length),l=e.state.env.get(a),o=l===void 0,c=l==="",u=n.startsWith(":");switch(n){case":-":case"-":return o||u&&c?i:l||"";case":=":case"=":return o||u&&c?(e.state.env.set(a,i),i):l||"";case":+":case"+":return!(o||u&&c)?i:"";case":?":case"?":{if(o||u&&c)throw new Error(i||`${a}: parameter null or not set`);return l||""}default:return l||""}}async function R(e,t,r=!1){switch(t.type){case"ArithNumber":if(Number.isNaN(t.value))throw new C("value too great for base");return t.value;case"ArithVariable":return await ht(e,t.name);case"ArithSpecialVar":{let n=(await v(e,t.name)).trim();if(!n)return 0;let a=Number.parseInt(n,10);if(!Number.isNaN(a)&&/^-?\d+$/.test(n))return a;let i=new V,{expr:l}=Z(i,n,0);return await R(e,l)}case"ArithNested":return await R(e,t.expression);case"ArithCommandSubst":{if(e.execFn){let s=await e.execFn(t.command,{signal:e.state.signal});s.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||"")+s.stderr);let n=s.stdout.trim();return Number.parseInt(n,10)||0}return 0}case"ArithBracedExpansion":{let s=await xe(e,t.content);return Number.parseInt(s,10)||0}case"ArithDynamicBase":{let s=await xe(e,t.baseExpr),n=Number.parseInt(s,10);if(n<2||n>64)return 0;let a=`${n}#${t.value}`;return ge(a)}case"ArithDynamicNumber":{let n=await xe(e,t.prefix)+t.suffix;return ge(n)}case"ArithArrayElement":{let s=e.state.associativeArrays?.has(t.array),n=async a=>{let i=e.state.env.get(a);return i!==void 0?await ft(e,i):0};if(t.stringKey!==void 0)return await n(`${t.array}_${t.stringKey}`);if(s&&t.index?.type==="ArithVariable"&&!t.index.hasDollarPrefix)return await n(`${t.array}_${t.index.name}`);if(s&&t.index?.type==="ArithVariable"&&t.index.hasDollarPrefix){let a=await v(e,t.index.name);return await n(`${t.array}_${a}`)}if(t.index){let a=await R(e,t.index,r);if(a<0){let o=P(e,t.array),c=e.state.currentLine;if(o.length===0)return e.state.expansionStderr=(e.state.expansionStderr||"")+`bash: line ${c}: ${t.array}: bad array subscript
49
49
  `,0;let f=Math.max(...o.map(([h])=>typeof h=="number"?h:0))+1+a;if(f<0)return e.state.expansionStderr=(e.state.expansionStderr||"")+`bash: line ${c}: ${t.array}: bad array subscript
50
- `,0;a=f}let i=`${t.array}_${a}`,l=e.state.env.get(i);if(l!==void 0)return ft(e,l);if(a===0){let o=e.state.env.get(t.array);if(o!==void 0)return ft(e,o)}if(e.state.options.nounset&&!Array.from(e.state.env.keys()).some(c=>c===t.array||c.startsWith(`${t.array}_`)))throw new j(`${t.array}[${a}]`);return 0}return 0}case"ArithDoubleSubscript":throw new C("double subscript","","");case"ArithNumberSubscript":throw new C(`${t.number}${t.errorToken}: syntax error: invalid arithmetic operator (error token is "${t.errorToken}")`);case"ArithSyntaxError":throw new C(t.message,"","",!0);case"ArithSingleQuote":{if(r)throw new C(`syntax error: operand expected (error token is "'${t.content}'")`);return t.value}case"ArithBinary":{if(t.operator==="||")return await R(e,t.left,r)||await R(e,t.right,r)?1:0;if(t.operator==="&&")return await R(e,t.left,r)&&await R(e,t.right,r)?1:0;let s=await R(e,t.left,r),n=await R(e,t.right,r);return Jr(s,n,t.operator)}case"ArithUnary":{let s=await R(e,t.operand,r);if(t.operator==="++"||t.operator==="--"){if(t.operand.type==="ArithVariable"){let n=t.operand.name,a=Number.parseInt(await v(e,n),10)||0,i=t.operator==="++"?a+1:a-1;return e.state.env.set(n,String(i)),t.prefix?i:a}if(t.operand.type==="ArithArrayElement"){let n=t.operand.array,a=e.state.associativeArrays?.has(n),i;if(t.operand.stringKey!==void 0)i=`${n}_${t.operand.stringKey}`;else if(a&&t.operand.index?.type==="ArithVariable"&&!t.operand.index.hasDollarPrefix)i=`${n}_${t.operand.index.name}`;else if(a&&t.operand.index?.type==="ArithVariable"&&t.operand.index.hasDollarPrefix){let c=await v(e,t.operand.index.name);i=`${n}_${c}`}else if(t.operand.index){let c=await R(e,t.operand.index,r);i=`${n}_${c}`}else return s;let l=Number.parseInt(e.state.env.get(i)||"0",10)||0,o=t.operator==="++"?l+1:l-1;return e.state.env.set(i,String(o)),t.prefix?o:l}if(t.operand.type==="ArithConcat"){let n="";for(let a of t.operand.parts)n+=await de(e,a,r);if(n&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)){let a=Number.parseInt(e.state.env.get(n)||"0",10)||0,i=t.operator==="++"?a+1:a-1;return e.state.env.set(n,String(i)),t.prefix?i:a}}if(t.operand.type==="ArithDynamicElement"){let n="";if(t.operand.nameExpr.type==="ArithConcat")for(let a of t.operand.nameExpr.parts)n+=await de(e,a,r);else t.operand.nameExpr.type==="ArithVariable"&&(n=t.operand.nameExpr.hasDollarPrefix?await v(e,t.operand.nameExpr.name):t.operand.nameExpr.name);if(n&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)){let a=await R(e,t.operand.subscript,r),i=`${n}_${a}`,l=Number.parseInt(e.state.env.get(i)||"0",10)||0,o=t.operator==="++"?l+1:l-1;return e.state.env.set(i,String(o)),t.prefix?o:l}}return s}return Yr(s,t.operator)}case"ArithTernary":return await R(e,t.condition,r)?await R(e,t.consequent,r):await R(e,t.alternate,r);case"ArithAssignment":{let s=t.variable,n=s;if(t.stringKey!==void 0)n=`${s}_${t.stringKey}`;else if(t.subscript){let o=e.state.associativeArrays?.has(s);if(o&&t.subscript.type==="ArithVariable"&&!t.subscript.hasDollarPrefix)n=`${s}_${t.subscript.name}`;else if(o&&t.subscript.type==="ArithVariable"&&t.subscript.hasDollarPrefix){let c=await v(e,t.subscript.name);n=`${s}_${c||"\\"}`}else if(o){let c=await R(e,t.subscript,r);n=`${s}_${c}`}else{let c=await R(e,t.subscript,r);if(c<0){let u=P(e,s);u.length>0&&(c=Math.max(...u.map(([h])=>typeof h=="number"?h:0))+1+c)}n=`${s}_${c}`}}let a=Number.parseInt(e.state.env.get(n)||"0",10)||0,i=await R(e,t.value,r),l=pn(a,i,t.operator);return e.state.env.set(n,String(l)),l}case"ArithGroup":return await R(e,t.expression,r);case"ArithConcat":{let s="";for(let n of t.parts)s+=await de(e,n,r);return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)?await ht(e,s):Number.parseInt(s,10)||0}case"ArithDynamicAssignment":{let s="";if(t.target.type==="ArithConcat")for(let o of t.target.parts)s+=await de(e,o,r);else t.target.type==="ArithVariable"&&(s=t.target.hasDollarPrefix?await v(e,t.target.name):t.target.name);if(!s||!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s))return 0;let n=s;if(t.subscript){let o=await R(e,t.subscript,r);n=`${s}_${o}`}let a=Number.parseInt(e.state.env.get(n)||"0",10)||0,i=await R(e,t.value,r),l=pn(a,i,t.operator);return e.state.env.set(n,String(l)),l}case"ArithDynamicElement":{let s="";if(t.nameExpr.type==="ArithConcat")for(let l of t.nameExpr.parts)s+=await de(e,l,r);else t.nameExpr.type==="ArithVariable"&&(s=t.nameExpr.hasDollarPrefix?await v(e,t.nameExpr.name):t.nameExpr.name);if(!s||!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s))return 0;let n=await R(e,t.subscript,r),a=`${s}_${n}`,i=e.state.env.get(a);return i!==void 0?ts(i):0}default:return 0}}async function de(e,t,r=!1){switch(t.type){case"ArithNumber":return String(t.value);case"ArithSingleQuote":return String(await R(e,t,r));case"ArithVariable":return t.hasDollarPrefix?await v(e,t.name):t.name;case"ArithSpecialVar":return await v(e,t.name);case"ArithBracedExpansion":return await xe(e,t.content);case"ArithCommandSubst":return e.execFn?(await e.execFn(t.command)).stdout.trim():"0";case"ArithConcat":{let s="";for(let n of t.parts)s+=await de(e,n,r);return s}default:return String(await R(e,t,r))}}function pt(e){for(let t=0;t<e.length;t++){if(e[t]==="\\"){t++;continue}if(e[t]==="$"){let r=e[t+1];if(r==="{"||r&&/[a-zA-Z_]/.test(r))return!0}}return!1}function ns(e){if(!e.operation)return!1;let t=e.operation,r;if((t.type==="DefaultValue"||t.type==="AssignDefault"||t.type==="UseAlternative"||t.type==="ErrorIfUnset")&&(r=t.word?.parts),!r)return!1;for(let s of r)if(s.type==="DoubleQuoted"||s.type==="SingleQuoted")return!0;return!1}function dn(e){if(!e.operation)return!1;let t=e.operation,r;if((t.type==="DefaultValue"||t.type==="AssignDefault"||t.type==="UseAlternative"||t.type==="ErrorIfUnset")&&(r=t.word?.parts),!r||r.length===0)return!1;for(let s of r)if(s.type!=="DoubleQuoted"&&s.type!=="SingleQuoted")return!1;return!0}function Ee(e){let t=!1,r=!1,s=!1,n=!1,a=!1,i=!1,l=!1;for(let o of e){if((o.type==="SingleQuoted"||o.type==="DoubleQuoted")&&(t=!0,o.type==="DoubleQuoted"))for(let c of o.parts)c.type==="ParameterExpansion"&&(c.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/)&&(!c.operation||c.operation.type==="PatternRemoval"||c.operation.type==="PatternReplacement")&&(n=!0),(c.operation?.type==="VarNamePrefix"||c.operation?.type==="ArrayKeys")&&(i=!0),c.operation?.type==="Indirection"&&(l=!0));o.type==="CommandSubstitution"&&(r=!0),o.type==="ParameterExpansion"&&(a=!0,(o.parameter==="@"||o.parameter==="*")&&(s=!0),ns(o)&&(t=!0),(o.operation?.type==="VarNamePrefix"||o.operation?.type==="ArrayKeys")&&(i=!0),o.operation?.type==="Indirection"&&(l=!0)),o.type==="Glob"&&pt(o.pattern)&&(a=!0)}return{hasQuoted:t,hasCommandSub:r,hasArrayVar:s,hasArrayAtExpansion:n,hasParamExpansion:a,hasVarNamePrefixExpansion:i,hasIndirection:l}}var mn="5.1.0(1)-release",vi="Linux version 5.15.0-generic (just-bash) #1 SMP PREEMPT";function Di(e){let{pid:t,ppid:r,uid:s,gid:n}=e;return`Name: bash
50
+ `,0;a=f}let i=`${t.array}_${a}`,l=e.state.env.get(i);if(l!==void 0)return ft(e,l);if(a===0){let o=e.state.env.get(t.array);if(o!==void 0)return ft(e,o)}if(e.state.options.nounset&&!Array.from(e.state.env.keys()).some(c=>c===t.array||c.startsWith(`${t.array}_`)))throw new j(`${t.array}[${a}]`);return 0}return 0}case"ArithDoubleSubscript":throw new C("double subscript","","");case"ArithNumberSubscript":throw new C(`${t.number}${t.errorToken}: syntax error: invalid arithmetic operator (error token is "${t.errorToken}")`);case"ArithSyntaxError":throw new C(t.message,"","",!0);case"ArithSingleQuote":{if(r)throw new C(`syntax error: operand expected (error token is "'${t.content}'")`);return t.value}case"ArithBinary":{if(t.operator==="||")return await R(e,t.left,r)||await R(e,t.right,r)?1:0;if(t.operator==="&&")return await R(e,t.left,r)&&await R(e,t.right,r)?1:0;let s=await R(e,t.left,r),n=await R(e,t.right,r);return Jr(s,n,t.operator)}case"ArithUnary":{let s=await R(e,t.operand,r);if(t.operator==="++"||t.operator==="--"){if(t.operand.type==="ArithVariable"){let n=t.operand.name,a=Number.parseInt(await v(e,n),10)||0,i=t.operator==="++"?a+1:a-1;return e.state.env.set(n,String(i)),t.prefix?i:a}if(t.operand.type==="ArithArrayElement"){let n=t.operand.array,a=e.state.associativeArrays?.has(n),i;if(t.operand.stringKey!==void 0)i=`${n}_${t.operand.stringKey}`;else if(a&&t.operand.index?.type==="ArithVariable"&&!t.operand.index.hasDollarPrefix)i=`${n}_${t.operand.index.name}`;else if(a&&t.operand.index?.type==="ArithVariable"&&t.operand.index.hasDollarPrefix){let c=await v(e,t.operand.index.name);i=`${n}_${c}`}else if(t.operand.index){let c=await R(e,t.operand.index,r);i=`${n}_${c}`}else return s;let l=Number.parseInt(e.state.env.get(i)||"0",10)||0,o=t.operator==="++"?l+1:l-1;return e.state.env.set(i,String(o)),t.prefix?o:l}if(t.operand.type==="ArithConcat"){let n="";for(let a of t.operand.parts)n+=await de(e,a,r);if(n&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)){let a=Number.parseInt(e.state.env.get(n)||"0",10)||0,i=t.operator==="++"?a+1:a-1;return e.state.env.set(n,String(i)),t.prefix?i:a}}if(t.operand.type==="ArithDynamicElement"){let n="";if(t.operand.nameExpr.type==="ArithConcat")for(let a of t.operand.nameExpr.parts)n+=await de(e,a,r);else t.operand.nameExpr.type==="ArithVariable"&&(n=t.operand.nameExpr.hasDollarPrefix?await v(e,t.operand.nameExpr.name):t.operand.nameExpr.name);if(n&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)){let a=await R(e,t.operand.subscript,r),i=`${n}_${a}`,l=Number.parseInt(e.state.env.get(i)||"0",10)||0,o=t.operator==="++"?l+1:l-1;return e.state.env.set(i,String(o)),t.prefix?o:l}}return s}return Yr(s,t.operator)}case"ArithTernary":return await R(e,t.condition,r)?await R(e,t.consequent,r):await R(e,t.alternate,r);case"ArithAssignment":{let s=t.variable,n=s;if(t.stringKey!==void 0)n=`${s}_${t.stringKey}`;else if(t.subscript){let o=e.state.associativeArrays?.has(s);if(o&&t.subscript.type==="ArithVariable"&&!t.subscript.hasDollarPrefix)n=`${s}_${t.subscript.name}`;else if(o&&t.subscript.type==="ArithVariable"&&t.subscript.hasDollarPrefix){let c=await v(e,t.subscript.name);n=`${s}_${c||"\\"}`}else if(o){let c=await R(e,t.subscript,r);n=`${s}_${c}`}else{let c=await R(e,t.subscript,r);if(c<0){let u=P(e,s);u.length>0&&(c=Math.max(...u.map(([h])=>typeof h=="number"?h:0))+1+c)}n=`${s}_${c}`}}let a=Number.parseInt(e.state.env.get(n)||"0",10)||0,i=await R(e,t.value,r),l=pn(a,i,t.operator);return e.state.env.set(n,String(l)),l}case"ArithGroup":return await R(e,t.expression,r);case"ArithConcat":{let s="";for(let n of t.parts)s+=await de(e,n,r);return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)?await ht(e,s):Number.parseInt(s,10)||0}case"ArithDynamicAssignment":{let s="";if(t.target.type==="ArithConcat")for(let o of t.target.parts)s+=await de(e,o,r);else t.target.type==="ArithVariable"&&(s=t.target.hasDollarPrefix?await v(e,t.target.name):t.target.name);if(!s||!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s))return 0;let n=s;if(t.subscript){let o=await R(e,t.subscript,r);n=`${s}_${o}`}let a=Number.parseInt(e.state.env.get(n)||"0",10)||0,i=await R(e,t.value,r),l=pn(a,i,t.operator);return e.state.env.set(n,String(l)),l}case"ArithDynamicElement":{let s="";if(t.nameExpr.type==="ArithConcat")for(let l of t.nameExpr.parts)s+=await de(e,l,r);else t.nameExpr.type==="ArithVariable"&&(s=t.nameExpr.hasDollarPrefix?await v(e,t.nameExpr.name):t.nameExpr.name);if(!s||!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s))return 0;let n=await R(e,t.subscript,r),a=`${s}_${n}`,i=e.state.env.get(a);return i!==void 0?ts(i):0}default:return 0}}async function de(e,t,r=!1){switch(t.type){case"ArithNumber":return String(t.value);case"ArithSingleQuote":return String(await R(e,t,r));case"ArithVariable":return t.hasDollarPrefix?await v(e,t.name):t.name;case"ArithSpecialVar":return await v(e,t.name);case"ArithBracedExpansion":return await xe(e,t.content);case"ArithCommandSubst":return e.execFn?(await e.execFn(t.command,{signal:e.state.signal})).stdout.trim():"0";case"ArithConcat":{let s="";for(let n of t.parts)s+=await de(e,n,r);return s}default:return String(await R(e,t,r))}}function pt(e){for(let t=0;t<e.length;t++){if(e[t]==="\\"){t++;continue}if(e[t]==="$"){let r=e[t+1];if(r==="{"||r&&/[a-zA-Z_]/.test(r))return!0}}return!1}function ns(e){if(!e.operation)return!1;let t=e.operation,r;if((t.type==="DefaultValue"||t.type==="AssignDefault"||t.type==="UseAlternative"||t.type==="ErrorIfUnset")&&(r=t.word?.parts),!r)return!1;for(let s of r)if(s.type==="DoubleQuoted"||s.type==="SingleQuoted")return!0;return!1}function dn(e){if(!e.operation)return!1;let t=e.operation,r;if((t.type==="DefaultValue"||t.type==="AssignDefault"||t.type==="UseAlternative"||t.type==="ErrorIfUnset")&&(r=t.word?.parts),!r||r.length===0)return!1;for(let s of r)if(s.type!=="DoubleQuoted"&&s.type!=="SingleQuoted")return!1;return!0}function Ee(e){let t=!1,r=!1,s=!1,n=!1,a=!1,i=!1,l=!1;for(let o of e){if((o.type==="SingleQuoted"||o.type==="DoubleQuoted")&&(t=!0,o.type==="DoubleQuoted"))for(let c of o.parts)c.type==="ParameterExpansion"&&(c.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/)&&(!c.operation||c.operation.type==="PatternRemoval"||c.operation.type==="PatternReplacement")&&(n=!0),(c.operation?.type==="VarNamePrefix"||c.operation?.type==="ArrayKeys")&&(i=!0),c.operation?.type==="Indirection"&&(l=!0));o.type==="CommandSubstitution"&&(r=!0),o.type==="ParameterExpansion"&&(a=!0,(o.parameter==="@"||o.parameter==="*")&&(s=!0),ns(o)&&(t=!0),(o.operation?.type==="VarNamePrefix"||o.operation?.type==="ArrayKeys")&&(i=!0),o.operation?.type==="Indirection"&&(l=!0)),o.type==="Glob"&&pt(o.pattern)&&(a=!0)}return{hasQuoted:t,hasCommandSub:r,hasArrayVar:s,hasArrayAtExpansion:n,hasParamExpansion:a,hasVarNamePrefixExpansion:i,hasIndirection:l}}var mn="5.1.0(1)-release",vi="Linux version 5.15.0-generic (just-bash) #1 SMP PREEMPT";function Di(e){let{pid:t,ppid:r,uid:s,gid:n}=e;return`Name: bash
51
51
  State: R (running)
52
52
  Pid: ${t}
53
53
  PPid: ${r}
@@ -59,7 +59,7 @@ Gid: ${n} ${n} ${n} ${n}
59
59
  `?r.push("\\n"):r.push(s);return t&&r.push("\\-"),r.join("")}function N(e){let t=e.get("IFS");return t===void 0?" ":t[0]||""}var ss=`
60
60
  `;function is(e){return ss.includes(e)}function gt(e){let t=new Set,r=new Set;for(let s of e)is(s)?t.add(s):r.add(s);return{whitespace:t,nonWhitespace:r}}function Oi(e,t,r,s){if(t==="")return e===""?{words:[],wordStarts:[]}:{words:[e],wordStarts:[0]};let{whitespace:n,nonWhitespace:a}=gt(t),i=[],l=[],o=0;for(;o<e.length&&n.has(e[o]);)o++;if(o>=e.length)return{words:[],wordStarts:[]};if(a.has(e[o]))for(i.push(""),l.push(o),o++;o<e.length&&n.has(e[o]);)o++;for(;o<e.length&&!(r!==void 0&&i.length>=r);){let c=o;for(l.push(c);o<e.length;){let u=e[o];if(!s&&u==="\\"){o++,o<e.length&&o++;continue}if(n.has(u)||a.has(u))break;o++}if(i.push(e.substring(c,o)),o>=e.length)break;for(;o<e.length&&n.has(e[o]);)o++;if(o<e.length&&a.has(e[o])){for(o++;o<e.length&&n.has(e[o]);)o++;for(;o<e.length&&a.has(e[o])&&!(r!==void 0&&i.length>=r);)for(i.push(""),l.push(o),o++;o<e.length&&n.has(e[o]);)o++}}return{words:i,wordStarts:l}}function Ce(e,t){if(t==="")return{words:e?[e]:[],hadLeadingDelimiter:!1,hadTrailingDelimiter:!1};if(e==="")return{words:[],hadLeadingDelimiter:!1,hadTrailingDelimiter:!1};let{whitespace:r,nonWhitespace:s}=gt(t),n=[],a=0,i=!1,l=!1,o=a;for(;a<e.length&&r.has(e[a]);)a++;if(a>o&&(i=!0),a>=e.length)return{words:[],hadLeadingDelimiter:!0,hadTrailingDelimiter:!0};if(s.has(e[a]))for(n.push(""),a++;a<e.length&&r.has(e[a]);)a++;for(;a<e.length;){let c=a;for(;a<e.length;){let f=e[a];if(r.has(f)||s.has(f))break;a++}if(n.push(e.substring(c,a)),a>=e.length){l=!1;break}let u=a;for(;a<e.length&&r.has(e[a]);)a++;if(a<e.length&&s.has(e[a])){for(a++;a<e.length&&r.has(e[a]);)a++;for(;a<e.length&&s.has(e[a]);)for(n.push(""),a++;a<e.length&&r.has(e[a]);)a++}a>=e.length&&a>u&&(l=!0)}return{words:n,hadLeadingDelimiter:i,hadTrailingDelimiter:l}}function x(e,t){return Ce(e,t).words}function as(e,t){for(let r of e)if(t.has(r))return!0;return!1}function Li(e,t,r){if(t==="")return e;let{whitespace:s,nonWhitespace:n}=gt(t),a=e.length;for(;a>0&&s.has(e[a-1]);){if(!r&&a>=2){let l=0,o=a-2;for(;o>=0&&e[o]==="\\";)l++,o--;if(l%2===1)break}a--}let i=e.substring(0,a);if(i.length>=1&&n.has(i[i.length-1])){if(!r&&i.length>=2){let o=0,c=i.length-2;for(;c>=0&&i[c]==="\\";)o++,c--;if(o%2===1)return i}let l=i.substring(0,i.length-1);if(!as(l,n))return l}return i}function L(e,t){return e.state.namerefs?.has(t)??!1}function Ti(e,t){e.state.namerefs??=new Set,e.state.namerefs.add(t)}function Mi(e,t){e.state.namerefs?.delete(t),e.state.boundNamerefs?.delete(t),e.state.invalidNamerefs?.delete(t)}function Vi(e,t){e.state.invalidNamerefs??=new Set,e.state.invalidNamerefs.add(t)}function En(e,t){return e.state.invalidNamerefs?.has(t)??!1}function qi(e,t){e.state.boundNamerefs??=new Set,e.state.boundNamerefs.add(t)}function os(e,t){let r=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(r){let n=r[1],a=Array.from(e.state.env.keys()).some(l=>l.startsWith(`${n}_`)&&!l.includes("__")),i=e.state.associativeArrays?.has(n)??!1;return a||i}return Array.from(e.state.env.keys()).some(n=>n.startsWith(`${t}_`)&&!n.includes("__"))?!0:e.state.env.has(t)}function he(e,t,r=100){if(!L(e,t)||En(e,t))return t;let s=new Set,n=t;for(;r-- >0;){if(s.has(n))return;if(s.add(n),!L(e,n))return n;let a=e.state.env.get(n);if(a===void 0||a===""||!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(a))return n;n=a}}function Ae(e,t){if(L(e,t))return e.state.env.get(t)}function Bi(e,t,r,s=100){if(!L(e,t)||En(e,t))return t;let n=new Set,a=t;for(;s-- >0;){if(n.has(a))return;if(n.add(a),!L(e,a))return a;let i=e.state.env.get(a);if(i===void 0||i==="")return r!==void 0?/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)&&os(e,r)?a:null:a;if(!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(i))return a;a=i}}function ls(e,t){let r=t.replace(/\$\{([a-zA-Z_][a-zA-Z0-9_]*)\}/g,(s,n)=>e.state.env.get(n)??"");return r=r.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)/g,(s,n)=>e.state.env.get(n)??""),r}function P(e,t){return t==="FUNCNAME"?(e.state.funcNameStack??[]).map((a,i)=>[i,a]):t==="BASH_LINENO"?(e.state.callLineStack??[]).map((a,i)=>[i,String(a)]):t==="BASH_SOURCE"?(e.state.sourceStack??[]).map((a,i)=>[i,a]):e.state.associativeArrays?.has(t)?mt(e,t).map(a=>[a,e.state.env.get(`${t}_${a}`)??""]):dt(e,t).map(n=>[n,e.state.env.get(`${t}_${n}`)??""])}function Se(e,t){return t==="FUNCNAME"?(e.state.funcNameStack?.length??0)>0:t==="BASH_LINENO"?(e.state.callLineStack?.length??0)>0:t==="BASH_SOURCE"?(e.state.sourceStack?.length??0)>0:e.state.associativeArrays?.has(t)?mt(e,t).length>0:dt(e,t).length>0}async function v(e,t,r=!0,s=!1){switch(t){case"?":return String(e.state.lastExitCode);case"$":return String(e.state.virtualPid);case"#":return e.state.env.get("#")||"0";case"@":return e.state.env.get("@")||"";case"_":return e.state.lastArg;case"-":{let i="";return i+="h",e.state.options.errexit&&(i+="e"),e.state.options.noglob&&(i+="f"),e.state.options.nounset&&(i+="u"),e.state.options.verbose&&(i+="v"),e.state.options.xtrace&&(i+="x"),i+="B",e.state.options.noclobber&&(i+="C"),i+="s",i}case"*":{let i=Number.parseInt(e.state.env.get("#")||"0",10);if(i===0)return"";let l=[];for(let o=1;o<=i;o++)l.push(e.state.env.get(String(o))||"");return l.join(N(e.state.env))}case"0":return e.state.env.get("0")||"bash";case"PWD":return e.state.env.get("PWD")??"";case"OLDPWD":return e.state.env.get("OLDPWD")??"";case"PPID":return String(e.state.virtualPpid);case"UID":return String(e.state.virtualUid);case"EUID":return String(e.state.virtualUid);case"RANDOM":return String(Math.floor(Math.random()*32768));case"SECONDS":return String(Math.floor((Date.now()-e.state.startTime)/1e3));case"BASH_VERSION":return mn;case"!":return String(e.state.lastBackgroundPid);case"BASHPID":return String(e.state.bashPid);case"LINENO":return String(e.state.currentLine);case"FUNCNAME":{let i=e.state.funcNameStack?.[0];if(i!==void 0)return i;if(r&&e.state.options.nounset)throw new j("FUNCNAME");return""}case"BASH_LINENO":{let i=e.state.callLineStack?.[0];if(i!==void 0)return String(i);if(r&&e.state.options.nounset)throw new j("BASH_LINENO");return""}case"BASH_SOURCE":{let i=e.state.sourceStack?.[0];if(i!==void 0)return i;if(r&&e.state.options.nounset)throw new j("BASH_SOURCE");return""}}if(/^[a-zA-Z_][a-zA-Z0-9_]*\[\]$/.test(t))throw new re(`\${${t}}`);let n=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(n){let i=n[1],l=n[2];if(L(e,i)){let f=he(e,i);if(f&&f!==i){if(f.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/))return"";i=f}}if(l==="@"||l==="*"){let f=P(e,i);if(f.length>0)return f.map(([,d])=>d).join(" ");let h=e.state.env.get(i);return h!==void 0?h:""}if(i==="FUNCNAME"){let f=Number.parseInt(l,10);return!Number.isNaN(f)&&f>=0?e.state.funcNameStack?.[f]??"":""}if(i==="BASH_LINENO"){let f=Number.parseInt(l,10);if(!Number.isNaN(f)&&f>=0){let h=e.state.callLineStack?.[f];return h!==void 0?String(h):""}return""}if(i==="BASH_SOURCE"){let f=Number.parseInt(l,10);return!Number.isNaN(f)&&f>=0?e.state.sourceStack?.[f]??"":""}if(e.state.associativeArrays?.has(i)){let f=_e(l);f=ls(e,f);let h=e.state.env.get(`${i}_${f}`);if(h===void 0&&r&&e.state.options.nounset)throw new j(`${i}[${l}]`);return h||""}let c;if(/^-?\d+$/.test(l))c=Number.parseInt(l,10);else try{let f=new V,h=M(f,l);c=await R(e,h.expression)}catch{let f=e.state.env.get(l);c=f?Number.parseInt(f,10):0,Number.isNaN(c)&&(c=0)}if(c<0){let f=P(e,i),h=e.state.currentLine;if(f.length===0)return e.state.expansionStderr=(e.state.expansionStderr||"")+`bash: line ${h}: ${i}: bad array subscript
61
61
  `,"";let m=Math.max(...f.map(([E])=>typeof E=="number"?E:0))+1+c;return m<0?(e.state.expansionStderr=(e.state.expansionStderr||"")+`bash: line ${h}: ${i}: bad array subscript
62
- `,""):e.state.env.get(`${i}_${m}`)||""}let u=e.state.env.get(`${i}_${c}`);if(u!==void 0)return u;if(c===0){let f=e.state.env.get(i);if(f!==void 0)return f}if(r&&e.state.options.nounset)throw new j(`${i}[${c}]`);return""}if(/^[1-9][0-9]*$/.test(t)){let i=e.state.env.get(t);if(i===void 0&&r&&e.state.options.nounset)throw new j(t);return i||""}if(L(e,t)){let i=he(e,t);if(i===void 0)return"";if(i!==t)return await v(e,i,r,s);let l=e.state.env.get(t);if((l===void 0||l==="")&&r&&e.state.options.nounset)throw new j(t);return l||""}let a=e.state.env.get(t);if(a!==void 0)return e.state.tempEnvBindings?.some(i=>i.has(t))&&(e.state.accessedTempEnvVars=e.state.accessedTempEnvVars||new Set,e.state.accessedTempEnvVars.add(t)),a;if(Se(e,t)){let i=e.state.env.get(`${t}_0`);return i!==void 0?i:""}if(r&&e.state.options.nounset)throw new j(t);return""}async function te(e,t){if(new Set(["?","$","#","_","-","0","PPID","UID","EUID","RANDOM","SECONDS","BASH_VERSION","!","BASHPID","LINENO"]).has(t))return!0;if(t==="@"||t==="*")return Number.parseInt(e.state.env.get("#")||"0",10)>0;if(t==="PWD"||t==="OLDPWD")return e.state.env.has(t);let s=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(s){let n=s[1],a=s[2];if(L(e,n)){let o=he(e,n);if(o&&o!==n){if(o.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/))return!1;n=o}}if(a==="@"||a==="*")return P(e,n).length>0?!0:e.state.env.has(n);if(e.state.associativeArrays?.has(n)){let o=_e(a);return e.state.env.has(`${n}_${o}`)}let l;if(/^-?\d+$/.test(a))l=Number.parseInt(a,10);else try{let o=new V,c=M(o,a);l=await R(e,c.expression)}catch{let o=e.state.env.get(a);l=o?Number.parseInt(o,10):0,Number.isNaN(l)&&(l=0)}if(l<0){let o=P(e,n);if(o.length===0)return!1;let u=Math.max(...o.map(([f])=>typeof f=="number"?f:0))+1+l;return u<0?!1:e.state.env.has(`${n}_${u}`)}return e.state.env.has(`${n}_${l}`)}if(L(e,t)){let n=he(e,t);return n===void 0||n===t?e.state.env.has(t):te(e,n)}return!!(e.state.env.has(t)||Se(e,t))}async function An(e,t){let r="",s=0;for(;s<t.length;){if(t[s]==="$"){if(t[s+1]==="{"){let n=1,a=s+2;for(;a<t.length&&n>0;)t[a]==="{"?n++:t[a]==="}"&&n--,a++;r+=t.slice(s,a),s=a;continue}if(t[s+1]==="("){let n=1,a=s+2;for(;a<t.length&&n>0;)t[a]==="("?n++:t[a]===")"&&n--,a++;r+=t.slice(s,a),s=a;continue}if(/[a-zA-Z_]/.test(t[s+1]||"")){let n=s+1;for(;n<t.length&&/[a-zA-Z0-9_]/.test(t[n]);)n++;let a=t.slice(s+1,n),i=await v(e,a);r+=i,s=n;continue}if(/[0-9]/.test(t[s+1]||"")){let n=s+1;for(;n<t.length&&/[0-9]/.test(t[n]);)n++;let a=t.slice(s+1,n),i=await v(e,a);r+=i,s=n;continue}if(/[*@#?\-!$]/.test(t[s+1]||"")){let n=t[s+1],a=await v(e,n);r+=a,s+=2;continue}}if(t[s]==='"'){for(r+='"',s++;s<t.length&&t[s]!=='"';)if(t[s]==="$"&&/[a-zA-Z_]/.test(t[s+1]||"")){let n=s+1;for(;n<t.length&&/[a-zA-Z0-9_]/.test(t[n]);)n++;let a=t.slice(s+1,n),i=await v(e,a);r+=i,s=n}else t[s]==="\\"?(r+=t[s],s++,s<t.length&&(r+=t[s],s++)):(r+=t[s],s++);s<t.length&&(r+='"',s++);continue}r+=t[s],s++}return r}async function yt(e,t){let r=t,s=t.startsWith('"')&&t.endsWith('"'),n=t.startsWith("'")&&t.endsWith("'");if((s||n)&&(r=t.slice(1,-1)),n)return r;let a="",i=0;for(;i<r.length;)if(r[i]==="$")if(r[i+1]==="("){let l=1,o=i+2;for(;o<r.length&&l>0;)r[o]==="("&&r[o-1]==="$"||r[o]==="("?l++:r[o]===")"&&l--,o++;let c=r.slice(i+2,o-1);if(e.execFn){let u=await e.execFn(c);a+=u.stdout.replace(/\n+$/,""),u.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||"")+u.stderr)}i=o}else if(r[i+1]==="{"){let l=1,o=i+2;for(;o<r.length&&l>0;)r[o]==="{"?l++:r[o]==="}"&&l--,o++;let c=r.slice(i+2,o-1),u=await v(e,c);a+=u,i=o}else if(/[a-zA-Z_]/.test(r[i+1]||"")){let l=i+1;for(;l<r.length&&/[a-zA-Z0-9_]/.test(r[l]);)l++;let o=r.slice(i+1,l),c=await v(e,o);a+=c,i=l}else a+=r[i],i++;else if(r[i]==="`"){let l=i+1;for(;l<r.length&&r[l]!=="`";)l++;let o=r.slice(i+1,l);if(e.execFn){let c=await e.execFn(o);a+=c.stdout.replace(/\n+$/,""),c.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||"")+c.stderr)}i=l+1}else a+=r[i],i++;return a}var Oe=1e4;function us(e,t,r,s,n){let a=r??1;a===0&&(a=1);let i=Math.abs(a),l=[],o=0;s?.match(/^-?0\d/)&&(o=Math.max(o,s.replace(/^-/,"").length)),n?.match(/^-?0\d/)&&(o=Math.max(o,n.replace(/^-/,"").length));let c=u=>{if(o>0){let f=u<0,h=String(Math.abs(u)).padStart(o,"0");return f?`-${h}`:h}return String(u)};if(e<=t)for(let u=e,f=0;u<=t&&f<Oe;u+=i,f++)l.push(c(u));else for(let u=e,f=0;u>=t&&f<Oe;u-=i,f++)l.push(c(u));return l}function cs(e,t,r){let s=r??1;s===0&&(s=1);let n=e.charCodeAt(0),a=t.charCodeAt(0),i=Math.abs(s),l=e>="A"&&e<="Z",o=e>="a"&&e<="z",c=t>="A"&&t<="Z",u=t>="a"&&t<="z";if(l&&u||o&&c){let h=r!==void 0?`..${r}`:"";throw new Rt(`{${e}..${t}${h}}: invalid sequence`)}let f=[];if(n<=a)for(let h=n,d=0;h<=a&&d<Oe;h+=i,d++)f.push(String.fromCharCode(h));else for(let h=n,d=0;h>=a&&d<Oe;h-=i,d++)f.push(String.fromCharCode(h));return f}function Et(e,t,r,s,n){let a=r!==void 0?`..${r}`:"";return typeof e=="number"&&typeof t=="number"?{expanded:us(e,t,r,s,n),literal:`{${e}..${t}${a}}`}:typeof e=="string"&&typeof t=="string"?{expanded:cs(e,t,r),literal:`{${e}..${t}${a}}`}:{expanded:null,literal:`{${e}..${t}${a}}`}}function Sn(e){if(e.statements.length!==1)return null;let t=e.statements[0];if(t.operators.length!==0||t.pipelines.length!==1)return null;let r=t.pipelines[0];if(r.negated||r.commands.length!==1)return null;let s=r.commands[0];if(s.type!=="SimpleCommand")return null;let n=s;if(n.name!==null||n.args.length!==0||n.assignments.length!==0||n.redirections.length!==1)return null;let a=n.redirections[0];return a.operator!=="<"||a.target.type!=="Word"?null:{target:a.target}}function ne(e,t){return!!(/[*?[]/.test(e)||t&&/[@*+?!]\(/.test(e))}function At(e){let t="",r=0;for(;r<e.length;)e[r]==="\\"&&r+1<e.length?(t+=e[r+1],r+=2):(t+=e[r],r++);return t}function X(e){return e.replace(/([*?[\]\\()|])/g,"\\$1")}function St(e){return e.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&")}function I(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k(e,t,r=!1){let s="",n=0;for(;n<e.length;){let a=e[n];if(r&&(a==="@"||a==="*"||a==="+"||a==="?"||a==="!")&&n+1<e.length&&e[n+1]==="("){let i=fs(e,n+1);if(i!==-1){let l=e.slice(n+2,i),c=hs(l).map(f=>k(f,t,r)),u=c.length>0?c.join("|"):"(?:)";a==="@"?s+=`(?:${u})`:a==="*"?s+=`(?:${u})*`:a==="+"?s+=`(?:${u})+`:a==="?"?s+=`(?:${u})?`:a==="!"&&(s+=`(?!(?:${u})$).*`),n=i+1;continue}}if(a==="\\")if(n+1<e.length){let i=e[n+1];/[\\^$.|+(){}[\]*?]/.test(i)?s+=`\\${i}`:s+=i,n+=2}else s+="\\\\",n++;else if(a==="*")s+=t?".*":".*?",n++;else if(a==="?")s+=".",n++;else if(a==="["){let i=ps(e,n);if(i===-1)s+="\\[",n++;else{let l=e.slice(n+1,i);s+=ds(l),n=i+1}}else/[\^$.|+(){}]/.test(a)?(s+=`\\${a}`,n++):(s+=a,n++)}return s}function fs(e,t){let r=1,s=t+1;for(;s<e.length&&r>0;){let n=e[s];if(n==="\\"){s+=2;continue}if(n==="(")r++;else if(n===")"&&(r--,r===0))return s;s++}return-1}function hs(e){let t=[],r="",s=0,n=0;for(;n<e.length;){let a=e[n];if(a==="\\"){r+=a,n+1<e.length?(r+=e[n+1],n+=2):n++;continue}a==="("?(s++,r+=a):a===")"?(s--,r+=a):a==="|"&&s===0?(t.push(r),r=""):r+=a,n++}return t.push(r),t}function ps(e,t){let r=t+1;for(r<e.length&&e[r]==="^"&&r++,r<e.length&&e[r]==="]"&&r++;r<e.length;){if(e[r]==="\\"&&r+1<e.length){r+=2;continue}if(e[r]==="]")return r;if(e[r]==="'"){let s=e.indexOf("'",r+1);if(s!==-1){r=s+1;continue}}if(e[r]==="["&&r+1<e.length&&e[r+1]===":"){let s=e.indexOf(":]",r+2);if(s!==-1){r=s+2;continue}}r++}return-1}function ds(e){let t="[",r=0;for((e[0]==="^"||e[0]==="!")&&(t+="^",r++);r<e.length;){if(e[r]==="'"){let n=e.indexOf("'",r+1);if(n!==-1){let a=e.slice(r+1,n);for(let i of a)i==="\\"?t+="\\\\":i==="]"?t+="\\]":i==="^"&&t==="["?t+="\\^":t+=i;r=n+1;continue}}if(e[r]==="["&&r+1<e.length&&e[r+1]===":"){let n=e.indexOf(":]",r+2);if(n!==-1){let a=e.slice(r+2,n);t+=gs(a),r=n+2;continue}}let s=e[r];s==="\\"?r+1<e.length?(t+=`\\${e[r+1]}`,r+=2):(t+="\\\\",r++):s==="-"&&r>0&&r<e.length-1?(t+="-",r++):s==="^"&&r===0?(t+="^",r++):(s==="]"&&r===0?t+="\\]":t+=s,r++)}return t+="]",t}var ms=new Map([["alnum","a-zA-Z0-9"],["alpha","a-zA-Z"],["ascii","\\x00-\\x7F"],["blank"," \\t"],["cntrl","\\x00-\\x1F\\x7F"],["digit","0-9"],["graph","!-~"],["lower","a-z"],["print"," -~"],["punct","!-/:-@\\[-`{-~"],["space"," \\t\\n\\r\\f\\v"],["upper","A-Z"],["word","a-zA-Z0-9_"],["xdigit","0-9A-Fa-f"]]);function gs(e){return ms.get(e)??""}function se(e,t,r,s){if(r==="prefix")return O(`^${t}`,"s").replace(e,"");let n=O(`${t}$`,"s");if(s)return n.replace(e,"");for(let a=e.length;a>=0;a--){let i=e.slice(a);if(n.test(i))return e.slice(0,a)}return e}function me(e,t){let r=Array.from(e.state.env.keys()),s=new Set,n=e.state.associativeArrays??new Set,a=new Set;for(let l of r){let o=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_\d+$/);o&&a.add(o[1]);let c=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)__length$/);c&&a.add(c[1])}let i=l=>{for(let o of n){let c=`${o}_`;if(l.startsWith(c)&&l!==o)return!0}return!1};for(let l of r)if(l.startsWith(t))if(l.includes("__")){let o=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)__length$/);o?.[1].startsWith(t)&&s.add(o[1])}else if(/_\d+$/.test(l)){let o=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_\d+$/);o?.[1].startsWith(t)&&s.add(o[1])}else i(l)||s.add(l);return[...s].sort()}function ys(e,t){let r=(a,i=2)=>String(a).padStart(i,"0");if(e===""){let a=r(t.getHours()),i=r(t.getMinutes()),l=r(t.getSeconds());return`${a}:${i}:${l}`}let s="",n=0;for(;n<e.length;)if(e[n]==="%"){if(n+1>=e.length){s+="%",n++;continue}let a=e[n+1];switch(a){case"H":s+=r(t.getHours());break;case"M":s+=r(t.getMinutes());break;case"S":s+=r(t.getSeconds());break;case"d":s+=r(t.getDate());break;case"m":s+=r(t.getMonth()+1);break;case"Y":s+=t.getFullYear();break;case"y":s+=r(t.getFullYear()%100);break;case"I":{let i=t.getHours()%12;i===0&&(i=12),s+=r(i);break}case"p":s+=t.getHours()<12?"AM":"PM";break;case"P":s+=t.getHours()<12?"am":"pm";break;case"%":s+="%";break;case"a":{s+=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][t.getDay()];break}case"b":{s+=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][t.getMonth()];break}default:s+=`%${a}`}n+=2}else s+=e[n],n++;return s}function be(e,t){let r="",s=0,n=e.state.env.get("USER")||e.state.env.get("LOGNAME")||"user",a=e.state.env.get("HOSTNAME")||"localhost",i=a.split(".")[0],l=e.state.env.get("PWD")||"/",o=e.state.env.get("HOME")||"/",c=l.startsWith(o)?`~${l.slice(o.length)}`:l,u=l.split("/").pop()||l,f=new Date,h=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],d=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],m=e.state.env.get("__COMMAND_NUMBER")||"1";for(;s<t.length;){let g=t[s];if(g==="\\"){if(s+1>=t.length){r+="\\",s++;continue}let E=t[s+1];if(E>="0"&&E<="7"){let A="",S=s+1;for(;S<t.length&&S<s+4&&t[S]>="0"&&t[S]<="7";)A+=t[S],S++;let y=Number.parseInt(A,8)%256;r+=String.fromCharCode(y),s=S;continue}switch(E){case"\\":r+="\\",s+=2;break;case"a":r+="\x07",s+=2;break;case"e":r+="\x1B",s+=2;break;case"n":r+=`
62
+ `,""):e.state.env.get(`${i}_${m}`)||""}let u=e.state.env.get(`${i}_${c}`);if(u!==void 0)return u;if(c===0){let f=e.state.env.get(i);if(f!==void 0)return f}if(r&&e.state.options.nounset)throw new j(`${i}[${c}]`);return""}if(/^[1-9][0-9]*$/.test(t)){let i=e.state.env.get(t);if(i===void 0&&r&&e.state.options.nounset)throw new j(t);return i||""}if(L(e,t)){let i=he(e,t);if(i===void 0)return"";if(i!==t)return await v(e,i,r,s);let l=e.state.env.get(t);if((l===void 0||l==="")&&r&&e.state.options.nounset)throw new j(t);return l||""}let a=e.state.env.get(t);if(a!==void 0)return e.state.tempEnvBindings?.some(i=>i.has(t))&&(e.state.accessedTempEnvVars=e.state.accessedTempEnvVars||new Set,e.state.accessedTempEnvVars.add(t)),a;if(Se(e,t)){let i=e.state.env.get(`${t}_0`);return i!==void 0?i:""}if(r&&e.state.options.nounset)throw new j(t);return""}async function te(e,t){if(new Set(["?","$","#","_","-","0","PPID","UID","EUID","RANDOM","SECONDS","BASH_VERSION","!","BASHPID","LINENO"]).has(t))return!0;if(t==="@"||t==="*")return Number.parseInt(e.state.env.get("#")||"0",10)>0;if(t==="PWD"||t==="OLDPWD")return e.state.env.has(t);let s=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(s){let n=s[1],a=s[2];if(L(e,n)){let o=he(e,n);if(o&&o!==n){if(o.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/))return!1;n=o}}if(a==="@"||a==="*")return P(e,n).length>0?!0:e.state.env.has(n);if(e.state.associativeArrays?.has(n)){let o=_e(a);return e.state.env.has(`${n}_${o}`)}let l;if(/^-?\d+$/.test(a))l=Number.parseInt(a,10);else try{let o=new V,c=M(o,a);l=await R(e,c.expression)}catch{let o=e.state.env.get(a);l=o?Number.parseInt(o,10):0,Number.isNaN(l)&&(l=0)}if(l<0){let o=P(e,n);if(o.length===0)return!1;let u=Math.max(...o.map(([f])=>typeof f=="number"?f:0))+1+l;return u<0?!1:e.state.env.has(`${n}_${u}`)}return e.state.env.has(`${n}_${l}`)}if(L(e,t)){let n=he(e,t);return n===void 0||n===t?e.state.env.has(t):te(e,n)}return!!(e.state.env.has(t)||Se(e,t))}async function An(e,t){let r="",s=0;for(;s<t.length;){if(t[s]==="$"){if(t[s+1]==="{"){let n=1,a=s+2;for(;a<t.length&&n>0;)t[a]==="{"?n++:t[a]==="}"&&n--,a++;r+=t.slice(s,a),s=a;continue}if(t[s+1]==="("){let n=1,a=s+2;for(;a<t.length&&n>0;)t[a]==="("?n++:t[a]===")"&&n--,a++;r+=t.slice(s,a),s=a;continue}if(/[a-zA-Z_]/.test(t[s+1]||"")){let n=s+1;for(;n<t.length&&/[a-zA-Z0-9_]/.test(t[n]);)n++;let a=t.slice(s+1,n),i=await v(e,a);r+=i,s=n;continue}if(/[0-9]/.test(t[s+1]||"")){let n=s+1;for(;n<t.length&&/[0-9]/.test(t[n]);)n++;let a=t.slice(s+1,n),i=await v(e,a);r+=i,s=n;continue}if(/[*@#?\-!$]/.test(t[s+1]||"")){let n=t[s+1],a=await v(e,n);r+=a,s+=2;continue}}if(t[s]==='"'){for(r+='"',s++;s<t.length&&t[s]!=='"';)if(t[s]==="$"&&/[a-zA-Z_]/.test(t[s+1]||"")){let n=s+1;for(;n<t.length&&/[a-zA-Z0-9_]/.test(t[n]);)n++;let a=t.slice(s+1,n),i=await v(e,a);r+=i,s=n}else t[s]==="\\"?(r+=t[s],s++,s<t.length&&(r+=t[s],s++)):(r+=t[s],s++);s<t.length&&(r+='"',s++);continue}r+=t[s],s++}return r}async function yt(e,t){let r=t,s=t.startsWith('"')&&t.endsWith('"'),n=t.startsWith("'")&&t.endsWith("'");if((s||n)&&(r=t.slice(1,-1)),n)return r;let a="",i=0;for(;i<r.length;)if(r[i]==="$")if(r[i+1]==="("){let l=1,o=i+2;for(;o<r.length&&l>0;)r[o]==="("&&r[o-1]==="$"||r[o]==="("?l++:r[o]===")"&&l--,o++;let c=r.slice(i+2,o-1);if(e.execFn){let u=await e.execFn(c,{signal:e.state.signal});a+=u.stdout.replace(/\n+$/,""),u.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||"")+u.stderr)}i=o}else if(r[i+1]==="{"){let l=1,o=i+2;for(;o<r.length&&l>0;)r[o]==="{"?l++:r[o]==="}"&&l--,o++;let c=r.slice(i+2,o-1),u=await v(e,c);a+=u,i=o}else if(/[a-zA-Z_]/.test(r[i+1]||"")){let l=i+1;for(;l<r.length&&/[a-zA-Z0-9_]/.test(r[l]);)l++;let o=r.slice(i+1,l),c=await v(e,o);a+=c,i=l}else a+=r[i],i++;else if(r[i]==="`"){let l=i+1;for(;l<r.length&&r[l]!=="`";)l++;let o=r.slice(i+1,l);if(e.execFn){let c=await e.execFn(o,{signal:e.state.signal});a+=c.stdout.replace(/\n+$/,""),c.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||"")+c.stderr)}i=l+1}else a+=r[i],i++;return a}var Oe=1e4;function us(e,t,r,s,n){let a=r??1;a===0&&(a=1);let i=Math.abs(a),l=[],o=0;s?.match(/^-?0\d/)&&(o=Math.max(o,s.replace(/^-/,"").length)),n?.match(/^-?0\d/)&&(o=Math.max(o,n.replace(/^-/,"").length));let c=u=>{if(o>0){let f=u<0,h=String(Math.abs(u)).padStart(o,"0");return f?`-${h}`:h}return String(u)};if(e<=t)for(let u=e,f=0;u<=t&&f<Oe;u+=i,f++)l.push(c(u));else for(let u=e,f=0;u>=t&&f<Oe;u-=i,f++)l.push(c(u));return l}function cs(e,t,r){let s=r??1;s===0&&(s=1);let n=e.charCodeAt(0),a=t.charCodeAt(0),i=Math.abs(s),l=e>="A"&&e<="Z",o=e>="a"&&e<="z",c=t>="A"&&t<="Z",u=t>="a"&&t<="z";if(l&&u||o&&c){let h=r!==void 0?`..${r}`:"";throw new Rt(`{${e}..${t}${h}}: invalid sequence`)}let f=[];if(n<=a)for(let h=n,d=0;h<=a&&d<Oe;h+=i,d++)f.push(String.fromCharCode(h));else for(let h=n,d=0;h>=a&&d<Oe;h-=i,d++)f.push(String.fromCharCode(h));return f}function Et(e,t,r,s,n){let a=r!==void 0?`..${r}`:"";return typeof e=="number"&&typeof t=="number"?{expanded:us(e,t,r,s,n),literal:`{${e}..${t}${a}}`}:typeof e=="string"&&typeof t=="string"?{expanded:cs(e,t,r),literal:`{${e}..${t}${a}}`}:{expanded:null,literal:`{${e}..${t}${a}}`}}function Sn(e){if(e.statements.length!==1)return null;let t=e.statements[0];if(t.operators.length!==0||t.pipelines.length!==1)return null;let r=t.pipelines[0];if(r.negated||r.commands.length!==1)return null;let s=r.commands[0];if(s.type!=="SimpleCommand")return null;let n=s;if(n.name!==null||n.args.length!==0||n.assignments.length!==0||n.redirections.length!==1)return null;let a=n.redirections[0];return a.operator!=="<"||a.target.type!=="Word"?null:{target:a.target}}function ne(e,t){return!!(/[*?[]/.test(e)||t&&/[@*+?!]\(/.test(e))}function At(e){let t="",r=0;for(;r<e.length;)e[r]==="\\"&&r+1<e.length?(t+=e[r+1],r+=2):(t+=e[r],r++);return t}function X(e){return e.replace(/([*?[\]\\()|])/g,"\\$1")}function St(e){return e.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&")}function I(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k(e,t,r=!1){let s="",n=0;for(;n<e.length;){let a=e[n];if(r&&(a==="@"||a==="*"||a==="+"||a==="?"||a==="!")&&n+1<e.length&&e[n+1]==="("){let i=fs(e,n+1);if(i!==-1){let l=e.slice(n+2,i),c=hs(l).map(f=>k(f,t,r)),u=c.length>0?c.join("|"):"(?:)";a==="@"?s+=`(?:${u})`:a==="*"?s+=`(?:${u})*`:a==="+"?s+=`(?:${u})+`:a==="?"?s+=`(?:${u})?`:a==="!"&&(s+=`(?!(?:${u})$).*`),n=i+1;continue}}if(a==="\\")if(n+1<e.length){let i=e[n+1];/[\\^$.|+(){}[\]*?]/.test(i)?s+=`\\${i}`:s+=i,n+=2}else s+="\\\\",n++;else if(a==="*")s+=t?".*":".*?",n++;else if(a==="?")s+=".",n++;else if(a==="["){let i=ps(e,n);if(i===-1)s+="\\[",n++;else{let l=e.slice(n+1,i);s+=ds(l),n=i+1}}else/[\^$.|+(){}]/.test(a)?(s+=`\\${a}`,n++):(s+=a,n++)}return s}function fs(e,t){let r=1,s=t+1;for(;s<e.length&&r>0;){let n=e[s];if(n==="\\"){s+=2;continue}if(n==="(")r++;else if(n===")"&&(r--,r===0))return s;s++}return-1}function hs(e){let t=[],r="",s=0,n=0;for(;n<e.length;){let a=e[n];if(a==="\\"){r+=a,n+1<e.length?(r+=e[n+1],n+=2):n++;continue}a==="("?(s++,r+=a):a===")"?(s--,r+=a):a==="|"&&s===0?(t.push(r),r=""):r+=a,n++}return t.push(r),t}function ps(e,t){let r=t+1;for(r<e.length&&e[r]==="^"&&r++,r<e.length&&e[r]==="]"&&r++;r<e.length;){if(e[r]==="\\"&&r+1<e.length){r+=2;continue}if(e[r]==="]")return r;if(e[r]==="'"){let s=e.indexOf("'",r+1);if(s!==-1){r=s+1;continue}}if(e[r]==="["&&r+1<e.length&&e[r+1]===":"){let s=e.indexOf(":]",r+2);if(s!==-1){r=s+2;continue}}r++}return-1}function ds(e){let t="[",r=0;for((e[0]==="^"||e[0]==="!")&&(t+="^",r++);r<e.length;){if(e[r]==="'"){let n=e.indexOf("'",r+1);if(n!==-1){let a=e.slice(r+1,n);for(let i of a)i==="\\"?t+="\\\\":i==="]"?t+="\\]":i==="^"&&t==="["?t+="\\^":t+=i;r=n+1;continue}}if(e[r]==="["&&r+1<e.length&&e[r+1]===":"){let n=e.indexOf(":]",r+2);if(n!==-1){let a=e.slice(r+2,n);t+=gs(a),r=n+2;continue}}let s=e[r];s==="\\"?r+1<e.length?(t+=`\\${e[r+1]}`,r+=2):(t+="\\\\",r++):s==="-"&&r>0&&r<e.length-1?(t+="-",r++):s==="^"&&r===0?(t+="^",r++):(s==="]"&&r===0?t+="\\]":t+=s,r++)}return t+="]",t}var ms=new Map([["alnum","a-zA-Z0-9"],["alpha","a-zA-Z"],["ascii","\\x00-\\x7F"],["blank"," \\t"],["cntrl","\\x00-\\x1F\\x7F"],["digit","0-9"],["graph","!-~"],["lower","a-z"],["print"," -~"],["punct","!-/:-@\\[-`{-~"],["space"," \\t\\n\\r\\f\\v"],["upper","A-Z"],["word","a-zA-Z0-9_"],["xdigit","0-9A-Fa-f"]]);function gs(e){return ms.get(e)??""}function se(e,t,r,s){if(r==="prefix")return O(`^${t}`,"s").replace(e,"");let n=O(`${t}$`,"s");if(s)return n.replace(e,"");for(let a=e.length;a>=0;a--){let i=e.slice(a);if(n.test(i))return e.slice(0,a)}return e}function me(e,t){let r=Array.from(e.state.env.keys()),s=new Set,n=e.state.associativeArrays??new Set,a=new Set;for(let l of r){let o=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_\d+$/);o&&a.add(o[1]);let c=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)__length$/);c&&a.add(c[1])}let i=l=>{for(let o of n){let c=`${o}_`;if(l.startsWith(c)&&l!==o)return!0}return!1};for(let l of r)if(l.startsWith(t))if(l.includes("__")){let o=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)__length$/);o?.[1].startsWith(t)&&s.add(o[1])}else if(/_\d+$/.test(l)){let o=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_\d+$/);o?.[1].startsWith(t)&&s.add(o[1])}else i(l)||s.add(l);return[...s].sort()}function ys(e,t){let r=(a,i=2)=>String(a).padStart(i,"0");if(e===""){let a=r(t.getHours()),i=r(t.getMinutes()),l=r(t.getSeconds());return`${a}:${i}:${l}`}let s="",n=0;for(;n<e.length;)if(e[n]==="%"){if(n+1>=e.length){s+="%",n++;continue}let a=e[n+1];switch(a){case"H":s+=r(t.getHours());break;case"M":s+=r(t.getMinutes());break;case"S":s+=r(t.getSeconds());break;case"d":s+=r(t.getDate());break;case"m":s+=r(t.getMonth()+1);break;case"Y":s+=t.getFullYear();break;case"y":s+=r(t.getFullYear()%100);break;case"I":{let i=t.getHours()%12;i===0&&(i=12),s+=r(i);break}case"p":s+=t.getHours()<12?"AM":"PM";break;case"P":s+=t.getHours()<12?"am":"pm";break;case"%":s+="%";break;case"a":{s+=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][t.getDay()];break}case"b":{s+=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][t.getMonth()];break}default:s+=`%${a}`}n+=2}else s+=e[n],n++;return s}function be(e,t){let r="",s=0,n=e.state.env.get("USER")||e.state.env.get("LOGNAME")||"user",a=e.state.env.get("HOSTNAME")||"localhost",i=a.split(".")[0],l=e.state.env.get("PWD")||"/",o=e.state.env.get("HOME")||"/",c=l.startsWith(o)?`~${l.slice(o.length)}`:l,u=l.split("/").pop()||l,f=new Date,h=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],d=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],m=e.state.env.get("__COMMAND_NUMBER")||"1";for(;s<t.length;){let g=t[s];if(g==="\\"){if(s+1>=t.length){r+="\\",s++;continue}let E=t[s+1];if(E>="0"&&E<="7"){let A="",S=s+1;for(;S<t.length&&S<s+4&&t[S]>="0"&&t[S]<="7";)A+=t[S],S++;let y=Number.parseInt(A,8)%256;r+=String.fromCharCode(y),s=S;continue}switch(E){case"\\":r+="\\",s+=2;break;case"a":r+="\x07",s+=2;break;case"e":r+="\x1B",s+=2;break;case"n":r+=`
63
63
  `,s+=2;break;case"r":r+="\r",s+=2;break;case"$":r+="$",s+=2;break;case"[":case"]":s+=2;break;case"u":r+=n,s+=2;break;case"h":r+=i,s+=2;break;case"H":r+=a,s+=2;break;case"w":r+=c,s+=2;break;case"W":r+=u,s+=2;break;case"d":{let A=String(f.getDate()).padStart(2," ");r+=`${h[f.getDay()]} ${d[f.getMonth()]} ${A}`,s+=2;break}case"t":{let A=String(f.getHours()).padStart(2,"0"),S=String(f.getMinutes()).padStart(2,"0"),y=String(f.getSeconds()).padStart(2,"0");r+=`${A}:${S}:${y}`,s+=2;break}case"T":{let A=f.getHours()%12;A===0&&(A=12);let S=String(A).padStart(2,"0"),y=String(f.getMinutes()).padStart(2,"0"),b=String(f.getSeconds()).padStart(2,"0");r+=`${S}:${y}:${b}`,s+=2;break}case"@":{let A=f.getHours()%12;A===0&&(A=12);let S=String(A).padStart(2,"0"),y=String(f.getMinutes()).padStart(2,"0"),b=f.getHours()<12?"AM":"PM";r+=`${S}:${y} ${b}`,s+=2;break}case"A":{let A=String(f.getHours()).padStart(2,"0"),S=String(f.getMinutes()).padStart(2,"0");r+=`${A}:${S}`,s+=2;break}case"D":if(s+2<t.length&&t[s+2]==="{"){let A=t.indexOf("}",s+3);if(A!==-1){let S=t.slice(s+3,A);r+=ys(S,f),s=A+1}else r+="\\D",s+=2}else r+="\\D",s+=2;break;case"s":r+="bash",s+=2;break;case"v":r+="5.0",s+=2;break;case"V":r+="5.0.0",s+=2;break;case"j":r+="0",s+=2;break;case"l":r+="tty",s+=2;break;case"#":r+=m,s+=2;break;case"!":r+=m,s+=2;break;case"x":r+="\\x",s+=2;break;default:r+=`\\${E}`,s+=2}}else r+=g,s++}return r}function le(e){if(e==="")return"''";if(/[\n\r\t\x00-\x1f\x7f']/.test(e)){let r="$'";for(let s of e)switch(s){case"'":r+="\\'";break;case"\\":r+="\\\\";break;case`
64
64
  `:r+="\\n";break;case"\r":r+="\\r";break;case" ":r+="\\t";break;default:{let n=s.charCodeAt(0);n<32||n===127?r+=`\\${n.toString(8).padStart(3,"0")}`:r+=s}}return`${r}'`}return`'${e}'`}function fa(e,t){e.state.readonlyVars=e.state.readonlyVars||new Set,e.state.readonlyVars.add(t)}function bt(e,t){return e.state.readonlyVars?.has(t)??!1}function ha(e,t,r="bash"){if(bt(e,t)){let s=`${r}: ${t}: readonly variable
65
65
  `;throw new K(1,"",s)}return null}function pa(e,t){let r=e.state.exportedVars?.has(t)??!1;if(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(t),e.state.localScopes.length>0&&e.state.localScopes[e.state.localScopes.length-1].has(t)&&!r){for(e.state.localExportedVars||(e.state.localExportedVars=[]);e.state.localExportedVars.length<e.state.localScopes.length;)e.state.localExportedVars.push(new Set);e.state.localExportedVars[e.state.localExportedVars.length-1].add(t)}}function da(e,t){e.state.exportedVars?.delete(t)}function ue(e,t){if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t))return"";let r="",s=e.state.env.has(`${t}__length`)||Array.from(e.state.env.keys()).some(a=>a.startsWith(`${t}_`)&&/^[0-9]+$/.test(a.slice(t.length+1))),n=e.state.associativeArrays?.has(t)??!1;return s&&!n&&(r+="a"),n&&(r+="A"),e.state.integerVars?.has(t)&&(r+="i"),L(e,t)&&(r+="n"),bt(e,t)&&(r+="r"),e.state.exportedVars?.has(t)&&(r+="x"),r}async function bn(e,t,r,s){return e.coverage?.hit("bash:expansion:default_value"),(r.isUnset||t.checkEmpty&&r.isEmpty)&&t.word?s(e,t.word.parts,r.inDoubleQuotes):r.effectiveValue}async function wn(e,t,r,s,n){if(e.coverage?.hit("bash:expansion:assign_default"),(s.isUnset||r.checkEmpty&&s.isEmpty)&&r.word){let i=await n(e,r.word.parts,s.inDoubleQuotes),l=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(l){let[,o,c]=l,u;if(/^\d+$/.test(c))u=Number.parseInt(c,10);else{try{let h=new V,d=M(h,c);u=await R(e,d.expression)}catch{let h=e.state.env.get(c);u=h?Number.parseInt(h,10):0}Number.isNaN(u)&&(u=0)}e.state.env.set(`${o}_${u}`,i);let f=Number.parseInt(e.state.env.get(`${o}__length`)||"0",10);u>=f&&e.state.env.set(`${o}__length`,String(u+1))}else e.state.env.set(t,i);return i}return s.effectiveValue}async function Nn(e,t,r,s,n){if(e.coverage?.hit("bash:expansion:error_if_unset"),s.isUnset||r.checkEmpty&&s.isEmpty){let i=r.word?await n(e,r.word.parts,s.inDoubleQuotes):`${t}: parameter null or not set`;throw new K(1,"",`bash: ${i}
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
  import{a as A,b as I,c as b}from"./chunk-GTNBSMZR.js";var $={name:"xargs",summary:"build and execute command lines from standard input",usage:"xargs [OPTION]... [COMMAND [INITIAL-ARGS]]",options:["-I REPLACE replace occurrences of REPLACE with input","-d DELIM use DELIM as input delimiter (e.g., -d '\\n' for newline)","-n NUM use at most NUM arguments per command line","-P NUM run at most NUM processes at a time","-0, --null items are separated by null, not whitespace","-t, --verbose print commands before executing","-r, --no-run-if-empty do not run command if input is empty"," --help display this help and exit"]},N={name:"xargs",async execute(l,i){if(I(l))return A($);let m=null,g=null,c=null,o=null,h=!1,x=!1,y=!1,s=0;for(let e=0;e<l.length;e++){let t=l[e];if(t==="-I"&&e+1<l.length)m=l[++e],s=e+1;else if(t==="-d"&&e+1<l.length)g=l[++e].replace(/\\n/g,`
3
3
  `).replace(/\\t/g," ").replace(/\\r/g,"\r").replace(/\\0/g,"\0").replace(/\\\\/g,"\\"),s=e+1;else if(t==="-n"&&e+1<l.length)c=parseInt(l[++e],10),s=e+1;else if(t==="-P"&&e+1<l.length)o=parseInt(l[++e],10),s=e+1;else if(t==="-0"||t==="--null")h=!0,s=e+1;else if(t==="-t"||t==="--verbose")x=!0,s=e+1;else if(t==="-r"||t==="--no-run-if-empty")y=!0,s=e+1;else{if(t.startsWith("--"))return b("xargs",t);if(t.startsWith("-")&&t.length>1){for(let n of t.slice(1))if(!"0tr".includes(n))return b("xargs",`-${n}`);t.includes("0")&&(h=!0),t.includes("t")&&(x=!0),t.includes("r")&&(y=!0),s=e+1}else if(!t.startsWith("-")){s=e;break}}}let a=l.slice(s);a.length===0&&a.push("echo");let r;if(h?r=i.stdin.split("\0").filter(e=>e.length>0):g!==null?r=i.stdin.replace(/\n$/,"").split(g).filter(t=>t.length>0):r=i.stdin.split(/\s+/).map(e=>e.trim()).filter(e=>e.length>0),r.length===0)return y?{stdout:"",stderr:"",exitCode:0}:{stdout:"",stderr:"",exitCode:0};let d="",u="",f=0,v=e=>/[\s"'\\$`!*?[\]{}();&|<>#]/.test(e)?`"${e.replace(/([\\"`$])/g,"\\$1")}"`:e,C=async e=>{let t=e.map(v).join(" ");return x&&(u+=`${t}
4
- `),i.exec?i.exec(t,{cwd:i.cwd}):{stdout:`${t}
4
+ `),i.exec?i.exec(t,{cwd:i.cwd,signal:i.signal}):{stdout:`${t}
5
5
  `,stderr:"",exitCode:0}},w=async e=>{if(o!==null&&o>1)for(let t=0;t<e.length;t+=o){let n=e.slice(t,t+o),M=await Promise.all(n.map(C));for(let p of M)d+=p.stdout,u+=p.stderr,p.exitCode!==0&&(f=p.exitCode)}else for(let t of e){let n=await C(t);d+=n.stdout,u+=n.stderr,n.exitCode!==0&&(f=n.exitCode)}};if(m!==null){let e=r.map(t=>a.map(n=>n.replaceAll(m,t)));await w(e)}else if(c!==null){let e=[];for(let t=0;t<r.length;t+=c){let n=r.slice(t,t+c);e.push([...a,...n])}await w(e)}else{let e=[...a,...r],t=await C(e);d+=t.stdout,u+=t.stderr,f=t.exitCode}return{stdout:d,stderr:u,exitCode:f}}},P={name:"xargs",flags:[{flag:"-I",type:"value",valueHint:"string"},{flag:"-d",type:"value",valueHint:"delimiter"},{flag:"-n",type:"value",valueHint:"number"},{flag:"-0",type:"boolean"},{flag:"-t",type:"boolean"},{flag:"-r",type:"boolean"}],stdinType:"text"};export{N as a,P as b};
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ function n(e){return`'${e.replace(/'/g,"'\\''")}'`}function r(e){return e.map(n).join(" ")}export{r as a};
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+ import{a as u}from"./chunk-4OALHZXB.js";import{a as c}from"./chunk-4PRVMER6.js";var b={name:"time",async execute(i,r){let a="%e %M",n=null,m=!1,f=!1,t=0;for(;t<i.length;){let e=i[t];if(e==="-f"||e==="--format"){if(t++,t>=i.length)return{stdout:"",stderr:`time: missing argument to '-f'
3
+ `,exitCode:1};a=i[t],t++}else if(e==="-o"||e==="--output"){if(t++,t>=i.length)return{stdout:"",stderr:`time: missing argument to '-o'
4
+ `,exitCode:1};n=i[t],t++}else if(e==="-a"||e==="--append")m=!0,t++;else if(e==="-v"||e==="--verbose")a=`Command being timed: %C
5
+ Elapsed (wall clock) time: %e seconds
6
+ Maximum resident set size (kbytes): %M`,t++;else if(e==="-p"||e==="--portability")f=!0,t++;else if(e==="--"){t++;break}else if(e.startsWith("-"))t++;else break}let l=i.slice(t);if(l.length===0)return{stdout:"",stderr:"",exitCode:0};let p=performance.now(),g=u(l),h=l.join(" "),s;try{if(!r.exec)return{stdout:"",stderr:`time: exec not available
7
+ `,exitCode:1};s=await r.exec(g,{env:c(r.env),cwd:r.cwd,stdin:r.stdin,signal:r.signal})}catch(e){s={stdout:"",stderr:`time: ${e.message}
8
+ `,exitCode:127}}let d=(performance.now()-p)/1e3,o;if(f?o=`real ${d.toFixed(2)}
9
+ user 0.00
10
+ sys 0.00
11
+ `:(o=a.replace(/%e/g,d.toFixed(2)).replace(/%E/g,C(d)).replace(/%M/g,"0").replace(/%S/g,"0.00").replace(/%U/g,"0.00").replace(/%P/g,"0%").replace(/%C/g,h),o.endsWith(`
12
+ `)||(o+=`
13
+ `)),n)try{let e=r.fs.resolvePath(r.cwd,n);if(m&&await r.fs.exists(e)){let w=await r.fs.readFile(e);await r.fs.writeFile(e,w+o)}else await r.fs.writeFile(e,o)}catch(e){return{stdout:s.stdout,stderr:s.stderr+`time: cannot write to '${n}': ${e.message}
14
+ `,exitCode:s.exitCode}}else s={...s,stderr:s.stderr+o};return s}};function C(i){let r=Math.floor(i/3600),a=Math.floor(i%3600/60),n=i%60;return r>0?`${r}:${a.toString().padStart(2,"0")}:${n.toFixed(2).padStart(5,"0")}`:`${a}:${n.toFixed(2).padStart(5,"0")}`}var y={name:"time",flags:[{flag:"-p",type:"boolean"}],needsArgs:!0};export{b as a,y as b};
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{b as p}from"./chunk-KTFEQPO7.js";import{a as j,b as h}from"./chunk-WIWKAGK6.js";import{a as S,b as q}from"./chunk-GTNBSMZR.js";import{existsSync as g}from"node:fs";import{dirname as H,join as w}from"node:path";import{fileURLToPath as J}from"node:url";import{Worker as W}from"node:worker_threads";import _ from"sql.js";function T(e,r,n){switch(n.mode){case"list":return V(e,r,n);case"csv":return O(e,r,n);case"json":return I(e,r);case"line":return N(e,r,n);case"column":return P(e,r,n);case"table":return M(e,r,n);case"markdown":return R(e,r,n);case"tabs":return F(e,r,n);case"box":return Q(e,r,n);case"quote":return B(e,r,n);case"html":return D(e,r,n);case"ascii":return U(e,r,n)}}function u(e,r){return e==null?r:e instanceof Uint8Array||Buffer.isBuffer(e)?Buffer.from(e).toString("utf8"):typeof e=="number"&&!Number.isInteger(e)?e.toPrecision(17).replace(/\.?0+$/,""):String(e)}function V(e,r,n){let t=[];n.header&&e.length>0&&t.push(e.join(n.separator));for(let l of r)t.push(l.map(i=>u(i,n.nullValue)).join(n.separator));return t.length>0?`${t.join(n.newline)}${n.newline}`:""}function O(e,r,n){let t=[];n.header&&e.length>0&&t.push(e.map(x).join(","));for(let l of r)t.push(l.map(i=>x(u(i,n.nullValue))).join(","));return t.length>0?`${t.join(`
2
+ import{b as p}from"./chunk-KTFEQPO7.js";import{a as j,b as h}from"./chunk-WIWKAGK6.js";import{a as S,b as q}from"./chunk-GTNBSMZR.js";import{existsSync as g}from"node:fs";import{dirname as H,join as w}from"node:path";import{fileURLToPath as W}from"node:url";import{Worker as J}from"node:worker_threads";import _ from"sql.js";function T(e,r,n){switch(n.mode){case"list":return V(e,r,n);case"csv":return O(e,r,n);case"json":return I(e,r);case"line":return N(e,r,n);case"column":return P(e,r,n);case"table":return M(e,r,n);case"markdown":return R(e,r,n);case"tabs":return F(e,r,n);case"box":return Q(e,r,n);case"quote":return B(e,r,n);case"html":return D(e,r,n);case"ascii":return U(e,r,n)}}function u(e,r){return e==null?r:e instanceof Uint8Array||Buffer.isBuffer(e)?Buffer.from(e).toString("utf8"):typeof e=="number"&&!Number.isInteger(e)?e.toPrecision(17).replace(/\.?0+$/,""):String(e)}function V(e,r,n){let t=[];n.header&&e.length>0&&t.push(e.join(n.separator));for(let l of r)t.push(l.map(i=>u(i,n.nullValue)).join(n.separator));return t.length>0?`${t.join(n.newline)}${n.newline}`:""}function O(e,r,n){let t=[];n.header&&e.length>0&&t.push(e.map(x).join(","));for(let l of r)t.push(l.map(i=>x(u(i,n.nullValue))).join(","));return t.length>0?`${t.join(`
3
3
  `)}
4
4
  `:""}function x(e){return e.includes(",")||e.includes('"')||e.includes("'")||e.includes(`
5
5
  `)?`"${e.replace(/"/g,'""')}"`:e}function y(e){return e.toPrecision(17).replace(/\.?0+$/,"")}function A(e){return e===null?"null":typeof e=="number"?Number.isInteger(e)?String(e):y(e):JSON.stringify(e)}function I(e,r){return r.length===0?"":`[${r.map(t=>`{${e.map((i,s)=>`${JSON.stringify(i)}:${A(t[s])}`).join(",")}}`).join(`,
@@ -23,14 +23,14 @@ import{b as p}from"./chunk-KTFEQPO7.js";import{a as j,b as h}from"./chunk-WIWKAG
23
23
  `,exitCode:1};r.nullValue=e[++s]}else if(o==="-cmd"){if(s+1>=e.length)return{stdout:"",stderr:`sqlite3: Error: missing argument to -cmd
24
24
  `,exitCode:1};r.cmd=e[++s]}else{if(o.startsWith("-"))return{stdout:"",stderr:`sqlite3: Error: unknown option: ${o.startsWith("--")?o.slice(1):o}
25
25
  Use -help for a list of options.
26
- `,exitCode:1};n===null?n=o:t===null&&(t=o)}}return{options:r,database:n,sql:t,showVersion:l}}async function G(){let e=await p.runTrustedAsync(()=>_()),r=new e.Database;try{let n=r.exec("SELECT sqlite_version()");return n.length>0&&n[0].values.length>0?String(n[0].values[0][0]):"unknown"}finally{r.close()}}function K(){let e=H(J(import.meta.url)),r=w(e,"../../commands/sqlite3/worker.js");if(g(r))return r;let n=w(e,"worker.js");if(g(n))return n;let t=w(e,"../../../dist/commands/sqlite3/worker.js");if(g(t))return t;throw new Error("sqlite3 worker not found. Run 'pnpm build' to compile the worker.")}async function Z(e,r){try{let n=K();return await new Promise((t,l)=>{let i=p.runTrusted(()=>new W(n,{workerData:e})),s=j(()=>{i.terminate(),t({success:!1,error:`Query timeout: execution exceeded ${r}ms limit`})},r);i.on("message",o=>{if(o.type==="security-violation"){h(s),t({success:!1,error:`Security violation: ${o.violation?.type??"unknown"}`});return}h(s),t(o)}),i.on("error",o=>{h(s),l(o)}),i.on("exit",o=>{h(s),o!==0&&t({success:!1,error:`Worker exited with code ${o}`})})})}catch(n){throw new Error(`sqlite3 worker failed to load: ${n.message}`)}}var ue={name:"sqlite3",async execute(e,r){if(q(e)||e.includes("-help"))return S(X);let n=Y(e);if("exitCode"in n)return n;let{options:t,database:l,sql:i,showVersion:s}=n;if(s)return{stdout:`${await G()}
26
+ `,exitCode:1};n===null?n=o:t===null&&(t=o)}}return{options:r,database:n,sql:t,showVersion:l}}async function G(){let e=await p.runTrustedAsync(()=>_()),r=new e.Database;try{let n=r.exec("SELECT sqlite_version()");return n.length>0&&n[0].values.length>0?String(n[0].values[0][0]):"unknown"}finally{r.close()}}function K(){let e=H(W(import.meta.url)),r=w(e,"../../commands/sqlite3/worker.js");if(g(r))return r;let n=w(e,"worker.js");if(g(n))return n;let t=w(e,"../../../dist/commands/sqlite3/worker.js");if(g(t))return t;throw new Error("sqlite3 worker not found. Run 'pnpm build' to compile the worker.")}var Z={createWorker(e,r){return new J(e,{workerData:r})}};async function v(e,r){try{let n=K();return await new Promise((t,l)=>{let i=p.runTrusted(()=>Z.createWorker(n,e)),s=j(()=>{i.terminate(),t({success:!1,error:`Query timeout: execution exceeded ${r}ms limit`})},r);i.on("message",o=>{if(o.type==="security-violation"){h(s),t({success:!1,error:`Security violation: ${o.violation?.type??"unknown"}`});return}h(s),t(o)}),i.on("error",o=>{h(s),l(o)}),i.on("exit",o=>{h(s),o!==0&&t({success:!1,error:`Worker exited with code ${o}`})})})}catch(n){throw new Error(`sqlite3 worker failed to load: ${n.message}`)}}var fe={name:"sqlite3",async execute(e,r){if(q(e)||e.includes("-help"))return S(X);let n=Y(e);if("exitCode"in n)return n;let{options:t,database:l,sql:i,showVersion:s}=n;if(s)return{stdout:`${await G()}
27
27
  `,stderr:"",exitCode:0};if(!l)return{stdout:"",stderr:`sqlite3: missing database argument
28
28
  `,exitCode:1};let o=i||r.stdin.trim();if(t.cmd&&(o=t.cmd+(o?`; ${o}`:"")),!o)return{stdout:"",stderr:`sqlite3: no SQL provided
29
29
  `,exitCode:1};let f=l===":memory:",m="",b=null;try{f||(m=r.fs.resolvePath(r.cwd,l),await r.fs.exists(m)&&(b=await r.fs.readFileBuffer(m)))}catch(a){return{stdout:"",stderr:`sqlite3: unable to open database "${l}": ${a.message}
30
- `,exitCode:1}}let C=r.limits?.maxSqliteTimeoutMs??z,L={dbBuffer:b,sql:o,options:{bail:t.bail,echo:t.echo}},d;try{d=await Z(L,C)}catch(a){return{stdout:"",stderr:`sqlite3: worker error: ${a.message}
30
+ `,exitCode:1}}let C=r.limits?.maxSqliteTimeoutMs??z,k={dbBuffer:b,sql:o,options:{bail:t.bail,echo:t.echo}},d;try{d=await v(k,C)}catch(a){return{stdout:"",stderr:`sqlite3: worker error: ${a.message}
31
31
  `,exitCode:1}}if(!d.success)return{stdout:"",stderr:`sqlite3: ${d.error}
32
- `,exitCode:1};let k={mode:t.mode,header:t.header,separator:t.separator,newline:t.newline,nullValue:t.nullValue},c="";t.echo&&(c+=`${o}
32
+ `,exitCode:1};let L={mode:t.mode,header:t.header,separator:t.separator,newline:t.newline,nullValue:t.nullValue},c="";t.echo&&(c+=`${o}
33
33
  `);let $=!1;for(let a of d.results)if(a.type==="error"){if(t.bail)return{stdout:c,stderr:`Error: ${a.error}
34
34
  `,exitCode:1};c+=`Error: ${a.error}
35
- `,$=!0}else a.columns&&a.rows&&(a.rows.length>0||t.header)&&(c+=T(a.columns,a.rows,k));if(d.hasModifications&&!t.readonly&&!f&&m&&d.dbBuffer)try{await r.fs.writeFile(m,d.dbBuffer)}catch(a){return{stdout:c,stderr:`sqlite3: failed to write database: ${a.message}
36
- `,exitCode:1}}return{stdout:c,stderr:"",exitCode:$&&t.bail?1:0}}},fe={name:"sqlite3",flags:[],needsArgs:!0};export{ue as a,fe as b};
35
+ `,$=!0}else a.columns&&a.rows&&(a.rows.length>0||t.header)&&(c+=T(a.columns,a.rows,L));if(d.hasModifications&&!t.readonly&&!f&&m&&d.dbBuffer)try{await r.fs.writeFile(m,d.dbBuffer)}catch(a){return{stdout:c,stderr:`sqlite3: failed to write database: ${a.message}
36
+ `,exitCode:1}}return{stdout:c,stderr:"",exitCode:$&&t.bail?1:0}}},de={name:"sqlite3",flags:[],needsArgs:!0};export{Z as a,fe as b,de as c};
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
- import{a as c}from"./chunk-WIWKAGK6.js";import{a as g,b as p,c as a}from"./chunk-GTNBSMZR.js";var O={name:"timeout",summary:"run a command with a time limit",usage:"timeout [OPTION] DURATION COMMAND [ARG]...",description:`Start COMMAND, and kill it if still running after DURATION.
2
+ import{a as h}from"./chunk-4OALHZXB.js";import{a as c}from"./chunk-WIWKAGK6.js";import{a as g,b as p,c as a}from"./chunk-GTNBSMZR.js";var v={name:"timeout",summary:"run a command with a time limit",usage:"timeout [OPTION] DURATION COMMAND [ARG]...",description:`Start COMMAND, and kill it if still running after DURATION.
3
3
 
4
4
  DURATION is a number with optional suffix:
5
5
  s - seconds (default)
6
6
  m - minutes
7
7
  h - hours
8
- d - days`,options:["-k, --kill-after=DURATION send KILL signal after DURATION if still running","-s, --signal=SIGNAL specify signal to send (default: TERM)"," --preserve-status exit with same status as COMMAND, even on timeout"," --foreground run command in foreground"," --help display this help and exit"]};function v(r){let i=r.match(/^(\d+\.?\d*)(s|m|h|d)?$/);if(!i)return null;let n=parseFloat(i[1]);switch(i[2]||"s"){case"s":return n*1e3;case"m":return n*60*1e3;case"h":return n*60*60*1e3;case"d":return n*24*60*60*1e3;default:return null}}var C={name:"timeout",async execute(r,i){if(p(r))return g(O);let n=!1,s=0;for(let t=0;t<r.length;t++){let e=r[t];if(e==="--preserve-status")n=!0,s=t+1;else if(e==="--foreground")s=t+1;else if(e==="-k"||e==="--kill-after")t++,s=t+1;else if(e.startsWith("--kill-after="))s=t+1;else if(e==="-s"||e==="--signal")t++,s=t+1;else if(e.startsWith("--signal="))s=t+1;else{if(e.startsWith("--")&&e!=="--")return a("timeout",e);if(e.startsWith("-")&&e.length>1&&e!=="--")if(e.startsWith("-k"))s=t+1;else if(e.startsWith("-s"))s=t+1;else return a("timeout",e);else{s=t;break}}}let o=r.slice(s);if(o.length===0)return{stdout:"",stderr:`timeout: missing operand
9
- `,exitCode:1};let u=o[0],l=v(u);if(l===null)return{stdout:"",stderr:`timeout: invalid time interval '${u}'
8
+ d - days`,options:["-k, --kill-after=DURATION send KILL signal after DURATION if still running","-s, --signal=SIGNAL specify signal to send (default: TERM)"," --preserve-status exit with same status as COMMAND, even on timeout"," --foreground run command in foreground"," --help display this help and exit"]};function w(r){let i=r.match(/^(\d+\.?\d*)(s|m|h|d)?$/);if(!i)return null;let n=parseFloat(i[1]);switch(i[2]||"s"){case"s":return n*1e3;case"m":return n*60*1e3;case"h":return n*60*60*1e3;case"d":return n*24*60*60*1e3;default:return null}}var y={name:"timeout",async execute(r,i){if(p(r))return g(v);let n=!1,s=0;for(let t=0;t<r.length;t++){let e=r[t];if(e==="--preserve-status")n=!0,s=t+1;else if(e==="--foreground")s=t+1;else if(e==="-k"||e==="--kill-after")t++,s=t+1;else if(e.startsWith("--kill-after="))s=t+1;else if(e==="-s"||e==="--signal")t++,s=t+1;else if(e.startsWith("--signal="))s=t+1;else{if(e.startsWith("--")&&e!=="--")return a("timeout",e);if(e.startsWith("-")&&e.length>1&&e!=="--")if(e.startsWith("-k"))s=t+1;else if(e.startsWith("-s"))s=t+1;else return a("timeout",e);else{s=t;break}}}let o=r.slice(s);if(o.length===0)return{stdout:"",stderr:`timeout: missing operand
9
+ `,exitCode:1};let l=o[0],u=w(l);if(u===null)return{stdout:"",stderr:`timeout: invalid time interval '${l}'
10
10
  `,exitCode:1};let m=o.slice(1);if(m.length===0)return{stdout:"",stderr:`timeout: missing operand
11
11
  `,exitCode:1};if(!i.exec)return{stdout:"",stderr:`timeout: exec not available
12
- `,exitCode:1};let h=m.map(t=>t.includes(" ")||t.includes(" ")?`'${t.replace(/'/g,"'\\''")}'`:t).join(" "),d=new AbortController,x=new Promise(t=>{c(()=>{d.abort(),t({timedOut:!0})},l)}),A=i.exec(h,{cwd:i.cwd,signal:d.signal}).then(t=>({timedOut:!1,result:t})),f=await Promise.race([x,A]);return f.timedOut?{stdout:"",stderr:"",exitCode:124}:f.result}},N={name:"timeout",flags:[{flag:"-k",type:"value",valueHint:"string"},{flag:"-s",type:"value",valueHint:"string"},{flag:"--preserve-status",type:"boolean"},{flag:"--foreground",type:"boolean"}],needsArgs:!0,minArgs:2};export{C as a,N as b};
12
+ `,exitCode:1};let A=h(m),d=new AbortController,x=new Promise(t=>{c(()=>{d.abort(),t({timedOut:!0})},u)}),O=i.exec(A,{cwd:i.cwd,signal:d.signal,stdin:i.stdin}).then(t=>({timedOut:!1,result:t})),f=await Promise.race([x,O]);return f.timedOut?{stdout:"",stderr:"",exitCode:124}:f.result}},D={name:"timeout",flags:[{flag:"-k",type:"value",valueHint:"string"},{flag:"-s",type:"value",valueHint:"string"},{flag:"--preserve-status",type:"boolean"},{flag:"--foreground",type:"boolean"}],needsArgs:!0,minArgs:2};export{y as a,D as b};
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ import{a as v}from"./chunk-4OALHZXB.js";import{a as d}from"./chunk-4PRVMER6.js";import{a as c,b as m,c as f}from"./chunk-GTNBSMZR.js";var y={name:"env",summary:"run a program in a modified environment",usage:"env [OPTION]... [NAME=VALUE]... [COMMAND [ARG]...]",options:["-i, --ignore-environment start with an empty environment","-u NAME, --unset=NAME remove NAME from the environment"," --help display this help and exit"]},N={name:"env",async execute(o,i){if(m(o))return c(y);let a=!1,r=[],u=new Map,t=-1;for(let n=0;n<o.length;n++){let e=o[n];if(e==="-i"||e==="--ignore-environment")a=!0;else if(e==="-u"&&n+1<o.length)r.push(o[++n]);else if(e.startsWith("-u"))r.push(e.slice(2));else if(e.startsWith("--unset="))r.push(e.slice(8));else{if(e.startsWith("--")&&e!=="--")return f("env",e);if(e.startsWith("-")&&e!=="-"){for(let l of e.slice(1))if(l!=="i"&&l!=="u")return f("env",`-${l}`);e.includes("i")&&(a=!0)}else if(e.includes("=")&&t===-1){let l=e.indexOf("="),g=e.slice(0,l),x=e.slice(l+1);u.set(g,x)}else{t=n;break}}}let s;if(a)s=new Map(u);else{s=new Map(i.env);for(let n of r)s.delete(n);for(let[n,e]of u)s.set(n,e)}if(t===-1){let n=[];for(let[e,l]of s)n.push(`${e}=${l}`);return{stdout:n.join(`
3
+ `)+(n.length>0?`
4
+ `:""),stderr:"",exitCode:0}}if(!i.exec)return{stdout:"",stderr:`env: command execution not supported in this context
5
+ `,exitCode:1};let p=o.slice(t),h=v(["command",...p]);return i.exec(h,{cwd:i.cwd,env:d(s),replaceEnv:!0,stdin:i.stdin,signal:i.signal})}},A={name:"printenv",summary:"print all or part of environment",usage:"printenv [OPTION]... [VARIABLE]...",options:[" --help display this help and exit"]},C={name:"printenv",async execute(o,i){if(m(o))return c(A);let a=o.filter(t=>!t.startsWith("-"));if(a.length===0){let t=[];for(let[s,p]of i.env)t.push(`${s}=${p}`);return{stdout:t.join(`
6
+ `)+(t.length>0?`
7
+ `:""),stderr:"",exitCode:0}}let r=[],u=0;for(let t of a){let s=i.env.get(t);s!==void 0?r.push(s):u=1}return{stdout:r.join(`
8
+ `)+(r.length>0?`
9
+ `:""),stderr:"",exitCode:u}}},O={name:"env",flags:[{flag:"-i",type:"boolean"},{flag:"-u",type:"value",valueHint:"string"}]},F={name:"printenv",flags:[]};export{N as a,C as b,O as c,F as d};