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,15 @@
1
+ #!/usr/bin/env node
2
+ import{b as F}from"./chunk-J7MJV6WO.js";import{a as v,b as y,c as C}from"./chunk-GTNBSMZR.js";import"./chunk-SJXDWN5X.js";function k(u,t,r){let f=r!==null?r:/\s+/,a=u.split(f),s=t.startField-1;if(s>=a.length)return"";if(t.endField===void 0){let i=a[s]||"";return t.startChar!==void 0&&(i=i.slice(t.startChar-1)),t.ignoreLeading&&(i=i.trimStart()),i}let l=Math.min(t.endField-1,a.length-1),c="";for(let i=s;i<=l&&i<a.length;i++){let o=a[i]||"";if(i===s&&t.startChar!==void 0&&(o=o.slice(t.startChar-1)),i===l&&t.endChar!==void 0){let e=i===s&&t.startChar!==void 0?t.endChar-t.startChar+1:t.endChar;o=o.slice(0,e)}i>s&&(c+=r||" "),c+=o}return t.ignoreLeading&&(c=c.trimStart()),c}function S(u,t,r,f){if(r){let l=parseFloat(u)||0,c=parseFloat(t)||0;return l-c}let a=u,s=t;return f&&(a=a.toLowerCase(),s=s.toLowerCase()),a.localeCompare(s)}function b(u){let{keys:t,fieldDelimiter:r,numeric:f,ignoreCase:a,reverse:s}=u;return(l,c)=>{if(t.length===0){let o=l,e=c;a&&(o=o.toLowerCase(),e=e.toLowerCase());let n;if(f){let d=parseFloat(o)||0,h=parseFloat(e)||0;if(n=d-h,n===0){let p=o.localeCompare(e);return s?-p:p}}else n=o.localeCompare(e);return s?-n:n}for(let o of t){let e=k(l,o,r),n=k(c,o,r),d=o.numeric??f,h=o.ignoreCase??a,p=o.reverse??s,g=S(e,n,d,h);if(g!==0)return p?-g:g}let i=l.localeCompare(c);return s?-i:i}}function w(u,t){if(t.keys.length===0){if(t.ignoreCase){let a=new Set;return u.filter(s=>{let l=s.toLowerCase();return a.has(l)?!1:(a.add(l),!0)})}return[...new Set(u)]}let r=t.keys[0],f=new Set;return u.filter(a=>{let s=k(a,r,t.fieldDelimiter);return(r.ignoreCase??t.ignoreCase)&&(s=s.toLowerCase()),f.has(s)?!1:(f.add(s),!0)})}function m(u){let t={startField:1},r="",f=u,a=f.match(/([nrfb]+)$/i);a&&(r=a[1].toLowerCase(),f=f.slice(0,-r.length)),r.includes("n")&&(t.numeric=!0),r.includes("r")&&(t.reverse=!0),r.includes("f")&&(t.ignoreCase=!0),r.includes("b")&&(t.ignoreLeading=!0);let s=f.split(",");if(s.length===0||s[0]==="")return null;let l=s[0].split("."),c=parseInt(l[0],10);if(Number.isNaN(c)||c<1)return null;if(t.startField=c,l.length>1&&l[1]){let i=parseInt(l[1],10);!Number.isNaN(i)&&i>=1&&(t.startChar=i)}if(s.length>1&&s[1]){let i=s[1],o=i.match(/([nrfb]+)$/i);if(o){let n=o[1].toLowerCase();n.includes("n")&&(t.numeric=!0),n.includes("r")&&(t.reverse=!0),n.includes("f")&&(t.ignoreCase=!0),n.includes("b")&&(t.ignoreLeading=!0),i=i.slice(0,-n.length)}let e=i.split(".");if(e[0]){let n=parseInt(e[0],10);if(!Number.isNaN(n)&&n>=1&&(t.endField=n),e.length>1&&e[1]){let d=parseInt(e[1],10);!Number.isNaN(d)&&d>=1&&(t.endChar=d)}}}return t}var N={name:"sort",summary:"sort lines of text files",usage:"sort [OPTION]... [FILE]...",options:["-f, --ignore-case fold lower case to upper case characters","-n, --numeric-sort compare according to string numerical value","-r, --reverse reverse the result of comparisons","-u, --unique output only unique lines","-k, --key=KEYDEF sort via a key; KEYDEF gives location and type","-t, --field-separator=SEP use SEP as field separator"," --help display this help and exit"],description:`KEYDEF is F[.C][OPTS][,F[.C][OPTS]]
3
+ F is a field number (1-indexed)
4
+ C is a character position within the field (1-indexed)
5
+ OPTS can be: n (numeric), r (reverse), f (fold case), b (ignore blanks)
6
+
7
+ Examples:
8
+ -k1 sort by first field
9
+ -k2,2 sort by second field only
10
+ -k1.3 sort by first field starting at 3rd character
11
+ -k1,2n sort by fields 1-2 numerically
12
+ -k2 -k1 sort by field 2, then by field 1`},D={name:"sort",async execute(u,t){if(y(u))return v(N);let r={reverse:!1,numeric:!1,unique:!1,ignoreCase:!1,keys:[],fieldDelimiter:null},f=[];for(let o=0;o<u.length;o++){let e=u[o];if(e==="-r"||e==="--reverse")r.reverse=!0;else if(e==="-n"||e==="--numeric-sort")r.numeric=!0;else if(e==="-u"||e==="--unique")r.unique=!0;else if(e==="-f"||e==="--ignore-case")r.ignoreCase=!0;else if(e==="-t"||e==="--field-separator")r.fieldDelimiter=u[++o]||null;else if(e.startsWith("-t"))r.fieldDelimiter=e.slice(2)||null;else if(e.startsWith("--field-separator="))r.fieldDelimiter=e.slice(18)||null;else if(e==="-k"||e==="--key"){let n=u[++o];if(n){let d=m(n);d&&r.keys.push(d)}}else if(e.startsWith("-k")){let n=m(e.slice(2));n&&r.keys.push(n)}else if(e.startsWith("--key=")){let n=m(e.slice(6));n&&r.keys.push(n)}else{if(e.startsWith("--"))return C("sort",e);if(e.startsWith("-")&&!e.startsWith("--")){let n=!1;for(let d of e.slice(1))if(d==="r")r.reverse=!0;else if(d==="n")r.numeric=!0;else if(d==="u")r.unique=!0;else if(d==="f")r.ignoreCase=!0;else{n=!0;break}if(n)return C("sort",e)}else f.push(e)}}let a=await F(t,f,{cmdName:"sort"});if(!a.ok)return a.error;let l=a.content.split(`
13
+ `);l.length>0&&l[l.length-1]===""&&l.pop();let c=b(r);return l.sort(c),r.unique&&(l=w(l,r)),{stdout:l.length>0?`${l.join(`
14
+ `)}
15
+ `:"",stderr:"",exitCode:0}}};export{D as sortCommand};
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ import{a as d}from"./chunk-TA7RUHGQ.js";import{a as u,b as g}from"./chunk-GTNBSMZR.js";import"./chunk-SJXDWN5X.js";var S={name:"stat",summary:"display file or file system status",usage:"stat [OPTION]... FILE...",options:["-c FORMAT use the specified FORMAT instead of the default"," --help display this help and exit"]},$={format:{short:"c",type:"string"}},x={name:"stat",async execute(e,a){if(g(e))return u(S);let s=d("stat",e,$);if(!s.ok)return s.error;let n=s.result.flags.format??null,c=s.result.positional;if(c.length===0)return{stdout:"",stderr:`stat: missing operand
3
+ `,exitCode:1};let o="",p="",f=!1;for(let i of c){let h=a.fs.resolvePath(a.cwd,i);try{let r=await a.fs.stat(h);if(n){let t=n,l=r.mode.toString(8),y=m(r.mode,r.isDirectory);t=t.replace(/%n/g,i),t=t.replace(/%N/g,`'${i}'`),t=t.replace(/%s/g,String(r.size)),t=t.replace(/%F/g,r.isDirectory?"directory":"regular file"),t=t.replace(/%a/g,l),t=t.replace(/%A/g,y),t=t.replace(/%u/g,"1000"),t=t.replace(/%U/g,"user"),t=t.replace(/%g/g,"1000"),t=t.replace(/%G/g,"group"),o+=`${t}
4
+ `}else{let t=r.mode.toString(8).padStart(4,"0"),l=m(r.mode,r.isDirectory);o+=` File: ${i}
5
+ `,o+=` Size: ${r.size} Blocks: ${Math.ceil(r.size/512)}
6
+ `,o+=`Access: (${t}/${l})
7
+ `,o+=`Modify: ${r.mtime.toISOString()}
8
+ `}}catch{p+=`stat: cannot stat '${i}': No such file or directory
9
+ `,f=!0}}return{stdout:o,stderr:p,exitCode:f?1:0}}};function m(e,a){let s=a?"d":"-",n=[e&256?"r":"-",e&128?"w":"-",e&64?"x":"-",e&32?"r":"-",e&16?"w":"-",e&8?"x":"-",e&4?"r":"-",e&2?"w":"-",e&1?"x":"-"];return s+n.join("")}export{x as statCommand};
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import{a,b as n,d as l}from"./chunk-J7BCMQDI.js";import{a as i,b as s}from"./chunk-GTNBSMZR.js";import"./chunk-SJXDWN5X.js";var h={name:"tail",summary:"output the last part of files",usage:"tail [OPTION]... [FILE]...",options:["-c, --bytes=NUM print the last NUM bytes","-n, --lines=NUM print the last NUM lines (default 10)","-n +NUM print starting from line NUM","-q, --quiet never print headers giving file names","-v, --verbose always print headers giving file names"," --help display this help and exit"]},c={name:"tail",async execute(t,r){if(s(t))return i(h);let e=a(t,"tail");if(!e.ok)return e.error;let{lines:o,bytes:p,fromLine:m}=e.options;return n(r,e.options,"tail",f=>l(f,o,p,m??!1))}};export{c as tailCommand};
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import{a as d}from"./chunk-TA7RUHGQ.js";import{a as p,b as l}from"./chunk-GTNBSMZR.js";import"./chunk-SJXDWN5X.js";var h={name:"tee",summary:"read from stdin and write to stdout and files",usage:"tee [OPTION]... [FILE]...",options:["-a, --append append to the given FILEs, do not overwrite"," --help display this help and exit"]},m={append:{short:"a",long:"append",type:"boolean"}},g={name:"tee",async execute(r,e){if(l(r))return p(h);let t=d("tee",r,m);if(!t.ok)return t.error;let{append:f}=t.result.flags,c=t.result.positional,o=e.stdin,n="",a=0;for(let i of c)try{let s=e.fs.resolvePath(e.cwd,i);f?await e.fs.appendFile(s,o):await e.fs.writeFile(s,o)}catch{n+=`tee: ${i}: No such file or directory
3
+ `,a=1}return{stdout:o,stderr:n,exitCode:a}}};export{g as teeCommand};
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ import{a as c,b as f,c as u}from"./chunk-GTNBSMZR.js";import"./chunk-SJXDWN5X.js";var x={name:"timeout",summary:"run a command with a time limit",usage:"timeout [OPTION] DURATION COMMAND [ARG]...",description:`Start COMMAND, and kill it if still running after DURATION.
3
+
4
+ DURATION is a number with optional suffix:
5
+ s - seconds (default)
6
+ m - minutes
7
+ h - hours
8
+ d - days`,options:["-k, --kill-after=DURATION send KILL signal after DURATION if still running","-s, --signal=SIGNAL specify signal to send (default: TERM)"," --preserve-status exit with same status as COMMAND, even on timeout"," --foreground run command in foreground"," --help display this help and exit"]};function O(r){let i=r.match(/^(\d+\.?\d*)(s|m|h|d)?$/);if(!i)return null;let n=parseFloat(i[1]);switch(i[2]||"s"){case"s":return n*1e3;case"m":return n*60*1e3;case"h":return n*60*60*1e3;case"d":return n*24*60*60*1e3;default:return null}}var w={name:"timeout",async execute(r,i){if(f(r))return c(x);let n=!1,s=0;for(let t=0;t<r.length;t++){let e=r[t];if(e==="--preserve-status")n=!0,s=t+1;else if(e==="--foreground")s=t+1;else if(e==="-k"||e==="--kill-after")t++,s=t+1;else if(e.startsWith("--kill-after="))s=t+1;else if(e==="-s"||e==="--signal")t++,s=t+1;else if(e.startsWith("--signal="))s=t+1;else{if(e.startsWith("--")&&e!=="--")return u("timeout",e);if(e.startsWith("-")&&e.length>1&&e!=="--")if(e.startsWith("-k"))s=t+1;else if(e.startsWith("-s"))s=t+1;else return u("timeout",e);else{s=t;break}}}let o=r.slice(s);if(o.length===0)return{stdout:"",stderr:`timeout: missing operand
9
+ `,exitCode:1};let a=o[0],l=O(a);if(l===null)return{stdout:"",stderr:`timeout: invalid time interval '${a}'
10
+ `,exitCode:1};let m=o.slice(1);if(m.length===0)return{stdout:"",stderr:`timeout: missing operand
11
+ `,exitCode:1};if(!i.exec)return{stdout:"",stderr:`timeout: exec not available
12
+ `,exitCode:1};let h=m.map(t=>t.includes(" ")||t.includes(" ")?`'${t.replace(/'/g,"'\\''")}'`:t).join(" "),p=new Promise(t=>{setTimeout(()=>t({timedOut:!0}),l)}),g=i.exec(h,{cwd:i.cwd}).then(t=>({timedOut:!1,result:t})),d=await Promise.race([p,g]);return d.timedOut?{stdout:"",stderr:"",exitCode:124}:d.result}};export{w as timeoutCommand};
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ import{a as f}from"./chunk-4VDEBYW7.js";import{c as r}from"./chunk-GTNBSMZR.js";import"./chunk-SJXDWN5X.js";var l={name:"touch",async execute(u,e){let s=[];for(let t of u){if(t.startsWith("--"))return r("touch",t);if(t.startsWith("-")&&t.length>1)return r("touch",t);s.push(t)}if(s.length===0)return{stdout:"",stderr:`touch: missing file operand
3
+ `,exitCode:1};let n="",i=0;for(let t of s)try{let o=e.fs.resolvePath(e.cwd,t);await e.fs.exists(o)||await e.fs.writeFile(o,"")}catch(o){n+=`touch: cannot touch '${t}': ${f(o)}
4
+ `,i=1}return{stdout:"",stderr:n,exitCode:i}}};export{l as touchCommand};
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+ import{a as C}from"./chunk-TA7RUHGQ.js";import{a as g,b as m}from"./chunk-GTNBSMZR.js";import"./chunk-SJXDWN5X.js";var x={name:"tr",summary:"translate or delete characters",usage:"tr [OPTION]... SET1 [SET2]",options:["-c, -C, --complement use the complement of SET1","-d, --delete delete characters in SET1","-s, --squeeze-repeats squeeze repeated characters"," --help display this help and exit"],description:`SET syntax:
3
+ a-z character range
4
+ [:alnum:] all letters and digits
5
+ [:alpha:] all letters
6
+ [:digit:] all digits
7
+ [:lower:] all lowercase letters
8
+ [:upper:] all uppercase letters
9
+ [:space:] all whitespace
10
+ [:blank:] horizontal whitespace
11
+ [:punct:] all punctuation
12
+ [:print:] all printable characters
13
+ [:graph:] all printable characters except space
14
+ [:cntrl:] all control characters
15
+ [:xdigit:] all hexadecimal digits
16
+ \\n, \\t, \\r escape sequences`},b={"[:alnum:]":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789","[:alpha:]":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz","[:blank:]":" ","[:cntrl:]":Array.from({length:32},(r,n)=>String.fromCharCode(n)).join("").concat("\x7F"),"[:digit:]":"0123456789","[:graph:]":Array.from({length:94},(r,n)=>String.fromCharCode(33+n)).join(""),"[:lower:]":"abcdefghijklmnopqrstuvwxyz","[:print:]":Array.from({length:95},(r,n)=>String.fromCharCode(32+n)).join(""),"[:punct:]":"!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~","[:space:]":`
17
+ \r\f\v`,"[:upper:]":"ABCDEFGHIJKLMNOPQRSTUVWXYZ","[:xdigit:]":"0123456789ABCDEFabcdef"};function S(r){let n="",e=0;for(;e<r.length;){if(r[e]==="["&&r[e+1]===":"){let l=!1;for(let[i,a]of Object.entries(b))if(r.slice(e).startsWith(i)){n+=a,e+=i.length,l=!0;break}if(l)continue}if(r[e]==="\\"&&e+1<r.length){let l=r[e+1];l==="n"?n+=`
18
+ `:l==="t"?n+=" ":l==="r"?n+="\r":n+=l,e+=2;continue}if(e+2<r.length&&r[e+1]==="-"){let l=r.charCodeAt(e),i=r.charCodeAt(e+2);for(let a=l;a<=i;a++)n+=String.fromCharCode(a);e+=3;continue}n+=r[e],e++}return n}var y={complement:{short:"c",long:"complement",type:"boolean"},complementUpper:{short:"C",type:"boolean"},delete:{short:"d",long:"delete",type:"boolean"},squeeze:{short:"s",long:"squeeze-repeats",type:"boolean"}},q={name:"tr",async execute(r,n){if(m(r))return g(x);let e=C("tr",r,y);if(!e.ok)return e.error;let l=e.result.flags.complement||e.result.flags.complementUpper,i=e.result.flags.delete,a=e.result.flags.squeeze,p=e.result.positional;if(p.length<1)return{stdout:"",stderr:`tr: missing operand
19
+ `,exitCode:1};if(!i&&!a&&p.length<2)return{stdout:"",stderr:`tr: missing operand after SET1
20
+ `,exitCode:1};let f=S(p[0]),s=p.length>1?S(p[1]):"",d=n.stdin,u=o=>{let t=f.includes(o);return l?!t:t},c="";if(i)for(let o of d)u(o)||(c+=o);else if(a&&p.length===1){let o="";for(let t of d)u(t)&&t===o||(c+=t,o=t)}else{if(l){let o=s.length>0?s[s.length-1]:"";for(let t of d)f.includes(t)?c+=t:c+=o}else{let o=new Map;for(let t=0;t<f.length;t++){let h=t<s.length?s[t]:s[s.length-1];o.set(f[t],h)}for(let t of d)c+=o.get(t)??t}if(a){let o="",t="";for(let h of c)s.includes(h)&&h===t||(o+=h,t=h);c=o}}return{stdout:c,stderr:"",exitCode:0}}};export{q as trCommand};
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ import{a as P}from"./chunk-TA7RUHGQ.js";import{a as $,b as w}from"./chunk-GTNBSMZR.js";import"./chunk-SJXDWN5X.js";var g={name:"tree",summary:"list contents of directories in a tree-like format",usage:"tree [OPTION]... [DIRECTORY]...",options:["-a include hidden files","-d list directories only","-L LEVEL limit depth of directory tree","-f print full path prefix for each file"," --help display this help and exit"]},O={showHidden:{short:"a",type:"boolean"},directoriesOnly:{short:"d",type:"boolean"},fullPath:{short:"f",type:"boolean"},maxDepth:{short:"L",type:"number"}},N={name:"tree",async execute(s,o){if(w(s))return $(g);let e=P("tree",s,O);if(!e.ok)return e.error;let u={showHidden:e.result.flags.showHidden,directoriesOnly:e.result.flags.directoriesOnly,maxDepth:e.result.flags.maxDepth??null,fullPath:e.result.flags.fullPath},a=e.result.positional;a.length===0&&a.push(".");let t="",c="",l=0,r=0;for(let i of a){let n=await b(o,i,u,"",0);t+=n.output,c+=n.stderr,l+=n.dirCount,r+=n.fileCount}return t+=`
3
+ ${l} director${l===1?"y":"ies"}`,u.directoriesOnly||(t+=`, ${r} file${r===1?"":"s"}`),t+=`
4
+ `,{stdout:t,stderr:c,exitCode:c?1:0}}};async function b(s,o,e,u,a){let t={output:"",stderr:"",dirCount:0,fileCount:0},c=s.fs.resolvePath(s.cwd,o);try{if(!(await s.fs.stat(c)).isDirectory)return t.output=`${o}
5
+ `,t.fileCount=1,t}catch{return t.stderr=`tree: ${o}: No such file or directory
6
+ `,t}if(t.output=`${o}
7
+ `,e.maxDepth!==null&&a>=e.maxDepth)return t;try{let r=(await s.fs.readdir(c)).filter(i=>!(!e.showHidden&&i.startsWith(".")));r.sort();for(let i=0;i<r.length;i++){let n=r[i],f=c==="/"?`/${n}`:`${c}/${n}`,h=i===r.length-1,y=h?"`-- ":"|-- ",p=u+(h?" ":"| ");try{if((await s.fs.stat(f)).isDirectory){t.dirCount++;let d=e.fullPath?f:n;if(t.output+=`${u+y+d}
8
+ `,e.maxDepth===null||a+1<e.maxDepth){let C=await D(s,f,e,p,a+1);t.output+=C.output,t.dirCount+=C.dirCount,t.fileCount+=C.fileCount}}else if(!e.directoriesOnly){t.fileCount++;let d=e.fullPath?f:n;t.output+=`${u+y+d}
9
+ `}}catch{}}}catch{t.stderr=`tree: ${o}: Permission denied
10
+ `}return t}async function D(s,o,e,u,a){let t={output:"",stderr:"",dirCount:0,fileCount:0};if(e.maxDepth!==null&&a>=e.maxDepth)return t;try{let l=(await s.fs.readdir(o)).filter(r=>!(!e.showHidden&&r.startsWith(".")));l.sort();for(let r=0;r<l.length;r++){let i=l[r],n=o==="/"?`/${i}`:`${o}/${i}`,f=r===l.length-1,h=f?"`-- ":"|-- ",y=u+(f?" ":"| ");try{if((await s.fs.stat(n)).isDirectory){t.dirCount++;let m=e.fullPath?n:i;t.output+=`${u+h+m}
11
+ `;let d=await D(s,n,e,y,a+1);t.output+=d.output,t.dirCount+=d.dirCount,t.fileCount+=d.fileCount}else if(!e.directoriesOnly){t.fileCount++;let m=e.fullPath?n:i;t.output+=`${u+h+m}
12
+ `}}catch{}}}catch{}return t}export{N as treeCommand};
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import"./chunk-SJXDWN5X.js";var e={name:"true",async execute(){return{stdout:"",stderr:"",exitCode:0}}},t={name:"false",async execute(){return{stdout:"",stderr:"",exitCode:1}}};export{t as falseCommand,e as trueCommand};
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+ import{b as g}from"./chunk-J7MJV6WO.js";import{a as f}from"./chunk-TA7RUHGQ.js";import{a as p,b as d}from"./chunk-GTNBSMZR.js";import"./chunk-SJXDWN5X.js";var b={name:"uniq",summary:"report or omit repeated lines",usage:"uniq [OPTION]... [INPUT [OUTPUT]]",options:["-c, --count prefix lines by the number of occurrences","-d, --repeated only print duplicate lines","-i, --ignore-case ignore case when comparing","-u, --unique only print unique lines"," --help display this help and exit"]},w={count:{short:"c",long:"count",type:"boolean"},duplicatesOnly:{short:"d",long:"repeated",type:"boolean"},uniqueOnly:{short:"u",long:"unique",type:"boolean"},ignoreCase:{short:"i",long:"ignore-case",type:"boolean"}},P={name:"uniq",async execute(a,m){if(d(a))return p(b);let o=f("uniq",a,w);if(!o.ok)return o.error;let{count:h,duplicatesOnly:y,uniqueOnly:q,ignoreCase:C}=o.result.flags,O=o.result.positional,u=await g(m,O,{cmdName:"uniq"});if(!u.ok)return u.error;let n=u.content.split(`
3
+ `);if(n.length>0&&n[n.length-1]===""&&n.pop(),n.length===0)return{stdout:"",stderr:"",exitCode:0};let t=[],r=n[0],i=1,x=(e,s)=>C?e.toLowerCase()===s.toLowerCase():e===s;for(let e=1;e<n.length;e++)x(n[e],r)?i++:(t.push({line:r,count:i}),r=n[e],i=1);t.push({line:r,count:i});let l=t;y?l=t.filter(e=>e.count>1):q&&(l=t.filter(e=>e.count===1));let c="";for(let{line:e,count:s}of l)h?c+=`${String(s).padStart(4)} ${e}
4
+ `:c+=`${e}
5
+ `;return{stdout:c,stderr:"",exitCode:0}}};export{P as uniqCommand};
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ import{a as y}from"./chunk-J7MJV6WO.js";import{a as g}from"./chunk-TA7RUHGQ.js";import{a as w,b as m}from"./chunk-GTNBSMZR.js";import"./chunk-SJXDWN5X.js";var C={name:"wc",summary:"print newline, word, and byte counts for each file",usage:"wc [OPTION]... [FILE]...",options:["-c, --bytes print the byte counts","-m, --chars print the character counts","-l, --lines print the newline counts","-w, --words print the word counts"," --help display this help and exit"]},S={lines:{short:"l",long:"lines",type:"boolean"},words:{short:"w",long:"words",type:"boolean"},bytes:{short:"c",long:"bytes",type:"boolean"},chars:{short:"m",long:"chars",type:"boolean"}},L={name:"wc",async execute(n,l){if(m(n))return w(C);let r=g("wc",n,S);if(!r.ok)return r.error;let{lines:s,words:t}=r.result.flags,e=r.result.flags.bytes||r.result.flags.chars,o=r.result.positional;!s&&!t&&!e&&(s=t=e=!0);let i=await y(l,o,{cmdName:"wc",stopOnError:!1});if(o.length===0){let f=b(i.files[0].content);return{stdout:`${h(f,s,t,e,"")}
3
+ `,stderr:"",exitCode:0}}let c="",u=0,d=0,p=0;for(let{filename:f,content:x}of i.files){let a=b(x);u+=a.lines,d+=a.words,p+=a.chars,c+=`${h(a,s,t,e,f)}
4
+ `}return o.length>1&&(c+=`${h({lines:u,words:d,chars:p},s,t,e,"total")}
5
+ `),{stdout:c,stderr:i.stderr,exitCode:i.exitCode}}};function b(n){let l=n.length,r=0,s=0,t=!1;for(let e=0;e<l;e++){let o=n[e];o===`
6
+ `?(r++,t&&(s++,t=!1)):o===" "||o===" "||o==="\r"?t&&(s++,t=!1):t=!0}return t&&s++,{lines:r,words:s,chars:l}}function h(n,l,r,s,t){let e=[];l&&e.push(String(n.lines)),r&&e.push(String(n.words)),s&&e.push(String(n.chars));let o=e.join(" ");return t&&(o+=` ${t}`),o}export{L as wcCommand};
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import{a as u}from"./chunk-TA7RUHGQ.js";import{a as f,b as h}from"./chunk-GTNBSMZR.js";import"./chunk-SJXDWN5X.js";var w={name:"which",summary:"locate a command",usage:"which [-as] program ...",options:["-a List all instances of executables found","-s No output, just return 0 if found, 1 if not","--help display this help and exit"]},g={showAll:{short:"a",type:"boolean"},silent:{short:"s",type:"boolean"}},A={name:"which",async execute(s,e){if(h(s))return f(w);let t=u("which",s,g);if(!t.ok)return t.error;let c=t.result.flags.showAll,p=t.result.flags.silent,o=t.result.positional;if(o.length===0)return{stdout:"",stderr:"",exitCode:1};let d=(e.env.PATH||"/bin:/usr/bin").split(":"),n="",r=!0;for(let m of o){let a=!1;for(let i of d){if(!i)continue;let l=`${i}/${m}`;if(await e.fs.exists(l)&&(a=!0,p||(n+=`${l}
3
+ `),!c))break}a||(r=!1)}return{stdout:n,stderr:"",exitCode:r?0:1}}};export{A as whichCommand};
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ import{a as b,b as A,c as w}from"./chunk-GTNBSMZR.js";import"./chunk-SJXDWN5X.js";var P={name:"xargs",summary:"build and execute command lines from standard input",usage:"xargs [OPTION]... [COMMAND [INITIAL-ARGS]]",options:["-I REPLACE replace occurrences of REPLACE with input","-n NUM use at most NUM arguments per command line","-P NUM run at most NUM processes at a time","-0, --null items are separated by null, not whitespace","-t, --verbose print commands before executing","-r, --no-run-if-empty do not run command if input is empty"," --help display this help and exit"]},E={name:"xargs",async execute(n,u){if(A(n))return b(P);let p=null,c=null,l=null,h=!1,x=!1,g=!1,r=0;for(let t=0;t<n.length;t++){let e=n[t];if(e==="-I"&&t+1<n.length)p=n[++t],r=t+1;else if(e==="-n"&&t+1<n.length)c=parseInt(n[++t],10),r=t+1;else if(e==="-P"&&t+1<n.length)l=parseInt(n[++t],10),r=t+1;else if(e==="-0"||e==="--null")h=!0,r=t+1;else if(e==="-t"||e==="--verbose")x=!0,r=t+1;else if(e==="-r"||e==="--no-run-if-empty")g=!0,r=t+1;else{if(e.startsWith("--"))return w("xargs",e);if(e.startsWith("-")&&e.length>1){for(let s of e.slice(1))if(!"0tr".includes(s))return w("xargs",`-${s}`);e.includes("0")&&(h=!0),e.includes("t")&&(x=!0),e.includes("r")&&(g=!0),r=t+1}else if(!e.startsWith("-")){r=t;break}}}let o=n.slice(r);o.length===0&&o.push("echo");let I=h?"\0":/\s+/,i=u.stdin.split(I).map(t=>t.trim()).filter(t=>t.length>0);if(i.length===0)return g?{stdout:"",stderr:"",exitCode:0}:{stdout:"",stderr:"",exitCode:0};let d="",a="",m=0,C=async t=>{let e=t.join(" ");return x&&(a+=`${e}
3
+ `),u.exec?u.exec(e,{cwd:u.cwd}):{stdout:`${e}
4
+ `,stderr:"",exitCode:0}},y=async t=>{if(l!==null&&l>1)for(let e=0;e<t.length;e+=l){let s=t.slice(e,e+l),N=await Promise.all(s.map(C));for(let f of N)d+=f.stdout,a+=f.stderr,f.exitCode!==0&&(m=f.exitCode)}else for(let e of t){let s=await C(e);d+=s.stdout,a+=s.stderr,s.exitCode!==0&&(m=s.exitCode)}};if(p!==null){let t=i.map(e=>o.map(s=>s.replaceAll(p,e)));await y(t)}else if(c!==null){let t=[];for(let e=0;e<i.length;e+=c){let s=i.slice(e,e+c);t.push([...o,...s])}await y(t)}else{let t=[...o,...i],e=await C(t);d+=e.stdout,a+=e.stderr,m=e.exitCode}return{stdout:d,stderr:a,exitCode:m}}};export{E as xargsCommand};
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ import{a as b,b as A,c as y}from"./chunk-GTNBSMZR.js";import"./chunk-SJXDWN5X.js";var N={name:"xargs",summary:"build and execute command lines from standard input",usage:"xargs [OPTION]... [COMMAND [INITIAL-ARGS]]",options:["-I REPLACE replace occurrences of REPLACE with input","-n NUM use at most NUM arguments per command line","-P NUM run at most NUM processes at a time","-0, --null items are separated by null, not whitespace","-t, --verbose print commands before executing","-r, --no-run-if-empty do not run command if input is empty"," --help display this help and exit"]},E={name:"xargs",async execute(n,u){if(A(n))return b(N);let h=null,c=null,l=null,x=!1,g=!1,C=!1,r=0;for(let t=0;t<n.length;t++){let e=n[t];if(e==="-I"&&t+1<n.length)h=n[++t],r=t+1;else if(e==="-n"&&t+1<n.length)c=parseInt(n[++t],10),r=t+1;else if(e==="-P"&&t+1<n.length)l=parseInt(n[++t],10),r=t+1;else if(e==="-0"||e==="--null")x=!0,r=t+1;else if(e==="-t"||e==="--verbose")g=!0,r=t+1;else if(e==="-r"||e==="--no-run-if-empty")C=!0,r=t+1;else{if(e.startsWith("--"))return y("xargs",e);if(e.startsWith("-")&&e.length>1){for(let f of e.slice(1))if(!"0trnIP".includes(f))return y("xargs",`-${f}`);e.includes("0")&&(x=!0),e.includes("t")&&(g=!0),e.includes("r")&&(C=!0),r=t+1}else if(!e.startsWith("-")){r=t;break}}}let o=n.slice(r);o.length===0&&o.push("echo");let P=x?"\0":/\s+/,i=u.stdin.split(P).map(t=>t.trim()).filter(t=>t.length>0);if(i.length===0)return C?{stdout:"",stderr:"",exitCode:0}:{stdout:"",stderr:"",exitCode:0};let d="",a="",m=0,w=async t=>{let e=t.join(" ");return g&&(a+=`${e}
3
+ `),u.exec?u.exec(e,{cwd:u.cwd}):{stdout:`${e}
4
+ `,stderr:"",exitCode:0}},I=async t=>{if(l!==null&&l>1)for(let e=0;e<t.length;e+=l){let s=t.slice(e,e+l),f=await Promise.all(s.map(w));for(let p of f)d+=p.stdout,a+=p.stderr,p.exitCode!==0&&(m=p.exitCode)}else for(let e of t){let s=await w(e);d+=s.stdout,a+=s.stderr,s.exitCode!==0&&(m=s.exitCode)}};if(h!==null){let t=i.map(e=>o.map(s=>s.replaceAll(h,e)));await I(t)}else if(c!==null){let t=[];for(let e=0;e<i.length;e+=c){let s=i.slice(e,e+c);t.push([...o,...s])}await I(t)}else{let t=[...o,...i],e=await w(t);d+=e.stdout,a+=e.stderr,m=e.exitCode}return{stdout:d,stderr:a,exitCode:m}}};export{E as xargsCommand};
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{a as U,b as K,c as H,d as ee,e as Y,f as k,g as F,h as me,i as z,j as oe,k as Fe}from"./chunks/chunk-NWWB2XRE.js";import{a as X}from"./chunks/chunk-4VDEBYW7.js";import"./chunks/chunk-5KNEBKYN.js";import*as On from"node:fs";import*as _n from"node:readline";var ur=[{name:"echo",load:async()=>(await import("./chunks/echo-DEUIS5JO.js")).echoCommand},{name:"cat",load:async()=>(await import("./chunks/cat-YZXBF5YF.js")).catCommand},{name:"printf",load:async()=>(await import("./chunks/printf-ASOYDPIK.js")).printfCommand},{name:"ls",load:async()=>(await import("./chunks/ls-C4MPAF3H.js")).lsCommand},{name:"mkdir",load:async()=>(await import("./chunks/mkdir-LWULWDHP.js")).mkdirCommand},{name:"touch",load:async()=>(await import("./chunks/touch-XCIAYF5I.js")).touchCommand},{name:"rm",load:async()=>(await import("./chunks/rm-W6CCBEMG.js")).rmCommand},{name:"cp",load:async()=>(await import("./chunks/cp-77UY7PGN.js")).cpCommand},{name:"mv",load:async()=>(await import("./chunks/mv-TDYCNSIQ.js")).mvCommand},{name:"ln",load:async()=>(await import("./chunks/ln-DB7J2W5X.js")).lnCommand},{name:"chmod",load:async()=>(await import("./chunks/chmod-3G4LK462.js")).chmodCommand},{name:"pwd",load:async()=>(await import("./chunks/pwd-X4MWD4JP.js")).pwdCommand},{name:"readlink",load:async()=>(await import("./chunks/readlink-DPNOQY67.js")).readlinkCommand},{name:"head",load:async()=>(await import("./chunks/head-VGXR3WWL.js")).headCommand},{name:"tail",load:async()=>(await import("./chunks/tail-YSVKBQ77.js")).tailCommand},{name:"wc",load:async()=>(await import("./chunks/wc-CNJ3QDRA.js")).wcCommand},{name:"stat",load:async()=>(await import("./chunks/stat-3PHITCPO.js")).statCommand},{name:"grep",load:async()=>(await import("./chunks/grep-PHBFGJCV.js")).grepCommand},{name:"fgrep",load:async()=>(await import("./chunks/grep-PHBFGJCV.js")).fgrepCommand},{name:"egrep",load:async()=>(await import("./chunks/grep-PHBFGJCV.js")).egrepCommand},{name:"sed",load:async()=>(await import("./chunks/sed-LTCVBSRV.js")).sedCommand},{name:"awk",load:async()=>(await import("./chunks/awk2-4DKPX43H.js")).awkCommand2},{name:"sort",load:async()=>(await import("./chunks/sort-UJP353TM.js")).sortCommand},{name:"uniq",load:async()=>(await import("./chunks/uniq-W4HF6YSB.js")).uniqCommand},{name:"cut",load:async()=>(await import("./chunks/cut-UYV3FM7R.js")).cutCommand},{name:"paste",load:async()=>(await import("./chunks/paste-R36J3G4K.js")).pasteCommand},{name:"tr",load:async()=>(await import("./chunks/tr-2EEKHHO6.js")).trCommand},{name:"tee",load:async()=>(await import("./chunks/tee-UU2VS3OM.js")).teeCommand},{name:"find",load:async()=>(await import("./chunks/find-NCI6KGUI.js")).findCommand},{name:"basename",load:async()=>(await import("./chunks/basename-Y7JDBYHN.js")).basenameCommand},{name:"dirname",load:async()=>(await import("./chunks/dirname-VLHP44TU.js")).dirnameCommand},{name:"tree",load:async()=>(await import("./chunks/tree-4247W67O.js")).treeCommand},{name:"du",load:async()=>(await import("./chunks/du-4FZ7WF2P.js")).duCommand},{name:"env",load:async()=>(await import("./chunks/env-AKGX6HSG.js")).envCommand},{name:"printenv",load:async()=>(await import("./chunks/env-AKGX6HSG.js")).printenvCommand},{name:"alias",load:async()=>(await import("./chunks/alias-74DFXE2E.js")).aliasCommand},{name:"unalias",load:async()=>(await import("./chunks/alias-74DFXE2E.js")).unaliasCommand},{name:"history",load:async()=>(await import("./chunks/history-PRQ4B6N2.js")).historyCommand},{name:"xargs",load:async()=>(await import("./chunks/xargs-DKUAYNEK.js")).xargsCommand},{name:"true",load:async()=>(await import("./chunks/true-JCX733LK.js")).trueCommand},{name:"false",load:async()=>(await import("./chunks/true-JCX733LK.js")).falseCommand},{name:"clear",load:async()=>(await import("./chunks/clear-GTCFHSB2.js")).clearCommand},{name:"bash",load:async()=>(await import("./chunks/bash-5IWSVGHN.js")).bashCommand},{name:"sh",load:async()=>(await import("./chunks/bash-5IWSVGHN.js")).shCommand},{name:"jq",load:async()=>(await import("./chunks/jq-EYSXBSCP.js")).jqCommand},{name:"base64",load:async()=>(await import("./chunks/base64-NC7HTKLZ.js")).base64Command},{name:"diff",load:async()=>(await import("./chunks/diff-TG2NXCX2.js")).diffCommand},{name:"date",load:async()=>(await import("./chunks/date-7NBRXV2Z.js")).dateCommand},{name:"sleep",load:async()=>(await import("./chunks/sleep-E4DIYGTT.js")).sleepCommand},{name:"timeout",load:async()=>(await import("./chunks/timeout-RP2AJGMV.js")).timeoutCommand},{name:"seq",load:async()=>(await import("./chunks/seq-DGJILX2Q.js")).seqCommand},{name:"expr",load:async()=>(await import("./chunks/expr-HA2ZNL6S.js")).exprCommand},{name:"html-to-markdown",load:async()=>(await import("./chunks/html-to-markdown-L4UWMK4S.js")).htmlToMarkdownCommand},{name:"help",load:async()=>(await import("./chunks/help-YQGNAT2T.js")).helpCommand},{name:"which",load:async()=>(await import("./chunks/which-HX2NMOP3.js")).whichCommand}],Ln=[{name:"curl",load:async()=>(await import("./chunks/curl-NE7XEWMN.js")).curlCommand}],hr=new Map;function dr(t){return{name:t.name,async execute(e,n){let r=hr.get(t.name);return r||(r=await t.load(),hr.set(t.name,r)),r.execute(e,n)}}}function mr(t){return(t?ur.filter(n=>t.includes(n.name)):ur).map(dr)}function pr(){return Ln.map(dr)}function yr(t){return"load"in t&&typeof t.load=="function"}function Er(t){let e=null;return{name:t.name,async execute(n,r){return e||(e=await t.load()),e.execute(n,r)}}}var Tn=new TextEncoder,Wn=new TextDecoder;function Ae(t,e){if(t instanceof Uint8Array)return t;switch(e){case"base64":return Uint8Array.from(atob(t),n=>n.charCodeAt(0));case"hex":{let n=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2)n[r/2]=parseInt(t.slice(r,r+2),16);return n}case"binary":case"latin1":return Uint8Array.from(t,n=>n.charCodeAt(0));default:return Tn.encode(t)}}function Me(t,e){switch(e){case"base64":return btoa(String.fromCharCode(...t));case"hex":return Array.from(t).map(n=>n.toString(16).padStart(2,"0")).join("");case"binary":case"latin1":return String.fromCharCode(...t);default:return Wn.decode(t)}}function ae(t){if(t!=null)return typeof t=="string"?t:t.encoding??void 0}var Be=new TextEncoder;function Fn(t){return typeof t=="object"&&t!==null&&!(t instanceof Uint8Array)&&"content"in t}var pe=class{data=new Map;constructor(e){if(this.data.set("/",{type:"directory",mode:493,mtime:new Date}),e)for(let[n,r]of Object.entries(e))Fn(r)?this.writeFileSync(n,r.content,void 0,{mode:r.mode,mtime:r.mtime}):this.writeFileSync(n,r)}normalizePath(e){if(!e||e==="/")return"/";let n=e.endsWith("/")&&e!=="/"?e.slice(0,-1):e;n.startsWith("/")||(n=`/${n}`);let r=n.split("/").filter(o=>o&&o!=="."),s=[];for(let o of r)o===".."?s.pop():s.push(o);return`/${s.join("/")}`||"/"}dirname(e){let n=this.normalizePath(e);if(n==="/")return"/";let r=n.lastIndexOf("/");return r===0?"/":n.slice(0,r)}ensureParentDirs(e){let n=this.dirname(e);n!=="/"&&(this.data.has(n)||(this.ensureParentDirs(n),this.data.set(n,{type:"directory",mode:493,mtime:new Date})))}writeFileSync(e,n,r,s){let o=this.normalizePath(e);this.ensureParentDirs(o);let i=ae(r),a=Ae(n,i);this.data.set(o,{type:"file",content:a,mode:s?.mode??420,mtime:s?.mtime??new Date})}async readFile(e,n){let r=await this.readFileBuffer(e),s=ae(n);return Me(r,s)}async readFileBuffer(e){let n=this.normalizePath(e),r=this.data.get(n),s=n;if(!r)throw new Error(`ENOENT: no such file or directory, open '${e}'`);let o=new Set;for(;r&&r.type==="symlink";){if(o.has(s))throw new Error(`ELOOP: too many levels of symbolic links, open '${e}'`);o.add(s),s=this.resolveSymlink(s,r.target),r=this.data.get(s)}if(!r)throw new Error(`ENOENT: no such file or directory, open '${e}'`);if(r.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${e}'`);return r.content instanceof Uint8Array?r.content:Be.encode(r.content)}async writeFile(e,n,r){this.writeFileSync(e,n,r)}async appendFile(e,n,r){let s=this.normalizePath(e),o=this.data.get(s);if(o&&o.type==="directory")throw new Error(`EISDIR: illegal operation on a directory, write '${e}'`);let i=ae(r),a=Ae(n,i);if(o?.type==="file"){let l=o.content instanceof Uint8Array?o.content:Be.encode(o.content),c=new Uint8Array(l.length+a.length);c.set(l),c.set(a,l.length),this.data.set(s,{type:"file",content:c,mode:o.mode,mtime:new Date})}else this.writeFileSync(e,n,r)}async exists(e){return this.data.has(this.normalizePath(e))}async stat(e){let n=this.normalizePath(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, stat '${e}'`);if(r.type==="symlink"){let o=this.resolveSymlink(n,r.target),i=this.data.get(o);if(!i)throw new Error(`ENOENT: no such file or directory, stat '${e}'`);r=i}let s=0;return r.type==="file"&&r.content&&(r.content instanceof Uint8Array?s=r.content.length:s=Be.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:s,mtime:r.mtime||new Date}}async lstat(e){let n=this.normalizePath(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, lstat '${e}'`);if(r.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:r.mode,size:r.target.length,mtime:r.mtime||new Date};let s=0;return r.type==="file"&&r.content&&(r.content instanceof Uint8Array?s=r.content.length:s=Be.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:s,mtime:r.mtime||new Date}}resolveSymlink(e,n){if(n.startsWith("/"))return this.normalizePath(n);let r=this.dirname(e);return this.normalizePath(r==="/"?`/${n}`:`${r}/${n}`)}async mkdir(e,n){this.mkdirSync(e,n)}mkdirSync(e,n){let r=this.normalizePath(e);if(this.data.has(r)){if(this.data.get(r)?.type==="file")throw new Error(`EEXIST: file already exists, mkdir '${e}'`);if(!n?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${e}'`);return}let s=this.dirname(r);if(s!=="/"&&!this.data.has(s))if(n?.recursive)this.mkdirSync(s,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${e}'`);this.data.set(r,{type:"directory",mode:493,mtime:new Date})}async readdir(e){let n=this.normalizePath(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);if(r.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${e}'`);let s=n==="/"?"/":`${n}/`,o=[];for(let i of this.data.keys())if(i!==n&&i.startsWith(s)){let l=i.slice(s.length).split("/")[0];l&&!o.includes(l)&&o.push(l)}return o.sort()}async rm(e,n){let r=this.normalizePath(e),s=this.data.get(r);if(!s){if(n?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${e}'`)}if(s.type==="directory"){let o=await this.readdir(r);if(o.length>0){if(!n?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${e}'`);for(let i of o){let a=r==="/"?`/${i}`:`${r}/${i}`;await this.rm(a,n)}}}this.data.delete(r)}async cp(e,n,r){let s=this.normalizePath(e),o=this.normalizePath(n),i=this.data.get(s);if(!i)throw new Error(`ENOENT: no such file or directory, cp '${e}'`);if(i.type==="file")this.ensureParentDirs(o),this.data.set(o,{...i});else if(i.type==="directory"){if(!r?.recursive)throw new Error(`EISDIR: is a directory, cp '${e}'`);await this.mkdir(o,{recursive:!0});let a=await this.readdir(s);for(let l of a){let c=s==="/"?`/${l}`:`${s}/${l}`,f=o==="/"?`/${l}`:`${o}/${l}`;await this.cp(c,f,r)}}}async mv(e,n){await this.cp(e,n,{recursive:!0}),await this.rm(e,{recursive:!0})}getAllPaths(){return Array.from(this.data.keys())}resolvePath(e,n){if(n.startsWith("/"))return this.normalizePath(n);let r=e==="/"?`/${n}`:`${e}/${n}`;return this.normalizePath(r)}async chmod(e,n){let r=this.normalizePath(e),s=this.data.get(r);if(!s)throw new Error(`ENOENT: no such file or directory, chmod '${e}'`);s.mode=n}async symlink(e,n){let r=this.normalizePath(n);if(this.data.has(r))throw new Error(`EEXIST: file already exists, symlink '${n}'`);this.ensureParentDirs(r),this.data.set(r,{type:"symlink",target:e,mode:511,mtime:new Date})}async link(e,n){let r=this.normalizePath(e),s=this.normalizePath(n),o=this.data.get(r);if(!o)throw new Error(`ENOENT: no such file or directory, link '${e}'`);if(o.type!=="file")throw new Error(`EPERM: operation not permitted, link '${e}'`);if(this.data.has(s))throw new Error(`EEXIST: file already exists, link '${n}'`);this.ensureParentDirs(s),this.data.set(s,{type:"file",content:o.content,mode:o.mode,mtime:o.mtime})}async readlink(e){let n=this.normalizePath(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, readlink '${e}'`);if(r.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${e}'`);return r.target}};function L(t,e){return{type:"ArithmeticExpression",expression:te(t,e,0).expr}}function te(t,e,n){return Mn(t,e,n)}function Mn(t,e,n){let{expr:r,pos:s}=Ue(t,e,n);for(s=D(e,s);e[s]===",";){s++;let{expr:o,pos:i}=Ue(t,e,s);r={type:"ArithBinary",operator:",",left:r,right:o},s=D(e,i)}return{expr:r,pos:s}}function Ue(t,e,n){let{expr:r,pos:s}=Bn(t,e,n);if(s=D(e,s),e[s]==="?"){s++;let{expr:o,pos:i}=te(t,e,s);if(s=D(e,i),e[s]===":"){s++;let{expr:a,pos:l}=te(t,e,s);return{expr:{type:"ArithTernary",condition:r,consequent:o,alternate:a},pos:l}}}return{expr:r,pos:s}}function Bn(t,e,n){let{expr:r,pos:s}=wr(t,e,n);for(;s=D(e,s),e.slice(s,s+2)==="||";){s+=2;let{expr:o,pos:i}=wr(t,e,s);r={type:"ArithBinary",operator:"||",left:r,right:o},s=i}return{expr:r,pos:s}}function wr(t,e,n){let{expr:r,pos:s}=gr(t,e,n);for(;s=D(e,s),e.slice(s,s+2)==="&&";){s+=2;let{expr:o,pos:i}=gr(t,e,s);r={type:"ArithBinary",operator:"&&",left:r,right:o},s=i}return{expr:r,pos:s}}function gr(t,e,n){let{expr:r,pos:s}=Ar(t,e,n);for(;s=D(e,s),e[s]==="|"&&e[s+1]!=="|";){s++;let{expr:o,pos:i}=Ar(t,e,s);r={type:"ArithBinary",operator:"|",left:r,right:o},s=i}return{expr:r,pos:s}}function Ar(t,e,n){let{expr:r,pos:s}=xr(t,e,n);for(;s=D(e,s),e[s]==="^";){s++;let{expr:o,pos:i}=xr(t,e,s);r={type:"ArithBinary",operator:"^",left:r,right:o},s=i}return{expr:r,pos:s}}function xr(t,e,n){let{expr:r,pos:s}=Sr(t,e,n);for(;s=D(e,s),e[s]==="&"&&e[s+1]!=="&";){s++;let{expr:o,pos:i}=Sr(t,e,s);r={type:"ArithBinary",operator:"&",left:r,right:o},s=i}return{expr:r,pos:s}}function Sr(t,e,n){let{expr:r,pos:s}=br(t,e,n);for(;s=D(e,s),e.slice(s,s+2)==="=="||e.slice(s,s+2)==="!=";){let o=e.slice(s,s+2);s+=2;let{expr:i,pos:a}=br(t,e,s);r={type:"ArithBinary",operator:o,left:r,right:i},s=a}return{expr:r,pos:s}}function br(t,e,n){let{expr:r,pos:s}=yt(t,e,n);for(;;)if(s=D(e,s),e.slice(s,s+2)==="<="||e.slice(s,s+2)===">="){let o=e.slice(s,s+2);s+=2;let{expr:i,pos:a}=yt(t,e,s);r={type:"ArithBinary",operator:o,left:r,right:i},s=a}else if(e[s]==="<"||e[s]===">"){let o=e[s];s++;let{expr:i,pos:a}=yt(t,e,s);r={type:"ArithBinary",operator:o,left:r,right:i},s=a}else break;return{expr:r,pos:s}}function yt(t,e,n){let{expr:r,pos:s}=Cr(t,e,n);for(;s=D(e,s),e.slice(s,s+2)==="<<"||e.slice(s,s+2)===">>";){let o=e.slice(s,s+2);s+=2;let{expr:i,pos:a}=Cr(t,e,s);r={type:"ArithBinary",operator:o,left:r,right:i},s=a}return{expr:r,pos:s}}function Cr(t,e,n){let{expr:r,pos:s}=Nr(t,e,n);for(;s=D(e,s),(e[s]==="+"||e[s]==="-")&&e[s+1]!==e[s];){let o=e[s];s++;let{expr:i,pos:a}=Nr(t,e,s);r={type:"ArithBinary",operator:o,left:r,right:i},s=a}return{expr:r,pos:s}}function Nr(t,e,n){let{expr:r,pos:s}=ze(t,e,n);for(;;)if(s=D(e,s),e[s]==="*"&&e[s+1]!=="*"){s++;let{expr:o,pos:i}=ze(t,e,s);r={type:"ArithBinary",operator:"*",left:r,right:o},s=i}else if(e[s]==="/"||e[s]==="%"){let o=e[s];s++;let{expr:i,pos:a}=ze(t,e,s);r={type:"ArithBinary",operator:o,left:r,right:i},s=a}else break;return{expr:r,pos:s}}function ze(t,e,n){let{expr:r,pos:s}=Et(t,e,n),o=D(e,s);if(e.slice(o,o+2)==="**"){o+=2;let{expr:i,pos:a}=ze(t,e,o);return{expr:{type:"ArithBinary",operator:"**",left:r,right:i},pos:a}}return{expr:r,pos:s}}function Et(t,e,n){let r=D(e,n);if(e.slice(r,r+2)==="++"||e.slice(r,r+2)==="--"){let s=e.slice(r,r+2);r+=2;let{expr:o,pos:i}=Et(t,e,r);return{expr:{type:"ArithUnary",operator:s,operand:o,prefix:!0},pos:i}}if(e[r]==="+"||e[r]==="-"||e[r]==="!"||e[r]==="~"){let s=e[r];r++;let{expr:o,pos:i}=Et(t,e,r);return{expr:{type:"ArithUnary",operator:s,operand:o,prefix:!0},pos:i}}return Un(t,e,r)}function zn(t,e){let n=t[e];return n==="$"||n==="`"}function Un(t,e,n){let{expr:r,pos:s}=$r(t,e,n),o=[r];for(;zn(e,s);){let{expr:i,pos:a}=$r(t,e,s);o.push(i),s=a}if(o.length>1&&(r={type:"ArithConcat",parts:o}),s=D(e,s),e.slice(s,s+2)==="++"||e.slice(s,s+2)==="--"){let i=e.slice(s,s+2);return s+=2,{expr:{type:"ArithUnary",operator:i,operand:r,prefix:!1},pos:s}}return{expr:r,pos:s}}function $r(t,e,n){let r=D(e,n);if(e.slice(r,r+3)==="$(("){r+=3;let s=1,o=r;for(;r<e.length-1&&s>0;)e[r]==="("&&e[r+1]==="("?(s++,r+=2):e[r]===")"&&e[r+1]===")"?(s--,s>0&&(r+=2)):r++;let i=e.slice(o,r),{expr:a}=te(t,i,0);return r+=2,{expr:{type:"ArithNested",expression:a},pos:r}}if(e.slice(r,r+2)==="$("&&e[r+2]!=="("){r+=2;let s=1,o=r;for(;r<e.length&&s>0;)e[r]==="("?s++:e[r]===")"&&s--,s>0&&r++;let i=e.slice(o,r);return r++,{expr:{type:"ArithCommandSubst",command:i},pos:r}}if(e[r]==="`"){r++;let s=r;for(;r<e.length&&e[r]!=="`";)r++;let o=e.slice(s,r);return e[r]==="`"&&r++,{expr:{type:"ArithCommandSubst",command:o},pos:r}}if(e[r]==="("){r++;let{expr:s,pos:o}=te(t,e,r);return r=D(e,o),e[r]===")"&&r++,{expr:{type:"ArithGroup",expression:s},pos:r}}if(/[0-9]/.test(e[r])){let s="",o=!1;for(;r<e.length;){let a=e[r];if(o)if(/[0-9a-zA-Z@_]/.test(a))s+=a,r++;else break;else if(a==="#")o=!0,s+=a,r++;else if(/[0-9a-fA-FxX]/.test(a))s+=a,r++;else break}if(e[r]==="."&&/[0-9]/.test(e[r+1]))throw new F(`${s}.${e[r+1]}...: syntax error: invalid arithmetic operator`);if(e[r]==="["){let a=e.slice(r).trim();return{expr:{type:"ArithNumberSubscript",number:s,errorToken:a},pos:e.length}}return{expr:{type:"ArithNumber",value:xe(s)},pos:r}}if(e[r]==="$"&&e[r+1]==="{"){let s=r+2,o=1,i=s;for(;i<e.length&&o>0;)e[i]==="{"?o++:e[i]==="}"&&o--,o>0&&i++;let a=e.slice(s,i),l=i+1;if(e[l]==="#"){let c=l+1;for(;c<e.length&&/[0-9a-zA-Z@_]/.test(e[c]);)c++;let f=e.slice(l+1,c);return{expr:{type:"ArithDynamicBase",baseExpr:a,value:f},pos:c}}if(/[0-9]/.test(e[l])||e[l]==="x"||e[l]==="X"){let c=l;if(e[l]==="x"||e[l]==="X")for(c++;c<e.length&&/[0-9a-fA-F]/.test(e[c]);)c++;else for(;c<e.length&&/[0-9]/.test(e[c]);)c++;let f=e.slice(l,c);return{expr:{type:"ArithDynamicNumber",prefix:a,suffix:f},pos:c}}return r=l,{expr:{type:"ArithBracedExpansion",content:a},pos:r}}if(e[r]==="$"&&r+1<e.length&&/[0-9]/.test(e[r+1])){r++;let s="";for(;r<e.length&&/[0-9]/.test(e[r]);)s+=e[r],r++;return{expr:{type:"ArithVariable",name:s},pos:r}}if(e[r]==="$"&&r+1<e.length&&/[a-zA-Z_]/.test(e[r+1])&&r++,/[a-zA-Z_]/.test(e[r])){let s="";for(;r<e.length&&/[a-zA-Z0-9_]/.test(e[r]);)s+=e[r],r++;if(e[r]==="["){r++;let i;if(e[r]==="'"||e[r]==='"'){let c=e[r];for(r++,i="";r<e.length&&e[r]!==c;)i+=e[r],r++;e[r]===c&&r++,r=D(e,r),e[r]==="]"&&r++}let a;if(i===void 0){let{expr:c,pos:f}=te(t,e,r);a=c,r=f,e[r]==="]"&&r++}if(r=D(e,r),e[r]==="["&&a)return{expr:{type:"ArithDoubleSubscript",array:s,index:a},pos:r};let l=["=","+=","-=","*=","/=","%=","<<=",">>=","&=","|=","^="];for(let c of l)if(e.slice(r,r+c.length)===c&&e.slice(r,r+c.length+1)!=="=="){r+=c.length;let{expr:f,pos:h}=Ue(t,e,r);return{expr:{type:"ArithAssignment",operator:c,variable:s,subscript:a,stringKey:i,value:f},pos:h}}return{expr:{type:"ArithArrayElement",array:s,index:a,stringKey:i},pos:r}}r=D(e,r);let o=["=","+=","-=","*=","/=","%=","<<=",">>=","&=","|=","^="];for(let i of o)if(e.slice(r,r+i.length)===i&&e.slice(r,r+i.length+1)!=="=="){r+=i.length;let{expr:a,pos:l}=Ue(t,e,r);return{expr:{type:"ArithAssignment",operator:i,variable:s,value:a},pos:l}}return{expr:{type:"ArithVariable",name:s},pos:r}}return{expr:{type:"ArithNumber",value:0},pos:r}}function xe(t){if(t.includes("#")){let[e,n]=t.split("#"),r=Number.parseInt(e,10);if(r<2||r>64)return Number.NaN;if(r<=36)return Number.parseInt(n,r);let s=0;for(let o of n){let i;if(o>="0"&&o<="9")i=o.charCodeAt(0)-48;else if(o>="a"&&o<="z")i=o.charCodeAt(0)-97+10;else if(o>="A"&&o<="Z")i=o.charCodeAt(0)-65+36;else if(o==="@")i=62;else if(o==="_")i=63;else return Number.NaN;if(i>=r)return Number.NaN;s=s*r+i}return s}return t.startsWith("0x")||t.startsWith("0X")?Number.parseInt(t.slice(2),16):t.startsWith("0")&&t.length>1&&/^[0-9]+$/.test(t)?/[89]/.test(t)?Number.NaN:Number.parseInt(t,8):Number.parseInt(t,10)}function D(t,e){for(;e<t.length;){if(t[e]==="\\"&&t[e+1]===`
2
+ import{a as U,b as K,c as H,d as ee,e as Y,f as k,g as F,h as me,i as z,j as oe,k as Fe}from"./chunks/chunk-NWWB2XRE.js";import{a as X}from"./chunks/chunk-4VDEBYW7.js";import"./chunks/chunk-SJXDWN5X.js";import*as On from"node:fs";import*as _n from"node:readline";var ur=[{name:"echo",load:async()=>(await import("./chunks/echo-HKLPYMNC.js")).echoCommand},{name:"cat",load:async()=>(await import("./chunks/cat-XILYL7NW.js")).catCommand},{name:"printf",load:async()=>(await import("./chunks/printf-2JFCUFOA.js")).printfCommand},{name:"ls",load:async()=>(await import("./chunks/ls-GU5227KE.js")).lsCommand},{name:"mkdir",load:async()=>(await import("./chunks/mkdir-4OYU22AA.js")).mkdirCommand},{name:"touch",load:async()=>(await import("./chunks/touch-3ZANYAXI.js")).touchCommand},{name:"rm",load:async()=>(await import("./chunks/rm-R4M647EC.js")).rmCommand},{name:"cp",load:async()=>(await import("./chunks/cp-HES4UN7K.js")).cpCommand},{name:"mv",load:async()=>(await import("./chunks/mv-H3S4FEWR.js")).mvCommand},{name:"ln",load:async()=>(await import("./chunks/ln-RUR4ALOJ.js")).lnCommand},{name:"chmod",load:async()=>(await import("./chunks/chmod-EXWX4N7Y.js")).chmodCommand},{name:"pwd",load:async()=>(await import("./chunks/pwd-T5Q3JEBO.js")).pwdCommand},{name:"readlink",load:async()=>(await import("./chunks/readlink-M44TLMFS.js")).readlinkCommand},{name:"head",load:async()=>(await import("./chunks/head-YGMY3DHE.js")).headCommand},{name:"tail",load:async()=>(await import("./chunks/tail-BYPLMYMZ.js")).tailCommand},{name:"wc",load:async()=>(await import("./chunks/wc-NBMNJDZL.js")).wcCommand},{name:"stat",load:async()=>(await import("./chunks/stat-CR2INBC2.js")).statCommand},{name:"grep",load:async()=>(await import("./chunks/grep-BEZRXAWL.js")).grepCommand},{name:"fgrep",load:async()=>(await import("./chunks/grep-BEZRXAWL.js")).fgrepCommand},{name:"egrep",load:async()=>(await import("./chunks/grep-BEZRXAWL.js")).egrepCommand},{name:"sed",load:async()=>(await import("./chunks/sed-QLLAZYHH.js")).sedCommand},{name:"awk",load:async()=>(await import("./chunks/awk2-A73ZNFXJ.js")).awkCommand2},{name:"sort",load:async()=>(await import("./chunks/sort-JL33INQB.js")).sortCommand},{name:"uniq",load:async()=>(await import("./chunks/uniq-F5NP3LLU.js")).uniqCommand},{name:"comm",load:async()=>(await import("./chunks/comm-KY3COLF5.js")).commCommand},{name:"cut",load:async()=>(await import("./chunks/cut-JSIPAKOX.js")).cutCommand},{name:"paste",load:async()=>(await import("./chunks/paste-HHCFASL4.js")).pasteCommand},{name:"tr",load:async()=>(await import("./chunks/tr-E66N7IS2.js")).trCommand},{name:"tee",load:async()=>(await import("./chunks/tee-HOMRRC3X.js")).teeCommand},{name:"find",load:async()=>(await import("./chunks/find-D3ZC5DXH.js")).findCommand},{name:"basename",load:async()=>(await import("./chunks/basename-IYEP3AMY.js")).basenameCommand},{name:"dirname",load:async()=>(await import("./chunks/dirname-UTCUUILN.js")).dirnameCommand},{name:"tree",load:async()=>(await import("./chunks/tree-EE2PYIMV.js")).treeCommand},{name:"du",load:async()=>(await import("./chunks/du-2JU3PUTM.js")).duCommand},{name:"env",load:async()=>(await import("./chunks/env-2SBJNP7X.js")).envCommand},{name:"printenv",load:async()=>(await import("./chunks/env-2SBJNP7X.js")).printenvCommand},{name:"alias",load:async()=>(await import("./chunks/alias-ZAQAKC5X.js")).aliasCommand},{name:"unalias",load:async()=>(await import("./chunks/alias-ZAQAKC5X.js")).unaliasCommand},{name:"history",load:async()=>(await import("./chunks/history-OGBCIAR5.js")).historyCommand},{name:"xargs",load:async()=>(await import("./chunks/xargs-EMY5BOJ2.js")).xargsCommand},{name:"true",load:async()=>(await import("./chunks/true-OWPVS7U4.js")).trueCommand},{name:"false",load:async()=>(await import("./chunks/true-OWPVS7U4.js")).falseCommand},{name:"clear",load:async()=>(await import("./chunks/clear-2APRIRCF.js")).clearCommand},{name:"bash",load:async()=>(await import("./chunks/bash-WZYHIZP6.js")).bashCommand},{name:"sh",load:async()=>(await import("./chunks/bash-WZYHIZP6.js")).shCommand},{name:"jq",load:async()=>(await import("./chunks/jq-ME57VHK6.js")).jqCommand},{name:"base64",load:async()=>(await import("./chunks/base64-JPITV4MD.js")).base64Command},{name:"diff",load:async()=>(await import("./chunks/diff-W4JRNHXW.js")).diffCommand},{name:"date",load:async()=>(await import("./chunks/date-CU4J7GHI.js")).dateCommand},{name:"sleep",load:async()=>(await import("./chunks/sleep-OJPODQGM.js")).sleepCommand},{name:"timeout",load:async()=>(await import("./chunks/timeout-MYKG34DQ.js")).timeoutCommand},{name:"seq",load:async()=>(await import("./chunks/seq-GJMQM7SP.js")).seqCommand},{name:"expr",load:async()=>(await import("./chunks/expr-M74QZQ6C.js")).exprCommand},{name:"md5sum",load:async()=>(await import("./chunks/md5sum-C7WDEYN5.js")).md5sumCommand},{name:"sha1sum",load:async()=>(await import("./chunks/sha1sum-WKCGV66X.js")).sha1sumCommand},{name:"sha256sum",load:async()=>(await import("./chunks/sha256sum-3ZDGP5WC.js")).sha256sumCommand},{name:"file",load:async()=>(await import("./chunks/file-QPD3U2H7.js")).fileCommand},{name:"html-to-markdown",load:async()=>(await import("./chunks/html-to-markdown-HTGML4TH.js")).htmlToMarkdownCommand},{name:"help",load:async()=>(await import("./chunks/help-UEF7LW7F.js")).helpCommand},{name:"which",load:async()=>(await import("./chunks/which-6MRG2UCF.js")).whichCommand}],Ln=[{name:"curl",load:async()=>(await import("./chunks/curl-BN5M3BUX.js")).curlCommand}],hr=new Map;function dr(t){return{name:t.name,async execute(e,n){let r=hr.get(t.name);return r||(r=await t.load(),hr.set(t.name,r)),r.execute(e,n)}}}function mr(t){return(t?ur.filter(n=>t.includes(n.name)):ur).map(dr)}function pr(){return Ln.map(dr)}function yr(t){return"load"in t&&typeof t.load=="function"}function Er(t){let e=null;return{name:t.name,async execute(n,r){return e||(e=await t.load()),e.execute(n,r)}}}var Tn=new TextEncoder,Wn=new TextDecoder;function Ae(t,e){if(t instanceof Uint8Array)return t;switch(e){case"base64":return Uint8Array.from(atob(t),n=>n.charCodeAt(0));case"hex":{let n=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2)n[r/2]=parseInt(t.slice(r,r+2),16);return n}case"binary":case"latin1":return Uint8Array.from(t,n=>n.charCodeAt(0));default:return Tn.encode(t)}}function Me(t,e){switch(e){case"base64":return btoa(String.fromCharCode(...t));case"hex":return Array.from(t).map(n=>n.toString(16).padStart(2,"0")).join("");case"binary":case"latin1":return String.fromCharCode(...t);default:return Wn.decode(t)}}function ae(t){if(t!=null)return typeof t=="string"?t:t.encoding??void 0}var Be=new TextEncoder;function Fn(t){return typeof t=="object"&&t!==null&&!(t instanceof Uint8Array)&&"content"in t}var pe=class{data=new Map;constructor(e){if(this.data.set("/",{type:"directory",mode:493,mtime:new Date}),e)for(let[n,r]of Object.entries(e))Fn(r)?this.writeFileSync(n,r.content,void 0,{mode:r.mode,mtime:r.mtime}):this.writeFileSync(n,r)}normalizePath(e){if(!e||e==="/")return"/";let n=e.endsWith("/")&&e!=="/"?e.slice(0,-1):e;n.startsWith("/")||(n=`/${n}`);let r=n.split("/").filter(o=>o&&o!=="."),s=[];for(let o of r)o===".."?s.pop():s.push(o);return`/${s.join("/")}`||"/"}dirname(e){let n=this.normalizePath(e);if(n==="/")return"/";let r=n.lastIndexOf("/");return r===0?"/":n.slice(0,r)}ensureParentDirs(e){let n=this.dirname(e);n!=="/"&&(this.data.has(n)||(this.ensureParentDirs(n),this.data.set(n,{type:"directory",mode:493,mtime:new Date})))}writeFileSync(e,n,r,s){let o=this.normalizePath(e);this.ensureParentDirs(o);let i=ae(r),a=Ae(n,i);this.data.set(o,{type:"file",content:a,mode:s?.mode??420,mtime:s?.mtime??new Date})}async readFile(e,n){let r=await this.readFileBuffer(e),s=ae(n);return Me(r,s)}async readFileBuffer(e){let n=this.normalizePath(e),r=this.data.get(n),s=n;if(!r)throw new Error(`ENOENT: no such file or directory, open '${e}'`);let o=new Set;for(;r&&r.type==="symlink";){if(o.has(s))throw new Error(`ELOOP: too many levels of symbolic links, open '${e}'`);o.add(s),s=this.resolveSymlink(s,r.target),r=this.data.get(s)}if(!r)throw new Error(`ENOENT: no such file or directory, open '${e}'`);if(r.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${e}'`);return r.content instanceof Uint8Array?r.content:Be.encode(r.content)}async writeFile(e,n,r){this.writeFileSync(e,n,r)}async appendFile(e,n,r){let s=this.normalizePath(e),o=this.data.get(s);if(o&&o.type==="directory")throw new Error(`EISDIR: illegal operation on a directory, write '${e}'`);let i=ae(r),a=Ae(n,i);if(o?.type==="file"){let l=o.content instanceof Uint8Array?o.content:Be.encode(o.content),c=new Uint8Array(l.length+a.length);c.set(l),c.set(a,l.length),this.data.set(s,{type:"file",content:c,mode:o.mode,mtime:new Date})}else this.writeFileSync(e,n,r)}async exists(e){return this.data.has(this.normalizePath(e))}async stat(e){let n=this.normalizePath(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, stat '${e}'`);if(r.type==="symlink"){let o=this.resolveSymlink(n,r.target),i=this.data.get(o);if(!i)throw new Error(`ENOENT: no such file or directory, stat '${e}'`);r=i}let s=0;return r.type==="file"&&r.content&&(r.content instanceof Uint8Array?s=r.content.length:s=Be.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:s,mtime:r.mtime||new Date}}async lstat(e){let n=this.normalizePath(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, lstat '${e}'`);if(r.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:r.mode,size:r.target.length,mtime:r.mtime||new Date};let s=0;return r.type==="file"&&r.content&&(r.content instanceof Uint8Array?s=r.content.length:s=Be.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:s,mtime:r.mtime||new Date}}resolveSymlink(e,n){if(n.startsWith("/"))return this.normalizePath(n);let r=this.dirname(e);return this.normalizePath(r==="/"?`/${n}`:`${r}/${n}`)}async mkdir(e,n){this.mkdirSync(e,n)}mkdirSync(e,n){let r=this.normalizePath(e);if(this.data.has(r)){if(this.data.get(r)?.type==="file")throw new Error(`EEXIST: file already exists, mkdir '${e}'`);if(!n?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${e}'`);return}let s=this.dirname(r);if(s!=="/"&&!this.data.has(s))if(n?.recursive)this.mkdirSync(s,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${e}'`);this.data.set(r,{type:"directory",mode:493,mtime:new Date})}async readdir(e){let n=this.normalizePath(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);if(r.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${e}'`);let s=n==="/"?"/":`${n}/`,o=[];for(let i of this.data.keys())if(i!==n&&i.startsWith(s)){let l=i.slice(s.length).split("/")[0];l&&!o.includes(l)&&o.push(l)}return o.sort()}async rm(e,n){let r=this.normalizePath(e),s=this.data.get(r);if(!s){if(n?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${e}'`)}if(s.type==="directory"){let o=await this.readdir(r);if(o.length>0){if(!n?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${e}'`);for(let i of o){let a=r==="/"?`/${i}`:`${r}/${i}`;await this.rm(a,n)}}}this.data.delete(r)}async cp(e,n,r){let s=this.normalizePath(e),o=this.normalizePath(n),i=this.data.get(s);if(!i)throw new Error(`ENOENT: no such file or directory, cp '${e}'`);if(i.type==="file")this.ensureParentDirs(o),this.data.set(o,{...i});else if(i.type==="directory"){if(!r?.recursive)throw new Error(`EISDIR: is a directory, cp '${e}'`);await this.mkdir(o,{recursive:!0});let a=await this.readdir(s);for(let l of a){let c=s==="/"?`/${l}`:`${s}/${l}`,f=o==="/"?`/${l}`:`${o}/${l}`;await this.cp(c,f,r)}}}async mv(e,n){await this.cp(e,n,{recursive:!0}),await this.rm(e,{recursive:!0})}getAllPaths(){return Array.from(this.data.keys())}resolvePath(e,n){if(n.startsWith("/"))return this.normalizePath(n);let r=e==="/"?`/${n}`:`${e}/${n}`;return this.normalizePath(r)}async chmod(e,n){let r=this.normalizePath(e),s=this.data.get(r);if(!s)throw new Error(`ENOENT: no such file or directory, chmod '${e}'`);s.mode=n}async symlink(e,n){let r=this.normalizePath(n);if(this.data.has(r))throw new Error(`EEXIST: file already exists, symlink '${n}'`);this.ensureParentDirs(r),this.data.set(r,{type:"symlink",target:e,mode:511,mtime:new Date})}async link(e,n){let r=this.normalizePath(e),s=this.normalizePath(n),o=this.data.get(r);if(!o)throw new Error(`ENOENT: no such file or directory, link '${e}'`);if(o.type!=="file")throw new Error(`EPERM: operation not permitted, link '${e}'`);if(this.data.has(s))throw new Error(`EEXIST: file already exists, link '${n}'`);this.ensureParentDirs(s),this.data.set(s,{type:"file",content:o.content,mode:o.mode,mtime:o.mtime})}async readlink(e){let n=this.normalizePath(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, readlink '${e}'`);if(r.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${e}'`);return r.target}};function L(t,e){return{type:"ArithmeticExpression",expression:te(t,e,0).expr}}function te(t,e,n){return Mn(t,e,n)}function Mn(t,e,n){let{expr:r,pos:s}=Ue(t,e,n);for(s=D(e,s);e[s]===",";){s++;let{expr:o,pos:i}=Ue(t,e,s);r={type:"ArithBinary",operator:",",left:r,right:o},s=D(e,i)}return{expr:r,pos:s}}function Ue(t,e,n){let{expr:r,pos:s}=Bn(t,e,n);if(s=D(e,s),e[s]==="?"){s++;let{expr:o,pos:i}=te(t,e,s);if(s=D(e,i),e[s]===":"){s++;let{expr:a,pos:l}=te(t,e,s);return{expr:{type:"ArithTernary",condition:r,consequent:o,alternate:a},pos:l}}}return{expr:r,pos:s}}function Bn(t,e,n){let{expr:r,pos:s}=wr(t,e,n);for(;s=D(e,s),e.slice(s,s+2)==="||";){s+=2;let{expr:o,pos:i}=wr(t,e,s);r={type:"ArithBinary",operator:"||",left:r,right:o},s=i}return{expr:r,pos:s}}function wr(t,e,n){let{expr:r,pos:s}=gr(t,e,n);for(;s=D(e,s),e.slice(s,s+2)==="&&";){s+=2;let{expr:o,pos:i}=gr(t,e,s);r={type:"ArithBinary",operator:"&&",left:r,right:o},s=i}return{expr:r,pos:s}}function gr(t,e,n){let{expr:r,pos:s}=Ar(t,e,n);for(;s=D(e,s),e[s]==="|"&&e[s+1]!=="|";){s++;let{expr:o,pos:i}=Ar(t,e,s);r={type:"ArithBinary",operator:"|",left:r,right:o},s=i}return{expr:r,pos:s}}function Ar(t,e,n){let{expr:r,pos:s}=xr(t,e,n);for(;s=D(e,s),e[s]==="^";){s++;let{expr:o,pos:i}=xr(t,e,s);r={type:"ArithBinary",operator:"^",left:r,right:o},s=i}return{expr:r,pos:s}}function xr(t,e,n){let{expr:r,pos:s}=Sr(t,e,n);for(;s=D(e,s),e[s]==="&"&&e[s+1]!=="&";){s++;let{expr:o,pos:i}=Sr(t,e,s);r={type:"ArithBinary",operator:"&",left:r,right:o},s=i}return{expr:r,pos:s}}function Sr(t,e,n){let{expr:r,pos:s}=br(t,e,n);for(;s=D(e,s),e.slice(s,s+2)==="=="||e.slice(s,s+2)==="!=";){let o=e.slice(s,s+2);s+=2;let{expr:i,pos:a}=br(t,e,s);r={type:"ArithBinary",operator:o,left:r,right:i},s=a}return{expr:r,pos:s}}function br(t,e,n){let{expr:r,pos:s}=yt(t,e,n);for(;;)if(s=D(e,s),e.slice(s,s+2)==="<="||e.slice(s,s+2)===">="){let o=e.slice(s,s+2);s+=2;let{expr:i,pos:a}=yt(t,e,s);r={type:"ArithBinary",operator:o,left:r,right:i},s=a}else if(e[s]==="<"||e[s]===">"){let o=e[s];s++;let{expr:i,pos:a}=yt(t,e,s);r={type:"ArithBinary",operator:o,left:r,right:i},s=a}else break;return{expr:r,pos:s}}function yt(t,e,n){let{expr:r,pos:s}=Cr(t,e,n);for(;s=D(e,s),e.slice(s,s+2)==="<<"||e.slice(s,s+2)===">>";){let o=e.slice(s,s+2);s+=2;let{expr:i,pos:a}=Cr(t,e,s);r={type:"ArithBinary",operator:o,left:r,right:i},s=a}return{expr:r,pos:s}}function Cr(t,e,n){let{expr:r,pos:s}=Nr(t,e,n);for(;s=D(e,s),(e[s]==="+"||e[s]==="-")&&e[s+1]!==e[s];){let o=e[s];s++;let{expr:i,pos:a}=Nr(t,e,s);r={type:"ArithBinary",operator:o,left:r,right:i},s=a}return{expr:r,pos:s}}function Nr(t,e,n){let{expr:r,pos:s}=ze(t,e,n);for(;;)if(s=D(e,s),e[s]==="*"&&e[s+1]!=="*"){s++;let{expr:o,pos:i}=ze(t,e,s);r={type:"ArithBinary",operator:"*",left:r,right:o},s=i}else if(e[s]==="/"||e[s]==="%"){let o=e[s];s++;let{expr:i,pos:a}=ze(t,e,s);r={type:"ArithBinary",operator:o,left:r,right:i},s=a}else break;return{expr:r,pos:s}}function ze(t,e,n){let{expr:r,pos:s}=Et(t,e,n),o=D(e,s);if(e.slice(o,o+2)==="**"){o+=2;let{expr:i,pos:a}=ze(t,e,o);return{expr:{type:"ArithBinary",operator:"**",left:r,right:i},pos:a}}return{expr:r,pos:s}}function Et(t,e,n){let r=D(e,n);if(e.slice(r,r+2)==="++"||e.slice(r,r+2)==="--"){let s=e.slice(r,r+2);r+=2;let{expr:o,pos:i}=Et(t,e,r);return{expr:{type:"ArithUnary",operator:s,operand:o,prefix:!0},pos:i}}if(e[r]==="+"||e[r]==="-"||e[r]==="!"||e[r]==="~"){let s=e[r];r++;let{expr:o,pos:i}=Et(t,e,r);return{expr:{type:"ArithUnary",operator:s,operand:o,prefix:!0},pos:i}}return Un(t,e,r)}function zn(t,e){let n=t[e];return n==="$"||n==="`"}function Un(t,e,n){let{expr:r,pos:s}=$r(t,e,n),o=[r];for(;zn(e,s);){let{expr:i,pos:a}=$r(t,e,s);o.push(i),s=a}if(o.length>1&&(r={type:"ArithConcat",parts:o}),s=D(e,s),e.slice(s,s+2)==="++"||e.slice(s,s+2)==="--"){let i=e.slice(s,s+2);return s+=2,{expr:{type:"ArithUnary",operator:i,operand:r,prefix:!1},pos:s}}return{expr:r,pos:s}}function $r(t,e,n){let r=D(e,n);if(e.slice(r,r+3)==="$(("){r+=3;let s=1,o=r;for(;r<e.length-1&&s>0;)e[r]==="("&&e[r+1]==="("?(s++,r+=2):e[r]===")"&&e[r+1]===")"?(s--,s>0&&(r+=2)):r++;let i=e.slice(o,r),{expr:a}=te(t,i,0);return r+=2,{expr:{type:"ArithNested",expression:a},pos:r}}if(e.slice(r,r+2)==="$("&&e[r+2]!=="("){r+=2;let s=1,o=r;for(;r<e.length&&s>0;)e[r]==="("?s++:e[r]===")"&&s--,s>0&&r++;let i=e.slice(o,r);return r++,{expr:{type:"ArithCommandSubst",command:i},pos:r}}if(e[r]==="`"){r++;let s=r;for(;r<e.length&&e[r]!=="`";)r++;let o=e.slice(s,r);return e[r]==="`"&&r++,{expr:{type:"ArithCommandSubst",command:o},pos:r}}if(e[r]==="("){r++;let{expr:s,pos:o}=te(t,e,r);return r=D(e,o),e[r]===")"&&r++,{expr:{type:"ArithGroup",expression:s},pos:r}}if(/[0-9]/.test(e[r])){let s="",o=!1;for(;r<e.length;){let a=e[r];if(o)if(/[0-9a-zA-Z@_]/.test(a))s+=a,r++;else break;else if(a==="#")o=!0,s+=a,r++;else if(/[0-9a-fA-FxX]/.test(a))s+=a,r++;else break}if(e[r]==="."&&/[0-9]/.test(e[r+1]))throw new F(`${s}.${e[r+1]}...: syntax error: invalid arithmetic operator`);if(e[r]==="["){let a=e.slice(r).trim();return{expr:{type:"ArithNumberSubscript",number:s,errorToken:a},pos:e.length}}return{expr:{type:"ArithNumber",value:xe(s)},pos:r}}if(e[r]==="$"&&e[r+1]==="{"){let s=r+2,o=1,i=s;for(;i<e.length&&o>0;)e[i]==="{"?o++:e[i]==="}"&&o--,o>0&&i++;let a=e.slice(s,i),l=i+1;if(e[l]==="#"){let c=l+1;for(;c<e.length&&/[0-9a-zA-Z@_]/.test(e[c]);)c++;let f=e.slice(l+1,c);return{expr:{type:"ArithDynamicBase",baseExpr:a,value:f},pos:c}}if(/[0-9]/.test(e[l])||e[l]==="x"||e[l]==="X"){let c=l;if(e[l]==="x"||e[l]==="X")for(c++;c<e.length&&/[0-9a-fA-F]/.test(e[c]);)c++;else for(;c<e.length&&/[0-9]/.test(e[c]);)c++;let f=e.slice(l,c);return{expr:{type:"ArithDynamicNumber",prefix:a,suffix:f},pos:c}}return r=l,{expr:{type:"ArithBracedExpansion",content:a},pos:r}}if(e[r]==="$"&&r+1<e.length&&/[0-9]/.test(e[r+1])){r++;let s="";for(;r<e.length&&/[0-9]/.test(e[r]);)s+=e[r],r++;return{expr:{type:"ArithVariable",name:s},pos:r}}if(e[r]==="$"&&r+1<e.length&&/[a-zA-Z_]/.test(e[r+1])&&r++,/[a-zA-Z_]/.test(e[r])){let s="";for(;r<e.length&&/[a-zA-Z0-9_]/.test(e[r]);)s+=e[r],r++;if(e[r]==="["){r++;let i;if(e[r]==="'"||e[r]==='"'){let c=e[r];for(r++,i="";r<e.length&&e[r]!==c;)i+=e[r],r++;e[r]===c&&r++,r=D(e,r),e[r]==="]"&&r++}let a;if(i===void 0){let{expr:c,pos:f}=te(t,e,r);a=c,r=f,e[r]==="]"&&r++}if(r=D(e,r),e[r]==="["&&a)return{expr:{type:"ArithDoubleSubscript",array:s,index:a},pos:r};let l=["=","+=","-=","*=","/=","%=","<<=",">>=","&=","|=","^="];for(let c of l)if(e.slice(r,r+c.length)===c&&e.slice(r,r+c.length+1)!=="=="){r+=c.length;let{expr:f,pos:h}=Ue(t,e,r);return{expr:{type:"ArithAssignment",operator:c,variable:s,subscript:a,stringKey:i,value:f},pos:h}}return{expr:{type:"ArithArrayElement",array:s,index:a,stringKey:i},pos:r}}r=D(e,r);let o=["=","+=","-=","*=","/=","%=","<<=",">>=","&=","|=","^="];for(let i of o)if(e.slice(r,r+i.length)===i&&e.slice(r,r+i.length+1)!=="=="){r+=i.length;let{expr:a,pos:l}=Ue(t,e,r);return{expr:{type:"ArithAssignment",operator:i,variable:s,value:a},pos:l}}return{expr:{type:"ArithVariable",name:s},pos:r}}return{expr:{type:"ArithNumber",value:0},pos:r}}function xe(t){if(t.includes("#")){let[e,n]=t.split("#"),r=Number.parseInt(e,10);if(r<2||r>64)return Number.NaN;if(r<=36)return Number.parseInt(n,r);let s=0;for(let o of n){let i;if(o>="0"&&o<="9")i=o.charCodeAt(0)-48;else if(o>="a"&&o<="z")i=o.charCodeAt(0)-97+10;else if(o>="A"&&o<="Z")i=o.charCodeAt(0)-65+36;else if(o==="@")i=62;else if(o==="_")i=63;else return Number.NaN;if(i>=r)return Number.NaN;s=s*r+i}return s}return t.startsWith("0x")||t.startsWith("0X")?Number.parseInt(t.slice(2),16):t.startsWith("0")&&t.length>1&&/^[0-9]+$/.test(t)?/[89]/.test(t)?Number.NaN:Number.parseInt(t,8):Number.parseInt(t,10)}function D(t,e){for(;e<t.length;){if(t[e]==="\\"&&t[e+1]===`
3
3
  `){e+=2;continue}if(/\s/.test(t[e])){e++;continue}break}return e}var A={script(t){return{type:"Script",statements:t}},statement(t,e=[],n=!1){return{type:"Statement",pipelines:t,operators:e,background:n}},pipeline(t,e=!1){return{type:"Pipeline",commands:t,negated:e}},simpleCommand(t,e=[],n=[],r=[]){return{type:"SimpleCommand",name:t,args:e,assignments:n,redirections:r}},word(t){return{type:"Word",parts:t}},literal(t){return{type:"Literal",value:t}},singleQuoted(t){return{type:"SingleQuoted",value:t}},doubleQuoted(t){return{type:"DoubleQuoted",parts:t}},escaped(t){return{type:"Escaped",value:t}},parameterExpansion(t,e=null){return{type:"ParameterExpansion",parameter:t,operation:e}},commandSubstitution(t,e=!1){return{type:"CommandSubstitution",body:t,legacy:e}},arithmeticExpansion(t){return{type:"ArithmeticExpansion",expression:t}},assignment(t,e,n=!1,r=null){return{type:"Assignment",name:t,value:e,append:n,array:r}},redirection(t,e,n=null){return{type:"Redirection",fd:n,operator:t,target:e}},hereDoc(t,e,n=!1,r=!1){return{type:"HereDoc",delimiter:t,content:e,stripTabs:n,quoted:r}},ifNode(t,e=null,n=[]){return{type:"If",clauses:t,elseBody:e,redirections:n}},forNode(t,e,n,r=[]){return{type:"For",variable:t,words:e,body:n,redirections:r}},whileNode(t,e,n=[]){return{type:"While",condition:t,body:e,redirections:n}},untilNode(t,e,n=[]){return{type:"Until",condition:t,body:e,redirections:n}},caseNode(t,e,n=[]){return{type:"Case",word:t,items:e,redirections:n}},caseItem(t,e,n=";;"){return{type:"CaseItem",patterns:t,body:e,terminator:n}},subshell(t,e=[]){return{type:"Subshell",body:t,redirections:e}},group(t,e=[]){return{type:"Group",body:t,redirections:e}},functionDef(t,e,n=[]){return{type:"FunctionDef",name:t,body:e,redirections:n}},conditionalCommand(t,e=[]){return{type:"ConditionalCommand",expression:t,redirections:e}},arithmeticCommand(t,e=[]){return{type:"ArithmeticCommand",expression:t,redirections:e}}};var u;(function(t){t.EOF="EOF",t.NEWLINE="NEWLINE",t.SEMICOLON="SEMICOLON",t.AMP="AMP",t.PIPE="PIPE",t.PIPE_AMP="PIPE_AMP",t.AND_AND="AND_AND",t.OR_OR="OR_OR",t.BANG="BANG",t.LESS="LESS",t.GREAT="GREAT",t.DLESS="DLESS",t.DGREAT="DGREAT",t.LESSAND="LESSAND",t.GREATAND="GREATAND",t.LESSGREAT="LESSGREAT",t.DLESSDASH="DLESSDASH",t.CLOBBER="CLOBBER",t.TLESS="TLESS",t.AND_GREAT="AND_GREAT",t.AND_DGREAT="AND_DGREAT",t.LPAREN="LPAREN",t.RPAREN="RPAREN",t.LBRACE="LBRACE",t.RBRACE="RBRACE",t.DSEMI="DSEMI",t.SEMI_AND="SEMI_AND",t.SEMI_SEMI_AND="SEMI_SEMI_AND",t.DBRACK_START="DBRACK_START",t.DBRACK_END="DBRACK_END",t.DPAREN_START="DPAREN_START",t.DPAREN_END="DPAREN_END",t.IF="IF",t.THEN="THEN",t.ELSE="ELSE",t.ELIF="ELIF",t.FI="FI",t.FOR="FOR",t.WHILE="WHILE",t.UNTIL="UNTIL",t.DO="DO",t.DONE="DONE",t.CASE="CASE",t.ESAC="ESAC",t.IN="IN",t.FUNCTION="FUNCTION",t.SELECT="SELECT",t.TIME="TIME",t.COPROC="COPROC",t.WORD="WORD",t.NAME="NAME",t.NUMBER="NUMBER",t.ASSIGNMENT_WORD="ASSIGNMENT_WORD",t.COMMENT="COMMENT",t.HEREDOC_CONTENT="HEREDOC_CONTENT"})(u||(u={}));var He={if:u.IF,then:u.THEN,else:u.ELSE,elif:u.ELIF,fi:u.FI,for:u.FOR,while:u.WHILE,until:u.UNTIL,do:u.DO,done:u.DONE,case:u.CASE,esac:u.ESAC,in:u.IN,function:u.FUNCTION,select:u.SELECT,time:u.TIME,coproc:u.COPROC};function Pr(t){let e=t.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);if(!e)return!1;let n=t.slice(e[0].length);if(n===""||n==="+")return!0;if(n[0]==="["){let r=0,s=0;for(;s<n.length;s++)if(n[s]==="[")r++;else if(n[s]==="]"&&(r--,r===0))break;if(r!==0||s>=n.length)return!1;let o=n.slice(s+1);return o===""||o==="+"}return!1}var Hn=[[";",";","&",u.SEMI_SEMI_AND],["<","<","<",u.TLESS],["&",">",">",u.AND_DGREAT]],Gn=[["[","[",u.DBRACK_START],["]","]",u.DBRACK_END],["(","(",u.DPAREN_START],[")",")",u.DPAREN_END],["&","&",u.AND_AND],["|","|",u.OR_OR],[";",";",u.DSEMI],[";","&",u.SEMI_AND],["|","&",u.PIPE_AMP],[">",">",u.DGREAT],["<","&",u.LESSAND],[">","&",u.GREATAND],["<",">",u.LESSGREAT],[">","|",u.CLOBBER],["&",">",u.AND_GREAT]],Vn={"|":u.PIPE,"&":u.AMP,";":u.SEMICOLON,"(":u.LPAREN,")":u.RPAREN,"<":u.LESS,">":u.GREAT};function Zn(t){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t)}var Ge=class{input;pos=0;line=1;column=1;tokens=[];pendingHeredocs=[];constructor(e){this.input=e}tokenize(){let n=this.input.length,r=this.tokens,s=this.pendingHeredocs;for(;this.pos<n&&(this.skipWhitespace(),!(this.pos>=n));){if(s.length>0&&r.length>0&&r[r.length-1].type===u.NEWLINE){this.readHeredocContent();continue}let o=this.nextToken();o&&r.push(o)}return r.push({type:u.EOF,value:"",start:this.pos,end:this.pos,line:this.line,column:this.column}),r}skipWhitespace(){let e=this.input,n=e.length,r=this.pos,s=this.column,o=this.line;for(;r<n;){let i=e[r];if(i===" "||i===" ")r++,s++;else if(i==="\\"&&e[r+1]===`
4
4
  `)r+=2,o++,s=1;else break}this.pos=r,this.column=s,this.line=o}nextToken(){let e=this.input,n=this.pos,r=this.line,s=this.column,o=e[n],i=e[n+1],a=e[n+2];if(o==="#")return this.readComment(n,r,s);if(o===`
5
5
  `)return this.pos=n+1,this.line++,this.column=1,{type:u.NEWLINE,value:`