just-bash 1.2.5 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (331) hide show
  1. package/README.md +1 -1
  2. package/dist/ai/index.d.ts +5 -0
  3. package/dist/ast/types.d.ts +2 -0
  4. package/dist/bin/chunks/{alias-74DFXE2E.js → alias-ZAQAKC5X.js} +1 -1
  5. package/dist/bin/chunks/{awk2-4DKPX43H.js → awk2-A73ZNFXJ.js} +1 -1
  6. package/dist/bin/chunks/base64-JPITV4MD.js +6 -0
  7. package/dist/bin/chunks/{basename-Y7JDBYHN.js → basename-IYEP3AMY.js} +1 -1
  8. package/dist/bin/{shell/chunks/bash-5IWSVGHN.js → chunks/bash-WZYHIZP6.js} +1 -1
  9. package/dist/bin/{shell/chunks/cat-YZXBF5YF.js → chunks/cat-XILYL7NW.js} +1 -1
  10. package/dist/bin/chunks/{chmod-3G4LK462.js → chmod-EXWX4N7Y.js} +1 -1
  11. package/dist/bin/chunks/chunk-GX4MPCG6.js +9 -0
  12. package/dist/bin/chunks/chunk-SJXDWN5X.js +2 -0
  13. package/dist/bin/{shell/chunks/clear-GTCFHSB2.js → chunks/clear-2APRIRCF.js} +1 -1
  14. package/dist/bin/chunks/comm-KY3COLF5.js +13 -0
  15. package/dist/bin/{shell/chunks/cp-77UY7PGN.js → chunks/cp-HES4UN7K.js} +1 -1
  16. package/dist/bin/chunks/{curl-NE7XEWMN.js → curl-BN5M3BUX.js} +1 -1
  17. package/dist/bin/chunks/{cut-UYV3FM7R.js → cut-JSIPAKOX.js} +1 -1
  18. package/dist/bin/chunks/{date-7NBRXV2Z.js → date-CU4J7GHI.js} +1 -1
  19. package/dist/bin/chunks/{diff-TG2NXCX2.js → diff-W4JRNHXW.js} +1 -1
  20. package/dist/bin/chunks/{dirname-VLHP44TU.js → dirname-UTCUUILN.js} +1 -1
  21. package/dist/bin/chunks/{du-4FZ7WF2P.js → du-2JU3PUTM.js} +1 -1
  22. package/dist/bin/chunks/{echo-DEUIS5JO.js → echo-HKLPYMNC.js} +1 -1
  23. package/dist/bin/chunks/{env-AKGX6HSG.js → env-2SBJNP7X.js} +1 -1
  24. package/dist/bin/chunks/{expr-HA2ZNL6S.js → expr-M74QZQ6C.js} +1 -1
  25. package/dist/bin/chunks/file-QPD3U2H7.js +23 -0
  26. package/dist/bin/{shell/chunks/find-JADNFF7V.js → chunks/find-D3ZC5DXH.js} +1 -1
  27. package/dist/bin/chunks/grep-BEZRXAWL.js +15 -0
  28. package/dist/bin/{shell/chunks/head-VGXR3WWL.js → chunks/head-YGMY3DHE.js} +1 -1
  29. package/dist/bin/chunks/{help-YQGNAT2T.js → help-UEF7LW7F.js} +1 -1
  30. package/dist/bin/{shell/chunks/history-PRQ4B6N2.js → chunks/history-OGBCIAR5.js} +1 -1
  31. package/dist/bin/chunks/{html-to-markdown-L4UWMK4S.js → html-to-markdown-HTGML4TH.js} +1 -1
  32. package/dist/bin/chunks/jq-ME57VHK6.js +14 -0
  33. package/dist/bin/chunks/{ln-DB7J2W5X.js → ln-RUR4ALOJ.js} +1 -1
  34. package/dist/bin/{shell/chunks/ls-C4MPAF3H.js → chunks/ls-GU5227KE.js} +1 -1
  35. package/dist/bin/chunks/md5sum-C7WDEYN5.js +2 -0
  36. package/dist/bin/chunks/{mkdir-LWULWDHP.js → mkdir-4OYU22AA.js} +1 -1
  37. package/dist/bin/chunks/{mv-TDYCNSIQ.js → mv-H3S4FEWR.js} +1 -1
  38. package/dist/bin/chunks/{paste-R36J3G4K.js → paste-HHCFASL4.js} +1 -1
  39. package/dist/bin/chunks/{printf-WM4X6IZ6.js → printf-2JFCUFOA.js} +1 -1
  40. package/dist/bin/chunks/{pwd-X4MWD4JP.js → pwd-T5Q3JEBO.js} +1 -1
  41. package/dist/bin/chunks/{readlink-DPNOQY67.js → readlink-M44TLMFS.js} +1 -1
  42. package/dist/bin/chunks/{rm-W6CCBEMG.js → rm-R4M647EC.js} +1 -1
  43. package/dist/bin/chunks/{sed-LTCVBSRV.js → sed-QLLAZYHH.js} +1 -1
  44. package/dist/bin/chunks/{seq-DGJILX2Q.js → seq-GJMQM7SP.js} +1 -1
  45. package/dist/bin/chunks/sha1sum-WKCGV66X.js +2 -0
  46. package/dist/bin/chunks/sha256sum-3ZDGP5WC.js +2 -0
  47. package/dist/bin/chunks/{sleep-E4DIYGTT.js → sleep-OJPODQGM.js} +1 -1
  48. package/dist/bin/chunks/sort-JL33INQB.js +16 -0
  49. package/dist/bin/{shell/chunks/stat-3PHITCPO.js → chunks/stat-CR2INBC2.js} +1 -1
  50. package/dist/bin/chunks/{tail-YSVKBQ77.js → tail-BYPLMYMZ.js} +1 -1
  51. package/dist/bin/chunks/{tee-UU2VS3OM.js → tee-HOMRRC3X.js} +1 -1
  52. package/dist/bin/chunks/{timeout-RP2AJGMV.js → timeout-MYKG34DQ.js} +1 -1
  53. package/dist/bin/{shell/chunks/touch-XCIAYF5I.js → chunks/touch-3ZANYAXI.js} +1 -1
  54. package/dist/bin/chunks/{tr-2EEKHHO6.js → tr-E66N7IS2.js} +1 -1
  55. package/dist/bin/chunks/{tree-4247W67O.js → tree-EE2PYIMV.js} +1 -1
  56. package/dist/bin/chunks/{true-JCX733LK.js → true-OWPVS7U4.js} +1 -1
  57. package/dist/bin/chunks/{uniq-W4HF6YSB.js → uniq-F5NP3LLU.js} +1 -1
  58. package/dist/bin/chunks/{wc-CNJ3QDRA.js → wc-NBMNJDZL.js} +1 -1
  59. package/dist/bin/chunks/{which-HX2NMOP3.js → which-6MRG2UCF.js} +1 -1
  60. package/dist/bin/chunks/xargs-EMY5BOJ2.js +4 -0
  61. package/dist/bin/just-bash.js +124 -116
  62. package/dist/bin/shell/chunks/{alias-74DFXE2E.js → alias-ZAQAKC5X.js} +1 -1
  63. package/dist/bin/shell/chunks/{awk2-4DKPX43H.js → awk2-A73ZNFXJ.js} +1 -1
  64. package/dist/bin/shell/chunks/base64-JPITV4MD.js +6 -0
  65. package/dist/bin/shell/chunks/{basename-Y7JDBYHN.js → basename-IYEP3AMY.js} +1 -1
  66. package/dist/bin/{chunks/bash-5IWSVGHN.js → shell/chunks/bash-WZYHIZP6.js} +1 -1
  67. package/dist/bin/{chunks/cat-YZXBF5YF.js → shell/chunks/cat-XILYL7NW.js} +1 -1
  68. package/dist/bin/shell/chunks/{chmod-3G4LK462.js → chmod-EXWX4N7Y.js} +1 -1
  69. package/dist/bin/shell/chunks/chunk-GX4MPCG6.js +9 -0
  70. package/dist/bin/shell/chunks/chunk-SJXDWN5X.js +2 -0
  71. package/dist/bin/{chunks/clear-GTCFHSB2.js → shell/chunks/clear-2APRIRCF.js} +1 -1
  72. package/dist/bin/shell/chunks/comm-KY3COLF5.js +13 -0
  73. package/dist/bin/{chunks/cp-77UY7PGN.js → shell/chunks/cp-HES4UN7K.js} +1 -1
  74. package/dist/bin/shell/chunks/{curl-NE7XEWMN.js → curl-BN5M3BUX.js} +1 -1
  75. package/dist/bin/shell/chunks/{cut-UYV3FM7R.js → cut-JSIPAKOX.js} +1 -1
  76. package/dist/bin/shell/chunks/{date-7NBRXV2Z.js → date-CU4J7GHI.js} +1 -1
  77. package/dist/bin/shell/chunks/{diff-TG2NXCX2.js → diff-W4JRNHXW.js} +1 -1
  78. package/dist/bin/shell/chunks/{dirname-VLHP44TU.js → dirname-UTCUUILN.js} +1 -1
  79. package/dist/bin/shell/chunks/{du-4FZ7WF2P.js → du-2JU3PUTM.js} +1 -1
  80. package/dist/bin/shell/chunks/{echo-DEUIS5JO.js → echo-HKLPYMNC.js} +1 -1
  81. package/dist/bin/shell/chunks/{env-AKGX6HSG.js → env-2SBJNP7X.js} +1 -1
  82. package/dist/bin/shell/chunks/{expr-HA2ZNL6S.js → expr-M74QZQ6C.js} +1 -1
  83. package/dist/bin/shell/chunks/file-QPD3U2H7.js +23 -0
  84. package/dist/bin/{chunks/find-JADNFF7V.js → shell/chunks/find-D3ZC5DXH.js} +1 -1
  85. package/dist/bin/shell/chunks/grep-BEZRXAWL.js +15 -0
  86. package/dist/bin/{chunks/head-VGXR3WWL.js → shell/chunks/head-YGMY3DHE.js} +1 -1
  87. package/dist/bin/shell/chunks/{help-YQGNAT2T.js → help-UEF7LW7F.js} +1 -1
  88. package/dist/bin/{chunks/history-PRQ4B6N2.js → shell/chunks/history-OGBCIAR5.js} +1 -1
  89. package/dist/bin/shell/chunks/{html-to-markdown-L4UWMK4S.js → html-to-markdown-HTGML4TH.js} +1 -1
  90. package/dist/bin/shell/chunks/jq-ME57VHK6.js +14 -0
  91. package/dist/bin/shell/chunks/{ln-DB7J2W5X.js → ln-RUR4ALOJ.js} +1 -1
  92. package/dist/bin/{chunks/ls-C4MPAF3H.js → shell/chunks/ls-GU5227KE.js} +1 -1
  93. package/dist/bin/shell/chunks/md5sum-C7WDEYN5.js +2 -0
  94. package/dist/bin/shell/chunks/{mkdir-LWULWDHP.js → mkdir-4OYU22AA.js} +1 -1
  95. package/dist/bin/shell/chunks/{mv-TDYCNSIQ.js → mv-H3S4FEWR.js} +1 -1
  96. package/dist/bin/shell/chunks/{paste-R36J3G4K.js → paste-HHCFASL4.js} +1 -1
  97. package/dist/bin/shell/chunks/{printf-WM4X6IZ6.js → printf-2JFCUFOA.js} +1 -1
  98. package/dist/bin/shell/chunks/{pwd-X4MWD4JP.js → pwd-T5Q3JEBO.js} +1 -1
  99. package/dist/bin/shell/chunks/{readlink-DPNOQY67.js → readlink-M44TLMFS.js} +1 -1
  100. package/dist/bin/shell/chunks/{rm-W6CCBEMG.js → rm-R4M647EC.js} +1 -1
  101. package/dist/bin/shell/chunks/{sed-LTCVBSRV.js → sed-QLLAZYHH.js} +1 -1
  102. package/dist/bin/shell/chunks/{seq-DGJILX2Q.js → seq-GJMQM7SP.js} +1 -1
  103. package/dist/bin/shell/chunks/sha1sum-WKCGV66X.js +2 -0
  104. package/dist/bin/shell/chunks/sha256sum-3ZDGP5WC.js +2 -0
  105. package/dist/bin/shell/chunks/{sleep-E4DIYGTT.js → sleep-OJPODQGM.js} +1 -1
  106. package/dist/bin/shell/chunks/sort-JL33INQB.js +16 -0
  107. package/dist/bin/{chunks/stat-3PHITCPO.js → shell/chunks/stat-CR2INBC2.js} +1 -1
  108. package/dist/bin/shell/chunks/{tail-YSVKBQ77.js → tail-BYPLMYMZ.js} +1 -1
  109. package/dist/bin/shell/chunks/{tee-UU2VS3OM.js → tee-HOMRRC3X.js} +1 -1
  110. package/dist/bin/shell/chunks/{timeout-RP2AJGMV.js → timeout-MYKG34DQ.js} +1 -1
  111. package/dist/bin/{chunks/touch-XCIAYF5I.js → shell/chunks/touch-3ZANYAXI.js} +1 -1
  112. package/dist/bin/shell/chunks/{tr-2EEKHHO6.js → tr-E66N7IS2.js} +1 -1
  113. package/dist/bin/shell/chunks/{tree-4247W67O.js → tree-EE2PYIMV.js} +1 -1
  114. package/dist/bin/shell/chunks/{true-JCX733LK.js → true-OWPVS7U4.js} +1 -1
  115. package/dist/bin/shell/chunks/{uniq-W4HF6YSB.js → uniq-F5NP3LLU.js} +1 -1
  116. package/dist/bin/shell/chunks/{wc-CNJ3QDRA.js → wc-NBMNJDZL.js} +1 -1
  117. package/dist/bin/shell/chunks/{which-HX2NMOP3.js → which-6MRG2UCF.js} +1 -1
  118. package/dist/bin/shell/chunks/xargs-EMY5BOJ2.js +4 -0
  119. package/dist/bin/shell/shell.js +107 -99
  120. package/dist/bundle/ai/index.js +442 -393
  121. package/dist/bundle/chunks/{alias-7ZSTROM7.js → alias-JFIUWFGE.js} +1 -1
  122. package/dist/{bin/chunks/awk2-UYU2UYZ2.js → bundle/chunks/awk2-QWBT4IFJ.js} +1 -2
  123. package/dist/bundle/chunks/base64-TUA2XORD.js +5 -0
  124. package/dist/bundle/chunks/{basename-SB5JXIY3.js → basename-5UVU5RXR.js} +1 -1
  125. package/dist/bundle/chunks/{bash-5WG5RD6L.js → bash-BASUPKHJ.js} +1 -1
  126. package/dist/bundle/chunks/cat-47EP4IAV.js +5 -0
  127. package/dist/bundle/chunks/{chmod-VLKWIL3N.js → chmod-XJXFAD4M.js} +1 -1
  128. package/dist/bundle/chunks/chunk-2RUN43TJ.js +1 -0
  129. package/dist/bundle/chunks/chunk-46TSKXFW.js +8 -0
  130. package/dist/bundle/chunks/clear-XD3TJRVQ.js +1 -0
  131. package/dist/bundle/chunks/comm-KSJ4BBRQ.js +12 -0
  132. package/dist/bundle/chunks/cp-37OVLNLD.js +7 -0
  133. package/dist/bundle/chunks/{curl-PA2MWGKN.js → curl-C43O5WQS.js} +1 -1
  134. package/dist/bundle/chunks/cut-FIZRELKC.js +5 -0
  135. package/dist/bundle/chunks/{date-YOOSNZVA.js → date-NN5C354M.js} +1 -1
  136. package/dist/bundle/chunks/diff-GLRVCAKJ.js +6 -0
  137. package/dist/bundle/chunks/dirname-U2KVUSQY.js +4 -0
  138. package/dist/bundle/chunks/du-KRAFOIQK.js +7 -0
  139. package/dist/bundle/chunks/{echo-W2TA2N7Y.js → echo-WUKBESC7.js} +1 -1
  140. package/dist/bundle/chunks/env-MSPSPGCD.js +8 -0
  141. package/dist/bundle/chunks/{expr-A4LJAGVP.js → expr-HYOCSWK6.js} +1 -1
  142. package/dist/bundle/chunks/file-LQXX6P4Y.js +22 -0
  143. package/dist/{bin/shell/chunks/find-NCI6KGUI.js → bundle/chunks/find-R6LJIRBI.js} +1 -2
  144. package/dist/bundle/chunks/grep-ZJVDG3FA.js +14 -0
  145. package/dist/bundle/chunks/head-6PAUYCDP.js +1 -0
  146. package/dist/{bin/shell/chunks/help-5V3MPCYQ.js → bundle/chunks/help-5E6PYJWQ.js} +3 -4
  147. package/dist/bundle/chunks/history-SG6VRATI.js +2 -0
  148. package/dist/bundle/chunks/html-to-markdown-ZSZ34PAN.js +4 -0
  149. package/dist/bundle/chunks/jq-ABWUP4LV.js +13 -0
  150. package/dist/bundle/chunks/ln-XFYHBIFL.js +9 -0
  151. package/dist/bundle/chunks/{ls-B7C35UDO.js → ls-JGYJQA2Y.js} +1 -1
  152. package/dist/bundle/chunks/md5sum-PIH6F3O3.js +1 -0
  153. package/dist/bundle/chunks/{mkdir-WYI2LJ6H.js → mkdir-HA2FJX4O.js} +1 -1
  154. package/dist/bundle/chunks/mv-7I62SB3I.js +6 -0
  155. package/dist/bundle/chunks/paste-QBGVCQFT.js +7 -0
  156. package/dist/bundle/chunks/{printf-O2UW73XK.js → printf-HBP44PXI.js} +1 -1
  157. package/dist/bundle/chunks/pwd-CEF235GL.js +2 -0
  158. package/dist/bundle/chunks/readlink-MQIMKDSA.js +6 -0
  159. package/dist/bundle/chunks/{rm-5X2XSQQ6.js → rm-NF3FNLAY.js} +1 -1
  160. package/dist/{bin/shell/chunks/sed-B6FXUN7R.js → bundle/chunks/sed-H2RWPMTM.js} +1 -2
  161. package/dist/bundle/chunks/{seq-TFPZQZPJ.js → seq-VKYIUOPJ.js} +1 -1
  162. package/dist/bundle/chunks/sha1sum-HVHNZSEC.js +1 -0
  163. package/dist/bundle/chunks/sha256sum-REOOJORK.js +1 -0
  164. package/dist/bundle/chunks/{sleep-QJBQD6VS.js → sleep-AFN3PHJW.js} +1 -1
  165. package/dist/bundle/chunks/sort-XODGFZC4.js +15 -0
  166. package/dist/bundle/chunks/{stat-TM5F5YO4.js → stat-FVFLDQGP.js} +1 -1
  167. package/dist/bundle/chunks/tail-QXKYHAML.js +1 -0
  168. package/dist/bundle/chunks/tee-W5HCCBPO.js +2 -0
  169. package/dist/bundle/chunks/{timeout-VG2N46UR.js → timeout-XAA3N7CF.js} +1 -1
  170. package/dist/bundle/chunks/{touch-Z5XRYFYY.js → touch-FOE745V2.js} +1 -1
  171. package/dist/bundle/chunks/{tr-UV4V27RJ.js → tr-LMLGE4IE.js} +1 -1
  172. package/dist/bundle/chunks/{tree-75UXQ4XJ.js → tree-WBUGLVP5.js} +1 -1
  173. package/dist/bundle/chunks/true-6LGCG4EY.js +1 -0
  174. package/dist/bundle/chunks/uniq-7PFWPNWK.js +4 -0
  175. package/dist/bundle/chunks/wc-GV5WUREX.js +5 -0
  176. package/dist/bundle/chunks/which-KHFYPBWW.js +2 -0
  177. package/dist/bundle/chunks/xargs-NQBNFMCT.js +3 -0
  178. package/dist/bundle/index.js +120 -112
  179. package/dist/commands/comm/comm.d.ts +10 -0
  180. package/dist/commands/file/file.d.ts +7 -0
  181. package/dist/commands/md5sum/checksum.d.ts +7 -0
  182. package/dist/commands/{awk/awk.d.ts → md5sum/md5sum.d.ts} +1 -1
  183. package/dist/commands/md5sum/sha1sum.d.ts +2 -0
  184. package/dist/commands/md5sum/sha256sum.d.ts +2 -0
  185. package/dist/commands/registry.d.ts +1 -1
  186. package/dist/commands/sort/types.d.ts +12 -0
  187. package/dist/interpreter/types.d.ts +6 -0
  188. package/dist/shell-metadata.d.ts +28 -0
  189. package/package.json +2 -1
  190. package/dist/bin/chunks/awk-S63F6IYK.js +0 -15
  191. package/dist/bin/chunks/awk2-6XCE67AX.js +0 -20
  192. package/dist/bin/chunks/awk2-DKAZ7LPG.js +0 -20
  193. package/dist/bin/chunks/awk2-GAJ72X3Z.js +0 -20
  194. package/dist/bin/chunks/awk2-HJAPWU2N.js +0 -18
  195. package/dist/bin/chunks/awk2-LVXC5OAC.js +0 -20
  196. package/dist/bin/chunks/awk2-T6HR4EYO.js +0 -20
  197. package/dist/bin/chunks/awk2-W64AZN7P.js +0 -20
  198. package/dist/bin/chunks/base64-NC7HTKLZ.js +0 -5
  199. package/dist/bin/chunks/bash-TQGTNXAE.js +0 -7
  200. package/dist/bin/chunks/chunk-5KNEBKYN.js +0 -2
  201. package/dist/bin/chunks/chunk-6QUZ7QML.js +0 -3
  202. package/dist/bin/chunks/chunk-LV662IGP.js +0 -6
  203. package/dist/bin/chunks/env-FVITWNHG.js +0 -9
  204. package/dist/bin/chunks/find-4B67H4RP.js +0 -11
  205. package/dist/bin/chunks/find-7BUNQZX4.js +0 -11
  206. package/dist/bin/chunks/find-AMA6ABN5.js +0 -11
  207. package/dist/bin/chunks/find-HW2TUO6B.js +0 -11
  208. package/dist/bin/chunks/find-NCI6KGUI.js +0 -11
  209. package/dist/bin/chunks/find-QEYP42JQ.js +0 -11
  210. package/dist/bin/chunks/find-WJV3FM6L.js +0 -11
  211. package/dist/bin/chunks/find-YATLECXJ.js +0 -11
  212. package/dist/bin/chunks/grep-OVWU4WCZ.js +0 -15
  213. package/dist/bin/chunks/grep-PHBFGJCV.js +0 -15
  214. package/dist/bin/chunks/help-5V3MPCYQ.js +0 -16
  215. package/dist/bin/chunks/jq-EYSXBSCP.js +0 -14
  216. package/dist/bin/chunks/printf-ASOYDPIK.js +0 -14
  217. package/dist/bin/chunks/printf-BOFQVMMK.js +0 -15
  218. package/dist/bin/chunks/sed-7IS44XON.js +0 -48
  219. package/dist/bin/chunks/sed-B6FXUN7R.js +0 -80
  220. package/dist/bin/chunks/sed-RHLDIXPL.js +0 -76
  221. package/dist/bin/chunks/sed-SYSATJXR.js +0 -75
  222. package/dist/bin/chunks/sort-UJP353TM.js +0 -15
  223. package/dist/bin/chunks/timeout-OZVAGW2H.js +0 -12
  224. package/dist/bin/chunks/xargs-DKUAYNEK.js +0 -4
  225. package/dist/bin/chunks/xargs-YNLVLPOF.js +0 -4
  226. package/dist/bin/shell/chunks/awk-S63F6IYK.js +0 -15
  227. package/dist/bin/shell/chunks/awk2-6XCE67AX.js +0 -20
  228. package/dist/bin/shell/chunks/awk2-DKAZ7LPG.js +0 -20
  229. package/dist/bin/shell/chunks/awk2-GAJ72X3Z.js +0 -20
  230. package/dist/bin/shell/chunks/awk2-HJAPWU2N.js +0 -18
  231. package/dist/bin/shell/chunks/awk2-LVXC5OAC.js +0 -20
  232. package/dist/bin/shell/chunks/awk2-T6HR4EYO.js +0 -20
  233. package/dist/bin/shell/chunks/awk2-UYU2UYZ2.js +0 -20
  234. package/dist/bin/shell/chunks/awk2-W64AZN7P.js +0 -20
  235. package/dist/bin/shell/chunks/base64-NC7HTKLZ.js +0 -5
  236. package/dist/bin/shell/chunks/bash-TQGTNXAE.js +0 -7
  237. package/dist/bin/shell/chunks/chunk-5KNEBKYN.js +0 -2
  238. package/dist/bin/shell/chunks/chunk-6QUZ7QML.js +0 -3
  239. package/dist/bin/shell/chunks/chunk-LV662IGP.js +0 -6
  240. package/dist/bin/shell/chunks/env-FVITWNHG.js +0 -9
  241. package/dist/bin/shell/chunks/find-4B67H4RP.js +0 -11
  242. package/dist/bin/shell/chunks/find-7BUNQZX4.js +0 -11
  243. package/dist/bin/shell/chunks/find-AMA6ABN5.js +0 -11
  244. package/dist/bin/shell/chunks/find-HW2TUO6B.js +0 -11
  245. package/dist/bin/shell/chunks/find-QEYP42JQ.js +0 -11
  246. package/dist/bin/shell/chunks/find-WJV3FM6L.js +0 -11
  247. package/dist/bin/shell/chunks/find-YATLECXJ.js +0 -11
  248. package/dist/bin/shell/chunks/grep-OVWU4WCZ.js +0 -15
  249. package/dist/bin/shell/chunks/grep-PHBFGJCV.js +0 -15
  250. package/dist/bin/shell/chunks/jq-EYSXBSCP.js +0 -14
  251. package/dist/bin/shell/chunks/printf-ASOYDPIK.js +0 -14
  252. package/dist/bin/shell/chunks/printf-BOFQVMMK.js +0 -15
  253. package/dist/bin/shell/chunks/sed-7IS44XON.js +0 -48
  254. package/dist/bin/shell/chunks/sed-RHLDIXPL.js +0 -76
  255. package/dist/bin/shell/chunks/sed-SYSATJXR.js +0 -75
  256. package/dist/bin/shell/chunks/sort-UJP353TM.js +0 -15
  257. package/dist/bin/shell/chunks/timeout-OZVAGW2H.js +0 -12
  258. package/dist/bin/shell/chunks/xargs-DKUAYNEK.js +0 -4
  259. package/dist/bin/shell/chunks/xargs-YNLVLPOF.js +0 -4
  260. package/dist/bundle/chunks/awk-V4C3GTJI.js +0 -14
  261. package/dist/bundle/chunks/awk2-365HINHI.js +0 -19
  262. package/dist/bundle/chunks/awk2-4YCQ6UCB.js +0 -19
  263. package/dist/bundle/chunks/awk2-7YCFY7D2.js +0 -19
  264. package/dist/bundle/chunks/awk2-7YL3P4KU.js +0 -19
  265. package/dist/bundle/chunks/awk2-ETXZHQQ4.js +0 -19
  266. package/dist/bundle/chunks/awk2-FMEL7ESV.js +0 -19
  267. package/dist/bundle/chunks/awk2-LE4QUFGK.js +0 -19
  268. package/dist/bundle/chunks/awk2-MGHA6JPJ.js +0 -17
  269. package/dist/bundle/chunks/awk2-XEAK5PBN.js +0 -19
  270. package/dist/bundle/chunks/base64-WATI5PWI.js +0 -4
  271. package/dist/bundle/chunks/bash-T4PXVRYX.js +0 -6
  272. package/dist/bundle/chunks/cat-5KESXK2M.js +0 -5
  273. package/dist/bundle/chunks/chunk-JYYFSUWP.js +0 -5
  274. package/dist/bundle/chunks/chunk-TDJNT32M.js +0 -2
  275. package/dist/bundle/chunks/clear-ZBD2DMXN.js +0 -1
  276. package/dist/bundle/chunks/cp-BLHAPLQZ.js +0 -7
  277. package/dist/bundle/chunks/cut-7RHEYJ7Y.js +0 -5
  278. package/dist/bundle/chunks/diff-IVJFQANX.js +0 -6
  279. package/dist/bundle/chunks/dirname-Q5HDZLH2.js +0 -4
  280. package/dist/bundle/chunks/du-I5HYAKTQ.js +0 -7
  281. package/dist/bundle/chunks/env-2F2VHNYS.js +0 -8
  282. package/dist/bundle/chunks/env-OORA5GFS.js +0 -8
  283. package/dist/bundle/chunks/find-3O5V74IR.js +0 -10
  284. package/dist/bundle/chunks/find-4QUN2ATO.js +0 -10
  285. package/dist/bundle/chunks/find-522XP4ZY.js +0 -10
  286. package/dist/bundle/chunks/find-5UN24ZV7.js +0 -10
  287. package/dist/bundle/chunks/find-JXG2HF6L.js +0 -10
  288. package/dist/bundle/chunks/find-K3NO35MZ.js +0 -10
  289. package/dist/bundle/chunks/find-K7D4PKHS.js +0 -10
  290. package/dist/bundle/chunks/find-KP4M5DWC.js +0 -10
  291. package/dist/bundle/chunks/find-WM6ZETA7.js +0 -10
  292. package/dist/bundle/chunks/grep-3D2INI4S.js +0 -14
  293. package/dist/bundle/chunks/grep-CZTYKNEE.js +0 -14
  294. package/dist/bundle/chunks/head-7H5R4WKO.js +0 -1
  295. package/dist/bundle/chunks/help-SDCRRU2F.js +0 -15
  296. package/dist/bundle/chunks/help-XHGUXTV3.js +0 -15
  297. package/dist/bundle/chunks/history-7Z2STZ6Y.js +0 -2
  298. package/dist/bundle/chunks/html-to-markdown-XMBYO6FD.js +0 -4
  299. package/dist/bundle/chunks/jq-7R2XGLLH.js +0 -13
  300. package/dist/bundle/chunks/ln-UTUVIAFP.js +0 -9
  301. package/dist/bundle/chunks/mv-GN23UIZU.js +0 -6
  302. package/dist/bundle/chunks/paste-L4TYPVSP.js +0 -7
  303. package/dist/bundle/chunks/printf-3ZT5XOIZ.js +0 -14
  304. package/dist/bundle/chunks/printf-G2SBUNW3.js +0 -13
  305. package/dist/bundle/chunks/pwd-ZVX5RTL4.js +0 -2
  306. package/dist/bundle/chunks/readlink-HHC33N5C.js +0 -6
  307. package/dist/bundle/chunks/sed-2WWCANZT.js +0 -79
  308. package/dist/bundle/chunks/sed-5LZHAGFR.js +0 -74
  309. package/dist/bundle/chunks/sed-IGVS3UIY.js +0 -79
  310. package/dist/bundle/chunks/sed-UZJSXYQZ.js +0 -47
  311. package/dist/bundle/chunks/sed-V7XSBPTD.js +0 -75
  312. package/dist/bundle/chunks/sort-LHMQWYH2.js +0 -14
  313. package/dist/bundle/chunks/tail-BLGGG2VX.js +0 -1
  314. package/dist/bundle/chunks/tee-VCNOG5VI.js +0 -2
  315. package/dist/bundle/chunks/timeout-THAT7IOO.js +0 -11
  316. package/dist/bundle/chunks/true-OD7ZXH3O.js +0 -1
  317. package/dist/bundle/chunks/uniq-IIOQKNTS.js +0 -4
  318. package/dist/bundle/chunks/wc-OXLYBRUE.js +0 -5
  319. package/dist/bundle/chunks/which-ONWH3TNF.js +0 -2
  320. package/dist/bundle/chunks/xargs-752VENJT.js +0 -3
  321. package/dist/bundle/chunks/xargs-E5JPQL24.js +0 -3
  322. package/dist/commands/awk/executor.d.ts +0 -3
  323. package/dist/commands/awk/expressions.d.ts +0 -3
  324. package/dist/commands/awk/functions.d.ts +0 -12
  325. package/dist/commands/awk/interpreter2.d.ts +0 -90
  326. package/dist/commands/awk/parser.d.ts +0 -3
  327. package/dist/commands/awk/types.d.ts +0 -44
  328. package/dist/fs-interface.d.ts +0 -186
  329. package/dist/fs.d.ts +0 -39
  330. package/dist/overlay-fs/OverlayFs.d.ts +0 -87
  331. package/dist/overlay-fs/index.d.ts +0 -1
