just-bash 1.2.4 → 1.3.0

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 (223) hide show
  1. package/README.md +1 -1
  2. package/dist/ai/index.d.ts +5 -0
  3. package/dist/bin/chunks/alias-ZAQAKC5X.js +7 -0
  4. package/dist/bin/chunks/awk2-A73ZNFXJ.js +20 -0
  5. package/dist/bin/chunks/base64-JPITV4MD.js +6 -0
  6. package/dist/bin/chunks/base64-KNBBHA5Y.js +5 -0
  7. package/dist/bin/chunks/basename-IYEP3AMY.js +6 -0
  8. package/dist/bin/chunks/bash-WZYHIZP6.js +7 -0
  9. package/dist/bin/chunks/cat-XILYL7NW.js +6 -0
  10. package/dist/bin/chunks/chmod-EXWX4N7Y.js +9 -0
  11. package/dist/bin/chunks/chunk-7Q4WQLOS.js +9 -0
  12. package/dist/bin/chunks/chunk-GX4MPCG6.js +9 -0
  13. package/dist/bin/chunks/chunk-PM2DS2YW.js +3 -0
  14. package/dist/bin/chunks/chunk-SJXDWN5X.js +2 -0
  15. package/dist/bin/chunks/clear-2APRIRCF.js +2 -0
  16. package/dist/bin/chunks/comm-KY3COLF5.js +13 -0
  17. package/dist/bin/chunks/cp-HES4UN7K.js +8 -0
  18. package/dist/bin/chunks/curl-BN5M3BUX.js +26 -0
  19. package/dist/bin/chunks/cut-JSIPAKOX.js +6 -0
  20. package/dist/bin/chunks/date-CU4J7GHI.js +5 -0
  21. package/dist/bin/chunks/diff-W4JRNHXW.js +19 -0
  22. package/dist/bin/chunks/dirname-UTCUUILN.js +5 -0
  23. package/dist/bin/chunks/du-2JU3PUTM.js +8 -0
  24. package/dist/bin/chunks/echo-HKLPYMNC.js +4 -0
  25. package/dist/bin/chunks/env-2SBJNP7X.js +9 -0
  26. package/dist/bin/chunks/expr-M74QZQ6C.js +5 -0
  27. package/dist/bin/chunks/file-Q4UOC4J2.js +23 -0
  28. package/dist/bin/chunks/file-QPD3U2H7.js +23 -0
  29. package/dist/bin/chunks/find-D3ZC5DXH.js +11 -0
  30. package/dist/bin/chunks/find-JADNFF7V.js +11 -0
  31. package/dist/bin/chunks/grep-BEZRXAWL.js +15 -0
  32. package/dist/bin/chunks/head-YGMY3DHE.js +2 -0
  33. package/dist/bin/chunks/help-UEF7LW7F.js +16 -0
  34. package/dist/bin/chunks/history-OGBCIAR5.js +3 -0
  35. package/dist/bin/chunks/html-to-markdown-HTGML4TH.js +84 -0
  36. package/dist/bin/chunks/jq-ME57VHK6.js +14 -0
  37. package/dist/bin/chunks/ln-RUR4ALOJ.js +10 -0
  38. package/dist/bin/chunks/ls-GU5227KE.js +26 -0
  39. package/dist/bin/chunks/md5sum-C7WDEYN5.js +2 -0
  40. package/dist/bin/chunks/md5sum-KZ4MRIXM.js +2 -0
  41. package/dist/bin/chunks/mkdir-4OYU22AA.js +7 -0
  42. package/dist/bin/chunks/mv-H3S4FEWR.js +7 -0
  43. package/dist/bin/chunks/paste-HHCFASL4.js +8 -0
  44. package/dist/bin/chunks/printf-2JFCUFOA.js +14 -0
  45. package/dist/bin/chunks/printf-WM4X6IZ6.js +14 -0
  46. package/dist/bin/chunks/pwd-T5Q3JEBO.js +3 -0
  47. package/dist/bin/chunks/readlink-M44TLMFS.js +7 -0
  48. package/dist/bin/chunks/rm-R4M647EC.js +8 -0
  49. package/dist/bin/chunks/sed-QLLAZYHH.js +80 -0
  50. package/dist/bin/chunks/seq-GJMQM7SP.js +7 -0
  51. package/dist/bin/chunks/sha1sum-WKCGV66X.js +2 -0
  52. package/dist/bin/chunks/sha1sum-XLRE72T4.js +2 -0
  53. package/dist/bin/chunks/sha256sum-3ZDGP5WC.js +2 -0
  54. package/dist/bin/chunks/sha256sum-BBKWFA43.js +2 -0
  55. package/dist/bin/chunks/sleep-OJPODQGM.js +10 -0
  56. package/dist/bin/chunks/sort-JL33INQB.js +16 -0
  57. package/dist/bin/chunks/sort-NCQNGVCX.js +16 -0
  58. package/dist/bin/chunks/sort-WGKQ3WYR.js +15 -0
  59. package/dist/bin/chunks/stat-CR2INBC2.js +9 -0
  60. package/dist/bin/chunks/tail-BYPLMYMZ.js +2 -0
  61. package/dist/bin/chunks/tee-HOMRRC3X.js +3 -0
  62. package/dist/bin/chunks/timeout-MYKG34DQ.js +12 -0
  63. package/dist/bin/chunks/touch-3ZANYAXI.js +4 -0
  64. package/dist/bin/chunks/tr-E66N7IS2.js +20 -0
  65. package/dist/bin/chunks/tree-EE2PYIMV.js +12 -0
  66. package/dist/bin/chunks/true-OWPVS7U4.js +2 -0
  67. package/dist/bin/chunks/uniq-F5NP3LLU.js +5 -0
  68. package/dist/bin/chunks/wc-NBMNJDZL.js +6 -0
  69. package/dist/bin/chunks/which-6MRG2UCF.js +3 -0
  70. package/dist/bin/chunks/xargs-EMY5BOJ2.js +4 -0
  71. package/dist/bin/chunks/xargs-XAZFX5J3.js +4 -0
  72. package/dist/bin/just-bash.js +36 -36
  73. package/dist/bin/shell/chunks/alias-ZAQAKC5X.js +7 -0
  74. package/dist/bin/shell/chunks/awk2-A73ZNFXJ.js +20 -0
  75. package/dist/bin/shell/chunks/base64-JPITV4MD.js +6 -0
  76. package/dist/bin/shell/chunks/base64-KNBBHA5Y.js +5 -0
  77. package/dist/bin/shell/chunks/basename-IYEP3AMY.js +6 -0
  78. package/dist/bin/shell/chunks/bash-WZYHIZP6.js +7 -0
  79. package/dist/bin/shell/chunks/cat-XILYL7NW.js +6 -0
  80. package/dist/bin/shell/chunks/chmod-EXWX4N7Y.js +9 -0
  81. package/dist/bin/shell/chunks/chunk-7Q4WQLOS.js +9 -0
  82. package/dist/bin/shell/chunks/chunk-GX4MPCG6.js +9 -0
  83. package/dist/bin/shell/chunks/chunk-PM2DS2YW.js +3 -0
  84. package/dist/bin/shell/chunks/chunk-SJXDWN5X.js +2 -0
  85. package/dist/bin/shell/chunks/clear-2APRIRCF.js +2 -0
  86. package/dist/bin/shell/chunks/comm-KY3COLF5.js +13 -0
  87. package/dist/bin/shell/chunks/cp-HES4UN7K.js +8 -0
  88. package/dist/bin/shell/chunks/curl-BN5M3BUX.js +26 -0
  89. package/dist/bin/shell/chunks/cut-JSIPAKOX.js +6 -0
  90. package/dist/bin/shell/chunks/date-CU4J7GHI.js +5 -0
  91. package/dist/bin/shell/chunks/diff-W4JRNHXW.js +19 -0
  92. package/dist/bin/shell/chunks/dirname-UTCUUILN.js +5 -0
  93. package/dist/bin/shell/chunks/du-2JU3PUTM.js +8 -0
  94. package/dist/bin/shell/chunks/echo-HKLPYMNC.js +4 -0
  95. package/dist/bin/shell/chunks/env-2SBJNP7X.js +9 -0
  96. package/dist/bin/shell/chunks/expr-M74QZQ6C.js +5 -0
  97. package/dist/bin/shell/chunks/file-Q4UOC4J2.js +23 -0
  98. package/dist/bin/shell/chunks/file-QPD3U2H7.js +23 -0
  99. package/dist/bin/shell/chunks/find-D3ZC5DXH.js +11 -0
  100. package/dist/bin/shell/chunks/find-JADNFF7V.js +11 -0
  101. package/dist/bin/shell/chunks/grep-BEZRXAWL.js +15 -0
  102. package/dist/bin/shell/chunks/head-YGMY3DHE.js +2 -0
  103. package/dist/bin/shell/chunks/help-UEF7LW7F.js +16 -0
  104. package/dist/bin/shell/chunks/history-OGBCIAR5.js +3 -0
  105. package/dist/bin/shell/chunks/html-to-markdown-HTGML4TH.js +84 -0
  106. package/dist/bin/shell/chunks/jq-ME57VHK6.js +14 -0
  107. package/dist/bin/shell/chunks/ln-RUR4ALOJ.js +10 -0
  108. package/dist/bin/shell/chunks/ls-GU5227KE.js +26 -0
  109. package/dist/bin/shell/chunks/md5sum-C7WDEYN5.js +2 -0
  110. package/dist/bin/shell/chunks/md5sum-KZ4MRIXM.js +2 -0
  111. package/dist/bin/shell/chunks/mkdir-4OYU22AA.js +7 -0
  112. package/dist/bin/shell/chunks/mv-H3S4FEWR.js +7 -0
  113. package/dist/bin/shell/chunks/paste-HHCFASL4.js +8 -0
  114. package/dist/bin/shell/chunks/printf-2JFCUFOA.js +14 -0
  115. package/dist/bin/shell/chunks/printf-WM4X6IZ6.js +14 -0
  116. package/dist/bin/shell/chunks/pwd-T5Q3JEBO.js +3 -0
  117. package/dist/bin/shell/chunks/readlink-M44TLMFS.js +7 -0
  118. package/dist/bin/shell/chunks/rm-R4M647EC.js +8 -0
  119. package/dist/bin/shell/chunks/sed-QLLAZYHH.js +80 -0
  120. package/dist/bin/shell/chunks/seq-GJMQM7SP.js +7 -0
  121. package/dist/bin/shell/chunks/sha1sum-WKCGV66X.js +2 -0
  122. package/dist/bin/shell/chunks/sha1sum-XLRE72T4.js +2 -0
  123. package/dist/bin/shell/chunks/sha256sum-3ZDGP5WC.js +2 -0
  124. package/dist/bin/shell/chunks/sha256sum-BBKWFA43.js +2 -0
  125. package/dist/bin/shell/chunks/sleep-OJPODQGM.js +10 -0
  126. package/dist/bin/shell/chunks/sort-JL33INQB.js +16 -0
  127. package/dist/bin/shell/chunks/sort-NCQNGVCX.js +16 -0
  128. package/dist/bin/shell/chunks/sort-WGKQ3WYR.js +15 -0
  129. package/dist/bin/shell/chunks/stat-CR2INBC2.js +9 -0
  130. package/dist/bin/shell/chunks/tail-BYPLMYMZ.js +2 -0
  131. package/dist/bin/shell/chunks/tee-HOMRRC3X.js +3 -0
  132. package/dist/bin/shell/chunks/timeout-MYKG34DQ.js +12 -0
  133. package/dist/bin/shell/chunks/touch-3ZANYAXI.js +4 -0
  134. package/dist/bin/shell/chunks/tr-E66N7IS2.js +20 -0
  135. package/dist/bin/shell/chunks/tree-EE2PYIMV.js +12 -0
  136. package/dist/bin/shell/chunks/true-OWPVS7U4.js +2 -0
  137. package/dist/bin/shell/chunks/uniq-F5NP3LLU.js +5 -0
  138. package/dist/bin/shell/chunks/wc-NBMNJDZL.js +6 -0
  139. package/dist/bin/shell/chunks/which-6MRG2UCF.js +3 -0
  140. package/dist/bin/shell/chunks/xargs-EMY5BOJ2.js +4 -0
  141. package/dist/bin/shell/chunks/xargs-XAZFX5J3.js +4 -0
  142. package/dist/bin/shell/shell.js +1 -1
  143. package/dist/bundle/ai/index.js +384 -343
  144. package/dist/bundle/chunks/alias-JFIUWFGE.js +6 -0
  145. package/dist/bundle/chunks/awk2-QWBT4IFJ.js +19 -0
  146. package/dist/bundle/chunks/base64-JN6XXTIG.js +4 -0
  147. package/dist/bundle/chunks/base64-TUA2XORD.js +5 -0
  148. package/dist/bundle/chunks/basename-5UVU5RXR.js +5 -0
  149. package/dist/bundle/chunks/bash-BASUPKHJ.js +6 -0
  150. package/dist/bundle/chunks/cat-47EP4IAV.js +5 -0
  151. package/dist/bundle/chunks/chmod-XJXFAD4M.js +8 -0
  152. package/dist/bundle/chunks/chunk-2RUN43TJ.js +1 -0
  153. package/dist/bundle/chunks/chunk-46TSKXFW.js +8 -0
  154. package/dist/bundle/chunks/chunk-4HEWHW5W.js +8 -0
  155. package/dist/bundle/chunks/chunk-NWEGHOXL.js +2 -0
  156. package/dist/bundle/chunks/clear-XD3TJRVQ.js +1 -0
  157. package/dist/bundle/chunks/comm-KSJ4BBRQ.js +12 -0
  158. package/dist/bundle/chunks/cp-37OVLNLD.js +7 -0
  159. package/dist/bundle/chunks/curl-C43O5WQS.js +25 -0
  160. package/dist/bundle/chunks/cut-FIZRELKC.js +5 -0
  161. package/dist/bundle/chunks/date-NN5C354M.js +4 -0
  162. package/dist/bundle/chunks/diff-GLRVCAKJ.js +6 -0
  163. package/dist/bundle/chunks/dirname-U2KVUSQY.js +4 -0
  164. package/dist/bundle/chunks/du-KRAFOIQK.js +7 -0
  165. package/dist/bundle/chunks/echo-WUKBESC7.js +3 -0
  166. package/dist/bundle/chunks/env-MSPSPGCD.js +8 -0
  167. package/dist/bundle/chunks/expr-HYOCSWK6.js +4 -0
  168. package/dist/bundle/chunks/file-JMDIXLHY.js +22 -0
  169. package/dist/bundle/chunks/file-LQXX6P4Y.js +22 -0
  170. package/dist/bundle/chunks/find-5UN24ZV7.js +10 -0
  171. package/dist/bundle/chunks/find-R6LJIRBI.js +10 -0
  172. package/dist/bundle/chunks/grep-ZJVDG3FA.js +14 -0
  173. package/dist/bundle/chunks/head-6PAUYCDP.js +1 -0
  174. package/dist/bundle/chunks/help-5E6PYJWQ.js +15 -0
  175. package/dist/bundle/chunks/history-SG6VRATI.js +2 -0
  176. package/dist/bundle/chunks/html-to-markdown-ZSZ34PAN.js +4 -0
  177. package/dist/bundle/chunks/jq-ABWUP4LV.js +13 -0
  178. package/dist/bundle/chunks/ln-XFYHBIFL.js +9 -0
  179. package/dist/bundle/chunks/ls-JGYJQA2Y.js +23 -0
  180. package/dist/bundle/chunks/md5sum-3BXZVFKC.js +1 -0
  181. package/dist/bundle/chunks/md5sum-PIH6F3O3.js +1 -0
  182. package/dist/bundle/chunks/mkdir-HA2FJX4O.js +6 -0
  183. package/dist/bundle/chunks/mv-7I62SB3I.js +6 -0
  184. package/dist/bundle/chunks/paste-QBGVCQFT.js +7 -0
  185. package/dist/bundle/chunks/printf-HBP44PXI.js +13 -0
  186. package/dist/bundle/chunks/printf-O2UW73XK.js +13 -0
  187. package/dist/bundle/chunks/pwd-CEF235GL.js +2 -0
  188. package/dist/bundle/chunks/readlink-MQIMKDSA.js +6 -0
  189. package/dist/bundle/chunks/rm-NF3FNLAY.js +7 -0
  190. package/dist/bundle/chunks/sed-H2RWPMTM.js +79 -0
  191. package/dist/bundle/chunks/seq-VKYIUOPJ.js +6 -0
  192. package/dist/bundle/chunks/sha1sum-HVHNZSEC.js +1 -0
  193. package/dist/bundle/chunks/sha1sum-MSBXCB4N.js +1 -0
  194. package/dist/bundle/chunks/sha256sum-REOOJORK.js +1 -0
  195. package/dist/bundle/chunks/sha256sum-YMKJMSTW.js +1 -0
  196. package/dist/bundle/chunks/sleep-AFN3PHJW.js +9 -0
  197. package/dist/bundle/chunks/sort-R3YWDMTV.js +14 -0
  198. package/dist/bundle/chunks/sort-TEXV7CUR.js +15 -0
  199. package/dist/bundle/chunks/sort-XODGFZC4.js +15 -0
  200. package/dist/bundle/chunks/stat-FVFLDQGP.js +8 -0
  201. package/dist/bundle/chunks/tail-QXKYHAML.js +1 -0
  202. package/dist/bundle/chunks/tee-W5HCCBPO.js +2 -0
  203. package/dist/bundle/chunks/timeout-XAA3N7CF.js +11 -0
  204. package/dist/bundle/chunks/touch-FOE745V2.js +3 -0
  205. package/dist/bundle/chunks/tr-LMLGE4IE.js +19 -0
  206. package/dist/bundle/chunks/tree-WBUGLVP5.js +11 -0
  207. package/dist/bundle/chunks/true-6LGCG4EY.js +1 -0
  208. package/dist/bundle/chunks/uniq-7PFWPNWK.js +4 -0
  209. package/dist/bundle/chunks/wc-GV5WUREX.js +5 -0
  210. package/dist/bundle/chunks/which-KHFYPBWW.js +2 -0
  211. package/dist/bundle/chunks/xargs-7KV5F66T.js +3 -0
  212. package/dist/bundle/chunks/xargs-NQBNFMCT.js +3 -0
  213. package/dist/bundle/index.js +1 -1
  214. package/dist/commands/comm/comm.d.ts +10 -0
  215. package/dist/commands/file/file.d.ts +7 -0
  216. package/dist/commands/md5sum/checksum.d.ts +7 -0
  217. package/dist/commands/md5sum/md5sum.d.ts +2 -0
  218. package/dist/commands/md5sum/sha1sum.d.ts +2 -0
  219. package/dist/commands/md5sum/sha256sum.d.ts +2 -0
  220. package/dist/commands/printf/escapes.d.ts +2 -1
  221. package/dist/commands/registry.d.ts +1 -1
  222. package/dist/commands/sort/types.d.ts +12 -0
  223. package/package.json +2 -1
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ import{a as l,b as r}from"./chunk-GTNBSMZR.js";import"./chunk-SJXDWN5X.js";var d={name:"alias",summary:"define or display aliases",usage:"alias [name[=value] ...]",options:[" --help display this help and exit"]},o="BASH_ALIAS_",f={name:"alias",async execute(i,n){if(r(i))return l(d);if(i.length===0){let e="";for(let[a,t]of Object.entries(n.env))if(a.startsWith(o)){let s=a.slice(o.length);e+=`alias ${s}='${t}'
3
+ `}return{stdout:e,stderr:"",exitCode:0}}for(let e of i){let a=e.indexOf("=");if(a===-1){let t=o+e;return n.env[t]?{stdout:`alias ${e}='${n.env[t]}'
4
+ `,stderr:"",exitCode:0}:{stdout:"",stderr:`alias: ${e}: not found
5
+ `,exitCode:1}}else{let t=e.slice(0,a),s=e.slice(a+1);(s.startsWith("'")&&s.endsWith("'")||s.startsWith('"')&&s.endsWith('"'))&&(s=s.slice(1,-1)),n.env[o+t]=s}}return{stdout:"",stderr:"",exitCode:0}}},m={name:"unalias",async execute(i,n){if(r(i))return l({name:"unalias",summary:"remove alias definitions",usage:"unalias name [name ...]",options:["-a remove all aliases"," --help display this help and exit"]});if(i.length===0)return{stdout:"",stderr:`unalias: usage: unalias [-a] name [name ...]
6
+ `,exitCode:1};if(i[0]==="-a"){for(let t of Object.keys(n.env))t.startsWith(o)&&delete n.env[t];return{stdout:"",stderr:"",exitCode:0}}let e=!1,a="";for(let t of i){let s=o+t;n.env[s]?delete n.env[s]:(a+=`unalias: ${t}: not found
7
+ `,e=!0)}return{stdout:"",stderr:a,exitCode:e?1:0}}};export{f as aliasCommand,m as unaliasCommand};
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+ import{i as g}from"./chunk-NWWB2XRE.js";import{a as K,b as Q,c as U}from"./chunk-GTNBSMZR.js";import"./chunk-SJXDWN5X.js";function x(e={}){let{fieldSep:t=/\s+/,maxIterations:r=1e4,maxRecursionDepth:n=100,fs:a,cwd:s}=e;return{FS:" ",OFS:" ",ORS:`
3
+ `,NR:0,NF:0,FNR:0,FILENAME:"",RSTART:0,RLENGTH:-1,SUBSEP:"",fields:[],line:"",vars:{},arrays:{},ARGC:0,ARGV:{},functions:new Map,fieldSep:t,maxIterations:r,maxRecursionDepth:n,currentRecursionDepth:0,exitCode:0,shouldExit:!1,shouldNext:!1,shouldNextFile:!1,loopBreak:!1,loopContinue:!1,hasReturn:!1,output:"",openedFiles:new Set,fs:a,cwd:s}}function j(e,t,r){switch(r){case"+":return e+t;case"-":return e-t;case"*":return e*t;case"/":return t!==0?e/t:0;case"%":return t!==0?e%t:0;case"^":case"**":return e**t;default:return 0}}function A(e){if(typeof e=="number")return e;let t=parseFloat(e);return Number.isNaN(t)?0:t}function w(e){return typeof e=="string"?e:(Number.isInteger(e),String(e))}async function ce(e,t,r){return e.length===0?t.line.length:w(await r.evalExpr(e[0])).length}async function he(e,t,r){if(e.length<2)return"";let n=w(await r.evalExpr(e[0])),a=Math.floor(A(await r.evalExpr(e[1])))-1;if(e.length>=3){let s=Math.floor(A(await r.evalExpr(e[2])));return n.substr(Math.max(0,a),s)}return n.substr(Math.max(0,a))}async function ue(e,t,r){if(e.length<2)return 0;let n=w(await r.evalExpr(e[0])),a=w(await r.evalExpr(e[1])),s=n.indexOf(a);return s===-1?0:s+1}async function pe(e,t,r){if(e.length<2)return 0;let n=w(await r.evalExpr(e[0])),a=e[1];if(a.type!=="variable")return 0;let s=a.name,o=t.FS;if(e.length>=3){let u=w(await r.evalExpr(e[2]));o=u===" "?/\s+/:u}else t.FS===" "&&(o=/\s+/);let l=n.split(o);t.arrays[s]={};for(let u=0;u<l.length;u++)t.arrays[s][String(u+1)]=l[u];return l.length}async function fe(e,t,r){if(e.length<2)return 0;let n;e[0].type==="regex"?n=e[0].pattern:(n=w(await r.evalExpr(e[0])),n.startsWith("/")&&n.endsWith("/")&&(n=n.slice(1,-1)));let a=w(await r.evalExpr(e[1])),s="$0";if(e.length>=3){let l=e[2];l.type==="variable"?s=l.name:l.type==="field"&&(s=`$${Math.floor(A(await r.evalExpr(l.index)))}`)}let o;if(s==="$0")o=t.line;else if(s.startsWith("$")){let l=parseInt(s.slice(1),10)-1;o=t.fields[l]||""}else o=w(t.vars[s]??"");try{let l=new RegExp(n),u=o.replace(l,z(a)),m=u!==o?1:0;if(s==="$0")t.line=u,t.fields=t.FS===" "?u.trim().split(/\s+/).filter(Boolean):u.split(t.fieldSep),t.NF=t.fields.length;else if(s.startsWith("$")){let N=parseInt(s.slice(1),10)-1;for(;t.fields.length<=N;)t.fields.push("");t.fields[N]=u,t.NF=t.fields.length,t.line=t.fields.join(t.OFS)}else t.vars[s]=u;return m}catch{return 0}}async function de(e,t,r){if(e.length<2)return 0;let n;e[0].type==="regex"?n=e[0].pattern:(n=w(await r.evalExpr(e[0])),n.startsWith("/")&&n.endsWith("/")&&(n=n.slice(1,-1)));let a=w(await r.evalExpr(e[1])),s="$0";if(e.length>=3){let l=e[2];l.type==="variable"?s=l.name:l.type==="field"&&(s=`$${Math.floor(A(await r.evalExpr(l.index)))}`)}let o;if(s==="$0")o=t.line;else if(s.startsWith("$")){let l=parseInt(s.slice(1),10)-1;o=t.fields[l]||""}else o=w(t.vars[s]??"");try{let l=new RegExp(n,"g"),u=o.match(l),m=u?u.length:0,N=o.replace(l,z(a));if(s==="$0")t.line=N,t.fields=t.FS===" "?N.trim().split(/\s+/).filter(Boolean):N.split(t.fieldSep),t.NF=t.fields.length;else if(s.startsWith("$")){let c=parseInt(s.slice(1),10)-1;for(;t.fields.length<=c;)t.fields.push("");t.fields[c]=N,t.NF=t.fields.length,t.line=t.fields.join(t.OFS)}else t.vars[s]=N;return m}catch{return 0}}function z(e){return t=>{let r="",n=0;for(;n<e.length;)if(e[n]==="\\"&&n+1<e.length){let a=e[n+1];a==="&"?(r+="&",n+=2):a==="\\"?(r+="\\",n+=2):(r+=e[n+1],n+=2)}else e[n]==="&"?(r+=t,n++):(r+=e[n],n++);return r}}async function Ee(e,t,r){if(e.length<2)return t.RSTART=0,t.RLENGTH=-1,0;let n=w(await r.evalExpr(e[0])),a;e[1].type==="regex"?a=e[1].pattern:(a=w(await r.evalExpr(e[1])),a.startsWith("/")&&a.endsWith("/")&&(a=a.slice(1,-1)));try{let o=new RegExp(a).exec(n);if(o)return t.RSTART=o.index+1,t.RLENGTH=o[0].length,t.RSTART}catch{}return t.RSTART=0,t.RLENGTH=-1,0}async function Ne(e,t,r){if(e.length<3)return"";let n;e[0].type==="regex"?n=e[0].pattern:(n=w(await r.evalExpr(e[0])),n.startsWith("/")&&n.endsWith("/")&&(n=n.slice(1,-1)));let a=w(await r.evalExpr(e[1])),s=w(await r.evalExpr(e[2])),o=e.length>=4?w(await r.evalExpr(e[3])):t.line;try{let l=s.toLowerCase()==="g",u=l?0:parseInt(s,10)||1;if(l){let m=new RegExp(n,"g");return o.replace(m,(N,...c)=>q(a,N,c.slice(0,-2)))}else{let m=0,N=new RegExp(n,"g");return o.replace(N,(c,...d)=>(m++,m===u?q(a,c,d.slice(0,-2)):c))}}catch{return o}}function q(e,t,r){let n="",a=0;for(;a<e.length;)if(e[a]==="\\"&&a+1<e.length){let s=e[a+1];if(s==="&")n+="&",a+=2;else if(s==="0")n+=t,a+=2;else if(s>="1"&&s<="9"){let o=parseInt(s,10)-1;n+=r[o]||"",a+=2}else s==="n"?(n+=`
4
+ `,a+=2):s==="t"?(n+=" ",a+=2):(n+=s,a+=2)}else e[a]==="&"?(n+=t,a++):(n+=e[a],a++);return n}async function ye(e,t,r){return e.length===0?"":w(await r.evalExpr(e[0])).toLowerCase()}async function me(e,t,r){return e.length===0?"":w(await r.evalExpr(e[0])).toUpperCase()}async function we(e,t,r){if(e.length===0)return"";let n=w(await r.evalExpr(e[0])),a=[];for(let s=1;s<e.length;s++)a.push(await r.evalExpr(e[s]));return W(n,a)}async function Re(e,t,r){return e.length===0?0:Math.floor(A(await r.evalExpr(e[0])))}async function Se(e,t,r){return e.length===0?0:Math.sqrt(A(await r.evalExpr(e[0])))}async function Ae(e,t,r){return e.length===0?0:Math.sin(A(await r.evalExpr(e[0])))}async function ge(e,t,r){return e.length===0?0:Math.cos(A(await r.evalExpr(e[0])))}async function ve(e,t,r){let n=e.length>0?A(await r.evalExpr(e[0])):0,a=e.length>1?A(await r.evalExpr(e[1])):0;return Math.atan2(n,a)}async function ke(e,t,r){return e.length===0?0:Math.log(A(await r.evalExpr(e[0])))}async function Ie(e,t,r){return e.length===0?1:Math.exp(A(await r.evalExpr(e[0])))}function Ce(e,t,r){return t.random?t.random():Math.random()}async function be(e,t,r){let n=e.length>0?A(await r.evalExpr(e[0])):Date.now();return t.vars._srand_seed=n,n}function H(e,t){return()=>{throw new Error(`${e}() is not supported - ${t}`)}}function $(e){return()=>{throw new Error(`function '${e}()' is not implemented`)}}function W(e,t){let r=0,n="",a=0;for(;a<e.length;)if(e[a]==="%"&&a+1<e.length){let s=a+1,o="",l="",u="";for(;s<e.length&&/[-+ #0]/.test(e[s]);)o+=e[s++];for(;s<e.length&&/\d/.test(e[s]);)l+=e[s++];if(e[s]===".")for(s++;s<e.length&&/\d/.test(e[s]);)u+=e[s++];let m=e[s],N=t[r];switch(m){case"s":{let c=N!==void 0?String(N):"";if(u&&(c=c.substring(0,parseInt(u,10))),l){let d=parseInt(l,10);o.includes("-")?c=c.padEnd(d):c=c.padStart(d)}n+=c,r++;break}case"d":case"i":{let c=N!==void 0?Math.floor(Number(N)):0;Number.isNaN(c)&&(c=0);let d=String(c);if(l){let h=parseInt(l,10);if(o.includes("-"))d=d.padEnd(h);else if(o.includes("0")&&!o.includes("-")){let f=c<0?"-":"";d=f+Math.abs(c).toString().padStart(h-f.length,"0")}else d=d.padStart(h)}n+=d,r++;break}case"f":{let c=N!==void 0?Number(N):0;Number.isNaN(c)&&(c=0);let d=u?parseInt(u,10):6,h=c.toFixed(d);if(l){let f=parseInt(l,10);o.includes("-")?h=h.padEnd(f):h=h.padStart(f)}n+=h,r++;break}case"e":case"E":{let c=N!==void 0?Number(N):0;Number.isNaN(c)&&(c=0);let d=u?parseInt(u,10):6,h=c.toExponential(d);if(m==="E"&&(h=h.toUpperCase()),l){let f=parseInt(l,10);o.includes("-")?h=h.padEnd(f):h=h.padStart(f)}n+=h,r++;break}case"g":case"G":{let c=N!==void 0?Number(N):0;Number.isNaN(c)&&(c=0);let d=u?parseInt(u,10):6,h=c!==0?Math.floor(Math.log10(Math.abs(c))):0,f;if(c===0?f="0":h<-4||h>=d?(f=c.toExponential(d-1),m==="G"&&(f=f.toUpperCase())):f=c.toPrecision(d),f=f.replace(/\.?0+$/,"").replace(/\.?0+e/,"e"),l){let R=parseInt(l,10);o.includes("-")?f=f.padEnd(R):f=f.padStart(R)}n+=f,r++;break}case"x":case"X":{let c=N!==void 0?Math.floor(Number(N)):0;Number.isNaN(c)&&(c=0);let d=Math.abs(c).toString(16);if(m==="X"&&(d=d.toUpperCase()),l){let h=parseInt(l,10);o.includes("0")?d=d.padStart(h,"0"):o.includes("-")?d=d.padEnd(h):d=d.padStart(h)}n+=c<0?`-${d}`:d,r++;break}case"o":{let c=N!==void 0?Math.floor(Number(N)):0;Number.isNaN(c)&&(c=0);let d=Math.abs(c).toString(8);if(l){let h=parseInt(l,10);o.includes("0")?d=d.padStart(h,"0"):o.includes("-")?d=d.padEnd(h):d=d.padStart(h)}n+=c<0?`-${d}`:d,r++;break}case"c":{typeof N=="number"?n+=String.fromCharCode(N):n+=String(N??"").charAt(0)||"",r++;break}case"%":n+="%";break;default:n+=e.substring(a,s+1)}a=s+1}else if(e[a]==="\\"&&a+1<e.length){let s=e[a+1];switch(s){case"n":n+=`
5
+ `;break;case"t":n+=" ";break;case"r":n+="\r";break;case"\\":n+="\\";break;default:n+=s}a+=2}else n+=e[a++];return n}var Z={length:ce,substr:he,index:ue,split:pe,sub:fe,gsub:de,match:Ee,gensub:Ne,tolower:ye,toupper:me,sprintf:we,int:Re,sqrt:Se,sin:Ae,cos:ge,atan2:ve,log:ke,exp:Ie,rand:Ce,srand:be,system:H("system","shell execution not allowed in sandboxed environment"),close:H("close","file operations not allowed"),fflush:H("fflush","file operations not allowed"),systime:$("systime"),mktime:$("mktime"),strftime:$("strftime")};function S(e){return typeof e=="number"?e!==0:e!==""}function E(e){if(typeof e=="number")return e;let t=parseFloat(e);return Number.isNaN(t)?0:t}function y(e){return typeof e=="string"?e:(Number.isInteger(e),String(e))}function X(e){if(typeof e=="number")return!0;let t=String(e).trim();return t===""?!1:!Number.isNaN(Number(t))}function F(e,t){try{return new RegExp(e).test(t)}catch{return!1}}function J(e,t){return e.FS===" "?t.trim().split(/\s+/).filter(Boolean):t.split(e.fieldSep)}function I(e,t){return t===0?e.line:t<0||t>e.fields.length?"":e.fields[t-1]??""}function O(e,t,r){if(t===0)e.line=y(r),e.fields=J(e,e.line),e.NF=e.fields.length;else if(t>0){for(;e.fields.length<t;)e.fields.push("");e.fields[t-1]=y(r),e.NF=e.fields.length,e.line=e.fields.join(e.OFS)}}function T(e,t){e.line=t,e.fields=J(e,t),e.NF=e.fields.length}function Y(e,t){if(e.FS=t,t===" ")e.fieldSep=/\s+/;else try{e.fieldSep=new RegExp(t)}catch{e.fieldSep=new RegExp(t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))}}function C(e,t){switch(t){case"FS":return e.FS;case"OFS":return e.OFS;case"ORS":return e.ORS;case"NR":return e.NR;case"NF":return e.NF;case"FNR":return e.FNR;case"FILENAME":return e.FILENAME;case"RSTART":return e.RSTART;case"RLENGTH":return e.RLENGTH;case"SUBSEP":return e.SUBSEP;case"ARGC":return e.ARGC}return e.vars[t]??""}function v(e,t,r){switch(t){case"FS":Y(e,y(r));return;case"OFS":e.OFS=y(r);return;case"ORS":e.ORS=y(r);return;case"NR":e.NR=Math.floor(E(r));return;case"NF":{let n=Math.floor(E(r));if(n<e.NF)e.fields=e.fields.slice(0,n),e.line=e.fields.join(e.OFS);else if(n>e.NF){for(;e.fields.length<n;)e.fields.push("");e.line=e.fields.join(e.OFS)}e.NF=n;return}case"FNR":e.FNR=Math.floor(E(r));return;case"FILENAME":e.FILENAME=y(r);return;case"RSTART":e.RSTART=Math.floor(E(r));return;case"RLENGTH":e.RLENGTH=Math.floor(E(r));return;case"SUBSEP":e.SUBSEP=y(r);return}e.vars[t]=r}function b(e,t,r){return t==="ARGV"?e.ARGV[r]??"":e.arrays[t]?.[r]??""}function P(e,t,r,n){e.arrays[t]||(e.arrays[t]={}),e.arrays[t][r]=n}function ee(e,t,r){return t==="ARGV"?e.ARGV[r]!==void 0:e.arrays[t]?.[r]!==void 0}function te(e,t,r){e.arrays[t]&&delete e.arrays[t][r]}function re(e,t){delete e.arrays[t]}var V=null;function ie(e){V=e}async function p(e,t){switch(t.type){case"number":return t.value;case"string":return t.value;case"regex":return F(t.pattern,e.line)?1:0;case"field":return Le(e,t);case"variable":return C(e,t.name);case"array_access":return Oe(e,t);case"binary":return Pe(e,t);case"unary":return Te(e,t);case"ternary":return S(await p(e,t.condition))?p(e,t.consequent):p(e,t.alternate);case"call":return _e(e,t.name,t.args);case"assignment":return De(e,t);case"pre_increment":return Be(e,t.operand);case"pre_decrement":return Ue(e,t.operand);case"post_increment":return xe(e,t.operand);case"post_decrement":return He(e,t.operand);case"in":return $e(e,t.key,t.array);case"getline":return We(e,t.variable,t.file);case"tuple":return Ve(e,t.elements);default:return""}}async function Le(e,t){let r=Math.floor(E(await p(e,t.index)));return I(e,r)}async function Oe(e,t){let r=y(await p(e,t.key));return b(e,t.array,r)}async function Pe(e,t){let r=t.operator;if(r==="||")return S(await p(e,t.left))||S(await p(e,t.right))?1:0;if(r==="&&")return S(await p(e,t.left))&&S(await p(e,t.right))?1:0;if(r==="~"){let l=await p(e,t.left),u=t.right.type==="regex"?t.right.pattern:y(await p(e,t.right));try{return new RegExp(u).test(y(l))?1:0}catch{return 0}}if(r==="!~"){let l=await p(e,t.left),u=t.right.type==="regex"?t.right.pattern:y(await p(e,t.right));try{return new RegExp(u).test(y(l))?0:1}catch{return 1}}let n=await p(e,t.left),a=await p(e,t.right);if(r===" ")return y(n)+y(a);if(Me(r))return Fe(n,a,r);let s=E(n),o=E(a);return j(s,o,r)}function Me(e){return["<","<=",">",">=","==","!="].includes(e)}function Fe(e,t,r){let n=X(e),a=X(t);if(n&&a){let l=E(e),u=E(t);switch(r){case"<":return l<u?1:0;case"<=":return l<=u?1:0;case">":return l>u?1:0;case">=":return l>=u?1:0;case"==":return l===u?1:0;case"!=":return l!==u?1:0}}let s=y(e),o=y(t);switch(r){case"<":return s<o?1:0;case"<=":return s<=o?1:0;case">":return s>o?1:0;case">=":return s>=o?1:0;case"==":return s===o?1:0;case"!=":return s!==o?1:0}return 0}async function Te(e,t){let r=await p(e,t.operand);switch(t.operator){case"!":return S(r)?0:1;case"-":return-E(r);case"+":return+E(r);default:return r}}async function _e(e,t,r){let n=Z[t];if(n)return n(r,e,{evalExpr:s=>p(e,s)});let a=e.functions.get(t);return a?Ge(e,a,r):""}async function Ge(e,t,r){if(e.currentRecursionDepth++,e.currentRecursionDepth>e.maxRecursionDepth)throw e.currentRecursionDepth--,new g(`awk: recursion depth exceeded maximum (${e.maxRecursionDepth})`,"recursion",e.output);let n={};for(let s of t.params)n[s]=e.vars[s];for(let s=0;s<t.params.length;s++){let o=t.params[s],l=s<r.length?await p(e,r[s]):"";e.vars[o]=l}e.hasReturn=!1,e.returnValue=void 0,V&&await V(e,t.body.statements);let a=e.returnValue??"";for(let s of t.params)n[s]!==void 0?e.vars[s]=n[s]:delete e.vars[s];return e.hasReturn=!1,e.returnValue=void 0,e.currentRecursionDepth--,a}async function De(e,t){let r=await p(e,t.value),n=t.target,a=t.operator,s;if(a==="=")s=r;else{let o;if(n.type==="field"){let m=Math.floor(E(await p(e,n.index)));o=I(e,m)}else if(n.type==="variable")o=C(e,n.name);else{let m=y(await p(e,n.key));o=b(e,n.array,m)}let l=E(o),u=E(r);switch(a){case"+=":s=l+u;break;case"-=":s=l-u;break;case"*=":s=l*u;break;case"/=":s=u!==0?l/u:0;break;case"%=":s=u!==0?l%u:0;break;case"^=":s=l**u;break;default:s=r}}if(n.type==="field"){let o=Math.floor(E(await p(e,n.index)));O(e,o,s)}else if(n.type==="variable")v(e,n.name,s);else{let o=y(await p(e,n.key));P(e,n.array,o,s)}return s}async function Be(e,t){let r;if(t.type==="field"){let n=Math.floor(E(await p(e,t.index)));r=E(I(e,n))+1,O(e,n,r)}else if(t.type==="variable")r=E(C(e,t.name))+1,v(e,t.name,r);else{let n=y(await p(e,t.key));r=E(b(e,t.array,n))+1,P(e,t.array,n,r)}return r}async function Ue(e,t){let r;if(t.type==="field"){let n=Math.floor(E(await p(e,t.index)));r=E(I(e,n))-1,O(e,n,r)}else if(t.type==="variable")r=E(C(e,t.name))-1,v(e,t.name,r);else{let n=y(await p(e,t.key));r=E(b(e,t.array,n))-1,P(e,t.array,n,r)}return r}async function xe(e,t){let r;if(t.type==="field"){let n=Math.floor(E(await p(e,t.index)));r=E(I(e,n)),O(e,n,r+1)}else if(t.type==="variable")r=E(C(e,t.name)),v(e,t.name,r+1);else{let n=y(await p(e,t.key));r=E(b(e,t.array,n)),P(e,t.array,n,r+1)}return r}async function He(e,t){let r;if(t.type==="field"){let n=Math.floor(E(await p(e,t.index)));r=E(I(e,n)),O(e,n,r-1)}else if(t.type==="variable")r=E(C(e,t.name)),v(e,t.name,r-1);else{let n=y(await p(e,t.key));r=E(b(e,t.array,n)),P(e,t.array,n,r-1)}return r}async function $e(e,t,r){let n;if(t.type==="tuple"){let a=[];for(let s of t.elements)a.push(y(await p(e,s)));n=a.join(e.SUBSEP)}else n=y(await p(e,t));return ee(e,r,n)?1:0}async function We(e,t,r){if(r)return Xe(e,t,r);if(!e.lines||e.lineIndex===void 0)return-1;let n=e.lineIndex+1;if(n>=e.lines.length)return 0;let a=e.lines[n];return t?v(e,t,a):T(e,a),e.NR++,e.lineIndex=n,1}async function Xe(e,t,r){if(!e.fs||!e.cwd)return-1;let n=y(await p(e,r)),a=e.fs.resolvePath(e.cwd,n),s=`__fc_${a}`,o=`__fi_${a}`,l,u;if(e.vars[s]===void 0)try{l=(await e.fs.readFile(a)).split(`
6
+ `),l.length>0&&l[l.length-1]===""&&l.pop(),e.vars[s]=JSON.stringify(l),e.vars[o]=-1,u=-1}catch{return-1}else l=JSON.parse(e.vars[s]),u=e.vars[o];let m=u+1;if(m>=l.length)return 0;let N=l[m];return e.vars[o]=m,t?v(e,t,N):T(e,N),1}async function Ve(e,t){if(t.length===0)return"";for(let r=0;r<t.length-1;r++)await p(e,t[r]);return p(e,t[t.length-1])}ie(M);async function M(e,t){for(let r of t)if(await L(e,r),Ke(e))break}function Ke(e){return e.shouldExit||e.shouldNext||e.shouldNextFile||e.loopBreak||e.loopContinue||e.hasReturn}async function L(e,t){switch(t.type){case"block":await M(e,t.statements);break;case"expr_stmt":await p(e,t.expression);break;case"print":await Qe(e,t.args,t.output);break;case"printf":await je(e,t.format,t.args,t.output);break;case"if":await qe(e,t);break;case"while":await ze(e,t);break;case"do_while":await Ze(e,t);break;case"for":await Je(e,t);break;case"for_in":await Ye(e,t);break;case"break":e.loopBreak=!0;break;case"continue":e.loopContinue=!0;break;case"next":e.shouldNext=!0;break;case"nextfile":e.shouldNextFile=!0;break;case"exit":e.shouldExit=!0,e.exitCode=t.code?Math.floor(E(await p(e,t.code))):0;break;case"return":e.hasReturn=!0,e.returnValue=t.value?await p(e,t.value):"";break;case"delete":await et(e,t.target);break}}async function Qe(e,t,r){let n=[];for(let s of t)n.push(y(await p(e,s)));let a=n.join(e.OFS)+e.ORS;r?await ne(e,r.redirect,r.file,a):e.output+=a}async function je(e,t,r,n){let a=y(await p(e,t)),s=[];for(let l of r)s.push(await p(e,l));let o=W(a,s);n?await ne(e,n.redirect,n.file,o):e.output+=o}async function ne(e,t,r,n){if(!e.fs||!e.cwd){e.output+=n;return}let a=y(await p(e,r)),s=e.fs.resolvePath(e.cwd,a);t===">"?e.openedFiles.has(s)?await e.fs.appendFile(s,n):(await e.fs.writeFile(s,n),e.openedFiles.add(s)):(e.openedFiles.has(s)||e.openedFiles.add(s),await e.fs.appendFile(s,n))}async function qe(e,t){S(await p(e,t.condition))?await L(e,t.consequent):t.alternate&&await L(e,t.alternate)}async function ze(e,t){let r=0;for(;S(await p(e,t.condition));){if(r++,r>e.maxIterations)throw new g(`awk: while loop exceeded maximum iterations (${e.maxIterations})`,"iterations",e.output);if(e.loopContinue=!1,await L(e,t.body),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break}}async function Ze(e,t){let r=0;do{if(r++,r>e.maxIterations)throw new g(`awk: do-while loop exceeded maximum iterations (${e.maxIterations})`,"iterations",e.output);if(e.loopContinue=!1,await L(e,t.body),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break}while(S(await p(e,t.condition)))}async function Je(e,t){t.init&&await p(e,t.init);let r=0;for(;!t.condition||S(await p(e,t.condition));){if(r++,r>e.maxIterations)throw new g(`awk: for loop exceeded maximum iterations (${e.maxIterations})`,"iterations",e.output);if(e.loopContinue=!1,await L(e,t.body),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break;t.update&&await p(e,t.update)}}async function Ye(e,t){let r=e.arrays[t.array];if(r)for(let n of Object.keys(r)){if(e.vars[t.variable]=n,e.loopContinue=!1,await L(e,t.body),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break}}async function et(e,t){if(t.type==="array_access"){let r=y(await p(e,t.key));te(e,t.array,r)}else t.type==="variable"&&re(e,t.name)}var _=class{ctx;program=null;rangeStates=[];constructor(t){this.ctx=t}execute(t){this.program=t,this.ctx.output="";for(let r of t.functions)this.ctx.functions.set(r.name,r);this.rangeStates=t.rules.map(()=>!1)}async executeBegin(){if(this.program){for(let t of this.program.rules)if(t.pattern?.type==="begin"&&(await M(this.ctx,t.action.statements),this.ctx.shouldExit))break}}async executeLine(t){if(!(!this.program||this.ctx.shouldExit)){T(this.ctx,t),this.ctx.NR++,this.ctx.FNR++,this.ctx.shouldNext=!1;for(let r=0;r<this.program.rules.length&&!(this.ctx.shouldExit||this.ctx.shouldNext||this.ctx.shouldNextFile);r++){let n=this.program.rules[r];n.pattern?.type==="begin"||n.pattern?.type==="end"||await this.matchesRule(n,r)&&await M(this.ctx,n.action.statements)}}}async executeEnd(){if(!(!this.program||this.ctx.shouldExit)){for(let t of this.program.rules)if(t.pattern?.type==="end"&&(await M(this.ctx,t.action.statements),this.ctx.shouldExit))break}}getOutput(){return this.ctx.output}getExitCode(){return this.ctx.exitCode}getContext(){return this.ctx}async matchesRule(t,r){let n=t.pattern;if(!n)return!0;switch(n.type){case"begin":case"end":return!1;case"regex_pattern":return F(n.pattern,this.ctx.line);case"expr_pattern":return S(await p(this.ctx,n.expression));case"range":{let a=await this.matchPattern(n.start),s=await this.matchPattern(n.end);return this.rangeStates[r]?(s&&(this.rangeStates[r]=!1),!0):a?(this.rangeStates[r]=!0,s&&(this.rangeStates[r]=!1),!0):!1}default:return!1}}async matchPattern(t){switch(t.type){case"regex_pattern":return F(t.pattern,this.ctx.line);case"expr_pattern":return S(await p(this.ctx,t.expression));default:return!1}}};var i;(function(e){e.NUMBER="NUMBER",e.STRING="STRING",e.REGEX="REGEX",e.IDENT="IDENT",e.BEGIN="BEGIN",e.END="END",e.IF="IF",e.ELSE="ELSE",e.WHILE="WHILE",e.DO="DO",e.FOR="FOR",e.IN="IN",e.BREAK="BREAK",e.CONTINUE="CONTINUE",e.NEXT="NEXT",e.NEXTFILE="NEXTFILE",e.EXIT="EXIT",e.RETURN="RETURN",e.DELETE="DELETE",e.FUNCTION="FUNCTION",e.PRINT="PRINT",e.PRINTF="PRINTF",e.GETLINE="GETLINE",e.PLUS="PLUS",e.MINUS="MINUS",e.STAR="STAR",e.SLASH="SLASH",e.PERCENT="PERCENT",e.CARET="CARET",e.EQ="EQ",e.NE="NE",e.LT="LT",e.GT="GT",e.LE="LE",e.GE="GE",e.MATCH="MATCH",e.NOT_MATCH="NOT_MATCH",e.AND="AND",e.OR="OR",e.NOT="NOT",e.ASSIGN="ASSIGN",e.PLUS_ASSIGN="PLUS_ASSIGN",e.MINUS_ASSIGN="MINUS_ASSIGN",e.STAR_ASSIGN="STAR_ASSIGN",e.SLASH_ASSIGN="SLASH_ASSIGN",e.PERCENT_ASSIGN="PERCENT_ASSIGN",e.CARET_ASSIGN="CARET_ASSIGN",e.INCREMENT="INCREMENT",e.DECREMENT="DECREMENT",e.QUESTION="QUESTION",e.COLON="COLON",e.COMMA="COMMA",e.SEMICOLON="SEMICOLON",e.NEWLINE="NEWLINE",e.LPAREN="LPAREN",e.RPAREN="RPAREN",e.LBRACE="LBRACE",e.RBRACE="RBRACE",e.LBRACKET="LBRACKET",e.RBRACKET="RBRACKET",e.DOLLAR="DOLLAR",e.APPEND="APPEND",e.PIPE="PIPE",e.EOF="EOF"})(i||(i={}));var tt={BEGIN:i.BEGIN,END:i.END,if:i.IF,else:i.ELSE,while:i.WHILE,do:i.DO,for:i.FOR,in:i.IN,break:i.BREAK,continue:i.CONTINUE,next:i.NEXT,nextfile:i.NEXTFILE,exit:i.EXIT,return:i.RETURN,delete:i.DELETE,function:i.FUNCTION,print:i.PRINT,printf:i.PRINTF,getline:i.GETLINE};function rt(e){return e.replace(/\[\[:space:\]\]/g,"[ \\t\\n\\r\\f\\v]").replace(/\[\[:blank:\]\]/g,"[ \\t]").replace(/\[\[:alpha:\]\]/g,"[a-zA-Z]").replace(/\[\[:digit:\]\]/g,"[0-9]").replace(/\[\[:alnum:\]\]/g,"[a-zA-Z0-9]").replace(/\[\[:upper:\]\]/g,"[A-Z]").replace(/\[\[:lower:\]\]/g,"[a-z]").replace(/\[\[:punct:\]\]/g,"[!\"#$%&'()*+,\\-./:;<=>?@\\[\\]\\\\^_`{|}~]").replace(/\[\[:xdigit:\]\]/g,"[0-9A-Fa-f]").replace(/\[\[:graph:\]\]/g,"[!-~]").replace(/\[\[:print:\]\]/g,"[ -~]").replace(/\[\[:cntrl:\]\]/g,"[\\x00-\\x1f\\x7f]")}var D=class{input;pos=0;line=1;column=1;lastTokenType=null;constructor(t){this.input=t}tokenize(){let t=[];for(;this.pos<this.input.length;){let r=this.nextToken();r&&(t.push(r),this.lastTokenType=r.type)}return t.push(this.makeToken(i.EOF,"")),t}makeToken(t,r){return{type:t,value:r,line:this.line,column:this.column}}peek(t=0){return this.input[this.pos+t]||""}advance(){let t=this.input[this.pos++]||"";return t===`
7
+ `?(this.line++,this.column=1):this.column++,t}skipWhitespace(){for(;this.pos<this.input.length;){let t=this.peek();if(t===" "||t===" "||t==="\r")this.advance();else if(t==="\\")if(this.peek(1)===`
8
+ `)this.advance(),this.advance();else break;else if(t==="#")for(;this.pos<this.input.length&&this.peek()!==`
9
+ `;)this.advance();else break}}nextToken(){if(this.skipWhitespace(),this.pos>=this.input.length)return null;let t=this.line,r=this.column,n=this.peek();return n===`
10
+ `?(this.advance(),{type:i.NEWLINE,value:`
11
+ `,line:t,column:r}):n==='"'?this.readString():n==="/"&&this.canBeRegex()?this.readRegex():this.isDigit(n)||n==="."&&this.isDigit(this.peek(1))?this.readNumber():this.isAlpha(n)||n==="_"?this.readIdentifier():this.readOperator()}canBeRegex(){return new Set([null,i.NEWLINE,i.SEMICOLON,i.LBRACE,i.RBRACE,i.LPAREN,i.LBRACKET,i.COMMA,i.ASSIGN,i.PLUS_ASSIGN,i.MINUS_ASSIGN,i.STAR_ASSIGN,i.SLASH_ASSIGN,i.PERCENT_ASSIGN,i.CARET_ASSIGN,i.AND,i.OR,i.NOT,i.MATCH,i.NOT_MATCH,i.QUESTION,i.COLON,i.LT,i.GT,i.LE,i.GE,i.EQ,i.NE,i.PLUS,i.MINUS,i.STAR,i.PERCENT,i.CARET,i.PRINT,i.PRINTF,i.IF,i.WHILE,i.DO,i.FOR,i.RETURN]).has(this.lastTokenType)}readString(){let t=this.line,r=this.column;this.advance();let n="";for(;this.pos<this.input.length&&this.peek()!=='"';)if(this.peek()==="\\"){this.advance();let a=this.advance();switch(a){case"n":n+=`
12
+ `;break;case"t":n+=" ";break;case"r":n+="\r";break;case"\\":n+="\\";break;case'"':n+='"';break;case"/":n+="/";break;default:n+=a}}else n+=this.advance();return this.peek()==='"'&&this.advance(),{type:i.STRING,value:n,line:t,column:r}}readRegex(){let t=this.line,r=this.column;this.advance();let n="";for(;this.pos<this.input.length&&this.peek()!=="/";)if(this.peek()==="\\")n+=this.advance(),this.pos<this.input.length&&(n+=this.advance());else{if(this.peek()===`
13
+ `)break;n+=this.advance()}return this.peek()==="/"&&this.advance(),n=rt(n),{type:i.REGEX,value:n,line:t,column:r}}readNumber(){let t=this.line,r=this.column,n="";for(;this.isDigit(this.peek());)n+=this.advance();if(this.peek()==="."&&this.isDigit(this.peek(1)))for(n+=this.advance();this.isDigit(this.peek());)n+=this.advance();if(this.peek()==="e"||this.peek()==="E")for(n+=this.advance(),(this.peek()==="+"||this.peek()==="-")&&(n+=this.advance());this.isDigit(this.peek());)n+=this.advance();return{type:i.NUMBER,value:parseFloat(n),line:t,column:r}}readIdentifier(){let t=this.line,r=this.column,n="";for(;this.isAlphaNumeric(this.peek())||this.peek()==="_";)n+=this.advance();let a=tt[n];return a?{type:a,value:n,line:t,column:r}:{type:i.IDENT,value:n,line:t,column:r}}readOperator(){let t=this.line,r=this.column,n=this.advance(),a=this.peek();switch(n){case"+":return a==="+"?(this.advance(),{type:i.INCREMENT,value:"++",line:t,column:r}):a==="="?(this.advance(),{type:i.PLUS_ASSIGN,value:"+=",line:t,column:r}):{type:i.PLUS,value:"+",line:t,column:r};case"-":return a==="-"?(this.advance(),{type:i.DECREMENT,value:"--",line:t,column:r}):a==="="?(this.advance(),{type:i.MINUS_ASSIGN,value:"-=",line:t,column:r}):{type:i.MINUS,value:"-",line:t,column:r};case"*":return a==="*"?(this.advance(),{type:i.CARET,value:"**",line:t,column:r}):a==="="?(this.advance(),{type:i.STAR_ASSIGN,value:"*=",line:t,column:r}):{type:i.STAR,value:"*",line:t,column:r};case"/":return a==="="?(this.advance(),{type:i.SLASH_ASSIGN,value:"/=",line:t,column:r}):{type:i.SLASH,value:"/",line:t,column:r};case"%":return a==="="?(this.advance(),{type:i.PERCENT_ASSIGN,value:"%=",line:t,column:r}):{type:i.PERCENT,value:"%",line:t,column:r};case"^":return a==="="?(this.advance(),{type:i.CARET_ASSIGN,value:"^=",line:t,column:r}):{type:i.CARET,value:"^",line:t,column:r};case"=":return a==="="?(this.advance(),{type:i.EQ,value:"==",line:t,column:r}):{type:i.ASSIGN,value:"=",line:t,column:r};case"!":return a==="="?(this.advance(),{type:i.NE,value:"!=",line:t,column:r}):a==="~"?(this.advance(),{type:i.NOT_MATCH,value:"!~",line:t,column:r}):{type:i.NOT,value:"!",line:t,column:r};case"<":return a==="="?(this.advance(),{type:i.LE,value:"<=",line:t,column:r}):{type:i.LT,value:"<",line:t,column:r};case">":return a==="="?(this.advance(),{type:i.GE,value:">=",line:t,column:r}):a===">"?(this.advance(),{type:i.APPEND,value:">>",line:t,column:r}):{type:i.GT,value:">",line:t,column:r};case"&":return a==="&"?(this.advance(),{type:i.AND,value:"&&",line:t,column:r}):{type:i.IDENT,value:"&",line:t,column:r};case"|":return a==="|"?(this.advance(),{type:i.OR,value:"||",line:t,column:r}):{type:i.PIPE,value:"|",line:t,column:r};case"~":return{type:i.MATCH,value:"~",line:t,column:r};case"?":return{type:i.QUESTION,value:"?",line:t,column:r};case":":return{type:i.COLON,value:":",line:t,column:r};case",":return{type:i.COMMA,value:",",line:t,column:r};case";":return{type:i.SEMICOLON,value:";",line:t,column:r};case"(":return{type:i.LPAREN,value:"(",line:t,column:r};case")":return{type:i.RPAREN,value:")",line:t,column:r};case"{":return{type:i.LBRACE,value:"{",line:t,column:r};case"}":return{type:i.RBRACE,value:"}",line:t,column:r};case"[":return{type:i.LBRACKET,value:"[",line:t,column:r};case"]":return{type:i.RBRACKET,value:"]",line:t,column:r};case"$":return{type:i.DOLLAR,value:"$",line:t,column:r};default:return{type:i.IDENT,value:n,line:t,column:r}}}isDigit(t){return t>="0"&&t<="9"}isAlpha(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"}isAlphaNumeric(t){return this.isDigit(t)||this.isAlpha(t)}};var B=class{tokens=[];pos=0;parse(t){let r=new D(t);return this.tokens=r.tokenize(),this.pos=0,this.parseProgram()}current(){return this.tokens[this.pos]||{type:i.EOF,value:"",line:0,column:0}}advance(){let t=this.current();return this.pos<this.tokens.length&&this.pos++,t}match(...t){return t.includes(this.current().type)}check(t){return this.current().type===t}expect(t,r){if(!this.check(t)){let n=this.current();throw new Error(r||`Expected ${t}, got ${n.type} at line ${n.line}:${n.column}`)}return this.advance()}skipNewlines(){for(;this.check(i.NEWLINE);)this.advance()}skipTerminators(){for(;this.check(i.NEWLINE)||this.check(i.SEMICOLON);)this.advance()}parseProgram(){let t=[],r=[];for(this.skipNewlines();!this.check(i.EOF)&&(this.skipNewlines(),!this.check(i.EOF));)this.check(i.FUNCTION)?t.push(this.parseFunction()):r.push(this.parseRule()),this.skipTerminators();return{functions:t,rules:r}}parseFunction(){this.expect(i.FUNCTION);let t=this.expect(i.IDENT).value;this.expect(i.LPAREN);let r=[];if(!this.check(i.RPAREN))for(r.push(this.expect(i.IDENT).value);this.check(i.COMMA);)this.advance(),r.push(this.expect(i.IDENT).value);this.expect(i.RPAREN),this.skipNewlines();let n=this.parseBlock();return{name:t,params:r,body:n}}parseRule(){let t;if(this.check(i.BEGIN))this.advance(),t={type:"begin"};else if(this.check(i.END))this.advance(),t={type:"end"};else if(this.check(i.LBRACE))t=void 0;else if(this.check(i.REGEX)){let n=this.advance();if(this.check(i.AND)||this.check(i.OR)){let a={type:"binary",operator:"~",left:{type:"field",index:{type:"number",value:0}},right:{type:"regex",pattern:n.value}};t={type:"expr_pattern",expression:this.parseLogicalOrRest(a)}}else{let a={type:"regex_pattern",pattern:n.value};if(this.check(i.COMMA)){this.advance();let s;this.check(i.REGEX)?s={type:"regex_pattern",pattern:this.advance().value}:s={type:"expr_pattern",expression:this.parseExpression()},t={type:"range",start:a,end:s}}else t=a}}else{let a={type:"expr_pattern",expression:this.parseExpression()};if(this.check(i.COMMA)){this.advance();let s;this.check(i.REGEX)?s={type:"regex_pattern",pattern:this.advance().value}:s={type:"expr_pattern",expression:this.parseExpression()},t={type:"range",start:a,end:s}}else t=a}this.skipNewlines();let r;return this.check(i.LBRACE)?r=this.parseBlock():r={type:"block",statements:[{type:"print",args:[{type:"field",index:{type:"number",value:0}}]}]},{pattern:t,action:r}}parseBlock(){this.expect(i.LBRACE),this.skipNewlines();let t=[];for(;!this.check(i.RBRACE)&&!this.check(i.EOF);)t.push(this.parseStatement()),this.skipTerminators();return this.expect(i.RBRACE),{type:"block",statements:t}}parseStatement(){if(this.check(i.LBRACE))return this.parseBlock();if(this.check(i.IF))return this.parseIf();if(this.check(i.WHILE))return this.parseWhile();if(this.check(i.DO))return this.parseDoWhile();if(this.check(i.FOR))return this.parseFor();if(this.check(i.BREAK))return this.advance(),{type:"break"};if(this.check(i.CONTINUE))return this.advance(),{type:"continue"};if(this.check(i.NEXT))return this.advance(),{type:"next"};if(this.check(i.NEXTFILE))return this.advance(),{type:"nextfile"};if(this.check(i.EXIT)){this.advance();let r;return!this.check(i.NEWLINE)&&!this.check(i.SEMICOLON)&&!this.check(i.RBRACE)&&!this.check(i.EOF)&&(r=this.parseExpression()),{type:"exit",code:r}}if(this.check(i.RETURN)){this.advance();let r;return!this.check(i.NEWLINE)&&!this.check(i.SEMICOLON)&&!this.check(i.RBRACE)&&!this.check(i.EOF)&&(r=this.parseExpression()),{type:"return",value:r}}if(this.check(i.DELETE)){this.advance();let r=this.parsePrimary();if(r.type!=="array_access"&&r.type!=="variable")throw new Error("delete requires array element or array");return{type:"delete",target:r}}return this.check(i.PRINT)?this.parsePrint():this.check(i.PRINTF)?this.parsePrintf():{type:"expr_stmt",expression:this.parseExpression()}}parseIf(){this.expect(i.IF),this.expect(i.LPAREN);let t=this.parseExpression();this.expect(i.RPAREN),this.skipNewlines();let r=this.parseStatement();this.skipTerminators();let n;return this.check(i.ELSE)&&(this.advance(),this.skipNewlines(),n=this.parseStatement()),{type:"if",condition:t,consequent:r,alternate:n}}parseWhile(){this.expect(i.WHILE),this.expect(i.LPAREN);let t=this.parseExpression();this.expect(i.RPAREN),this.skipNewlines();let r=this.parseStatement();return{type:"while",condition:t,body:r}}parseDoWhile(){this.expect(i.DO),this.skipNewlines();let t=this.parseStatement();this.skipNewlines(),this.expect(i.WHILE),this.expect(i.LPAREN);let r=this.parseExpression();return this.expect(i.RPAREN),{type:"do_while",body:t,condition:r}}parseFor(){if(this.expect(i.FOR),this.expect(i.LPAREN),this.check(i.IDENT)){let s=this.advance();if(this.check(i.IN)){this.advance();let o=this.expect(i.IDENT).value;this.expect(i.RPAREN),this.skipNewlines();let l=this.parseStatement();return{type:"for_in",variable:s.value,array:o,body:l}}this.pos--}let t;this.check(i.SEMICOLON)||(t=this.parseExpression()),this.expect(i.SEMICOLON);let r;this.check(i.SEMICOLON)||(r=this.parseExpression()),this.expect(i.SEMICOLON);let n;this.check(i.RPAREN)||(n=this.parseExpression()),this.expect(i.RPAREN),this.skipNewlines();let a=this.parseStatement();return{type:"for",init:t,condition:r,update:n,body:a}}parsePrint(){this.expect(i.PRINT);let t=[];if(this.check(i.NEWLINE)||this.check(i.SEMICOLON)||this.check(i.RBRACE)||this.check(i.PIPE)||this.check(i.GT)||this.check(i.APPEND))t.push({type:"field",index:{type:"number",value:0}});else for(t.push(this.parsePrintArg());this.check(i.COMMA);)this.advance(),t.push(this.parsePrintArg());let r;return this.check(i.GT)?(this.advance(),r={redirect:">",file:this.parsePrimary()}):this.check(i.APPEND)&&(this.advance(),r={redirect:">>",file:this.parsePrimary()}),{type:"print",args:t,output:r}}parsePrintArg(){return this.lookAheadForTernary()?this.parseTernary():this.parsePrintOr()}lookAheadForTernary(){let t=0,r=this.pos;for(;r<this.tokens.length;){let n=this.tokens[r];if(n.type===i.LPAREN&&t++,n.type===i.RPAREN&&t--,n.type===i.QUESTION&&t===0)return!0;if(n.type===i.NEWLINE||n.type===i.SEMICOLON||n.type===i.RBRACE||n.type===i.COMMA||n.type===i.PIPE)return!1;r++}return!1}parsePrintOr(){let t=this.parsePrintAnd();for(;this.check(i.OR);){this.advance();let r=this.parsePrintAnd();t={type:"binary",operator:"||",left:t,right:r}}return t}parsePrintAnd(){let t=this.parsePrintIn();for(;this.check(i.AND);){this.advance();let r=this.parsePrintIn();t={type:"binary",operator:"&&",left:t,right:r}}return t}parsePrintIn(){let t=this.parsePrintMatch();if(this.check(i.IN)){this.advance();let r=String(this.expect(i.IDENT).value);return{type:"in",key:t,array:r}}return t}parsePrintMatch(){let t=this.parsePrintComparison();for(;this.match(i.MATCH,i.NOT_MATCH);){let r=this.advance().type===i.MATCH?"~":"!~",n=this.parsePrintComparison();t={type:"binary",operator:r,left:t,right:n}}return t}parsePrintComparison(){let t=this.parseConcatenation();for(;this.match(i.LT,i.LE,i.GE,i.EQ,i.NE);){let r=this.advance(),n=this.parseConcatenation();t={type:"binary",operator:{"<":"<","<=":"<=",">=":">=","==":"==","!=":"!="}[r.value],left:t,right:n}}return t}parsePrintf(){this.expect(i.PRINTF);let t=this.parsePrintArg(),r=[];for(;this.check(i.COMMA);)this.advance(),r.push(this.parsePrintArg());let n;return this.check(i.GT)?(this.advance(),n={redirect:">",file:this.parsePrimary()}):this.check(i.APPEND)&&(this.advance(),n={redirect:">>",file:this.parsePrimary()}),{type:"printf",format:t,args:r,output:n}}parseExpression(){return this.parseAssignment()}parseAssignment(){let t=this.parseTernary();if(this.match(i.ASSIGN,i.PLUS_ASSIGN,i.MINUS_ASSIGN,i.STAR_ASSIGN,i.SLASH_ASSIGN,i.PERCENT_ASSIGN,i.CARET_ASSIGN)){let r=this.advance(),n=this.parseAssignment();if(t.type!=="variable"&&t.type!=="field"&&t.type!=="array_access")throw new Error("Invalid assignment target");return{type:"assignment",operator:{"=":"=","+=":"+=","-=":"-=","*=":"*=","/=":"/=","%=":"%=","^=":"^="}[r.value],target:t,value:n}}return t}parseTernary(){let t=this.parseOr();if(this.check(i.QUESTION)){this.advance();let r=this.parseExpression();this.expect(i.COLON);let n=this.parseExpression();t={type:"ternary",condition:t,consequent:r,alternate:n}}return t}parseOr(){let t=this.parseAnd();for(;this.check(i.OR);){this.advance();let r=this.parseAnd();t={type:"binary",operator:"||",left:t,right:r}}return t}parseLogicalOrRest(t){for(t=this.parseLogicalAndRest(t);this.check(i.OR);){this.advance();let r=this.parseAnd();t={type:"binary",operator:"||",left:t,right:r}}return t}parseLogicalAndRest(t){for(;this.check(i.AND);){this.advance();let r=this.parseIn();t={type:"binary",operator:"&&",left:t,right:r}}return t}parseAnd(){let t=this.parseIn();for(;this.check(i.AND);){this.advance();let r=this.parseIn();t={type:"binary",operator:"&&",left:t,right:r}}return t}parseIn(){let t=this.parseMatch();if(this.check(i.IN)){this.advance();let r=this.expect(i.IDENT).value;return{type:"in",key:t,array:r}}return t}parseMatch(){let t=this.parseComparison();for(;this.match(i.MATCH,i.NOT_MATCH);){let r=this.advance().type===i.MATCH?"~":"!~",n=this.parseComparison();t={type:"binary",operator:r,left:t,right:n}}return t}parseComparison(){let t=this.parseConcatenation();for(;this.match(i.LT,i.LE,i.GT,i.GE,i.EQ,i.NE);){let r=this.advance(),n=this.parseConcatenation();t={type:"binary",operator:{"<":"<","<=":"<=",">":">",">=":">=","==":"==","!=":"!="}[r.value],left:t,right:n}}return t}parseConcatenation(){let t=this.parseAddSub();for(;this.canStartExpression()&&!this.isComparisonOrHigherOp();){let r=this.parseAddSub();t={type:"binary",operator:" ",left:t,right:r}}return t}canStartExpression(){return this.match(i.NUMBER,i.STRING,i.IDENT,i.DOLLAR,i.LPAREN,i.NOT,i.MINUS,i.PLUS,i.INCREMENT,i.DECREMENT)}isComparisonOrHigherOp(){return this.match(i.LT,i.LE,i.GT,i.GE,i.EQ,i.NE,i.AND,i.OR,i.QUESTION,i.MATCH,i.NOT_MATCH,i.ASSIGN,i.PLUS_ASSIGN,i.MINUS_ASSIGN,i.STAR_ASSIGN,i.SLASH_ASSIGN,i.PERCENT_ASSIGN,i.CARET_ASSIGN,i.COMMA,i.SEMICOLON,i.NEWLINE,i.RBRACE,i.RPAREN,i.RBRACKET,i.COLON,i.PIPE,i.APPEND,i.IN)}parseAddSub(){let t=this.parseMulDiv();for(;this.match(i.PLUS,i.MINUS);){let r=this.advance().value,n=this.parseMulDiv();t={type:"binary",operator:r,left:t,right:n}}return t}parseMulDiv(){let t=this.parseUnary();for(;this.match(i.STAR,i.SLASH,i.PERCENT);){let r=this.advance(),n=this.parseUnary();t={type:"binary",operator:{"*":"*","/":"/","%":"%"}[r.value],left:t,right:n}}return t}parseUnary(){if(this.check(i.INCREMENT)){this.advance();let t=this.parseUnary();return t.type!=="variable"&&t.type!=="field"&&t.type!=="array_access"?{type:"unary",operator:"+",operand:{type:"unary",operator:"+",operand:t}}:{type:"pre_increment",operand:t}}if(this.check(i.DECREMENT)){this.advance();let t=this.parseUnary();return t.type!=="variable"&&t.type!=="field"&&t.type!=="array_access"?{type:"unary",operator:"-",operand:{type:"unary",operator:"-",operand:t}}:{type:"pre_decrement",operand:t}}if(this.match(i.NOT,i.MINUS,i.PLUS)){let t=this.advance().value,r=this.parseUnary();return{type:"unary",operator:t,operand:r}}return this.parsePower()}parsePower(){let t=this.parsePostfix();if(this.check(i.CARET)){this.advance();let r=this.parsePower();t={type:"binary",operator:"^",left:t,right:r}}return t}parsePostfix(){let t=this.parsePrimary();if(this.check(i.INCREMENT)){if(this.advance(),t.type!=="variable"&&t.type!=="field"&&t.type!=="array_access")throw new Error("Invalid increment operand");return{type:"post_increment",operand:t}}if(this.check(i.DECREMENT)){if(this.advance(),t.type!=="variable"&&t.type!=="field"&&t.type!=="array_access")throw new Error("Invalid decrement operand");return{type:"post_decrement",operand:t}}return t}parsePrimary(){if(this.check(i.NUMBER))return{type:"number",value:this.advance().value};if(this.check(i.STRING))return{type:"string",value:this.advance().value};if(this.check(i.REGEX))return{type:"regex",pattern:this.advance().value};if(this.check(i.DOLLAR))return this.advance(),{type:"field",index:this.parsePrimary()};if(this.check(i.LPAREN)){this.advance();let t=this.parseExpression();if(this.check(i.COMMA)){let r=[t];for(;this.check(i.COMMA);)this.advance(),r.push(this.parseExpression());return this.expect(i.RPAREN),{type:"tuple",elements:r}}return this.expect(i.RPAREN),t}if(this.check(i.GETLINE)){this.advance();let t,r;return this.check(i.IDENT)&&(t=this.advance().value),this.check(i.LT)&&(this.advance(),r=this.parsePrimary()),{type:"getline",variable:t,file:r}}if(this.check(i.IDENT)){let t=this.advance().value;if(this.check(i.LPAREN)){this.advance();let r=[];if(!this.check(i.RPAREN))for(r.push(this.parseExpression());this.check(i.COMMA);)this.advance(),r.push(this.parseExpression());return this.expect(i.RPAREN),{type:"call",name:t,args:r}}if(this.check(i.LBRACKET)){this.advance();let r=[this.parseExpression()];for(;this.check(i.COMMA);)this.advance(),r.push(this.parseExpression());this.expect(i.RBRACKET);let n;if(r.length===1)n=r[0];else{n=r[0];for(let a=1;a<r.length;a++)n={type:"binary",operator:" ",left:{type:"binary",operator:" ",left:n,right:{type:"variable",name:"SUBSEP"}},right:r[a]}}return{type:"array_access",array:t,key:n}}return{type:"variable",name:t}}throw new Error(`Unexpected token: ${this.current().type} at line ${this.current().line}:${this.current().column}`)}};var it={name:"awk",summary:"pattern scanning and text processing language",usage:"awk [OPTIONS] 'PROGRAM' [FILE...]",options:["-F FS use FS as field separator","-v VAR=VAL assign VAL to variable VAR"," --help display this help and exit"]},Ht={name:"awk",async execute(e,t){if(Q(e))return K(it);let r=/\s+/,n=" ",a={},s=0;for(let h=0;h<e.length;h++){let f=e[h];if(f==="-F"&&h+1<e.length)n=se(e[++h]),r=ae(n),s=h+1;else if(f.startsWith("-F"))n=se(f.slice(2)),r=ae(n),s=h+1;else if(f==="-v"&&h+1<e.length){let R=e[++h],G=R.indexOf("=");if(G>0){let k=R.slice(0,G),oe=R.slice(G+1);a[k]=oe}s=h+1}else{if(f.startsWith("--"))return U("awk",f);if(f.startsWith("-")&&f.length>1){let R=f[1];if(R!=="F"&&R!=="v")return U("awk",`-${R}`);s=h+1}else if(!f.startsWith("-")){s=h;break}}}if(s>=e.length)return{stdout:"",stderr:`awk: missing program
14
+ `,exitCode:1};let o=e[s],l=e.slice(s+1),u=new B,m;try{m=u.parse(o)}catch(h){return{stdout:"",stderr:`awk: ${h instanceof Error?h.message:String(h)}
15
+ `,exitCode:1}}let N={readFile:t.fs.readFile.bind(t.fs),writeFile:t.fs.writeFile.bind(t.fs),appendFile:async(h,f)=>{try{let R=await t.fs.readFile(h);await t.fs.writeFile(h,R+f)}catch{await t.fs.writeFile(h,f)}},resolvePath:t.fs.resolvePath.bind(t.fs)},c=x({fieldSep:r,maxIterations:t.limits?.maxAwkIterations,fs:N,cwd:t.cwd});c.FS=n,c.vars={...a},c.ARGC=l.length+1,c.ARGV={0:"awk"};for(let h=0;h<l.length;h++)c.ARGV[String(h+1)]=l[h];let d=new _(c);d.execute(m);try{if(await d.executeBegin(),c.shouldExit)return{stdout:d.getOutput(),stderr:"",exitCode:d.getExitCode()};let h=[];if(l.length>0)for(let f of l)try{let R=t.fs.resolvePath(t.cwd,f),k=(await t.fs.readFile(R)).split(`
16
+ `);k.length>0&&k[k.length-1]===""&&k.pop(),h.push({filename:f,lines:k})}catch{return{stdout:"",stderr:`awk: ${f}: No such file or directory
17
+ `,exitCode:1}}else{let f=t.stdin.split(`
18
+ `);f.length>0&&f[f.length-1]===""&&f.pop(),h.push({filename:"",lines:f})}for(let f of h){for(c.FILENAME=f.filename,c.FNR=0,c.lines=f.lines,c.lineIndex=-1,c.shouldNextFile=!1;c.lineIndex<f.lines.length-1&&(c.lineIndex++,await d.executeLine(f.lines[c.lineIndex]),!(c.shouldExit||c.shouldNextFile)););if(c.shouldExit)break}return c.shouldExit||await d.executeEnd(),{stdout:d.getOutput(),stderr:"",exitCode:d.getExitCode()}}catch(h){let f=h instanceof Error?h.message:String(h),R=h instanceof g?g.EXIT_CODE:2;return{stdout:d.getOutput(),stderr:`awk: ${f}
19
+ `,exitCode:R}}}};function se(e){return e.replace(/\\t/g," ").replace(/\\n/g,`
20
+ `).replace(/\\r/g,"\r").replace(/\\\\/g,"\\")}function ae(e){if(e===" ")return/\s+/;if(/[[\](){}.*+?^$|\\]/.test(e))try{return new RegExp(e)}catch{return new RegExp(le(e))}return new RegExp(le(e))}function le(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}export{Ht as awkCommand2};
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ import{a as f}from"./chunk-TA7RUHGQ.js";import{a as l,b as u}from"./chunk-GTNBSMZR.js";import"./chunk-SJXDWN5X.js";var g={name:"base64",summary:"base64 encode/decode data and print to standard output",usage:"base64 [OPTION]... [FILE]",options:["-d, --decode decode data","-w, --wrap=COLS wrap encoded lines after COLS character (default 76, 0 to disable)"," --help display this help and exit"]},m={decode:{short:"d",long:"decode",type:"boolean"},wrap:{short:"w",long:"wrap",type:"number",default:76}};async function p(o,r,n){if(r.length===0||r.length===1&&r[0]==="-")return{ok:!0,data:new TextEncoder().encode(o.stdin)};let s=[];for(let e of r){if(e==="-"){s.push(new TextEncoder().encode(o.stdin));continue}try{let t=o.fs.resolvePath(o.cwd,e),a=await o.fs.readFileBuffer(t);s.push(a)}catch{return{ok:!1,error:{stdout:"",stderr:`${n}: ${e}: No such file or directory
3
+ `,exitCode:1}}}}let c=s.reduce((e,t)=>e+t.length,0),i=new Uint8Array(c),d=0;for(let e of s)i.set(e,d),d+=e.length;return{ok:!0,data:i}}var x={name:"base64",async execute(o,r){if(u(o))return l(g);let n=f("base64",o,m);if(!n.ok)return n.error;let s=n.result.flags.decode,c=n.result.flags.wrap,i=n.result.positional;try{if(s){let t=await p(r,i,"base64");if(!t.ok)return t.error;let h=new TextDecoder().decode(t.data).replace(/\s/g,""),w=Uint8Array.from(atob(h),b=>b.charCodeAt(0));return{stdout:new TextDecoder().decode(w),stderr:"",exitCode:0}}let d=await p(r,i,"base64");if(!d.ok)return d.error;let e=btoa(String.fromCharCode(...d.data));if(c>0){let t=[];for(let a=0;a<e.length;a+=c)t.push(e.slice(a,a+c));e=t.join(`
4
+ `)+(e.length>0?`
5
+ `:"")}return{stdout:e,stderr:"",exitCode:0}}catch{return{stdout:"",stderr:`base64: invalid input
6
+ `,exitCode:1}}}};export{x as base64Command};
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+ import{b as p}from"./chunk-J7MJV6WO.js";import{a as l}from"./chunk-TA7RUHGQ.js";import{a as c,b as i}from"./chunk-GTNBSMZR.js";import"./chunk-SJXDWN5X.js";var b={name:"base64",summary:"base64 encode/decode data and print to standard output",usage:"base64 [OPTION]... [FILE]",options:["-d, --decode decode data","-w, --wrap=COLS wrap encoded lines after COLS character (default 76, 0 to disable)"," --help display this help and exit"]},g={decode:{short:"d",long:"decode",type:"boolean"},wrap:{short:"w",long:"wrap",type:"number",default:76}},x={name:"base64",async execute(d,u){if(i(d))return c(b);let e=l("base64",d,g);if(!e.ok)return e.error;let f=e.result.flags.decode,s=e.result.flags.wrap,m=e.result.positional,a=await p(u,m,{cmdName:"base64"});if(!a.ok)return a.error;let n=a.content;try{if(f){let r=n.replace(/\s/g,"");return{stdout:Buffer.from(r,"base64").toString("utf-8"),stderr:"",exitCode:0}}let t=Buffer.from(n).toString("base64");if(s>0){let r=[];for(let o=0;o<t.length;o+=s)r.push(t.slice(o,o+s));t=r.join(`
3
+ `)+(t.length>0?`
4
+ `:"")}return{stdout:t,stderr:"",exitCode:0}}catch{return{stdout:"",stderr:`base64: invalid input
5
+ `,exitCode:1}}}};export{x as base64Command};
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ import{a as r,b as m}from"./chunk-GTNBSMZR.js";import"./chunk-SJXDWN5X.js";var p={name:"basename",summary:"strip directory and suffix from filenames",usage:`basename NAME [SUFFIX]
3
+ basename OPTION... NAME...`,options:["-a, --multiple support multiple arguments","-s, --suffix=SUFFIX remove a trailing SUFFIX"," --help display this help and exit"]},c={name:"basename",async execute(n,u){if(m(n))return r(p);let i=!1,s="",a=[];for(let t=0;t<n.length;t++){let e=n[t];e==="-a"||e==="--multiple"?i=!0:e==="-s"&&t+1<n.length?(s=n[++t],i=!0):e.startsWith("--suffix=")?(s=e.slice(9),i=!0):e.startsWith("-")||a.push(e)}if(a.length===0)return{stdout:"",stderr:`basename: missing operand
4
+ `,exitCode:1};!i&&a.length>=2&&(s=a.pop()??"");let o=[];for(let t of a){let e=t.replace(/\/+$/,""),l=e.split("/").pop()||e;s&&l.endsWith(s)&&(l=l.slice(0,-s.length)),o.push(l)}return{stdout:`${o.join(`
5
+ `)}
6
+ `,stderr:"",exitCode:0}}};export{c as basenameCommand};
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ import{a as l,b as d}from"./chunk-GTNBSMZR.js";import"./chunk-SJXDWN5X.js";var m={name:"bash",summary:"execute shell commands or scripts",usage:"bash [OPTIONS] [SCRIPT_FILE] [ARGUMENTS...]",options:["-c COMMAND execute COMMAND string"," --help display this help and exit"],notes:["Without -c, reads and executes commands from SCRIPT_FILE.","Arguments are passed as $1, $2, etc. to the script.",'$0 is set to the script name (or "bash" with -c).']},b={name:"bash",async execute(t,e){if(d(t))return l(m);if(t[0]==="-c"&&t.length>=2){let o=t[1],s=t[2]||"bash",i=t.slice(3);return h(o,s,i,e)}if(t.length===0)return{stdout:"",stderr:"",exitCode:0};let n=t[0],c=t.slice(1);try{let o=e.fs.resolvePath(e.cwd,n),s=await e.fs.readFile(o);return h(s,n,c,e)}catch{return{stdout:"",stderr:`bash: ${n}: No such file or directory
3
+ `,exitCode:127}}}},w={name:"sh",async execute(t,e){if(d(t))return l({...m,name:"sh",summary:"execute shell commands or scripts (POSIX shell)"});if(t[0]==="-c"&&t.length>=2){let o=t[1],s=t[2]||"sh",i=t.slice(3);return h(o,s,i,e)}if(t.length===0)return{stdout:"",stderr:"",exitCode:0};let n=t[0],c=t.slice(1);try{let o=e.fs.resolvePath(e.cwd,n),s=await e.fs.readFile(o);return h(s,n,c,e)}catch{return{stdout:"",stderr:`sh: ${n}: No such file or directory
4
+ `,exitCode:127}}}};async function h(t,e,n,c){if(!c.exec)return{stdout:"",stderr:`bash: internal error: exec function not available
5
+ `,exitCode:1};let o={0:e,"#":String(n.length),"@":n.join(" "),"*":n.join(" ")};n.forEach((r,a)=>{o[String(a+1)]=r});let s=t;if(s.startsWith("#!")){let r=s.indexOf(`
6
+ `);r!==-1&&(s=s.slice(r+1))}let i=s.split(`
7
+ `),u=[];for(let r of i){let a=r.trim();a&&!a.startsWith("#")&&u.push(a)}let f=u.join("; ");return await c.exec(f,{env:o,cwd:c.cwd})}export{b as bashCommand,w as shCommand};
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ import{a as p}from"./chunk-J7MJV6WO.js";import{a as d}from"./chunk-TA7RUHGQ.js";import{a as c,b as m}from"./chunk-GTNBSMZR.js";import"./chunk-SJXDWN5X.js";var f={name:"cat",summary:"concatenate files and print on the standard output",usage:"cat [OPTION]... [FILE]...",options:["-n, --number number all output lines"," --help display this help and exit"]},b={number:{short:"n",long:"number",type:"boolean"}},w={name:"cat",async execute(t,r){if(m(t))return c(f);let e=d("cat",t,b);if(!e.ok)return e.error;let s=e.result.flags.number,o=e.result.positional,a=await p(r,o,{cmdName:"cat",allowStdinMarker:!0,stopOnError:!1}),n="",i=1;for(let{content:l}of a.files)if(s){let u=h(l,i);n+=u.content,i=u.nextLineNumber}else n+=l;return{stdout:n,stderr:a.stderr,exitCode:a.exitCode}}};function h(t,r){let e=t.split(`
3
+ `),s=t.endsWith(`
4
+ `),o=s?e.slice(0,-1):e;return{content:o.map((n,i)=>`${String(r+i).padStart(6," ")} ${n}`).join(`
5
+ `)+(s?`
6
+ `:""),nextLineNumber:r+o.length}}export{w as catCommand};
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ import{a as h,b as m}from"./chunk-GTNBSMZR.js";import"./chunk-SJXDWN5X.js";var v={name:"chmod",summary:"change file mode bits",usage:"chmod [OPTIONS] MODE FILE...",options:["-R change files recursively","-v output a diagnostic for every file processed"," --help display this help and exit"]},C={name:"chmod",async execute(o,s){if(m(o))return h(v);if(o.length<2)return{stdout:"",stderr:`chmod: missing operand
3
+ `,exitCode:1};let r=!1,n=!1,e=0;for(;e<o.length&&o[e].startsWith("-");){let t=o[e];if(t==="-R"||t==="--recursive")r=!0,e++;else if(t==="-v"||t==="--verbose")n=!0,e++;else if(t==="--"){e++;break}else{if(/^[+-]?[rwxugo]+/.test(t)||/^\d+$/.test(t))break;if(/^-[Rv]+$/.test(t)){t.includes("R")&&(r=!0),t.includes("v")&&(n=!0),e++;continue}return{stdout:"",stderr:`chmod: invalid option -- '${t.slice(1)}'
4
+ `,exitCode:1}}}if(o.length-e<2)return{stdout:"",stderr:`chmod: missing operand
5
+ `,exitCode:1};let a=o[e],f=o.slice(e+1),i;try{i=$(a)}catch{return{stdout:"",stderr:`chmod: invalid mode: '${a}'
6
+ `,exitCode:1}}let c="",d="",l=!1;for(let t of f){let u=s.fs.resolvePath(s.cwd,t);try{if(await s.fs.chmod(u,i),n&&(c+=`mode of '${t}' changed to ${i.toString(8).padStart(4,"0")}
7
+ `),r&&(await s.fs.stat(u)).isDirectory){let w=await p(s,u,i,n);c+=w}}catch{d+=`chmod: cannot access '${t}': No such file or directory
8
+ `,l=!0}}return{stdout:c,stderr:d,exitCode:l?1:0}}};async function p(o,s,r,n){let e="",a=await o.fs.readdir(s);for(let f of a){let i=s==="/"?`/${f}`:`${s}/${f}`;await o.fs.chmod(i,r),n&&(e+=`mode of '${i}' changed to ${r.toString(8).padStart(4,"0")}
9
+ `),(await o.fs.stat(i)).isDirectory&&(e+=await p(o,i,r,n))}return e}function $(o){if(/^[0-7]+$/.test(o))return parseInt(o,8);let s=420,r=o.split(",");for(let n of r){let e=n.match(/^([ugoa]*)([+\-=])([rwxXst]*)$/);if(!e)throw new Error(`Invalid mode: ${o}`);let a=e[1]||"a",f=e[2],i=e[3];(a==="a"||a==="")&&(a="ugo");let c=0;i.includes("r")&&(c|=4),i.includes("w")&&(c|=2),(i.includes("x")||i.includes("X"))&&(c|=1);for(let d of a){let l=0;d==="u"?l=6:d==="g"?l=3:d==="o"&&(l=0);let t=c<<l;f==="+"?s|=t:f==="-"?s&=~t:f==="="&&(s&=~(7<<l),s|=t)}}return s}export{C as chmodCommand};
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ import{a as F,b as k,c as C}from"./chunk-GTNBSMZR.js";var D={sha1:"SHA-1",sha256:"SHA-256"};function S(f){let d=new TextEncoder().encode(f);function $(r,b){return r<<b|r>>>32-b}let y=new Uint32Array([3614090360,3905402710,606105819,3250441966,4118548399,1200080426,2821735955,4249261313,1770035416,2336552879,4294925233,2304563134,1804603682,4254626195,2792965006,1236535329,4129170786,3225465664,643717713,3921069994,3593408605,38016083,3634488961,3889429448,568446438,3275163606,4107603335,1163531501,2850285829,4243563512,1735328473,2368359562,4294588738,2272392833,1839030562,4259657740,2763975236,1272893353,4139469664,3200236656,681279174,3936430074,3572445317,76029189,3654602809,3873151461,530742520,3299628645,4096336452,1126891415,2878612391,4237533241,1700485571,2399980690,4293915773,2240044497,1873313359,4264355552,2734768916,1309151649,4149444226,3174756917,718787259,3951481745]),n=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],m=d.length*8,l=(d.length%64<56?56:120)-d.length%64,o=new Uint8Array(d.length+l+8);o.set(d),o[d.length]=128;let A=new DataView(o.buffer);A.setUint32(o.length-8,m>>>0,!0),A.setUint32(o.length-4,Math.floor(m/4294967296),!0);let e=1732584193,a=4023233417,i=2562383102,u=271733878;for(let r=0;r<o.length;r+=64){let b=new Uint32Array(16);for(let t=0;t<16;t++)b[t]=A.getUint32(r+t*4,!0);let w=e,c=a,s=i,x=u;for(let t=0;t<64;t++){let p,U;t<16?(p=c&s|~c&x,U=t):t<32?(p=x&c|~x&s,U=(5*t+1)%16):t<48?(p=c^s^x,U=(3*t+5)%16):(p=s^(c|~x),U=7*t%16),p=p+w+y[t]+b[U]>>>0,w=x,x=s,s=c,c=c+$(p,n[t])>>>0}e=e+w>>>0,a=a+c>>>0,i=i+s>>>0,u=u+x>>>0}let h=new Uint8Array(16);return new DataView(h.buffer).setUint32(0,e,!0),new DataView(h.buffer).setUint32(4,a,!0),new DataView(h.buffer).setUint32(8,i,!0),new DataView(h.buffer).setUint32(12,u,!0),Array.from(h).map(r=>r.toString(16).padStart(2,"0")).join("")}async function L(f,g){if(f==="md5")return S(g);let $=new TextEncoder().encode(g),y=await globalThis.crypto.subtle.digest(D[f],$);return Array.from(new Uint8Array(y)).map(n=>n.toString(16).padStart(2,"0")).join("")}function H(f,g,d){let $={name:f,summary:d,usage:`${f} [OPTION]... [FILE]...`,options:["-c, --check read checksums from FILEs and check them"," --help display this help and exit"]};return{name:f,async execute(y,n){if(k(y))return F($);let m=!1,l=[];for(let e of y)if(e==="-c"||e==="--check")m=!0;else if(!(e==="-b"||e==="-t"||e==="--binary"||e==="--text")){if(e.startsWith("-")&&e!=="-")return C(f,e);l.push(e)}if(l.length===0&&l.push("-"),m){let e=0,a="";for(let i of l){let u=i==="-"?n.stdin:await n.fs.readFile(n.fs.resolvePath(n.cwd,i)).catch(()=>null);if(u===null)return{stdout:"",stderr:`${f}: ${i}: No such file or directory
3
+ `,exitCode:1};for(let h of u.split(`
4
+ `)){let r=h.match(/^([a-fA-F0-9]+)\s+[* ]?(.+)$/);if(!r)continue;let[,b,w]=r;try{let c=await n.fs.readFile(n.fs.resolvePath(n.cwd,w)),s=await L(g,c)===b.toLowerCase();a+=`${w}: ${s?"OK":"FAILED"}
5
+ `,s||e++}catch{a+=`${w}: FAILED open or read
6
+ `,e++}}}return e>0&&(a+=`${f}: WARNING: ${e} computed checksum${e>1?"s":""} did NOT match
7
+ `),{stdout:a,stderr:"",exitCode:e>0?1:0}}let o="",A=0;for(let e of l)try{let a=e==="-"?n.stdin:await n.fs.readFile(n.fs.resolvePath(n.cwd,e));o+=`${await L(g,a)} ${e}
8
+ `}catch{o+=`${f}: ${e}: No such file or directory
9
+ `,A=1}return{stdout:o,stderr:"",exitCode:A}}}}export{H as a};
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ import{a as U,b as m,c as F}from"./chunk-GTNBSMZR.js";var C={sha1:"SHA-1",sha256:"SHA-256"};function L(n){function h(a,u){return a<<u|a>>>32-u}let p=new Uint32Array([3614090360,3905402710,606105819,3250441966,4118548399,1200080426,2821735955,4249261313,1770035416,2336552879,4294925233,2304563134,1804603682,4254626195,2792965006,1236535329,4129170786,3225465664,643717713,3921069994,3593408605,38016083,3634488961,3889429448,568446438,3275163606,4107603335,1163531501,2850285829,4243563512,1735328473,2368359562,4294588738,2272392833,1839030562,4259657740,2763975236,1272893353,4139469664,3200236656,681279174,3936430074,3572445317,76029189,3654602809,3873151461,530742520,3299628645,4096336452,1126891415,2878612391,4237533241,1700485571,2399980690,4293915773,2240044497,1873313359,4264355552,2734768916,1309151649,4149444226,3174756917,718787259,3951481745]),g=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],A=n.length*8,o=(n.length%64<56?56:120)-n.length%64,s=new Uint8Array(n.length+o+8);s.set(n),s[n.length]=128;let d=new DataView(s.buffer);d.setUint32(s.length-8,A>>>0,!0),d.setUint32(s.length-4,Math.floor(A/4294967296),!0);let b=1732584193,l=4023233417,w=2562383102,e=271733878;for(let a=0;a<s.length;a+=64){let u=new Uint32Array(16);for(let t=0;t<16;t++)u[t]=d.getUint32(a+t*4,!0);let $=b,r=l,x=w,c=e;for(let t=0;t<64;t++){let i,y;t<16?(i=r&x|~r&c,y=t):t<32?(i=c&r|~c&x,y=(5*t+1)%16):t<48?(i=r^x^c,y=(3*t+5)%16):(i=x^(r|~c),y=7*t%16),i=i+$+p[t]+u[y]>>>0,$=c,c=x,x=r,r=r+h(i,g[t])>>>0}b=b+$>>>0,l=l+r>>>0,w=w+x>>>0,e=e+c>>>0}let f=new Uint8Array(16);return new DataView(f.buffer).setUint32(0,b,!0),new DataView(f.buffer).setUint32(4,l,!0),new DataView(f.buffer).setUint32(8,w,!0),new DataView(f.buffer).setUint32(12,e,!0),Array.from(f).map(a=>a.toString(16).padStart(2,"0")).join("")}async function k(n,h){if(n==="md5")return L(h);let p=await globalThis.crypto.subtle.digest(C[n],new Uint8Array(h).buffer);return Array.from(new Uint8Array(p)).map(g=>g.toString(16).padStart(2,"0")).join("")}function S(n,h,p){let g={name:n,summary:p,usage:`${n} [OPTION]... [FILE]...`,options:["-c, --check read checksums from FILEs and check them"," --help display this help and exit"]};return{name:n,async execute(A,o){if(m(A))return U(g);let s=!1,d=[];for(let e of A)if(e==="-c"||e==="--check")s=!0;else if(!(e==="-b"||e==="-t"||e==="--binary"||e==="--text")){if(e.startsWith("-")&&e!=="-")return F(n,e);d.push(e)}d.length===0&&d.push("-");let b=async e=>{if(e==="-")return new TextEncoder().encode(o.stdin);try{return await o.fs.readFileBuffer(o.fs.resolvePath(o.cwd,e))}catch{return null}};if(s){let e=0,f="";for(let a of d){let u=a==="-"?o.stdin:await o.fs.readFile(o.fs.resolvePath(o.cwd,a)).catch(()=>null);if(u===null)return{stdout:"",stderr:`${n}: ${a}: No such file or directory
3
+ `,exitCode:1};for(let $ of u.split(`
4
+ `)){let r=$.match(/^([a-fA-F0-9]+)\s+[* ]?(.+)$/);if(!r)continue;let[,x,c]=r,t=await b(c);if(t===null){f+=`${c}: FAILED open or read
5
+ `,e++;continue}let i=await k(h,t)===x.toLowerCase();f+=`${c}: ${i?"OK":"FAILED"}
6
+ `,i||e++}}return e>0&&(f+=`${n}: WARNING: ${e} computed checksum${e>1?"s":""} did NOT match
7
+ `),{stdout:f,stderr:"",exitCode:e>0?1:0}}let l="",w=0;for(let e of d){let f=await b(e);if(f===null){l+=`${n}: ${e}: No such file or directory
8
+ `,w=1;continue}l+=`${await k(h,f)} ${e}
9
+ `}return{stdout:l,stderr:"",exitCode:w}}}}export{S as a};
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ function i(t,a,e){let s=t;e>=0&&s.length>e&&(s=s.slice(0,e));let n=Math.abs(a);return n>s.length&&(a<0?s=s.padEnd(n," "):s=s.padStart(n," ")),s}function c(t,a){let e=a,s=0,n=-1,l=!1;for(e<t.length&&t[e]==="-"&&(l=!0,e++);e<t.length&&/\d/.test(t[e]);)s=s*10+parseInt(t[e],10),e++;if(e<t.length&&t[e]===".")for(e++,n=0;e<t.length&&/\d/.test(t[e]);)n=n*10+parseInt(t[e],10),e++;return l&&s>0&&(s=-s),[s,n,e-a]}function h(t){let a="",e=0;for(;e<t.length;)if(t[e]==="\\"&&e+1<t.length)switch(t[e+1]){case"n":a+=`
3
+ `,e+=2;break;case"t":a+=" ",e+=2;break;case"r":a+="\r",e+=2;break;case"\\":a+="\\",e+=2;break;case"a":a+="\x07",e+=2;break;case"b":a+="\b",e+=2;break;case"f":a+="\f",e+=2;break;case"v":a+="\v",e+=2;break;case"e":case"E":a+="\x1B",e+=2;break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":{let n="",l=e+1;for(;l<t.length&&l<e+4&&/[0-7]/.test(t[l]);)n+=t[l],l++;a+=String.fromCharCode(parseInt(n,8)),e=l;break}case"x":e+3<t.length&&/[0-9a-fA-F]{2}/.test(t.slice(e+2,e+4))?(a+=String.fromCharCode(parseInt(t.slice(e+2,e+4),16)),e+=4):(a+=t[e],e++);break;case"u":{let n="",l=e+2;for(;l<t.length&&l<e+6&&/[0-9a-fA-F]/.test(t[l]);)n+=t[l],l++;n?(a+=String.fromCodePoint(parseInt(n,16)),e=l):(a+="\\u",e+=2);break}case"U":{let n="",l=e+2;for(;l<t.length&&l<e+10&&/[0-9a-fA-F]/.test(t[l]);)n+=t[l],l++;n?(a+=String.fromCodePoint(parseInt(n,16)),e=l):(a+="\\U",e+=2);break}default:a+=t[e],e++}else a+=t[e],e++;return a}export{i as a,c as b,h as c};
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ var g=Object.create;var f=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var m=(a=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(b,c)=>(typeof require<"u"?require:b)[c]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});var n=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports);var l=(a,b,c,e)=>{if(b&&typeof b=="object"||typeof b=="function")for(let d of i(b))!k.call(a,d)&&d!==c&&f(a,d,{get:()=>b[d],enumerable:!(e=h(b,d))||e.enumerable});return a};var o=(a,b,c)=>(c=a!=null?g(j(a)):{},l(b||!a||!a.__esModule?f(c,"default",{value:a,enumerable:!0}):c,a));export{m as a,n as b,o as c};
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import{a as e,b as r}from"./chunk-GTNBSMZR.js";import"./chunk-SJXDWN5X.js";var t={name:"clear",summary:"clear the terminal screen",usage:"clear [OPTIONS]",options:[" --help display this help and exit"]},s={name:"clear",async execute(a,c){return r(a)?e(t):{stdout:"\x1B[2J\x1B[H",stderr:"",exitCode:0}}};export{s as clearCommand};
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env node
2
+ import{a as g,b as $,c as y}from"./chunk-GTNBSMZR.js";import"./chunk-SJXDWN5X.js";var x={name:"comm",summary:"compare two sorted files line by line",usage:"comm [OPTION]... FILE1 FILE2",options:["-1 suppress column 1 (lines unique to FILE1)","-2 suppress column 2 (lines unique to FILE2)","-3 suppress column 3 (lines that appear in both files)"," --help display this help and exit"]},I={name:"comm",async execute(p,c){if($(p))return g(x);let o=!1,i=!1,f=!1,l=[];for(let e of p)if(e==="-1")o=!0;else if(e==="-2")i=!0;else if(e==="-3")f=!0;else if(e==="-12"||e==="-21")o=!0,i=!0;else if(e==="-13"||e==="-31")o=!0,f=!0;else if(e==="-23"||e==="-32")i=!0,f=!0;else if(e==="-123"||e==="-132"||e==="-213"||e==="-231"||e==="-312"||e==="-321")o=!0,i=!0,f=!0;else{if(e.startsWith("-")&&e!=="-")return y("comm",e);l.push(e)}if(l.length!==2)return{stdout:"",stderr:`comm: missing operand
3
+ Try 'comm --help' for more information.
4
+ `,exitCode:1};let m=async e=>{if(e==="-")return c.stdin;try{let F=c.fs.resolvePath(c.cwd,e);return await c.fs.readFile(F)}catch{return null}},a=await m(l[0]);if(a===null)return{stdout:"",stderr:`comm: ${l[0]}: No such file or directory
5
+ `,exitCode:1};let h=await m(l[1]);if(h===null)return{stdout:"",stderr:`comm: ${l[1]}: No such file or directory
6
+ `,exitCode:1};let t=a.split(`
7
+ `),s=h.split(`
8
+ `);t.length>0&&t[t.length-1]===""&&t.pop(),s.length>0&&s[s.length-1]===""&&s.pop();let n=0,r=0,u="",d=o?"":" ",w=(o?"":" ")+(i?"":" ");for(;n<t.length||r<s.length;)n>=t.length?(i||(u+=`${d}${s[r]}
9
+ `),r++):r>=s.length?(o||(u+=`${t[n]}
10
+ `),n++):t[n]<s[r]?(o||(u+=`${t[n]}
11
+ `),n++):t[n]>s[r]?(i||(u+=`${d}${s[r]}
12
+ `),r++):(f||(u+=`${w}${t[n]}
13
+ `),n++,r++);return{stdout:u,stderr:"",exitCode:0}}};export{I as commCommand};
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ import{a as m}from"./chunk-TA7RUHGQ.js";import{a as $}from"./chunk-4VDEBYW7.js";import{a as g,b as y}from"./chunk-GTNBSMZR.js";import"./chunk-SJXDWN5X.js";var D={name:"cp",summary:"copy files and directories",usage:"cp [OPTION]... SOURCE... DEST",options:["-r, -R, --recursive copy directories recursively","-n, --no-clobber do not overwrite an existing file","-p, --preserve preserve file attributes","-v, --verbose explain what is being done"," --help display this help and exit"]},E={recursive:{short:"r",long:"recursive",type:"boolean"},recursiveUpper:{short:"R",type:"boolean"},noClobber:{short:"n",long:"no-clobber",type:"boolean"},preserve:{short:"p",long:"preserve",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},R={name:"cp",async execute(f,e){if(y(f))return g(D);let t=m("cp",f,E);if(!t.ok)return t.error;let u=t.result.flags.recursive||t.result.flags.recursiveUpper,w=t.result.flags.noClobber,C=t.result.flags.preserve,P=t.result.flags.verbose,a=t.result.positional;if(a.length<2)return{stdout:"",stderr:`cp: missing destination file operand
3
+ `,exitCode:1};let d=a.pop()??"",h=a,o=e.fs.resolvePath(e.cwd,d),v="",n="",l=0,p=!1;try{p=(await e.fs.stat(o)).isDirectory}catch{}if(h.length>1&&!p)return{stdout:"",stderr:`cp: target '${d}' is not a directory
4
+ `,exitCode:1};for(let r of h)try{let i=e.fs.resolvePath(e.cwd,r),s=await e.fs.stat(i),c=o;if(p){let b=r.split("/").pop()||r;c=o==="/"?`/${b}`:`${o}/${b}`}if(s.isDirectory&&!u){n+=`cp: -r not specified; omitting directory '${r}'
5
+ `,l=1;continue}if(w)try{await e.fs.stat(c);continue}catch{}await e.fs.cp(i,c,{recursive:u}),P&&(v+=`'${r}' -> '${c}'
6
+ `)}catch(i){let s=$(i);s.includes("ENOENT")||s.includes("no such file")?n+=`cp: cannot stat '${r}': No such file or directory
7
+ `:n+=`cp: cannot copy '${r}': ${s}
8
+ `,l=1}return{stdout:v,stderr:n,exitCode:l}}};export{R as cpCommand};
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env node
2
+ import{a as b}from"./chunk-4VDEBYW7.js";import{a as T,b as y,c as f}from"./chunk-GTNBSMZR.js";import"./chunk-SJXDWN5X.js";function u(s){let t=s.indexOf("=");if(t>=0){let r=s.slice(0,t),e=s.slice(t+1);return r?`${encodeURIComponent(r)}=${encodeURIComponent(e)}`:encodeURIComponent(e)}return encodeURIComponent(s)}function c(s){let t=s.indexOf("=");if(t<0)return null;let r=s.slice(0,t),e=s.slice(t+1),i,a,o=e.match(/;type=([^;]+)$/);o&&(a=o[1],e=e.slice(0,-o[0].length));let n=e.match(/;filename=([^;]+)/);return n&&(i=n[1],e=e.replace(n[0],"")),(e.startsWith("@")||e.startsWith("<"))&&(i=i??e.slice(1).split("/").pop()),{name:r,value:e,filename:i,contentType:a}}function w(s,t){let r=`----CurlFormBoundary${Date.now().toString(36)}`,e=[];for(let i of s){let a=i.value;if(a.startsWith("@")||a.startsWith("<")){let n=a.slice(1);a=t.get(n)??""}let o=`--${r}\r
3
+ `;i.filename?(o+=`Content-Disposition: form-data; name="${i.name}"; filename="${i.filename}"\r
4
+ `,i.contentType&&(o+=`Content-Type: ${i.contentType}\r
5
+ `)):o+=`Content-Disposition: form-data; name="${i.name}"\r
6
+ `,o+=`\r
7
+ ${a}\r
8
+ `,e.push(o)}return e.push(`--${r}--\r
9
+ `),{body:e.join(""),boundary:r}}var O={name:"curl",summary:"transfer a URL",usage:"curl [OPTIONS] URL",options:["-X, --request METHOD HTTP method (GET, POST, PUT, DELETE, etc.)","-H, --header HEADER Add header (can be used multiple times)","-d, --data DATA HTTP POST data"," --data-raw DATA HTTP POST data (no @ interpretation)"," --data-binary DATA HTTP POST binary data"," --data-urlencode DATA URL-encode and POST data","-F, --form NAME=VALUE Multipart form data","-u, --user USER:PASS HTTP authentication","-A, --user-agent STR Set User-Agent header","-e, --referer URL Set Referer header","-b, --cookie DATA Send cookies (name=value or @file)","-c, --cookie-jar FILE Save cookies to file","-T, --upload-file FILE Upload file (PUT)","-o, --output FILE Write output to file","-O, --remote-name Write to file named from URL","-I, --head Show headers only (HEAD request)","-i, --include Include response headers in output","-s, --silent Silent mode (no progress)","-S, --show-error Show errors even when silent","-f, --fail Fail silently on HTTP errors (no output)","-L, --location Follow redirects (default)"," --max-redirs NUM Maximum redirects (default: 20)","-m, --max-time SECS Maximum time for request"," --connect-timeout SECS Connection timeout","-w, --write-out FMT Output format after completion","-v, --verbose Verbose output"," --help Display this help and exit","","Note: Network access must be configured via BashEnv network option."," curl is not available by default for security reasons."]};function S(s){let t={method:"GET",headers:{},dataBinary:!1,formFields:[],useRemoteName:!1,headOnly:!1,includeHeaders:!1,silent:!1,showError:!1,failSilently:!1,followRedirects:!0,verbose:!1};for(let r=0;r<s.length;r++){let e=s[r];if(e==="-X"||e==="--request")t.method=s[++r]??"GET";else if(e.startsWith("-X"))t.method=e.slice(2);else if(e.startsWith("--request="))t.method=e.slice(10);else if(e==="-H"||e==="--header"){let i=s[++r];if(i){let a=i.indexOf(":");if(a>0){let o=i.slice(0,a).trim(),n=i.slice(a+1).trim();t.headers[o]=n}}}else if(e.startsWith("--header=")){let i=e.slice(9),a=i.indexOf(":");if(a>0){let o=i.slice(0,a).trim(),n=i.slice(a+1).trim();t.headers[o]=n}}else if(e==="-d"||e==="--data"||e==="--data-raw")t.data=s[++r]??"",t.method==="GET"&&(t.method="POST");else if(e.startsWith("-d"))t.data=e.slice(2),t.method==="GET"&&(t.method="POST");else if(e.startsWith("--data="))t.data=e.slice(7),t.method==="GET"&&(t.method="POST");else if(e.startsWith("--data-raw="))t.data=e.slice(11),t.method==="GET"&&(t.method="POST");else if(e==="--data-binary")t.data=s[++r]??"",t.dataBinary=!0,t.method==="GET"&&(t.method="POST");else if(e.startsWith("--data-binary="))t.data=e.slice(14),t.dataBinary=!0,t.method==="GET"&&(t.method="POST");else if(e==="--data-urlencode"){let i=s[++r]??"";t.data=(t.data?`${t.data}&`:"")+u(i),t.method==="GET"&&(t.method="POST")}else if(e.startsWith("--data-urlencode=")){let i=e.slice(17);t.data=(t.data?`${t.data}&`:"")+u(i),t.method==="GET"&&(t.method="POST")}else if(e==="-F"||e==="--form"){let i=s[++r]??"",a=c(i);a&&t.formFields.push(a),t.method==="GET"&&(t.method="POST")}else if(e.startsWith("--form=")){let i=e.slice(7),a=c(i);a&&t.formFields.push(a),t.method==="GET"&&(t.method="POST")}else if(e==="-u"||e==="--user")t.user=s[++r];else if(e.startsWith("-u"))t.user=e.slice(2);else if(e.startsWith("--user="))t.user=e.slice(7);else if(e==="-A"||e==="--user-agent")t.headers["User-Agent"]=s[++r]??"";else if(e.startsWith("-A"))t.headers["User-Agent"]=e.slice(2);else if(e.startsWith("--user-agent="))t.headers["User-Agent"]=e.slice(13);else if(e==="-e"||e==="--referer")t.headers.Referer=s[++r]??"";else if(e.startsWith("-e"))t.headers.Referer=e.slice(2);else if(e.startsWith("--referer="))t.headers.Referer=e.slice(10);else if(e==="-b"||e==="--cookie")t.headers.Cookie=s[++r]??"";else if(e.startsWith("-b"))t.headers.Cookie=e.slice(2);else if(e.startsWith("--cookie="))t.headers.Cookie=e.slice(9);else if(e==="-c"||e==="--cookie-jar")t.cookieJar=s[++r];else if(e.startsWith("--cookie-jar="))t.cookieJar=e.slice(13);else if(e==="-T"||e==="--upload-file")t.uploadFile=s[++r],t.method==="GET"&&(t.method="PUT");else if(e.startsWith("--upload-file="))t.uploadFile=e.slice(14),t.method==="GET"&&(t.method="PUT");else if(e==="-m"||e==="--max-time"){let i=parseFloat(s[++r]??"0");!Number.isNaN(i)&&i>0&&(t.timeoutMs=i*1e3)}else if(e.startsWith("--max-time=")){let i=parseFloat(e.slice(11));!Number.isNaN(i)&&i>0&&(t.timeoutMs=i*1e3)}else if(e==="--connect-timeout"){let i=parseFloat(s[++r]??"0");!Number.isNaN(i)&&i>0&&t.timeoutMs===void 0&&(t.timeoutMs=i*1e3)}else if(e.startsWith("--connect-timeout=")){let i=parseFloat(e.slice(18));!Number.isNaN(i)&&i>0&&t.timeoutMs===void 0&&(t.timeoutMs=i*1e3)}else if(e==="-o"||e==="--output")t.outputFile=s[++r];else if(e.startsWith("--output="))t.outputFile=e.slice(9);else if(e==="-O"||e==="--remote-name")t.useRemoteName=!0;else if(e==="-I"||e==="--head")t.headOnly=!0,t.method="HEAD";else if(e==="-i"||e==="--include")t.includeHeaders=!0;else if(e==="-s"||e==="--silent")t.silent=!0;else if(e==="-S"||e==="--show-error")t.showError=!0;else if(e==="-f"||e==="--fail")t.failSilently=!0;else if(e==="-L"||e==="--location")t.followRedirects=!0;else if(e==="--max-redirs")r++;else if(!e.startsWith("--max-redirs="))if(e==="-w"||e==="--write-out")t.writeOut=s[++r];else if(e.startsWith("--write-out="))t.writeOut=e.slice(12);else if(e==="-v"||e==="--verbose")t.verbose=!0;else{if(e.startsWith("--")&&e!=="--")return f("curl",e);if(e.startsWith("-")&&e!=="-")for(let i of e.slice(1))switch(i){case"s":t.silent=!0;break;case"S":t.showError=!0;break;case"f":t.failSilently=!0;break;case"L":t.followRedirects=!0;break;case"I":t.headOnly=!0,t.method="HEAD";break;case"i":t.includeHeaders=!0;break;case"O":t.useRemoteName=!0;break;case"v":t.verbose=!0;break;default:return f("curl",`-${i}`)}else e.startsWith("-")||(t.url=e)}}return t}function h(s){return Object.entries(s).map(([t,r])=>`${t}: ${r}`).join(`\r
10
+ `)}function E(s){try{return new URL(s).pathname.split("/").pop()||"index.html"}catch{return"index.html"}}function m(s,t){let r=s;return r=r.replace(/%\{http_code\}/g,String(t.status)),r=r.replace(/%\{content_type\}/g,t.headers["content-type"]||""),r=r.replace(/%\{url_effective\}/g,t.url),r=r.replace(/%\{size_download\}/g,String(t.bodyLength)),r=r.replace(/\\n/g,`
11
+ `),r}async function F(s,t){if(s.uploadFile){let r=t.fs.resolvePath(t.cwd,s.uploadFile);return{body:await t.fs.readFile(r)}}if(s.formFields.length>0){let r=new Map;for(let a of s.formFields)if(a.value.startsWith("@")||a.value.startsWith("<")){let o=t.fs.resolvePath(t.cwd,a.value.slice(1));try{let n=await t.fs.readFile(o);r.set(a.value.slice(1),n)}catch{r.set(a.value.slice(1),"")}}let{body:e,boundary:i}=w(s.formFields,r);return{body:e,contentType:`multipart/form-data; boundary=${i}`}}return s.data!==void 0?{body:s.data}:{}}function P(s,t){let r={...s.headers};if(s.user){let e=Buffer.from(s.user).toString("base64");r.Authorization=`Basic ${e}`}return t&&!r["Content-Type"]&&(r["Content-Type"]=t),r}async function W(s,t,r){if(!s.cookieJar)return;let e=t["set-cookie"];if(!e)return;let i=r.fs.resolvePath(r.cwd,s.cookieJar);await r.fs.writeFile(i,e)}function $(s,t,r){let e="";if(s.verbose){e+=`> ${s.method} ${r}
12
+ `;for(let[i,a]of Object.entries(s.headers))e+=`> ${i}: ${a}
13
+ `;e+=`>
14
+ `,e+=`< HTTP/1.1 ${t.status} ${t.statusText}
15
+ `;for(let[i,a]of Object.entries(t.headers))e+=`< ${i}: ${a}
16
+ `;e+=`<
17
+ `}return s.includeHeaders&&!s.verbose&&(e+=`HTTP/1.1 ${t.status} ${t.statusText}\r
18
+ `,e+=h(t.headers),e+=`\r
19
+ \r
20
+ `),s.headOnly?s.includeHeaders||s.verbose||(e+=`HTTP/1.1 ${t.status} ${t.statusText}\r
21
+ `,e+=h(t.headers),e+=`\r
22
+ `):e+=t.body,s.writeOut&&(e+=m(s.writeOut,{status:t.status,headers:t.headers,url:t.url,bodyLength:t.body.length})),e}var I={name:"curl",async execute(s,t){if(y(s))return T(O);let r=S(s);if("exitCode"in r)return r;let e=r;if(!e.url)return{stdout:"",stderr:`curl: no URL specified
23
+ `,exitCode:2};if(!t.fetch)return{stdout:"",stderr:`curl: internal error: fetch not available
24
+ `,exitCode:1};let i=e.url;i.match(/^https?:\/\//)||(i=`https://${i}`);try{let{body:a,contentType:o}=await F(e,t),n=P(e,o),l=await t.fetch(i,{method:e.method,headers:Object.keys(n).length>0?n:void 0,body:a,followRedirects:e.followRedirects,timeoutMs:e.timeoutMs});if(await W(e,l.headers,t),e.failSilently&&l.status>=400)return{stdout:"",stderr:e.showError||!e.silent?`curl: (22) The requested URL returned error: ${l.status}
25
+ `:"",exitCode:22};let d=$(e,l,i);if(e.outputFile||e.useRemoteName){let p=e.outputFile||E(i),v=t.fs.resolvePath(t.cwd,p);await t.fs.writeFile(v,e.headOnly?"":l.body),e.verbose||(d=""),e.writeOut&&(d=m(e.writeOut,{status:l.status,headers:l.headers,url:l.url,bodyLength:l.body.length}))}return{stdout:d,stderr:"",exitCode:0}}catch(a){let o=b(a),n=1;return o.includes("Network access denied")?n=7:o.includes("HTTP method")&&o.includes("not allowed")?n=3:o.includes("Redirect target not in allow-list")||o.includes("Too many redirects")?n=47:o.includes("aborted")&&(n=28),{stdout:"",stderr:!e.silent||e.showError?`curl: (${n}) ${o}
26
+ `:"",exitCode:n}}}};export{I as curlCommand};
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ import{b as x}from"./chunk-J7MJV6WO.js";import{a as y,b as I,c as m}from"./chunk-GTNBSMZR.js";import"./chunk-SJXDWN5X.js";var W={name:"cut",summary:"remove sections from each line of files",usage:"cut [OPTION]... [FILE]...",options:["-c LIST select only these characters","-d DELIM use DELIM instead of TAB for field delimiter","-f LIST select only these fields","-s, --only-delimited do not print lines without delimiters"," --help display this help and exit"]};function k(t){let c=[],l=t.split(",");for(let n of l)if(n.includes("-")){let[s,r]=n.split("-");c.push({start:s?parseInt(s,10):1,end:r?parseInt(r,10):null})}else{let s=parseInt(n,10);c.push({start:s,end:s})}return c}function C(t,c){let l=[];for(let n of c){let s=n.start-1,r=n.end===null?t.length:n.end;for(let i=s;i<r&&i<t.length;i++)i>=0&&!l.includes(t[i])&&l.push(t[i])}return l}var E={name:"cut",async execute(t,c){if(I(t))return y(W);let l=" ",n=null,s=null,r=!1,i=[];for(let o=0;o<t.length;o++){let e=t[o];if(e==="-d")l=t[++o]||" ";else if(e.startsWith("-d"))l=e.slice(2);else if(e==="-f")n=t[++o];else if(e.startsWith("-f"))n=e.slice(2);else if(e==="-c")s=t[++o];else if(e.startsWith("-c"))s=e.slice(2);else if(e==="-s"||e==="--only-delimited")r=!0;else{if(e.startsWith("--"))return m("cut",e);if(e.startsWith("-")){let f=!1;for(let u of e.slice(1))if(u==="s")r=!0;else if(!"dfc".includes(u)){f=!0;break}if(f)return m("cut",e)}else i.push(e)}}if(!n&&!s)return{stdout:"",stderr:`cut: you must specify a list of bytes, characters, or fields
3
+ `,exitCode:1};let p=await x(c,i,{cmdName:"cut"});if(!p.ok)return p.error;let a=p.content.split(`
4
+ `);a.length>0&&a[a.length-1]===""&&a.pop();let g=k(n||s||"1"),h="";for(let o of a)if(s){let e=o.split(""),f=[];for(let u of g){let w=u.start-1,L=u.end===null?e.length:u.end;for(let d=w;d<L&&d<e.length;d++)d>=0&&f.push(e[d])}h+=`${f.join("")}
5
+ `}else{if(r&&!o.includes(l))continue;let e=o.split(l),f=C(e,g);h+=`${f.join(l)}
6
+ `}return{stdout:h,stderr:"",exitCode:0}}};export{E as cutCommand};
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+ import{a as g,b as k,c as m}from"./chunk-GTNBSMZR.js";import"./chunk-SJXDWN5X.js";var p={name:"date",summary:"display the current time in the given FORMAT",usage:"date [OPTION]... [+FORMAT]",options:["-d, --date=STRING display time described by STRING","-u, --utc print Coordinated Universal Time (UTC)","-I, --iso-8601 output date/time in ISO 8601 format","-R, --rfc-email output RFC 5322 date format"," --help display this help and exit"]},M=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],h=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function n(t,i=2){return String(t).padStart(i,"0")}function T(t){let i=-t.getTimezoneOffset();return`${i>=0?"+":"-"}${n(Math.floor(Math.abs(i)/60))}${n(Math.abs(i)%60)}`}function d(t,i,r){let a=r?{Y:t.getUTCFullYear(),m:t.getUTCMonth(),D:t.getUTCDate(),H:t.getUTCHours(),M:t.getUTCMinutes(),S:t.getUTCSeconds(),w:t.getUTCDay()}:{Y:t.getFullYear(),m:t.getMonth(),D:t.getDate(),H:t.getHours(),M:t.getMinutes(),S:t.getSeconds(),w:t.getDay()},e="",o=0;for(;o<i.length;){if(i[o]==="%"&&o+1<i.length){let c=i[++o];switch(c){case"%":e+="%";break;case"a":e+=M[a.w];break;case"b":case"h":e+=h[a.m];break;case"d":e+=n(a.D);break;case"e":e+=String(a.D).padStart(2," ");break;case"F":e+=`${a.Y}-${n(a.m+1)}-${n(a.D)}`;break;case"H":e+=n(a.H);break;case"I":e+=n(a.H%12||12);break;case"m":e+=n(a.m+1);break;case"M":e+=n(a.M);break;case"n":e+=`
3
+ `;break;case"p":e+=a.H<12?"AM":"PM";break;case"P":e+=a.H<12?"am":"pm";break;case"R":e+=`${n(a.H)}:${n(a.M)}`;break;case"s":e+=Math.floor(t.getTime()/1e3);break;case"S":e+=n(a.S);break;case"t":e+=" ";break;case"T":e+=`${n(a.H)}:${n(a.M)}:${n(a.S)}`;break;case"u":e+=a.w||7;break;case"w":e+=a.w;break;case"y":e+=n(a.Y%100);break;case"Y":e+=a.Y;break;case"z":e+=r?"+0000":T(t);break;case"Z":e+=r?"UTC":Intl.DateTimeFormat().resolvedOptions().timeZone;break;default:e+=`%${c}`}}else e+=i[o];o++}return e}function S(t){let i=new Date(t);if(!Number.isNaN(i.getTime()))return i;if(/^\d+$/.test(t))return new Date(Number.parseInt(t,10)*1e3);let r=t.toLowerCase();return r==="now"||r==="today"?new Date:r==="yesterday"?new Date(Date.now()-864e5):r==="tomorrow"?new Date(Date.now()+864e5):null}var w={name:"date",async execute(t,i){if(k(t))return g(p);let r=!1,a=null,e=null,o=!1,c=!1;for(let f=0;f<t.length;f++){let s=t[f];if(s==="-u"||s==="--utc")r=!0;else if(s==="-d"||s==="--date")a=t[++f]??"";else if(s.startsWith("--date="))a=s.slice(7);else if(s==="-I"||s==="--iso-8601")o=!0;else if(s==="-R"||s==="--rfc-email")c=!0;else if(s.startsWith("+"))e=s.slice(1);else{if(s.startsWith("--"))return m("date",s);if(s.startsWith("-"))for(let b of s.slice(1))if(b==="u")r=!0;else if(b==="I")o=!0;else if(b==="R")c=!0;else return m("date",`-${b}`)}}let l=a!==null?S(a):new Date;if(!l)return{stdout:"",stderr:`date: invalid date '${a}'
4
+ `,exitCode:1};let u;return e?u=d(l,e,r):o?u=d(l,"%Y-%m-%dT%H:%M:%S%z",r):c?u=d(l,"%a, %d %b %Y %H:%M:%S %z",r):u=d(l,"%a %b %e %H:%M:%S %Z %Y",r),{stdout:`${u}
5
+ `,stderr:"",exitCode:0}}};export{w as dateCommand};
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env node
2
+ import{a as N}from"./chunk-TA7RUHGQ.js";import{a as S,b as E}from"./chunk-GTNBSMZR.js";import"./chunk-SJXDWN5X.js";var v=class{diff(e,t,n={}){let s;typeof n=="function"?(s=n,n={}):"callback"in n&&(s=n.callback);let u=this.castInput(e,n),f=this.castInput(t,n),i=this.removeEmpty(this.tokenize(u,n)),a=this.removeEmpty(this.tokenize(f,n));return this.diffWithOptionsObj(i,a,n,s)}diffWithOptionsObj(e,t,n,s){var u;let f=r=>{if(r=this.postProcess(r,n),s){setTimeout(function(){s(r)},0);return}else return r},i=t.length,a=e.length,d=1,o=i+a;n.maxEditLength!=null&&(o=Math.min(o,n.maxEditLength));let g=(u=n.timeout)!==null&&u!==void 0?u:1/0,w=Date.now()+g,m=[{oldPos:-1,lastComponent:void 0}],P=this.extractCommon(m[0],t,e,0,n);if(m[0].oldPos+1>=a&&P+1>=i)return f(this.buildValues(m[0].lastComponent,t,e));let C=-1/0,x=1/0,L=()=>{for(let r=Math.max(C,-d);r<=Math.min(x,d);r+=2){let c,h=m[r-1],p=m[r+1];h&&(m[r-1]=void 0);let y=!1;if(p){let I=p.oldPos-r;y=p&&0<=I&&I<i}let b=h&&h.oldPos+1<a;if(!y&&!b){m[r]=void 0;continue}if(!b||y&&h.oldPos<p.oldPos?c=this.addToPath(p,!0,!1,0,n):c=this.addToPath(h,!1,!0,1,n),P=this.extractCommon(c,t,e,r,n),c.oldPos+1>=a&&P+1>=i)return f(this.buildValues(c.lastComponent,t,e))||!0;m[r]=c,c.oldPos+1>=a&&(x=Math.min(x,r-1)),P+1>=i&&(C=Math.max(C,r+1))}d++};if(s)(function r(){setTimeout(function(){if(d>o||Date.now()>w)return s(void 0);L()||r()},0)})();else for(;d<=o&&Date.now()<=w;){let r=L();if(r)return r}}addToPath(e,t,n,s,u){let f=e.lastComponent;return f&&!u.oneChangePerToken&&f.added===t&&f.removed===n?{oldPos:e.oldPos+s,lastComponent:{count:f.count+1,added:t,removed:n,previousComponent:f.previousComponent}}:{oldPos:e.oldPos+s,lastComponent:{count:1,added:t,removed:n,previousComponent:f}}}extractCommon(e,t,n,s,u){let f=t.length,i=n.length,a=e.oldPos,d=a-s,o=0;for(;d+1<f&&a+1<i&&this.equals(n[a+1],t[d+1],u);)d++,a++,o++,u.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return o&&!u.oneChangePerToken&&(e.lastComponent={count:o,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=a,d}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join("")}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){let s=[],u;for(;e;)s.push(e),u=e.previousComponent,delete e.previousComponent,e=u;s.reverse();let f=s.length,i=0,a=0,d=0;for(;i<f;i++){let o=s[i];if(o.removed)o.value=this.join(n.slice(d,d+o.count)),d+=o.count;else{if(!o.added&&this.useLongestToken){let g=t.slice(a,a+o.count);g=g.map(function(w,m){let P=n[d+m];return P.length>w.length?P:w}),o.value=this.join(g)}else o.value=this.join(t.slice(a,a+o.count));a+=o.count,o.added||(d+=o.count)}}return s}};var T=class extends v{constructor(){super(...arguments),this.tokenize=W}equals(e,t,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
3
+ `))&&(e=e.trim()),(!n.newlineIsToken||!t.includes(`
4
+ `))&&(t=t.trim())):n.ignoreNewlineAtEof&&!n.newlineIsToken&&(e.endsWith(`
5
+ `)&&(e=e.slice(0,-1)),t.endsWith(`
6
+ `)&&(t=t.slice(0,-1))),super.equals(e,t,n)}},O=new T;function D(l,e,t){return O.diff(l,e,t)}function W(l,e){e.stripTrailingCr&&(l=l.replace(/\r\n/g,`
7
+ `));let t=[],n=l.split(/(\n|\r\n)/);n[n.length-1]||n.pop();for(let s=0;s<n.length;s++){let u=n[s];s%2&&!e.newlineIsToken?t[t.length-1]+=u:t.push(u)}return t}function j(l,e,t,n,s,u,f){let i;f?typeof f=="function"?i={callback:f}:i=f:i={},typeof i.context>"u"&&(i.context=4);let a=i.context;if(i.newlineIsToken)throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");if(i.callback){let{callback:o}=i;D(t,n,Object.assign(Object.assign({},i),{callback:g=>{let w=d(g);o(w)}}))}else return d(D(t,n,i));function d(o){if(!o)return;o.push({value:"",lines:[]});function g(r){return r.map(function(c){return" "+c})}let w=[],m=0,P=0,C=[],x=1,L=1;for(let r=0;r<o.length;r++){let c=o[r],h=c.lines||A(c.value);if(c.lines=h,c.added||c.removed){if(!m){let p=o[r-1];m=x,P=L,p&&(C=a>0?g(p.lines.slice(-a)):[],m-=C.length,P-=C.length)}for(let p of h)C.push((c.added?"+":"-")+p);c.added?L+=h.length:x+=h.length}else{if(m)if(h.length<=a*2&&r<o.length-2)for(let p of g(h))C.push(p);else{let p=Math.min(h.length,a);for(let b of g(h.slice(0,p)))C.push(b);let y={oldStart:m,oldLines:x-m+p,newStart:P,newLines:L-P+p,lines:C};w.push(y),m=0,P=0,C=[]}x+=h.length,L+=h.length}}for(let r of w)for(let c=0;c<r.lines.length;c++)r.lines[c].endsWith(`
8
+ `)?r.lines[c]=r.lines[c].slice(0,-1):(r.lines.splice(c+1,0,"\"),c++);return{oldFileName:l,newFileName:e,oldHeader:s,newHeader:u,hunks:w}}}function k(l){if(Array.isArray(l))return l.map(k).join(`
9
+ `);let e=[];l.oldFileName==l.newFileName&&e.push("Index: "+l.oldFileName),e.push("==================================================================="),e.push("--- "+l.oldFileName+(typeof l.oldHeader>"u"?"":" "+l.oldHeader)),e.push("+++ "+l.newFileName+(typeof l.newHeader>"u"?"":" "+l.newHeader));for(let t=0;t<l.hunks.length;t++){let n=l.hunks[t];n.oldLines===0&&(n.oldStart-=1),n.newLines===0&&(n.newStart-=1),e.push("@@ -"+n.oldStart+","+n.oldLines+" +"+n.newStart+","+n.newLines+" @@");for(let s of n.lines)e.push(s)}return e.join(`
10
+ `)+`
11
+ `}function F(l,e,t,n,s,u,f){if(typeof f=="function"&&(f={callback:f}),f?.callback){let{callback:i}=f;j(l,e,t,n,s,u,Object.assign(Object.assign({},f),{callback:a=>{i(a?k(a):void 0)}}))}else{let i=j(l,e,t,n,s,u,f);return i?k(i):void 0}}function A(l){let e=l.endsWith(`
12
+ `),t=l.split(`
13
+ `).map(n=>n+`
14
+ `);return e?t.pop():t.push(t.pop().slice(0,-1)),t}var z={name:"diff",summary:"compare files line by line",usage:"diff [OPTION]... FILE1 FILE2",options:["-u, --unified output unified diff format (default)","-q, --brief report only whether files differ","-s, --report-identical-files report when files are the same","-i, --ignore-case ignore case differences"," --help display this help and exit"]},H={unified:{short:"u",long:"unified",type:"boolean"},brief:{short:"q",long:"brief",type:"boolean"},reportSame:{short:"s",long:"report-identical-files",type:"boolean"},ignoreCase:{short:"i",long:"ignore-case",type:"boolean"}},K={name:"diff",async execute(l,e){if(E(l))return S(z);let t=N("diff",l,H);if(!t.ok)return t.error;let n=t.result.flags.brief,s=t.result.flags.reportSame,u=t.result.flags.ignoreCase,f=t.result.positional;if(t.result.flags.unified,f.length<2)return{stdout:"",stderr:`diff: missing operand
15
+ `,exitCode:2};let i,a,[d,o]=f;try{i=d==="-"?e.stdin:await e.fs.readFile(e.fs.resolvePath(e.cwd,d))}catch{return{stdout:"",stderr:`diff: ${d}: No such file or directory
16
+ `,exitCode:2}}try{a=o==="-"?e.stdin:await e.fs.readFile(e.fs.resolvePath(e.cwd,o))}catch{return{stdout:"",stderr:`diff: ${o}: No such file or directory
17
+ `,exitCode:2}}let g=i,w=a;return u&&(g=g.toLowerCase(),w=w.toLowerCase()),g===w?s?{stdout:`Files ${d} and ${o} are identical
18
+ `,stderr:"",exitCode:0}:{stdout:"",stderr:"",exitCode:0}:n?{stdout:`Files ${d} and ${o} differ
19
+ `,stderr:"",exitCode:1}:{stdout:F(d,o,i,a,"","",{context:3}),stderr:"",exitCode:1}}};export{K as diffCommand};
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+ import{a as i,b as o}from"./chunk-GTNBSMZR.js";import"./chunk-SJXDWN5X.js";var m={name:"dirname",summary:"strip last component from file name",usage:"dirname [OPTION] NAME...",options:[" --help display this help and exit"]},p={name:"dirname",async execute(t,l){if(o(t))return i(m);let a=t.filter(n=>!n.startsWith("-"));if(a.length===0)return{stdout:"",stderr:`dirname: missing operand
3
+ `,exitCode:1};let e=[];for(let n of a){let r=n.replace(/\/+$/,""),s=r.lastIndexOf("/");s===-1?e.push("."):s===0?e.push("/"):e.push(r.slice(0,s))}return{stdout:`${e.join(`
4
+ `)}
5
+ `,stderr:"",exitCode:0}}};export{p as dirnameCommand};
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ import{a as z}from"./chunk-TA7RUHGQ.js";import{a as p,b as g}from"./chunk-GTNBSMZR.js";import"./chunk-SJXDWN5X.js";var $={name:"du",summary:"estimate file space usage",usage:"du [OPTION]... [FILE]...",options:["-a write counts for all files, not just directories","-h print sizes in human readable format","-s display only a total for each argument","-c produce a grand total","--max-depth=N print total for directory only if N or fewer levels deep"," --help display this help and exit"]},D={allFiles:{short:"a",type:"boolean"},humanReadable:{short:"h",type:"boolean"},summarize:{short:"s",type:"boolean"},grandTotal:{short:"c",type:"boolean"},maxDepth:{long:"max-depth",type:"number"}},F={name:"du",async execute(t,l){if(g(t))return p($);let a=z("du",t,D);if(!a.ok)return a.error;let e={allFiles:a.result.flags.allFiles,humanReadable:a.result.flags.humanReadable,summarize:a.result.flags.summarize,grandTotal:a.result.flags.grandTotal,maxDepth:a.result.flags.maxDepth??null},s=a.result.positional;s.length===0&&s.push(".");let r="",n="",m=0;for(let o of s){let i=l.fs.resolvePath(l.cwd,o);try{await l.fs.stat(i);let u=await y(l,i,o,e,0);r+=u.output,m+=u.totalSize,n+=u.stderr}catch{n+=`du: cannot access '${o}': No such file or directory
3
+ `}}return e.grandTotal&&s.length>0&&(r+=`${d(m,e.humanReadable)} total
4
+ `),{stdout:r,stderr:n,exitCode:n?1:0}}};async function y(t,l,a,e,s){let r={output:"",totalSize:0,stderr:""};try{let n=await t.fs.stat(l);if(!n.isDirectory)return r.totalSize=n.size,(e.allFiles||s===0)&&(r.output=d(n.size,e.humanReadable)+" "+a+`
5
+ `),r;let m=await t.fs.readdir(l),o=0;for(let i of m){let u=l==="/"?`/${i}`:`${l}/${i}`,f=a==="."?i:`${a}/${i}`;try{let c=await t.fs.stat(u);if(c.isDirectory){let h=await y(t,u,f,e,s+1);o+=h.totalSize,e.summarize||(e.maxDepth===null||s+1<=e.maxDepth?r.output+=h.output:o+=0)}else o+=c.size,e.allFiles&&!e.summarize&&(r.output+=d(c.size,e.humanReadable)+" "+f+`
6
+ `)}catch{}}r.totalSize=o,(e.summarize||e.maxDepth===null||s<=e.maxDepth)&&(r.output+=`${d(o,e.humanReadable)} ${a}
7
+ `)}catch{r.stderr=`du: cannot read directory '${a}': Permission denied
8
+ `}return r}function d(t,l){return l?t<1024?`${t}`:t<1024*1024?`${(t/1024).toFixed(1)}K`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)}M`:`${(t/(1024*1024*1024)).toFixed(1)}G`:String(Math.ceil(t/1024)||1)}export{F as duCommand};
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ import"./chunk-SJXDWN5X.js";function o(a){let s="",e=0;for(;e<a.length;)if(a[e]==="\\"){if(e+1>=a.length){s+="\\";break}let c=a[e+1];switch(c){case"\\":s+="\\",e+=2;break;case"n":s+=`
3
+ `,e+=2;break;case"t":s+=" ",e+=2;break;case"r":s+="\r",e+=2;break;case"a":s+="\x07",e+=2;break;case"b":s+="\b",e+=2;break;case"f":s+="\f",e+=2;break;case"v":s+="\v",e+=2;break;case"e":case"E":s+="\x1B",e+=2;break;case"c":return{output:s,stop:!0};case"0":{let r="",t=e+2;for(;t<a.length&&t<e+5&&/[0-7]/.test(a[t]);)r+=a[t],t++;if(r.length===0)s+="\0";else{let l=parseInt(r,8)%256;s+=String.fromCharCode(l)}e=t;break}case"x":{let r="",t=e+2;for(;t<a.length&&t<e+4&&/[0-9a-fA-F]/.test(a[t]);)r+=a[t],t++;if(r.length===0)s+="\\x",e+=2;else{let l=parseInt(r,16);s+=String.fromCharCode(l),e=t}break}case"u":{let r="",t=e+2;for(;t<a.length&&t<e+6&&/[0-9a-fA-F]/.test(a[t]);)r+=a[t],t++;if(r.length===0)s+="\\u",e+=2;else{let l=parseInt(r,16);s+=String.fromCodePoint(l),e=t}break}case"U":{let r="",t=e+2;for(;t<a.length&&t<e+10&&/[0-9a-fA-F]/.test(a[t]);)r+=a[t],t++;if(r.length===0)s+="\\U",e+=2;else{let l=parseInt(r,16);try{s+=String.fromCodePoint(l)}catch{s+=`\\U${r}`}e=t}break}default:s+=`\\${c}`,e+=2}}else s+=a[e],e++;return{output:s,stop:!1}}var n={name:"echo",async execute(a,s){let e=!1,c=!1,r=0;for(;r<a.length;){let l=a[r];if(l==="-n")e=!0,r++;else if(l==="-e")c=!0,r++;else if(l==="-E")c=!1,r++;else if(l==="-ne"||l==="-en")e=!0,c=!0,r++;else break}let t=a.slice(r).join(" ");if(c){let l=o(t);if(t=l.output,l.stop)return{stdout:t,stderr:"",exitCode:0}}return e||(t+=`
4
+ `),{stdout:t,stderr:"",exitCode:0}}};export{n as echoCommand};
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ import{a as m,b as f,c as p}from"./chunk-GTNBSMZR.js";import"./chunk-SJXDWN5X.js";var O={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"]},y={name:"env",async execute(s,i){if(f(s))return m(O);let u=!1,o=[],l={},t=-1;for(let n=0;n<s.length;n++){let e=s[n];if(e==="-i"||e==="--ignore-environment")u=!0;else if(e==="-u"&&n+1<s.length)o.push(s[++n]);else if(e.startsWith("-u"))o.push(e.slice(2));else if(e.startsWith("--unset="))o.push(e.slice(8));else{if(e.startsWith("--")&&e!=="--")return p("env",e);if(e.startsWith("-")&&e!=="-"){for(let r of e.slice(1))if(r!=="i"&&r!=="u")return p("env",`-${r}`);e.includes("i")&&(u=!0)}else if(e.includes("=")&&t===-1){let r=e.indexOf("="),h=e.slice(0,r),x=e.slice(r+1);l[h]=x}else{t=n;break}}}let a;if(u)a={...l};else{a={...i.env};for(let n of o)delete a[n];Object.assign(a,l)}if(t===-1){let n=[];for(let[e,r]of Object.entries(a))n.push(`${e}=${r}`);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 c=s.slice(t).join(" "),d=Object.entries(l).map(([n,e])=>`${n}="${e}"`).join(" "),v=d?`${d} ${c}`:c;return i.exec(v,{cwd:i.cwd})}},g={name:"printenv",summary:"print all or part of environment",usage:"printenv [OPTION]... [VARIABLE]...",options:[" --help display this help and exit"]},A={name:"printenv",async execute(s,i){if(f(s))return m(g);let u=s.filter(t=>!t.startsWith("-"));if(u.length===0){let t=[];for(let[a,c]of Object.entries(i.env))t.push(`${a}=${c}`);return{stdout:t.join(`
6
+ `)+(t.length>0?`
7
+ `:""),stderr:"",exitCode:0}}let o=[],l=0;for(let t of u)t in i.env?o.push(i.env[t]):l=1;return{stdout:o.join(`
8
+ `)+(o.length>0?`
9
+ `:""),stderr:"",exitCode:l}}};export{y as envCommand,A as printenvCommand};
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+ import"./chunk-SJXDWN5X.js";var d={name:"expr",async execute(s,r){if(s.length===0)return{stdout:"",stderr:`expr: missing operand
3
+ `,exitCode:2};try{let l=g(s),h=l==="0"||l===""?1:0;return{stdout:`${l}
4
+ `,stderr:"",exitCode:h}}catch(l){return{stdout:"",stderr:`expr: ${l.message}
5
+ `,exitCode:2}}}};function g(s){if(s.length===1)return s[0];let r=0;function l(){let e=h();for(;r<s.length&&s[r]==="|";){r++;let t=h();if(e!=="0"&&e!=="")return e;e=t}return e}function h(){let e=a();for(;r<s.length&&s[r]==="&";){r++;let t=a();(e==="0"||e===""||t==="0"||t==="")&&(e="0")}return e}function a(){let e=p();for(;r<s.length;){let t=s[r];if(["=","!=","<",">","<=",">="].includes(t)){r++;let o=p(),n=parseInt(e,10),i=parseInt(o,10),f=!Number.isNaN(n)&&!Number.isNaN(i),c;t==="="?c=f?n===i:e===o:t==="!="?c=f?n!==i:e!==o:t==="<"?c=f?n<i:e<o:t===">"?c=f?n>i:e>o:t==="<="?c=f?n<=i:e<=o:c=f?n>=i:e>=o,e=c?"1":"0"}else break}return e}function p(){let e=N();for(;r<s.length;){let t=s[r];if(t==="+"||t==="-"){r++;let o=N(),n=parseInt(e,10),i=parseInt(o,10);if(Number.isNaN(n)||Number.isNaN(i))throw new Error("non-integer argument");e=String(t==="+"?n+i:n-i)}else break}return e}function N(){let e=m();for(;r<s.length;){let t=s[r];if(t==="*"||t==="/"||t==="%"){r++;let o=m(),n=parseInt(e,10),i=parseInt(o,10);if(Number.isNaN(n)||Number.isNaN(i))throw new Error("non-integer argument");if((t==="/"||t==="%")&&i===0)throw new Error("division by zero");t==="*"?e=String(n*i):t==="/"?e=String(Math.trunc(n/i)):e=String(n%i)}else break}return e}function m(){let e=u();for(;r<s.length&&s[r]===":";){r++;let t=u(),o=new RegExp(`^${t}`),n=e.match(o);n?e=n[1]!==void 0?n[1]:String(n[0].length):e="0"}return e}function u(){if(r>=s.length)throw new Error("syntax error");let e=s[r];if(e==="match"){r++;let t=u(),o=u(),n=new RegExp(o),i=t.match(n);return i?i[1]!==void 0?i[1]:String(i[0].length):"0"}if(e==="substr"){r++;let t=u(),o=parseInt(u(),10),n=parseInt(u(),10);if(Number.isNaN(o)||Number.isNaN(n))throw new Error("non-integer argument");return t.substring(o-1,o-1+n)}if(e==="index"){r++;let t=u(),o=u();for(let n=0;n<t.length;n++)if(o.includes(t[n]))return String(n+1);return"0"}if(e==="length"){r++;let t=u();return String(t.length)}if(e==="("){r++;let t=l();if(r>=s.length||s[r]!==")")throw new Error("syntax error");return r++,t}return r++,e}return l()}export{d as exprCommand};