@@ -1,20 +0,0 @@
1
- #!/usr/bin/env node
2
- import{i as L}from"./chunk-LV662IGP.js";import{a as K,b as Q,c as U}from"./chunk-GTNBSMZR.js";import"./chunk-5KNEBKYN.js";function x(e={}){let{fieldSep:t=/\s+/,maxIterations:r=1e4,maxRecursionDepth:n=1e3,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 S=parseInt(l,10);o.includes("-")?f=f.padEnd(S):f=f.padStart(S)}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 R(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 k(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 I(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 g(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 C(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 I(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 R(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 k(e,r)}async function Oe(e,t){let r=y(await p(e,t.key));return C(e,t.array,r)}async function Pe(e,t){let r=t.operator;if(r==="||")return R(await p(e,t.left))||R(await p(e,t.right))?1:0;if(r==="&&")return R(await p(e,t.left))&&R(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 R(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 L(`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=k(e,m)}else if(n.type==="variable")o=I(e,n.name);else{let m=y(await p(e,n.key));o=C(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")g(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(k(e,n))+1,O(e,n,r)}else if(t.type==="variable")r=E(I(e,t.name))+1,g(e,t.name,r);else{let n=y(await p(e,t.key));r=E(C(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(k(e,n))-1,O(e,n,r)}else if(t.type==="variable")r=E(I(e,t.name))-1,g(e,t.name,r);else{let n=y(await p(e,t.key));r=E(C(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(k(e,n)),O(e,n,r+1)}else if(t.type==="variable")r=E(I(e,t.name)),g(e,t.name,r+1);else{let n=y(await p(e,t.key));r=E(C(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(k(e,n)),O(e,n,r-1)}else if(t.type==="variable")r=E(I(e,t.name)),g(e,t.name,r-1);else{let n=y(await p(e,t.key));r=E(C(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?g(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?g(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 b(e,r),Ke(e))break}function Ke(e){return e.shouldExit||e.shouldNext||e.shouldNextFile||e.loopBreak||e.loopContinue||e.hasReturn}async function b(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){R(await p(e,t.condition))?await b(e,t.consequent):t.alternate&&await b(e,t.alternate)}async function ze(e,t){let r=0;for(;R(await p(e,t.condition));){if(r++,r>e.maxIterations)throw new L(`awk: while loop exceeded maximum iterations (${e.maxIterations})`,"iterations",e.output);if(e.loopContinue=!1,await b(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 L(`awk: do-while loop exceeded maximum iterations (${e.maxIterations})`,"iterations",e.output);if(e.loopContinue=!1,await b(e,t.body),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break}while(R(await p(e,t.condition)))}async function Je(e,t){t.init&&await p(e,t.init);let r=0;for(;!t.condition||R(await p(e,t.condition));){if(r++,r>e.maxIterations)throw new L(`awk: for loop exceeded maximum iterations (${e.maxIterations})`,"iterations",e.output);if(e.loopContinue=!1,await b(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 b(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 R(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 R(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"]},xt={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 S=e[++h],G=S.indexOf("=");if(G>0){let v=S.slice(0,G),oe=S.slice(G+1);a[v]=oe}s=h+1}else{if(f.startsWith("--"))return U("awk",f);if(f.startsWith("-")&&f.length>1){let S=f[1];if(S!=="F"&&S!=="v")return U("awk",`-${S}`);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 S=await t.fs.readFile(h);await t.fs.writeFile(h,S+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 S=t.fs.resolvePath(t.cwd,f),v=(await t.fs.readFile(S)).split(`
16
- `);v.length>0&&v[v.length-1]===""&&v.pop(),h.push({filename:f,lines:v})}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);return{stdout:d.getOutput(),stderr:`awk: ${f}
19
- `,exitCode:2}}}};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{xt as awkCommand2};
@@ -1,5 +0,0 @@
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-5KNEBKYN.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};
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env node
2
- import{a as l,b as u}from"./chunk-GTNBSMZR.js";import"./chunk-5KNEBKYN.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(u(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],r=t.slice(1);try{let o=e.fs.resolvePath(e.cwd,n),s=await e.fs.readFile(o);return h(s,n,r,e)}catch{return{stdout:"",stderr:`bash: ${n}: No such file or directory
3
- `,exitCode:127}}}},x={name:"sh",async execute(t,e){if(u(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],r=t.slice(1);try{let o=e.fs.resolvePath(e.cwd,n),s=await e.fs.readFile(o);return h(s,n,r,e)}catch{return{stdout:"",stderr:`sh: ${n}: No such file or directory
4
- `,exitCode:127}}}};async function h(t,e,n,r){if(!r.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((c,a)=>{o[String(a+1)]=c});let s=t;if(s.startsWith("#!")){let c=s.indexOf(`
6
- `);c!==-1&&(s=s.slice(c+1))}let i=s.split(`
7
- `),d=[];for(let c of i){let a=c.trim();a&&!a.startsWith("#")&&d.push(a)}let f=d.join("; ");return await r.exec(f,{env:o})}export{b as bashCommand,x as shCommand};
@@ -1,2 +0,0 @@
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=(b,a)=>()=>(a||b((a={exports:{}}).exports,a),a.exports);var l=(b,a,c,e)=>{if(a&&typeof a=="object"||typeof a=="function")for(let d of i(a))!k.call(b,d)&&d!==c&&f(b,d,{get:()=>a[d],enumerable:!(e=h(a,d))||e.enumerable});return b};var n=(b,a,c)=>(c=b!=null?g(j(b)):{},l(a||!b||!b.__esModule?f(c,"default",{value:b,enumerable:!0}):c,b));export{m as a,n as b};
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- function c(t,a,e){let l=t;e>=0&&l.length>e&&(l=l.slice(0,e));let s=Math.abs(a);return s>l.length&&(a<0?l=l.padEnd(s," "):l=l.padStart(s," ")),l}function i(t,a){let e=a,l=0,s=-1,n=!1;for(e<t.length&&t[e]==="-"&&(n=!0,e++);e<t.length&&/\d/.test(t[e]);)l=l*10+parseInt(t[e],10),e++;if(e<t.length&&t[e]===".")for(e++,s=0;e<t.length&&/\d/.test(t[e]);)s=s*10+parseInt(t[e],10),e++;return n&&l>0&&(l=-l),[l,s,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"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":{let s="",n=e+1;for(;n<t.length&&n<e+4&&/[0-7]/.test(t[n]);)s+=t[n],n++;a+=String.fromCharCode(parseInt(s,8)),e=n;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;default:a+=t[e],e++}else a+=t[e],e++;return a}export{c as a,i as b,h as c};
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env node
2
- var n=class extends Error{stdout;stderr;constructor(t,s="",e=""){super(t),this.stdout=s,this.stderr=e}prependOutput(t,s){this.stdout=t+this.stdout,this.stderr=s+this.stderr}},o=class extends n{levels;name="BreakError";constructor(t=1,s="",e=""){super("break",s,e),this.levels=t}},i=class extends n{levels;name="ContinueError";constructor(t=1,s="",e=""){super("continue",s,e),this.levels=t}},c=class extends n{exitCode;name="ReturnError";constructor(t=0,s="",e=""){super("return",s,e),this.exitCode=t}},a=class extends n{exitCode;name="ErrexitError";constructor(t,s="",e=""){super(`errexit: command exited with status ${t}`,s,e),this.exitCode=t}},d=class extends n{varName;name="NounsetError";constructor(t,s=""){super(`${t}: unbound variable`,s,`bash: ${t}: unbound variable
3
- `),this.varName=t}},x=class extends n{exitCode;name="ExitError";constructor(t,s="",e=""){super("exit",s,e),this.exitCode=t}},p=class extends n{name="ArithmeticError";constructor(t,s="",e=""){super(t,s,e),this.stderr=e||`bash: ${t}
4
- `}},h=class extends n{name="BadSubstitutionError";constructor(t,s="",e=""){super(t,s,e),this.stderr=e||`bash: ${t}: bad substitution
5
- `}},l=class extends n{limitType;name="ExecutionLimitError";static EXIT_CODE=126;constructor(t,s,e="",u=""){super(t,e,u),this.limitType=s,this.stderr=u||`bash: ${t}
6
- `}};function b(r){return r instanceof o||r instanceof i||r instanceof c}export{o as a,i as b,c,a as d,d as e,x as f,p as g,h,l as i,b as j};
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env node
2
- import{a as m,b as f,c as p}from"./chunk-GTNBSMZR.js";import"./chunk-5KNEBKYN.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,r){if(f(s))return m(O);let u=!1,i=[],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)i.push(s[++n]);else if(e.startsWith("-u"))i.push(e.slice(2));else if(e.startsWith("--unset="))i.push(e.slice(8));else{if(e.startsWith("--")&&e!=="--")return p("env",e);if(e.startsWith("-")&&e!=="-"){for(let o of e.slice(1))if(o!=="i"&&o!=="u")return p("env",`-${o}`);e.includes("i")&&(u=!0)}else if(e.includes("=")&&t===-1){let o=e.indexOf("="),h=e.slice(0,o),x=e.slice(o+1);l[h]=x}else{t=n;break}}}let a;if(u)a={...l};else{a={...r.env};for(let n of i)delete a[n];Object.assign(a,l)}if(t===-1){let n=[];for(let[e,o]of Object.entries(a))n.push(`${e}=${o}`);return{stdout:n.join(`
3
- `)+(n.length>0?`
4
- `:""),stderr:"",exitCode:0}}if(!r.exec)return{stdout:"",stderr:`env: command execution not supported in this context
5
- `,exitCode:1};let c=s.slice(t).join(" "),v=Object.entries(l).map(([n,e])=>`${n}="${e}"`).join(" "),d=v?`${v} ${c}`:c;return r.exec(d)}},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,r){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(r.env))t.push(`${a}=${c}`);return{stdout:t.join(`
6
- `)+(t.length>0?`
7
- `:""),stderr:"",exitCode:0}}let i=[],l=0;for(let t of u)t in r.env?i.push(r.env[t]):l=1;return{stdout:i.join(`
8
- `)+(i.length>0?`
9
- `:""),stderr:"",exitCode:l}}};export{y as envCommand,A as printenvCommand};
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env node
2
- import{a as v}from"./chunk-26Q3PZQ6.js";import{a as N,b as C}from"./chunk-GTNBSMZR.js";import"./chunk-5KNEBKYN.js";function b(e,o){switch(e.type){case"name":return v(o.name,e.pattern,e.ignoreCase);case"path":return v(o.relativePath,e.pattern,e.ignoreCase);case"type":return e.fileType==="f"?o.isFile:e.fileType==="d"?o.isDirectory:!1;case"empty":return o.isEmpty;case"mtime":{let r=(Date.now()-o.mtime)/(1e3*60*60*24);return e.comparison==="more"?r>e.days:e.comparison==="less"?r<e.days:Math.floor(r)===e.days}case"newer":{let s=o.newerRefTimes.get(e.refPath);return s===void 0?!1:o.mtime>s}case"size":{let s=e.value;switch(e.unit){case"c":s=e.value;break;case"k":s=e.value*1024;break;case"M":s=e.value*1024*1024;break;case"G":s=e.value*1024*1024*1024;break;case"b":s=e.value*512;break}return e.comparison==="more"?o.size>s:e.comparison==="less"?o.size<s:e.unit==="b"?Math.ceil(o.size/512)===e.value:o.size===s}case"perm":{let s=o.mode&511,r=e.mode&511;return e.matchType==="exact"?s===r:e.matchType==="all"?(s&r)===r:(s&r)!==0}case"not":return!b(e.expr,o);case"and":return b(e.left,o)&&b(e.right,o);case"or":return b(e.left,o)||b(e.right,o)}}function P(e){let o=[],s=r=>{r&&(r.type==="newer"?o.push(r.refPath):r.type==="not"?s(r.expr):(r.type==="and"||r.type==="or")&&(s(r.left),s(r.right)))};return s(e),o}function R(e,o){let s=[],r=[],i=o;for(;i<e.length;){let t=e[i];if(t==="-name"&&i+1<e.length)s.push({type:"expr",expr:{type:"name",pattern:e[++i]}});else if(t==="-iname"&&i+1<e.length)s.push({type:"expr",expr:{type:"name",pattern:e[++i],ignoreCase:!0}});else if(t==="-path"&&i+1<e.length)s.push({type:"expr",expr:{type:"path",pattern:e[++i]}});else if(t==="-ipath"&&i+1<e.length)s.push({type:"expr",expr:{type:"path",pattern:e[++i],ignoreCase:!0}});else if(t==="-type"&&i+1<e.length){let n=e[++i];if(n==="f"||n==="d")s.push({type:"expr",expr:{type:"type",fileType:n}});else return{expr:null,pathIndex:i,error:`find: Unknown argument to -type: ${n}
3
- `,actions:[]}}else if(t==="-empty")s.push({type:"expr",expr:{type:"empty"}});else if(t==="-mtime"&&i+1<e.length){let n=e[++i],p="exact",h=n;n.startsWith("+")?(p="more",h=n.slice(1)):n.startsWith("-")&&(p="less",h=n.slice(1));let u=parseInt(h,10);Number.isNaN(u)||s.push({type:"expr",expr:{type:"mtime",days:u,comparison:p}})}else if(t==="-newer"&&i+1<e.length){let n=e[++i];s.push({type:"expr",expr:{type:"newer",refPath:n}})}else if(t==="-size"&&i+1<e.length){let n=e[++i],p="exact",h=n;n.startsWith("+")?(p="more",h=n.slice(1)):n.startsWith("-")&&(p="less",h=n.slice(1));let u=h.match(/^(\d+)([ckMGb])?$/);if(u){let w=parseInt(u[1],10),x=u[2]||"b";s.push({type:"expr",expr:{type:"size",value:w,unit:x,comparison:p}})}}else if(t==="-perm"&&i+1<e.length){let n=e[++i],p="exact",h=n;n.startsWith("-")?(p="all",h=n.slice(1)):n.startsWith("/")&&(p="any",h=n.slice(1));let u=parseInt(h,8);Number.isNaN(u)||s.push({type:"expr",expr:{type:"perm",mode:u,matchType:p}})}else if(t==="-not"||t==="!")s.push({type:"not"});else if(t==="-o"||t==="-or")s.push({type:"op",op:"or"});else if(t==="-a"||t==="-and")s.push({type:"op",op:"and"});else if(t==="-maxdepth"||t==="-mindepth")i++;else if(t==="-exec"){let n=[];for(i++;i<e.length&&e[i]!==";"&&e[i]!=="+";)n.push(e[i]),i++;if(i>=e.length)return{expr:null,pathIndex:i,error:"find: missing argument to `-exec'\n",actions:[]};let p=e[i]==="+";r.push({type:"exec",command:n,batchMode:p})}else if(t==="-print")r.push({type:"print"});else if(t==="-print0")r.push({type:"print0"});else if(t==="-delete")r.push({type:"delete"});else{if(t.startsWith("-"))return{expr:null,pathIndex:i,error:`find: unknown predicate '${t}'
4
- `,actions:[]};if(s.length===0){i++;continue}break}i++}if(s.length===0)return{expr:null,pathIndex:i,actions:r};let g=[];for(let t=0;t<s.length;t++){let n=s[t];if(n.type==="not"){if(t+1<s.length&&s[t+1].type==="expr"){let p=s[t+1].expr;g.push({type:"expr",expr:{type:"not",expr:p}}),t++}}else(n.type==="expr"||n.type==="op")&&g.push(n)}let E=[[]];for(let t of g)t.type==="op"&&t.op==="or"?E.push([]):t.type==="expr"&&E[E.length-1].push(t.expr);let y=[];for(let t of E){if(t.length===0)continue;let n=t[0];for(let p=1;p<t.length;p++)n={type:"and",left:n,right:t[p]};y.push(n)}if(y.length===0)return{expr:null,pathIndex:i,actions:r};let T=y[0];for(let t=1;t<y.length;t++)T={type:"or",left:T,right:y[t]};return{expr:T,pathIndex:i,actions:r}}var $={name:"find",summary:"search for files in a directory hierarchy",usage:"find [path...] [expression]",options:["-name PATTERN file name matches shell pattern PATTERN","-iname PATTERN like -name but case insensitive","-path PATTERN file path matches shell pattern PATTERN","-ipath PATTERN like -path but case insensitive","-type TYPE file is of type: f (regular file), d (directory)","-empty file is empty or directory is empty","-mtime N file's data was modified N*24 hours ago","-newer FILE file was modified more recently than FILE","-size N[ckMGb] file uses N units of space (c=bytes, k=KB, M=MB, G=GB, b=512B blocks)","-perm MODE file's permission bits are exactly MODE (octal)","-perm -MODE all permission bits MODE are set","-perm /MODE any permission bits MODE are set","-maxdepth LEVELS descend at most LEVELS directories","-mindepth LEVELS do not apply tests at levels less than LEVELS","-not, ! negate the following expression","-a, -and logical AND (default)","-o, -or logical OR","-exec CMD {} ; execute CMD on each file ({} is replaced by filename)","-exec CMD {} + execute CMD with multiple files at once","-print print the full file name (default action)","-print0 print the full file name followed by a null character","-delete delete found files/directories"," --help display this help and exit"]},A=new Set(["-name","-iname","-path","-ipath","-type","-maxdepth","-mindepth","-mtime","-newer","-size","-perm"]),G={name:"find",async execute(e,o){if(C(e))return N($);let s=".",r=null,i=null;for(let l=0;l<e.length;l++){let a=e[l];if(a==="-maxdepth"&&l+1<e.length)r=parseInt(e[++l],10);else if(a==="-mindepth"&&l+1<e.length)i=parseInt(e[++l],10);else if(a==="-exec")for(l++;l<e.length&&e[l]!==";"&&e[l]!=="+";)l++;else!a.startsWith("-")&&a!==";"&&a!=="+"?s=a:A.has(a)&&l++}let{expr:g,error:E,actions:y}=R(e,0);if(E)return{stdout:"",stderr:E,exitCode:1};let T=y.length===0,t=o.fs.resolvePath(o.cwd,s);try{await o.fs.stat(t)}catch{return{stdout:"",stderr:`find: ${s}: No such file or directory
5
- `,exitCode:1}}let n=[],p=P(g),h=new Map;for(let l of p){let a=o.fs.resolvePath(o.cwd,l);try{let f=await o.fs.stat(a);h.set(l,f.mtime?.getTime()??Date.now())}catch{}}async function u(l,a){if(r!==null&&a>r)return;let f;try{f=await o.fs.stat(l)}catch{return}if(!f)return;let m;l===t?m=s.split("/").pop()||s:m=l.split("/").pop()||"";let c=l===t?s:s==="."?`./${l.slice(t.length+1)}`:s+l.slice(t.length),d=null;f.isDirectory&&(d=await o.fs.readdir(l));let z=f.isFile?f.size===0:d!==null&&d.length===0,D=i===null||a>=i;if(D&&g!==null){let k={name:m,relativePath:c,isFile:f.isFile,isDirectory:f.isDirectory,isEmpty:z,mtime:f.mtime?.getTime()??Date.now(),size:f.size??0,mode:f.mode??420,newerRefTimes:h};D=b(g,k)}if(D&&n.push(c),d!==null)for(let k of d){let I=l==="/"?`/${k}`:`${l}/${k}`;await u(I,a+1)}}await u(t,0);let w="",x="",M=0;if(y.length>0)for(let l of y)switch(l.type){case"print":w+=n.length>0?`${n.join(`
6
- `)}
7
- `:"";break;case"print0":w+=n.length>0?`${n.join("\0")}\0`:"";break;case"delete":{let a=[...n].sort((f,m)=>m.length-f.length);for(let f of a){let m=o.fs.resolvePath(o.cwd,f);try{await o.fs.rm(m,{recursive:!1})}catch(c){let d=c instanceof Error?c.message:String(c);x+=`find: cannot delete '${f}': ${d}
8
- `,M=1}}break}case"exec":if(!o.exec)return{stdout:"",stderr:`find: -exec not supported in this context
9
- `,exitCode:1};if(l.batchMode){let a=[];for(let c of l.command)c==="{}"?a.push(...n):a.push(c);let f=a.map(c=>`"${c}"`).join(" "),m=await o.exec(f);w+=m.stdout,x+=m.stderr,m.exitCode!==0&&(M=m.exitCode)}else for(let a of n){let m=l.command.map(d=>d==="{}"?a:d).map(d=>`"${d}"`).join(" "),c=await o.exec(m);w+=c.stdout,x+=c.stderr,c.exitCode!==0&&(M=c.exitCode)}break}else T&&(w=n.length>0?`${n.join(`
10
- `)}
11
- `:"");return{stdout:w,stderr:x,exitCode:M}}};export{G as findCommand};
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env node
2
- import{a as v}from"./chunk-26Q3PZQ6.js";import{a as C,b as k}from"./chunk-GTNBSMZR.js";import"./chunk-5KNEBKYN.js";function w(e,t){switch(e.type){case"name":return v(t.name,e.pattern,e.ignoreCase);case"path":return v(t.relativePath,e.pattern,e.ignoreCase);case"type":return e.fileType==="f"?t.isFile:e.fileType==="d"?t.isDirectory:!1;case"empty":return t.isEmpty;case"mtime":{let r=(Date.now()-t.mtime)/(1e3*60*60*24);return e.comparison==="more"?r>e.days:e.comparison==="less"?r<e.days:Math.floor(r)===e.days}case"newer":{let i=t.newerRefTimes.get(e.refPath);return i===void 0?!1:t.mtime>i}case"size":{let i=e.value;switch(e.unit){case"c":i=e.value;break;case"k":i=e.value*1024;break;case"M":i=e.value*1024*1024;break;case"G":i=e.value*1024*1024*1024;break;case"b":i=e.value*512;break}return e.comparison==="more"?t.size>i:e.comparison==="less"?t.size<i:e.unit==="b"?Math.ceil(t.size/512)===e.value:t.size===i}case"perm":{let i=t.mode&511,r=e.mode&511;return e.matchType==="exact"?i===r:e.matchType==="all"?(i&r)===r:(i&r)!==0}case"not":return!w(e.expr,t);case"and":return w(e.left,t)&&w(e.right,t);case"or":return w(e.left,t)||w(e.right,t)}}function P(e){let t=[],i=r=>{r&&(r.type==="newer"?t.push(r.refPath):r.type==="not"?i(r.expr):(r.type==="and"||r.type==="or")&&(i(r.left),i(r.right)))};return i(e),t}function z(e,t){let i=[],r=[],s=t;for(;s<e.length;){let l=e[s];if(l==="("||l==="\\("){i.push({type:"lparen"}),s++;continue}if(l===")"||l==="\\)"){i.push({type:"rparen"}),s++;continue}if(l==="-name"&&s+1<e.length)i.push({type:"expr",expr:{type:"name",pattern:e[++s]}});else if(l==="-iname"&&s+1<e.length)i.push({type:"expr",expr:{type:"name",pattern:e[++s],ignoreCase:!0}});else if(l==="-path"&&s+1<e.length)i.push({type:"expr",expr:{type:"path",pattern:e[++s]}});else if(l==="-ipath"&&s+1<e.length)i.push({type:"expr",expr:{type:"path",pattern:e[++s],ignoreCase:!0}});else if(l==="-type"&&s+1<e.length){let n=e[++s];if(n==="f"||n==="d")i.push({type:"expr",expr:{type:"type",fileType:n}});else return{expr:null,pathIndex:s,error:`find: Unknown argument to -type: ${n}
3
- `,actions:[]}}else if(l==="-empty")i.push({type:"expr",expr:{type:"empty"}});else if(l==="-mtime"&&s+1<e.length){let n=e[++s],p="exact",a=n;n.startsWith("+")?(p="more",a=n.slice(1)):n.startsWith("-")&&(p="less",a=n.slice(1));let c=parseInt(a,10);Number.isNaN(c)||i.push({type:"expr",expr:{type:"mtime",days:c,comparison:p}})}else if(l==="-newer"&&s+1<e.length){let n=e[++s];i.push({type:"expr",expr:{type:"newer",refPath:n}})}else if(l==="-size"&&s+1<e.length){let n=e[++s],p="exact",a=n;n.startsWith("+")?(p="more",a=n.slice(1)):n.startsWith("-")&&(p="less",a=n.slice(1));let c=a.match(/^(\d+)([ckMGb])?$/);if(c){let M=parseInt(c[1],10),E=c[2]||"b";i.push({type:"expr",expr:{type:"size",value:M,unit:E,comparison:p}})}}else if(l==="-perm"&&s+1<e.length){let n=e[++s],p="exact",a=n;n.startsWith("-")?(p="all",a=n.slice(1)):n.startsWith("/")&&(p="any",a=n.slice(1));let c=parseInt(a,8);Number.isNaN(c)||i.push({type:"expr",expr:{type:"perm",mode:c,matchType:p}})}else if(l==="-not"||l==="!")i.push({type:"not"});else if(l==="-o"||l==="-or")i.push({type:"op",op:"or"});else if(l==="-a"||l==="-and")i.push({type:"op",op:"and"});else if(l==="-maxdepth"||l==="-mindepth")s++;else if(l==="-exec"){let n=[];for(s++;s<e.length&&e[s]!==";"&&e[s]!=="+";)n.push(e[s]),s++;if(s>=e.length)return{expr:null,pathIndex:s,error:"find: missing argument to `-exec'\n",actions:[]};let p=e[s]==="+";r.push({type:"exec",command:n,batchMode:p})}else if(l==="-print")r.push({type:"print"});else if(l==="-print0")r.push({type:"print0"});else if(l==="-delete")r.push({type:"delete"});else{if(l.startsWith("-"))return{expr:null,pathIndex:s,error:`find: unknown predicate '${l}'
4
- `,actions:[]};if(i.length===0){s++;continue}break}s++}if(i.length===0)return{expr:null,pathIndex:s,actions:r};let y=$(i);return y.error?{expr:null,pathIndex:s,error:y.error,actions:r}:{expr:y.expr,pathIndex:s,actions:r}}function $(e){let t=0;function i(){let n=r();if(!n)return null;for(;t<e.length;){let p=e[t];if(p.type==="op"&&p.op==="or"){t++;let a=r();if(!a)return n;n={type:"or",left:n,right:a}}else break}return n}function r(){let n=s();if(!n)return null;for(;t<e.length;){let p=e[t];if(p.type==="op"&&p.op==="and"){t++;let a=s();if(!a)return n;n={type:"and",left:n,right:a}}else if(p.type==="expr"||p.type==="not"||p.type==="lparen"){let a=s();if(!a)return n;n={type:"and",left:n,right:a}}else break}return n}function s(){if(t<e.length&&e[t].type==="not"){t++;let n=s();return n?{type:"not",expr:n}:null}return y()}function y(){if(t>=e.length)return null;let n=e[t];if(n.type==="lparen"){t++;let p=i();return t<e.length&&e[t].type==="rparen"&&t++,p}return n.type==="expr"?(t++,n.expr):(n.type==="rparen",null)}return{expr:i()}}var A={name:"find",summary:"search for files in a directory hierarchy",usage:"find [path...] [expression]",options:["-name PATTERN file name matches shell pattern PATTERN","-iname PATTERN like -name but case insensitive","-path PATTERN file path matches shell pattern PATTERN","-ipath PATTERN like -path but case insensitive","-type TYPE file is of type: f (regular file), d (directory)","-empty file is empty or directory is empty","-mtime N file's data was modified N*24 hours ago","-newer FILE file was modified more recently than FILE","-size N[ckMGb] file uses N units of space (c=bytes, k=KB, M=MB, G=GB, b=512B blocks)","-perm MODE file's permission bits are exactly MODE (octal)","-perm -MODE all permission bits MODE are set","-perm /MODE any permission bits MODE are set","-maxdepth LEVELS descend at most LEVELS directories","-mindepth LEVELS do not apply tests at levels less than LEVELS","-not, ! negate the following expression","-a, -and logical AND (default)","-o, -or logical OR","-exec CMD {} ; execute CMD on each file ({} is replaced by filename)","-exec CMD {} + execute CMD with multiple files at once","-print print the full file name (default action)","-print0 print the full file name followed by a null character","-delete delete found files/directories"," --help display this help and exit"]},S=new Set(["-name","-iname","-path","-ipath","-type","-maxdepth","-mindepth","-mtime","-newer","-size","-perm"]),H={name:"find",async execute(e,t){if(k(e))return C(A);let i=".",r=null,s=null;for(let o=0;o<e.length;o++){let f=e[o];if(f==="-maxdepth"&&o+1<e.length)r=parseInt(e[++o],10);else if(f==="-mindepth"&&o+1<e.length)s=parseInt(e[++o],10);else if(f==="-exec")for(o++;o<e.length&&e[o]!==";"&&e[o]!=="+";)o++;else!f.startsWith("-")&&f!==";"&&f!=="+"&&f!=="("&&f!==")"&&f!=="\\("&&f!=="\\)"?i=f:S.has(f)&&o++}let{expr:y,error:l,actions:n}=z(e,0);if(l)return{stdout:"",stderr:l,exitCode:1};let p=n.length===0,a=t.fs.resolvePath(t.cwd,i);try{await t.fs.stat(a)}catch{return{stdout:"",stderr:`find: ${i}: No such file or directory
5
- `,exitCode:1}}let c=[],M=P(y),E=new Map;for(let o of M){let f=t.fs.resolvePath(t.cwd,o);try{let h=await t.fs.stat(f);E.set(o,h.mtime?.getTime()??Date.now())}catch{}}async function N(o,f){if(r!==null&&f>r)return;let h;try{h=await t.fs.stat(o)}catch{return}if(!h)return;let m;o===a?m=i.split("/").pop()||i:m=o.split("/").pop()||"";let u=o===a?i:i==="."?`./${o.slice(a.length+1)}`:i+o.slice(a.length),d=null;h.isDirectory&&(d=await t.fs.readdir(o));let I=h.isFile?h.size===0:d!==null&&d.length===0,D=s===null||f>=s;if(D&&y!==null){let T={name:m,relativePath:u,isFile:h.isFile,isDirectory:h.isDirectory,isEmpty:I,mtime:h.mtime?.getTime()??Date.now(),size:h.size??0,mode:h.mode??420,newerRefTimes:E};D=w(y,T)}if(D&&c.push(u),d!==null)for(let T of d){let R=o==="/"?`/${T}`:`${o}/${T}`;await N(R,f+1)}}await N(a,0);let b="",g="",x=0;if(n.length>0)for(let o of n)switch(o.type){case"print":b+=c.length>0?`${c.join(`
6
- `)}
7
- `:"";break;case"print0":b+=c.length>0?`${c.join("\0")}\0`:"";break;case"delete":{let f=[...c].sort((h,m)=>m.length-h.length);for(let h of f){let m=t.fs.resolvePath(t.cwd,h);try{await t.fs.rm(m,{recursive:!1})}catch(u){let d=u instanceof Error?u.message:String(u);g+=`find: cannot delete '${h}': ${d}
8
- `,x=1}}break}case"exec":if(!t.exec)return{stdout:"",stderr:`find: -exec not supported in this context
9
- `,exitCode:1};if(o.batchMode){let f=[];for(let u of o.command)u==="{}"?f.push(...c):f.push(u);let h=f.map(u=>`"${u}"`).join(" "),m=await t.exec(h);b+=m.stdout,g+=m.stderr,m.exitCode!==0&&(x=m.exitCode)}else for(let f of c){let m=o.command.map(d=>d==="{}"?f:d).map(d=>`"${d}"`).join(" "),u=await t.exec(m);b+=u.stdout,g+=u.stderr,u.exitCode!==0&&(x=u.exitCode)}break}else p&&(b=c.length>0?`${c.join(`
10
- `)}
11
- `:"");return{stdout:b,stderr:g,exitCode:x}}};export{H as findCommand};
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env node
2
- import{a as N}from"./chunk-26Q3PZQ6.js";import{a as L,b as B,c as H}from"./chunk-6QUZ7QML.js";import{a as I,b as O}from"./chunk-GTNBSMZR.js";import"./chunk-5KNEBKYN.js";function w(e,s){switch(e.type){case"name":return{matches:N(s.name,e.pattern,e.ignoreCase),pruned:!1,printed:!1};case"path":return{matches:N(s.relativePath,e.pattern,e.ignoreCase),pruned:!1,printed:!1};case"regex":try{let n=e.ignoreCase?"i":"";return{matches:new RegExp(e.pattern,n).test(s.relativePath),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:s.isFile,pruned:!1,printed:!1}:e.fileType==="d"?{matches:s.isDirectory,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"empty":return{matches:s.isEmpty,pruned:!1,printed:!1};case"mtime":{let r=(Date.now()-s.mtime)/(1e3*60*60*24),t;return e.comparison==="more"?t=r>e.days:e.comparison==="less"?t=r<e.days:t=Math.floor(r)===e.days,{matches:t,pruned:!1,printed:!1}}case"newer":{let n=s.newerRefTimes.get(e.refPath);return n===void 0?{matches:!1,pruned:!1,printed:!1}:{matches:s.mtime>n,pruned:!1,printed:!1}}case"size":{let n=e.value;switch(e.unit){case"c":n=e.value;break;case"k":n=e.value*1024;break;case"M":n=e.value*1024*1024;break;case"G":n=e.value*1024*1024*1024;break;case"b":n=e.value*512;break}let r;return e.comparison==="more"?r=s.size>n:e.comparison==="less"?r=s.size<n:e.unit==="b"?r=Math.ceil(s.size/512)===e.value:r=s.size===n,{matches:r,pruned:!1,printed:!1}}case"perm":{let n=s.mode&511,r=e.mode&511,t;return e.matchType==="exact"?t=n===r:e.matchType==="all"?t=(n&r)===r:t=(n&r)!==0,{matches:t,pruned:!1,printed:!1}}case"prune":return{matches:!0,pruned:!0,printed:!1};case"print":return{matches:!0,pruned:!1,printed:!0};case"not":{let n=w(e.expr,s);return{matches:!n.matches,pruned:n.pruned,printed:!1}}case"and":{let n=w(e.left,s);if(!n.matches)return{matches:!1,pruned:n.pruned,printed:!1};let r=w(e.right,s);return{matches:r.matches,pruned:n.pruned||r.pruned,printed:n.printed||r.printed}}case"or":{let n=w(e.left,s);if(n.matches)return n;let r=w(e.right,s);return{matches:r.matches,pruned:n.pruned||r.pruned,printed:r.printed}}}}function G(e){let s=[],n=r=>{r&&(r.type==="newer"?s.push(r.refPath):r.type==="not"?n(r.expr):(r.type==="and"||r.type==="or")&&(n(r.left),n(r.right)))};return n(e),s}function j(e,s){let n=[],r=[],t=s;for(;t<e.length;){let a=e[t];if(a==="("||a==="\\("){n.push({type:"lparen"}),t++;continue}if(a===")"||a==="\\)"){n.push({type:"rparen"}),t++;continue}if(a==="-name"&&t+1<e.length)n.push({type:"expr",expr:{type:"name",pattern:e[++t]}});else if(a==="-iname"&&t+1<e.length)n.push({type:"expr",expr:{type:"name",pattern:e[++t],ignoreCase:!0}});else if(a==="-path"&&t+1<e.length)n.push({type:"expr",expr:{type:"path",pattern:e[++t]}});else if(a==="-ipath"&&t+1<e.length)n.push({type:"expr",expr:{type:"path",pattern:e[++t],ignoreCase:!0}});else if(a==="-regex"&&t+1<e.length)n.push({type:"expr",expr:{type:"regex",pattern:e[++t]}});else if(a==="-iregex"&&t+1<e.length)n.push({type:"expr",expr:{type:"regex",pattern:e[++t],ignoreCase:!0}});else if(a==="-type"&&t+1<e.length){let i=e[++t];if(i==="f"||i==="d")n.push({type:"expr",expr:{type:"type",fileType:i}});else return{expr:null,pathIndex:t,error:`find: Unknown argument to -type: ${i}
3
- `,actions:[]}}else if(a==="-empty")n.push({type:"expr",expr:{type:"empty"}});else if(a==="-mtime"&&t+1<e.length){let i=e[++t],c="exact",o=i;i.startsWith("+")?(c="more",o=i.slice(1)):i.startsWith("-")&&(c="less",o=i.slice(1));let h=parseInt(o,10);Number.isNaN(h)||n.push({type:"expr",expr:{type:"mtime",days:h,comparison:c}})}else if(a==="-newer"&&t+1<e.length){let i=e[++t];n.push({type:"expr",expr:{type:"newer",refPath:i}})}else if(a==="-size"&&t+1<e.length){let i=e[++t],c="exact",o=i;i.startsWith("+")?(c="more",o=i.slice(1)):i.startsWith("-")&&(c="less",o=i.slice(1));let h=o.match(/^(\d+)([ckMGb])?$/);if(h){let b=parseInt(h[1],10),y=h[2]||"b";n.push({type:"expr",expr:{type:"size",value:b,unit:y,comparison:c}})}}else if(a==="-perm"&&t+1<e.length){let i=e[++t],c="exact",o=i;i.startsWith("-")?(c="all",o=i.slice(1)):i.startsWith("/")&&(c="any",o=i.slice(1));let h=parseInt(o,8);Number.isNaN(h)||n.push({type:"expr",expr:{type:"perm",mode:h,matchType:c}})}else if(a==="-prune")n.push({type:"expr",expr:{type:"prune"}});else if(a==="-not"||a==="!")n.push({type:"not"});else if(a==="-o"||a==="-or")n.push({type:"op",op:"or"});else if(a==="-a"||a==="-and")n.push({type:"op",op:"and"});else if(a==="-maxdepth"||a==="-mindepth")t++;else if(a!=="-depth")if(a==="-exec"){let i=[];for(t++;t<e.length&&e[t]!==";"&&e[t]!=="+";)i.push(e[t]),t++;if(t>=e.length)return{expr:null,pathIndex:t,error:"find: missing argument to `-exec'\n",actions:[]};let c=e[t]==="+";r.push({type:"exec",command:i,batchMode:c})}else if(a==="-print")n.push({type:"expr",expr:{type:"print"}}),r.push({type:"print"});else if(a==="-print0")r.push({type:"print0"});else if(a==="-printf"&&t+1<e.length){let i=e[++t];r.push({type:"printf",format:i})}else if(a==="-delete")r.push({type:"delete"});else{if(a.startsWith("-"))return{expr:null,pathIndex:t,error:`find: unknown predicate '${a}'
4
- `,actions:[]};if(n.length===0){t++;continue}break}t++}if(n.length===0)return{expr:null,pathIndex:t,actions:r};let m=_(n);return m.error?{expr:null,pathIndex:t,error:m.error,actions:r}:{expr:m.expr,pathIndex:t,actions:r}}function _(e){let s=0;function n(){let i=r();if(!i)return null;for(;s<e.length;){let c=e[s];if(c.type==="op"&&c.op==="or"){s++;let o=r();if(!o)return i;i={type:"or",left:i,right:o}}else break}return i}function r(){let i=t();if(!i)return null;for(;s<e.length;){let c=e[s];if(c.type==="op"&&c.op==="and"){s++;let o=t();if(!o)return i;i={type:"and",left:i,right:o}}else if(c.type==="expr"||c.type==="not"||c.type==="lparen"){let o=t();if(!o)return i;i={type:"and",left:i,right:o}}else break}return i}function t(){if(s<e.length&&e[s].type==="not"){s++;let i=t();return i?{type:"not",expr:i}:null}return m()}function m(){if(s>=e.length)return null;let i=e[s];if(i.type==="lparen"){s++;let c=n();return s<e.length&&e[s].type==="rparen"&&s++,c}return i.type==="expr"?(s++,i.expr):(i.type==="rparen",null)}return{expr:n()}}var K={name:"find",summary:"search for files in a directory hierarchy",usage:"find [path...] [expression]",options:["-name PATTERN file name matches shell pattern PATTERN","-iname PATTERN like -name but case insensitive","-path PATTERN file path matches shell pattern PATTERN","-ipath PATTERN like -path but case insensitive","-regex PATTERN file path matches regular expression PATTERN","-iregex PATTERN like -regex but case insensitive","-type TYPE file is of type: f (regular file), d (directory)","-empty file is empty or directory is empty","-mtime N file's data was modified N*24 hours ago","-newer FILE file was modified more recently than FILE","-size N[ckMGb] file uses N units of space (c=bytes, k=KB, M=MB, G=GB, b=512B blocks)","-perm MODE file's permission bits are exactly MODE (octal)","-perm -MODE all permission bits MODE are set","-perm /MODE any permission bits MODE are set","-maxdepth LEVELS descend at most LEVELS directories","-mindepth LEVELS do not apply tests at levels less than LEVELS","-depth process directory contents before directory itself","-prune do not descend into this directory","-not, ! negate the following expression","-a, -and logical AND (default)","-o, -or logical OR","-exec CMD {} ; execute CMD on each file ({} is replaced by filename)","-exec CMD {} + execute CMD with multiple files at once","-print print the full file name (default action)","-print0 print the full file name followed by a null character","-printf FORMAT print FORMAT with directives: %f %h %p %P %s %d %m %M %t","-delete delete found files/directories"," --help display this help and exit"]},U=new Set(["-name","-iname","-path","-ipath","-regex","-iregex","-type","-maxdepth","-mindepth","-mtime","-newer","-size","-perm"]),oe={name:"find",async execute(e,s){if(O(e))return I(K);let n=[],r=null,t=null,m=!1,a=!1;for(let p=0;p<e.length;p++){let l=e[p];if(l==="-maxdepth"&&p+1<e.length)a=!0,r=parseInt(e[++p],10);else if(l==="-mindepth"&&p+1<e.length)a=!0,t=parseInt(e[++p],10);else if(l==="-depth")a=!0,m=!0;else if(l==="-exec")for(a=!0,p++;p<e.length&&e[p]!==";"&&e[p]!=="+";)p++;else!l.startsWith("-")&&l!==";"&&l!=="+"&&l!=="("&&l!==")"&&l!=="\\("&&l!=="\\)"&&l!=="!"?a||n.push(l):U.has(l)?(a=!0,p++):(l.startsWith("-")||l==="("||l==="\\("||l==="!")&&(a=!0)}n.length===0&&n.push(".");let{expr:i,error:c,actions:o}=j(e,0);if(c)return{stdout:"",stderr:c,exitCode:1};let h=o.some(p=>p.type==="print"),b=o.length===0,y=[],Y=o.some(p=>p.type==="printf"),F=[],T="",D=0,V=G(i),k=new Map;for(let p of V){let l=s.fs.resolvePath(s.cwd,p);try{let g=await s.fs.stat(l);k.set(p,g.mtime?.getTime()??Date.now())}catch{}}for(let p of n){let l=s.fs.resolvePath(s.cwd,p);try{await s.fs.stat(l)}catch{T+=`find: ${p}: No such file or directory
5
- `,D=1;continue}async function g(u,d){if(r!==null&&d>r)return;let f;try{f=await s.fs.stat(u)}catch{return}if(!f)return;let E;u===l?E=p.split("/").pop()||p:E=u.split("/").pop()||"";let v=u===l?p:p==="."?`./${u.slice(l.length+1)}`:p+u.slice(l.length),M=null;f.isDirectory&&(M=await s.fs.readdir(u));let R=f.isFile?f.size===0:M!==null&&M.length===0,C=()=>{let x=t===null||d>=t,$=!1;if(x&&i!==null){let J={name:E,relativePath:v,isFile:f.isFile,isDirectory:f.isDirectory,isEmpty:R,mtime:f.mtime?.getTime()??Date.now(),size:f.size??0,mode:f.mode??420,newerRefTimes:k},W=w(i,J);x=W.matches,h?$=W.printed:$=x}else x&&($=!0);$&&(y.push(v),Y&&F.push({path:v,name:E,size:f.size??0,mtime:f.mtime?.getTime()??Date.now(),mode:f.mode??420,isDirectory:f.isDirectory,depth:d,startingPoint:p}))},A=async()=>{if(M!==null)for(let P of M){let x=u==="/"?`/${P}`:`${u}/${P}`;await g(x,d+1)}},z=!1;if(!m&&i!==null){let P={name:E,relativePath:v,isFile:f.isFile,isDirectory:f.isDirectory,isEmpty:R,mtime:f.mtime?.getTime()??Date.now(),size:f.size??0,mode:f.mode??420,newerRefTimes:k};z=w(i,P).pruned}m?(await A(),C()):(C(),z||await A())}await g(l,0)}let S="";if(o.length>0)for(let p of o)switch(p.type){case"print":S+=y.length>0?`${y.join(`
6
- `)}
7
- `:"";break;case"print0":S+=y.length>0?`${y.join("\0")}\0`:"";break;case"delete":{let l=[...y].sort((g,u)=>u.length-g.length);for(let g of l){let u=s.fs.resolvePath(s.cwd,g);try{await s.fs.rm(u,{recursive:!1})}catch(d){let f=d instanceof Error?d.message:String(d);T+=`find: cannot delete '${g}': ${f}
8
- `,D=1}}break}case"printf":for(let l of F)S+=q(p.format,l);break;case"exec":if(!s.exec)return{stdout:"",stderr:`find: -exec not supported in this context
9
- `,exitCode:1};if(p.batchMode){let l=[];for(let d of p.command)d==="{}"?l.push(...y):l.push(d);let g=l.map(d=>`"${d}"`).join(" "),u=await s.exec(g,{cwd:s.cwd});S+=u.stdout,T+=u.stderr,u.exitCode!==0&&(D=u.exitCode)}else for(let l of y){let u=p.command.map(f=>f==="{}"?l:f).map(f=>`"${f}"`).join(" "),d=await s.exec(u,{cwd:s.cwd});S+=d.stdout,T+=d.stderr,d.exitCode!==0&&(D=d.exitCode)}break}else b&&(S=y.length>0?`${y.join(`
10
- `)}
11
- `:"");return{stdout:S,stderr:T,exitCode:D}}};function q(e,s){let n=H(e),r="",t=0;for(;t<n.length;)if(n[t]==="%"&&t+1<n.length){if(t++,n[t]==="%"){r+="%",t++;continue}let[m,a,i]=B(n,t);if(t+=i,t>=n.length){r+="%";break}let c=n[t],o;switch(c){case"f":o=s.name,t++;break;case"h":{let h=s.path.lastIndexOf("/");o=h>0?s.path.slice(0,h):".",t++;break}case"p":o=s.path,t++;break;case"P":{let h=s.startingPoint;s.path===h?o="":s.path.startsWith(`${h}/`)?o=s.path.slice(h.length+1):h==="."&&s.path.startsWith("./")?o=s.path.slice(2):o=s.path,t++;break}case"s":o=String(s.size),t++;break;case"d":o=String(s.depth),t++;break;case"m":o=(s.mode&511).toString(8),t++;break;case"M":o=Q(s.mode,s.isDirectory),t++;break;case"t":{let h=new Date(s.mtime);o=X(h),t++;break}case"T":{if(t+1<n.length){let h=n[t+1],b=new Date(s.mtime);o=Z(b,h),t+=2}else o="%T",t++;break}default:r+="%"+(m!==0||a!==-1?`${m}.${a}`:"")+c,t++;continue}r+=L(o,m,a)}else r+=n[t],t++;return r}function Q(e,s){let n=e&511,r=s?"d":"-";return r+=n&256?"r":"-",r+=n&128?"w":"-",r+=n&64?"x":"-",r+=n&32?"r":"-",r+=n&16?"w":"-",r+=n&8?"x":"-",r+=n&4?"r":"-",r+=n&2?"w":"-",r+=n&1?"x":"-",r}function X(e){let s=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],r=s[e.getDay()],t=n[e.getMonth()],m=String(e.getDate()).padStart(2," "),a=String(e.getHours()).padStart(2,"0"),i=String(e.getMinutes()).padStart(2,"0"),c=String(e.getSeconds()).padStart(2,"0"),o=e.getFullYear();return`${r} ${t} ${m} ${a}:${i}:${c} ${o}`}function Z(e,s){switch(s){case"@":return String(e.getTime()/1e3);case"Y":return String(e.getFullYear());case"m":return String(e.getMonth()+1).padStart(2,"0");case"d":return String(e.getDate()).padStart(2,"0");case"H":return String(e.getHours()).padStart(2,"0");case"M":return String(e.getMinutes()).padStart(2,"0");case"S":return String(e.getSeconds()).padStart(2,"0");case"T":return`${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}:${String(e.getSeconds()).padStart(2,"0")}`;case"F":return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`;default:return`%T${s}`}}export{oe as findCommand};
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env node
2
- import{a as N}from"./chunk-26Q3PZQ6.js";import{a as A,b as z}from"./chunk-GTNBSMZR.js";import"./chunk-5KNEBKYN.js";function g(e,s){switch(e.type){case"name":return{matches:N(s.name,e.pattern,e.ignoreCase),pruned:!1,printed:!1};case"path":return{matches:N(s.relativePath,e.pattern,e.ignoreCase),pruned:!1,printed:!1};case"regex":try{let t=e.ignoreCase?"i":"";return{matches:new RegExp(e.pattern,t).test(s.relativePath),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:s.isFile,pruned:!1,printed:!1}:e.fileType==="d"?{matches:s.isDirectory,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"empty":return{matches:s.isEmpty,pruned:!1,printed:!1};case"mtime":{let r=(Date.now()-s.mtime)/(1e3*60*60*24),n;return e.comparison==="more"?n=r>e.days:e.comparison==="less"?n=r<e.days:n=Math.floor(r)===e.days,{matches:n,pruned:!1,printed:!1}}case"newer":{let t=s.newerRefTimes.get(e.refPath);return t===void 0?{matches:!1,pruned:!1,printed:!1}:{matches:s.mtime>t,pruned:!1,printed:!1}}case"size":{let t=e.value;switch(e.unit){case"c":t=e.value;break;case"k":t=e.value*1024;break;case"M":t=e.value*1024*1024;break;case"G":t=e.value*1024*1024*1024;break;case"b":t=e.value*512;break}let r;return e.comparison==="more"?r=s.size>t:e.comparison==="less"?r=s.size<t:e.unit==="b"?r=Math.ceil(s.size/512)===e.value:r=s.size===t,{matches:r,pruned:!1,printed:!1}}case"perm":{let t=s.mode&511,r=e.mode&511,n;return e.matchType==="exact"?n=t===r:e.matchType==="all"?n=(t&r)===r:n=(t&r)!==0,{matches:n,pruned:!1,printed:!1}}case"prune":return{matches:!0,pruned:!0,printed:!1};case"print":return{matches:!0,pruned:!1,printed:!0};case"not":{let t=g(e.expr,s);return{matches:!t.matches,pruned:t.pruned,printed:!1}}case"and":{let t=g(e.left,s);if(!t.matches)return{matches:!1,pruned:t.pruned,printed:!1};let r=g(e.right,s);return{matches:r.matches,pruned:t.pruned||r.pruned,printed:t.printed||r.printed}}case"or":{let t=g(e.left,s);if(t.matches)return t;let r=g(e.right,s);return{matches:r.matches,pruned:t.pruned||r.pruned,printed:r.printed}}}}function I(e){let s=[],t=r=>{r&&(r.type==="newer"?s.push(r.refPath):r.type==="not"?t(r.expr):(r.type==="and"||r.type==="or")&&(t(r.left),t(r.right)))};return t(e),s}function $(e,s){let t=[],r=[],n=s;for(;n<e.length;){let l=e[n];if(l==="("||l==="\\("){t.push({type:"lparen"}),n++;continue}if(l===")"||l==="\\)"){t.push({type:"rparen"}),n++;continue}if(l==="-name"&&n+1<e.length)t.push({type:"expr",expr:{type:"name",pattern:e[++n]}});else if(l==="-iname"&&n+1<e.length)t.push({type:"expr",expr:{type:"name",pattern:e[++n],ignoreCase:!0}});else if(l==="-path"&&n+1<e.length)t.push({type:"expr",expr:{type:"path",pattern:e[++n]}});else if(l==="-ipath"&&n+1<e.length)t.push({type:"expr",expr:{type:"path",pattern:e[++n],ignoreCase:!0}});else if(l==="-regex"&&n+1<e.length)t.push({type:"expr",expr:{type:"regex",pattern:e[++n]}});else if(l==="-iregex"&&n+1<e.length)t.push({type:"expr",expr:{type:"regex",pattern:e[++n],ignoreCase:!0}});else if(l==="-type"&&n+1<e.length){let i=e[++n];if(i==="f"||i==="d")t.push({type:"expr",expr:{type:"type",fileType:i}});else return{expr:null,pathIndex:n,error:`find: Unknown argument to -type: ${i}
3
- `,actions:[]}}else if(l==="-empty")t.push({type:"expr",expr:{type:"empty"}});else if(l==="-mtime"&&n+1<e.length){let i=e[++n],o="exact",f=i;i.startsWith("+")?(o="more",f=i.slice(1)):i.startsWith("-")&&(o="less",f=i.slice(1));let u=parseInt(f,10);Number.isNaN(u)||t.push({type:"expr",expr:{type:"mtime",days:u,comparison:o}})}else if(l==="-newer"&&n+1<e.length){let i=e[++n];t.push({type:"expr",expr:{type:"newer",refPath:i}})}else if(l==="-size"&&n+1<e.length){let i=e[++n],o="exact",f=i;i.startsWith("+")?(o="more",f=i.slice(1)):i.startsWith("-")&&(o="less",f=i.slice(1));let u=f.match(/^(\d+)([ckMGb])?$/);if(u){let m=parseInt(u[1],10),v=u[2]||"b";t.push({type:"expr",expr:{type:"size",value:m,unit:v,comparison:o}})}}else if(l==="-perm"&&n+1<e.length){let i=e[++n],o="exact",f=i;i.startsWith("-")?(o="all",f=i.slice(1)):i.startsWith("/")&&(o="any",f=i.slice(1));let u=parseInt(f,8);Number.isNaN(u)||t.push({type:"expr",expr:{type:"perm",mode:u,matchType:o}})}else if(l==="-prune")t.push({type:"expr",expr:{type:"prune"}});else if(l==="-not"||l==="!")t.push({type:"not"});else if(l==="-o"||l==="-or")t.push({type:"op",op:"or"});else if(l==="-a"||l==="-and")t.push({type:"op",op:"and"});else if(l==="-maxdepth"||l==="-mindepth")n++;else if(l==="-exec"){let i=[];for(n++;n<e.length&&e[n]!==";"&&e[n]!=="+";)i.push(e[n]),n++;if(n>=e.length)return{expr:null,pathIndex:n,error:"find: missing argument to `-exec'\n",actions:[]};let o=e[n]==="+";r.push({type:"exec",command:i,batchMode:o})}else if(l==="-print")t.push({type:"expr",expr:{type:"print"}}),r.push({type:"print"});else if(l==="-print0")r.push({type:"print0"});else if(l==="-delete")r.push({type:"delete"});else{if(l.startsWith("-"))return{expr:null,pathIndex:n,error:`find: unknown predicate '${l}'
4
- `,actions:[]};if(t.length===0){n++;continue}break}n++}if(t.length===0)return{expr:null,pathIndex:n,actions:r};let w=S(t);return w.error?{expr:null,pathIndex:n,error:w.error,actions:r}:{expr:w.expr,pathIndex:n,actions:r}}function S(e){let s=0;function t(){let i=r();if(!i)return null;for(;s<e.length;){let o=e[s];if(o.type==="op"&&o.op==="or"){s++;let f=r();if(!f)return i;i={type:"or",left:i,right:f}}else break}return i}function r(){let i=n();if(!i)return null;for(;s<e.length;){let o=e[s];if(o.type==="op"&&o.op==="and"){s++;let f=n();if(!f)return i;i={type:"and",left:i,right:f}}else if(o.type==="expr"||o.type==="not"||o.type==="lparen"){let f=n();if(!f)return i;i={type:"and",left:i,right:f}}else break}return i}function n(){if(s<e.length&&e[s].type==="not"){s++;let i=n();return i?{type:"not",expr:i}:null}return w()}function w(){if(s>=e.length)return null;let i=e[s];if(i.type==="lparen"){s++;let o=t();return s<e.length&&e[s].type==="rparen"&&s++,o}return i.type==="expr"?(s++,i.expr):(i.type==="rparen",null)}return{expr:t()}}var F={name:"find",summary:"search for files in a directory hierarchy",usage:"find [path...] [expression]",options:["-name PATTERN file name matches shell pattern PATTERN","-iname PATTERN like -name but case insensitive","-path PATTERN file path matches shell pattern PATTERN","-ipath PATTERN like -path but case insensitive","-regex PATTERN file path matches regular expression PATTERN","-iregex PATTERN like -regex but case insensitive","-type TYPE file is of type: f (regular file), d (directory)","-empty file is empty or directory is empty","-mtime N file's data was modified N*24 hours ago","-newer FILE file was modified more recently than FILE","-size N[ckMGb] file uses N units of space (c=bytes, k=KB, M=MB, G=GB, b=512B blocks)","-perm MODE file's permission bits are exactly MODE (octal)","-perm -MODE all permission bits MODE are set","-perm /MODE any permission bits MODE are set","-maxdepth LEVELS descend at most LEVELS directories","-mindepth LEVELS do not apply tests at levels less than LEVELS","-prune do not descend into this directory","-not, ! negate the following expression","-a, -and logical AND (default)","-o, -or logical OR","-exec CMD {} ; execute CMD on each file ({} is replaced by filename)","-exec CMD {} + execute CMD with multiple files at once","-print print the full file name (default action)","-print0 print the full file name followed by a null character","-delete delete found files/directories"," --help display this help and exit"]},L=new Set(["-name","-iname","-path","-ipath","-regex","-iregex","-type","-maxdepth","-mindepth","-mtime","-newer","-size","-perm"]),K={name:"find",async execute(e,s){if(z(e))return A(F);let t=".",r=null,n=null;for(let a=0;a<e.length;a++){let p=e[a];if(p==="-maxdepth"&&a+1<e.length)r=parseInt(e[++a],10);else if(p==="-mindepth"&&a+1<e.length)n=parseInt(e[++a],10);else if(p==="-exec")for(a++;a<e.length&&e[a]!==";"&&e[a]!=="+";)a++;else!p.startsWith("-")&&p!==";"&&p!=="+"&&p!=="("&&p!==")"&&p!=="\\("&&p!=="\\)"&&p!=="!"?t=p:L.has(p)&&a++}let{expr:w,error:l,actions:i}=$(e,0);if(l)return{stdout:"",stderr:l,exitCode:1};let o=i.some(a=>a.type==="print"),f=i.length===0,u=s.fs.resolvePath(s.cwd,t);try{await s.fs.stat(u)}catch{return{stdout:"",stderr:`find: ${t}: No such file or directory
5
- `,exitCode:1}}let m=[],v=I(w),C=new Map;for(let a of v){let p=s.fs.resolvePath(s.cwd,a);try{let c=await s.fs.stat(p);C.set(a,c.mtime?.getTime()??Date.now())}catch{}}async function R(a,p){if(r!==null&&p>r)return;let c;try{c=await s.fs.stat(a)}catch{return}if(!c)return;let d;a===u?d=t.split("/").pop()||t:d=a.split("/").pop()||"";let h=a===u?t:t==="."?`./${a.slice(u.length+1)}`:t+a.slice(u.length),y=null;c.isDirectory&&(y=await s.fs.readdir(a));let W=c.isFile?c.size===0:y!==null&&y.length===0,P=n===null||p>=n,k=!1,D=!1;if(P&&w!==null){let M={name:d,relativePath:h,isFile:c.isFile,isDirectory:c.isDirectory,isEmpty:W,mtime:c.mtime?.getTime()??Date.now(),size:c.size??0,mode:c.mode??420,newerRefTimes:C},E=g(w,M);P=E.matches,k=E.pruned,o?D=E.printed:D=P}else P&&(D=!0);if(D&&m.push(h),y!==null&&!k)for(let M of y){let E=a==="/"?`/${M}`:`${a}/${M}`;await R(E,p+1)}}await R(u,0);let x="",b="",T=0;if(i.length>0)for(let a of i)switch(a.type){case"print":x+=m.length>0?`${m.join(`
6
- `)}
7
- `:"";break;case"print0":x+=m.length>0?`${m.join("\0")}\0`:"";break;case"delete":{let p=[...m].sort((c,d)=>d.length-c.length);for(let c of p){let d=s.fs.resolvePath(s.cwd,c);try{await s.fs.rm(d,{recursive:!1})}catch(h){let y=h instanceof Error?h.message:String(h);b+=`find: cannot delete '${c}': ${y}
8
- `,T=1}}break}case"exec":if(!s.exec)return{stdout:"",stderr:`find: -exec not supported in this context
9
- `,exitCode:1};if(a.batchMode){let p=[];for(let h of a.command)h==="{}"?p.push(...m):p.push(h);let c=p.map(h=>`"${h}"`).join(" "),d=await s.exec(c,{cwd:s.cwd});x+=d.stdout,b+=d.stderr,d.exitCode!==0&&(T=d.exitCode)}else for(let p of m){let d=a.command.map(y=>y==="{}"?p:y).map(y=>`"${y}"`).join(" "),h=await s.exec(d,{cwd:s.cwd});x+=h.stdout,b+=h.stderr,h.exitCode!==0&&(T=h.exitCode)}break}else f&&(x=m.length>0?`${m.join(`
10
- `)}
11
- `:"");return{stdout:x,stderr:b,exitCode:T}}};export{K as findCommand};
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env node
2
- import{a as N}from"./chunk-26Q3PZQ6.js";import{a as L,b as B,c as H}from"./chunk-6QUZ7QML.js";import{a as I,b as O}from"./chunk-GTNBSMZR.js";import"./chunk-5KNEBKYN.js";function w(e,s){switch(e.type){case"name":return{matches:N(s.name,e.pattern,e.ignoreCase),pruned:!1,printed:!1};case"path":return{matches:N(s.relativePath,e.pattern,e.ignoreCase),pruned:!1,printed:!1};case"regex":try{let n=e.ignoreCase?"i":"";return{matches:new RegExp(e.pattern,n).test(s.relativePath),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:s.isFile,pruned:!1,printed:!1}:e.fileType==="d"?{matches:s.isDirectory,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"empty":return{matches:s.isEmpty,pruned:!1,printed:!1};case"mtime":{let r=(Date.now()-s.mtime)/(1e3*60*60*24),t;return e.comparison==="more"?t=r>e.days:e.comparison==="less"?t=r<e.days:t=Math.floor(r)===e.days,{matches:t,pruned:!1,printed:!1}}case"newer":{let n=s.newerRefTimes.get(e.refPath);return n===void 0?{matches:!1,pruned:!1,printed:!1}:{matches:s.mtime>n,pruned:!1,printed:!1}}case"size":{let n=e.value;switch(e.unit){case"c":n=e.value;break;case"k":n=e.value*1024;break;case"M":n=e.value*1024*1024;break;case"G":n=e.value*1024*1024*1024;break;case"b":n=e.value*512;break}let r;return e.comparison==="more"?r=s.size>n:e.comparison==="less"?r=s.size<n:e.unit==="b"?r=Math.ceil(s.size/512)===e.value:r=s.size===n,{matches:r,pruned:!1,printed:!1}}case"perm":{let n=s.mode&511,r=e.mode&511,t;return e.matchType==="exact"?t=n===r:e.matchType==="all"?t=(n&r)===r:t=(n&r)!==0,{matches:t,pruned:!1,printed:!1}}case"prune":return{matches:!0,pruned:!0,printed:!1};case"print":return{matches:!0,pruned:!1,printed:!0};case"not":{let n=w(e.expr,s);return{matches:!n.matches,pruned:n.pruned,printed:!1}}case"and":{let n=w(e.left,s);if(!n.matches)return{matches:!1,pruned:n.pruned,printed:!1};let r=w(e.right,s);return{matches:r.matches,pruned:n.pruned||r.pruned,printed:n.printed||r.printed}}case"or":{let n=w(e.left,s);if(n.matches)return n;let r=w(e.right,s);return{matches:r.matches,pruned:n.pruned||r.pruned,printed:r.printed}}}}function G(e){let s=[],n=r=>{r&&(r.type==="newer"?s.push(r.refPath):r.type==="not"?n(r.expr):(r.type==="and"||r.type==="or")&&(n(r.left),n(r.right)))};return n(e),s}function j(e,s){let n=[],r=[],t=s;for(;t<e.length;){let a=e[t];if(a==="("||a==="\\("){n.push({type:"lparen"}),t++;continue}if(a===")"||a==="\\)"){n.push({type:"rparen"}),t++;continue}if(a==="-name"&&t+1<e.length)n.push({type:"expr",expr:{type:"name",pattern:e[++t]}});else if(a==="-iname"&&t+1<e.length)n.push({type:"expr",expr:{type:"name",pattern:e[++t],ignoreCase:!0}});else if(a==="-path"&&t+1<e.length)n.push({type:"expr",expr:{type:"path",pattern:e[++t]}});else if(a==="-ipath"&&t+1<e.length)n.push({type:"expr",expr:{type:"path",pattern:e[++t],ignoreCase:!0}});else if(a==="-regex"&&t+1<e.length)n.push({type:"expr",expr:{type:"regex",pattern:e[++t]}});else if(a==="-iregex"&&t+1<e.length)n.push({type:"expr",expr:{type:"regex",pattern:e[++t],ignoreCase:!0}});else if(a==="-type"&&t+1<e.length){let i=e[++t];if(i==="f"||i==="d")n.push({type:"expr",expr:{type:"type",fileType:i}});else return{expr:null,pathIndex:t,error:`find: Unknown argument to -type: ${i}
3
- `,actions:[]}}else if(a==="-empty")n.push({type:"expr",expr:{type:"empty"}});else if(a==="-mtime"&&t+1<e.length){let i=e[++t],c="exact",o=i;i.startsWith("+")?(c="more",o=i.slice(1)):i.startsWith("-")&&(c="less",o=i.slice(1));let h=parseInt(o,10);Number.isNaN(h)||n.push({type:"expr",expr:{type:"mtime",days:h,comparison:c}})}else if(a==="-newer"&&t+1<e.length){let i=e[++t];n.push({type:"expr",expr:{type:"newer",refPath:i}})}else if(a==="-size"&&t+1<e.length){let i=e[++t],c="exact",o=i;i.startsWith("+")?(c="more",o=i.slice(1)):i.startsWith("-")&&(c="less",o=i.slice(1));let h=o.match(/^(\d+)([ckMGb])?$/);if(h){let b=parseInt(h[1],10),y=h[2]||"b";n.push({type:"expr",expr:{type:"size",value:b,unit:y,comparison:c}})}}else if(a==="-perm"&&t+1<e.length){let i=e[++t],c="exact",o=i;i.startsWith("-")?(c="all",o=i.slice(1)):i.startsWith("/")&&(c="any",o=i.slice(1));let h=parseInt(o,8);Number.isNaN(h)||n.push({type:"expr",expr:{type:"perm",mode:h,matchType:c}})}else if(a==="-prune")n.push({type:"expr",expr:{type:"prune"}});else if(a==="-not"||a==="!")n.push({type:"not"});else if(a==="-o"||a==="-or")n.push({type:"op",op:"or"});else if(a==="-a"||a==="-and")n.push({type:"op",op:"and"});else if(a==="-maxdepth"||a==="-mindepth")t++;else if(a!=="-depth")if(a==="-exec"){let i=[];for(t++;t<e.length&&e[t]!==";"&&e[t]!=="+";)i.push(e[t]),t++;if(t>=e.length)return{expr:null,pathIndex:t,error:"find: missing argument to `-exec'\n",actions:[]};let c=e[t]==="+";r.push({type:"exec",command:i,batchMode:c})}else if(a==="-print")n.push({type:"expr",expr:{type:"print"}}),r.push({type:"print"});else if(a==="-print0")r.push({type:"print0"});else if(a==="-printf"&&t+1<e.length){let i=e[++t];r.push({type:"printf",format:i})}else if(a==="-delete")r.push({type:"delete"});else{if(a.startsWith("-"))return{expr:null,pathIndex:t,error:`find: unknown predicate '${a}'
4
- `,actions:[]};if(n.length===0){t++;continue}break}t++}if(n.length===0)return{expr:null,pathIndex:t,actions:r};let m=_(n);return m.error?{expr:null,pathIndex:t,error:m.error,actions:r}:{expr:m.expr,pathIndex:t,actions:r}}function _(e){let s=0;function n(){let i=r();if(!i)return null;for(;s<e.length;){let c=e[s];if(c.type==="op"&&c.op==="or"){s++;let o=r();if(!o)return i;i={type:"or",left:i,right:o}}else break}return i}function r(){let i=t();if(!i)return null;for(;s<e.length;){let c=e[s];if(c.type==="op"&&c.op==="and"){s++;let o=t();if(!o)return i;i={type:"and",left:i,right:o}}else if(c.type==="expr"||c.type==="not"||c.type==="lparen"){let o=t();if(!o)return i;i={type:"and",left:i,right:o}}else break}return i}function t(){if(s<e.length&&e[s].type==="not"){s++;let i=t();return i?{type:"not",expr:i}:null}return m()}function m(){if(s>=e.length)return null;let i=e[s];if(i.type==="lparen"){s++;let c=n();return s<e.length&&e[s].type==="rparen"&&s++,c}return i.type==="expr"?(s++,i.expr):(i.type==="rparen",null)}return{expr:n()}}var K={name:"find",summary:"search for files in a directory hierarchy",usage:"find [path...] [expression]",options:["-name PATTERN file name matches shell pattern PATTERN","-iname PATTERN like -name but case insensitive","-path PATTERN file path matches shell pattern PATTERN","-ipath PATTERN like -path but case insensitive","-regex PATTERN file path matches regular expression PATTERN","-iregex PATTERN like -regex but case insensitive","-type TYPE file is of type: f (regular file), d (directory)","-empty file is empty or directory is empty","-mtime N file's data was modified N*24 hours ago","-newer FILE file was modified more recently than FILE","-size N[ckMGb] file uses N units of space (c=bytes, k=KB, M=MB, G=GB, b=512B blocks)","-perm MODE file's permission bits are exactly MODE (octal)","-perm -MODE all permission bits MODE are set","-perm /MODE any permission bits MODE are set","-maxdepth LEVELS descend at most LEVELS directories","-mindepth LEVELS do not apply tests at levels less than LEVELS","-depth process directory contents before directory itself","-prune do not descend into this directory","-not, ! negate the following expression","-a, -and logical AND (default)","-o, -or logical OR","-exec CMD {} ; execute CMD on each file ({} is replaced by filename)","-exec CMD {} + execute CMD with multiple files at once","-print print the full file name (default action)","-print0 print the full file name followed by a null character","-printf FORMAT print FORMAT with directives: %f %h %p %P %s %d %m %M %t","-delete delete found files/directories"," --help display this help and exit"]},U=new Set(["-name","-iname","-path","-ipath","-regex","-iregex","-type","-maxdepth","-mindepth","-mtime","-newer","-size","-perm"]),oe={name:"find",async execute(e,s){if(O(e))return I(K);let n=[],r=null,t=null,m=!1,a=!1;for(let p=0;p<e.length;p++){let l=e[p];if(l==="-maxdepth"&&p+1<e.length)a=!0,r=parseInt(e[++p],10);else if(l==="-mindepth"&&p+1<e.length)a=!0,t=parseInt(e[++p],10);else if(l==="-depth")a=!0,m=!0;else if(l==="-exec")for(a=!0,p++;p<e.length&&e[p]!==";"&&e[p]!=="+";)p++;else!l.startsWith("-")&&l!==";"&&l!=="+"&&l!=="("&&l!==")"&&l!=="\\("&&l!=="\\)"&&l!=="!"?a||n.push(l):U.has(l)?(a=!0,p++):(l.startsWith("-")||l==="("||l==="\\("||l==="!")&&(a=!0)}n.length===0&&n.push(".");let{expr:i,error:c,actions:o}=j(e,0);if(c)return{stdout:"",stderr:c,exitCode:1};let h=o.some(p=>p.type==="print"),b=o.length===0,y=[],Y=o.some(p=>p.type==="printf"),F=[],T="",D=0,V=G(i),k=new Map;for(let p of V){let l=s.fs.resolvePath(s.cwd,p);try{let g=await s.fs.stat(l);k.set(p,g.mtime?.getTime()??Date.now())}catch{}}for(let p of n){let l=s.fs.resolvePath(s.cwd,p);try{await s.fs.stat(l)}catch{T+=`find: ${p}: No such file or directory
5
- `,D=1;continue}async function g(u,d){if(r!==null&&d>r)return;let f;try{f=await s.fs.stat(u)}catch{return}if(!f)return;let E;u===l?E=p.split("/").pop()||p:E=u.split("/").pop()||"";let $=u===l?p:p==="."?`./${u.slice(l.length+1)}`:p+u.slice(l.length),M=null;f.isDirectory&&(M=await s.fs.readdir(u));let R=f.isFile?f.size===0:M!==null&&M.length===0,C=()=>{let x=t===null||d>=t,v=!1;if(x&&i!==null){let J={name:E,relativePath:$,isFile:f.isFile,isDirectory:f.isDirectory,isEmpty:R,mtime:f.mtime?.getTime()??Date.now(),size:f.size??0,mode:f.mode??420,newerRefTimes:k},W=w(i,J);x=W.matches,h?v=W.printed:v=x}else x&&(v=!0);v&&(y.push($),Y&&F.push({path:$,name:E,size:f.size??0,mtime:f.mtime?.getTime()??Date.now(),mode:f.mode??420,isDirectory:f.isDirectory,depth:d,startingPoint:p}))},A=async()=>{if(M!==null)for(let P of M){let x=u==="/"?`/${P}`:`${u}/${P}`;await g(x,d+1)}},z=!1;if(!m&&i!==null){let P={name:E,relativePath:$,isFile:f.isFile,isDirectory:f.isDirectory,isEmpty:R,mtime:f.mtime?.getTime()??Date.now(),size:f.size??0,mode:f.mode??420,newerRefTimes:k};z=w(i,P).pruned}m?(await A(),C()):(C(),z||await A())}await g(l,0)}let S="";if(o.length>0)for(let p of o)switch(p.type){case"print":S+=y.length>0?`${y.join(`
6
- `)}
7
- `:"";break;case"print0":S+=y.length>0?`${y.join("\0")}\0`:"";break;case"delete":{let l=[...y].sort((g,u)=>u.length-g.length);for(let g of l){let u=s.fs.resolvePath(s.cwd,g);try{await s.fs.rm(u,{recursive:!1})}catch(d){let f=d instanceof Error?d.message:String(d);T+=`find: cannot delete '${g}': ${f}
8
- `,D=1}}break}case"printf":for(let l of F)S+=q(p.format,l);break;case"exec":if(!s.exec)return{stdout:"",stderr:`find: -exec not supported in this context
9
- `,exitCode:1};if(p.batchMode){let l=[];for(let d of p.command)d==="{}"?l.push(...y):l.push(d);let g=l.map(d=>`"${d}"`).join(" "),u=await s.exec(g,{cwd:s.cwd});S+=u.stdout,T+=u.stderr,u.exitCode!==0&&(D=u.exitCode)}else for(let l of y){let u=p.command.map(f=>f==="{}"?l:f).map(f=>`"${f}"`).join(" "),d=await s.exec(u,{cwd:s.cwd});S+=d.stdout,T+=d.stderr,d.exitCode!==0&&(D=d.exitCode)}break}else b&&(S=y.length>0?`${y.join(`
10
- `)}
11
- `:"");return{stdout:S,stderr:T,exitCode:D}}};function q(e,s){let n=H(e),r="",t=0;for(;t<n.length;)if(n[t]==="%"&&t+1<n.length){if(t++,n[t]==="%"){r+="%",t++;continue}let[m,a,i]=B(n,t);if(t+=i,t>=n.length){r+="%";break}let c=n[t],o;switch(c){case"f":o=s.name,t++;break;case"h":{let h=s.path.lastIndexOf("/");o=h>0?s.path.slice(0,h):".",t++;break}case"p":o=s.path,t++;break;case"P":{let h=s.startingPoint;s.path===h?o="":s.path.startsWith(`${h}/`)?o=s.path.slice(h.length+1):h==="."&&s.path.startsWith("./")?o=s.path.slice(2):o=s.path,t++;break}case"s":o=String(s.size),t++;break;case"d":o=String(s.depth),t++;break;case"m":o=(s.mode&511).toString(8),t++;break;case"M":o=Q(s.mode,s.isDirectory),t++;break;case"t":{let h=new Date(s.mtime);o=X(h),t++;break}case"T":{if(t+1<n.length){let h=n[t+1],b=new Date(s.mtime);o=Z(b,h),t+=2}else o="%T",t++;break}default:r+=`%${m!==0||a!==-1?`${m}.${a}`:""}${c}`,t++;continue}r+=L(o,m,a)}else r+=n[t],t++;return r}function Q(e,s){let n=e&511,r=s?"d":"-";return r+=n&256?"r":"-",r+=n&128?"w":"-",r+=n&64?"x":"-",r+=n&32?"r":"-",r+=n&16?"w":"-",r+=n&8?"x":"-",r+=n&4?"r":"-",r+=n&2?"w":"-",r+=n&1?"x":"-",r}function X(e){let s=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],r=s[e.getDay()],t=n[e.getMonth()],m=String(e.getDate()).padStart(2," "),a=String(e.getHours()).padStart(2,"0"),i=String(e.getMinutes()).padStart(2,"0"),c=String(e.getSeconds()).padStart(2,"0"),o=e.getFullYear();return`${r} ${t} ${m} ${a}:${i}:${c} ${o}`}function Z(e,s){switch(s){case"@":return String(e.getTime()/1e3);case"Y":return String(e.getFullYear());case"m":return String(e.getMonth()+1).padStart(2,"0");case"d":return String(e.getDate()).padStart(2,"0");case"H":return String(e.getHours()).padStart(2,"0");case"M":return String(e.getMinutes()).padStart(2,"0");case"S":return String(e.getSeconds()).padStart(2,"0");case"T":return`${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}:${String(e.getSeconds()).padStart(2,"0")}`;case"F":return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`;default:return`%T${s}`}}export{oe as findCommand};
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env node
2
- import{a as k}from"./chunk-26Q3PZQ6.js";import{a as $,b as S}from"./chunk-GTNBSMZR.js";import"./chunk-5KNEBKYN.js";function g(e,s){switch(e.type){case"name":return{matches:k(s.name,e.pattern,e.ignoreCase),pruned:!1,printed:!1};case"path":return{matches:k(s.relativePath,e.pattern,e.ignoreCase),pruned:!1,printed:!1};case"regex":try{let t=e.ignoreCase?"i":"";return{matches:new RegExp(e.pattern,t).test(s.relativePath),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:s.isFile,pruned:!1,printed:!1}:e.fileType==="d"?{matches:s.isDirectory,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"empty":return{matches:s.isEmpty,pruned:!1,printed:!1};case"mtime":{let r=(Date.now()-s.mtime)/(1e3*60*60*24),n;return e.comparison==="more"?n=r>e.days:e.comparison==="less"?n=r<e.days:n=Math.floor(r)===e.days,{matches:n,pruned:!1,printed:!1}}case"newer":{let t=s.newerRefTimes.get(e.refPath);return t===void 0?{matches:!1,pruned:!1,printed:!1}:{matches:s.mtime>t,pruned:!1,printed:!1}}case"size":{let t=e.value;switch(e.unit){case"c":t=e.value;break;case"k":t=e.value*1024;break;case"M":t=e.value*1024*1024;break;case"G":t=e.value*1024*1024*1024;break;case"b":t=e.value*512;break}let r;return e.comparison==="more"?r=s.size>t:e.comparison==="less"?r=s.size<t:e.unit==="b"?r=Math.ceil(s.size/512)===e.value:r=s.size===t,{matches:r,pruned:!1,printed:!1}}case"perm":{let t=s.mode&511,r=e.mode&511,n;return e.matchType==="exact"?n=t===r:e.matchType==="all"?n=(t&r)===r:n=(t&r)!==0,{matches:n,pruned:!1,printed:!1}}case"prune":return{matches:!0,pruned:!0,printed:!1};case"print":return{matches:!0,pruned:!1,printed:!0};case"not":{let t=g(e.expr,s);return{matches:!t.matches,pruned:t.pruned,printed:!1}}case"and":{let t=g(e.left,s);if(!t.matches)return{matches:!1,pruned:t.pruned,printed:!1};let r=g(e.right,s);return{matches:r.matches,pruned:t.pruned||r.pruned,printed:t.printed||r.printed}}case"or":{let t=g(e.left,s);if(t.matches)return t;let r=g(e.right,s);return{matches:r.matches,pruned:t.pruned||r.pruned,printed:r.printed}}}}function L(e){let s=[],t=r=>{r&&(r.type==="newer"?s.push(r.refPath):r.type==="not"?t(r.expr):(r.type==="and"||r.type==="or")&&(t(r.left),t(r.right)))};return t(e),s}function O(e,s){let t=[],r=[],n=s;for(;n<e.length;){let l=e[n];if(l==="("||l==="\\("){t.push({type:"lparen"}),n++;continue}if(l===")"||l==="\\)"){t.push({type:"rparen"}),n++;continue}if(l==="-name"&&n+1<e.length)t.push({type:"expr",expr:{type:"name",pattern:e[++n]}});else if(l==="-iname"&&n+1<e.length)t.push({type:"expr",expr:{type:"name",pattern:e[++n],ignoreCase:!0}});else if(l==="-path"&&n+1<e.length)t.push({type:"expr",expr:{type:"path",pattern:e[++n]}});else if(l==="-ipath"&&n+1<e.length)t.push({type:"expr",expr:{type:"path",pattern:e[++n],ignoreCase:!0}});else if(l==="-regex"&&n+1<e.length)t.push({type:"expr",expr:{type:"regex",pattern:e[++n]}});else if(l==="-iregex"&&n+1<e.length)t.push({type:"expr",expr:{type:"regex",pattern:e[++n],ignoreCase:!0}});else if(l==="-type"&&n+1<e.length){let i=e[++n];if(i==="f"||i==="d")t.push({type:"expr",expr:{type:"type",fileType:i}});else return{expr:null,pathIndex:n,error:`find: Unknown argument to -type: ${i}
3
- `,actions:[]}}else if(l==="-empty")t.push({type:"expr",expr:{type:"empty"}});else if(l==="-mtime"&&n+1<e.length){let i=e[++n],o="exact",f=i;i.startsWith("+")?(o="more",f=i.slice(1)):i.startsWith("-")&&(o="less",f=i.slice(1));let y=parseInt(f,10);Number.isNaN(y)||t.push({type:"expr",expr:{type:"mtime",days:y,comparison:o}})}else if(l==="-newer"&&n+1<e.length){let i=e[++n];t.push({type:"expr",expr:{type:"newer",refPath:i}})}else if(l==="-size"&&n+1<e.length){let i=e[++n],o="exact",f=i;i.startsWith("+")?(o="more",f=i.slice(1)):i.startsWith("-")&&(o="less",f=i.slice(1));let y=f.match(/^(\d+)([ckMGb])?$/);if(y){let N=parseInt(y[1],10),d=y[2]||"b";t.push({type:"expr",expr:{type:"size",value:N,unit:d,comparison:o}})}}else if(l==="-perm"&&n+1<e.length){let i=e[++n],o="exact",f=i;i.startsWith("-")?(o="all",f=i.slice(1)):i.startsWith("/")&&(o="any",f=i.slice(1));let y=parseInt(f,8);Number.isNaN(y)||t.push({type:"expr",expr:{type:"perm",mode:y,matchType:o}})}else if(l==="-prune")t.push({type:"expr",expr:{type:"prune"}});else if(l==="-not"||l==="!")t.push({type:"not"});else if(l==="-o"||l==="-or")t.push({type:"op",op:"or"});else if(l==="-a"||l==="-and")t.push({type:"op",op:"and"});else if(l==="-maxdepth"||l==="-mindepth")n++;else if(l!=="-depth")if(l==="-exec"){let i=[];for(n++;n<e.length&&e[n]!==";"&&e[n]!=="+";)i.push(e[n]),n++;if(n>=e.length)return{expr:null,pathIndex:n,error:"find: missing argument to `-exec'\n",actions:[]};let o=e[n]==="+";r.push({type:"exec",command:i,batchMode:o})}else if(l==="-print")t.push({type:"expr",expr:{type:"print"}}),r.push({type:"print"});else if(l==="-print0")r.push({type:"print0"});else if(l==="-delete")r.push({type:"delete"});else{if(l.startsWith("-"))return{expr:null,pathIndex:n,error:`find: unknown predicate '${l}'
4
- `,actions:[]};if(t.length===0){n++;continue}break}n++}if(t.length===0)return{expr:null,pathIndex:n,actions:r};let w=j(t);return w.error?{expr:null,pathIndex:n,error:w.error,actions:r}:{expr:w.expr,pathIndex:n,actions:r}}function j(e){let s=0;function t(){let i=r();if(!i)return null;for(;s<e.length;){let o=e[s];if(o.type==="op"&&o.op==="or"){s++;let f=r();if(!f)return i;i={type:"or",left:i,right:f}}else break}return i}function r(){let i=n();if(!i)return null;for(;s<e.length;){let o=e[s];if(o.type==="op"&&o.op==="and"){s++;let f=n();if(!f)return i;i={type:"and",left:i,right:f}}else if(o.type==="expr"||o.type==="not"||o.type==="lparen"){let f=n();if(!f)return i;i={type:"and",left:i,right:f}}else break}return i}function n(){if(s<e.length&&e[s].type==="not"){s++;let i=n();return i?{type:"not",expr:i}:null}return w()}function w(){if(s>=e.length)return null;let i=e[s];if(i.type==="lparen"){s++;let o=t();return s<e.length&&e[s].type==="rparen"&&s++,o}return i.type==="expr"?(s++,i.expr):(i.type==="rparen",null)}return{expr:t()}}var H={name:"find",summary:"search for files in a directory hierarchy",usage:"find [path...] [expression]",options:["-name PATTERN file name matches shell pattern PATTERN","-iname PATTERN like -name but case insensitive","-path PATTERN file path matches shell pattern PATTERN","-ipath PATTERN like -path but case insensitive","-regex PATTERN file path matches regular expression PATTERN","-iregex PATTERN like -regex but case insensitive","-type TYPE file is of type: f (regular file), d (directory)","-empty file is empty or directory is empty","-mtime N file's data was modified N*24 hours ago","-newer FILE file was modified more recently than FILE","-size N[ckMGb] file uses N units of space (c=bytes, k=KB, M=MB, G=GB, b=512B blocks)","-perm MODE file's permission bits are exactly MODE (octal)","-perm -MODE all permission bits MODE are set","-perm /MODE any permission bits MODE are set","-maxdepth LEVELS descend at most LEVELS directories","-mindepth LEVELS do not apply tests at levels less than LEVELS","-depth process directory contents before directory itself","-prune do not descend into this directory","-not, ! negate the following expression","-a, -and logical AND (default)","-o, -or logical OR","-exec CMD {} ; execute CMD on each file ({} is replaced by filename)","-exec CMD {} + execute CMD with multiple files at once","-print print the full file name (default action)","-print0 print the full file name followed by a null character","-delete delete found files/directories"," --help display this help and exit"]},V=new Set(["-name","-iname","-path","-ipath","-regex","-iregex","-type","-maxdepth","-mindepth","-mtime","-newer","-size","-perm"]),Q={name:"find",async execute(e,s){if(S(e))return $(H);let t=[],r=null,n=null,w=!1,l=!1;for(let p=0;p<e.length;p++){let a=e[p];if(a==="-maxdepth"&&p+1<e.length)l=!0,r=parseInt(e[++p],10);else if(a==="-mindepth"&&p+1<e.length)l=!0,n=parseInt(e[++p],10);else if(a==="-depth")l=!0,w=!0;else if(a==="-exec")for(l=!0,p++;p<e.length&&e[p]!==";"&&e[p]!=="+";)p++;else!a.startsWith("-")&&a!==";"&&a!=="+"&&a!=="("&&a!==")"&&a!=="\\("&&a!=="\\)"&&a!=="!"?l||t.push(a):V.has(a)?(l=!0,p++):(a.startsWith("-")||a==="("||a==="\\("||a==="!")&&(l=!0)}t.length===0&&t.push(".");let{expr:i,error:o,actions:f}=O(e,0);if(o)return{stdout:"",stderr:o,exitCode:1};let y=f.some(p=>p.type==="print"),N=f.length===0,d=[],b="",T=0,B=L(i),C=new Map;for(let p of B){let a=s.fs.resolvePath(s.cwd,p);try{let m=await s.fs.stat(a);C.set(p,m.mtime?.getTime()??Date.now())}catch{}}for(let p of t){let a=s.fs.resolvePath(s.cwd,p);try{await s.fs.stat(a)}catch{b+=`find: ${p}: No such file or directory
5
- `,T=1;continue}async function m(u,h){if(r!==null&&h>r)return;let c;try{c=await s.fs.stat(u)}catch{return}if(!c)return;let v;u===a?v=p.split("/").pop()||p:v=u.split("/").pop()||"";let R=u===a?p:p==="."?`./${u.slice(a.length+1)}`:p+u.slice(a.length),D=null;c.isDirectory&&(D=await s.fs.readdir(u));let z=c.isFile?c.size===0:D!==null&&D.length===0,A=()=>{let x=n===null||h>=n,M=!1;if(x&&i!==null){let G={name:v,relativePath:R,isFile:c.isFile,isDirectory:c.isDirectory,isEmpty:z,mtime:c.mtime?.getTime()??Date.now(),size:c.size??0,mode:c.mode??420,newerRefTimes:C},W=g(i,G);x=W.matches,y?M=W.printed:M=x}else x&&(M=!0);M&&d.push(R)},F=async()=>{if(D!==null)for(let P of D){let x=u==="/"?`/${P}`:`${u}/${P}`;await m(x,h+1)}},I=!1;if(!w&&i!==null){let P={name:v,relativePath:R,isFile:c.isFile,isDirectory:c.isDirectory,isEmpty:z,mtime:c.mtime?.getTime()??Date.now(),size:c.size??0,mode:c.mode??420,newerRefTimes:C};I=g(i,P).pruned}w?(await F(),A()):(A(),I||await F())}await m(a,0)}let E="";if(f.length>0)for(let p of f)switch(p.type){case"print":E+=d.length>0?`${d.join(`
6
- `)}
7
- `:"";break;case"print0":E+=d.length>0?`${d.join("\0")}\0`:"";break;case"delete":{let a=[...d].sort((m,u)=>u.length-m.length);for(let m of a){let u=s.fs.resolvePath(s.cwd,m);try{await s.fs.rm(u,{recursive:!1})}catch(h){let c=h instanceof Error?h.message:String(h);b+=`find: cannot delete '${m}': ${c}
8
- `,T=1}}break}case"exec":if(!s.exec)return{stdout:"",stderr:`find: -exec not supported in this context
9
- `,exitCode:1};if(p.batchMode){let a=[];for(let h of p.command)h==="{}"?a.push(...d):a.push(h);let m=a.map(h=>`"${h}"`).join(" "),u=await s.exec(m,{cwd:s.cwd});E+=u.stdout,b+=u.stderr,u.exitCode!==0&&(T=u.exitCode)}else for(let a of d){let u=p.command.map(c=>c==="{}"?a:c).map(c=>`"${c}"`).join(" "),h=await s.exec(u,{cwd:s.cwd});E+=h.stdout,b+=h.stderr,h.exitCode!==0&&(T=h.exitCode)}break}else N&&(E=d.length>0?`${d.join(`
10
- `)}
11
- `:"");return{stdout:E,stderr:b,exitCode:T}}};export{Q as findCommand};
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env node
2
- import{a as N}from"./chunk-26Q3PZQ6.js";import{a as A,b as z}from"./chunk-GTNBSMZR.js";import"./chunk-5KNEBKYN.js";function g(e,s){switch(e.type){case"name":return{matches:N(s.name,e.pattern,e.ignoreCase),pruned:!1,printed:!1};case"path":return{matches:N(s.relativePath,e.pattern,e.ignoreCase),pruned:!1,printed:!1};case"regex":try{let t=e.ignoreCase?"i":"";return{matches:new RegExp(e.pattern,t).test(s.relativePath),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:s.isFile,pruned:!1,printed:!1}:e.fileType==="d"?{matches:s.isDirectory,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"empty":return{matches:s.isEmpty,pruned:!1,printed:!1};case"mtime":{let r=(Date.now()-s.mtime)/(1e3*60*60*24),n;return e.comparison==="more"?n=r>e.days:e.comparison==="less"?n=r<e.days:n=Math.floor(r)===e.days,{matches:n,pruned:!1,printed:!1}}case"newer":{let t=s.newerRefTimes.get(e.refPath);return t===void 0?{matches:!1,pruned:!1,printed:!1}:{matches:s.mtime>t,pruned:!1,printed:!1}}case"size":{let t=e.value;switch(e.unit){case"c":t=e.value;break;case"k":t=e.value*1024;break;case"M":t=e.value*1024*1024;break;case"G":t=e.value*1024*1024*1024;break;case"b":t=e.value*512;break}let r;return e.comparison==="more"?r=s.size>t:e.comparison==="less"?r=s.size<t:e.unit==="b"?r=Math.ceil(s.size/512)===e.value:r=s.size===t,{matches:r,pruned:!1,printed:!1}}case"perm":{let t=s.mode&511,r=e.mode&511,n;return e.matchType==="exact"?n=t===r:e.matchType==="all"?n=(t&r)===r:n=(t&r)!==0,{matches:n,pruned:!1,printed:!1}}case"prune":return{matches:!0,pruned:!0,printed:!1};case"print":return{matches:!0,pruned:!1,printed:!0};case"not":{let t=g(e.expr,s);return{matches:!t.matches,pruned:t.pruned,printed:!1}}case"and":{let t=g(e.left,s);if(!t.matches)return{matches:!1,pruned:t.pruned,printed:!1};let r=g(e.right,s);return{matches:r.matches,pruned:t.pruned||r.pruned,printed:t.printed||r.printed}}case"or":{let t=g(e.left,s);if(t.matches)return t;let r=g(e.right,s);return{matches:r.matches,pruned:t.pruned||r.pruned,printed:r.printed}}}}function I(e){let s=[],t=r=>{r&&(r.type==="newer"?s.push(r.refPath):r.type==="not"?t(r.expr):(r.type==="and"||r.type==="or")&&(t(r.left),t(r.right)))};return t(e),s}function $(e,s){let t=[],r=[],n=s;for(;n<e.length;){let l=e[n];if(l==="("||l==="\\("){t.push({type:"lparen"}),n++;continue}if(l===")"||l==="\\)"){t.push({type:"rparen"}),n++;continue}if(l==="-name"&&n+1<e.length)t.push({type:"expr",expr:{type:"name",pattern:e[++n]}});else if(l==="-iname"&&n+1<e.length)t.push({type:"expr",expr:{type:"name",pattern:e[++n],ignoreCase:!0}});else if(l==="-path"&&n+1<e.length)t.push({type:"expr",expr:{type:"path",pattern:e[++n]}});else if(l==="-ipath"&&n+1<e.length)t.push({type:"expr",expr:{type:"path",pattern:e[++n],ignoreCase:!0}});else if(l==="-regex"&&n+1<e.length)t.push({type:"expr",expr:{type:"regex",pattern:e[++n]}});else if(l==="-iregex"&&n+1<e.length)t.push({type:"expr",expr:{type:"regex",pattern:e[++n],ignoreCase:!0}});else if(l==="-type"&&n+1<e.length){let i=e[++n];if(i==="f"||i==="d")t.push({type:"expr",expr:{type:"type",fileType:i}});else return{expr:null,pathIndex:n,error:`find: Unknown argument to -type: ${i}
3
- `,actions:[]}}else if(l==="-empty")t.push({type:"expr",expr:{type:"empty"}});else if(l==="-mtime"&&n+1<e.length){let i=e[++n],p="exact",f=i;i.startsWith("+")?(p="more",f=i.slice(1)):i.startsWith("-")&&(p="less",f=i.slice(1));let u=parseInt(f,10);Number.isNaN(u)||t.push({type:"expr",expr:{type:"mtime",days:u,comparison:p}})}else if(l==="-newer"&&n+1<e.length){let i=e[++n];t.push({type:"expr",expr:{type:"newer",refPath:i}})}else if(l==="-size"&&n+1<e.length){let i=e[++n],p="exact",f=i;i.startsWith("+")?(p="more",f=i.slice(1)):i.startsWith("-")&&(p="less",f=i.slice(1));let u=f.match(/^(\d+)([ckMGb])?$/);if(u){let m=parseInt(u[1],10),v=u[2]||"b";t.push({type:"expr",expr:{type:"size",value:m,unit:v,comparison:p}})}}else if(l==="-perm"&&n+1<e.length){let i=e[++n],p="exact",f=i;i.startsWith("-")?(p="all",f=i.slice(1)):i.startsWith("/")&&(p="any",f=i.slice(1));let u=parseInt(f,8);Number.isNaN(u)||t.push({type:"expr",expr:{type:"perm",mode:u,matchType:p}})}else if(l==="-prune")t.push({type:"expr",expr:{type:"prune"}});else if(l==="-not"||l==="!")t.push({type:"not"});else if(l==="-o"||l==="-or")t.push({type:"op",op:"or"});else if(l==="-a"||l==="-and")t.push({type:"op",op:"and"});else if(l==="-maxdepth"||l==="-mindepth")n++;else if(l==="-exec"){let i=[];for(n++;n<e.length&&e[n]!==";"&&e[n]!=="+";)i.push(e[n]),n++;if(n>=e.length)return{expr:null,pathIndex:n,error:"find: missing argument to `-exec'\n",actions:[]};let p=e[n]==="+";r.push({type:"exec",command:i,batchMode:p})}else if(l==="-print")t.push({type:"expr",expr:{type:"print"}}),r.push({type:"print"});else if(l==="-print0")r.push({type:"print0"});else if(l==="-delete")r.push({type:"delete"});else{if(l.startsWith("-"))return{expr:null,pathIndex:n,error:`find: unknown predicate '${l}'
4
- `,actions:[]};if(t.length===0){n++;continue}break}n++}if(t.length===0)return{expr:null,pathIndex:n,actions:r};let w=S(t);return w.error?{expr:null,pathIndex:n,error:w.error,actions:r}:{expr:w.expr,pathIndex:n,actions:r}}function S(e){let s=0;function t(){let i=r();if(!i)return null;for(;s<e.length;){let p=e[s];if(p.type==="op"&&p.op==="or"){s++;let f=r();if(!f)return i;i={type:"or",left:i,right:f}}else break}return i}function r(){let i=n();if(!i)return null;for(;s<e.length;){let p=e[s];if(p.type==="op"&&p.op==="and"){s++;let f=n();if(!f)return i;i={type:"and",left:i,right:f}}else if(p.type==="expr"||p.type==="not"||p.type==="lparen"){let f=n();if(!f)return i;i={type:"and",left:i,right:f}}else break}return i}function n(){if(s<e.length&&e[s].type==="not"){s++;let i=n();return i?{type:"not",expr:i}:null}return w()}function w(){if(s>=e.length)return null;let i=e[s];if(i.type==="lparen"){s++;let p=t();return s<e.length&&e[s].type==="rparen"&&s++,p}return i.type==="expr"?(s++,i.expr):(i.type==="rparen",null)}return{expr:t()}}var F={name:"find",summary:"search for files in a directory hierarchy",usage:"find [path...] [expression]",options:["-name PATTERN file name matches shell pattern PATTERN","-iname PATTERN like -name but case insensitive","-path PATTERN file path matches shell pattern PATTERN","-ipath PATTERN like -path but case insensitive","-regex PATTERN file path matches regular expression PATTERN","-iregex PATTERN like -regex but case insensitive","-type TYPE file is of type: f (regular file), d (directory)","-empty file is empty or directory is empty","-mtime N file's data was modified N*24 hours ago","-newer FILE file was modified more recently than FILE","-size N[ckMGb] file uses N units of space (c=bytes, k=KB, M=MB, G=GB, b=512B blocks)","-perm MODE file's permission bits are exactly MODE (octal)","-perm -MODE all permission bits MODE are set","-perm /MODE any permission bits MODE are set","-maxdepth LEVELS descend at most LEVELS directories","-mindepth LEVELS do not apply tests at levels less than LEVELS","-prune do not descend into this directory","-not, ! negate the following expression","-a, -and logical AND (default)","-o, -or logical OR","-exec CMD {} ; execute CMD on each file ({} is replaced by filename)","-exec CMD {} + execute CMD with multiple files at once","-print print the full file name (default action)","-print0 print the full file name followed by a null character","-delete delete found files/directories"," --help display this help and exit"]},L=new Set(["-name","-iname","-path","-ipath","-regex","-iregex","-type","-maxdepth","-mindepth","-mtime","-newer","-size","-perm"]),K={name:"find",async execute(e,s){if(z(e))return A(F);let t=".",r=null,n=null;for(let a=0;a<e.length;a++){let o=e[a];if(o==="-maxdepth"&&a+1<e.length)r=parseInt(e[++a],10);else if(o==="-mindepth"&&a+1<e.length)n=parseInt(e[++a],10);else if(o==="-exec")for(a++;a<e.length&&e[a]!==";"&&e[a]!=="+";)a++;else!o.startsWith("-")&&o!==";"&&o!=="+"&&o!=="("&&o!==")"&&o!=="\\("&&o!=="\\)"?t=o:L.has(o)&&a++}let{expr:w,error:l,actions:i}=$(e,0);if(l)return{stdout:"",stderr:l,exitCode:1};let p=i.some(a=>a.type==="print"),f=i.length===0,u=s.fs.resolvePath(s.cwd,t);try{await s.fs.stat(u)}catch{return{stdout:"",stderr:`find: ${t}: No such file or directory
5
- `,exitCode:1}}let m=[],v=I(w),C=new Map;for(let a of v){let o=s.fs.resolvePath(s.cwd,a);try{let c=await s.fs.stat(o);C.set(a,c.mtime?.getTime()??Date.now())}catch{}}async function R(a,o){if(r!==null&&o>r)return;let c;try{c=await s.fs.stat(a)}catch{return}if(!c)return;let d;a===u?d=t.split("/").pop()||t:d=a.split("/").pop()||"";let h=a===u?t:t==="."?`./${a.slice(u.length+1)}`:t+a.slice(u.length),y=null;c.isDirectory&&(y=await s.fs.readdir(a));let W=c.isFile?c.size===0:y!==null&&y.length===0,P=n===null||o>=n,k=!1,D=!1;if(P&&w!==null){let M={name:d,relativePath:h,isFile:c.isFile,isDirectory:c.isDirectory,isEmpty:W,mtime:c.mtime?.getTime()??Date.now(),size:c.size??0,mode:c.mode??420,newerRefTimes:C},E=g(w,M);P=E.matches,k=E.pruned,p?D=E.printed:D=P}else P&&(D=!0);if(D&&m.push(h),y!==null&&!k)for(let M of y){let E=a==="/"?`/${M}`:`${a}/${M}`;await R(E,o+1)}}await R(u,0);let x="",b="",T=0;if(i.length>0)for(let a of i)switch(a.type){case"print":x+=m.length>0?`${m.join(`
6
- `)}
7
- `:"";break;case"print0":x+=m.length>0?`${m.join("\0")}\0`:"";break;case"delete":{let o=[...m].sort((c,d)=>d.length-c.length);for(let c of o){let d=s.fs.resolvePath(s.cwd,c);try{await s.fs.rm(d,{recursive:!1})}catch(h){let y=h instanceof Error?h.message:String(h);b+=`find: cannot delete '${c}': ${y}
8
- `,T=1}}break}case"exec":if(!s.exec)return{stdout:"",stderr:`find: -exec not supported in this context
9
- `,exitCode:1};if(a.batchMode){let o=[];for(let h of a.command)h==="{}"?o.push(...m):o.push(h);let c=o.map(h=>`"${h}"`).join(" "),d=await s.exec(c,{cwd:s.cwd});x+=d.stdout,b+=d.stderr,d.exitCode!==0&&(T=d.exitCode)}else for(let o of m){let d=a.command.map(y=>y==="{}"?o:y).map(y=>`"${y}"`).join(" "),h=await s.exec(d,{cwd:s.cwd});x+=h.stdout,b+=h.stderr,h.exitCode!==0&&(T=h.exitCode)}break}else f&&(x=m.length>0?`${m.join(`
10
- `)}
11
- `:"");return{stdout:x,stderr:b,exitCode:T}}};export{K as findCommand};
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env node
2
- import{a as N}from"./chunk-26Q3PZQ6.js";import{a as A,b as z}from"./chunk-GTNBSMZR.js";import"./chunk-5KNEBKYN.js";function x(e,s){switch(e.type){case"name":return{matches:N(s.name,e.pattern,e.ignoreCase),pruned:!1,printed:!1};case"path":return{matches:N(s.relativePath,e.pattern,e.ignoreCase),pruned:!1,printed:!1};case"regex":try{let t=e.ignoreCase?"i":"";return{matches:new RegExp(e.pattern,t).test(s.relativePath),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:s.isFile,pruned:!1,printed:!1}:e.fileType==="d"?{matches:s.isDirectory,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"empty":return{matches:s.isEmpty,pruned:!1,printed:!1};case"mtime":{let r=(Date.now()-s.mtime)/(1e3*60*60*24),n;return e.comparison==="more"?n=r>e.days:e.comparison==="less"?n=r<e.days:n=Math.floor(r)===e.days,{matches:n,pruned:!1,printed:!1}}case"newer":{let t=s.newerRefTimes.get(e.refPath);return t===void 0?{matches:!1,pruned:!1,printed:!1}:{matches:s.mtime>t,pruned:!1,printed:!1}}case"size":{let t=e.value;switch(e.unit){case"c":t=e.value;break;case"k":t=e.value*1024;break;case"M":t=e.value*1024*1024;break;case"G":t=e.value*1024*1024*1024;break;case"b":t=e.value*512;break}let r;return e.comparison==="more"?r=s.size>t:e.comparison==="less"?r=s.size<t:e.unit==="b"?r=Math.ceil(s.size/512)===e.value:r=s.size===t,{matches:r,pruned:!1,printed:!1}}case"perm":{let t=s.mode&511,r=e.mode&511,n;return e.matchType==="exact"?n=t===r:e.matchType==="all"?n=(t&r)===r:n=(t&r)!==0,{matches:n,pruned:!1,printed:!1}}case"prune":return{matches:!0,pruned:!0,printed:!1};case"print":return{matches:!0,pruned:!1,printed:!0};case"not":{let t=x(e.expr,s);return{matches:!t.matches,pruned:t.pruned,printed:!1}}case"and":{let t=x(e.left,s);if(!t.matches)return{matches:!1,pruned:t.pruned,printed:!1};let r=x(e.right,s);return{matches:r.matches,pruned:t.pruned||r.pruned,printed:t.printed||r.printed}}case"or":{let t=x(e.left,s);if(t.matches)return t;let r=x(e.right,s);return{matches:r.matches,pruned:t.pruned||r.pruned,printed:r.printed}}}}function I(e){let s=[],t=r=>{r&&(r.type==="newer"?s.push(r.refPath):r.type==="not"?t(r.expr):(r.type==="and"||r.type==="or")&&(t(r.left),t(r.right)))};return t(e),s}function $(e,s){let t=[],r=[],n=s;for(;n<e.length;){let l=e[n];if(l==="("||l==="\\("){t.push({type:"lparen"}),n++;continue}if(l===")"||l==="\\)"){t.push({type:"rparen"}),n++;continue}if(l==="-name"&&n+1<e.length)t.push({type:"expr",expr:{type:"name",pattern:e[++n]}});else if(l==="-iname"&&n+1<e.length)t.push({type:"expr",expr:{type:"name",pattern:e[++n],ignoreCase:!0}});else if(l==="-path"&&n+1<e.length)t.push({type:"expr",expr:{type:"path",pattern:e[++n]}});else if(l==="-ipath"&&n+1<e.length)t.push({type:"expr",expr:{type:"path",pattern:e[++n],ignoreCase:!0}});else if(l==="-regex"&&n+1<e.length)t.push({type:"expr",expr:{type:"regex",pattern:e[++n]}});else if(l==="-iregex"&&n+1<e.length)t.push({type:"expr",expr:{type:"regex",pattern:e[++n],ignoreCase:!0}});else if(l==="-type"&&n+1<e.length){let i=e[++n];if(i==="f"||i==="d")t.push({type:"expr",expr:{type:"type",fileType:i}});else return{expr:null,pathIndex:n,error:`find: Unknown argument to -type: ${i}
3
- `,actions:[]}}else if(l==="-empty")t.push({type:"expr",expr:{type:"empty"}});else if(l==="-mtime"&&n+1<e.length){let i=e[++n],p="exact",f=i;i.startsWith("+")?(p="more",f=i.slice(1)):i.startsWith("-")&&(p="less",f=i.slice(1));let u=parseInt(f,10);Number.isNaN(u)||t.push({type:"expr",expr:{type:"mtime",days:u,comparison:p}})}else if(l==="-newer"&&n+1<e.length){let i=e[++n];t.push({type:"expr",expr:{type:"newer",refPath:i}})}else if(l==="-size"&&n+1<e.length){let i=e[++n],p="exact",f=i;i.startsWith("+")?(p="more",f=i.slice(1)):i.startsWith("-")&&(p="less",f=i.slice(1));let u=f.match(/^(\d+)([ckMGb])?$/);if(u){let m=parseInt(u[1],10),v=u[2]||"b";t.push({type:"expr",expr:{type:"size",value:m,unit:v,comparison:p}})}}else if(l==="-perm"&&n+1<e.length){let i=e[++n],p="exact",f=i;i.startsWith("-")?(p="all",f=i.slice(1)):i.startsWith("/")&&(p="any",f=i.slice(1));let u=parseInt(f,8);Number.isNaN(u)||t.push({type:"expr",expr:{type:"perm",mode:u,matchType:p}})}else if(l==="-prune")t.push({type:"expr",expr:{type:"prune"}});else if(l==="-not"||l==="!")t.push({type:"not"});else if(l==="-o"||l==="-or")t.push({type:"op",op:"or"});else if(l==="-a"||l==="-and")t.push({type:"op",op:"and"});else if(l==="-maxdepth"||l==="-mindepth")n++;else if(l==="-exec"){let i=[];for(n++;n<e.length&&e[n]!==";"&&e[n]!=="+";)i.push(e[n]),n++;if(n>=e.length)return{expr:null,pathIndex:n,error:"find: missing argument to `-exec'\n",actions:[]};let p=e[n]==="+";r.push({type:"exec",command:i,batchMode:p})}else if(l==="-print")t.push({type:"expr",expr:{type:"print"}}),r.push({type:"print"});else if(l==="-print0")r.push({type:"print0"});else if(l==="-delete")r.push({type:"delete"});else{if(l.startsWith("-"))return{expr:null,pathIndex:n,error:`find: unknown predicate '${l}'
4
- `,actions:[]};if(t.length===0){n++;continue}break}n++}if(t.length===0)return{expr:null,pathIndex:n,actions:r};let g=S(t);return g.error?{expr:null,pathIndex:n,error:g.error,actions:r}:{expr:g.expr,pathIndex:n,actions:r}}function S(e){let s=0;function t(){let i=r();if(!i)return null;for(;s<e.length;){let p=e[s];if(p.type==="op"&&p.op==="or"){s++;let f=r();if(!f)return i;i={type:"or",left:i,right:f}}else break}return i}function r(){let i=n();if(!i)return null;for(;s<e.length;){let p=e[s];if(p.type==="op"&&p.op==="and"){s++;let f=n();if(!f)return i;i={type:"and",left:i,right:f}}else if(p.type==="expr"||p.type==="not"||p.type==="lparen"){let f=n();if(!f)return i;i={type:"and",left:i,right:f}}else break}return i}function n(){if(s<e.length&&e[s].type==="not"){s++;let i=n();return i?{type:"not",expr:i}:null}return g()}function g(){if(s>=e.length)return null;let i=e[s];if(i.type==="lparen"){s++;let p=t();return s<e.length&&e[s].type==="rparen"&&s++,p}return i.type==="expr"?(s++,i.expr):(i.type==="rparen",null)}return{expr:t()}}var F={name:"find",summary:"search for files in a directory hierarchy",usage:"find [path...] [expression]",options:["-name PATTERN file name matches shell pattern PATTERN","-iname PATTERN like -name but case insensitive","-path PATTERN file path matches shell pattern PATTERN","-ipath PATTERN like -path but case insensitive","-regex PATTERN file path matches regular expression PATTERN","-iregex PATTERN like -regex but case insensitive","-type TYPE file is of type: f (regular file), d (directory)","-empty file is empty or directory is empty","-mtime N file's data was modified N*24 hours ago","-newer FILE file was modified more recently than FILE","-size N[ckMGb] file uses N units of space (c=bytes, k=KB, M=MB, G=GB, b=512B blocks)","-perm MODE file's permission bits are exactly MODE (octal)","-perm -MODE all permission bits MODE are set","-perm /MODE any permission bits MODE are set","-maxdepth LEVELS descend at most LEVELS directories","-mindepth LEVELS do not apply tests at levels less than LEVELS","-prune do not descend into this directory","-not, ! negate the following expression","-a, -and logical AND (default)","-o, -or logical OR","-exec CMD {} ; execute CMD on each file ({} is replaced by filename)","-exec CMD {} + execute CMD with multiple files at once","-print print the full file name (default action)","-print0 print the full file name followed by a null character","-delete delete found files/directories"," --help display this help and exit"]},L=new Set(["-name","-iname","-path","-ipath","-regex","-iregex","-type","-maxdepth","-mindepth","-mtime","-newer","-size","-perm"]),K={name:"find",async execute(e,s){if(z(e))return A(F);let t=".",r=null,n=null;for(let a=0;a<e.length;a++){let o=e[a];if(o==="-maxdepth"&&a+1<e.length)r=parseInt(e[++a],10);else if(o==="-mindepth"&&a+1<e.length)n=parseInt(e[++a],10);else if(o==="-exec")for(a++;a<e.length&&e[a]!==";"&&e[a]!=="+";)a++;else!o.startsWith("-")&&o!==";"&&o!=="+"&&o!=="("&&o!==")"&&o!=="\\("&&o!=="\\)"?t=o:L.has(o)&&a++}let{expr:g,error:l,actions:i}=$(e,0);if(l)return{stdout:"",stderr:l,exitCode:1};let p=i.some(a=>a.type==="print"),f=i.length===0,u=s.fs.resolvePath(s.cwd,t);try{await s.fs.stat(u)}catch{return{stdout:"",stderr:`find: ${t}: No such file or directory
5
- `,exitCode:1}}let m=[],v=I(g),C=new Map;for(let a of v){let o=s.fs.resolvePath(s.cwd,a);try{let c=await s.fs.stat(o);C.set(a,c.mtime?.getTime()??Date.now())}catch{}}async function R(a,o){if(r!==null&&o>r)return;let c;try{c=await s.fs.stat(a)}catch{return}if(!c)return;let d;a===u?d=t.split("/").pop()||t:d=a.split("/").pop()||"";let h=a===u?t:t==="."?`./${a.slice(u.length+1)}`:t+a.slice(u.length),y=null;c.isDirectory&&(y=await s.fs.readdir(a));let W=c.isFile?c.size===0:y!==null&&y.length===0,P=n===null||o>=n,k=!1,D=!1;if(P&&g!==null){let M={name:d,relativePath:h,isFile:c.isFile,isDirectory:c.isDirectory,isEmpty:W,mtime:c.mtime?.getTime()??Date.now(),size:c.size??0,mode:c.mode??420,newerRefTimes:C},E=x(g,M);P=E.matches,k=E.pruned,p?D=E.printed:D=P}else P&&(D=!0);if(D&&m.push(h),y!==null&&!k)for(let M of y){let E=a==="/"?`/${M}`:`${a}/${M}`;await R(E,o+1)}}await R(u,0);let w="",b="",T=0;if(i.length>0)for(let a of i)switch(a.type){case"print":w+=m.length>0?`${m.join(`
6
- `)}
7
- `:"";break;case"print0":w+=m.length>0?`${m.join("\0")}\0`:"";break;case"delete":{let o=[...m].sort((c,d)=>d.length-c.length);for(let c of o){let d=s.fs.resolvePath(s.cwd,c);try{await s.fs.rm(d,{recursive:!1})}catch(h){let y=h instanceof Error?h.message:String(h);b+=`find: cannot delete '${c}': ${y}
8
- `,T=1}}break}case"exec":if(!s.exec)return{stdout:"",stderr:`find: -exec not supported in this context
9
- `,exitCode:1};if(a.batchMode){let o=[];for(let h of a.command)h==="{}"?o.push(...m):o.push(h);let c=o.map(h=>`"${h}"`).join(" "),d=await s.exec(c);w+=d.stdout,b+=d.stderr,d.exitCode!==0&&(T=d.exitCode)}else for(let o of m){let d=a.command.map(y=>y==="{}"?o:y).map(y=>`"${y}"`).join(" "),h=await s.exec(d);w+=h.stdout,b+=h.stderr,h.exitCode!==0&&(T=h.exitCode)}break}else f&&(w=m.length>0?`${m.join(`
10
- `)}
11
- `:"");return{stdout:w,stderr:b,exitCode:T}}};export{K as findCommand};
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env node
2
- import{a as N}from"./chunk-26Q3PZQ6.js";import{a as q,b as G,c as O}from"./chunk-GTNBSMZR.js";import"./chunk-5KNEBKYN.js";var j={name:"grep",summary:"print lines that match patterns",usage:"grep [OPTION]... PATTERN [FILE]...",options:["-E, --extended-regexp PATTERN is an extended regular expression","-F, --fixed-strings PATTERN is a set of newline-separated strings","-i, --ignore-case ignore case distinctions","-v, --invert-match select non-matching lines","-w, --word-regexp match only whole words","-c, --count print only a count of matching lines","-l, --files-with-matches print only names of files with matches","-L, --files-without-match print names of files with no matches","-n, --line-number print line number with output lines","-h, --no-filename suppress the file name prefix on output","-o, --only-matching show only nonempty parts of lines that match","-q, --quiet, --silent suppress all normal output","-r, -R, --recursive search directories recursively","-A NUM print NUM lines of trailing context","-B NUM print NUM lines of leading context","-C NUM print NUM lines of context","-e PATTERN use PATTERN for matching"," --include=GLOB search only files matching GLOB"," --exclude=GLOB skip files matching GLOB"," --exclude-dir=DIR skip directories matching DIR"," --help display this help and exit"]},k={name:"grep",async execute(s,e){if(G(s))return q(j);let o=!1,r=!1,f=!1,u=!1,w=!1,p=!1,h=!1,d=!1,g=!1,m=!1,y=!1,L=!1,x=!1,v=0,l=0,C=[],i=[],n=[],I=null,P=[];for(let a=0;a<s.length;a++){let c=s[a];if(c.startsWith("-")&&c!=="-"){if(c==="-e"&&a+1<s.length){I=s[++a];continue}if(c.startsWith("--include=")){C.push(c.slice(10));continue}if(c.startsWith("--exclude=")){i.push(c.slice(10));continue}if(c.startsWith("--exclude-dir=")){n.push(c.slice(14));continue}let $=c.match(/^-([ABC])(\d+)$/);if($){let t=parseInt($[2],10);$[1]==="A"?l=t:$[1]==="B"?v=t:$[1]==="C"&&(v=t,l=t);continue}if((c==="-A"||c==="-B"||c==="-C")&&a+1<s.length){let t=parseInt(s[++a],10);c==="-A"?l=t:c==="-B"?v=t:(v=t,l=t);continue}let A=c.startsWith("--")?[c]:c.slice(1).split("");for(let t of A)if(t==="i"||t==="--ignore-case")o=!0;else if(t==="n"||t==="--line-number")r=!0;else if(t==="v"||t==="--invert-match")f=!0;else if(t==="c"||t==="--count")u=!0;else if(t==="l"||t==="--files-with-matches")w=!0;else if(t==="L"||t==="--files-without-match")p=!0;else if(t==="r"||t==="R"||t==="--recursive")h=!0;else if(t==="w"||t==="--word-regexp")d=!0;else if(t==="E"||t==="--extended-regexp")g=!0;else if(t==="F"||t==="--fixed-strings")m=!0;else if(t==="o"||t==="--only-matching")y=!0;else if(t==="h"||t==="--no-filename")L=!0;else if(t==="q"||t==="--quiet"||t==="--silent")x=!0;else{if(t.startsWith("--"))return O("grep",t);if(t.length===1)return O("grep",`-${t}`)}}else I===null?I=c:P.push(c)}if(I===null)return{stdout:"",stderr:`grep: missing pattern
3
- `,exitCode:2};let R;m?R=I.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"):g?R=I:R=z(I),d&&(R=`\\b${R}\\b`);let B;try{B=new RegExp(R,o?"gi":"g")}catch{return{stdout:"",stderr:`grep: invalid regular expression: ${I}
4
- `,exitCode:2}}if(P.length===0&&e.stdin){let a=b(e.stdin,B,f,r,u,"",y,v,l);return x?{stdout:"",stderr:"",exitCode:a.matched?0:1}:{stdout:a.output,stderr:"",exitCode:a.matched?0:1}}if(P.length===0)return{stdout:"",stderr:`grep: no input files
5
- `,exitCode:2};let E="",W="",Q=!1,U=!1,M=[];for(let a of P)if(a.includes("*")||a.includes("?")||a.includes("[")){let c=await J(a,e);if(h)for(let $ of c){let A=await S($,e,C,i,n);M.push(...A)}else M.push(...c)}else if(h){let c=await S(a,e,C,i,n);M.push(...c)}else M.push(a);let H=(M.length>1||h)&&!L;for(let a of M){let c=a.split("/").pop()||a;if(!(i.length>0&&!h&&i.some($=>N(c,$,{stripQuotes:!0})))&&!(C.length>0&&!h&&!C.some($=>N(c,$,{stripQuotes:!0}))))try{let $=e.fs.resolvePath(e.cwd,a);if((await e.fs.stat($)).isDirectory){h||(W+=`grep: ${a}: Is a directory
6
- `);continue}let t=await e.fs.readFile($),F=b(t,B,f,r,u,H?a:"",y,v,l);if(F.matched){if(Q=!0,x)return{stdout:"",stderr:"",exitCode:0};w?E+=`${a}
7
- `:p||(E+=F.output)}else p?E+=`${a}
8
- `:u&&!w&&(E+=F.output)}catch{W+=`grep: ${a}: No such file or directory
9
- `,U=!0}}let T;return U?T=2:p?T=E.length>0?0:1:T=Q?0:1,x?{stdout:"",stderr:"",exitCode:T}:{stdout:E,stderr:W,exitCode:T}}};function z(s){let e="",o=0;for(;o<s.length;){let r=s[o];if(r==="\\"&&o+1<s.length){let f=s[o+1];if(f==="|"||f==="("||f===")"){e+=f,o+=2;continue}else if(f==="{"||f==="}"){e+=`\\${f}`,o+=2;continue}}r==="+"||r==="?"||r==="|"||r==="("||r===")"||r==="{"||r==="}"?e+=`\\${r}`:e+=r,o++}return e}function b(s,e,o,r,f,u,w=!1,p=0,h=0){let d=s.split(`
10
- `),g=d.length,m=g>0&&d[g-1]===""?g-1:g;if(f){let l=0;for(let i=0;i<m;i++)e.lastIndex=0,e.test(d[i])!==o&&l++;return{output:`${u?`${u}:${l}`:String(l)}
11
- `,matched:l>0}}if(p===0&&h===0){let l=[],C=!1;for(let i=0;i<m;i++){let n=d[i];if(e.lastIndex=0,e.test(n)!==o)if(C=!0,w){e.lastIndex=0;for(let P=e.exec(n);P!==null;P=e.exec(n))l.push(u?`${u}:${P[0]}`:P[0]),P[0].length===0&&e.lastIndex++}else r?l.push(u?`${u}:${i+1}:${n}`:`${i+1}:${n}`):l.push(u?`${u}:${n}`:n)}return{output:l.length>0?`${l.join(`
12
- `)}
13
- `:"",matched:C}}let y=[],L=0,x=new Set,v=[];for(let l=0;l<m;l++)e.lastIndex=0,e.test(d[l])!==o&&(v.push(l),L++);for(let l of v){for(let i=Math.max(0,l-p);i<l;i++)if(!x.has(i)){x.add(i);let n=d[i];r&&(n=`${i+1}-${n}`),u&&(n=`${u}-${n}`),y.push(n)}if(!x.has(l)){x.add(l);let i=d[l];if(w){e.lastIndex=0;for(let n=e.exec(i);n!==null;n=e.exec(i))y.push(u?`${u}:${n[0]}`:n[0]),n[0].length===0&&e.lastIndex++}else{let n=i;r&&(n=`${l+1}:${n}`),u&&(n=`${u}:${n}`),y.push(n)}}let C=Math.min(m-1,l+h);for(let i=l+1;i<=C;i++)if(!x.has(i)){x.add(i);let n=d[i];r&&(n=`${i+1}-${n}`),u&&(n=`${u}-${n}`),y.push(n)}}return{output:y.length>0?`${y.join(`
14
- `)}
15
- `:"",matched:L>0}}async function S(s,e,o=[],r=[],f=[]){let u=e.fs.resolvePath(e.cwd,s),w=[];try{if(!(await e.fs.stat(u)).isDirectory){let g=s.split("/").pop()||s;return r.length>0&&r.some(m=>N(g,m,{stripQuotes:!0}))?[]:o.length>0&&!o.some(m=>N(g,m,{stripQuotes:!0}))?[]:[s]}let h=s.split("/").pop()||s;if(f.length>0&&f.some(g=>N(h,g,{stripQuotes:!0})))return[];let d=await e.fs.readdir(u);for(let g of d){if(g.startsWith("."))continue;let m=s==="."?g:`${s}/${g}`,y=await S(m,e,o,r,f);w.push(...y)}}catch{}return w}async function J(s,e){let o=[],r=s.lastIndexOf("/"),f,u;if(r===-1?(f=e.cwd,u=s):(f=s.slice(0,r)||"/",u=s.slice(r+1)),s.includes("**")){let p=s.split("**"),h=p[0].replace(/\/$/,"")||".",d=p[1]||"";return await D(h,d,e,o),o}let w=e.fs.resolvePath(e.cwd,f);try{let p=await e.fs.readdir(w);for(let h of p)if(N(h,u,{stripQuotes:!0})){let d=r===-1?h:`${f}/${h}`;o.push(d)}}catch{}return o.sort()}async function D(s,e,o,r){let f=o.fs.resolvePath(o.cwd,s);try{if(!(await o.fs.stat(f)).isDirectory){let p=s.split("/").pop()||"";if(e){let h=e.replace(/^\//,"");N(p,h,{stripQuotes:!0})&&r.push(s)}return}let w=await o.fs.readdir(f);for(let p of w){let h=s==="."?p:`${s}/${p}`,d=o.fs.resolvePath(o.cwd,h);if((await o.fs.stat(d)).isDirectory)await D(h,e,o,r);else if(e){let m=e.replace(/^\//,"");N(p,m,{stripQuotes:!0})&&r.push(h)}}}catch{}}var X={name:"fgrep",async execute(s,e){return k.execute(["-F",...s],e)}},Y={name:"egrep",async execute(s,e){return k.execute(["-E",...s],e)}};export{Y as egrepCommand,X as fgrepCommand,k as grepCommand};