@poe-platform/safe-bash 0.1.799 → 0.1.800

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 (847) hide show
  1. package/README.md +32 -17
  2. package/dist/image-ast/index.browser.js +1384 -23
  3. package/dist/image-ast/index.js +1384 -23
  4. package/dist/mp4-ast/types.d.ts +1 -0
  5. package/dist/office-package/zip.d.ts +2 -0
  6. package/dist/office-package/zip.js +1 -1
  7. package/dist/pdf-ast/index.js +1 -1
  8. package/dist/safe-bash/chunks/{chunk-IUTD5FH5.js → chunk-46UISJCK.js} +1 -6
  9. package/dist/safe-bash/chunks/chunk-4SEW2Q6H.js +26 -0
  10. package/dist/safe-bash/chunks/{chunk-AKC46AF6.js → chunk-7YSRXFEG.js} +7 -40
  11. package/dist/safe-bash/chunks/{chunk-KTGR4U57.js → chunk-BHJE5LPZ.js} +1 -2
  12. package/dist/safe-bash/chunks/{chunk-TRVGCN3U.js → chunk-HHW7MGS2.js} +2 -2
  13. package/dist/safe-bash/chunks/{chunk-ZNAFMYIA.js → chunk-I7L3G3NX.js} +1 -1
  14. package/dist/safe-bash/chunks/{chunk-KMH2DF3I.js → chunk-JJSTTIEZ.js} +6 -1
  15. package/dist/safe-bash/chunks/{chunk-6IBTC4YL.js → chunk-JTLSUJ7V.js} +57 -20
  16. package/dist/safe-bash/chunks/chunk-K2VCOJ2B.js +111 -0
  17. package/dist/safe-bash/chunks/chunk-K4YMYFRJ.js +9802 -0
  18. package/dist/safe-bash/chunks/{chunk-SPYL72GN.js → chunk-KW24TAIU.js} +446 -5519
  19. package/dist/safe-bash/chunks/{chunk-ENR3HB2B.js → chunk-NLAW7KDI.js} +0 -1
  20. package/dist/safe-bash/chunks/{chunk-B3DDEDH2.js → chunk-PPYM75Z3.js} +1 -1
  21. package/dist/safe-bash/chunks/{chunk-NX2SQVON.js → chunk-RKKRJ54E.js} +19 -7
  22. package/dist/safe-bash/chunks/{chunk-WUNK5NXJ.js → chunk-RMWLWH7Q.js} +870 -953
  23. package/dist/safe-bash/chunks/{chunk-JSVX4VIA.js → chunk-TFGRKY43.js} +2 -1
  24. package/dist/safe-bash/chunks/{chunk-T5KKDMYB.js → chunk-TYD7EVUJ.js} +6 -0
  25. package/dist/safe-bash/chunks/{csvkit-W2UEKH6P.js → csvkit-QGP3GAOB.js} +1 -1
  26. package/dist/safe-bash/chunks/{ffmpeg-42CGASMV.js → ffmpeg-JTVH26MK.js} +1 -1
  27. package/dist/safe-bash/chunks/{gh-26GYLH6D.js → gh-I7QX7N5C.js} +1 -1
  28. package/dist/safe-bash/chunks/{git-YREKMUVD.js → git-MA7NKYVP.js} +1 -1
  29. package/dist/safe-bash/chunks/{imagemagick-3YIX4XO2.js → imagemagick-Y4NPWX2Q.js} +1 -1
  30. package/dist/safe-bash/chunks/{implementation-E3YMKU3Z.js → implementation-BWDKOVQJ.js} +1 -1
  31. package/dist/safe-bash/chunks/mmdc-44PELHDG.js +118 -0
  32. package/dist/safe-bash/chunks/{pdfimages-UE2UISP2.js → pdfimages-635TRW4Q.js} +1 -1
  33. package/dist/safe-bash/chunks/{pdfinfo-RGARKLI5.js → pdfinfo-FSDAA2KY.js} +3 -11
  34. package/dist/safe-bash/chunks/{pdftk-JY3WVCCC.js → pdftk-GQ5UH3VG.js} +1 -1
  35. package/dist/safe-bash/chunks/{pdftoppm-GPD3BMPY.js → pdftoppm-YTXQCAYT.js} +1 -1
  36. package/dist/safe-bash/chunks/{pdftotext-K7GQ2QJZ.js → pdftotext-CVA2G7FY.js} +1 -1
  37. package/dist/safe-bash/chunks/{qpdf-F4U7WUSU.js → qpdf-HZMIFG4A.js} +1 -1
  38. package/dist/safe-bash/chunks/{sips-RWENS7X5.js → sips-E7UBDP33.js} +1 -1
  39. package/dist/safe-bash/chunks/{soffice-IT6W2C5F.js → soffice-ELASUWUK.js} +1 -1
  40. package/dist/safe-bash/chunks/{wkhtmltopdf-JYNDAHIZ.js → wkhtmltopdf-EPO6YCMG.js} +1 -1
  41. package/dist/safe-bash/command-chunks/chunk-2FGJYFWZ.js +44 -0
  42. package/dist/safe-bash/command-chunks/chunk-2H4JTFIL.js +53 -0
  43. package/dist/safe-bash/command-chunks/{chunk-LLCXZKZ6.js → chunk-2QHG43WJ.js} +2 -2
  44. package/dist/safe-bash/command-chunks/chunk-364TMWBT.js +946 -0
  45. package/dist/safe-bash/command-chunks/{chunk-EIVW3X3N.js → chunk-3DT2YOGW.js} +11 -6
  46. package/dist/safe-bash/command-chunks/chunk-3E2OIS2J.js +7037 -0
  47. package/dist/safe-bash/command-chunks/{chunk-AIRGA2SU.js → chunk-3HXDA5PT.js} +1 -1
  48. package/dist/safe-bash/command-chunks/chunk-3LSOYLNV.js +1091 -0
  49. package/dist/safe-bash/command-chunks/chunk-4B7Y7S6E.js +61 -0
  50. package/dist/safe-bash/command-chunks/{chunk-HRLIAMXC.js → chunk-4C6QI5BQ.js} +3 -2
  51. package/dist/safe-bash/command-chunks/chunk-4ZHMW6F5.js +104 -0
  52. package/dist/safe-bash/command-chunks/{chunk-4ZALPDBV.js → chunk-53P53XFM.js} +2 -2
  53. package/dist/safe-bash/command-chunks/chunk-5LSGEIZY.js +379 -0
  54. package/dist/safe-bash/command-chunks/{chunk-MKQVQMXO.js → chunk-5LU4UCBR.js} +1 -1
  55. package/dist/safe-bash/command-chunks/chunk-5T7CRJHW.js +560 -0
  56. package/dist/safe-bash/command-chunks/chunk-5TBUOBDE.js +346 -0
  57. package/dist/safe-bash/command-chunks/chunk-5XY4DTNG.js +34 -0
  58. package/dist/safe-bash/command-chunks/chunk-5ZMZ573Q.js +140 -0
  59. package/dist/safe-bash/command-chunks/{chunk-OPUJSTHS.js → chunk-67IQF5GC.js} +200 -66
  60. package/dist/safe-bash/command-chunks/chunk-67QKREJK.js +347 -0
  61. package/dist/safe-bash/command-chunks/chunk-6EPHJGGF.js +23 -0
  62. package/dist/safe-bash/command-chunks/chunk-6F4XCVON.js +266 -0
  63. package/dist/safe-bash/command-chunks/{chunk-ESMCX3YV.js → chunk-6HMX4CQS.js} +669 -130
  64. package/dist/safe-bash/command-chunks/chunk-7K6JYKPJ.js +422 -0
  65. package/dist/safe-bash/command-chunks/chunk-7N2LI2KO.js +206 -0
  66. package/dist/safe-bash/command-chunks/chunk-7RGB363W.js +362 -0
  67. package/dist/safe-bash/command-chunks/{pptx-GBPNWNEP-7EQEVXV5.js → chunk-AI5JAXQF.js} +34820 -18029
  68. package/dist/safe-bash/command-chunks/chunk-AMO3THU4.js +105 -0
  69. package/dist/safe-bash/command-chunks/chunk-BAGCY35S.js +231 -0
  70. package/dist/safe-bash/command-chunks/chunk-BAXU7B5Z.js +101 -0
  71. package/dist/safe-bash/command-chunks/{chunk-KMCZ6P4O.js → chunk-BKCNF5U3.js} +68 -7
  72. package/dist/safe-bash/command-chunks/chunk-BNOU5YQS.js +182 -0
  73. package/dist/safe-bash/command-chunks/chunk-C7I25AAL.js +25 -0
  74. package/dist/safe-bash/command-chunks/chunk-CKXV2CLD.js +65 -0
  75. package/dist/safe-bash/command-chunks/chunk-CQ5YGOGB.js +150 -0
  76. package/dist/safe-bash/command-chunks/{chunk-I3K5RYU4.js → chunk-D4OP2BR3.js} +72 -24
  77. package/dist/safe-bash/command-chunks/chunk-DB453IE6.js +122 -0
  78. package/dist/safe-bash/command-chunks/chunk-DOKKNRRM.js +87 -0
  79. package/dist/safe-bash/command-chunks/{chunk-2PX5B7T5.js → chunk-DQAVUDDX.js} +2 -2
  80. package/dist/safe-bash/command-chunks/chunk-DT7BCTWY.js +249 -0
  81. package/dist/safe-bash/command-chunks/chunk-E2LB7FRT.js +42 -0
  82. package/dist/safe-bash/command-chunks/chunk-EK6YNAXT.js +343 -0
  83. package/dist/safe-bash/command-chunks/chunk-EQ4HV54N.js +22 -0
  84. package/dist/safe-bash/command-chunks/chunk-ERYJLO6G.js +293 -0
  85. package/dist/safe-bash/command-chunks/{chunk-4ONEXMD3.js → chunk-EUSPTFAX.js} +1 -1
  86. package/dist/safe-bash/command-chunks/chunk-FKKB5X5V.js +97 -0
  87. package/dist/safe-bash/command-chunks/chunk-FXELCPFX.js +195 -0
  88. package/dist/safe-bash/command-chunks/{chunk-JCNNOMBV.js → chunk-GI4CJED2.js} +3 -2
  89. package/dist/safe-bash/command-chunks/{chunk-CU5RLO62.js → chunk-GLOZX57Y.js} +92 -18
  90. package/dist/safe-bash/command-chunks/chunk-GMIHJYDG.js +331 -0
  91. package/dist/safe-bash/command-chunks/chunk-H622NS6Z.js +11 -0
  92. package/dist/safe-bash/command-chunks/{chunk-UI32HWGS.js → chunk-HMOZ6XVJ.js} +1 -1
  93. package/dist/safe-bash/command-chunks/{chunk-AVSPNLWV.js → chunk-I237SNW5.js} +1 -1
  94. package/dist/safe-bash/command-chunks/{chunk-ZS3QPNUL.js → chunk-IR2BY7EL.js} +21 -6
  95. package/dist/safe-bash/command-chunks/chunk-IYPAQ7PH.js +42 -0
  96. package/dist/safe-bash/command-chunks/chunk-JN7WIP6S.js +94 -0
  97. package/dist/safe-bash/command-chunks/chunk-JNZ3CVAE.js +147 -0
  98. package/dist/safe-bash/command-chunks/{chunk-HLBX5IRS.js → chunk-JQ74HC37.js} +24 -32
  99. package/dist/safe-bash/command-chunks/chunk-KFVV7ZJO.js +216 -0
  100. package/dist/safe-bash/command-chunks/{chunk-G4PNVO6Z.js → chunk-KP7AO66M.js} +1 -1
  101. package/dist/safe-bash/command-chunks/chunk-KWESKQHR.js +25 -0
  102. package/dist/safe-bash/command-chunks/chunk-KYSPGS33.js +41 -0
  103. package/dist/safe-bash/command-chunks/{chunk-C7IHMJEW.js → chunk-KZC5UWFF.js} +2 -2
  104. package/dist/safe-bash/command-chunks/chunk-L6DVEBW3.js +553 -0
  105. package/dist/safe-bash/command-chunks/chunk-LC2MFKT4.js +2489 -0
  106. package/dist/safe-bash/command-chunks/chunk-LE5LZNHE.js +204 -0
  107. package/dist/safe-bash/command-chunks/chunk-MDH5T4OS.js +41 -0
  108. package/dist/safe-bash/command-chunks/chunk-MM6HU6CX.js +20 -0
  109. package/dist/safe-bash/command-chunks/{chunk-MYJAZ3U2.js → chunk-MPL2466A.js} +2 -2
  110. package/dist/safe-bash/command-chunks/{chunk-VZHRZMS7.js → chunk-NAY27PXB.js} +1 -1
  111. package/dist/safe-bash/command-chunks/chunk-NCD7PEWH.js +298 -0
  112. package/dist/safe-bash/command-chunks/chunk-NFGI5IGF.js +266 -0
  113. package/dist/safe-bash/command-chunks/{chunk-KVFCSLKK.js → chunk-NXEQ3ESQ.js} +6 -0
  114. package/dist/safe-bash/command-chunks/{chunk-3VGGYEDH.js → chunk-ORYGZYKW.js} +4 -3
  115. package/dist/safe-bash/command-chunks/{chunk-OLQG7ZCN.js → chunk-PEF7K3UQ.js} +136 -75
  116. package/dist/safe-bash/command-chunks/chunk-PII4YEZW.js +123 -0
  117. package/dist/safe-bash/command-chunks/{chunk-43GSSUAY.js → chunk-PJJUYO3R.js} +5 -5
  118. package/dist/safe-bash/command-chunks/{chunk-ZT4KSS2V.js → chunk-PTT3I223.js} +1 -1
  119. package/dist/safe-bash/command-chunks/chunk-Q3DII3Q7.js +174 -0
  120. package/dist/safe-bash/command-chunks/chunk-Q3EWDEUQ.js +185 -0
  121. package/dist/safe-bash/command-chunks/{chunk-2FUAW6GO.js → chunk-QI7LGHJJ.js} +58 -9
  122. package/dist/safe-bash/command-chunks/{chunk-6BETHLXZ.js → chunk-QJAFJP2G.js} +1 -1
  123. package/dist/safe-bash/command-chunks/chunk-QNIMV57G.js +63 -0
  124. package/dist/safe-bash/command-chunks/{chunk-VVI4Z73I.js → chunk-QP4R6GLA.js} +5 -1
  125. package/dist/safe-bash/command-chunks/{chunk-LPORMIZS.js → chunk-QWIDNAAK.js} +8 -8
  126. package/dist/safe-bash/command-chunks/chunk-RVLO4DYT.js +35 -0
  127. package/dist/safe-bash/command-chunks/{chunk-X2YQLGKS.js → chunk-SAMH7SQE.js} +4 -4
  128. package/dist/safe-bash/command-chunks/chunk-SEM36PG5.js +11 -0
  129. package/dist/safe-bash/command-chunks/chunk-STC3LEWJ.js +634 -0
  130. package/dist/safe-bash/command-chunks/chunk-SVULUDOP.js +331 -0
  131. package/dist/safe-bash/command-chunks/chunk-TEVJJPTC.js +1392 -0
  132. package/dist/safe-bash/command-chunks/{chunk-ZXKW7SJ2.js → chunk-TYCGMRLM.js} +2 -2
  133. package/dist/safe-bash/command-chunks/chunk-UG7SMZFF.js +178 -0
  134. package/dist/safe-bash/command-chunks/{chunk-YZ5SVZFD.js → chunk-UMDIOL3O.js} +3 -3
  135. package/dist/safe-bash/command-chunks/chunk-UXSR5BZH.js +136 -0
  136. package/dist/safe-bash/command-chunks/chunk-V6BEDRMQ.js +112 -0
  137. package/dist/safe-bash/command-chunks/chunk-V6MSPQLA.js +362 -0
  138. package/dist/safe-bash/command-chunks/{chunk-J4PEQWSF.js → chunk-VGG2DL5Q.js} +0 -1
  139. package/dist/safe-bash/command-chunks/{chunk-SG424QWS.js → chunk-VL67NWNS.js} +1 -1
  140. package/dist/safe-bash/command-chunks/chunk-WB5SVIG7.js +1034 -0
  141. package/dist/safe-bash/command-chunks/{src-UJOWAS2S.js → chunk-WD3ERGRY.js} +77 -277
  142. package/dist/safe-bash/command-chunks/{chunk-YFSDDFGV.js → chunk-WH627NJL.js} +446 -53
  143. package/dist/safe-bash/command-chunks/chunk-WNE7FPVR.js +236 -0
  144. package/dist/safe-bash/command-chunks/{chunk-UKS2XJZI.js → chunk-WPYIOKE3.js} +4 -4
  145. package/dist/safe-bash/command-chunks/chunk-XETLEHZP.js +1227 -0
  146. package/dist/safe-bash/command-chunks/chunk-XIIBTGC5.js +580 -0
  147. package/dist/safe-bash/command-chunks/chunk-XJXU3VVH.js +737 -0
  148. package/dist/safe-bash/command-chunks/chunk-Y5INTD6S.js +220 -0
  149. package/dist/safe-bash/command-chunks/{chunk-5ZSM4UFN.js → chunk-YGC6OS5O.js} +3 -56
  150. package/dist/safe-bash/command-chunks/chunk-YJDV76GL.js +262 -0
  151. package/dist/safe-bash/command-chunks/chunk-YOF7R4OY.js +80 -0
  152. package/dist/safe-bash/command-chunks/chunk-Z7RVSD5K.js +594 -0
  153. package/dist/safe-bash/command-chunks/chunk-ZHUWOUWB.js +618 -0
  154. package/dist/safe-bash/command-chunks/{model-store-L35QTZMJ.js → model-store-WPKMRPV4.js} +2 -2
  155. package/dist/safe-bash/command-chunks/pptx-7G52EJ6L-4JACH5FB.js +625 -0
  156. package/dist/safe-bash/command-chunks/python-worker-source-TYOFJMCW.js +4 -0
  157. package/dist/safe-bash/command-chunks/src-ICMQISAA.js +501 -0
  158. package/dist/safe-bash/commands/archive/create.d.ts +1 -17
  159. package/dist/safe-bash/commands/archive/create.js +1 -252
  160. package/dist/safe-bash/commands/archive/extract.d.ts +1 -11
  161. package/dist/safe-bash/commands/archive/extract.js +1 -640
  162. package/dist/safe-bash/commands/archive/format.d.ts +1 -32
  163. package/dist/safe-bash/commands/archive/format.js +1 -225
  164. package/dist/safe-bash/commands/archive/index.d.ts +5 -10
  165. package/dist/safe-bash/commands/archive/index.js +6 -931
  166. package/dist/safe-bash/commands/archive/listing.d.ts +1 -2
  167. package/dist/safe-bash/commands/archive/listing.js +1 -21
  168. package/dist/safe-bash/commands/archive/modes.d.ts +1 -5
  169. package/dist/safe-bash/commands/archive/modes.js +1 -182
  170. package/dist/safe-bash/commands/archive/options.d.ts +1 -53
  171. package/dist/safe-bash/commands/archive/options.js +1 -462
  172. package/dist/safe-bash/commands/archive/stream.d.ts +1 -22
  173. package/dist/safe-bash/commands/archive/stream.js +1 -188
  174. package/dist/safe-bash/commands/archive/transform.d.ts +1 -16
  175. package/dist/safe-bash/commands/archive/transform.js +1 -85
  176. package/dist/safe-bash/commands/archive/unzip/arguments.d.ts +1 -53
  177. package/dist/safe-bash/commands/archive/unzip/arguments.js +1 -322
  178. package/dist/safe-bash/commands/archive/unzip/safety.d.ts +1 -32
  179. package/dist/safe-bash/commands/archive/unzip/safety.js +1 -295
  180. package/dist/safe-bash/commands/archive/unzip.d.ts +1 -3
  181. package/dist/safe-bash/commands/archive/unzip.js +1 -398
  182. package/dist/safe-bash/commands/archive/zip/aes.d.ts +1 -17
  183. package/dist/safe-bash/commands/archive/zip/aes.js +1 -156
  184. package/dist/safe-bash/commands/archive/zip/comments.d.ts +1 -17
  185. package/dist/safe-bash/commands/archive/zip/comments.js +1 -83
  186. package/dist/safe-bash/commands/archive/zip/crc.d.ts +1 -1
  187. package/dist/safe-bash/commands/archive/zip/crc.js +1 -1
  188. package/dist/safe-bash/commands/archive/zip/crypto.d.ts +1 -19
  189. package/dist/safe-bash/commands/archive/zip/crypto.js +1 -118
  190. package/dist/safe-bash/commands/archive/zip/dates.d.ts +1 -4
  191. package/dist/safe-bash/commands/archive/zip/dates.js +1 -66
  192. package/dist/safe-bash/commands/archive/zip/environment.d.ts +1 -2
  193. package/dist/safe-bash/commands/archive/zip/environment.js +1 -62
  194. package/dist/safe-bash/commands/archive/zip/grow.d.ts +1 -3
  195. package/dist/safe-bash/commands/archive/zip/grow.js +1 -2
  196. package/dist/safe-bash/commands/archive/zip/help.d.ts +1 -4
  197. package/dist/safe-bash/commands/archive/zip/help.js +1 -182
  198. package/dist/safe-bash/commands/archive/zip/line-endings.d.ts +1 -2
  199. package/dist/safe-bash/commands/archive/zip/line-endings.js +1 -194
  200. package/dist/safe-bash/commands/archive/zip/log.d.ts +1 -22
  201. package/dist/safe-bash/commands/archive/zip/log.js +1 -159
  202. package/dist/safe-bash/commands/archive/zip/lzma.d.ts +1 -9
  203. package/dist/safe-bash/commands/archive/zip/lzma.js +1 -40
  204. package/dist/safe-bash/commands/archive/zip/move.d.ts +1 -11
  205. package/dist/safe-bash/commands/archive/zip/move.js +1 -59
  206. package/dist/safe-bash/commands/archive/zip/names.d.ts +1 -2
  207. package/dist/safe-bash/commands/archive/zip/names.js +1 -33
  208. package/dist/safe-bash/commands/archive/zip/options.d.ts +1 -13
  209. package/dist/safe-bash/commands/archive/zip/options.js +1 -124
  210. package/dist/safe-bash/commands/archive/zip/repair.d.ts +1 -10
  211. package/dist/safe-bash/commands/archive/zip/repair.js +1 -392
  212. package/dist/safe-bash/commands/archive/zip/safety.d.ts +1 -54
  213. package/dist/safe-bash/commands/archive/zip/safety.js +1 -360
  214. package/dist/safe-bash/commands/archive/zip/sfx.d.ts +1 -4
  215. package/dist/safe-bash/commands/archive/zip/sfx.js +1 -52
  216. package/dist/safe-bash/commands/archive/zip/test-command.d.ts +1 -5
  217. package/dist/safe-bash/commands/archive/zip/test-command.js +1 -101
  218. package/dist/safe-bash/commands/archive/zip/volumes.d.ts +1 -21
  219. package/dist/safe-bash/commands/archive/zip/volumes.js +1 -281
  220. package/dist/safe-bash/commands/archive/zip/zip64.d.ts +1 -30
  221. package/dist/safe-bash/commands/archive/zip/zip64.js +1 -227
  222. package/dist/safe-bash/commands/archive/zip-format.d.ts +1 -68
  223. package/dist/safe-bash/commands/archive/zip-format.js +1 -1075
  224. package/dist/safe-bash/commands/archive/zip.d.ts +1 -3
  225. package/dist/safe-bash/commands/archive/zip.js +1 -1523
  226. package/dist/safe-bash/commands/awk/index.d.ts +2 -0
  227. package/dist/safe-bash/commands/awk/index.js +2 -0
  228. package/dist/safe-bash/commands/bytes/compression/index.js +2 -1
  229. package/dist/safe-bash/commands/curl/index.d.ts +2 -0
  230. package/dist/safe-bash/commands/curl/index.js +2 -0
  231. package/dist/safe-bash/commands/diff/index.d.ts +2 -0
  232. package/dist/safe-bash/commands/diff/index.js +2 -0
  233. package/dist/safe-bash/commands/diff-patch/diff-format.d.ts +1 -10
  234. package/dist/safe-bash/commands/diff-patch/diff-format.js +1 -237
  235. package/dist/safe-bash/commands/diff-patch/diff-options.d.ts +1 -38
  236. package/dist/safe-bash/commands/diff-patch/diff-options.js +1 -261
  237. package/dist/safe-bash/commands/diff-patch/diff-output.d.ts +1 -20
  238. package/dist/safe-bash/commands/diff-patch/diff-output.js +1 -290
  239. package/dist/safe-bash/commands/diff-patch/diff.d.ts +1 -2
  240. package/dist/safe-bash/commands/diff-patch/diff.js +1 -656
  241. package/dist/safe-bash/commands/diff-patch/index.d.ts +4 -5
  242. package/dist/safe-bash/commands/diff-patch/index.js +8 -333
  243. package/dist/safe-bash/commands/diff-patch/patch-envelope.d.ts +1 -2
  244. package/dist/safe-bash/commands/diff-patch/patch-envelope.js +1 -63
  245. package/dist/safe-bash/commands/diff-patch/patch-formats.d.ts +1 -7
  246. package/dist/safe-bash/commands/diff-patch/patch-formats.js +1 -264
  247. package/dist/safe-bash/commands/diff-patch/patch-gnu-paths.d.ts +1 -41
  248. package/dist/safe-bash/commands/diff-patch/patch-gnu-paths.js +1 -263
  249. package/dist/safe-bash/commands/diff-patch/patch-gnu-reject.d.ts +1 -3
  250. package/dist/safe-bash/commands/diff-patch/patch-gnu-reject.js +1 -100
  251. package/dist/safe-bash/commands/diff-patch/patch-path.d.ts +1 -3
  252. package/dist/safe-bash/commands/diff-patch/patch-path.js +1 -91
  253. package/dist/safe-bash/commands/diff-patch/patch-publication.d.ts +1 -13
  254. package/dist/safe-bash/commands/diff-patch/patch-publication.js +1 -107
  255. package/dist/safe-bash/commands/diff-patch/patch.d.ts +1 -2
  256. package/dist/safe-bash/commands/diff-patch/patch.js +1 -653
  257. package/dist/safe-bash/commands/diff-patch/shared.d.ts +1 -53
  258. package/dist/safe-bash/commands/diff-patch/shared.js +1 -267
  259. package/dist/safe-bash/commands/diff-patch/unified.d.ts +1 -52
  260. package/dist/safe-bash/commands/diff-patch/unified.js +1 -385
  261. package/dist/safe-bash/commands/directory-admission.d.ts +1 -3
  262. package/dist/safe-bash/commands/directory-admission.js +1 -26
  263. package/dist/safe-bash/commands/find/index.d.ts +2 -0
  264. package/dist/safe-bash/commands/find/index.js +2 -0
  265. package/dist/safe-bash/commands/find-format.d.ts +1 -20
  266. package/dist/safe-bash/commands/find-format.js +1 -161
  267. package/dist/safe-bash/commands/find.d.ts +2 -18
  268. package/dist/safe-bash/commands/find.js +2 -1236
  269. package/dist/safe-bash/commands/gzip/index.d.ts +2 -0
  270. package/dist/safe-bash/commands/gzip/index.js +2 -0
  271. package/dist/safe-bash/commands/line-endings/index.browser.js +1 -1
  272. package/dist/safe-bash/commands/line-endings/index.d.ts +1 -1
  273. package/dist/safe-bash/commands/line-endings/index.js +1 -262
  274. package/dist/safe-bash/commands/llm/index.browser.js +3 -1
  275. package/dist/safe-bash/commands/mdq/index.browser.js +2 -2
  276. package/dist/safe-bash/commands/metadata/chmod.d.ts +1 -4
  277. package/dist/safe-bash/commands/metadata/chmod.js +2 -63
  278. package/dist/safe-bash/commands/network/aggregate.d.ts +1 -4
  279. package/dist/safe-bash/commands/network/aggregate.js +1 -23
  280. package/dist/safe-bash/commands/network/args.d.ts +1 -68
  281. package/dist/safe-bash/commands/network/args.js +1 -321
  282. package/dist/safe-bash/commands/network/authorizer.d.ts +1 -6
  283. package/dist/safe-bash/commands/network/authorizer.js +1 -33
  284. package/dist/safe-bash/commands/network/body.d.ts +1 -9
  285. package/dist/safe-bash/commands/network/body.js +1 -393
  286. package/dist/safe-bash/commands/network/curl.d.ts +3 -13
  287. package/dist/safe-bash/commands/network/curl.js +6 -693
  288. package/dist/safe-bash/commands/network/deadline.d.ts +1 -2
  289. package/dist/safe-bash/commands/network/deadline.js +1 -14
  290. package/dist/safe-bash/commands/network/decode.d.ts +1 -2
  291. package/dist/safe-bash/commands/network/decode.js +1 -79
  292. package/dist/safe-bash/commands/network/fetch-transport.d.ts +1 -7
  293. package/dist/safe-bash/commands/network/fetch-transport.js +1 -94
  294. package/dist/safe-bash/commands/network/form-content-type.d.ts +1 -5
  295. package/dist/safe-bash/commands/network/form-content-type.js +1 -63
  296. package/dist/safe-bash/commands/network/form-headers.d.ts +1 -2
  297. package/dist/safe-bash/commands/network/form-headers.js +1 -35
  298. package/dist/safe-bash/commands/network/glob.d.ts +1 -7
  299. package/dist/safe-bash/commands/network/glob.js +1 -134
  300. package/dist/safe-bash/commands/network/index.browser.js +2 -10
  301. package/dist/safe-bash/commands/network/input.d.ts +1 -5
  302. package/dist/safe-bash/commands/network/input.js +1 -276
  303. package/dist/safe-bash/commands/network/output.d.ts +1 -6
  304. package/dist/safe-bash/commands/network/output.js +1 -131
  305. package/dist/safe-bash/commands/network/private-address.d.ts +1 -1
  306. package/dist/safe-bash/commands/network/private-address.js +1 -44
  307. package/dist/safe-bash/commands/network/shared.d.ts +1 -14
  308. package/dist/safe-bash/commands/network/shared.js +1 -71
  309. package/dist/safe-bash/commands/network/types.d.ts +1 -37
  310. package/dist/safe-bash/commands/network/types.js +1 -31
  311. package/dist/safe-bash/commands/network/url.d.ts +1 -2
  312. package/dist/safe-bash/commands/network/url.js +1 -30
  313. package/dist/safe-bash/commands/network/wget.d.ts +3 -3
  314. package/dist/safe-bash/commands/network/wget.js +10 -331
  315. package/dist/safe-bash/commands/node/index.browser.js +4 -5
  316. package/dist/safe-bash/commands/node/index.d.ts +3 -3
  317. package/dist/safe-bash/commands/node/index.js +5 -0
  318. package/dist/safe-bash/commands/node/safejs.d.ts +3 -3
  319. package/dist/safe-bash/commands/node/safejs.js +6 -1
  320. package/dist/safe-bash/commands/node/types.d.ts +1 -1
  321. package/dist/safe-bash/commands/node/unconfigured.d.ts +3 -0
  322. package/dist/safe-bash/commands/node/unconfigured.js +10 -0
  323. package/dist/safe-bash/commands/op/index.browser.js +2 -2
  324. package/dist/safe-bash/commands/patch/index.d.ts +2 -0
  325. package/dist/safe-bash/commands/patch/index.js +2 -0
  326. package/dist/safe-bash/commands/pdfinfo/index.js +2 -1
  327. package/dist/safe-bash/commands/predicates.js +3 -4
  328. package/dist/safe-bash/commands/python/index.browser.js +5 -5
  329. package/dist/safe-bash/commands/python/llm-capability.d.ts +1 -0
  330. package/dist/safe-bash/commands/python/llm-capability.js +27 -7
  331. package/dist/safe-bash/commands/python/llm-module.js +11 -0
  332. package/dist/safe-bash/commands/python/manifest.d.ts +1 -0
  333. package/dist/safe-bash/commands/python/manifest.js +9 -5
  334. package/dist/safe-bash/commands/python/provisioning.js +1 -1
  335. package/dist/safe-bash/commands/regex-execution/matching.js +1 -2
  336. package/dist/safe-bash/commands/regex-execution/public.browser.js +5 -5
  337. package/dist/safe-bash/commands/search/index.d.ts +1 -1
  338. package/dist/safe-bash/commands/search/index.js +1 -347
  339. package/dist/safe-bash/commands/search/portable.d.ts +2 -2
  340. package/dist/safe-bash/commands/search/portable.js +3 -2
  341. package/dist/safe-bash/commands/sed/index.d.ts +2 -0
  342. package/dist/safe-bash/commands/sed/index.js +2 -0
  343. package/dist/safe-bash/commands/tar/index.d.ts +2 -0
  344. package/dist/safe-bash/commands/tar/index.js +2 -0
  345. package/dist/safe-bash/commands/text-programs/awk-inspection.d.ts +1 -19
  346. package/dist/safe-bash/commands/text-programs/awk-inspection.js +1 -50
  347. package/dist/safe-bash/commands/text-programs/awk-pipes.d.ts +2 -0
  348. package/dist/safe-bash/commands/text-programs/awk-pipes.js +2 -0
  349. package/dist/safe-bash/commands/text-programs/awk-pretty.d.ts +1 -3
  350. package/dist/safe-bash/commands/text-programs/awk-pretty.js +1 -197
  351. package/dist/safe-bash/commands/text-programs/awk-quote.d.ts +1 -2
  352. package/dist/safe-bash/commands/text-programs/awk-quote.js +1 -15
  353. package/dist/safe-bash/commands/text-programs/awk-reader.d.ts +1 -42
  354. package/dist/safe-bash/commands/text-programs/awk-reader.js +1 -449
  355. package/dist/safe-bash/commands/text-programs/awk-retention.d.ts +1 -13
  356. package/dist/safe-bash/commands/text-programs/awk-retention.js +1 -51
  357. package/dist/safe-bash/commands/text-programs/awk-runtime.d.ts +1 -150
  358. package/dist/safe-bash/commands/text-programs/awk-runtime.js +1 -2627
  359. package/dist/safe-bash/commands/text-programs/awk-syntax.d.ts +1 -142
  360. package/dist/safe-bash/commands/text-programs/awk-syntax.js +1 -509
  361. package/dist/safe-bash/commands/text-programs/awk-values.d.ts +1 -32
  362. package/dist/safe-bash/commands/text-programs/awk-values.js +1 -386
  363. package/dist/safe-bash/commands/text-programs/awk.d.ts +1 -3
  364. package/dist/safe-bash/commands/text-programs/awk.js +1 -361
  365. package/dist/safe-bash/commands/text-programs/inplace.d.ts +1 -16
  366. package/dist/safe-bash/commands/text-programs/inplace.js +1 -155
  367. package/dist/safe-bash/commands/text-programs/sed.d.ts +1 -3
  368. package/dist/safe-bash/commands/text-programs/sed.js +1 -1647
  369. package/dist/safe-bash/commands/unzip/index.d.ts +2 -0
  370. package/dist/safe-bash/commands/unzip/index.js +2 -0
  371. package/dist/safe-bash/commands/wget/index.d.ts +2 -0
  372. package/dist/safe-bash/commands/wget/index.js +2 -0
  373. package/dist/safe-bash/commands/yq/index.browser.js +7 -2
  374. package/dist/safe-bash/commands/yq/index.d.ts +1 -6
  375. package/dist/safe-bash/commands/yq/index.js +1 -36
  376. package/dist/safe-bash/commands/zip/index.d.ts +2 -0
  377. package/dist/safe-bash/commands/zip/index.js +2 -0
  378. package/dist/safe-bash/core.browser.js +1 -1
  379. package/dist/safe-bash/core.d.ts +8 -1
  380. package/dist/safe-bash/core.js +7 -1
  381. package/dist/safe-bash/fs/s3/index.d.ts +2 -2
  382. package/dist/safe-bash/fs/s3/index.js +1 -1
  383. package/dist/safe-bash/full-core.browser.js +254 -223
  384. package/dist/safe-bash/jobs.browser.js +2 -2
  385. package/dist/safe-bash/lazy-mmdc.d.ts +6 -0
  386. package/dist/safe-bash/lazy-mmdc.js +23 -0
  387. package/dist/safe-bash/opt-in/commands/yq/mike.js +6 -13
  388. package/dist/safe-bash/opt-in/commands/yq/native-work.d.ts +1 -0
  389. package/dist/safe-bash/opt-in/commands/yq/native-work.js +17 -0
  390. package/dist/safe-bash/optional-host.browser.js +8 -4
  391. package/dist/safe-bash/optional-host.d.ts +1 -1
  392. package/dist/safe-bash/optional-host.js +1 -1
  393. package/dist/safe-bash/playwright/ability-execution.js +3 -2
  394. package/dist/safe-bash/playwright/adapter.js +1 -1
  395. package/dist/safe-bash/playwright/controller.js +9 -8
  396. package/dist/safe-bash/playwright/modal-capabilities.js +2 -1
  397. package/dist/safe-bash/playwright/native-json-snapshot.js +4 -3
  398. package/dist/safe-bash/playwright/native-snapshot.js +5 -4
  399. package/dist/safe-bash/playwright/open-options.js +3 -3
  400. package/dist/safe-bash/playwright/resource-limit.d.ts +2 -0
  401. package/dist/safe-bash/playwright/resource-limit.js +4 -0
  402. package/dist/safe-bash/playwright/session-configuration.js +8 -3
  403. package/dist/safe-bash/playwright/snapshot.js +8 -7
  404. package/dist/safe-bash/playwright/standard-capabilities.js +5 -4
  405. package/dist/safe-bash/plugins/index.browser.js +14 -16
  406. package/dist/safe-bash/registry-entry.browser.js +14 -16
  407. package/dist/safe-bash/shell/arrays/bindings.d.ts +3 -5
  408. package/dist/safe-bash/shell/arrays/bindings.js +6 -2
  409. package/dist/safe-bash/shell/input.js +16 -14
  410. package/dist/safe-bash/shell/runtime.d.ts +3 -0
  411. package/dist/safe-bash/shell/runtime.js +316 -64
  412. package/dist/safe-bash/shell/types.d.ts +2 -0
  413. package/dist/safe-bash/shell/value-state.js +17 -2
  414. package/dist/safe-bash/shell/worker-limits.js +1 -0
  415. package/dist/safe-bash/shell-entry.browser.js +13 -15
  416. package/dist/safe-bash/trap.browser.d.ts +3 -0
  417. package/dist/safe-bash/trap.browser.js +14 -0
  418. package/dist/safe-bash/worker/host.js +1 -1
  419. package/dist/safe-bash-command-apply-patch/apply.js +2 -2
  420. package/dist/safe-bash-command-apply-patch/index.js +3 -3
  421. package/dist/safe-bash-command-awk/LICENSE +21 -0
  422. package/dist/safe-bash-command-awk/awk-inspection.d.ts +19 -0
  423. package/dist/safe-bash-command-awk/awk-inspection.js +9 -0
  424. package/dist/safe-bash-command-awk/awk-pipes.d.ts +19 -0
  425. package/dist/safe-bash-command-awk/awk-pipes.js +8 -0
  426. package/dist/safe-bash-command-awk/awk-pretty.d.ts +3 -0
  427. package/dist/safe-bash-command-awk/awk-pretty.js +8 -0
  428. package/dist/safe-bash-command-awk/awk-quote.d.ts +2 -0
  429. package/dist/safe-bash-command-awk/awk-quote.js +7 -0
  430. package/dist/safe-bash-command-awk/awk-reader.d.ts +42 -0
  431. package/dist/safe-bash-command-awk/awk-reader.js +9 -0
  432. package/dist/safe-bash-command-awk/awk-retention.d.ts +13 -0
  433. package/dist/safe-bash-command-awk/awk-retention.js +7 -0
  434. package/dist/safe-bash-command-awk/awk-runtime.d.ts +151 -0
  435. package/dist/safe-bash-command-awk/awk-runtime.js +11 -0
  436. package/dist/safe-bash-command-awk/awk-syntax.d.ts +144 -0
  437. package/dist/safe-bash-command-awk/awk-syntax.js +14 -0
  438. package/dist/safe-bash-command-awk/awk-values.d.ts +32 -0
  439. package/dist/safe-bash-command-awk/awk-values.js +35 -0
  440. package/dist/safe-bash-command-awk/awk.d.ts +3 -0
  441. package/dist/safe-bash-command-awk/awk.js +16 -0
  442. package/dist/safe-bash-command-awk/index.d.ts +7 -0
  443. package/dist/safe-bash-command-awk/index.js +36 -0
  444. package/dist/safe-bash-command-bc/index.d.ts +4 -0
  445. package/dist/safe-bash-command-bc/index.js +15 -176
  446. package/dist/safe-bash-command-column/column.js +3 -3
  447. package/dist/safe-bash-command-column/index.js +3 -3
  448. package/dist/safe-bash-command-column/layout.js +2 -2
  449. package/dist/safe-bash-command-csplit/command.js +2 -2
  450. package/dist/safe-bash-command-csplit/index.js +2 -2
  451. package/dist/safe-bash-command-csvkit/contracts.d.ts +1 -0
  452. package/dist/safe-bash-command-csvkit/csvpy-interpreter.d.ts +2 -1
  453. package/dist/safe-bash-command-csvkit/default-csvpy.d.ts +11 -0
  454. package/dist/safe-bash-command-csvkit/errors.js +22 -0
  455. package/dist/safe-bash-command-csvkit/index.d.ts +1 -0
  456. package/dist/safe-bash-command-csvkit/index.js +172 -4
  457. package/dist/safe-bash-command-csvkit/python-worker-browser.d.ts +3 -0
  458. package/dist/safe-bash-command-csvkit/python-worker-browser.js +16 -0
  459. package/dist/safe-bash-command-csvkit/python-worker-contract.d.ts +20 -0
  460. package/dist/safe-bash-command-csvkit/python-worker-node.d.ts +3 -0
  461. package/dist/safe-bash-command-csvkit/python-worker-node.js +9 -0
  462. package/dist/safe-bash-command-csvkit/runtime.d.ts +1 -0
  463. package/dist/safe-bash-command-curl/LICENSE +21 -0
  464. package/dist/safe-bash-command-curl/curl.d.ts +13 -0
  465. package/dist/safe-bash-command-curl/curl.js +9 -0
  466. package/dist/safe-bash-command-curl/index.d.ts +6 -0
  467. package/dist/safe-bash-command-curl/index.js +26 -0
  468. package/dist/safe-bash-command-diff/LICENSE +21 -0
  469. package/dist/safe-bash-command-diff/diff-format.d.ts +10 -0
  470. package/dist/safe-bash-command-diff/diff-format.js +10 -0
  471. package/dist/safe-bash-command-diff/diff-options.d.ts +38 -0
  472. package/dist/safe-bash-command-diff/diff-options.js +7 -0
  473. package/dist/safe-bash-command-diff/diff-output.d.ts +20 -0
  474. package/dist/safe-bash-command-diff/diff-output.js +19 -0
  475. package/dist/safe-bash-command-diff/diff.d.ts +2 -0
  476. package/dist/safe-bash-command-diff/diff.js +10 -0
  477. package/dist/safe-bash-command-diff/index.d.ts +8 -0
  478. package/dist/safe-bash-command-diff/index.js +34 -0
  479. package/dist/safe-bash-command-diff/sync.d.ts +2 -0
  480. package/dist/safe-bash-command-diff/sync.js +9 -0
  481. package/dist/safe-bash-command-diff3/index.js +5 -5
  482. package/dist/safe-bash-command-docx/index.d.ts +4 -4
  483. package/dist/safe-bash-command-docx/index.js +12 -5
  484. package/dist/safe-bash-command-dos2unix/index.d.ts +1 -0
  485. package/dist/safe-bash-command-dos2unix/index.js +225 -1
  486. package/dist/safe-bash-command-dos2unix/sync.d.ts +1 -0
  487. package/dist/safe-bash-command-exiftool/index.js +2 -2
  488. package/dist/safe-bash-command-factor/command.js +2 -2
  489. package/dist/safe-bash-command-factor/index.js +2 -2
  490. package/dist/safe-bash-command-ffmpeg/index.js +86 -94
  491. package/dist/safe-bash-command-file/index.js +3 -3
  492. package/dist/safe-bash-command-find/LICENSE +21 -0
  493. package/dist/safe-bash-command-find/find-format.d.ts +20 -0
  494. package/dist/safe-bash-command-find/find-format.js +9 -0
  495. package/dist/safe-bash-command-find/find.d.ts +18 -0
  496. package/dist/safe-bash-command-find/find.js +10 -0
  497. package/dist/safe-bash-command-find/index.d.ts +13 -0
  498. package/dist/safe-bash-command-find/index.js +45 -0
  499. package/dist/safe-bash-command-fmt/index.js +7 -4
  500. package/dist/safe-bash-command-git/git_rust.wasm +0 -0
  501. package/dist/safe-bash-command-git/index.js +5 -7
  502. package/dist/safe-bash-command-git/wasm.generated.js +1 -1
  503. package/dist/safe-bash-command-gzip/LICENSE +21 -0
  504. package/dist/safe-bash-command-gzip/index.d.ts +11 -0
  505. package/dist/safe-bash-command-gzip/index.js +94 -0
  506. package/dist/safe-bash-command-html-to-markdown/index.js +5 -5
  507. package/dist/safe-bash-command-htmlq/index.js +12 -8
  508. package/dist/safe-bash-command-imagemagick/index.js +22 -30
  509. package/dist/safe-bash-command-jq/index.js +1 -1
  510. package/dist/safe-bash-command-jq/jq.js +1 -1
  511. package/dist/safe-bash-command-llm/command.js +1 -1
  512. package/dist/safe-bash-command-llm/index.d.ts +1 -0
  513. package/dist/safe-bash-command-llm/index.js +16 -14
  514. package/dist/safe-bash-command-llm/openai.js +3 -3
  515. package/dist/safe-bash-command-llm/providers/index.js +3 -3
  516. package/dist/safe-bash-command-llm/providers/openai.js +3 -3
  517. package/dist/safe-bash-command-llm/stored-schema.d.ts +10 -0
  518. package/dist/safe-bash-command-mmdc/index.js +13 -604
  519. package/dist/safe-bash-command-mmdc/settings.d.ts +2 -0
  520. package/dist/safe-bash-command-mmdc/settings.js +7 -0
  521. package/dist/safe-bash-command-pandoc/command.js +4 -3
  522. package/dist/safe-bash-command-pandoc/defaults.d.ts +1 -0
  523. package/dist/safe-bash-command-pandoc/index.js +4 -3
  524. package/dist/safe-bash-command-pandoc/lua-filters.js +1 -1
  525. package/dist/safe-bash-command-pandoc/types.d.ts +3 -1
  526. package/dist/safe-bash-command-patch/LICENSE +21 -0
  527. package/dist/safe-bash-command-patch/index.d.ts +8 -0
  528. package/dist/safe-bash-command-patch/index.js +38 -0
  529. package/dist/safe-bash-command-patch/patch-envelope.d.ts +2 -0
  530. package/dist/safe-bash-command-patch/patch-envelope.js +7 -0
  531. package/dist/safe-bash-command-patch/patch-formats.d.ts +7 -0
  532. package/dist/safe-bash-command-patch/patch-formats.js +9 -0
  533. package/dist/safe-bash-command-patch/patch-gnu-paths.d.ts +41 -0
  534. package/dist/safe-bash-command-patch/patch-gnu-paths.js +26 -0
  535. package/dist/safe-bash-command-patch/patch-gnu-reject.d.ts +3 -0
  536. package/dist/safe-bash-command-patch/patch-gnu-reject.js +7 -0
  537. package/dist/safe-bash-command-patch/patch-path.d.ts +3 -0
  538. package/dist/safe-bash-command-patch/patch-path.js +11 -0
  539. package/dist/safe-bash-command-patch/patch-publication.d.ts +13 -0
  540. package/dist/safe-bash-command-patch/patch-publication.js +7 -0
  541. package/dist/safe-bash-command-patch/patch.d.ts +2 -0
  542. package/dist/safe-bash-command-patch/patch.js +14 -0
  543. package/dist/safe-bash-command-patch/sync.d.ts +2 -0
  544. package/dist/safe-bash-command-patch/sync.js +7 -0
  545. package/dist/safe-bash-command-patch/unified.d.ts +52 -0
  546. package/dist/safe-bash-command-patch/unified.js +16 -0
  547. package/dist/safe-bash-command-pdfimages/index.js +37 -16
  548. package/dist/safe-bash-command-pdfinfo/index.d.ts +0 -23
  549. package/dist/safe-bash-command-pdfinfo/index.js +20 -772
  550. package/dist/safe-bash-command-pdftk/index.js +37 -9
  551. package/dist/safe-bash-command-pdftoppm/index.js +50 -20
  552. package/dist/safe-bash-command-pdftotext/index.js +10 -2
  553. package/dist/safe-bash-command-pptx/index.d.ts +4 -4
  554. package/dist/safe-bash-command-pptx/index.js +11 -5
  555. package/dist/safe-bash-command-pr/command.js +2 -2
  556. package/dist/safe-bash-command-pr/index.js +4 -4
  557. package/dist/safe-bash-command-qpdf/index.js +26 -13
  558. package/dist/safe-bash-command-rg/index.d.ts +1 -0
  559. package/dist/safe-bash-command-rg/index.js +222 -1
  560. package/dist/safe-bash-command-rg/rg-command.js +1 -1
  561. package/dist/safe-bash-command-rg/sync.d.ts +1 -0
  562. package/dist/safe-bash-command-sed/LICENSE +21 -0
  563. package/dist/safe-bash-command-sed/index.d.ts +7 -0
  564. package/dist/safe-bash-command-sed/index.js +28 -0
  565. package/dist/safe-bash-command-sed/inplace.d.ts +16 -0
  566. package/dist/safe-bash-command-sed/inplace.js +9 -0
  567. package/dist/safe-bash-command-sed/sed.d.ts +3 -0
  568. package/dist/safe-bash-command-sed/sed.js +8 -0
  569. package/dist/safe-bash-command-sips/index.js +111 -35
  570. package/dist/safe-bash-command-soffice/index.js +4 -4
  571. package/dist/safe-bash-command-sqlite3/engine.d.ts +1 -2
  572. package/dist/safe-bash-command-sqlite3/index.js +152 -452
  573. package/dist/safe-bash-command-ssconvert/commands.js +1 -1
  574. package/dist/safe-bash-command-ssconvert/formats/ods.js +2 -2
  575. package/dist/safe-bash-command-ssconvert/formats/xlsx.js +3 -3
  576. package/dist/safe-bash-command-ssconvert/index.js +5 -5
  577. package/dist/safe-bash-command-tar/LICENSE +21 -0
  578. package/dist/safe-bash-command-tar/create.d.ts +17 -0
  579. package/dist/safe-bash-command-tar/create.js +14 -0
  580. package/dist/safe-bash-command-tar/extract.d.ts +11 -0
  581. package/dist/safe-bash-command-tar/extract.js +14 -0
  582. package/dist/safe-bash-command-tar/format.d.ts +32 -0
  583. package/dist/safe-bash-command-tar/format.js +19 -0
  584. package/dist/safe-bash-command-tar/index.d.ts +8 -0
  585. package/dist/safe-bash-command-tar/index.js +550 -0
  586. package/dist/safe-bash-command-tar/listing.d.ts +2 -0
  587. package/dist/safe-bash-command-tar/listing.js +7 -0
  588. package/dist/safe-bash-command-tar/modes.d.ts +5 -0
  589. package/dist/safe-bash-command-tar/modes.js +16 -0
  590. package/dist/safe-bash-command-tar/options.d.ts +53 -0
  591. package/dist/safe-bash-command-tar/options.js +10 -0
  592. package/dist/safe-bash-command-tar/stream.d.ts +22 -0
  593. package/dist/safe-bash-command-tar/stream.js +15 -0
  594. package/dist/safe-bash-command-tar/transform.d.ts +16 -0
  595. package/dist/safe-bash-command-tar/transform.js +9 -0
  596. package/dist/safe-bash-command-unzip/LICENSE +21 -0
  597. package/dist/safe-bash-command-unzip/index.d.ts +7 -0
  598. package/dist/safe-bash-command-unzip/index.js +39 -0
  599. package/dist/safe-bash-command-unzip/sync.d.ts +3 -0
  600. package/dist/safe-bash-command-unzip/sync.js +9 -0
  601. package/dist/safe-bash-command-unzip/unzip/safety.d.ts +32 -0
  602. package/dist/safe-bash-command-unzip/unzip/safety.js +7 -0
  603. package/dist/safe-bash-command-unzip/unzip.d.ts +3 -0
  604. package/dist/safe-bash-command-unzip/unzip.js +8 -0
  605. package/dist/safe-bash-command-wget/LICENSE +21 -0
  606. package/dist/safe-bash-command-wget/index.d.ts +6 -0
  607. package/dist/safe-bash-command-wget/index.js +26 -0
  608. package/dist/safe-bash-command-wget/wget.d.ts +3 -0
  609. package/dist/safe-bash-command-wget/wget.js +7 -0
  610. package/dist/safe-bash-command-xan/argv.d.ts +4 -1
  611. package/dist/safe-bash-command-xan/argv.js +1 -1
  612. package/dist/safe-bash-command-xan/commands.js +4 -3
  613. package/dist/safe-bash-command-xan/index.js +15 -14
  614. package/dist/safe-bash-command-xan/io.js +2 -2
  615. package/dist/safe-bash-command-xmllint/index.js +189 -49
  616. package/dist/safe-bash-command-xz/index.js +3 -2
  617. package/dist/safe-bash-command-xz/options.d.ts +9 -1
  618. package/dist/safe-bash-command-xz/options.js +3 -1
  619. package/dist/safe-bash-command-yq/index.d.ts +4 -11
  620. package/dist/safe-bash-command-yq/index.js +3367 -670
  621. package/dist/safe-bash-command-yq/mike.js +6 -13
  622. package/dist/safe-bash-command-yq/native-work.d.ts +1 -0
  623. package/dist/safe-bash-command-yq/native-work.js +17 -0
  624. package/dist/safe-bash-command-yq/query.d.ts +11 -0
  625. package/dist/safe-bash-command-yq/query.js +735 -0
  626. package/dist/safe-bash-command-zip/LICENSE +21 -0
  627. package/dist/safe-bash-command-zip/index.d.ts +7 -0
  628. package/dist/safe-bash-command-zip/index.js +38 -0
  629. package/dist/safe-bash-command-zip/sync.d.ts +3 -0
  630. package/dist/safe-bash-command-zip/sync.js +9 -0
  631. package/dist/safe-bash-command-zip/zip.d.ts +3 -0
  632. package/dist/safe-bash-command-zip/zip.js +7 -0
  633. package/dist/safe-bash-compression-engine/files.js +4 -4
  634. package/dist/safe-bash-compression-engine/index.js +2 -2
  635. package/dist/safe-bash-compression-engine/operand.js +6 -6
  636. package/dist/safe-bash-compression-engine/stream.js +2 -2
  637. package/dist/safe-bash-compression-engine/zstd-decode.js +1 -1
  638. package/dist/safe-bash-contracts/command.js +1 -1
  639. package/dist/safe-bash-contracts/diagnostics.js +4 -4
  640. package/dist/safe-bash-contracts/escaping.js +11 -11
  641. package/dist/safe-bash-contracts/filesystem-descriptor.js +1 -1
  642. package/dist/safe-bash-contracts/filesystem-output.js +8 -8
  643. package/dist/safe-bash-contracts/index.js +34 -34
  644. package/dist/safe-bash-contracts/io.js +2 -2
  645. package/dist/safe-bash-contracts/output.js +3 -3
  646. package/dist/safe-bash-diff-engine/LICENSE +21 -0
  647. package/dist/safe-bash-diff-engine/index.d.ts +1 -0
  648. package/dist/safe-bash-diff-engine/index.js +24 -0
  649. package/dist/safe-bash-diff-engine/shared.d.ts +53 -0
  650. package/dist/safe-bash-diff-engine/shared.js +19 -0
  651. package/dist/safe-bash-io-engine/commands/directory-admission.d.ts +3 -0
  652. package/dist/safe-bash-io-engine/commands/directory-admission.js +34 -0
  653. package/dist/safe-bash-io-engine/commands/mode-change.d.ts +4 -0
  654. package/dist/safe-bash-io-engine/commands/mode-change.js +60 -0
  655. package/dist/safe-bash-io-engine/commands/text-programs/shared.js +20 -31
  656. package/dist/safe-bash-io-engine/shell/pattern.js +7 -12
  657. package/dist/safe-bash-markdown-engine/commonmark-blocks.js +4 -4
  658. package/dist/safe-bash-markdown-engine/commonmark-inlines.js +4 -4
  659. package/dist/safe-bash-markdown-engine/commonmark-syntax.js +2 -2
  660. package/dist/safe-bash-markdown-engine/gfm-syntax.js +3 -3
  661. package/dist/safe-bash-markdown-engine/index.js +7 -7
  662. package/dist/safe-bash-mcp/index.browser.d.ts +6 -0
  663. package/dist/safe-bash-mcp/index.browser.js +1 -0
  664. package/dist/safe-bash-mcp/index.d.ts +12 -0
  665. package/dist/safe-bash-mcp/index.js +1558 -36
  666. package/dist/safe-bash-network-engine/LICENSE +21 -0
  667. package/dist/safe-bash-network-engine/aggregate.d.ts +4 -0
  668. package/dist/safe-bash-network-engine/aggregate.js +37 -0
  669. package/dist/safe-bash-network-engine/args.d.ts +68 -0
  670. package/dist/safe-bash-network-engine/args.js +19 -0
  671. package/dist/safe-bash-network-engine/authorizer.d.ts +6 -0
  672. package/dist/safe-bash-network-engine/authorizer.js +8 -0
  673. package/dist/safe-bash-network-engine/body.d.ts +9 -0
  674. package/dist/safe-bash-network-engine/body.js +374 -0
  675. package/dist/safe-bash-network-engine/deadline.d.ts +2 -0
  676. package/dist/safe-bash-network-engine/deadline.js +7 -0
  677. package/dist/safe-bash-network-engine/decode.d.ts +2 -0
  678. package/dist/safe-bash-network-engine/decode.js +81 -0
  679. package/dist/safe-bash-network-engine/fetch-transport.d.ts +7 -0
  680. package/dist/safe-bash-network-engine/fetch-transport.js +9 -0
  681. package/dist/safe-bash-network-engine/form-content-type.d.ts +5 -0
  682. package/dist/safe-bash-network-engine/form-content-type.js +8 -0
  683. package/dist/safe-bash-network-engine/form-headers.d.ts +2 -0
  684. package/dist/safe-bash-network-engine/form-headers.js +10 -0
  685. package/dist/safe-bash-network-engine/glob.d.ts +7 -0
  686. package/dist/safe-bash-network-engine/glob.js +124 -0
  687. package/dist/safe-bash-network-engine/index.d.ts +3 -0
  688. package/dist/safe-bash-network-engine/index.js +26 -0
  689. package/dist/safe-bash-network-engine/input.d.ts +5 -0
  690. package/dist/safe-bash-network-engine/input.js +255 -0
  691. package/dist/safe-bash-network-engine/output.d.ts +6 -0
  692. package/dist/safe-bash-network-engine/output.js +132 -0
  693. package/dist/safe-bash-network-engine/platform-portable.d.ts +5 -0
  694. package/dist/safe-bash-network-engine/platform-portable.js +19 -0
  695. package/dist/safe-bash-network-engine/private-address.d.ts +1 -0
  696. package/dist/safe-bash-network-engine/private-address.js +7 -0
  697. package/dist/safe-bash-network-engine/shared.d.ts +14 -0
  698. package/dist/safe-bash-network-engine/shared.js +23 -0
  699. package/dist/safe-bash-network-engine/types.d.ts +37 -0
  700. package/dist/safe-bash-network-engine/types.js +11 -0
  701. package/dist/safe-bash-network-engine/url.d.ts +2 -0
  702. package/dist/safe-bash-network-engine/url.js +8 -0
  703. package/dist/safe-bash-query-engine/capture.d.ts +1 -0
  704. package/dist/safe-bash-query-engine/capture.js +9 -7
  705. package/dist/safe-bash-query-engine/dates.d.ts +5 -1
  706. package/dist/safe-bash-query-engine/dates.js +10 -2
  707. package/dist/safe-bash-query-engine/delpaths.js +5 -5
  708. package/dist/safe-bash-query-engine/formats.js +3 -3
  709. package/dist/safe-bash-query-engine/index.js +15 -15
  710. package/dist/safe-bash-query-engine/indices.js +5 -5
  711. package/dist/safe-bash-query-engine/input.d.ts +1 -2
  712. package/dist/safe-bash-query-engine/input.js +2 -4
  713. package/dist/safe-bash-query-engine/interpreter.d.ts +5 -0
  714. package/dist/safe-bash-query-engine/interpreter.js +13 -13
  715. package/dist/safe-bash-query-engine/limits.js +1 -1
  716. package/dist/safe-bash-query-engine/parser.d.ts +8 -1
  717. package/dist/safe-bash-query-engine/parser.js +2 -2
  718. package/dist/safe-bash-query-engine/query-core.js +15 -15
  719. package/dist/safe-bash-query-engine/recurse.js +2 -2
  720. package/dist/safe-bash-query-engine/regex.d.ts +4 -2
  721. package/dist/safe-bash-query-engine/regex.js +10 -5
  722. package/dist/safe-bash-query-engine/split.js +2 -2
  723. package/dist/safe-bash-query-engine/splits.d.ts +1 -1
  724. package/dist/safe-bash-query-engine/splits.js +7 -6
  725. package/dist/safe-bash-query-engine/values.js +4 -4
  726. package/dist/safe-bash-regex-engine/ere/matcher.js +4 -4
  727. package/dist/safe-bash-regex-engine/index.js +2 -2
  728. package/dist/safe-bash-regex-engine/text/regex.d.ts +1 -0
  729. package/dist/safe-bash-regex-engine/text/regex.js +2 -2
  730. package/dist/safe-bash-search-engine/ergonomic-regex.d.ts +12 -2
  731. package/dist/safe-bash-search-engine/ergonomic-regex.js +2 -2
  732. package/dist/safe-bash-search-engine/glob.js +2 -2
  733. package/dist/safe-bash-search-engine/grep.js +2 -2
  734. package/dist/safe-bash-search-engine/matcher.d.ts +6 -2
  735. package/dist/safe-bash-search-engine/matcher.js +30 -8
  736. package/dist/safe-bash-search-engine/options.js +1 -1
  737. package/dist/safe-bash-search-engine/output.d.ts +3 -2
  738. package/dist/safe-bash-search-engine/output.js +111 -30
  739. package/dist/safe-bash-search-engine/shared.d.ts +2 -0
  740. package/dist/safe-bash-search-engine/shared.js +2 -2
  741. package/dist/safe-bash-search-engine/walk.js +11 -10
  742. package/dist/safe-bash-xml-engine/document.d.ts +1 -1
  743. package/dist/safe-bash-xml-engine/document.js +3 -3
  744. package/dist/safe-bash-xml-engine/evaluate.d.ts +1 -0
  745. package/dist/safe-bash-xml-engine/evaluate.js +4 -1
  746. package/dist/safe-bash-xml-engine/index.js +8 -6
  747. package/dist/safe-bash-xml-engine/io.js +1 -1
  748. package/dist/safe-bash-xml-engine/limits.d.ts +2 -0
  749. package/dist/safe-bash-xml-engine/limits.js +1 -1
  750. package/dist/safe-bash-xml-engine/predicate.d.ts +57 -0
  751. package/dist/safe-bash-xml-engine/query.d.ts +3 -15
  752. package/dist/safe-bash-xml-engine/query.js +3 -2
  753. package/dist/safe-bash-zip-engine/LICENSE +21 -0
  754. package/dist/safe-bash-zip-engine/index.d.ts +1 -0
  755. package/dist/safe-bash-zip-engine/index.js +32 -0
  756. package/dist/safe-bash-zip-engine/unzip/arguments.d.ts +53 -0
  757. package/dist/safe-bash-zip-engine/unzip/arguments.js +270 -0
  758. package/dist/safe-bash-zip-engine/zip/aes.d.ts +17 -0
  759. package/dist/safe-bash-zip-engine/zip/aes.js +15 -0
  760. package/dist/safe-bash-zip-engine/zip/comments.d.ts +17 -0
  761. package/dist/safe-bash-zip-engine/zip/comments.js +77 -0
  762. package/dist/safe-bash-zip-engine/zip/crc.d.ts +1 -0
  763. package/dist/safe-bash-zip-engine/zip/crc.js +7 -0
  764. package/dist/safe-bash-zip-engine/zip/crypto.d.ts +19 -0
  765. package/dist/safe-bash-zip-engine/zip/crypto.js +16 -0
  766. package/dist/safe-bash-zip-engine/zip/dates.d.ts +4 -0
  767. package/dist/safe-bash-zip-engine/zip/dates.js +68 -0
  768. package/dist/safe-bash-zip-engine/zip/environment.d.ts +2 -0
  769. package/dist/safe-bash-zip-engine/zip/environment.js +60 -0
  770. package/dist/safe-bash-zip-engine/zip/grow.d.ts +3 -0
  771. package/dist/safe-bash-zip-engine/zip/grow.js +7 -0
  772. package/dist/safe-bash-zip-engine/zip/help.d.ts +4 -0
  773. package/dist/safe-bash-zip-engine/zip/help.js +194 -0
  774. package/dist/safe-bash-zip-engine/zip/line-endings.d.ts +2 -0
  775. package/dist/safe-bash-zip-engine/zip/line-endings.js +165 -0
  776. package/dist/safe-bash-zip-engine/zip/log.d.ts +22 -0
  777. package/dist/safe-bash-zip-engine/zip/log.js +153 -0
  778. package/dist/safe-bash-zip-engine/zip/lzma.d.ts +9 -0
  779. package/dist/safe-bash-zip-engine/zip/lzma.js +7 -0
  780. package/dist/safe-bash-zip-engine/zip/move.d.ts +11 -0
  781. package/dist/safe-bash-zip-engine/zip/move.js +57 -0
  782. package/dist/safe-bash-zip-engine/zip/names.d.ts +2 -0
  783. package/dist/safe-bash-zip-engine/zip/names.js +37 -0
  784. package/dist/safe-bash-zip-engine/zip/options.d.ts +13 -0
  785. package/dist/safe-bash-zip-engine/zip/options.js +23 -0
  786. package/dist/safe-bash-zip-engine/zip/repair.d.ts +10 -0
  787. package/dist/safe-bash-zip-engine/zip/repair.js +348 -0
  788. package/dist/safe-bash-zip-engine/zip/safety.d.ts +54 -0
  789. package/dist/safe-bash-zip-engine/zip/safety.js +19 -0
  790. package/dist/safe-bash-zip-engine/zip/sfx.d.ts +4 -0
  791. package/dist/safe-bash-zip-engine/zip/sfx.js +58 -0
  792. package/dist/safe-bash-zip-engine/zip/test-command.d.ts +5 -0
  793. package/dist/safe-bash-zip-engine/zip/test-command.js +98 -0
  794. package/dist/safe-bash-zip-engine/zip/volumes.d.ts +21 -0
  795. package/dist/safe-bash-zip-engine/zip/volumes.js +255 -0
  796. package/dist/safe-bash-zip-engine/zip/zip64.d.ts +30 -0
  797. package/dist/safe-bash-zip-engine/zip/zip64.js +25 -0
  798. package/dist/safe-bash-zip-engine/zip-format.d.ts +68 -0
  799. package/dist/safe-bash-zip-engine/zip-format.js +27 -0
  800. package/dist/safe-playwright-cloudflare/browser-codegen.generated.d.ts +7 -7
  801. package/dist/safe-playwright-cloudflare/browser-codegen.generated.js +866 -8069
  802. package/dist/safe-playwright-cloudflare/browser-run-code-budget.d.ts +0 -1
  803. package/dist/safe-playwright-cloudflare/browser-run-code-budget.js +0 -2
  804. package/dist/safe-playwright-cloudflare/browser-trace-archive.d.ts +5 -1
  805. package/dist/safe-playwright-cloudflare/browser-trace-archive.js +2 -1
  806. package/dist/safe-playwright-cloudflare/browser-trace-budget.js +2 -2
  807. package/dist/safe-playwright-cloudflare/shell-browser-resource.d.ts +2 -0
  808. package/dist/safe-playwright-cloudflare/shell-browser-resource.js +3 -11
  809. package/dist/safe-playwright-cloudflare/shell-playwright.d.ts +2 -0
  810. package/dist/safe-playwright-cloudflare/shell-playwright.js +1 -1
  811. package/dist/spreadsheet-engine/io/publication.d.ts +1 -0
  812. package/package.json +163 -14
  813. package/dist/safe-bash/chunks/chunk-AZAJJVFX.js +0 -23017
  814. package/dist/safe-bash/chunks/chunk-O4ZUCRGN.js +0 -13
  815. package/dist/safe-bash/chunks/chunk-S264DZO2.js +0 -243
  816. package/dist/safe-bash/chunks/chunk-WVG5SHHQ.js +0 -12
  817. package/dist/safe-bash/chunks/chunk-ZW6K2J7P.js +0 -2652
  818. package/dist/safe-bash/command-chunks/chunk-5MPOQ6V3.js +0 -181
  819. package/dist/safe-bash/command-chunks/chunk-BIXLZ3OG.js +0 -14342
  820. package/dist/safe-bash/command-chunks/chunk-DUYJE2HY.js +0 -14
  821. package/dist/safe-bash/command-chunks/chunk-NETECMOF.js +0 -40
  822. package/dist/safe-bash/command-chunks/chunk-XS3PGJU2.js +0 -343
  823. package/dist/safe-bash/command-chunks/chunk-XTZALMLR.js +0 -488
  824. package/dist/safe-bash/commands/archive/zip/aes-primitives-unavailable.d.ts +0 -2
  825. package/dist/safe-bash/commands/archive/zip/aes-primitives-unavailable.js +0 -3
  826. package/dist/safe-bash/commands/archive/zip/aes-primitives.d.ts +0 -2
  827. package/dist/safe-bash/commands/archive/zip/aes-primitives.js +0 -3
  828. package/dist/safe-bash/commands/xml/document.d.ts +0 -2
  829. package/dist/safe-bash/commands/xml/document.js +0 -2
  830. package/dist/safe-bash/commands/xml/evaluate.d.ts +0 -2
  831. package/dist/safe-bash/commands/xml/evaluate.js +0 -2
  832. package/dist/safe-bash/commands/xml/json.d.ts +0 -2
  833. package/dist/safe-bash/commands/xml/json.js +0 -2
  834. package/dist/safe-bash/commands/xml/limits.d.ts +0 -2
  835. package/dist/safe-bash/commands/xml/limits.js +0 -2
  836. package/dist/safe-bash/commands/xml/query.d.ts +0 -2
  837. package/dist/safe-bash/commands/xml/query.js +0 -2
  838. package/dist/safe-bash/chunks/{chunk-NHOXKQNE.js → chunk-QVSRRNZT.js} +3 -3
  839. package/dist/safe-bash/command-chunks/{chunk-FIUFIDAO.js → chunk-2JRBIDAD.js} +3 -3
  840. package/dist/safe-bash/command-chunks/{chunk-B5BKA5WH.js → chunk-B5TAOCKD.js} +3 -3
  841. package/dist/safe-bash/command-chunks/{chunk-TYVCKQDH.js → chunk-J5SN3PZ3.js} +3 -3
  842. package/dist/safe-bash/command-chunks/{chunk-2ENZ6JGA.js → chunk-KEV7C3KH.js} +3 -3
  843. package/dist/safe-bash/command-chunks/{chunk-S62HELHU.js → chunk-PL6O4K6W.js} +3 -3
  844. package/dist/safe-bash/command-chunks/{chunk-2WRTLCGK.js → chunk-QZF3SINC.js} +4 -4
  845. package/dist/safe-bash/command-chunks/{chunk-X7TM3AKW.js → chunk-U6G67N23.js} +3 -3
  846. package/dist/safe-bash/command-chunks/{chunk-DDLQ5YDB.js → chunk-YHFXOX6U.js} +9 -9
  847. package/dist/safe-bash/command-chunks/{chunk-DQMOM72Z.js → chunk-ZRRBXU3M.js} +4 -4
@@ -1,16 +1,18 @@
1
1
  import {
2
2
  evalSyncYqPrep,
3
3
  formatSyncYqYamlLines
4
- } from "./chunk-AKC46AF6.js";
4
+ } from "./chunk-7YSRXFEG.js";
5
+ import {
6
+ captureIgnoredTrapSignals,
7
+ defaultPortableTrapExtension,
8
+ isIdlePortableTrapInstance
9
+ } from "./chunk-LUOFIVNI.js";
5
10
  import {
6
11
  abortManagedController,
7
12
  addAbortSignalWaiter,
8
- clearAwkReaderPool,
13
+ bindFileOutputBudget,
9
14
  clearRgFastRunnerPool,
10
15
  combineManagedSignals,
11
- compare,
12
- compilePattern,
13
- compilePatternBoundaries,
14
16
  createBcCommands,
15
17
  createCalCommands,
16
18
  createDdCommands,
@@ -71,28 +73,21 @@ import {
71
73
  formatPrintf,
72
74
  getRuntimeBackingFileSystem,
73
75
  gnuInformationSync,
74
- inputValue,
75
76
  interruptible,
76
77
  isManagedAbortSignal,
77
78
  isSyncResolved,
78
- matchesPattern,
79
- number,
80
- numeric,
79
+ openFileOutput,
81
80
  parseFmtArguments,
82
81
  preverifyMemoryRgTree,
83
82
  printfCommand,
84
83
  registerManagedAbortSignal,
85
84
  removeAbortSignalWaiter,
86
- settings,
87
- string,
88
- text,
89
85
  tryFastEcho,
90
86
  tryFastPredicate,
91
87
  tryFastPrintf,
92
- tryMatchesPatternSync,
93
88
  variablePresence,
94
89
  wcDisplayWidth
95
- } from "./chunk-AZAJJVFX.js";
90
+ } from "./chunk-K4YMYFRJ.js";
96
91
  import {
97
92
  evalSyncGetopt
98
93
  } from "./chunk-3L3T6LYV.js";
@@ -101,39 +96,28 @@ import {
101
96
  } from "./chunk-H6JW3E4F.js";
102
97
  import {
103
98
  evalSyncLineEndings
104
- } from "./chunk-S264DZO2.js";
99
+ } from "./chunk-4SEW2Q6H.js";
105
100
  import {
106
101
  evalSyncMdq
107
- } from "./chunk-B3DDEDH2.js";
102
+ } from "./chunk-PPYM75Z3.js";
108
103
  import {
109
104
  evalSyncXmllint,
110
105
  evalSyncXq
111
106
  } from "./chunk-K7IQZE7D.js";
112
- import {
113
- bindFileOutputBudget,
114
- openFileOutput
115
- } from "./chunk-O4ZUCRGN.js";
116
107
  import {
117
108
  PublicDiagnostic,
118
- publicDiagnosticMessage
119
- } from "./chunk-WVG5SHHQ.js";
120
- import {
109
+ publicDiagnosticMessage,
121
110
  writeDiagnostic
122
- } from "./chunk-T5KKDMYB.js";
123
- import {
124
- evalSyncPr
125
- } from "./chunk-F3RV2F72.js";
126
- import {
127
- captureIgnoredTrapSignals,
128
- defaultPortableTrapExtension,
129
- isIdlePortableTrapInstance
130
- } from "./chunk-LUOFIVNI.js";
111
+ } from "./chunk-TYD7EVUJ.js";
131
112
  import {
132
113
  bytesToHex,
133
114
  compareUtf8,
134
115
  latin1Bytes,
135
116
  latin1Text
136
- } from "./chunk-KTGR4U57.js";
117
+ } from "./chunk-BHJE5LPZ.js";
118
+ import {
119
+ evalSyncPr
120
+ } from "./chunk-F3RV2F72.js";
137
121
  import {
138
122
  EreLedger,
139
123
  EreProfileLimitError,
@@ -146,7 +130,7 @@ import {
146
130
  } from "./chunk-XB3B7KMM.js";
147
131
  import {
148
132
  jobsExtension
149
- } from "./chunk-NHOXKQNE.js";
133
+ } from "./chunk-QVSRRNZT.js";
150
134
  import {
151
135
  concatShellValues,
152
136
  shellValueByteLength,
@@ -161,7 +145,7 @@ import {
161
145
  import {
162
146
  FsError,
163
147
  isFsError
164
- } from "./chunk-IUTD5FH5.js";
148
+ } from "./chunk-46UISJCK.js";
165
149
  import {
166
150
  basename,
167
151
  cancelTurn,
@@ -177,13 +161,6 @@ import {
177
161
  scheduleTurn,
178
162
  yieldTurn
179
163
  } from "./chunk-VYZTG3GV.js";
180
- import {
181
- CommandRegistry,
182
- commandRuntimeIdentity,
183
- createCommandArguments,
184
- getCommandArguments,
185
- validateExitCode
186
- } from "./chunk-LQHGH25W.js";
187
164
  import {
188
165
  createBytePipe,
189
166
  outputFailure,
@@ -192,6 +169,13 @@ import {
192
169
  writeBytes,
193
170
  writeText
194
171
  } from "./chunk-PYVEAFJM.js";
172
+ import {
173
+ CommandRegistry,
174
+ commandRuntimeIdentity,
175
+ createCommandArguments,
176
+ getCommandArguments,
177
+ validateExitCode
178
+ } from "./chunk-LQHGH25W.js";
195
179
  import {
196
180
  RESOLVED_EXIT_ONE,
197
181
  RESOLVED_EXIT_ZERO,
@@ -201,7 +185,7 @@ import {
201
185
  registerDefaultExecutor,
202
186
  registerDefaultExecutors,
203
187
  syncCommandEvaluators
204
- } from "./chunk-ENR3HB2B.js";
188
+ } from "./chunk-NLAW7KDI.js";
205
189
  import {
206
190
  init_platform
207
191
  } from "./chunk-YG5WAHK7.js";
@@ -366,33 +350,33 @@ function treeFeatures(tree) {
366
350
  }
367
351
  return { hasSubscript, hasMutation };
368
352
  }
369
- function fastDecimalLiteral(text2, budget) {
370
- if (text2 === void 0 || text2 === "0") {
353
+ function fastDecimalLiteral(text3, budget) {
354
+ if (text3 === void 0 || text3 === "0") {
371
355
  budget.admit(2);
372
356
  return 0n;
373
357
  }
374
- if (text2 === "") {
358
+ if (text3 === "") {
375
359
  budget.admit(1);
376
360
  return 0n;
377
361
  }
378
- const len = text2.length;
362
+ const len = text3.length;
379
363
  if (len > 16) return void 0;
380
364
  let start = 0;
381
365
  let negative = false;
382
- if (text2.charCodeAt(0) === 45) {
366
+ if (text3.charCodeAt(0) === 45) {
383
367
  if (len === 1) return void 0;
384
- if (text2 === "-0") {
368
+ if (text3 === "-0") {
385
369
  budget.admit(4);
386
370
  return 0n;
387
371
  }
388
372
  negative = true;
389
373
  start = 1;
390
374
  }
391
- const first = text2.charCodeAt(start);
375
+ const first = text3.charCodeAt(start);
392
376
  if (first < 49 || first > 57) return void 0;
393
377
  let num = first - 48;
394
378
  for (let i = start + 1; i < len; i++) {
395
- const code = text2.charCodeAt(i);
379
+ const code = text3.charCodeAt(i);
396
380
  if (code < 48 || code > 57) return void 0;
397
381
  num = num * 10 + (code - 48);
398
382
  }
@@ -474,12 +458,12 @@ var precedence = {
474
458
  "%": 13,
475
459
  "**": 14
476
460
  };
477
- function integer(text2) {
478
- if (/^0[xX][\da-fA-F]+$/u.test(text2)) return BigInt(text2);
479
- if (/^0[0-7]+$/u.test(text2)) return BigInt(`0o${text2.slice(1)}`);
480
- if (/^0\d+$/u.test(text2)) throw new PublicDiagnostic("Invalid octal constant");
481
- if (/^\d+$/u.test(text2)) return BigInt(text2);
482
- const match = /^(\d+)#([\da-zA-Z@_]+)$/u.exec(text2);
461
+ function integer(text3) {
462
+ if (/^0[xX][\da-fA-F]+$/u.test(text3)) return BigInt(text3);
463
+ if (/^0[0-7]+$/u.test(text3)) return BigInt(`0o${text3.slice(1)}`);
464
+ if (/^0\d+$/u.test(text3)) throw new PublicDiagnostic("Invalid octal constant");
465
+ if (/^\d+$/u.test(text3)) return BigInt(text3);
466
+ const match = /^(\d+)#([\da-zA-Z@_]+)$/u.exec(text3);
483
467
  if (!match) throw new PublicDiagnostic("Invalid arithmetic constant");
484
468
  const base = Number(match[1]);
485
469
  if (base < 2 || base > 64) throw new PublicDiagnostic("Invalid arithmetic base");
@@ -733,33 +717,33 @@ function intToStr(n) {
733
717
  LARGE_INT_STRS[slot] = s;
734
718
  return s;
735
719
  }
736
- function fastSafeInt(text2, budget) {
737
- if (text2 === void 0 || text2 === "0") {
720
+ function fastSafeInt(text3, budget) {
721
+ if (text3 === void 0 || text3 === "0") {
738
722
  budget.admit(2);
739
723
  return 0;
740
724
  }
741
- if (text2 === "") {
725
+ if (text3 === "") {
742
726
  budget.admit(1);
743
727
  return 0;
744
728
  }
745
- const len = text2.length;
729
+ const len = text3.length;
746
730
  if (len > 8) return void 0;
747
731
  let start = 0;
748
732
  let negative = false;
749
- if (text2.charCodeAt(0) === 45) {
733
+ if (text3.charCodeAt(0) === 45) {
750
734
  if (len === 1) return void 0;
751
- if (text2 === "-0") {
735
+ if (text3 === "-0") {
752
736
  budget.admit(4);
753
737
  return 0;
754
738
  }
755
739
  negative = true;
756
740
  start = 1;
757
741
  }
758
- const first = text2.charCodeAt(start);
742
+ const first = text3.charCodeAt(start);
759
743
  if (first < 49 || first > 57) return void 0;
760
744
  let num = first - 48;
761
745
  for (let i = start + 1; i < len; i++) {
762
- const code = text2.charCodeAt(i);
746
+ const code = text3.charCodeAt(i);
763
747
  if (code < 48 || code > 57) return void 0;
764
748
  num = num * 10 + (code - 48);
765
749
  }
@@ -797,8 +781,8 @@ function evalSafeSmi(node, refs, budget) {
797
781
  if (node.kind === "literal") return Number(node.value);
798
782
  if (node.kind === "name") {
799
783
  const ref = refs.resolve(node.name, node.subscript);
800
- const text2 = refs.read(ref);
801
- return fastSafeInt(text2, budget);
784
+ const text3 = refs.read(ref);
785
+ return fastSafeInt(text3, budget);
802
786
  }
803
787
  if (node.kind === "unary") {
804
788
  if (node.operator === "++" || node.operator === "--") {
@@ -954,13 +938,13 @@ function evaluateArithmeticSync(program, references, budget) {
954
938
  const evalNameValue = (node, depth) => {
955
939
  const reference = references.resolve(node.name, node.subscript);
956
940
  if (visiting?.has(reference)) throw new PublicDiagnostic("Arithmetic variable recursion");
957
- const text2 = references.read(reference);
958
- const fast = fastDecimalLiteral(text2, budget);
941
+ const text3 = references.read(reference);
942
+ const fast = fastDecimalLiteral(text3, budget);
959
943
  if (fast !== void 0) return fast;
960
944
  visiting ??= /* @__PURE__ */ new Set();
961
945
  visiting.add(reference);
962
946
  try {
963
- return evalNode(parseArithmetic(text2 ?? "0", 0, budget), depth + 1);
947
+ return evalNode(parseArithmetic(text3 ?? "0", 0, budget), depth + 1);
964
948
  } finally {
965
949
  visiting.delete(reference);
966
950
  }
@@ -968,13 +952,13 @@ function evaluateArithmeticSync(program, references, budget) {
968
952
  const evalName = (node, depth) => {
969
953
  const reference = references.resolve(node.name, node.subscript);
970
954
  if (visiting?.has(reference)) throw new PublicDiagnostic("Arithmetic variable recursion");
971
- const text2 = references.read(reference);
972
- const fast = fastDecimalLiteral(text2, budget);
955
+ const text3 = references.read(reference);
956
+ const fast = fastDecimalLiteral(text3, budget);
973
957
  if (fast !== void 0) return { reference, value: fast };
974
958
  visiting ??= /* @__PURE__ */ new Set();
975
959
  visiting.add(reference);
976
960
  try {
977
- return { reference, value: evalNode(parseArithmetic(text2 ?? "0", 0, budget), depth + 1) };
961
+ return { reference, value: evalNode(parseArithmetic(text3 ?? "0", 0, budget), depth + 1) };
978
962
  } finally {
979
963
  visiting.delete(reference);
980
964
  }
@@ -1105,13 +1089,13 @@ function* arithmeticEvaluation(program, references, budget) {
1105
1089
  const reference = yield references.resolve(node.name, node.subscript);
1106
1090
  resolved.set(node, reference);
1107
1091
  if (visiting.has(reference)) throw new PublicDiagnostic("Arithmetic variable recursion");
1108
- const text2 = yield references.read(reference);
1109
- const fast = fastDecimalLiteral(text2, budget);
1092
+ const text3 = yield references.read(reference);
1093
+ const fast = fastDecimalLiteral(text3, budget);
1110
1094
  if (fast !== void 0) {
1111
1095
  value = fast;
1112
1096
  } else {
1113
1097
  visiting.add(reference);
1114
- pending.push({ kind: "variable", name: reference }, { kind: "evaluate", node: parseArithmetic(text2 ?? "0", 0, budget) });
1098
+ pending.push({ kind: "variable", name: reference }, { kind: "evaluate", node: parseArithmetic(text3 ?? "0", 0, budget) });
1115
1099
  }
1116
1100
  } else if (node.kind === "conditional") {
1117
1101
  pending.push({ kind: "conditional", node }, { kind: "evaluate", node: node.condition });
@@ -1684,6 +1668,10 @@ import { ACCESS_MODES } from "../../safe-bash-contracts/filesystem.js";
1684
1668
  init_platform();
1685
1669
  import { composeMiddleware } from "../../safe-bash-contracts/plugin.js";
1686
1670
 
1671
+ // packages/safe-bash/src/shell/pattern.ts
1672
+ init_platform();
1673
+ import { compilePattern, compilePatternBoundaries, matchesPattern, tryMatchesPatternSync } from "../../safe-bash-io-engine/shell/pattern.js";
1674
+
1687
1675
  // packages/safe-bash/src/shell/locale.ts
1688
1676
  init_platform();
1689
1677
  function byteLocale(variables) {
@@ -2280,23 +2268,23 @@ var Lexer = class {
2280
2268
  }
2281
2269
  }
2282
2270
  *documentWords() {
2283
- let text2 = "";
2271
+ let text3 = "";
2284
2272
  while (this.position < this.source.length) {
2285
2273
  const current = this.source[this.position];
2286
2274
  const opaque = this.sourceValues?.get(this.sourceOffset + this.position);
2287
2275
  if (opaque !== void 0) {
2288
- if (text2) {
2276
+ if (text3) {
2289
2277
  this.budget.admit(2);
2290
- yield { offset: 0, parts: [{ kind: "text", value: text2, quoted: true, ...this.byteSource ? { byteValue: shellValueFromBytes(latin1Bytes(text2)) } : {} }] };
2291
- text2 = "";
2278
+ yield { offset: 0, parts: [{ kind: "text", value: text3, quoted: true, ...this.byteSource ? { byteValue: shellValueFromBytes(latin1Bytes(text3)) } : {} }] };
2279
+ text3 = "";
2292
2280
  }
2293
2281
  this.budget.admit(2);
2294
2282
  yield { offset: this.position++, parts: [{ kind: "text", value: shellValueText(opaque), byteValue: opaque, quoted: true }] };
2295
2283
  } else if (current === "$" || current === "`") {
2296
- if (text2) {
2284
+ if (text3) {
2297
2285
  this.budget.admit(2);
2298
- yield { offset: 0, parts: [{ kind: "text", value: text2, quoted: true, ...this.byteSource ? { byteValue: shellValueFromBytes(latin1Bytes(text2)) } : {} }] };
2299
- text2 = "";
2286
+ yield { offset: 0, parts: [{ kind: "text", value: text3, quoted: true, ...this.byteSource ? { byteValue: shellValueFromBytes(latin1Bytes(text3)) } : {} }] };
2287
+ text3 = "";
2300
2288
  }
2301
2289
  const offset = this.position;
2302
2290
  this.budget.admit();
@@ -2316,21 +2304,21 @@ var Lexer = class {
2316
2304
  }
2317
2305
  yield { offset, parts };
2318
2306
  } else if (current === "\\" && /[$`\\]/u.test(this.source[this.position + 1] ?? "")) {
2319
- text2 += this.source[this.position + 1];
2307
+ text3 += this.source[this.position + 1];
2320
2308
  this.position += 2;
2321
2309
  } else {
2322
- text2 += current;
2310
+ text3 += current;
2323
2311
  this.position++;
2324
2312
  }
2325
- if (text2.length >= 1024) {
2313
+ if (text3.length >= 1024) {
2326
2314
  this.budget.admit(2);
2327
- yield { offset: 0, parts: [{ kind: "text", value: text2, quoted: true, ...this.byteSource ? { byteValue: shellValueFromBytes(latin1Bytes(text2)) } : {} }] };
2328
- text2 = "";
2315
+ yield { offset: 0, parts: [{ kind: "text", value: text3, quoted: true, ...this.byteSource ? { byteValue: shellValueFromBytes(latin1Bytes(text3)) } : {} }] };
2316
+ text3 = "";
2329
2317
  }
2330
2318
  }
2331
- if (text2) {
2319
+ if (text3) {
2332
2320
  this.budget.admit(2);
2333
- yield { offset: 0, parts: [{ kind: "text", value: text2, quoted: true, ...this.byteSource ? { byteValue: shellValueFromBytes(latin1Bytes(text2)) } : {} }] };
2321
+ yield { offset: 0, parts: [{ kind: "text", value: text3, quoted: true, ...this.byteSource ? { byteValue: shellValueFromBytes(latin1Bytes(text3)) } : {} }] };
2334
2322
  }
2335
2323
  }
2336
2324
  documentSubstitutionError(source, error, backtick = false) {
@@ -2352,9 +2340,9 @@ shell: command substitution: line ${line}: \`${sourceLine}'
2352
2340
  if (!backtick && opening !== "(" && opening !== "{") return this.source[this.position++];
2353
2341
  let value = backtick ? "`" : `$${opening}`;
2354
2342
  const fragments = [];
2355
- const append = (text2, position) => {
2343
+ const append = (text3, position) => {
2356
2344
  const opaque = this.sourceValues?.get(this.sourceOffset + position);
2357
- if (opaque === void 0) value += text2;
2345
+ if (opaque === void 0) value += text3;
2358
2346
  else {
2359
2347
  this.budget.admit(2);
2360
2348
  fragments.push(value, opaque);
@@ -2410,7 +2398,7 @@ shell: command substitution: line ${line}: \`${sourceLine}'
2410
2398
  let regexClass = "";
2411
2399
  const conditionalPattern = terminator === void 0 ? this.conditionalPattern : void 0;
2412
2400
  let plain = true;
2413
- const text2 = (value, quoted, synthetic = false, start = this.position, end = start + shellValueText(value).length, ansi = false) => {
2401
+ const text3 = (value, quoted, synthetic = false, start = this.position, end = start + shellValueText(value).length, ansi = false) => {
2414
2402
  if (this.byteSource && typeof value === "string" && [...value].some((character) => character.charCodeAt(0) > 127)) value = shellValueFromBytes(latin1Bytes(value));
2415
2403
  const projection = shellValueText(value);
2416
2404
  if (conditionalPattern === "regex" && regexBracket && quoted && projection.length) {
@@ -2439,7 +2427,7 @@ shell: command substitution: line ${line}: \`${sourceLine}'
2439
2427
  const opaque = this.braceReplay?.get(this.position) ?? this.sourceValues?.get(this.sourceOffset + this.position);
2440
2428
  if (opaque !== void 0) {
2441
2429
  plain = false;
2442
- text2(opaque, enclosingQuoted);
2430
+ text3(opaque, enclosingQuoted);
2443
2431
  this.position++;
2444
2432
  continue;
2445
2433
  }
@@ -2511,7 +2499,7 @@ shell: command substitution: line ${line}: \`${sourceLine}'
2511
2499
  this.unprintedWords++;
2512
2500
  const start = this.position;
2513
2501
  const value = this.ansiWord();
2514
- text2(value, true, false, start, this.position, true);
2502
+ text3(value, true, false, start, this.position, true);
2515
2503
  } else if (current === "'" && !enclosingQuoted) {
2516
2504
  plain = false;
2517
2505
  let end = this.source.indexOf("'", this.position + 1);
@@ -2524,25 +2512,25 @@ shell: command substitution: line ${line}: \`${sourceLine}'
2524
2512
  for (let position = start; position < end; position++) {
2525
2513
  const opaque2 = this.braceReplay?.get(position) ?? this.sourceValues?.get(this.sourceOffset + position);
2526
2514
  if (opaque2 === void 0) continue;
2527
- if (position > start) text2(this.source.slice(start, position), true, false, start, position);
2528
- text2(opaque2, true, false, position, position + 1);
2515
+ if (position > start) text3(this.source.slice(start, position), true, false, start, position);
2516
+ text3(opaque2, true, false, position, position + 1);
2529
2517
  start = position + 1;
2530
2518
  }
2531
- text2(this.source.slice(start, end), true, false, start, end);
2532
- } else text2(this.source.slice(this.position + 1, end), true, false, this.position, Math.min(end + 1, this.source.length));
2519
+ text3(this.source.slice(start, end), true, false, start, end);
2520
+ } else text3(this.source.slice(this.position + 1, end), true, false, this.position, Math.min(end + 1, this.source.length));
2533
2521
  this.position = Math.min(end + 1, this.source.length);
2534
2522
  } else if (current === '"') {
2535
2523
  plain = false;
2536
2524
  const quoteLine = this.lineAt(this.position);
2537
2525
  this.position++;
2538
- text2("", true, true, this.position - 1, this.position);
2526
+ text3("", true, true, this.position - 1, this.position);
2539
2527
  const quoteParts = parts.length;
2540
2528
  let nameListing = false;
2541
2529
  while (this.position < this.source.length && this.source[this.position] !== '"') {
2542
2530
  const inner = this.source[this.position];
2543
2531
  const opaque2 = this.braceReplay?.get(this.position) ?? this.sourceValues?.get(this.sourceOffset + this.position);
2544
2532
  if (opaque2 !== void 0) {
2545
- text2(opaque2, true);
2533
+ text3(opaque2, true);
2546
2534
  this.position++;
2547
2535
  } else if (!literal && (inner === "$" || inner === "`")) {
2548
2536
  this.expansion(parts, true);
@@ -2551,11 +2539,11 @@ shell: command substitution: line ${line}: \`${sourceLine}'
2551
2539
  nameListing ||= part.kind === "variable" && (part.prefixNames === "@" || !!part.transform && (part.name === "@" || selector?.kind === "members" && selector.separator === "@"));
2552
2540
  } else if (inner === "\\" && /[$`"\\\n]/u.test(this.source[this.position + 1] ?? "")) {
2553
2541
  const escaped = this.source[this.position + 1];
2554
- if (escaped !== "\n") text2(escaped, true, false, this.position, this.position + 2);
2542
+ if (escaped !== "\n") text3(escaped, true, false, this.position, this.position + 2);
2555
2543
  else this.printedNewlineReduction++;
2556
2544
  this.position += 2;
2557
2545
  } else {
2558
- text2(inner, true);
2546
+ text3(inner, true);
2559
2547
  this.position++;
2560
2548
  }
2561
2549
  }
@@ -2578,17 +2566,17 @@ shell: command substitution: line ${line}: \`${sourceLine}'
2578
2566
  this.position++;
2579
2567
  if (this.position === this.source.length) {
2580
2568
  if (!this.braceReplay) this.error("Trailing escape");
2581
- text2("", true);
2569
+ text3("", true);
2582
2570
  break;
2583
2571
  }
2584
- if (this.source[this.position] !== "\n") text2(this.sourceValues?.get(this.sourceOffset + this.position) ?? this.source[this.position], true, false, this.position - 1, this.position + 1);
2572
+ if (this.source[this.position] !== "\n") text3(this.sourceValues?.get(this.sourceOffset + this.position) ?? this.source[this.position], true, false, this.position - 1, this.position + 1);
2585
2573
  else this.printedNewlineReduction++;
2586
2574
  this.position++;
2587
2575
  } else if (current === "$" || current === "`") {
2588
2576
  plain = false;
2589
2577
  if (literal) {
2590
2578
  if (current === "$" && ["'", '"'].includes(this.source[this.position + 1] ?? "")) this.error("Unsupported shell quoting in here-document delimiter");
2591
- text2(this.literalExpansion(), current === "`");
2579
+ text3(this.literalExpansion(), current === "`");
2592
2580
  } else this.expansion(parts, enclosingQuoted);
2593
2581
  } else {
2594
2582
  if (arithmetic) {
@@ -2597,7 +2585,7 @@ shell: command substitution: line ${line}: \`${sourceLine}'
2597
2585
  else if (current === "?") conditionals++;
2598
2586
  else if (current === ":" && conditionals > 0) conditionals--;
2599
2587
  }
2600
- text2(current, false);
2588
+ text3(current, false);
2601
2589
  this.position++;
2602
2590
  }
2603
2591
  }
@@ -2812,9 +2800,9 @@ shell: command substitution: line ${line}: \`${sourceLine}'
2812
2800
  }
2813
2801
  let transform;
2814
2802
  if (this.source[this.position] === "@") {
2815
- const operation = this.source[this.position + 1];
2816
- if (length || prefixNames || !["Q", "E", "a", "A", "K", "k", "P", "u", "U", "L"].includes(operation ?? "") || this.source[this.position + 2] !== "}") this.error("Unsupported parameter transform");
2817
- transform = operation;
2803
+ const operation2 = this.source[this.position + 1];
2804
+ if (length || prefixNames || !["Q", "E", "a", "A", "K", "k", "P", "u", "U", "L"].includes(operation2 ?? "") || this.source[this.position + 2] !== "}") this.error("Unsupported parameter transform");
2805
+ transform = operation2;
2818
2806
  this.position += 2;
2819
2807
  }
2820
2808
  const caseCharacter = this.source[this.position];
@@ -3913,6 +3901,7 @@ init_platform();
3913
3901
  import { createRgCommand } from "../../safe-bash-command-rg/index.js";
3914
3902
 
3915
3903
  // packages/safe-bash/src/commands/search/index.ts
3904
+ import { evalSyncRg } from "../../safe-bash-command-rg/index.js";
3916
3905
  function createSearchCommands(options = {}) {
3917
3906
  const definitions = [createRgCommand(options)];
3918
3907
  for (let i = 0; i < definitions.length; i++) builtInDirectContextExecutors.add(definitions[i].execute);
@@ -3930,286 +3919,15 @@ function searchCommands(options = {}) {
3930
3919
  }
3931
3920
  };
3932
3921
  }
3933
- var syncRgDecoder = new TextDecoder("utf-8", { fatal: false });
3934
- function evalSyncRg(stdinBytes, args, readFile, allowNullBytes = false) {
3935
- let fixed = false;
3936
- let ignoreCase = false;
3937
- let smartCase = false;
3938
- let invert = false;
3939
- let countOnly = false;
3940
- let onlyMatching = false;
3941
- let wordRegexp = false;
3942
- let lineRegexp = false;
3943
- let replaceSpec;
3944
- let lineNumber;
3945
- let withFilename;
3946
- let filesWithMatches = false;
3947
- let filesWithoutMatch = false;
3948
- let quiet = false;
3949
- let nullTerminated = false;
3950
- let maxCount = Infinity;
3951
- const patterns = [];
3952
- let positionalPatternConsumed = false;
3953
- const paths = [];
3954
- let endOpts = false;
3955
- for (let i = 0; i < args.length; i++) {
3956
- const a = args[i];
3957
- if (!endOpts && a === "--") {
3958
- endOpts = true;
3959
- continue;
3960
- }
3961
- if (!endOpts && (a === "-e" || a === "--regexp")) {
3962
- if (i + 1 >= args.length) return void 0;
3963
- patterns.push(args[++i]);
3964
- positionalPatternConsumed = true;
3965
- continue;
3966
- }
3967
- if (!endOpts && a.startsWith("--regexp=")) {
3968
- patterns.push(a.slice(9));
3969
- positionalPatternConsumed = true;
3970
- continue;
3971
- }
3972
- if (!endOpts && (a === "-r" || a === "--replace")) {
3973
- if (i + 1 >= args.length) return void 0;
3974
- replaceSpec = args[++i];
3975
- continue;
3976
- }
3977
- if (!endOpts && a.startsWith("--replace=")) {
3978
- replaceSpec = a.slice(10);
3979
- continue;
3980
- }
3981
- if (!endOpts && (a === "-m" || a === "--max-count")) {
3982
- if (i + 1 >= args.length || !/^\d+$/u.test(args[i + 1])) return void 0;
3983
- maxCount = Number(args[++i]);
3984
- continue;
3985
- }
3986
- if (!endOpts && a.startsWith("--max-count=")) {
3987
- const v = a.slice(12);
3988
- if (!/^\d+$/u.test(v)) return void 0;
3989
- maxCount = Number(v);
3990
- continue;
3991
- }
3992
- if (!endOpts && a.startsWith("--") && a.length > 2) {
3993
- if (a === "--fixed-strings") fixed = true;
3994
- else if (a === "--ignore-case") {
3995
- ignoreCase = true;
3996
- smartCase = false;
3997
- } else if (a === "--case-sensitive") {
3998
- ignoreCase = false;
3999
- smartCase = false;
4000
- } else if (a === "--smart-case") {
4001
- smartCase = true;
4002
- ignoreCase = false;
4003
- } else if (a === "--invert-match") invert = true;
4004
- else if (a === "--count") countOnly = true;
4005
- else if (a === "--only-matching") onlyMatching = true;
4006
- else if (a === "--word-regexp") wordRegexp = true;
4007
- else if (a === "--line-regexp") lineRegexp = true;
4008
- else if (a === "--line-number") lineNumber = true;
4009
- else if (a === "--no-line-number") lineNumber = false;
4010
- else if (a === "--with-filename") withFilename = true;
4011
- else if (a === "--no-filename") withFilename = false;
4012
- else if (a === "--files-with-matches") filesWithMatches = true;
4013
- else if (a === "--files-without-match") filesWithoutMatch = true;
4014
- else if (a === "--quiet") quiet = true;
4015
- else if (a === "--null") nullTerminated = true;
4016
- else return void 0;
4017
- continue;
4018
- }
4019
- if (!endOpts && a.startsWith("-") && a.length > 1) {
4020
- for (let j = 1; j < a.length; j++) {
4021
- const ch = a[j];
4022
- if (ch === "F") fixed = true;
4023
- else if (ch === "i") {
4024
- ignoreCase = true;
4025
- smartCase = false;
4026
- } else if (ch === "s") {
4027
- ignoreCase = false;
4028
- smartCase = false;
4029
- } else if (ch === "S") {
4030
- smartCase = true;
4031
- ignoreCase = false;
4032
- } else if (ch === "v") invert = true;
4033
- else if (ch === "c") countOnly = true;
4034
- else if (ch === "o") onlyMatching = true;
4035
- else if (ch === "w") wordRegexp = true;
4036
- else if (ch === "x") lineRegexp = true;
4037
- else if (ch === "n") lineNumber = true;
4038
- else if (ch === "N") lineNumber = false;
4039
- else if (ch === "H") withFilename = true;
4040
- else if (ch === "I") withFilename = false;
4041
- else if (ch === "l") filesWithMatches = true;
4042
- else if (ch === "q") quiet = true;
4043
- else if (ch === "0") nullTerminated = true;
4044
- else if (ch === "e") {
4045
- const rest = a.slice(j + 1);
4046
- if (rest) patterns.push(rest);
4047
- else {
4048
- if (i + 1 >= args.length) return void 0;
4049
- patterns.push(args[++i]);
4050
- }
4051
- positionalPatternConsumed = true;
4052
- break;
4053
- } else if (ch === "m") {
4054
- const rest = a.slice(j + 1);
4055
- const v = rest || args[++i];
4056
- if (!v || !/^\d+$/u.test(v)) return void 0;
4057
- maxCount = Number(v);
4058
- break;
4059
- } else if (ch === "r") {
4060
- const rest = a.slice(j + 1);
4061
- if (rest) replaceSpec = rest;
4062
- else {
4063
- if (i + 1 >= args.length) return void 0;
4064
- replaceSpec = args[++i];
4065
- }
4066
- break;
4067
- } else return void 0;
4068
- }
4069
- continue;
4070
- }
4071
- if (!positionalPatternConsumed) {
4072
- patterns.push(a);
4073
- positionalPatternConsumed = true;
4074
- } else {
4075
- paths.push(a);
4076
- }
4077
- }
4078
- if (patterns.length === 0) return void 0;
4079
- if (nullTerminated && (!allowNullBytes || !filesWithMatches && !filesWithoutMatch)) return void 0;
4080
- if ((onlyMatching || replaceSpec !== void 0) && (invert || countOnly || filesWithMatches || filesWithoutMatch)) return void 0;
4081
- const effectiveIgnoreCase = ignoreCase || smartCase && !patterns.some((p) => /[A-Z]/u.test(p));
4082
- const escapeRegex = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
4083
- const rawSources = [];
4084
- for (const pat of patterns) {
4085
- if (fixed) {
4086
- rawSources.push(escapeRegex(pat));
4087
- } else {
4088
- if (!/^[a-zA-Z0-9_ :;,=.+*?^$\-[\]()|/{}\\]+$/u.test(pat) || /\([^)]*[+*][^)]*\)[+*?]/u.test(pat)) return void 0;
4089
- rawSources.push(pat);
4090
- }
4091
- }
4092
- const combinedSource = rawSources.length === 1 ? rawSources[0] : rawSources.map((s) => `(?:${s})`).join("|");
4093
- const wrappedSource = lineRegexp ? `^(?:${combinedSource})$` : wordRegexp ? `(?<![a-zA-Z0-9_])(?:${combinedSource})(?![a-zA-Z0-9_])` : combinedSource;
4094
- let reTest;
4095
- let reGlobal;
4096
- try {
4097
- reTest = new RegExp(wrappedSource, effectiveIgnoreCase ? "i" : "");
4098
- reGlobal = new RegExp(wrappedSource, effectiveIgnoreCase ? "gi" : "g");
4099
- } catch {
4100
- return void 0;
4101
- }
4102
- const applyReplace = (m) => {
4103
- if (replaceSpec === void 0) return m[0];
4104
- let res = "";
4105
- for (let k = 0; k < replaceSpec.length; k++) {
4106
- if (replaceSpec[k] === "$") {
4107
- const nxt = replaceSpec[k + 1];
4108
- if (nxt === "$") {
4109
- res += "$";
4110
- k++;
4111
- continue;
4112
- }
4113
- if (nxt === "0" || nxt === "&") {
4114
- res += m[0] ?? "";
4115
- k++;
4116
- continue;
4117
- }
4118
- if (nxt !== void 0 && nxt >= "1" && nxt <= "9") {
4119
- const gIdx = Number(nxt);
4120
- res += m[gIdx] ?? "";
4121
- k++;
4122
- continue;
4123
- }
4124
- if (nxt === "{") {
4125
- const close = replaceSpec.indexOf("}", k + 2);
4126
- if (close > k + 2) {
4127
- const key = replaceSpec.slice(k + 2, close);
4128
- res += (/^\d+$/.test(key) ? m[Number(key)] : m.groups?.[key]) ?? "";
4129
- k = close;
4130
- continue;
4131
- }
4132
- }
4133
- }
4134
- res += replaceSpec[k];
4135
- }
4136
- return res;
4137
- };
4138
- const targets = paths.length > 0 ? paths : ["-"];
4139
- const showFile = withFilename ?? targets.length > 1;
4140
- const showLine = lineNumber ?? false;
4141
- const outLines = [];
4142
- let anyMatched = false;
4143
- for (const t of targets) {
4144
- const b = t === "-" ? stdinBytes : readFile ? readFile(t) : void 0;
4145
- if (!b || b.byteLength > 65536 || b.includes(0)) return void 0;
4146
- const text2 = syncRgDecoder.decode(b);
4147
- const rawLines = text2.length === 0 ? [] : text2.endsWith("\n") ? text2.slice(0, -1).split("\n") : text2.split("\n");
4148
- let count = 0;
4149
- for (let idx = 0; idx < rawLines.length; idx++) {
4150
- const line = rawLines[idx];
4151
- const ok = reTest.test(line);
4152
- if (invert ? !ok : ok) {
4153
- count++;
4154
- if (filesWithoutMatch) {
4155
- break;
4156
- }
4157
- anyMatched = true;
4158
- if (filesWithMatches) {
4159
- outLines.push(t);
4160
- break;
4161
- }
4162
- if (!countOnly) {
4163
- let prefix = "";
4164
- if (showFile) prefix += `${t}:`;
4165
- if (showLine) prefix += `${idx + 1}:`;
4166
- if (onlyMatching) {
4167
- reGlobal.lastIndex = 0;
4168
- let m;
4169
- while ((m = reGlobal.exec(line)) !== null) {
4170
- outLines.push(prefix + applyReplace(m));
4171
- if (m[0].length === 0) reGlobal.lastIndex++;
4172
- }
4173
- } else if (replaceSpec !== void 0) {
4174
- reGlobal.lastIndex = 0;
4175
- let rebuilt = "";
4176
- let lastEnd = 0;
4177
- let m;
4178
- while ((m = reGlobal.exec(line)) !== null) {
4179
- rebuilt += line.slice(lastEnd, m.index) + applyReplace(m);
4180
- lastEnd = m.index + m[0].length;
4181
- if (m[0].length === 0) {
4182
- if (reGlobal.lastIndex < line.length) rebuilt += line[reGlobal.lastIndex];
4183
- reGlobal.lastIndex++;
4184
- lastEnd = reGlobal.lastIndex;
4185
- }
4186
- }
4187
- rebuilt += line.slice(lastEnd);
4188
- outLines.push(prefix + rebuilt);
4189
- } else {
4190
- outLines.push(prefix + line);
4191
- }
4192
- }
4193
- if (count >= maxCount) break;
4194
- }
4195
- }
4196
- if (filesWithoutMatch) {
4197
- if (count === 0) {
4198
- anyMatched = true;
4199
- outLines.push(t);
4200
- }
4201
- } else if (countOnly && count > 0) {
4202
- outLines.push(showFile ? `${t}:${count}` : String(count));
4203
- }
4204
- }
4205
- if (!anyMatched) return void 0;
4206
- if (quiet) return "";
4207
- const sep = nullTerminated ? "\0" : "\n";
4208
- return outLines.length === 0 ? "" : `${outLines.join(sep)}${sep}`;
4209
- }
4210
3922
 
4211
3923
  // packages/safe-bash/src/shell/shell.ts
4212
3924
  init_platform();
3925
+
3926
+ // packages/safe-bash/src/commands/text-programs/awk-reader.ts
3927
+ init_platform();
3928
+ import { Reader, clearAwkReaderPool } from "../../safe-bash-command-awk/awk-reader.js";
3929
+
3930
+ // packages/safe-bash/src/shell/shell.ts
4213
3931
  import { createDeviceFileSystem } from "@poe-platform/safe-fs/core";
4214
3932
 
4215
3933
  // packages/safe-bash/src/shell/env-warning.ts
@@ -4655,7 +4373,7 @@ async function prepareFileInput(context, path, budget, inputProfile = context.fs
4655
4373
  return Promise.reject(error);
4656
4374
  }
4657
4375
  pendingReads++;
4658
- const operation = work.then(async () => {
4376
+ const operation2 = work.then(async () => {
4659
4377
  signal.throwIfAborted();
4660
4378
  if (ended) return { done: true, value: void 0 };
4661
4379
  check();
@@ -4682,12 +4400,12 @@ async function prepareFileInput(context, path, budget, inputProfile = context.fs
4682
4400
  ended = done && provenance !== "regular";
4683
4401
  return done ? { done: true, value: void 0 } : { done: false, value: chunk.subarray(0, length) };
4684
4402
  });
4685
- work = operation.then(() => {
4403
+ work = operation2.then(() => {
4686
4404
  pendingReads--;
4687
4405
  }, () => {
4688
4406
  pendingReads--;
4689
4407
  });
4690
- return operation.then(async (result) => {
4408
+ return operation2.then(async (result) => {
4691
4409
  if (result.done && provenance !== "regular") {
4692
4410
  if (legacy) await close();
4693
4411
  else {
@@ -4758,10 +4476,10 @@ async function fileInput(fs, path, maxBytes, signal, inputProfile = fs, ownershi
4758
4476
  })();
4759
4477
  return closing;
4760
4478
  };
4761
- const work = async (operation) => {
4479
+ const work = async (operation2) => {
4762
4480
  signal.throwIfAborted();
4763
4481
  if (closed2) throw new FsError("EBADF", { path });
4764
- const task = Promise.resolve().then(operation);
4482
+ const task = Promise.resolve().then(operation2);
4765
4483
  pending.add(task);
4766
4484
  void task.finally(() => {
4767
4485
  pending.delete(task);
@@ -5134,14 +4852,14 @@ var InputCursor = class {
5134
4852
  this._readFailed = true;
5135
4853
  this._closed = true;
5136
4854
  }
5137
- async consume(signal, operation, interrupted) {
4855
+ async consume(signal, operation2, interrupted) {
5138
4856
  if (signal.aborted && interrupted) return interrupted(signal.reason);
5139
4857
  signal.throwIfAborted();
5140
4858
  if (this._consumers === 0 && this._turn === resolvedVoid) {
5141
4859
  this._consumers = 1;
5142
4860
  try {
5143
4861
  if (this._eof === "retryable") this._ended = false;
5144
- return await operation();
4862
+ return await operation2();
5145
4863
  } finally {
5146
4864
  this._finishConsumer();
5147
4865
  }
@@ -5167,7 +4885,7 @@ var InputCursor = class {
5167
4885
  throw error;
5168
4886
  }
5169
4887
  if (this._eof === "retryable") this._ended = false;
5170
- return await operation();
4888
+ return await operation2();
5171
4889
  } finally {
5172
4890
  this._consumers--;
5173
4891
  if (this._consumers === 0) this._turn = resolvedVoid;
@@ -5230,7 +4948,7 @@ var InputCursor = class {
5230
4948
  if (this._boundedReads && chunk.byteLength > this._budget.limits.maxInputBytes - this._produced) this._budget.fail("maxInputBytes");
5231
4949
  this._produced += chunk.byteLength;
5232
4950
  this._ended = true;
5233
- return { value: this._boundedReads ? new Uint8Array(chunk) : chunk, done: false };
4951
+ return { value: chunk, done: false };
5234
4952
  }
5235
4953
  if (this._ended || this._closed) return { value: void 0, done: true };
5236
4954
  if (!this._read) {
@@ -5252,7 +4970,7 @@ var InputCursor = class {
5252
4970
  if (!(result.value instanceof Uint8Array)) throw new TypeError("Shell stdin must yield Uint8Array");
5253
4971
  if (this._boundedReads && result.value.byteLength > this._budget.limits.maxInputBytes - this._produced) this._budget.fail("maxInputBytes");
5254
4972
  this._produced += result.value.byteLength;
5255
- const out = { value: this._boundedReads ? new Uint8Array(result.value) : result.value, done: false };
4973
+ const out = { value: result.value, done: false };
5256
4974
  this._readSettled = true;
5257
4975
  this._readResult = out;
5258
4976
  return out;
@@ -5312,7 +5030,7 @@ var InputCursor = class {
5312
5030
  if (!(result.value instanceof Uint8Array)) throw new TypeError("Shell stdin must yield Uint8Array");
5313
5031
  if (this._boundedReads && result.value.byteLength > this._budget.limits.maxInputBytes - this._produced) this._budget.fail("maxInputBytes");
5314
5032
  this._produced += result.value.byteLength;
5315
- const out = { value: this._boundedReads ? new Uint8Array(result.value) : result.value, done: false };
5033
+ const out = { value: result.value, done: false };
5316
5034
  this._readSettled = true;
5317
5035
  this._readResult = out;
5318
5036
  return out;
@@ -5514,9 +5232,10 @@ var ShellInput = class _ShellInput {
5514
5232
  if (!maxBytes) return { done: false, value: new Uint8Array() };
5515
5233
  const result = await this._cursor.take(signal, maxBytes);
5516
5234
  if (result.done) return result;
5517
- const count = Math.min(maxBytes, result.value.byteLength);
5518
- const value = new Uint8Array(result.value.subarray(0, count));
5519
- if (count < result.value.byteLength) this._cursor.remainder = result.value.subarray(count);
5235
+ const bytes = new Uint8Array(result.value);
5236
+ const count = Math.min(maxBytes, bytes.byteLength);
5237
+ const value = new Uint8Array(bytes.subarray(0, count));
5238
+ if (count < bytes.byteLength) this._cursor.remainder = bytes.subarray(count);
5520
5239
  this._cursor.position += count;
5521
5240
  return { done: false, value };
5522
5241
  });
@@ -5539,13 +5258,14 @@ var ShellInput = class _ShellInput {
5539
5258
  }
5540
5259
  const result = await this._cursor.take(signal, maxBytes - length);
5541
5260
  if (result.done) break;
5542
- const count = Math.min(maxBytes - length, result.value.byteLength);
5261
+ const bytes = new Uint8Array(result.value);
5262
+ const count = Math.min(maxBytes - length, bytes.byteLength);
5543
5263
  if (count > this.budget.limits.maxInputBytes - length) {
5544
- this._cursor.restore([result.value]);
5264
+ this._cursor.restore([bytes]);
5545
5265
  this.budget.fail("maxInputBytes");
5546
5266
  }
5547
- if (count < result.value.byteLength) this._cursor.remainder = result.value.subarray(count);
5548
- if (count) chunks.push(result.value.subarray(0, count));
5267
+ if (count < bytes.byteLength) this._cursor.remainder = bytes.subarray(count);
5268
+ if (count) chunks.push(bytes.subarray(0, count));
5549
5269
  length += count;
5550
5270
  }
5551
5271
  signal.throwIfAborted();
@@ -5863,6 +5583,7 @@ var ShellInput = class _ShellInput {
5863
5583
  tryReadSimpleRawAsciiLineSync(delimiter = 10, raw = true) {
5864
5584
  if (this._viewClosed || this._reads && this._reads.size > 0) return void 0;
5865
5585
  const cursor = this._cursor;
5586
+ cursor.admitBoundedRead();
5866
5587
  if (!cursor.remainder && cursor.canTakeRemainderSync()) {
5867
5588
  const ready = cursor.tryTakeReadySync();
5868
5589
  if (ready && !ready.done && ready.value.length > 0) {
@@ -5878,7 +5599,6 @@ var ShellInput = class _ShellInput {
5878
5599
  if (b === 0 || b >= 128 || !raw && b === 92) return void 0;
5879
5600
  }
5880
5601
  this.signal.throwIfAborted();
5881
- cursor.admitBoundedRead();
5882
5602
  cursor.position += delimIdx + 1;
5883
5603
  cursor.remainder = delimIdx + 1 < rem.length ? rem.subarray(delimIdx + 1) : void 0;
5884
5604
  return latin1Text(rem.subarray(0, delimIdx));
@@ -5888,6 +5608,7 @@ var ShellInput = class _ShellInput {
5888
5608
  this.signal.throwIfAborted();
5889
5609
  if (count !== void 0 && (!Number.isSafeInteger(count) || count < 0)) throw new RangeError("Invalid read count");
5890
5610
  if (!Number.isInteger(delimiter) || delimiter < 0 || delimiter > 255) throw new RangeError("Invalid read delimiter");
5611
+ this._cursor.admitBoundedRead();
5891
5612
  const scope = this.budget.values.scope();
5892
5613
  let active = 1;
5893
5614
  let closed = false;
@@ -5946,7 +5667,6 @@ var ShellInput = class _ShellInput {
5946
5667
  }
5947
5668
  }
5948
5669
  if (!hasNul) {
5949
- this._cursor.admitBoundedRead();
5950
5670
  this._cursor.position += delimIdx + 1;
5951
5671
  this._cursor.remainder = delimIdx + 1 < rem.length ? rem.subarray(delimIdx + 1) : void 0;
5952
5672
  scope.reserve(delimIdx + 64, 1);
@@ -6430,6 +6150,10 @@ function splitSyncJqExpression(expression, separator) {
6430
6150
  return { parts, wrapped };
6431
6151
  }
6432
6152
 
6153
+ // packages/safe-bash/src/commands/text-programs/awk-values.ts
6154
+ init_platform();
6155
+ import { AwkArray, SCALAR_ONE, SCALAR_ZERO, compare, formatted, inputValue, inputValueFromSlice, number, numeric, scalar, string, text, truth, unset, validateFormat } from "../../safe-bash-command-awk/awk-values.js";
6156
+
6433
6157
  // packages/safe-bash/src/worker/runtime-context.ts
6434
6158
  init_platform();
6435
6159
  var shellDescriptorAdmissions = /* @__PURE__ */ new WeakMap();
@@ -6441,12 +6165,12 @@ var DEFAULT_VALUE_ARENA_FAIL = (limit) => {
6441
6165
  throw new ShellLimitError(limit);
6442
6166
  };
6443
6167
  var ValueArena = class {
6444
- constructor(maximumBytes, maximumSlots, checkpoint, fail = DEFAULT_VALUE_ARENA_FAIL) {
6168
+ constructor(maximumBytes, maximumSlots, checkpoint, fail2 = DEFAULT_VALUE_ARENA_FAIL) {
6445
6169
  this.maximumBytes = maximumBytes;
6446
6170
  this.maximumSlots = maximumSlots;
6447
6171
  this.hasInfiniteBytes = maximumBytes === Infinity;
6448
6172
  this.checkpoint = checkpoint;
6449
- this.fail = fail;
6173
+ this.fail = fail2;
6450
6174
  this._objects = void 0;
6451
6175
  this._freeScopes = void 0;
6452
6176
  this._freeStores = void 0;
@@ -6749,8 +6473,8 @@ var ValueStore = class {
6749
6473
  }
6750
6474
  this._stringRecord ??= this.arena.allocate(0, 0);
6751
6475
  }
6752
- get(name2, text2) {
6753
- return this._values?.get(name2)?.value ?? this._strings?.get(name2) ?? text2;
6476
+ get(name2, text3) {
6477
+ return this._values?.get(name2)?.value ?? this._strings?.get(name2) ?? text3;
6754
6478
  }
6755
6479
  publishString(name2, value, rawVariables) {
6756
6480
  if (this.arena.hasInfiniteBytes) {
@@ -6911,14 +6635,22 @@ var ValueStore = class {
6911
6635
  for (let i = 0; i < values.length; i++) {
6912
6636
  totalBytes += values[i].length * 2;
6913
6637
  }
6914
- const record2 = this.arena.allocate(totalBytes, 0);
6638
+ const previousRecord = this._stringRecord;
6639
+ const previousBytes = this._stringBytes;
6640
+ const record2 = previousRecord ?? this.arena.allocate(totalBytes, 0);
6641
+ if (previousRecord) this.arena.resizeStringRecord(record2, Math.max(previousBytes, totalBytes));
6642
+ this._stringRecord = void 0;
6915
6643
  try {
6916
6644
  action();
6917
6645
  } catch (error) {
6918
- this.arena.release(record2);
6646
+ if (previousRecord) this.arena.shrinkStringRecord(record2, Math.max(0, totalBytes - previousBytes));
6647
+ else this.arena.release(record2);
6648
+ this._stringRecord = previousRecord;
6649
+ this._stringBytes = previousBytes;
6919
6650
  throw error;
6920
6651
  }
6921
6652
  this.invalidate();
6653
+ if (previousRecord) this.arena.shrinkStringRecord(record2, Math.max(0, previousBytes - totalBytes));
6922
6654
  this._stringRecord = record2;
6923
6655
  this._stringBytes = totalBytes;
6924
6656
  }
@@ -6996,6 +6728,12 @@ var ValueStore = class {
6996
6728
 
6997
6729
  // packages/safe-bash/src/commands/limits.ts
6998
6730
  init_platform();
6731
+
6732
+ // packages/safe-bash/src/commands/archive/internal.ts
6733
+ init_platform();
6734
+ import { Budget, DEFAULT_ARCHIVE_LIMITS, bounded, checkPath, display, fail, fileSource, hasIdentity, invocationLimits, maybeStat, operation, publish, sameIdentity, settings, smallFile, text as text2, vfsPath, wait } from "../../safe-bash-io-engine/commands/archive/internal.js";
6735
+
6736
+ // packages/safe-bash/src/commands/limits.ts
6999
6737
  import { settings as htmlSettings } from "../../safe-bash-command-html-to-markdown/options.js";
7000
6738
  import { settings as splitSettings } from "../../safe-bash-command-split/options.js";
7001
6739
  function resolveCommandLimits(...profiles) {
@@ -7262,10 +7000,10 @@ var InvocationScope = class _InvocationScope {
7262
7000
  for (const resolve of waiters) resolve();
7263
7001
  }
7264
7002
  }
7265
- run(operation) {
7003
+ run(operation2) {
7266
7004
  this.enterWork();
7267
7005
  try {
7268
- const pending = operation();
7006
+ const pending = operation2();
7269
7007
  const onSettled = () => {
7270
7008
  this.leaveWork();
7271
7009
  };
@@ -7500,7 +7238,7 @@ function throwCleanupFailures(failures) {
7500
7238
  function pipeObservation(endpoint, buffered) {
7501
7239
  const { direction } = endpoint;
7502
7240
  const probe = endpoint.probe.bind(endpoint);
7503
- const wait = endpoint.waitForChange.bind(endpoint);
7241
+ const wait2 = endpoint.waitForChange.bind(endpoint);
7504
7242
  const ready = () => direction === "read" && buffered?.().readiness === "ready";
7505
7243
  return {
7506
7244
  readable: direction === "read",
@@ -7515,7 +7253,7 @@ function pipeObservation(endpoint, buffered) {
7515
7253
  if (snapshot.ready || ready()) return "ready";
7516
7254
  const remaining = deadline - monotonicNow();
7517
7255
  if (remaining <= 0) return "timeout";
7518
- await wait(snapshot.revision, { timeoutMs: Math.min(2147483647, Math.ceil(remaining)), signal });
7256
+ await wait2(snapshot.revision, { timeoutMs: Math.min(2147483647, Math.ceil(remaining)), signal });
7519
7257
  }
7520
7258
  }
7521
7259
  };
@@ -7738,7 +7476,7 @@ function observeDescriptor(source, scope, budget, signal) {
7738
7476
  allocation.reserve(256, 1);
7739
7477
  const { readable, probeRead, waitRead } = source;
7740
7478
  const probe = probeRead.bind(source);
7741
- const wait = waitRead?.bind(source);
7479
+ const wait2 = waitRead?.bind(source);
7742
7480
  const run = (forwarded, action) => {
7743
7481
  try {
7744
7482
  check(forwarded);
@@ -7794,10 +7532,10 @@ function observeDescriptor(source, scope, budget, signal) {
7794
7532
  const result = await checkedProbe(local);
7795
7533
  local.throwIfAborted();
7796
7534
  if (result.readiness === "ready") return "ready";
7797
- if (result.readiness === "unknown" || result.timeout !== "honor" || !wait) return "unknown";
7535
+ if (result.readiness === "unknown" || result.timeout !== "honor" || !wait2) return "unknown";
7798
7536
  const remaining = deadline - monotonicNow();
7799
7537
  if (remaining <= 0) return "timeout";
7800
- const readiness = await wait({ timeoutMs, deadline, signal: local });
7538
+ const readiness = await wait2({ timeoutMs, deadline, signal: local });
7801
7539
  if (readiness !== "ready" && readiness !== "timeout" && readiness !== "unknown") throw new TypeError("Invalid descriptor wait result");
7802
7540
  return readiness;
7803
7541
  });
@@ -7867,26 +7605,26 @@ function tryFastExpandBraceRange(word, budget, reserveBytes) {
7867
7605
  braceRangeWordCache.set(word, null);
7868
7606
  return void 0;
7869
7607
  }
7870
- const text2 = part.value;
7871
- const open = text2.indexOf("{");
7608
+ const text3 = part.value;
7609
+ const open = text3.indexOf("{");
7872
7610
  if (open < 0) {
7873
7611
  braceRangeWordCache.set(word, null);
7874
7612
  return void 0;
7875
7613
  }
7876
- const close = text2.indexOf("}", open + 1);
7614
+ const close = text3.indexOf("}", open + 1);
7877
7615
  if (close < 0) {
7878
7616
  braceRangeWordCache.set(word, null);
7879
7617
  return void 0;
7880
7618
  }
7881
- for (let i = 0; i < text2.length; i++) {
7619
+ for (let i = 0; i < text3.length; i++) {
7882
7620
  if (i === open || i === close) continue;
7883
- const c = text2.charCodeAt(i);
7621
+ const c = text3.charCodeAt(i);
7884
7622
  if (c === 123 || c === 125 || c === 44 || c === 92 || c === 126 || c === 42 || c === 63 || c === 91 || c === 32 || c === 9 || c === 10) {
7885
7623
  braceRangeWordCache.set(word, null);
7886
7624
  return void 0;
7887
7625
  }
7888
7626
  }
7889
- const inner = text2.slice(open + 1, close);
7627
+ const inner = text3.slice(open + 1, close);
7890
7628
  const dot = inner.indexOf("..");
7891
7629
  if (dot <= 0 || inner.indexOf("..", dot + 2) >= 0) {
7892
7630
  braceRangeWordCache.set(word, null);
@@ -7910,8 +7648,8 @@ function tryFastExpandBraceRange(word, budget, reserveBytes) {
7910
7648
  return void 0;
7911
7649
  }
7912
7650
  if (count > budget.limits.maxExpansionFields) return void 0;
7913
- const prefix = text2.slice(0, open);
7914
- const suffix = text2.slice(close + 1);
7651
+ const prefix = text3.slice(0, open);
7652
+ const suffix = text3.slice(close + 1);
7915
7653
  const prefixBytes = shellValueByteLength(prefix);
7916
7654
  const suffixBytes = shellValueByteLength(suffix);
7917
7655
  const maxTermBytes = prefixBytes + suffixBytes + Math.max(startStr.length, endStr.length);
@@ -7938,16 +7676,16 @@ function tryFastExpandBraceRange(word, budget, reserveBytes) {
7938
7676
  braceRangeWordCache.set(word, { values: out, totalCharLen, maxTermBytes });
7939
7677
  return out;
7940
7678
  }
7941
- async function integer2(text2, checkpoint) {
7942
- let offset = text2.startsWith("-") || text2.startsWith("+") ? 1 : 0;
7943
- if (offset === text2.length) return void 0;
7944
- while (text2[offset] === "0") {
7679
+ async function integer2(text3, checkpoint) {
7680
+ let offset = text3.startsWith("-") || text3.startsWith("+") ? 1 : 0;
7681
+ if (offset === text3.length) return void 0;
7682
+ while (text3[offset] === "0") {
7945
7683
  if (offset % 1024 === 0) await checkpoint();
7946
7684
  offset++;
7947
7685
  }
7948
- if (text2.length - offset > 19) return void 0;
7949
- for (let index = offset; index < text2.length; index++) if (text2[index] < "0" || text2[index] > "9") return void 0;
7950
- const value = BigInt(text2.slice(offset) || "0") * (text2.startsWith("-") ? -1n : 1n);
7686
+ if (text3.length - offset > 19) return void 0;
7687
+ for (let index = offset; index < text3.length; index++) if (text3[index] < "0" || text3[index] > "9") return void 0;
7688
+ const value = BigInt(text3.slice(offset) || "0") * (text3.startsWith("-") ? -1n : 1n);
7951
7689
  return value < -9223372036854775808n || value > 9223372036854775807n ? void 0 : value;
7952
7690
  }
7953
7691
  async function* expandBraces(word, budget, signal) {
@@ -8158,9 +7896,9 @@ async function* expandBraces(word, budget, signal) {
8158
7896
  const value = node.start + BigInt(current.rank) * node.step;
8159
7897
  materialized.reserveBytes(Math.max(node.width, 32) * 2);
8160
7898
  const digits = node.numeric ? (value < 0n ? -value : value).toString() : String.fromCharCode(Number(value));
8161
- const text2 = node.numeric ? (value < 0n ? "-" : "") + digits.padStart(node.width - Number(value < 0n), "0") : digits;
8162
- part = { kind: "text", value: text2, quoted: false };
8163
- if (!node.numeric && (text2 === "\\" || text2 === "`")) {
7899
+ const text3 = node.numeric ? (value < 0n ? "-" : "") + digits.padStart(node.width - Number(value < 0n), "0") : digits;
7900
+ part = { kind: "text", value: text3, quoted: false };
7901
+ if (!node.numeric && (text3 === "\\" || text3 === "`")) {
8164
7902
  materialized.reserveBytes(32);
8165
7903
  generatedSyntax.add(part);
8166
7904
  }
@@ -8325,7 +8063,7 @@ function evaluatePositionalArithmetic(program, options, evaluate) {
8325
8063
  const admission = options.owner?.reserve({ payload, metadata: 64, allocatedSlots: 2, work: 4 });
8326
8064
  if (admission) admissions.push(admission);
8327
8065
  };
8328
- const length = (text2, start, end, maximum) => {
8066
+ const length = (text3, start, end, maximum) => {
8329
8067
  let size = 0;
8330
8068
  let nextCheckpoint = start;
8331
8069
  for (let position = start; position < end; ) {
@@ -8333,10 +8071,10 @@ function evaluatePositionalArithmetic(program, options, evaluate) {
8333
8071
  options.checkpoint();
8334
8072
  nextCheckpoint = position + 128;
8335
8073
  }
8336
- const code = text2.charCodeAt(position++);
8074
+ const code = text3.charCodeAt(position++);
8337
8075
  if (code <= 127) size++;
8338
8076
  else if (code <= 2047) size += 2;
8339
- else if (code >= 55296 && code <= 56319 && position < end && text2.charCodeAt(position) >= 56320 && text2.charCodeAt(position) <= 57343) {
8077
+ else if (code >= 55296 && code <= 56319 && position < end && text3.charCodeAt(position) >= 56320 && text3.charCodeAt(position) <= 57343) {
8340
8078
  size += 4;
8341
8079
  position++;
8342
8080
  } else size += 3;
@@ -8379,10 +8117,10 @@ function evaluatePositionalArithmetic(program, options, evaluate) {
8379
8117
  const name2 = source.slice(nameStart, nameEnd);
8380
8118
  const value = positionalValue(name2, options);
8381
8119
  options.requireParameter(name2, value);
8382
- const text2 = value ?? "";
8383
- const size = length(text2, 0, text2.length, options.maximumBytes - bytes);
8120
+ const text3 = value ?? "";
8121
+ const size = length(text3, 0, text3.length, options.maximumBytes - bytes);
8384
8122
  reserve(size);
8385
- chunks.push(text2);
8123
+ chunks.push(text3);
8386
8124
  bytes += size;
8387
8125
  position = nameEnd + (braced ? 1 : 0);
8388
8126
  start = position;
@@ -8413,20 +8151,20 @@ async function selectMenu(values, columns, byteLocale2, sink, work, allocation)
8413
8151
  const bytes = shellValueBytes(value, allocation);
8414
8152
  allocation.reserve(bytes.length * 2 + 64, 0);
8415
8153
  const decoder = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
8416
- let text2 = "";
8154
+ let text3 = "";
8417
8155
  for (let offset = 0; offset < bytes.length; offset += 1024) {
8418
8156
  const end = Math.min(offset + 1024, bytes.length);
8419
8157
  const pending = stringCheckpoint(work, end - offset);
8420
8158
  if (pending) await pending;
8421
- if (text2 !== void 0) try {
8422
- text2 += decoder.decode(bytes.subarray(offset, end), { stream: end < bytes.length });
8159
+ if (text3 !== void 0) try {
8160
+ text3 += decoder.decode(bytes.subarray(offset, end), { stream: end < bytes.length });
8423
8161
  } catch (error) {
8424
8162
  if (!(error instanceof TypeError) || "code" in error && error.code !== "ERR_ENCODING_INVALID_ENCODED_DATA") throw error;
8425
- text2 = void 0;
8163
+ text3 = void 0;
8426
8164
  }
8427
8165
  }
8428
8166
  let width = 0;
8429
- if (text2 !== void 0) for (const character of text2) {
8167
+ if (text3 !== void 0) for (const character of text3) {
8430
8168
  const pending = stringCheckpoint(work);
8431
8169
  if (pending) await pending;
8432
8170
  const point = character.codePointAt(0);
@@ -9232,20 +8970,20 @@ function printableWidth(bytes, offset, byteLocale2) {
9232
8970
  if (byteLocale2 || first < 194 || first > 244) return 0;
9233
8971
  const width = first <= 223 ? 2 : first <= 239 ? 3 : 4;
9234
8972
  if (offset + width > bytes.length) return 0;
9235
- let scalar = first & 127 >> width;
8973
+ let scalar2 = first & 127 >> width;
9236
8974
  for (let index = 1; index < width; index++) {
9237
8975
  const continuation = bytes[offset + index];
9238
8976
  if (continuation < 128 || continuation > 191) return 0;
9239
- scalar = scalar << 6 | continuation & 63;
8977
+ scalar2 = scalar2 << 6 | continuation & 63;
9240
8978
  }
9241
- if (width === 3 && scalar < 2048 || width === 4 && scalar < 65536 || scalar >= 55296 && scalar <= 57343 || scalar > 1114111) return 0;
8979
+ if (width === 3 && scalar2 < 2048 || width === 4 && scalar2 < 65536 || scalar2 >= 55296 && scalar2 <= 57343 || scalar2 > 1114111) return 0;
9242
8980
  let lower = 0;
9243
8981
  let upper = diagnosticPrintableRanges.length - 1;
9244
8982
  while (lower <= upper) {
9245
8983
  const middle = lower + upper >>> 1;
9246
8984
  const [start, end] = diagnosticPrintableRanges[middle];
9247
- if (scalar < start) upper = middle - 1;
9248
- else if (scalar > end) lower = middle + 1;
8985
+ if (scalar2 < start) upper = middle - 1;
8986
+ else if (scalar2 > end) lower = middle + 1;
9249
8987
  else return width;
9250
8988
  }
9251
8989
  return 0;
@@ -9296,14 +9034,14 @@ function diagnosticCommandName(value, byteLocale2, allocation) {
9296
9034
 
9297
9035
  // packages/safe-bash/src/shell/parameter-trim.ts
9298
9036
  init_platform();
9299
- function isWellFormedString(text2, byteMode) {
9300
- for (let i = 0; i < text2.length; i++) {
9301
- const code = text2.charCodeAt(i);
9037
+ function isWellFormedString(text3, byteMode) {
9038
+ for (let i = 0; i < text3.length; i++) {
9039
+ const code = text3.charCodeAt(i);
9302
9040
  if (byteMode) {
9303
9041
  if (code >= 128) return false;
9304
9042
  } else if (code >= 55296 && code <= 57343) {
9305
- if (code <= 56319 && i + 1 < text2.length) {
9306
- const next = text2.charCodeAt(i + 1);
9043
+ if (code <= 56319 && i + 1 < text3.length) {
9044
+ const next = text3.charCodeAt(i + 1);
9307
9045
  if (next >= 56320 && next <= 57343) {
9308
9046
  i++;
9309
9047
  continue;
@@ -9324,13 +9062,13 @@ async function project(bytes, work) {
9324
9062
  work.allocation?.reserve(128 + (bytes.length + 1) * 16, 0);
9325
9063
  const offsets = new Int32Array(bytes.length + 1).fill(-1);
9326
9064
  const invalid = new Uint32Array(bytes.length + 1);
9327
- let text2 = "";
9065
+ let text3 = "";
9328
9066
  let binary = "";
9329
9067
  let errors = 0;
9330
9068
  for (let position = 0; position < bytes.length; ) {
9331
9069
  const pending = stringCheckpoint(work);
9332
9070
  if (pending) await pending;
9333
- offsets[position] = text2.length;
9071
+ offsets[position] = text3.length;
9334
9072
  const first = bytes[position];
9335
9073
  let width = first < 128 ? 1 : first >= 194 && first <= 223 ? 2 : first >= 224 && first <= 239 ? 3 : first >= 240 && first <= 244 ? 4 : 0;
9336
9074
  let point = width === 1 ? first : first & 127 >> width;
@@ -9349,15 +9087,15 @@ async function project(bytes, work) {
9349
9087
  point = 56320 + first;
9350
9088
  errors++;
9351
9089
  }
9352
- text2 += String.fromCodePoint(point);
9090
+ text3 += String.fromCodePoint(point);
9353
9091
  for (let index = 0; index < width; index++) {
9354
9092
  binary += String.fromCharCode(bytes[position + index]);
9355
9093
  invalid[position + index + 1] = errors;
9356
9094
  }
9357
9095
  position += width;
9358
9096
  }
9359
- offsets[bytes.length] = text2.length;
9360
- return { bytes: binary, text: text2, offsets, invalid };
9097
+ offsets[bytes.length] = text3.length;
9098
+ return { bytes: binary, text: text3, offsets, invalid };
9361
9099
  }
9362
9100
  async function trimParameter(value, parts, operator, byteMode, work, allocation, maximumBytes = Number.MAX_SAFE_INTEGER, extglob = false) {
9363
9101
  if (typeof value === "string" && (operator === "#" || operator === "##" || operator === "%" || operator === "%%") && isWellFormedString(value, byteMode)) {
@@ -9372,25 +9110,25 @@ async function trimParameter(value, parts, operator, byteMode, work, allocation,
9372
9110
  fastOk = false;
9373
9111
  break;
9374
9112
  }
9375
- const text2 = part.value;
9113
+ const text3 = part.value;
9376
9114
  if (part.literal) {
9377
- if (text2.length > 0) {
9115
+ if (text3.length > 0) {
9378
9116
  if (suffixStar) {
9379
9117
  fastOk = false;
9380
9118
  break;
9381
9119
  }
9382
- literal += text2;
9120
+ literal += text3;
9383
9121
  seenLiteral = true;
9384
9122
  }
9385
9123
  } else {
9386
- for (let i = 0; i < text2.length; i++) {
9387
- const ch = text2[i];
9124
+ for (let i = 0; i < text3.length; i++) {
9125
+ const ch = text3[i];
9388
9126
  if (ch === "\\" || ch === "?" || ch === "[" || extglob && "()|+!@".includes(ch)) {
9389
9127
  fastOk = false;
9390
9128
  break;
9391
9129
  }
9392
9130
  if (ch === "*") {
9393
- if (extglob && text2[i + 1] === "(") {
9131
+ if (extglob && text3[i + 1] === "(") {
9394
9132
  fastOk = false;
9395
9133
  break;
9396
9134
  }
@@ -9521,14 +9259,14 @@ async function trimParameter(value, parts, operator, byteMode, work, allocation,
9521
9259
  const longest = operator.length === 2;
9522
9260
  let cut;
9523
9261
  if (byteMode || !subject.invalid.at(-1)) {
9524
- const text2 = byteMode ? subject.bytes : subject.text;
9262
+ const text3 = byteMode ? subject.bytes : subject.text;
9525
9263
  const boundaries = await compilePatternBoundaries(byteMode ? bytePattern : unicodePattern, work, false, extglob);
9526
- const ends = await boundaries(text2, !longest && prefix, !prefix);
9527
- let boundary = longest === prefix ? text2.length : 0;
9264
+ const ends = await boundaries(text3, !longest && prefix, !prefix);
9265
+ let boundary = longest === prefix ? text3.length : 0;
9528
9266
  while (true) {
9529
9267
  const pending = stringCheckpoint(work);
9530
9268
  if (pending) await pending;
9531
- if (ends[prefix ? 0 : boundary] === (prefix ? boundary : text2.length)) {
9269
+ if (ends[prefix ? 0 : boundary] === (prefix ? boundary : text3.length)) {
9532
9270
  if (byteMode) cut = boundary;
9533
9271
  else for (let position = 0; position < subject.offsets.length; position++) {
9534
9272
  const scanning = stringCheckpoint(work);
@@ -9540,8 +9278,8 @@ async function trimParameter(value, parts, operator, byteMode, work, allocation,
9540
9278
  }
9541
9279
  break;
9542
9280
  }
9543
- if (boundary === (longest === prefix ? 0 : text2.length)) break;
9544
- boundary = longest === prefix ? previousCodePointOffset(text2, boundary) : nextCodePointOffset(text2, boundary);
9281
+ if (boundary === (longest === prefix ? 0 : text3.length)) break;
9282
+ boundary = longest === prefix ? previousCodePointOffset(text3, boundary) : nextCodePointOffset(text3, boundary);
9545
9283
  }
9546
9284
  } else {
9547
9285
  const byteMatch = await compilePattern(bytePattern, work, false, extglob);
@@ -9570,7 +9308,7 @@ function ownedShellSource(value, budget, allocation) {
9570
9308
  const bytes = shellValueBytes(value, allocation);
9571
9309
  allocation.reserve(64 + bytes.length * 2, 0);
9572
9310
  const values = /* @__PURE__ */ new Map();
9573
- let text2 = "";
9311
+ let text3 = "";
9574
9312
  let scanned = 0;
9575
9313
  for (let position = 0; position < bytes.length; ) {
9576
9314
  if (scanned++ % 128 === 0) budget.admit();
@@ -9587,18 +9325,18 @@ function ownedShellSource(value, budget, allocation) {
9587
9325
  point = point * 64 + (next & 63);
9588
9326
  }
9589
9327
  if (width > 1 && (point < (width === 2 ? 128 : width === 3 ? 2048 : 65536) || point > 1114111 || point >= 55296 && point <= 57343)) width = 0;
9590
- if (width) text2 += String.fromCodePoint(point);
9328
+ if (width) text3 += String.fromCodePoint(point);
9591
9329
  else {
9592
9330
  budget.admit();
9593
9331
  allocation.reserve(64, 1);
9594
- values.set(text2.length, shellValueFromBytes(bytes.subarray(position, position + 1), allocation));
9595
- text2 += "\uFFFD";
9332
+ values.set(text3.length, shellValueFromBytes(bytes.subarray(position, position + 1), allocation));
9333
+ text3 += "\uFFFD";
9596
9334
  width = 1;
9597
9335
  }
9598
9336
  position += width;
9599
9337
  }
9600
9338
  budget.admit(0);
9601
- return { text: text2, values };
9339
+ return { text: text3, values };
9602
9340
  }
9603
9341
 
9604
9342
  // packages/safe-bash/src/shell/display.ts
@@ -9612,60 +9350,60 @@ ${indent}`);
9612
9350
  }
9613
9351
  function commandText(command, indent) {
9614
9352
  const nested = `${indent} `;
9615
- let text2;
9353
+ let text3;
9616
9354
  switch (command.kind) {
9617
9355
  case "simple":
9618
- text2 = command.words.map(spelling).join(" ");
9356
+ text3 = command.words.map(spelling).join(" ");
9619
9357
  break;
9620
9358
  case "arithmetic":
9621
- text2 = `(( ${command.source} ))`;
9359
+ text3 = `(( ${command.source} ))`;
9622
9360
  break;
9623
9361
  case "arithmetic-for":
9624
- text2 = `for (( ${command.expressions.map((expression) => expression?.source ?? "").join("; ")} ));
9362
+ text3 = `for (( ${command.expressions.map((expression) => expression?.source ?? "").join("; ")} ));
9625
9363
  do
9626
9364
  ${nested}${scriptText(command.body, nested, true)}
9627
9365
  ${indent}done`;
9628
9366
  break;
9629
9367
  case "conditional":
9630
- text2 = `[[${command.source}]]`;
9368
+ text3 = `[[${command.source}]]`;
9631
9369
  break;
9632
9370
  case "group":
9633
- text2 = `{
9371
+ text3 = `{
9634
9372
  ${nested}${scriptText(command.body, nested)}
9635
9373
  ${indent}}`;
9636
9374
  break;
9637
9375
  case "subshell":
9638
- text2 = `( ${scriptText(command.body, indent)} )`;
9376
+ text3 = `( ${scriptText(command.body, indent)} )`;
9639
9377
  break;
9640
9378
  case "function":
9641
- text2 = `${command.name} ()
9379
+ text3 = `${command.name} ()
9642
9380
  ${indent}${commandText(command.body, indent)}`;
9643
9381
  break;
9644
9382
  case "if":
9645
- text2 = command.branches.map((branch, index) => `${index ? "elif" : "if"} ${scriptText(branch.condition, indent, true)} then
9383
+ text3 = command.branches.map((branch, index) => `${index ? "elif" : "if"} ${scriptText(branch.condition, indent, true)} then
9646
9384
  ${nested}${scriptText(branch.body, nested, true)}`).join(`
9647
9385
  ${indent}`);
9648
- if (command.otherwise) text2 += `
9386
+ if (command.otherwise) text3 += `
9649
9387
  ${indent}else
9650
9388
  ${nested}${scriptText(command.otherwise, nested, true)}`;
9651
- text2 += `
9389
+ text3 += `
9652
9390
  ${indent}fi`;
9653
9391
  break;
9654
9392
  case "while":
9655
9393
  case "until":
9656
- text2 = `${command.kind} ${scriptText(command.condition, indent, true)} do
9394
+ text3 = `${command.kind} ${scriptText(command.condition, indent, true)} do
9657
9395
  ${nested}${scriptText(command.body, nested, true)}
9658
9396
  ${indent}done`;
9659
9397
  break;
9660
9398
  case "for":
9661
9399
  case "select":
9662
- text2 = `${command.kind} ${command.name}${command.words ? ` in ${command.words.map(spelling).join(" ")}` : ""};
9400
+ text3 = `${command.kind} ${command.name}${command.words ? ` in ${command.words.map(spelling).join(" ")}` : ""};
9663
9401
  do
9664
9402
  ${nested}${scriptText(command.body, nested, true)}
9665
9403
  ${indent}done`;
9666
9404
  break;
9667
9405
  case "case":
9668
- text2 = `case ${spelling(command.subject)} in
9406
+ text3 = `case ${spelling(command.subject)} in
9669
9407
  ${command.clauses.map((clause) => `${nested}${clause.patterns.map(spelling).join(" | ")})
9670
9408
  ${nested} ${scriptText(clause.body, `${nested} `)}
9671
9409
  ${nested}${clause.terminator === "esac" ? "" : clause.terminator}`).join("\n")}
@@ -9675,12 +9413,12 @@ ${indent}esac`;
9675
9413
  for (const redirect of command.redirects) {
9676
9414
  if (redirect.implicitPipeline) continue;
9677
9415
  const defaultDescriptor = redirect.operator.startsWith("<") ? 0 : 1;
9678
- text2 += ` ${redirect.descriptor === defaultDescriptor ? "" : redirect.descriptor}${redirect.operator} ${spelling(redirect.target)}${redirect.move ? "-" : ""}`;
9679
- if (redirect.document) text2 += `
9416
+ text3 += ` ${redirect.descriptor === defaultDescriptor ? "" : redirect.descriptor}${redirect.operator} ${spelling(redirect.target)}${redirect.move ? "-" : ""}`;
9417
+ if (redirect.document) text3 += `
9680
9418
  ${redirect.document.body}${redirect.document.delimiter}
9681
9419
  `;
9682
9420
  }
9683
- return text2;
9421
+ return text3;
9684
9422
  }
9685
9423
  function functionDisplay(name2, body) {
9686
9424
  return `${name2} ()
@@ -10026,7 +9764,7 @@ var SignalDetacherImpl = class {
10026
9764
  }
10027
9765
  onAbort() {
10028
9766
  const origin = this.origin ?? getFirstControl(this.state);
10029
- if (origin) publish(this.state, origin);
9767
+ if (origin) publish2(this.state, origin);
10030
9768
  }
10031
9769
  };
10032
9770
  var emptyCloseResult = Object.freeze({ failures: Object.freeze([]) });
@@ -10196,7 +9934,7 @@ function invokeSubscriber(state, subscriber, origin) {
10196
9934
  if (state.closed || !isSubscriberActive(subscriber)) return;
10197
9935
  try {
10198
9936
  if (subscriber.kind === "link") {
10199
- publish(subscriber, origin);
9937
+ publish2(subscriber, origin);
10200
9938
  } else {
10201
9939
  subscriber.callback(origin);
10202
9940
  }
@@ -10223,7 +9961,7 @@ function notify(state, origin) {
10223
9961
  if (state.closed && state.notifying === 0) finalizeClose(state);
10224
9962
  }
10225
9963
  }
10226
- function publish(state, origin) {
9964
+ function publish2(state, origin) {
10227
9965
  if (state.closed) return;
10228
9966
  Object.freeze(origin);
10229
9967
  let changed = false;
@@ -10281,7 +10019,7 @@ function attachOrigin(state, origin) {
10281
10019
  detacher = new SignalDetacherImpl(true, origin.signal, state, origin);
10282
10020
  addAbortSignalWaiter(origin.signal, detacher);
10283
10021
  } else {
10284
- const listener = () => publish(state, origin);
10022
+ const listener = () => publish2(state, origin);
10285
10023
  detacher = new SignalDetacherImpl(false, origin.signal, state, origin, listener);
10286
10024
  try {
10287
10025
  origin.signal.addEventListener("abort", listener, { once: true });
@@ -10300,7 +10038,7 @@ function attachOrigin(state, origin) {
10300
10038
  } else {
10301
10039
  state.signalDetachers.push(detacher);
10302
10040
  }
10303
- if (signalAborted(origin.signal)) publish(state, origin);
10041
+ if (signalAborted(origin.signal)) publish2(state, origin);
10304
10042
  }
10305
10043
  function attachFirstControl(state) {
10306
10044
  const sig = state.firstControlSignal;
@@ -10643,7 +10381,7 @@ function activateChildCancellation(prepared) {
10643
10381
  for (let i = 0; i < state.controls.length; i++) attachOrigin(state, state.controls[i]);
10644
10382
  throwAdmissionFailure(preparation.parent);
10645
10383
  const inherited = preparation.parent.selected ?? preparation.parent.delivered;
10646
- if (inherited) publish(state, inherited);
10384
+ if (inherited) publish2(state, inherited);
10647
10385
  const cancellation = admissionFailure(state);
10648
10386
  if (cancellation.failed) throw cancellation.reason;
10649
10387
  return state.boundary;
@@ -10703,7 +10441,7 @@ function createRootCancellationLink(input) {
10703
10441
  if (state.firstControlSignal) attachFirstControl(state);
10704
10442
  for (let i = 0; i < state.controls.length; i++) attachOrigin(state, state.controls[i]);
10705
10443
  const preaborted = bestVisibleOrigin(state);
10706
- if (preaborted) publish(state, preaborted);
10444
+ if (preaborted) publish2(state, preaborted);
10707
10445
  return state.boundary;
10708
10446
  } catch (error) {
10709
10447
  const rollback = rollbackState(state);
@@ -11448,20 +11186,20 @@ async function valueToken(owner, value, signal) {
11448
11186
  try {
11449
11187
  const input = shellValueBytes(value);
11450
11188
  const decoder = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
11451
- let text2 = "";
11189
+ let text3 = "";
11452
11190
  for (let offset = 0; offset < bytes; offset += 1024) {
11453
11191
  const end = Math.min(bytes, offset + 1024);
11454
11192
  owner.chargeWork(end - offset);
11455
11193
  const pending = owner.ledger.checkpoint(signal, end - offset);
11456
11194
  if (pending) await pending;
11457
- if (text2 !== void 0) try {
11458
- text2 += decoder.decode(input.subarray(offset, end), { stream: end < bytes });
11195
+ if (text3 !== void 0) try {
11196
+ text3 += decoder.decode(input.subarray(offset, end), { stream: end < bytes });
11459
11197
  } catch (error) {
11460
11198
  if (!(error instanceof TypeError) || "code" in error && error.code !== "ERR_ENCODING_INVALID_ENCODED_DATA") throw error;
11461
- text2 = void 0;
11199
+ text3 = void 0;
11462
11200
  }
11463
11201
  }
11464
- if (text2 !== void 0) return await textToken(owner, text2, signal);
11202
+ if (text3 !== void 0) return await textToken(owner, text3, signal);
11465
11203
  const admission = owner.reserve({ payload: bytes * 4, metadata: 128, work: 4 });
11466
11204
  try {
11467
11205
  const raw = shellValueFromBytes(input);
@@ -11529,20 +11267,20 @@ var IndexedBinding = class _IndexedBinding {
11529
11267
  if (existing || !create) return existing?.index;
11530
11268
  const index = this.maximum + 1;
11531
11269
  const admission = this.owner.reserve({ metadata: 128 + identity.length * 2, work: 8 });
11532
- let text2;
11270
+ let text3;
11533
11271
  try {
11534
- text2 = await valueToken(this.owner, value, signal);
11272
+ text3 = await valueToken(this.owner, value, signal);
11535
11273
  } catch (error) {
11536
11274
  admission.release();
11537
11275
  throw error;
11538
11276
  }
11539
- const entry = { index, text: text2, admission };
11277
+ const entry = { index, text: text3, admission };
11540
11278
  admission.cleanup = () => {
11541
11279
  if (this.keys.get(identity) === entry) {
11542
11280
  this.keys.delete(identity);
11543
11281
  this.keyByIndex.delete(index);
11544
11282
  }
11545
- text2.release();
11283
+ text3.release();
11546
11284
  };
11547
11285
  this.keys.set(identity, entry);
11548
11286
  this.keyByIndex.set(index, identity);
@@ -11555,40 +11293,40 @@ var IndexedBinding = class _IndexedBinding {
11555
11293
  if (existing) return { index: existing.index };
11556
11294
  const index = nextMaximum + 1;
11557
11295
  const admission = this.owner.reserve({ metadata: 128 + identity.length * 2, work: 8 });
11558
- let text2;
11296
+ let text3;
11559
11297
  try {
11560
- text2 = await valueToken(this.owner, value, signal);
11298
+ text3 = await valueToken(this.owner, value, signal);
11561
11299
  } catch (error) {
11562
11300
  admission.release();
11563
11301
  throw error;
11564
11302
  }
11565
- return { index, pendingKey: { identity, index, text: text2, admission } };
11303
+ return { index, pendingKey: { identity, index, text: text3, admission } };
11566
11304
  }
11567
11305
  resolveOrInsertKeySync(identity, keyText, keyByteLen) {
11568
11306
  const existing = this.keys.get(identity);
11569
11307
  if (existing) return existing.index;
11570
11308
  const index = this.maximum + 1;
11571
11309
  const admission = this.owner.reserve({ metadata: 128 + identity.length * 2, work: 8 });
11572
- let text2;
11310
+ let text3;
11573
11311
  try {
11574
11312
  this.owner.chargeWork(keyByteLen);
11575
- text2 = new OwnedText(keyText, keyByteLen, this.owner.reserve({ payload: keyByteLen, metadata: 32, work: 4 }));
11313
+ text3 = new OwnedText(keyText, keyByteLen, this.owner.reserve({ payload: keyByteLen, metadata: 32, work: 4 }));
11576
11314
  } catch (error) {
11577
11315
  admission.release();
11578
11316
  throw error;
11579
11317
  }
11580
- this.commitStagedKey({ identity, index, text: text2, admission });
11318
+ this.commitStagedKey({ identity, index, text: text3, admission });
11581
11319
  return index;
11582
11320
  }
11583
11321
  commitStagedKey(pending) {
11584
- const { identity, index, text: text2, admission } = pending;
11585
- const entry = { index, text: text2, admission };
11322
+ const { identity, index, text: text3, admission } = pending;
11323
+ const entry = { index, text: text3, admission };
11586
11324
  admission.cleanup = () => {
11587
11325
  if (this.keys.get(identity) === entry) {
11588
11326
  this.keys.delete(identity);
11589
11327
  this.keyByIndex.delete(index);
11590
11328
  }
11591
- text2.release();
11329
+ text3.release();
11592
11330
  };
11593
11331
  this.keys.set(identity, entry);
11594
11332
  this.keyByIndex.set(index, identity);
@@ -11617,20 +11355,20 @@ var IndexedBinding = class _IndexedBinding {
11617
11355
  if (--this.references === 0) return this.owner.close();
11618
11356
  return void 0;
11619
11357
  }
11620
- insert(index, text2, preallocatedSlot) {
11621
- if (!text2.references || text2.admission.released) throw new ArrayFailure("cell ownership is released");
11358
+ insert(index, text3, preallocatedSlot) {
11359
+ if (!text3.references || text3.admission.released) throw new ArrayFailure("cell ownership is released");
11622
11360
  const slot = preallocatedSlot ?? this.owner.reserve({ slots: 1, metadata: 32, work: 5 });
11623
11361
  try {
11624
- this.owner.share(text2.admission);
11362
+ this.owner.share(text3.admission);
11625
11363
  } catch (error) {
11626
11364
  slot.release();
11627
11365
  throw error;
11628
11366
  }
11629
11367
  const previous = this.values.get(index);
11630
- const element = { text: text2, slot };
11368
+ const element = { text: text3, slot };
11631
11369
  slot.cleanup = () => {
11632
11370
  if (this.values.get(index) === element) this.values.delete(index);
11633
- text2.release();
11371
+ text3.release();
11634
11372
  };
11635
11373
  this.values.set(index, element);
11636
11374
  this.assigned = true;
@@ -11649,14 +11387,14 @@ var IndexedBinding = class _IndexedBinding {
11649
11387
  for (const [identity, entry] of this.keys) {
11650
11388
  const admission = copy.owner.reserve({ metadata: 128 + identity.length * 2, work: identity.length + 8 });
11651
11389
  copy.owner.share(entry.text.admission);
11652
- const text2 = entry.text.retain();
11653
- const cloned = { index: entry.index, text: text2, admission };
11390
+ const text3 = entry.text.retain();
11391
+ const cloned = { index: entry.index, text: text3, admission };
11654
11392
  admission.cleanup = () => {
11655
11393
  if (keyCopy.keys.get(identity) === cloned) {
11656
11394
  keyCopy.keys.delete(identity);
11657
11395
  keyCopy.keyByIndex.delete(entry.index);
11658
11396
  }
11659
- text2.release();
11397
+ text3.release();
11660
11398
  };
11661
11399
  copy.keys.set(identity, cloned);
11662
11400
  copy.keyByIndex.set(entry.index, identity);
@@ -11667,11 +11405,11 @@ var IndexedBinding = class _IndexedBinding {
11667
11405
  }
11668
11406
  for (const [index, element] of this.values) {
11669
11407
  copy.owner.chargeWork(2);
11670
- const text2 = element.text.retain();
11408
+ const text3 = element.text.retain();
11671
11409
  try {
11672
- copy.insert(index, text2);
11410
+ copy.insert(index, text3);
11673
11411
  } catch (error) {
11674
- text2.release();
11412
+ text3.release();
11675
11413
  throw error;
11676
11414
  }
11677
11415
  await copy.owner.ledger.checkpoint(signal, 2);
@@ -11765,7 +11503,7 @@ var BindingStore = class _BindingStore {
11765
11503
  async prepare(name2, signal, copy = true) {
11766
11504
  signal.throwIfAborted();
11767
11505
  const owner = this.owner;
11768
- const operation = ArrayOwner.create(owner.ledger, owner);
11506
+ const operation2 = ArrayOwner.create(owner.ledger, owner);
11769
11507
  let holding;
11770
11508
  let binding;
11771
11509
  let retirement;
@@ -11781,7 +11519,7 @@ var BindingStore = class _BindingStore {
11781
11519
  else await binding?.release();
11782
11520
  } finally {
11783
11521
  try {
11784
- await operation.close();
11522
+ await operation2.close();
11785
11523
  } finally {
11786
11524
  holding?.release();
11787
11525
  }
@@ -11791,13 +11529,13 @@ var BindingStore = class _BindingStore {
11791
11529
  };
11792
11530
  try {
11793
11531
  holding = owner.hold();
11794
- operation.reserve({ metadata: 192, work: 12 });
11795
- const watch = await this.watch(name2, operation, signal);
11796
- const tickets = operation.adopt(this.tickets(name2));
11532
+ operation2.reserve({ metadata: 192, work: 12 });
11533
+ const watch = await this.watch(name2, operation2, signal);
11534
+ const tickets = operation2.adopt(this.tickets(name2));
11797
11535
  const previous = this.get(name2);
11798
11536
  binding = copy && previous ? await previous.copy(signal) : IndexedBinding.create(owner);
11799
11537
  const staged = binding;
11800
- const prepared = await this.prepareName(name2, operation, signal);
11538
+ const prepared = await this.prepareName(name2, operation2, signal);
11801
11539
  const validate = () => {
11802
11540
  signal.throwIfAborted();
11803
11541
  if (closed || published) throw new ArrayFailure("binding publication is closed");
@@ -11823,9 +11561,9 @@ var BindingStore = class _BindingStore {
11823
11561
  throw error;
11824
11562
  }
11825
11563
  }
11826
- async watch(name2, operation, signal, owner = this.owner) {
11564
+ async watch(name2, operation2, signal, owner = this.owner) {
11827
11565
  let watch = this.watches.get(name2);
11828
- const observer = operation.reserve({ metadata: 64, work: 5 });
11566
+ const observer = operation2.reserve({ metadata: 64, work: 5 });
11829
11567
  if (!watch) {
11830
11568
  signal.throwIfAborted();
11831
11569
  owner.chargeWork(name2.length);
@@ -11844,7 +11582,7 @@ var BindingStore = class _BindingStore {
11844
11582
  watch.observers++;
11845
11583
  const result = new BindingWatch(this, name2, watch, observer);
11846
11584
  observer.cleanup = () => result.close();
11847
- const pending = operation.ledger.checkpoint(signal, name2.length);
11585
+ const pending = operation2.ledger.checkpoint(signal, name2.length);
11848
11586
  if (pending) await pending;
11849
11587
  return result;
11850
11588
  }
@@ -11873,25 +11611,25 @@ var BindingStore = class _BindingStore {
11873
11611
  }
11874
11612
  }
11875
11613
  }
11876
- async prepareName(name2, operation, signal) {
11614
+ async prepareName(name2, operation2, signal) {
11877
11615
  if (this.bindings.has(name2)) return void 0;
11878
- const token = await textToken(operation, name2, signal);
11616
+ const token = await textToken(operation2, name2, signal);
11879
11617
  try {
11880
- const admission = operation.reserve({ slots: 1, metadata: 32, work: 5 });
11618
+ const admission = operation2.reserve({ slots: 1, metadata: 32, work: 5 });
11881
11619
  return { name: token, admission };
11882
11620
  } catch (error) {
11883
11621
  token.release();
11884
11622
  throw error;
11885
11623
  }
11886
11624
  }
11887
- prepareExistingName(name2, bytes, operation, signal) {
11625
+ prepareExistingName(name2, bytes, operation2, signal) {
11888
11626
  if (this.bindings.has(name2)) return void 0;
11889
11627
  signal.throwIfAborted();
11890
- operation.assertOpen();
11891
- operation.chargeWork(name2.length);
11892
- const token = new OwnedText(name2, bytes, operation.reserve({ payload: bytes, metadata: 32, work: 4 }));
11628
+ operation2.assertOpen();
11629
+ operation2.chargeWork(name2.length);
11630
+ const token = new OwnedText(name2, bytes, operation2.reserve({ payload: bytes, metadata: 32, work: 4 }));
11893
11631
  try {
11894
- const admission = operation.reserve({ slots: 1, metadata: 32, work: 5 });
11632
+ const admission = operation2.reserve({ slots: 1, metadata: 32, work: 5 });
11895
11633
  return { name: token, admission };
11896
11634
  } catch (error) {
11897
11635
  token.release();
@@ -11936,6 +11674,7 @@ var BindingStore = class _BindingStore {
11936
11674
  }
11937
11675
  rec.binding.maximum = -1;
11938
11676
  rec.binding.assigned = false;
11677
+ rec.identity = tickets.generation;
11939
11678
  this.bindings.set(name2, rec);
11940
11679
  this.changed(tickets, name2);
11941
11680
  return rec.binding;
@@ -11944,12 +11683,14 @@ var BindingStore = class _BindingStore {
11944
11683
  this.releaseRecycled(name2);
11945
11684
  const previous = this.bindings.get(name2);
11946
11685
  const displaced = previous?.binding;
11947
- if (previous) previous.binding = binding;
11948
- else {
11686
+ if (previous) {
11687
+ previous.binding = binding;
11688
+ if (restoring && prepared?.identity !== void 0) previous.identity = prepared.identity;
11689
+ } else {
11949
11690
  if (!prepared) throw new Error("Missing indexed-array name admission");
11950
11691
  owner.adopt(prepared.name.admission, restoring);
11951
11692
  owner.adopt(prepared.admission, restoring);
11952
- const entry = { binding, name: prepared.name, admission: prepared.admission };
11693
+ const entry = { binding, identity: restoring ? prepared.identity ?? tickets.generation : tickets.generation, name: prepared.name, admission: prepared.admission };
11953
11694
  prepared.admission.cleanup = () => {
11954
11695
  if (this.bindings.get(name2) === entry) {
11955
11696
  this.bindings.delete(name2);
@@ -11999,33 +11740,33 @@ async function mapfileOptions(context, work, allocation) {
11999
11740
  const options = { name: "MAPFILE", strip: false, delimiter: 10, count: 0, skip: 0, origin: 0, preserve: false, callback: void 0, quantum: 5e3 };
12000
11741
  const args = getCommandArguments(context);
12001
11742
  let cursor = 0;
12002
- const numeric2 = async (text2, maximum) => {
11743
+ const numeric2 = async (text3, maximum) => {
12003
11744
  let value = 0;
12004
11745
  let index = 0;
12005
11746
  const whitespace = (code) => code === 32 || code >= 9 && code <= 13;
12006
- while (index < text2.length && whitespace(text2.charCodeAt(index))) {
11747
+ while (index < text3.length && whitespace(text3.charCodeAt(index))) {
12007
11748
  const pending = stringCheckpoint(work);
12008
11749
  if (pending) await pending;
12009
11750
  index++;
12010
11751
  }
12011
- const negative = text2[index] === "-";
12012
- if (negative || text2[index] === "+") index++;
11752
+ const negative = text3[index] === "-";
11753
+ if (negative || text3[index] === "+") index++;
12013
11754
  let digits = 0;
12014
- for (; index < text2.length; index++) {
11755
+ for (; index < text3.length; index++) {
12015
11756
  const pending = stringCheckpoint(work);
12016
11757
  if (pending) await pending;
12017
- const digit2 = text2.charCodeAt(index) - 48;
11758
+ const digit2 = text3.charCodeAt(index) - 48;
12018
11759
  if (digit2 < 0 || digit2 > 9) break;
12019
- if (value > Math.floor((maximum - digit2) / 10)) throw new MapfileUsageError(`${text2}: invalid number`, 1);
11760
+ if (value > Math.floor((maximum - digit2) / 10)) throw new MapfileUsageError(`${text3}: invalid number`, 1);
12020
11761
  value = value * 10 + digit2;
12021
11762
  digits++;
12022
11763
  }
12023
- for (; index < text2.length; index++) {
11764
+ for (; index < text3.length; index++) {
12024
11765
  const pending = stringCheckpoint(work);
12025
11766
  if (pending) await pending;
12026
- if (!whitespace(text2.charCodeAt(index))) throw new MapfileUsageError(`${text2}: invalid number`, 1);
11767
+ if (!whitespace(text3.charCodeAt(index))) throw new MapfileUsageError(`${text3}: invalid number`, 1);
12027
11768
  }
12028
- if (!digits || negative && value !== 0) throw new MapfileUsageError(`${text2}: invalid number`, 1);
11769
+ if (!digits || negative && value !== 0) throw new MapfileUsageError(`${text3}: invalid number`, 1);
12029
11770
  return value;
12030
11771
  };
12031
11772
  while (cursor < context.args.length) {
@@ -13160,19 +12901,19 @@ async function publishPipelineStatusSlow(state, target, monitor, statuses, signa
13160
12901
  const store = monitor.activate(true);
13161
12902
  const owner = monitor.internalOwner();
13162
12903
  const epoch = monitor.epoch;
13163
- const operation = ArrayOwner.create(owner.ledger, owner);
12904
+ const operation2 = ArrayOwner.create(owner.ledger, owner);
13164
12905
  const holding = owner.hold();
13165
12906
  let staged;
13166
12907
  let primary = false;
13167
12908
  let failure;
13168
12909
  try {
13169
- const watch = await store.watch(name, operation, signal, owner);
13170
- const supersede = await stateMonitor(state).prepareTypedPublication(name, operation, signal);
13171
- const tickets = operation.reserve({ generation: true, version: true, epoch: true, work: 8 });
13172
- const prepared = await store.prepareName(name, operation, signal);
12910
+ const watch = await store.watch(name, operation2, signal, owner);
12911
+ const supersede = await stateMonitor(state).prepareTypedPublication(name, operation2, signal);
12912
+ const tickets = operation2.reserve({ generation: true, version: true, epoch: true, work: 8 });
12913
+ const prepared = await store.prepareName(name, operation2, signal);
13173
12914
  staged = IndexedBinding.create(owner);
13174
12915
  for (let index = 0; index < statuses.length; index++) {
13175
- operation.reserve({ work: 2 });
12916
+ operation2.reserve({ work: 2 });
13176
12917
  const status = statuses[index];
13177
12918
  if (!Number.isSafeInteger(status) || status < 0 || status > 255) throw new TypeError("Invalid PIPESTATUS completion");
13178
12919
  const token = await textToken(staged.owner, String(status), signal);
@@ -13182,7 +12923,7 @@ async function publishPipelineStatusSlow(state, target, monitor, statuses, signa
13182
12923
  token.release();
13183
12924
  throw error;
13184
12925
  }
13185
- const pending = operation.ledger.checkpoint(signal, 2);
12926
+ const pending = operation2.ledger.checkpoint(signal, 2);
13186
12927
  if (pending) await pending;
13187
12928
  }
13188
12929
  signal.throwIfAborted();
@@ -13201,7 +12942,7 @@ async function publishPipelineStatusSlow(state, target, monitor, statuses, signa
13201
12942
  failure = error;
13202
12943
  }
13203
12944
  await scope.cleanup(() => staged?.release());
13204
- await scope.cleanup(() => operation.close());
12945
+ await scope.cleanup(() => operation2.close());
13205
12946
  await scope.cleanup(() => holding.release());
13206
12947
  signal.throwIfAborted();
13207
12948
  if (primary) throw failure;
@@ -13278,25 +13019,25 @@ var PathLookup = class {
13278
13019
  return file;
13279
13020
  }
13280
13021
  };
13281
- function* pathTargets(name2, path, limits, signal, fail) {
13022
+ function* pathTargets(name2, path, limits, signal, fail2) {
13282
13023
  signal.throwIfAborted();
13283
- if (path !== void 0 && shellValueByteLength(path) > limits.maxExpansionBytes) fail("maxExpansionBytes");
13024
+ if (path !== void 0 && shellValueByteLength(path) > limits.maxExpansionBytes) fail2("maxExpansionBytes");
13284
13025
  if (name2.includes("/") || path === void 0) {
13285
- if (limits.maxExpansionFields < 1) fail("maxExpansionFields");
13026
+ if (limits.maxExpansionFields < 1) fail2("maxExpansionFields");
13286
13027
  yield name2;
13287
13028
  return;
13288
13029
  }
13289
13030
  let fields = 1;
13290
13031
  for (let separator = path.indexOf(":"); separator >= 0; separator = path.indexOf(":", separator + 1)) {
13291
13032
  signal.throwIfAborted();
13292
- if (++fields > limits.maxExpansionFields) fail("maxExpansionFields");
13033
+ if (++fields > limits.maxExpansionFields) fail2("maxExpansionFields");
13293
13034
  }
13294
- if (fields > limits.maxExpansionFields) fail("maxExpansionFields");
13035
+ if (fields > limits.maxExpansionFields) fail2("maxExpansionFields");
13295
13036
  let start = 0;
13296
13037
  let consulted = 0;
13297
13038
  while (start <= path.length) {
13298
13039
  signal.throwIfAborted();
13299
- if (consulted >= limits.maxPathComponents) fail("maxPathComponents");
13040
+ if (consulted >= limits.maxPathComponents) fail2("maxPathComponents");
13300
13041
  consulted++;
13301
13042
  const end = path.indexOf(":", start);
13302
13043
  const component = path.slice(start, end < 0 ? path.length : end);
@@ -13353,8 +13094,8 @@ async function transformParameter(value, operator, options) {
13353
13094
  if (output) output[size] = byte;
13354
13095
  size++;
13355
13096
  };
13356
- const ascii = (text2) => {
13357
- for (let index = 0; index < text2.length; index++) emit(text2.charCodeAt(index));
13097
+ const ascii = (text3) => {
13098
+ for (let index = 0; index < text3.length; index++) emit(text3.charCodeAt(index));
13358
13099
  };
13359
13100
  const scan = async () => {
13360
13101
  size = 0;
@@ -13628,6 +13369,7 @@ function hasActiveExtensions(state) {
13628
13369
  }
13629
13370
  var memberPatternOperators = ["#", "##", "%", "%%", "/", "//", "/#", "/%", "^", "^^", ",", ",,"];
13630
13371
  var defaultParameterOperators = ["-", "+", "=", "?", ":-", ":+", ":=", ":?"];
13372
+ var printfSlowTargets = /* @__PURE__ */ new Set([...controlNames, "FUNCNAME", "RANDOM", "SECONDS", "PIPESTATUS", "_"]);
13631
13373
  async function signedLong(argument, budget, signal) {
13632
13374
  const checkpoint = async () => {
13633
13375
  budget.cpuCheckpoint();
@@ -13675,6 +13417,7 @@ var defaultLimits = {
13675
13417
  maxPipelineStages: Infinity,
13676
13418
  maxLoopIterations: Infinity,
13677
13419
  maxSubstitutionDepth: Infinity,
13420
+ maxFunctionDepth: Infinity,
13678
13421
  maxSourceBytes: Infinity,
13679
13422
  maxExpansionFields: Infinity,
13680
13423
  maxExpansionBytes: Infinity,
@@ -13991,7 +13734,7 @@ function tickSharedWallClockBudgets() {
13991
13734
  sharedWallClockTimer.unref?.();
13992
13735
  }
13993
13736
  }
13994
- var Budget = class {
13737
+ var Budget2 = class {
13995
13738
  get fileSystemOperations() {
13996
13739
  return this._fileSystemOperations;
13997
13740
  }
@@ -14302,7 +14045,7 @@ var Budget = class {
14302
14045
  return output;
14303
14046
  }
14304
14047
  };
14305
- Object.assign(Budget.prototype, {
14048
+ Object.assign(Budget2.prototype, {
14306
14049
  onInternalError: void 0,
14307
14050
  _yieldCheckpoint: void 0,
14308
14051
  _values: void 0,
@@ -15136,13 +14879,13 @@ function bindCommandIO(context, io, limits = {}) {
15136
14879
  return completion;
15137
14880
  };
15138
14881
  leases.add(close);
15139
- async function work(callerSignal, operation) {
14882
+ async function work(callerSignal, operation2) {
15140
14883
  callerSignal.throwIfAborted();
15141
14884
  context.signal.throwIfAborted();
15142
14885
  if (closed || ended) throw new FsError("EBADF");
15143
14886
  if (pending.size >= (limits.maxDescriptorOperations ?? Infinity)) throw new FsError("EAGAIN");
15144
14887
  const combined = combineManagedSignals2(callerSignal, context.signal, lifetime.signal);
15145
- const task = Promise.resolve().then(() => operation(combined));
14888
+ const task = Promise.resolve().then(() => operation2(combined));
15146
14889
  pending.add(task);
15147
14890
  void task.finally(() => pending.delete(task)).catch(() => {
15148
14891
  });
@@ -15558,7 +15301,7 @@ async function cloneState(state, signal, scope, inheritLocals = true) {
15558
15301
  const token = await textToken(savedOwner, name2, signal);
15559
15302
  const admission = savedOwner.reserve({ slots: 1, metadata: 32, work: 5 });
15560
15303
  binding = typed.binding?.retain();
15561
- typedSavedVariables.set(copied, { owner: savedOwner, binding, tickets, prepared: { name: token, admission }, watch, scalarLegacy: typed.scalarLegacy });
15304
+ typedSavedVariables.set(copied, { owner: savedOwner, binding, tickets, prepared: { ...typed.prepared, name: token, admission }, watch, scalarLegacy: typed.scalarLegacy });
15562
15305
  tickets.cleanup = () => {
15563
15306
  if (typedSavedVariables.delete(copied) && scope) releaseBinding = scope.cleanup(async () => {
15564
15307
  await binding?.release();
@@ -15652,9 +15395,9 @@ function publishVariable(state, name2, value) {
15652
15395
  monitor.publishStringVariable(name2, value);
15653
15396
  return;
15654
15397
  }
15655
- const text2 = shellValueText(value);
15398
+ const text3 = shellValueText(value);
15656
15399
  monitor.values.publish(name2, value, () => {
15657
- state.variables[name2] = text2;
15400
+ state.variables[name2] = text3;
15658
15401
  return true;
15659
15402
  });
15660
15403
  return;
@@ -15945,8 +15688,8 @@ var DirectoryStackWork = class {
15945
15688
  outputBytes = 0;
15946
15689
  chunk = "";
15947
15690
  chunkBytes = 0;
15948
- fail(text2, status = 1) {
15949
- throw new CommandFailure(cdDiagnostic([this.name, ": ", text2], this.limits.maxDirectoryDiagnosticBytes), status);
15691
+ fail(text3, status = 1) {
15692
+ throw new CommandFailure(cdDiagnostic([this.name, ": ", text3], this.limits.maxDirectoryDiagnosticBytes), status);
15950
15693
  }
15951
15694
  async charge(amount) {
15952
15695
  this.signal.throwIfAborted();
@@ -16004,15 +15747,15 @@ var DirectoryStackWork = class {
16004
15747
  if (!digits) this.fail("invalid directory stack index", 2);
16005
15748
  return negative ? -value : value;
16006
15749
  }
16007
- async emit(text2) {
16008
- for (let offset = 0; offset < text2.length; ) {
16009
- const point = text2.codePointAt(offset);
15750
+ async emit(text3) {
15751
+ for (let offset = 0; offset < text3.length; ) {
15752
+ const point = text3.codePointAt(offset);
16010
15753
  const width = cdUtf8Width(point);
16011
15754
  if (width > this.limits.maxDirectoryStackOutputBytes - this.outputBytes) this.fail("display byte limit exceeded");
16012
15755
  await this.charge(width);
16013
15756
  if (width > 16384 - this.chunkBytes) await this.flushOutput();
16014
15757
  const units = point > 65535 ? 2 : 1;
16015
- this.chunk += text2.slice(offset, offset + units);
15758
+ this.chunk += text3.slice(offset, offset + units);
16016
15759
  this.chunkBytes += width;
16017
15760
  this.outputBytes += width;
16018
15761
  offset += units;
@@ -16021,10 +15764,10 @@ var DirectoryStackWork = class {
16021
15764
  async flushOutput() {
16022
15765
  this.signal.throwIfAborted();
16023
15766
  if (!this.chunkBytes) return;
16024
- const text2 = this.chunk;
15767
+ const text3 = this.chunk;
16025
15768
  this.chunk = "";
16026
15769
  this.chunkBytes = 0;
16027
- await writeText(this.stdout, text2);
15770
+ await writeText(this.stdout, text3);
16028
15771
  this.signal.throwIfAborted();
16029
15772
  }
16030
15773
  async display(cwd, entries, options, home) {
@@ -16064,8 +15807,8 @@ var closedSink = { async write() {
16064
15807
  var closedSource = { [Symbol.asyncIterator]() {
16065
15808
  let closed = false;
16066
15809
  let completion = Promise.resolve();
16067
- const enqueue = (operation) => {
16068
- const pending = completion.then(operation);
15810
+ const enqueue = (operation2) => {
15811
+ const pending = completion.then(operation2);
16069
15812
  completion = pending.then(() => {
16070
15813
  }, () => {
16071
15814
  });
@@ -16385,12 +16128,12 @@ var assignmentCache = {
16385
16128
  } else (fallbackAssignmentCache ??= /* @__PURE__ */ new WeakMap()).set(word, value);
16386
16129
  }
16387
16130
  };
16388
- function hasGlobOrEscape(text2, extglob = false) {
16389
- for (let i = 0; i < text2.length; i++) {
16390
- const code = text2.charCodeAt(i);
16131
+ function hasGlobOrEscape(text3, extglob = false) {
16132
+ for (let i = 0; i < text3.length; i++) {
16133
+ const code = text3.charCodeAt(i);
16391
16134
  if (code === 42 || code === 63 || code === 91 || code === 92) return true;
16392
16135
  if (extglob && code === 40 && i > 0) {
16393
- const prev = text2.charCodeAt(i - 1);
16136
+ const prev = text3.charCodeAt(i - 1);
16394
16137
  if (prev === 63 || prev === 42 || prev === 43 || prev === 64 || prev === 33) return true;
16395
16138
  }
16396
16139
  }
@@ -16409,12 +16152,12 @@ var defaultFloat64Array = globalThis.Float64Array;
16409
16152
  var fastMkdirRmPaths = new Array(32).fill("");
16410
16153
  var fastRedirectScratchBytes = new Uint8Array(8192);
16411
16154
  var fastRedirectScratchViews = Array.from({ length: 129 }, (_, len) => fastRedirectScratchBytes.subarray(0, len));
16412
- function encodeRedirectTextToScratch(formatted) {
16413
- const len = formatted.length;
16155
+ function encodeRedirectTextToScratch(formatted2) {
16156
+ const len = formatted2.length;
16414
16157
  if (len <= 128) {
16415
16158
  let ascii = true;
16416
16159
  for (let i = 0; i < len; i++) {
16417
- const code = formatted.charCodeAt(i);
16160
+ const code = formatted2.charCodeAt(i);
16418
16161
  if (code >= 128) {
16419
16162
  ascii = false;
16420
16163
  break;
@@ -16423,7 +16166,7 @@ function encodeRedirectTextToScratch(formatted) {
16423
16166
  }
16424
16167
  if (ascii) return fastRedirectScratchViews[len];
16425
16168
  }
16426
- return len * 3 <= fastRedirectScratchBytes.byteLength ? fastRedirectScratchBytes.subarray(0, fastSharedTextEncoder.encodeInto(formatted, fastRedirectScratchBytes).written) : fastSharedTextEncoder.encode(formatted);
16169
+ return len * 3 <= fastRedirectScratchBytes.byteLength ? fastRedirectScratchBytes.subarray(0, fastSharedTextEncoder.encodeInto(formatted2, fastRedirectScratchBytes).written) : fastSharedTextEncoder.encode(formatted2);
16427
16170
  }
16428
16171
  function encodeRedirectTextWithNewlineToScratch(arg0) {
16429
16172
  const len = arg0.length;
@@ -16873,6 +16616,7 @@ function resolveSimpleArithOperand(tok, rawState, monitor, activeArrayStore, syn
16873
16616
  return Number(elemVal);
16874
16617
  }
16875
16618
  tok = resolveSyncNameref(rawState, tok);
16619
+ if (tok === "LINENO" || tok === "_" || tok === "FUNCNAME" || tok === "PIPESTATUS") return void 0;
16876
16620
  if (rawState.nounset || activeArrayStore?.bindings.has(tok) || monitor?.hasOverlay(tok) || activeArrayStore?.watches.has(tok)) return void 0;
16877
16621
  const raw = rawState.variables[tok];
16878
16622
  if (raw === void 0 || raw === "") return 0;
@@ -17077,6 +16821,7 @@ var Runtime = class _Runtime {
17077
16821
  _syncPendingEvalResume;
17078
16822
  _syncReadOnlyArithRefs;
17079
16823
  _activeSyncLoopAssignedVars;
16824
+ _activeSyncArrayLoopWords;
17080
16825
  _activeSyncLoopHasFileMutations = false;
17081
16826
  _inSyncLoopPreflight = false;
17082
16827
  _activeSyncLoopIO;
@@ -17179,16 +16924,16 @@ var Runtime = class _Runtime {
17179
16924
  pattern._cachedSimpleEre = res2;
17180
16925
  return res2;
17181
16926
  }
17182
- let text2 = "";
16927
+ let text3 = "";
17183
16928
  for (let i = 0; i < pattern.parts.length; i++) {
17184
16929
  const p = pattern.parts[i];
17185
16930
  if (p.kind !== "text" || p.quoted || p.byteValue || p.value.includes("\\") || p.value.includes("~")) {
17186
16931
  pattern._cachedSimpleEre = null;
17187
16932
  return void 0;
17188
16933
  }
17189
- text2 += p.value;
16934
+ text3 += p.value;
17190
16935
  }
17191
- const res = { text: text2, literal: false };
16936
+ const res = { text: text3, literal: false };
17192
16937
  pattern._cachedSimpleEre = res;
17193
16938
  return res;
17194
16939
  }
@@ -17391,7 +17136,7 @@ var Runtime = class _Runtime {
17391
17136
  }
17392
17137
  }
17393
17138
  const store = requireArrays(state);
17394
- let operation;
17139
+ let operation2;
17395
17140
  let holding;
17396
17141
  let staged;
17397
17142
  let closing;
@@ -17400,7 +17145,7 @@ var Runtime = class _Runtime {
17400
17145
  await staged?.release();
17401
17146
  } finally {
17402
17147
  try {
17403
- await operation?.close();
17148
+ await operation2?.close();
17404
17149
  } finally {
17405
17150
  holding?.release();
17406
17151
  }
@@ -17408,19 +17153,19 @@ var Runtime = class _Runtime {
17408
17153
  });
17409
17154
  let primary = false;
17410
17155
  try {
17411
- operation = ArrayOwner.create(store.owner.ledger, store.owner);
17156
+ operation2 = ArrayOwner.create(store.owner.ledger, store.owner);
17412
17157
  holding = store.owner.hold();
17413
- await this.prepareArrayObservers(state, operation);
17414
- operation.reserve({ metadata: 64, allocatedSlots: 1, work: 2 });
17158
+ await this.prepareArrayObservers(state, operation2);
17159
+ operation2.reserve({ metadata: 64, allocatedSlots: 1, work: 2 });
17415
17160
  const fragments = [];
17416
17161
  if (pattern.parts.length === 1 && pattern.parts[0].kind === "text" && !pattern.parts[0].value.includes("\\") && !pattern.parts[0].value.includes("~")) {
17417
17162
  const p0 = pattern.parts[0];
17418
- operation.reserve({ metadata: 64, allocatedSlots: 1, payload: shellValueByteLength(p0.value), work: p0.value.length + 2 });
17163
+ operation2.reserve({ metadata: 64, allocatedSlots: 1, payload: shellValueByteLength(p0.value), work: p0.value.length + 2 });
17419
17164
  fragments.push({ text: p0.value, literal: !!p0.quoted });
17420
17165
  } else {
17421
- await this.word(pattern, state, io, false, false, false, false, (text2, literal) => {
17422
- operation.reserve({ metadata: 64, allocatedSlots: 1, payload: shellValueByteLength(text2), work: text2.length + 2 });
17423
- fragments.push({ text: text2, literal });
17166
+ await this.word(pattern, state, io, false, false, false, false, (text3, literal) => {
17167
+ operation2.reserve({ metadata: 64, allocatedSlots: 1, payload: shellValueByteLength(text3), work: text3.length + 2 });
17168
+ fragments.push({ text: text3, literal });
17424
17169
  });
17425
17170
  }
17426
17171
  const collation = state.variables.LC_ALL || state.variables.LC_COLLATE || state.variables.LANG || "C";
@@ -17429,9 +17174,9 @@ var Runtime = class _Runtime {
17429
17174
  await this.ereDiagnostic(io, "[[ unsupported ERE profile: locale must be C, POSIX or UTF-8");
17430
17175
  return 2;
17431
17176
  }
17432
- await textToken(operation, subject, this.signal);
17177
+ await textToken(operation2, subject, this.signal);
17433
17178
  const name2 = "BASH_REMATCH";
17434
- const watch = await store.watch(name2, operation, this.signal);
17179
+ const watch = await store.watch(name2, operation2, this.signal);
17435
17180
  const ledger = new EreLedger({
17436
17181
  maxExpansionBytes: this.budget.limits.maxExpansionBytes,
17437
17182
  maxExpansionFields: this.budget.limits.maxExpansionFields
@@ -17460,14 +17205,14 @@ var Runtime = class _Runtime {
17460
17205
  }
17461
17206
  if (state.exported.has(name2)) throw new ArrayFailure("exported binding cannot be indexed");
17462
17207
  if (!watch.valid()) throw new ArrayFailure("stale binding");
17463
- const supersede = await stateMonitor(state).prepareTypedPublication(name2, operation, this.signal);
17464
- const tickets = operation.reserve({ generation: true, version: true, epoch: true, work: 8 });
17465
- const prepared = await store.prepareName(name2, operation, this.signal);
17208
+ const supersede = await stateMonitor(state).prepareTypedPublication(name2, operation2, this.signal);
17209
+ const tickets = operation2.reserve({ generation: true, version: true, epoch: true, work: 8 });
17210
+ const prepared = await store.prepareName(name2, operation2, this.signal);
17466
17211
  staged = IndexedBinding.create(store.owner);
17467
17212
  if (result.matched) for (let index = 0; index < result.captures.length; index++) {
17468
17213
  const span = result.captures[index];
17469
17214
  const size = span === null ? 0 : span.end - span.start;
17470
- operation.reserve({ payload: size, metadata: 32, work: size + 2 });
17215
+ operation2.reserve({ payload: size, metadata: 32, work: size + 2 });
17471
17216
  const value = span === null ? "" : subject.slice(span.start, span.end);
17472
17217
  const token = await textToken(staged.owner, value, this.signal);
17473
17218
  try {
@@ -17598,13 +17343,13 @@ var Runtime = class _Runtime {
17598
17343
  clearOutcomeReport() {
17599
17344
  if (this.outcomeFrame) this.outcomeFrame.report = void 0;
17600
17345
  }
17601
- async diagnostic(io, text2) {
17346
+ async diagnostic(io, text3) {
17602
17347
  const prefix = `${io.scriptName ?? "shell"}: line ${io.diagnosticLine ?? 1}: `;
17603
- if (typeof text2 === "string") return writeDiagnostic(io.stderr, `${prefix}${text2}
17348
+ if (typeof text3 === "string") return writeDiagnostic(io.stderr, `${prefix}${text3}
17604
17349
  `, this.signal);
17605
17350
  const allocation = this.budget.values.scope();
17606
17351
  try {
17607
- const value = concatShellValues([prefix, text2, "\n"], allocation);
17352
+ const value = concatShellValues([prefix, text3, "\n"], allocation);
17608
17353
  await io.stderr.write(shellValueBytes(value, allocation));
17609
17354
  } finally {
17610
17355
  allocation.close();
@@ -17731,14 +17476,14 @@ var Runtime = class _Runtime {
17731
17476
  if (st.nounset || arrayStore(st)?.get(subVar) || stateMonitor(st)?.hasOverlay(subVar)) throw new ArrayFailure("complex var subscript in sync arithmetic");
17732
17477
  const rawSub = this._syncArithRawVars[subVar];
17733
17478
  if (typeof rawSub !== "string" || rawSub.length === 0) throw new ArrayFailure("empty var subscript in sync arithmetic");
17734
- resolvedSub = shellValueText(stateMonitor(st)?.values.get(subVar, rawSub) ?? rawSub);
17479
+ resolvedSub = this._syncArithRawWriteOnly && this._syncArithTouched?.has(subVar) ? rawSub : shellValueText(stateMonitor(st)?.values.get(subVar, rawSub) ?? rawSub);
17735
17480
  } else if (/^[a-zA-Z_][a-zA-Z_0-9]*$/.test(resolvedSub)) {
17736
17481
  const st = this._syncArithState;
17737
17482
  const binding = arrayStore(st)?.get(variable);
17738
17483
  if (!binding || !binding.associative) {
17739
- if (st.nounset || arrayStore(st)?.get(resolvedSub) || stateMonitor(st)?.hasOverlay(resolvedSub)) throw new ArrayFailure("complex indexed ident subscript in sync arithmetic");
17740
- const rawSub = this._syncArithRawVars[resolvedSub];
17741
- resolvedSub = rawSub === void 0 || rawSub === "" ? "0" : shellValueText(stateMonitor(st)?.values.get(resolvedSub, rawSub) ?? rawSub);
17484
+ const index = resolveSimpleArithOperand(resolvedSub, st, stateMonitor(st), arrayStore(st), this._syncArithRawWriteOnly ? this._syncArithTouched : void 0);
17485
+ if (index === void 0) throw new ArrayFailure("complex indexed ident subscript in sync arithmetic");
17486
+ resolvedSub = String(index);
17742
17487
  }
17743
17488
  } else {
17744
17489
  const st = this._syncArithState;
@@ -17904,22 +17649,22 @@ var Runtime = class _Runtime {
17904
17649
  }
17905
17650
  if (arrayStore(state)?.get(tree.name)) return false;
17906
17651
  const value = state.variables[tree.name] ?? (tree.name === "LINENO" ? String(line ?? 1) : tree.name === "_" ? state.lastArgument ?? "" : tree.name === "FUNCNAME" ? state.functionNames?.[0] : void 0);
17907
- const text2 = value === void 0 ? void 0 : this._syncArithRawWriteOnly && this._syncArithTouched?.has(tree.name) ? value : monitor?.values.get(tree.name, value) ?? value;
17908
- if (text2 === void 0 || text2 === "") return true;
17909
- if (typeof text2 !== "string") return false;
17910
- let index = text2[0] === "+" || text2[0] === "-" ? 1 : 0;
17911
- if (index === text2.length) return false;
17652
+ const text3 = value === void 0 ? void 0 : this._syncArithRawWriteOnly && this._syncArithTouched?.has(tree.name) ? value : monitor?.values.get(tree.name, value) ?? value;
17653
+ if (text3 === void 0 || text3 === "") return true;
17654
+ if (typeof text3 !== "string") return false;
17655
+ let index = text3[0] === "+" || text3[0] === "-" ? 1 : 0;
17656
+ if (index === text3.length) return false;
17912
17657
  let allDigits = true;
17913
- for (; index < text2.length; index++) {
17914
- const code = text2.charCodeAt(index);
17658
+ for (; index < text3.length; index++) {
17659
+ const code = text3.charCodeAt(index);
17915
17660
  if (code < 48 || code > 57) {
17916
17661
  allDigits = false;
17917
17662
  break;
17918
17663
  }
17919
17664
  }
17920
17665
  if (allDigits) return true;
17921
- if (depth < 8 && text2.length <= 64 && !text2.includes("/") && !text2.includes("%") && !text2.includes("<<") && !text2.includes(">>") && !text2.includes("**")) {
17922
- const subProg = prepareArithmetic(text2, this.budget.parsing);
17666
+ if (depth < 8 && text3.length <= 64 && !text3.includes("/") && !text3.includes("%") && !text3.includes("<<") && !text3.includes(">>") && !text3.includes("**")) {
17667
+ const subProg = prepareArithmetic(text3, this.budget.parsing);
17923
17668
  return !subProg.error && isSafeSmiProgram(subProg) && this.canSyncArithmeticWithoutFault(subProg.tree, state, line, depth + 1);
17924
17669
  }
17925
17670
  return false;
@@ -18064,7 +17809,7 @@ var Runtime = class _Runtime {
18064
17809
  resolvedVariables[reference] = value;
18065
17810
  return;
18066
17811
  }
18067
- const [name2, index, key, scalar] = JSON.parse(reference);
17812
+ const [name2, index, key, scalar2] = JSON.parse(reference);
18068
17813
  await this.arrayAssignment({
18069
17814
  kind: "element",
18070
17815
  name: name2,
@@ -18072,7 +17817,7 @@ var Runtime = class _Runtime {
18072
17817
  index: { decimal: String(index ?? 0), ...key == null ? {} : { word: { offset: 0, parts: [{ kind: "text", value: key, quoted: true }] } } },
18073
17818
  value: { offset: 0, parts: [{ kind: "text", value, quoted: true }] }
18074
17819
  }, state, io);
18075
- if (scalar && state.allexport) state.exported.add(name2);
17820
+ if (scalar2 && state.allexport) state.exported.add(name2);
18076
17821
  }
18077
17822
  };
18078
17823
  return evaluateArithmeticReferences(program, references, this.budget.parsing);
@@ -18171,6 +17916,7 @@ var Runtime = class _Runtime {
18171
17916
  const binding = arrayStore(state)?.get(name2);
18172
17917
  if (binding) return binding.get(binding.associative ? binding.keys.get("30")?.index ?? -1 : 0);
18173
17918
  if (name2 === "DIRSTACK") return state.cwd;
17919
+ if (name2 === "BASH_SUBSHELL") return state.variables.BASH_SUBSHELL ?? "0";
18174
17920
  if (name2 === "FUNCNAME" && state.variables.FUNCNAME === void 0) return state.functionNames?.[0];
18175
17921
  if (name2 === "_" && state.variables._ === void 0) return state.lastArgument ?? "";
18176
17922
  return state.variables[name2];
@@ -18274,7 +18020,7 @@ var Runtime = class _Runtime {
18274
18020
  if (saved.value !== void 0) await textToken(owner, saved.value, this.signal);
18275
18021
  if (!watch.valid()) throw new ArrayFailure("stale binding");
18276
18022
  binding = scalarLegacy ? void 0 : store.get(name2)?.retain();
18277
- typedSavedVariables.set(saved, { owner, binding, tickets, prepared: { name: token, admission }, watch, scalarLegacy });
18023
+ typedSavedVariables.set(saved, { owner, binding, tickets, prepared: { name: token, admission, identity: store.bindings.get(name2)?.identity }, watch, scalarLegacy });
18278
18024
  tickets.cleanup = () => {
18279
18025
  typedSavedVariables.delete(saved);
18280
18026
  };
@@ -18312,12 +18058,12 @@ var Runtime = class _Runtime {
18312
18058
  }
18313
18059
  async indexedEnvironment(state, env) {
18314
18060
  const store = requireArrays(state);
18315
- const operation = ArrayOwner.create(store.owner.ledger, store.owner);
18061
+ const operation2 = ArrayOwner.create(store.owner.ledger, store.owner);
18316
18062
  const holding = store.owner.hold();
18317
18063
  const epoch = stateMonitor(state).epoch;
18318
18064
  try {
18319
18065
  const keys = Object.keys(env);
18320
- operation.reserve({ metadata: 128 + keys.length * 64, allocatedSlots: keys.length * 2, work: keys.length * 5 + 8 });
18066
+ operation2.reserve({ metadata: 128 + keys.length * 64, allocatedSlots: keys.length * 2, work: keys.length * 5 + 8 });
18321
18067
  for (const key of keys) {
18322
18068
  const value = env[key];
18323
18069
  if (key.includes("\0") || key.includes("=") || typeof value !== "string" || value.includes("\0")) throw new TypeError("Invalid invoke environment entry");
@@ -18327,9 +18073,9 @@ var Runtime = class _Runtime {
18327
18073
  for (const key of keys) {
18328
18074
  await textToken(store.owner, key, this.signal);
18329
18075
  await textToken(store.owner, env[key], this.signal);
18330
- publications.set(key, operation.reserve({ generation: true, version: true, epoch: true, work: 8 }));
18076
+ publications.set(key, operation2.reserve({ generation: true, version: true, epoch: true, work: 8 }));
18331
18077
  }
18332
- const controls = operation.reserve({ epoch: true, work: state.exported.size + keys.length + 5 });
18078
+ const controls = operation2.reserve({ epoch: true, work: state.exported.size + keys.length + 5 });
18333
18079
  this.signal.throwIfAborted();
18334
18080
  if (stateMonitor(state).epoch !== epoch) throw new ArrayFailure("stale state snapshot");
18335
18081
  stateMonitor(state).publish(controls, void 0, () => {
@@ -18345,7 +18091,7 @@ var Runtime = class _Runtime {
18345
18091
  }
18346
18092
  } finally {
18347
18093
  try {
18348
- await operation.close();
18094
+ await operation2.close();
18349
18095
  } finally {
18350
18096
  holding.release();
18351
18097
  }
@@ -18353,22 +18099,22 @@ var Runtime = class _Runtime {
18353
18099
  }
18354
18100
  async unsetIndexed(state, name2, index) {
18355
18101
  const store = requireArrays(state);
18356
- const operation = ArrayOwner.create(store.owner.ledger, store.owner);
18102
+ const operation2 = ArrayOwner.create(store.owner.ledger, store.owner);
18357
18103
  const holding = store.owner.hold();
18358
18104
  let staged;
18359
18105
  try {
18360
18106
  if (state.readonlyVariables?.has(name2)) throw new ArrayFailure("readonly binding");
18361
- const watch = await store.watch(name2, operation, this.signal);
18362
- const tickets = operation.reserve({ generation: true, version: true, epoch: true, work: 8 });
18107
+ const watch = await store.watch(name2, operation2, this.signal);
18108
+ const tickets = operation2.reserve({ generation: true, version: true, epoch: true, work: 8 });
18363
18109
  const current = store.get(name2);
18364
18110
  if (index !== void 0 && current) {
18365
18111
  staged = index === "members" ? IndexedBinding.create(store.owner) : await current.copy(this.signal);
18366
18112
  staged.assigned = current.assigned;
18367
18113
  let maximum = -1;
18368
18114
  for (const key of staged.values.keys()) {
18369
- operation.reserve({ work: 2 }).release();
18115
+ operation2.reserve({ work: 2 }).release();
18370
18116
  if (key !== index && key > maximum) maximum = key;
18371
- await operation.ledger.checkpoint(this.signal, 2);
18117
+ await operation2.ledger.checkpoint(this.signal, 2);
18372
18118
  }
18373
18119
  if (typeof index === "number") staged.remove(index);
18374
18120
  staged.maximum = maximum;
@@ -18391,7 +18137,7 @@ var Runtime = class _Runtime {
18391
18137
  } finally {
18392
18138
  try {
18393
18139
  await staged?.release();
18394
- await operation.close();
18140
+ await operation2.close();
18395
18141
  } finally {
18396
18142
  holding.release();
18397
18143
  }
@@ -18404,13 +18150,13 @@ var Runtime = class _Runtime {
18404
18150
  }
18405
18151
  async arrayZero(state, name2, io, expand, append = false, freeze = false) {
18406
18152
  const store = requireArrays(state);
18407
- const operation = ArrayOwner.create(store.owner.ledger, store.owner);
18153
+ const operation2 = ArrayOwner.create(store.owner.ledger, store.owner);
18408
18154
  const holding = store.owner.hold();
18409
18155
  const valueAllocation = this.budget.values.scope();
18410
18156
  let staged;
18411
18157
  try {
18412
- const watch = await store.watch(name2, operation, this.signal);
18413
- const tickets = operation.reserve({ generation: true, version: true, epoch: true, work: 8 });
18158
+ const watch = await store.watch(name2, operation2, this.signal);
18159
+ const tickets = operation2.reserve({ generation: true, version: true, epoch: true, work: 8 });
18414
18160
  let frozenAttributes;
18415
18161
  if (freeze) {
18416
18162
  store.owner.reserve({ metadata: state.readonlyVariables ? 32 : 96, slots: 1, work: 5 });
@@ -18423,10 +18169,10 @@ var Runtime = class _Runtime {
18423
18169
  const current = store.get(name2);
18424
18170
  if (!current) throw new ArrayFailure("stale binding");
18425
18171
  staged = await current.copy(this.signal);
18426
- const index = staged.associative ? await staged.keyIndex("0", operation, this.signal, true) : 0;
18172
+ const index = staged.associative ? await staged.keyIndex("0", operation2, this.signal, true) : 0;
18427
18173
  const previous = current.getValue(index) ?? "";
18428
18174
  const integer4 = state.variableAttributes?.get(name2)?.includes("i");
18429
- let value = !append || integer4 ? expanded : typeof previous === "string" && typeof expanded === "string" ? await this.arrayJoin(operation, [previous, expanded], "") : concatShellValues([previous, expanded], valueAllocation);
18175
+ let value = !append || integer4 ? expanded : typeof previous === "string" && typeof expanded === "string" ? await this.arrayJoin(operation2, [previous, expanded], "") : concatShellValues([previous, expanded], valueAllocation);
18430
18176
  value = await this.attributeValue(state, name2, value, io, "assignment", append ? previous : void 0);
18431
18177
  const token = await textToken(staged.owner, value, this.signal);
18432
18178
  try {
@@ -18435,7 +18181,7 @@ var Runtime = class _Runtime {
18435
18181
  token.release();
18436
18182
  throw error;
18437
18183
  }
18438
- const supersede = await stateMonitor(state).prepareTypedPublication(name2, operation, this.signal);
18184
+ const supersede = await stateMonitor(state).prepareTypedPublication(name2, operation2, this.signal);
18439
18185
  this.signal.throwIfAborted();
18440
18186
  this.assertArrayWritable(state, name2);
18441
18187
  if (!watch.valid()) throw new ArrayFailure("stale binding");
@@ -18455,7 +18201,7 @@ var Runtime = class _Runtime {
18455
18201
  } finally {
18456
18202
  try {
18457
18203
  await staged?.release();
18458
- await operation.close();
18204
+ await operation2.close();
18459
18205
  } finally {
18460
18206
  valueAllocation.close();
18461
18207
  holding.release();
@@ -18852,6 +18598,19 @@ var Runtime = class _Runtime {
18852
18598
  }
18853
18599
  return p0.operator !== void 0 ? this.applySyncArrayMemberOperator(out, p0, rawState) : out;
18854
18600
  }
18601
+ syncArraySubscriptWord(index, state) {
18602
+ if (byteLocale(state.variables) || state.depth >= 24) return void 0;
18603
+ const cached = index;
18604
+ const word = index.word ?? (cached._cachedSyntax === state.extensions?.syntax ? cached._cachedWord : void 0);
18605
+ if (word) return word;
18606
+ try {
18607
+ cached._cachedWord = parseArraySubscript(index.source ?? index.decimal, this.budget.parsing, false, state.depth, false, state.extensions?.syntax);
18608
+ cached._cachedSyntax = state.extensions?.syntax;
18609
+ return cached._cachedWord;
18610
+ } catch {
18611
+ return void 0;
18612
+ }
18613
+ }
18855
18614
  tryFastArrayAssignmentSync(assignment, state, io, diagnosticLine, declaration, associative, ignoreYield = false) {
18856
18615
  if (!ignoreYield && hasYieldCheckpoint(this.signal)) return false;
18857
18616
  if (declaration) return false;
@@ -19090,11 +18849,11 @@ var Runtime = class _Runtime {
19090
18849
  return false;
19091
18850
  }
19092
18851
  if (typeof val !== "string") return false;
19093
- const scalar = !current ? rawState.variables[name2] : void 0;
18852
+ const scalar2 = !current ? rawState.variables[name2] : void 0;
19094
18853
  const target = ensureBinding(false);
19095
18854
  if (!target) return false;
19096
- if (scalar !== void 0 && (idxNum !== 0 || assignment.append)) {
19097
- if (!this.tryFastArraySubscriptWriteSync(rawState, name2, "0", scalar)) return false;
18855
+ if (scalar2 !== void 0 && (idxNum !== 0 || assignment.append)) {
18856
+ if (!this.tryFastArraySubscriptWriteSync(rawState, name2, "0", scalar2)) return false;
19098
18857
  }
19099
18858
  if (assignment.append) {
19100
18859
  const prev = target.getValue(idxNum) ?? "";
@@ -19106,18 +18865,8 @@ var Runtime = class _Runtime {
19106
18865
  return false;
19107
18866
  }
19108
18867
  if (assignment.kind === "element" && current?.associative) {
19109
- const cachedIdx = assignment.index;
19110
- let word = assignment.index.word ?? (cachedIdx._cachedSyntax === rawState.extensions?.syntax ? cachedIdx._cachedWord : void 0);
19111
- if (!word) {
19112
- if (byteLocale(rawState.variables) || rawState.depth >= 24) return false;
19113
- try {
19114
- word = parseArraySubscript(assignment.index.source ?? assignment.index.decimal, this.budget.parsing, false, rawState.depth, false, rawState.extensions?.syntax);
19115
- cachedIdx._cachedWord = word;
19116
- cachedIdx._cachedSyntax = rawState.extensions?.syntax;
19117
- } catch {
19118
- return false;
19119
- }
19120
- }
18868
+ const word = this.syncArraySubscriptWord(assignment.index, rawState);
18869
+ if (!word) return false;
19121
18870
  let keyVal;
19122
18871
  let val;
19123
18872
  try {
@@ -19223,11 +18972,11 @@ var Runtime = class _Runtime {
19223
18972
  this.assertArrayWritable(state, name2, origin);
19224
18973
  if (controlNames.has(name2)) throw new ArrayFailure("control binding cannot be indexed");
19225
18974
  const store = requireArrays(state);
19226
- const operation = ArrayOwner.create(store.owner.ledger, store.owner);
18975
+ const operation2 = ArrayOwner.create(store.owner.ledger, store.owner);
19227
18976
  const holding = store.owner.hold();
19228
18977
  let staged;
19229
18978
  try {
19230
- const watch = await store.watch(name2, operation, this.signal);
18979
+ const watch = await store.watch(name2, operation2, this.signal);
19231
18980
  const current = store.get(name2);
19232
18981
  if (associative !== void 0 && current && current.associative !== associative) throw new ArrayFailure("cannot convert array kind");
19233
18982
  const isAssociative = associative ?? current?.associative;
@@ -19235,11 +18984,11 @@ var Runtime = class _Runtime {
19235
18984
  let selectedIndex;
19236
18985
  let planned = assignment.append && assignment.kind === "compound" ? initialMaximum + 1 : 0;
19237
18986
  if (assignment.kind === "element") {
19238
- operation.reserve({ work: assignment.index.decimal.length + 1 }).release();
19239
- if (!current?.associative) selectedIndex = await this.arrayIndex(current, assignment.index, state, io, operation, true, initialMaximum);
18987
+ operation2.reserve({ work: assignment.index.decimal.length + 1 }).release();
18988
+ if (!current?.associative) selectedIndex = await this.arrayIndex(current, assignment.index, state, io, operation2, true, initialMaximum);
19240
18989
  } else for (const entry of assignment.entries) {
19241
18990
  if (isAssociative && !entry.index) throw new ArrayFailure("associative compound entry requires a subscript");
19242
- operation.reserve({ work: entry.value.parts.length + (entry.index?.decimal.length ?? 0) + 2 }).release();
18991
+ operation2.reserve({ work: entry.value.parts.length + (entry.index?.decimal.length ?? 0) + 2 }).release();
19243
18992
  if (entry.index) {
19244
18993
  const index = numericIndex(entry.index);
19245
18994
  planned = !isAssociative && index !== void 0 ? index + 1 : null;
@@ -19254,17 +19003,17 @@ var Runtime = class _Runtime {
19254
19003
  if (certain && planned !== null) planned++;
19255
19004
  else planned = null;
19256
19005
  }
19257
- await operation.ledger.checkpoint(this.signal, entry.value.parts.length + 2);
19006
+ await operation2.ledger.checkpoint(this.signal, entry.value.parts.length + 2);
19258
19007
  }
19259
- const supersede = await stateMonitor(state).prepareTypedPublication(name2, operation, this.signal);
19260
- await this.prepareArrayObservers(state, operation);
19261
- const tickets = operation.reserve({ generation: true, version: true, epoch: true, work: 8 });
19008
+ const supersede = await stateMonitor(state).prepareTypedPublication(name2, operation2, this.signal);
19009
+ await this.prepareArrayObservers(state, operation2);
19010
+ const tickets = operation2.reserve({ generation: true, version: true, epoch: true, work: 8 });
19262
19011
  let frozenAttributes;
19263
19012
  if (declaration && !state.readonlyVariables?.has(name2)) {
19264
19013
  store.owner.reserve({ metadata: state.readonlyVariables ? 32 : 96, slots: 1, work: 5 });
19265
19014
  if (!state.readonlyVariables) frozenAttributes = stateMonitor(state).prepareCollection(/* @__PURE__ */ new Set(), "readonlyVariables");
19266
19015
  }
19267
- const prepared = await store.prepareName(name2, operation, this.signal);
19016
+ const prepared = await store.prepareName(name2, operation2, this.signal);
19268
19017
  const preserve = assignment.kind === "element" || assignment.append;
19269
19018
  const canReviseInPlace = false;
19270
19019
  const pendingInPlace = [];
@@ -19311,7 +19060,7 @@ var Runtime = class _Runtime {
19311
19060
  }
19312
19061
  writes++;
19313
19062
  };
19314
- const join = async (values) => values.every((value) => typeof value === "string") ? this.arrayJoin(operation, values, "") : concatShellValues(values, io[valueScope]);
19063
+ const join = async (values) => values.every((value) => typeof value === "string") ? this.arrayJoin(operation2, values, "") : concatShellValues(values, io[valueScope]);
19315
19064
  if (assignment.kind === "element") {
19316
19065
  let index;
19317
19066
  if (selectedIndex !== void 0) index = selectedIndex;
@@ -19326,14 +19075,14 @@ var Runtime = class _Runtime {
19326
19075
  await this.diagnostic(io, "associative array: bad array subscript");
19327
19076
  throw completedExit(1);
19328
19077
  }
19329
- const stagedKey = await targetBinding.stageKeyIndex(keyValue, operation, this.signal);
19078
+ const stagedKey = await targetBinding.stageKeyIndex(keyValue, operation2, this.signal);
19330
19079
  if (stagedKey.pendingKey) pendingKeys.push(stagedKey.pendingKey);
19331
19080
  index = stagedKey.index;
19332
- } else index = await this.arrayIndex(targetBinding, assignment.index, state, io, operation, true);
19081
+ } else index = await this.arrayIndex(targetBinding, assignment.index, state, io, operation2, true);
19333
19082
  const value = await join(await this.valueWord(assignment.value, state, io, false, false, false, false, void 0, false, false, 0));
19334
19083
  if (!current && state.variables[name2] !== void 0 && (index !== 0 || assignment.append)) {
19335
- const scalar = stateMonitor(state)?.values.get(name2, state.variables[name2]) ?? state.variables[name2];
19336
- const token = await valueToken(targetBinding.owner, scalar, this.signal);
19084
+ const scalar2 = stateMonitor(state)?.values.get(name2, state.variables[name2]) ?? state.variables[name2];
19085
+ const token = await valueToken(targetBinding.owner, scalar2, this.signal);
19337
19086
  try {
19338
19087
  targetBinding.insert(0, token);
19339
19088
  } catch (error) {
@@ -19357,7 +19106,7 @@ var Runtime = class _Runtime {
19357
19106
  }
19358
19107
  if (expandedEntry) continue;
19359
19108
  }
19360
- const index = entry.index ? await this.arrayIndex(targetBinding, entry.index, state, io, operation, true) : void 0;
19109
+ const index = entry.index ? await this.arrayIndex(targetBinding, entry.index, state, io, operation2, true) : void 0;
19361
19110
  const fields = await this.valueWord(entry.value, state, io, entry.index === void 0, false, false, false, void 0, false, entry.index === void 0, entry.index === void 0 ? void 0 : 0);
19362
19111
  if (index !== void 0) {
19363
19112
  const value = await join(fields);
@@ -19438,7 +19187,7 @@ var Runtime = class _Runtime {
19438
19187
  } finally {
19439
19188
  try {
19440
19189
  await staged?.release();
19441
- await operation.close();
19190
+ await operation2.close();
19442
19191
  } finally {
19443
19192
  holding.release();
19444
19193
  }
@@ -19480,11 +19229,11 @@ var Runtime = class _Runtime {
19480
19229
  if (state.depth >= this.budget.limits.maxSubstitutionDepth) this.budget.fail("maxSubstitutionDepth");
19481
19230
  this.budget.source(shellValueByteLength(source));
19482
19231
  const byteSource = typeof source !== "string";
19483
- const text2 = byteSource ? latin1Text(shellValueBytes(source)) : source;
19232
+ const text3 = byteSource ? latin1Text(shellValueBytes(source)) : source;
19484
19233
  const restoration = stateMonitor(state)?.restoration(true);
19485
19234
  try {
19486
19235
  state.depth++;
19487
- return await this.runCurrentText(text2, state, { ...io, diagnosticOffset: (io.diagnosticLine ?? 1) - 1 }, false, options?.name === void 0 ? void 0 : `${io.scriptName ?? "shell"}: ${options.name}`, byteSource, false);
19236
+ return await this.runCurrentText(text3, state, { ...io, diagnosticOffset: (io.diagnosticLine ?? 1) - 1 }, false, options?.name === void 0 ? void 0 : `${io.scriptName ?? "shell"}: ${options.name}`, byteSource, false);
19488
19237
  } finally {
19489
19238
  if (restoration) restoration.apply(() => {
19490
19239
  state.depth--;
@@ -19506,11 +19255,11 @@ var Runtime = class _Runtime {
19506
19255
  validateExitCode(status);
19507
19256
  return !signal.aborted && (frame.waiting?.(status) ?? false);
19508
19257
  },
19509
- waitInterruptibly: async (operation) => {
19258
+ waitInterruptibly: async (operation2) => {
19510
19259
  signal.throwIfAborted();
19511
19260
  const scope = io[invocationScope];
19512
19261
  scope.assertOpen();
19513
- if (typeof operation !== "function") throw new TypeError("Cooperative wait requires a callable operation");
19262
+ if (typeof operation2 !== "function") throw new TypeError("Cooperative wait requires a callable operation");
19514
19263
  if (frame.waiting) throw new Error("A cooperative wait is already active in this shell scope");
19515
19264
  const controller = new AbortController();
19516
19265
  const reason = Object.freeze({});
@@ -19527,7 +19276,7 @@ var Runtime = class _Runtime {
19527
19276
  scope.register(close);
19528
19277
  frame.waiting = interrupt;
19529
19278
  try {
19530
- const value = await scope.run(() => operation(AbortSignal.any([signal, scope.signal, controller.signal])));
19279
+ const value = await scope.run(() => operation2(AbortSignal.any([signal, scope.signal, controller.signal])));
19531
19280
  signal.throwIfAborted();
19532
19281
  return { kind: "completed", value };
19533
19282
  } catch (error) {
@@ -19578,8 +19327,8 @@ var Runtime = class _Runtime {
19578
19327
  checkName(name2);
19579
19328
  checkIndex(index, 4294967295);
19580
19329
  const binding = arrayStore(state)?.get(name2);
19581
- const scalar = state.variables[name2];
19582
- return retain(binding ? binding.getValue(index) : index === 0 && scalar !== void 0 ? stateMonitor(state)?.values.get(name2, scalar) ?? scalar : void 0);
19330
+ const scalar2 = state.variables[name2];
19331
+ return retain(binding ? binding.getValue(index) : index === 0 && scalar2 !== void 0 ? stateMonitor(state)?.values.get(name2, scalar2) ?? scalar2 : void 0);
19583
19332
  },
19584
19333
  assign: async (name2, value) => {
19585
19334
  checkName(name2);
@@ -19612,8 +19361,8 @@ var Runtime = class _Runtime {
19612
19361
  try {
19613
19362
  owned = this.budget.values.scope();
19614
19363
  owned.hold(reference);
19615
- const text2 = shellValueText(reference);
19616
- const match = /^([a-zA-Z_][a-zA-Z_0-9]*)(?:\[([^\[\]]+)\])?$/u.exec(text2);
19364
+ const text3 = shellValueText(reference);
19365
+ const match = /^([a-zA-Z_][a-zA-Z_0-9]*)(?:\[([^\[\]]+)\])?$/u.exec(text3);
19617
19366
  if (!match) {
19618
19367
  const result = failure(reference, "': not a valid identifier", "`");
19619
19368
  await close();
@@ -19621,7 +19370,7 @@ var Runtime = class _Runtime {
19621
19370
  }
19622
19371
  const name2 = match[1];
19623
19372
  const subscript = match[2];
19624
- const reservation = owned.reserve(128 + text2.length * 2, 1);
19373
+ const reservation = owned.reserve(128 + text3.length * 2, 1);
19625
19374
  const run = (action) => {
19626
19375
  try {
19627
19376
  assertOpen();
@@ -19644,9 +19393,9 @@ var Runtime = class _Runtime {
19644
19393
  };
19645
19394
  const handle = Object.freeze({
19646
19395
  unbindName: () => run(async () => {
19647
- if (state.readonlyVariables?.has(text2)) return failure(reference, ": cannot unset: readonly variable");
19648
- if (arrayStore(state)?.get(text2)) await this.unsetIndexed(state, text2);
19649
- else this.unsetVariable(state, text2);
19396
+ if (state.readonlyVariables?.has(text3)) return failure(reference, ": cannot unset: readonly variable");
19397
+ if (arrayStore(state)?.get(text3)) await this.unsetIndexed(state, text3);
19398
+ else this.unsetVariable(state, text3);
19650
19399
  return Object.freeze({ ok: true, value: void 0 });
19651
19400
  }),
19652
19401
  assignInteger: (value) => run(async () => {
@@ -19839,7 +19588,7 @@ var Runtime = class _Runtime {
19839
19588
  scope.assertOpen();
19840
19589
  if (closed) throw new ArrayFailure("indexed writer is closed");
19841
19590
  owner.assertOpen();
19842
- if (arrayStore(state) !== store || store.owner !== owner || identity !== void 0 && store.bindings.get(name2) !== identity) throw new ArrayFailure("incremental target identity changed");
19591
+ if (arrayStore(state) !== store || store.owner !== owner || identity !== void 0 && store.bindings.get(name2)?.identity !== identity) throw new ArrayFailure("incremental target identity changed");
19843
19592
  if (localIdentity() !== admittedLocal) throw new ArrayFailure("incremental target local identity changed");
19844
19593
  };
19845
19594
  try {
@@ -19884,8 +19633,8 @@ var Runtime = class _Runtime {
19884
19633
  await prepared.close();
19885
19634
  }
19886
19635
  }
19887
- identity = store.bindings.get(name2);
19888
- if (!identity) throw new ArrayFailure("incremental target is not indexed");
19636
+ identity = store.bindings.get(name2)?.identity;
19637
+ if (identity === void 0) throw new ArrayFailure("incremental target is not indexed");
19889
19638
  validate();
19890
19639
  } finally {
19891
19640
  watch.close();
@@ -19927,17 +19676,17 @@ var Runtime = class _Runtime {
19927
19676
  }
19928
19677
  }
19929
19678
  const current = store.get(name2);
19930
- const operation = ArrayOwner.create(owner.ledger, lifetime);
19679
+ const operation2 = ArrayOwner.create(owner.ledger, lifetime);
19931
19680
  let retained = false;
19932
19681
  let staged;
19933
19682
  let token;
19934
19683
  try {
19935
19684
  current.retain();
19936
19685
  retained = true;
19937
- const watch = await store.watch(name2, operation, this.signal);
19938
- const tickets = operation.reserve({ generation: true, version: true, epoch: true, work: 8 });
19939
- await this.prepareArrayObservers(state, operation);
19940
- token = await textToken(operation, value, this.signal);
19686
+ const watch = await store.watch(name2, operation2, this.signal);
19687
+ const tickets = operation2.reserve({ generation: true, version: true, epoch: true, work: 8 });
19688
+ await this.prepareArrayObservers(state, operation2);
19689
+ token = await textToken(operation2, value, this.signal);
19941
19690
  validate();
19942
19691
  if (!watch.valid() || store.get(name2) !== current) throw new ArrayFailure("incremental target changed during write");
19943
19692
  if (current.references > 2) staged = await current.copy(this.signal);
@@ -19963,7 +19712,7 @@ var Runtime = class _Runtime {
19963
19712
  try {
19964
19713
  if (retained) await current.release();
19965
19714
  } finally {
19966
- await operation.close();
19715
+ await operation2.close();
19967
19716
  }
19968
19717
  }
19969
19718
  }
@@ -21789,7 +21538,7 @@ var Runtime = class _Runtime {
21789
21538
  if (b && b.references === 1 && !st.watches.has(arrName) && !rawState.readonlyVariables?.has(arrName) && !rawState.exported.has(arrName) && !rawState.variableAttributes?.get(arrName) && !hasUnpreparedLocal(rawState, arrName) && !mon.hasOverlay(arrName) && (b.associative ? subStr.length > 0 && !/[$\x60\\"']/.test(subStr) : /^(?:0|[1-9][0-9]{0,8}|[a-zA-Z_][a-zA-Z0-9_]*(?:\s*[+-]\s*(?:0|[1-9][0-9]{0,6}))?)$/.test(subStr))) {
21790
21539
  targetOk = true;
21791
21540
  }
21792
- } else if (isShellIdentifier(w2Plain) && !controlNames.has(w2Plain) && !rawState.readonlyVariables?.has(w2Plain) && !rawState.variableAttributes?.get(w2Plain) && !st?.get(w2Plain) && !mon.hasOverlay(w2Plain)) {
21541
+ } else if (isShellIdentifier(w2Plain) && !printfSlowTargets.has(w2Plain) && !rawState.readonlyVariables?.has(w2Plain) && !rawState.variableAttributes?.get(w2Plain) && !st?.get(w2Plain) && !mon.hasOverlay(w2Plain)) {
21793
21542
  targetOk = true;
21794
21543
  }
21795
21544
  } else if (w2) {
@@ -23016,19 +22765,19 @@ var Runtime = class _Runtime {
23016
22765
  return finalStatus2;
23017
22766
  }
23018
22767
  let targetVal;
23019
- let formatted;
22768
+ let formatted2;
23020
22769
  let preEncoded;
23021
22770
  let lastArg = w0Plain;
23022
22771
  try {
23023
22772
  if (w0Plain === "echo" && command.words.length === 1) {
23024
22773
  targetVal = this.fastValueWord(r0.target, rawState, io, true, false, false, true, void 0, diagnosticLine);
23025
- formatted = "\n";
22774
+ formatted2 = "\n";
23026
22775
  } else if (w0Plain === "echo" && command.words.length === 2) {
23027
22776
  const arg0 = this.fastValueWord(command.words[1], rawState, io, true, false, false, true, void 0, diagnosticLine);
23028
22777
  if (typeof arg0 === "string" && !arg0.startsWith("-") && !arg0.includes("\0")) {
23029
22778
  targetVal = this.fastValueWord(r0.target, rawState, io, true, false, false, true, void 0, diagnosticLine);
23030
22779
  preEncoded = encodeRedirectTextWithNewlineToScratch(arg0);
23031
- if (preEncoded === void 0) formatted = `${arg0}
22780
+ if (preEncoded === void 0) formatted2 = `${arg0}
23032
22781
  `;
23033
22782
  lastArg = arg0;
23034
22783
  }
@@ -23045,24 +22794,24 @@ var Runtime = class _Runtime {
23045
22794
  }
23046
22795
  if (allStrings) {
23047
22796
  if (fastSubScratchArgs.length > 0) lastArg = fastSubScratchArgs[fastSubScratchArgs.length - 1];
23048
- if (w0Plain === "printf") formatted = tryFastPrintf(fastSubScratchArgs);
22797
+ if (w0Plain === "printf") formatted2 = tryFastPrintf(fastSubScratchArgs);
23049
22798
  else if (!fastSubScratchArgs[0]?.startsWith("-")) {
23050
22799
  const joined = `${fastSubScratchArgs.join(" ")}
23051
22800
  `;
23052
- if (!joined.includes("\0")) formatted = joined;
22801
+ if (!joined.includes("\0")) formatted2 = joined;
23053
22802
  }
23054
22803
  fastSubScratchArgs.length = 0;
23055
- if (formatted !== void 0) targetVal = this.fastValueWord(r0.target, rawState, io, true, false, false, true, void 0, diagnosticLine);
22804
+ if (formatted2 !== void 0) targetVal = this.fastValueWord(r0.target, rawState, io, true, false, false, true, void 0, diagnosticLine);
23056
22805
  } else fastSubScratchArgs.length = 0;
23057
22806
  }
23058
22807
  } catch {
23059
22808
  fastSubScratchArgs.length = 0;
23060
22809
  return void 0;
23061
22810
  }
23062
- if (preEncoded === void 0 && formatted === void 0 || typeof targetVal !== "string" || targetVal.length === 0 || targetVal.includes("\0")) return void 0;
22811
+ if (preEncoded === void 0 && formatted2 === void 0 || typeof targetVal !== "string" || targetVal.length === 0 || targetVal.includes("\0")) return void 0;
23063
22812
  const path = isCleanAbsolutePath(targetVal) ? targetVal : pathOf(rawState, targetVal);
23064
22813
  if (path.startsWith("/dev/") || path === "/dev") return void 0;
23065
- const encoded = preEncoded ?? encodeRedirectTextToScratch(formatted);
22814
+ const encoded = preEncoded ?? encodeRedirectTextToScratch(formatted2);
23066
22815
  const byteLength = encoded.byteLength;
23067
22816
  if (this.budget.bytes + byteLength > this.budget.maxOutputBytesSmi && byteLength > this.budget.limits.maxOutputBytes - this.budget.bytes) return void 0;
23068
22817
  if (!this.budget.canFileSystemOperation()) return void 0;
@@ -23309,7 +23058,7 @@ var Runtime = class _Runtime {
23309
23058
  const isSubTarget = openBr > 0 && targetSpec.endsWith("]") && targetSpec.length > openBr + 2;
23310
23059
  const rawTargetVar = isSubTarget ? targetSpec.slice(0, openBr) : targetSpec;
23311
23060
  const targetVar = isShellIdentifier(rawTargetVar) ? resolveSyncNameref(rawState, rawTargetVar) : "";
23312
- if (targetVar && isShellIdentifier(targetVar) && targetVar !== "OPTIND" && targetVar !== "PIPESTATUS" && targetVar !== "_" && !rawState.readonlyVariables?.has(targetVar) && !rawState.variableAttributes?.get(targetVar) && !monitor.hasOverlay(targetVar) && (isSubTarget ? Boolean(store?.get(targetVar)) : !store?.get(targetVar))) {
23061
+ if (targetVar && isShellIdentifier(targetVar) && !printfSlowTargets.has(targetVar) && !rawState.readonlyVariables?.has(targetVar) && !rawState.variableAttributes?.get(targetVar) && !monitor.hasOverlay(targetVar) && (isSubTarget ? Boolean(store?.get(targetVar)) : !store?.get(targetVar))) {
23313
23062
  fastSubScratchArgs.length = 0;
23314
23063
  let allStrings = true;
23315
23064
  try {
@@ -23335,9 +23084,9 @@ var Runtime = class _Runtime {
23335
23084
  allStrings = false;
23336
23085
  }
23337
23086
  const lastArg = fastSubScratchArgs.length > 0 ? fastSubScratchArgs[fastSubScratchArgs.length - 1] : targetSpec;
23338
- const formatted = allStrings ? tryFastPrintf(fastSubScratchArgs) : void 0;
23087
+ const formatted2 = allStrings ? tryFastPrintf(fastSubScratchArgs) : void 0;
23339
23088
  fastSubScratchArgs.length = 0;
23340
- if (formatted !== void 0 && formatted.length <= this.budget.limits.maxExpansionBytes && (formatted.length * 3 <= this.budget.limits.maxExpansionBytes || shellValueByteLength(formatted) <= this.budget.limits.maxExpansionBytes)) {
23089
+ if (formatted2 !== void 0 && formatted2.length <= this.budget.limits.maxExpansionBytes && (formatted2.length * 3 <= this.budget.limits.maxExpansionBytes || shellValueByteLength(formatted2) <= this.budget.limits.maxExpansionBytes)) {
23341
23090
  let wroteTarget = true;
23342
23091
  if (isSubTarget) {
23343
23092
  wroteTarget = this.tryFastArrayAssignmentSync({
@@ -23345,12 +23094,12 @@ var Runtime = class _Runtime {
23345
23094
  name: targetVar,
23346
23095
  append: false,
23347
23096
  index: stringIndex(targetSpec.slice(openBr + 1, -1), this.budget.parsing),
23348
- value: { offset: 0, parts: [{ kind: "text", value: formatted, quoted: true }] }
23097
+ value: { offset: 0, parts: [{ kind: "text", value: formatted2, quoted: true }] }
23349
23098
  }, rawState, io, diagnosticLine);
23350
23099
  } else if (this._syncArithRawWriteOnly && this._syncArithTouched) {
23351
- rawState.variables[targetVar] = formatted;
23100
+ rawState.variables[targetVar] = formatted2;
23352
23101
  this._syncArithTouched.add(targetVar);
23353
- } else monitor.publishStringVariable(targetVar, formatted);
23102
+ } else monitor.publishStringVariable(targetVar, formatted2);
23354
23103
  if (wroteTarget) {
23355
23104
  if (rawState.extensions && !rawState.extensions.eventDepth) publishCommandSpelling(rawState, commandSpelling(command));
23356
23105
  const restEpoch = monitor.chargeInternal(syncRestorationCharge, syncRestorationTickets).epoch;
@@ -23826,17 +23575,17 @@ var Runtime = class _Runtime {
23826
23575
  const def = fastSyncSink || fastPipeSink || syncOut ? this.commands.get(w0Plain) : void 0;
23827
23576
  if ((fastSyncSink || fastPipeSink || syncOut) && def && (w0Plain === "printf" ? def.execute === printfCommand.execute : defaultEchoExecutors.has(def.execute)) && command.words.length <= this.budget.maxExpansionFieldsSmi && (this.arePureArgWords(command.words, rawState) || command.words.every((w, idx) => idx === 0 ? this.isPureArgWord(w, rawState) : this.isPureArgWord(w, rawState) || this.canSyncArrayMembersWord(w, rawState))) && (canMutatePipeStatus || elem0.text.shellValue === "0") && (!pipeline.negate || ignored || !rawState.errexit)) {
23828
23577
  if (rawState.extensions && !rawState.extensions.eventDepth) publishCommandSpelling(rawState, commandSpelling(command));
23829
- let formatted;
23578
+ let formatted2;
23830
23579
  let preEncoded;
23831
23580
  let lastArg = w0Plain;
23832
23581
  try {
23833
23582
  if (w0Plain === "echo" && command.words.length === 1) {
23834
- formatted = "\n";
23583
+ formatted2 = "\n";
23835
23584
  } else if (w0Plain === "echo" && command.words.length === 2 && !this.canSyncArrayMembersWord(command.words[1], rawState)) {
23836
23585
  const arg0 = this.fastValueWord(command.words[1], rawState, io, true, false, false, true, void 0, diagnosticLine);
23837
23586
  if (typeof arg0 === "string" && !arg0.startsWith("-") && !arg0.includes("\0")) {
23838
23587
  preEncoded = encodeRedirectTextWithNewlineToScratch(arg0);
23839
- if (!preEncoded) formatted = `${arg0}
23588
+ if (!preEncoded) formatted2 = `${arg0}
23840
23589
  `;
23841
23590
  lastArg = arg0;
23842
23591
  }
@@ -23863,11 +23612,11 @@ var Runtime = class _Runtime {
23863
23612
  }
23864
23613
  if (allStrings) {
23865
23614
  if (fastSubScratchArgs.length > 0) lastArg = fastSubScratchArgs[fastSubScratchArgs.length - 1];
23866
- if (w0Plain === "printf") formatted = tryFastPrintf(fastSubScratchArgs);
23615
+ if (w0Plain === "printf") formatted2 = tryFastPrintf(fastSubScratchArgs);
23867
23616
  else if (!fastSubScratchArgs[0]?.startsWith("-")) {
23868
23617
  const joined = `${fastSubScratchArgs.join(" ")}
23869
23618
  `;
23870
- if (!joined.includes("\0")) formatted = joined;
23619
+ if (!joined.includes("\0")) formatted2 = joined;
23871
23620
  }
23872
23621
  }
23873
23622
  fastSubScratchArgs.length = 0;
@@ -23876,8 +23625,8 @@ var Runtime = class _Runtime {
23876
23625
  fastSubScratchArgs.length = 0;
23877
23626
  return void 0;
23878
23627
  }
23879
- if (preEncoded !== void 0 || formatted !== void 0) {
23880
- const encoded = preEncoded ?? encodeRedirectTextToScratch(formatted);
23628
+ if (preEncoded !== void 0 || formatted2 !== void 0) {
23629
+ const encoded = preEncoded ?? encodeRedirectTextToScratch(formatted2);
23881
23630
  const byteLength = encoded.byteLength;
23882
23631
  if (this.budget.bytes + byteLength <= this.budget.maxOutputBytesSmi || byteLength <= this.budget.limits.maxOutputBytes - this.budget.bytes) {
23883
23632
  const restEpoch = monitor.chargeInternal(syncRestorationCharge, syncRestorationTickets).epoch;
@@ -24026,6 +23775,7 @@ var Runtime = class _Runtime {
24026
23775
  let simpleRead = true;
24027
23776
  let readDelim = 10;
24028
23777
  let arrayTarget;
23778
+ let readLastArgument = command.words[command.words.length - 1].plain;
24029
23779
  while (readWordIdx < command.words.length) {
24030
23780
  const p = command.words[readWordIdx].plain;
24031
23781
  if (p === void 0) {
@@ -24054,6 +23804,7 @@ var Runtime = class _Runtime {
24054
23804
  delimStr = void 0;
24055
23805
  }
24056
23806
  }
23807
+ if (readWordIdx === command.words.length - 1) readLastArgument = delimStr;
24057
23808
  }
24058
23809
  if (delimStr !== void 0 && delimStr.length >= 1 && delimStr.charCodeAt(0) > 0 && delimStr.charCodeAt(0) < 128) {
24059
23810
  readDelim = delimStr.charCodeAt(0);
@@ -24262,7 +24013,7 @@ var Runtime = class _Runtime {
24262
24013
  this.budget.tick();
24263
24014
  rawState.substitutionStatus = 0;
24264
24015
  if (rawState.variables._ !== void 0) delete rawState.variables._;
24265
- rawState.lastArgument = command.words[command.words.length - 1].plain;
24016
+ rawState.lastArgument = readLastArgument;
24266
24017
  if (io.assignmentDiagnosticContext) io.assignmentDiagnosticContext.name = void 0;
24267
24018
  if (!existing) {
24268
24019
  monitor.lazyPipeStatus = singleStatusZero;
@@ -24843,6 +24594,7 @@ var Runtime = class _Runtime {
24843
24594
  }
24844
24595
  }
24845
24596
  if (canSyncFn) {
24597
+ if (rawState.functionDepth >= this.budget.limits.maxFunctionDepth) this.budget.fail("maxFunctionDepth");
24846
24598
  const prevCommands = this.budget.commands;
24847
24599
  this.budget.tick();
24848
24600
  rawState.substitutionStatus = 0;
@@ -25140,12 +24892,12 @@ var Runtime = class _Runtime {
25140
24892
  return void 0;
25141
24893
  }
25142
24894
  const def = this.commands.get("printf");
25143
- const isPlainTargetId = targetSpec !== void 0 && /^[a-zA-Z_][a-zA-Z_0-9]*$/.test(targetSpec) && targetSpec !== "OPTIND" && targetSpec !== "PIPESTATUS";
24895
+ const isPlainTargetId = targetSpec !== void 0 && isShellIdentifier(targetSpec) && !printfSlowTargets.has(targetSpec);
25144
24896
  const isScalarTarget = isPlainTargetId && !store?.get(targetSpec);
25145
24897
  const brkIdx = targetSpec !== void 0 && !isPlainTargetId && targetSpec.endsWith("]") ? targetSpec.indexOf("[") : -1;
25146
24898
  const arrName = isPlainTargetId && !isScalarTarget ? targetSpec : brkIdx > 0 ? targetSpec.slice(0, brkIdx) : void 0;
25147
24899
  const subExpr = isPlainTargetId && !isScalarTarget ? "0" : brkIdx > 0 ? targetSpec.slice(brkIdx + 1, -1) : void 0;
25148
- const isArrayTarget = arrName !== void 0 && /^[a-zA-Z_][a-zA-Z_0-9]*$/.test(arrName) && !controlNames.has(arrName) && subExpr !== void 0 && subExpr.length > 0 && !subExpr.includes("$") && !subExpr.includes("`");
24900
+ const isArrayTarget = arrName !== void 0 && isShellIdentifier(arrName) && !printfSlowTargets.has(arrName) && subExpr !== void 0 && subExpr.length > 0 && !subExpr.includes("$") && !subExpr.includes("`");
25149
24901
  if (def?.execute === printfCommand.execute && (isScalarTarget || isArrayTarget) && command.words.length <= this.budget.maxExpansionFieldsSmi) {
25150
24902
  fastSubScratchArgs.length = 0;
25151
24903
  let allStrings = true;
@@ -25175,16 +24927,16 @@ var Runtime = class _Runtime {
25175
24927
  }
25176
24928
  if (allStrings && fastSubScratchArgs.length > 0 && !fastSubScratchArgs[0].startsWith("-")) {
25177
24929
  const lastPrintfArg = fastSubScratchArgs[fastSubScratchArgs.length - 1];
25178
- const formatted = tryFastPrintf(fastSubScratchArgs);
24930
+ const formatted2 = tryFastPrintf(fastSubScratchArgs);
25179
24931
  fastSubScratchArgs.length = 0;
25180
- if (formatted !== void 0 && formatted.length <= this.budget.limits.maxExpansionBytes) {
24932
+ if (formatted2 !== void 0 && formatted2.length <= this.budget.limits.maxExpansionBytes) {
25181
24933
  if (isArrayTarget) {
25182
24934
  if (!this.tryFastArrayAssignmentSync({
25183
24935
  kind: "element",
25184
24936
  name: arrName,
25185
24937
  append: false,
25186
24938
  index: stringIndex(subExpr, this.budget.parsing),
25187
- value: { offset: 0, parts: [{ kind: "text", value: formatted, quoted: true }] }
24939
+ value: { offset: 0, parts: [{ kind: "text", value: formatted2, quoted: true }] }
25188
24940
  }, rawState, io, diagnosticLine)) return void 0;
25189
24941
  }
25190
24942
  if (isPlainTargetId && isArrayTarget && rawState.allexport) rawState.exported.add(arrName);
@@ -25195,10 +24947,10 @@ var Runtime = class _Runtime {
25195
24947
  rawState.lastArgument = lastPrintfArg;
25196
24948
  if (isScalarTarget) {
25197
24949
  if (this._syncArithRawWriteOnly && this._syncArithTouched) {
25198
- rawState.variables[targetSpec] = formatted;
24950
+ rawState.variables[targetSpec] = formatted2;
25199
24951
  this._syncArithTouched.add(targetSpec);
25200
24952
  } else {
25201
- monitor.publishStringVariable(targetSpec, formatted);
24953
+ monitor.publishStringVariable(targetSpec, formatted2);
25202
24954
  }
25203
24955
  if (rawState.allexport) monitor.proxy.exported.add(targetSpec);
25204
24956
  }
@@ -25519,7 +25271,147 @@ var Runtime = class _Runtime {
25519
25271
  this._syncLoopInvariantSubMap.set(part, { text: res, outBytes, exitStatus: 0, dynamic: usesInduction });
25520
25272
  return true;
25521
25273
  }
25274
+ admitSyncArrayLoop(command, state) {
25275
+ const monitor = stateMonitor(state);
25276
+ const store = monitor?.store;
25277
+ if (!store || store.watches.size || hasUnpreparedLocals(state) || state.depth >= 24 || byteLocale(state.variables) || state.nounset || hasActiveVariableAttributes(state) || this.budget.limits.maxExpansionBytes !== Infinity || this.budget.limits.maxExpansionFields !== Infinity) return void 0;
25278
+ const initializer = command.expressions[0]?.tree;
25279
+ if (initializer?.kind !== "binary" || initializer.operator !== "=" || initializer.left.kind !== "name") return void 0;
25280
+ const induction = initializer.left.name;
25281
+ const dynamicNames = /* @__PURE__ */ new Set(["PIPESTATUS", "LINENO", "_", "FUNCNAME", "DIRSTACK", "BASH_SUBSHELL"]);
25282
+ const assignments2 = [];
25283
+ const appends = /* @__PURE__ */ new Map();
25284
+ for (const list of command.body.lists) {
25285
+ if (list.terminator || list.pipelines.length !== 1) return void 0;
25286
+ const pipeline = list.pipelines[0];
25287
+ const cmd = pipeline.commands[0];
25288
+ if (pipeline.negate || pipeline.commands.length !== 1 || cmd?.kind !== "simple" || cmd.redirects.length || cmd.words.length !== 1) return void 0;
25289
+ const assignment = getArrayAssignment(cmd.words[0]) ?? this.assignment(cmd.words[0]);
25290
+ if (!assignment || assignment.name === induction || controlNames.has(assignment.name) || dynamicNames.has(assignment.name) || monitor.hasOverlay(assignment.name) || state.readonlyVariables?.has(assignment.name)) return void 0;
25291
+ if ("kind" in assignment) {
25292
+ const binding = store.get(assignment.name);
25293
+ if (!binding || binding.references !== 1 || state.exported.has(assignment.name)) return void 0;
25294
+ if (assignment.kind === "element") {
25295
+ if (!binding.associative || assignment.append) return void 0;
25296
+ } else {
25297
+ if (binding.associative || !assignment.append || assignment.entries.some((entry2) => entry2.index || entry2.append)) return void 0;
25298
+ appends.set(assignment.name, (appends.get(assignment.name) ?? 0) + assignment.entries.length);
25299
+ }
25300
+ } else if (assignment.append || store.get(assignment.name) || ["IFS", "LC_ALL", "LC_CTYPE", "LC_COLLATE", "LANG"].includes(assignment.name)) return void 0;
25301
+ assignments2.push(assignment);
25302
+ }
25303
+ if (assignments2.length > 30 || !assignments2.some((assignment) => "kind" in assignment && assignment.kind === "element")) return void 0;
25304
+ const integer4 = { min: 1, max: 20, integer: true };
25305
+ const decimal = (value) => {
25306
+ if (value === "") return true;
25307
+ let i = value[0] === "-" ? 1 : 0;
25308
+ if (i === value.length || value.length > 20 || value[i] === "0" && i + 1 !== value.length) return false;
25309
+ for (; i < value.length; i++) if (value[i] < "0" || value[i] > "9") return false;
25310
+ return true;
25311
+ };
25312
+ const literalShape = (value) => {
25313
+ if (typeof value !== "string") return void 0;
25314
+ for (let i = 0; i < value.length; i++) if (value.charCodeAt(i) >= 128) return void 0;
25315
+ return { min: value.length, max: value.length, integer: decimal(value) };
25316
+ };
25317
+ const integerArrays = /* @__PURE__ */ new Set();
25318
+ for (const [name2, { binding }] of store.bindings) {
25319
+ if (!binding.associative) continue;
25320
+ if (![...binding.values.values()].every((slot) => typeof slot.text.shellValue === "string" && decimal(slot.text.shellValue))) continue;
25321
+ const writesInteger = assignments2.every((assignment) => {
25322
+ if (assignment.name !== name2 || !("kind" in assignment) || assignment.kind !== "element") return true;
25323
+ const parts = assignment.value.parts.filter((part) => part.kind !== "text" || part.value !== "");
25324
+ return parts.length === 1 && parts[0].kind === "arithmetic" || parts.every((part) => part.kind === "text") && decimal(parts.map((part) => part.value).join(""));
25325
+ });
25326
+ if (writesInteger) integerArrays.add(name2);
25327
+ }
25328
+ const entry = /* @__PURE__ */ new Map();
25329
+ for (const assignment of assignments2) {
25330
+ if ("kind" in assignment) continue;
25331
+ const raw = state.variables[assignment.name];
25332
+ const shape = literalShape(raw === void 0 ? "" : monitor.values.get(assignment.name, raw) ?? raw);
25333
+ if (!shape) return void 0;
25334
+ entry.set(assignment.name, shape);
25335
+ }
25336
+ for (let pass = 0; pass < 32; pass++) {
25337
+ const values = new Map(entry);
25338
+ values.set(induction, integer4);
25339
+ const words = /* @__PURE__ */ new WeakSet();
25340
+ const integerWords = /* @__PURE__ */ new WeakSet();
25341
+ const scalar2 = (name2) => {
25342
+ if (!isShellIdentifier(name2) || controlNames.has(name2) || dynamicNames.has(name2) || store.get(name2) || monitor.hasOverlay(name2) || hasUnpreparedLocal(state, name2)) return void 0;
25343
+ const known = values.get(name2);
25344
+ if (known) return known;
25345
+ const raw = state.variables[name2];
25346
+ return literalShape(raw === void 0 ? "" : monitor.values.get(name2, raw) ?? raw);
25347
+ };
25348
+ const shapeWord = (word, key = false) => {
25349
+ if (!word.parts.length) return void 0;
25350
+ const shapes = [];
25351
+ for (const part of word.parts) {
25352
+ let shape;
25353
+ if (part.kind === "text") {
25354
+ if (part.byteValue || invokedValues.has(part) || !part.quoted && part.value.includes("~")) return void 0;
25355
+ shape = literalShape(part.value);
25356
+ } else if (part.kind === "arithmetic") {
25357
+ const names = /* @__PURE__ */ new Set();
25358
+ if (!collectPureReadOnlySmiNames(part.expression, names) || [...names].some((name2) => !scalar2(name2)?.integer)) return void 0;
25359
+ shape = integer4;
25360
+ } else if (part.kind === "variable") {
25361
+ if (part.indirect || part.specialParameter || part.prefixNames || part.length || part.substring || part.transform || part.keys || dynamicNames.has(part.name)) return void 0;
25362
+ const selector = getArraySelector(part);
25363
+ if (selector) {
25364
+ if (key || selector.kind !== "element" || !store.get(part.name)?.associative || monitor.hasOverlay(part.name) || controlNames.has(part.name)) return void 0;
25365
+ const index = this.syncArraySubscriptWord(selector.index, state);
25366
+ if (!index || !shapeWord(index, true)) return void 0;
25367
+ shape = { min: 0, max: integerArrays.has(part.name) ? 20 : Infinity, integer: integerArrays.has(part.name) };
25368
+ if (part.operator !== void 0) {
25369
+ if (part.operator !== "-" && part.operator !== ":-" || !part.alternate || !part.alternate.parts.every((p) => p.kind === "text")) return void 0;
25370
+ const alternate = shapeWord(part.alternate);
25371
+ if (!alternate) return void 0;
25372
+ shape = { min: part.operator === ":-" ? Math.min(1, alternate.min) : 0, max: Math.max(shape.max, alternate.max), integer: shape.integer && alternate.integer };
25373
+ }
25374
+ } else {
25375
+ if (part.operator !== void 0) return void 0;
25376
+ shape = scalar2(part.name);
25377
+ }
25378
+ } else return void 0;
25379
+ if (!shape) return void 0;
25380
+ shapes.push(shape);
25381
+ }
25382
+ const nonempty = shapes.filter((shape) => shape.max !== 0);
25383
+ const result = { min: shapes.reduce((sum, shape) => sum + shape.min, 0), max: shapes.reduce((sum, shape) => sum + shape.max, 0), integer: nonempty.length === 0 || nonempty.length === 1 && nonempty[0].integer };
25384
+ if (key && (result.min === 0 || result.max > 4096)) return void 0;
25385
+ words.add(word);
25386
+ if (result.integer) integerWords.add(word);
25387
+ return result;
25388
+ };
25389
+ for (const assignment of assignments2) {
25390
+ if ("kind" in assignment && assignment.kind === "compound") {
25391
+ if (assignment.entries.some((entry2) => !entry2.value.parts.every((part) => part.quoted) || !shapeWord(entry2.value))) return void 0;
25392
+ } else {
25393
+ if ("kind" in assignment) {
25394
+ const index = this.syncArraySubscriptWord(assignment.index, state);
25395
+ if (!index || !shapeWord(index, true)) return void 0;
25396
+ }
25397
+ const shape = shapeWord(assignment.value);
25398
+ if (!shape) return void 0;
25399
+ if (!("kind" in assignment)) values.set(assignment.name, shape);
25400
+ }
25401
+ }
25402
+ let stable = true;
25403
+ for (const [name2, before] of entry) {
25404
+ const after = values.get(name2);
25405
+ const merged = { min: Math.min(before.min, after.min), max: Math.max(before.max, after.max), integer: before.integer && after.integer };
25406
+ if (merged.min !== before.min || merged.max !== before.max || merged.integer !== before.integer) stable = false;
25407
+ entry.set(name2, merged);
25408
+ }
25409
+ if (stable) return { words, integerWords, appends };
25410
+ }
25411
+ return void 0;
25412
+ }
25522
25413
  isPureSyncValueWord(word, rawState, allowAt = false) {
25414
+ if (this._activeSyncArrayLoopWords?.has(word)) return true;
25523
25415
  if (word.parts.length === 0) return false;
25524
25416
  for (let i = 0; i < word.parts.length; i++) {
25525
25417
  const part = word.parts[i];
@@ -25907,7 +25799,7 @@ var Runtime = class _Runtime {
25907
25799
  if (w.parts.some((part) => part.kind === "substitution" || part.kind === "text" && !part.quoted && part.value.includes("~"))) return false;
25908
25800
  if (p0.kind === "text" && !p0.quoted && p0.value.startsWith("~")) return false;
25909
25801
  if (inOptions) {
25910
- const literal = w.parts.reduce((text2, part) => text2 !== void 0 && part.kind === "text" ? text2 + part.value : void 0, "");
25802
+ const literal = w.parts.reduce((text3, part) => text3 !== void 0 && part.kind === "text" ? text3 + part.value : void 0, "");
25911
25803
  if (literal !== void 0) {
25912
25804
  if (/^-[nE]+$/.test(literal)) continue;
25913
25805
  if (literal.startsWith("-")) return false;
@@ -26279,7 +26171,7 @@ var Runtime = class _Runtime {
26279
26171
  }
26280
26172
  if (cmd.redirects.length === 0 && cmd.words.length >= 4 && cmd.words[0].plain === "printf" && cmd.words[1].plain === "-v") {
26281
26173
  const vName = cmd.words[2].plain;
26282
- if (!hasActiveVariableAttributes(rawState) && vName !== void 0 && isShellIdentifier(vName) && !controlNames.has(vName) && vName !== "OPTIND" && !rawState.readonlyVariables?.has(vName) && !rawState.variableAttributes?.get(vName) && !store?.get(vName) && !stateMonitor(rawState)?.hasOverlay(vName) && this.isSyncPrintfCallOk(cmd, 3, rawState, printfInductionName)) {
26174
+ if (!hasActiveVariableAttributes(rawState) && vName !== void 0 && isShellIdentifier(vName) && !printfSlowTargets.has(vName) && !rawState.readonlyVariables?.has(vName) && !rawState.variableAttributes?.get(vName) && !store?.get(vName) && !stateMonitor(rawState)?.hasOverlay(vName) && this.isSyncPrintfCallOk(cmd, 3, rawState, printfInductionName)) {
26283
26175
  continue;
26284
26176
  }
26285
26177
  return false;
@@ -26309,12 +26201,16 @@ var Runtime = class _Runtime {
26309
26201
  if (arrAssign) {
26310
26202
  if (this._syncLoopFnCheckDepth > 0) return false;
26311
26203
  if (hasUnpreparedLocals(rawState)) return false;
26312
- if (arrAssign.kind === "element") return false;
26313
26204
  const curArr = store?.get(arrAssign.name);
26314
26205
  const activeArrStore = store ?? stateMonitor(rawState)?.store;
26315
- if (!curArr || curArr.references !== 1 || activeArrStore?.watches.has(arrAssign.name) || rawState.readonlyVariables?.has(arrAssign.name) || rawState.exported.has(arrAssign.name) || controlNames.has(arrAssign.name)) {
26206
+ if (!curArr || curArr.references !== 1 || activeArrStore?.watches.has(arrAssign.name) || rawState.readonlyVariables?.has(arrAssign.name) || rawState.variableAttributes?.has(arrAssign.name) || rawState.exported.has(arrAssign.name) || controlNames.has(arrAssign.name)) {
26316
26207
  return false;
26317
26208
  }
26209
+ if (arrAssign.kind === "element") {
26210
+ const index = curArr.associative ? this.syncArraySubscriptWord(arrAssign.index, rawState) : void 0;
26211
+ if (!index || !this._activeSyncArrayLoopWords?.has(index) || !this.isPureSyncValueWord(index, rawState) || !this.isPureSyncValueWord(arrAssign.value, rawState)) return false;
26212
+ continue;
26213
+ }
26318
26214
  if (arrAssign.kind === "compound" && arrAssign.entries.length <= 16 && arrAssign.entries.every((e) => !e.append)) {
26319
26215
  let allEntriesOk = true;
26320
26216
  for (let ei = 0; ei < arrAssign.entries.length; ei++) {
@@ -26721,7 +26617,7 @@ var Runtime = class _Runtime {
26721
26617
  }
26722
26618
  return res;
26723
26619
  }
26724
- syncLoopArithmeticReadsRemainInteger(steps, rawState) {
26620
+ syncLoopArithmeticReadsRemainInteger(steps, rawState, integerWords) {
26725
26621
  const reads = /* @__PURE__ */ new Set();
26726
26622
  const seen = /* @__PURE__ */ new WeakSet();
26727
26623
  const collect = (value) => {
@@ -26738,7 +26634,7 @@ var Runtime = class _Runtime {
26738
26634
  const safeWrites = (items) => items.every((step) => {
26739
26635
  if (step.name && reads.has(step.name)) {
26740
26636
  const literal = step.value?.plain;
26741
- if (step.append || !this.extractIntLoopStep(step, rawState) && (literal === void 0 || !/^-?[0-9]+$/.test(literal))) return false;
26637
+ if (step.append || !integerWords?.has(step.value) && !this.extractIntLoopStep(step, rawState) && (literal === void 0 || !/^-?[0-9]+$/.test(literal))) return false;
26742
26638
  }
26743
26639
  if (step.readHereString?.varNames.some((name2) => reads.has(name2)) || step.readHereString?.arrayTarget && reads.has(step.readHereString.arrayTarget)) return false;
26744
26640
  if (step.localDecl?.items.some((item) => reads.has(item.name))) return false;
@@ -26859,6 +26755,9 @@ var Runtime = class _Runtime {
26859
26755
  const prevAssignedVars = this._activeSyncLoopAssignedVars;
26860
26756
  const prevLoopIO = this._activeSyncLoopIO;
26861
26757
  const prevInvMap = this._syncLoopInvariantSubMap;
26758
+ const prevArrayWords = this._activeSyncArrayLoopWords;
26759
+ const arrayLoop = command.kind === "arithmetic-for" ? this.admitSyncArrayLoop(command, rawState) : void 0;
26760
+ this._activeSyncArrayLoopWords = arrayLoop?.words;
26862
26761
  this._activePrintfInductionName = printfInductionName;
26863
26762
  this._activeSyncLoopAssignedVars = this.collectSyncLoopAssignedVars(command, rawState);
26864
26763
  this._activeSyncLoopIO = io;
@@ -26872,6 +26771,7 @@ var Runtime = class _Runtime {
26872
26771
  this._activeSyncLoopAssignedVars = prevAssignedVars;
26873
26772
  this._activeSyncLoopIO = prevLoopIO;
26874
26773
  this._syncLoopInvariantSubMap = prevInvMap;
26774
+ this._activeSyncArrayLoopWords = prevArrayWords;
26875
26775
  }
26876
26776
  if (!bodySyncOk) {
26877
26777
  command._skipTrySyncLoop = true;
@@ -26906,7 +26806,7 @@ var Runtime = class _Runtime {
26906
26806
  this._syncLoopInvariantSubMap = localInvMap;
26907
26807
  try {
26908
26808
  const { steps: bodyAssignments, redirectCount } = this.buildSyncLoopBody(command, rawState, io);
26909
- if (bodyAssignments.length > 30 || !this.syncLoopArithmeticReadsRemainInteger(bodyAssignments, rawState)) return void 0;
26809
+ if (bodyAssignments.length > 30 || !this.syncLoopArithmeticReadsRemainInteger(bodyAssignments, rawState, arrayLoop?.integerWords)) return void 0;
26910
26810
  const touched = this._syncArithRawWriteOnly ? /* @__PURE__ */ new Set() : sharedSyncLoopTouched;
26911
26811
  touched.clear();
26912
26812
  let lastCmd;
@@ -27016,6 +26916,7 @@ var Runtime = class _Runtime {
27016
26916
  const wordsToScan = step.arrayAssign?.kind === "compound" ? step.arrayAssign.entries.map((e) => e.value) : step.printfVArgs ? step.printfVArgs : step.value ? [step.value] : [];
27017
26917
  for (let wIdx = 0; wIdx < wordsToScan.length; wIdx++) {
27018
26918
  const wVal = wordsToScan[wIdx];
26919
+ if (arrayLoop?.words.has(wVal)) continue;
27019
26920
  for (let i = 0; i < wVal.parts.length; i++) {
27020
26921
  const part = wVal.parts[i];
27021
26922
  if (part.kind === "text" || part.kind === "variable") continue;
@@ -27128,11 +27029,18 @@ var Runtime = class _Runtime {
27128
27029
  deferredMask,
27129
27030
  touchedIntNamesList
27130
27031
  } = plan;
27032
+ if (arrayLoop?.appends.size) {
27033
+ if (!isSimpleLiteralAsc) return void 0;
27034
+ for (const [name2, count] of arrayLoop.appends) {
27035
+ if (store.get(name2).maximum + iterations * count > 2147483647) return void 0;
27036
+ }
27037
+ }
27131
27038
  if (inductionName === "OPTIND" || controlNames.has(inductionName) || monitor.hasOverlay(inductionName) || hasUnpreparedLocal(rawState, inductionName) || store?.get(inductionName) || rawState.readonlyVariables?.has(inductionName) || rawState.variableAttributes?.get(inductionName)) return void 0;
27132
27039
  if (!isSimpleLiteralAsc && (!this.canSyncArithmeticWithoutFault(e0.tree, rawState, diagnosticLine) || !this.canSyncArithmeticWithoutFault(e1.tree, rawState, diagnosticLine) || !this.canSyncArithmeticWithoutFault(e2.tree, rawState, diagnosticLine))) return void 0;
27133
27040
  if (arithNamesList.length > 0) {
27134
27041
  for (let a = 0; a < arithNamesList.length; a++) {
27135
27042
  const refName = arithNamesList[a];
27043
+ if (store?.get(refName)) return void 0;
27136
27044
  if (refName === inductionName) continue;
27137
27045
  const initial = rawState.variables[refName];
27138
27046
  if (initial !== void 0 && initial !== "" && !/^-?[0-9]+$/.test(initial)) return void 0;
@@ -28463,9 +28371,9 @@ ${s1}
28463
28371
  else void io.stdout.write(chunk);
28464
28372
  }
28465
28373
  }
28466
- writeSyncStdoutText(text2, io) {
28467
- if (text2.length === 0) return;
28468
- this._syncStdoutBatch += text2;
28374
+ writeSyncStdoutText(text3, io) {
28375
+ if (text3.length === 0) return;
28376
+ this._syncStdoutBatch += text3;
28469
28377
  if (this._syncStdoutBatch.length >= 8192) this.flushSyncStdoutBatch(io);
28470
28378
  }
28471
28379
  runSyncDiscardStep(step, rawState, io) {
@@ -28570,8 +28478,8 @@ ${s1}
28570
28478
  lastArg = val;
28571
28479
  }
28572
28480
  } else if (step.targetWord !== void 0 && step.printfVArgs !== void 0) {
28573
- const { formatted, lastArg: pLastArg } = this.evalSyncPrintfStep(step.printfVArgs, rawState, io, step.line, step.cmd.words[0]?.plain === "echo");
28574
- const encoded = fastSharedTextEncoder.encode(formatted);
28481
+ const { formatted: formatted2, lastArg: pLastArg } = this.evalSyncPrintfStep(step.printfVArgs, rawState, io, step.line, step.cmd.words[0]?.plain === "echo");
28482
+ const encoded = fastSharedTextEncoder.encode(formatted2);
28575
28483
  this.writeSyncRedirectStep(step, encoded, step.append, mode, rawState, io);
28576
28484
  this.budget.fileSystemOperation();
28577
28485
  this.budget.bytes += encoded.byteLength;
@@ -28581,8 +28489,8 @@ ${s1}
28581
28489
  this.writeSyncStdoutText(this.formatSyncEchoLine(val), io);
28582
28490
  lastArg = val;
28583
28491
  } else if (step.isStdoutEcho && step.printfVArgs !== void 0) {
28584
- const { formatted, lastArg: pLastArg } = this.evalSyncPrintfStep(step.printfVArgs, rawState, io, step.line, step.cmd.words[0]?.plain === "echo");
28585
- this.writeSyncStdoutText(formatted, io);
28492
+ const { formatted: formatted2, lastArg: pLastArg } = this.evalSyncPrintfStep(step.printfVArgs, rawState, io, step.line, step.cmd.words[0]?.plain === "echo");
28493
+ this.writeSyncStdoutText(formatted2, io);
28586
28494
  lastArg = pLastArg;
28587
28495
  } else if (step.arrayAssign !== void 0) {
28588
28496
  if (!this.tryFastArrayAssignmentSync(step.arrayAssign, rawState, io, step.line, void 0, void 0, true)) {
@@ -28631,8 +28539,8 @@ ${s1}
28631
28539
  rawState.status = nonZero ? 0 : 1;
28632
28540
  continue;
28633
28541
  } else if (step.printfVArgs !== void 0 && step.name !== void 0) {
28634
- const { formatted, lastArg: pLastArg } = this.evalSyncPrintfStep(step.printfVArgs, rawState, io, step.line, step.cmd.words[0]?.plain === "echo");
28635
- rawState.variables[step.name] = formatted;
28542
+ const { formatted: formatted2, lastArg: pLastArg } = this.evalSyncPrintfStep(step.printfVArgs, rawState, io, step.line, step.cmd.words[0]?.plain === "echo");
28543
+ rawState.variables[step.name] = formatted2;
28636
28544
  touched.add(step.name);
28637
28545
  lastArg = pLastArg;
28638
28546
  } else if (step.isDiscardDevNull && step.discardWords !== void 0) {
@@ -29110,8 +29018,8 @@ ${s1}
29110
29018
  lastArg = val;
29111
29019
  }
29112
29020
  } else if (step.targetWord !== void 0 && step.printfVArgs !== void 0) {
29113
- const { formatted, lastArg: pLastArg } = this.evalSyncPrintfStep(step.printfVArgs, rawState, io, step.line, step.cmd.words[0]?.plain === "echo");
29114
- const encoded = fastSharedTextEncoder.encode(formatted);
29021
+ const { formatted: formatted2, lastArg: pLastArg } = this.evalSyncPrintfStep(step.printfVArgs, rawState, io, step.line, step.cmd.words[0]?.plain === "echo");
29022
+ const encoded = fastSharedTextEncoder.encode(formatted2);
29115
29023
  this.writeSyncRedirectStep(step, encoded, step.append, mode, rawState, io);
29116
29024
  this.budget.fileSystemOperation();
29117
29025
  this.budget.bytes += encoded.byteLength;
@@ -29122,8 +29030,8 @@ ${s1}
29122
29030
  }
29123
29031
  lastArg = "";
29124
29032
  } else if (step.printfVArgs !== void 0 && step.name !== void 0) {
29125
- const { formatted, lastArg: pLastArg } = this.evalSyncPrintfStep(step.printfVArgs, rawState, io, step.line, step.cmd.words[0]?.plain === "echo");
29126
- rawState.variables[step.name] = formatted;
29033
+ const { formatted: formatted2, lastArg: pLastArg } = this.evalSyncPrintfStep(step.printfVArgs, rawState, io, step.line, step.cmd.words[0]?.plain === "echo");
29034
+ rawState.variables[step.name] = formatted2;
29127
29035
  touched.add(step.name);
29128
29036
  lastArg = pLastArg;
29129
29037
  } else if (step.isDiscardDevNull && step.discardWords !== void 0) {
@@ -29143,8 +29051,8 @@ ${s1}
29143
29051
  this.writeSyncStdoutText(this.formatSyncEchoLine(val), io);
29144
29052
  lastArg = val;
29145
29053
  } else if (step.isStdoutEcho && step.printfVArgs !== void 0) {
29146
- const { formatted, lastArg: pLastArg } = this.evalSyncPrintfStep(step.printfVArgs, rawState, io, step.line, step.cmd.words[0]?.plain === "echo");
29147
- this.writeSyncStdoutText(formatted, io);
29054
+ const { formatted: formatted2, lastArg: pLastArg } = this.evalSyncPrintfStep(step.printfVArgs, rawState, io, step.line, step.cmd.words[0]?.plain === "echo");
29055
+ this.writeSyncStdoutText(formatted2, io);
29148
29056
  lastArg = pLastArg;
29149
29057
  } else {
29150
29058
  lastArg = step.cmd.words[0].plain;
@@ -29218,8 +29126,8 @@ ${s1}
29218
29126
  lastArg = val;
29219
29127
  }
29220
29128
  } else if (step.targetWord !== void 0 && step.printfVArgs !== void 0) {
29221
- const { formatted, lastArg: pLastArg } = this.evalSyncPrintfStep(step.printfVArgs, rawState, io, step.line, step.cmd.words[0]?.plain === "echo");
29222
- const encoded = fastSharedTextEncoder.encode(formatted);
29129
+ const { formatted: formatted2, lastArg: pLastArg } = this.evalSyncPrintfStep(step.printfVArgs, rawState, io, step.line, step.cmd.words[0]?.plain === "echo");
29130
+ const encoded = fastSharedTextEncoder.encode(formatted2);
29223
29131
  this.writeSyncRedirectStep(step, encoded, step.append, mode, rawState, io);
29224
29132
  this.budget.fileSystemOperation();
29225
29133
  this.budget.bytes += encoded.byteLength;
@@ -29267,8 +29175,8 @@ ${s1}
29267
29175
  rawState.status = nonZero ? 0 : 1;
29268
29176
  continue;
29269
29177
  } else if (step.printfVArgs !== void 0 && step.name !== void 0) {
29270
- const { formatted, lastArg: pLastArg } = this.evalSyncPrintfStep(step.printfVArgs, rawState, io, step.line);
29271
- rawState.variables[step.name] = formatted;
29178
+ const { formatted: formatted2, lastArg: pLastArg } = this.evalSyncPrintfStep(step.printfVArgs, rawState, io, step.line);
29179
+ rawState.variables[step.name] = formatted2;
29272
29180
  touched.add(step.name);
29273
29181
  lastArg = pLastArg;
29274
29182
  } else if (step.isDiscardDevNull && step.discardWords !== void 0) {
@@ -29288,8 +29196,8 @@ ${s1}
29288
29196
  this.writeSyncStdoutText(this.formatSyncEchoLine(val), io);
29289
29197
  lastArg = val;
29290
29198
  } else if (step.isStdoutEcho && step.printfVArgs !== void 0) {
29291
- const { formatted, lastArg: pLastArg } = this.evalSyncPrintfStep(step.printfVArgs, rawState, io, step.line, step.cmd.words[0]?.plain === "echo");
29292
- this.writeSyncStdoutText(formatted, io);
29199
+ const { formatted: formatted2, lastArg: pLastArg } = this.evalSyncPrintfStep(step.printfVArgs, rawState, io, step.line, step.cmd.words[0]?.plain === "echo");
29200
+ this.writeSyncStdoutText(formatted2, io);
29293
29201
  lastArg = pLastArg;
29294
29202
  } else {
29295
29203
  lastArg = step.cmd.words[0].plain;
@@ -29413,6 +29321,7 @@ ${s1}
29413
29321
  signal.throwIfAborted();
29414
29322
  child.extensions = forkExtensions(state.extensions, "subshell");
29415
29323
  child.isolated = true;
29324
+ child.variables.BASH_SUBSHELL = String(Number(state.variables.BASH_SUBSHELL ?? 0) + 1);
29416
29325
  child.depth++;
29417
29326
  const allocation = this.budget.values.scope();
29418
29327
  scope.register(() => allocation.close());
@@ -29589,6 +29498,8 @@ ${s1}
29589
29498
  _readOnlyStage: true
29590
29499
  }) : tryCloneStateSync(state) ?? await cloneState(state, this.signal);
29591
29500
  preparedChild = child;
29501
+ if (child._readOnlyStage) child.variables = { ...child.variables };
29502
+ child.variables.BASH_SUBSHELL = String(Number(state.variables.BASH_SUBSHELL ?? 0) + 1);
29592
29503
  if (!child._readOnlyStage) {
29593
29504
  child.extensions = void 0;
29594
29505
  child.extensions = forkExtensions(state.extensions, "pipeline");
@@ -30153,19 +30064,19 @@ ${s1}
30153
30064
  const rawState = stateMonitor(state)?.raw ?? state;
30154
30065
  if (def && (w0Plain === "printf" ? def.execute === printfCommand.execute : defaultEchoExecutors.has(def.execute)) && this.isPureArgWord(r0.target, rawState) && command.words.every((w) => this.isPureArgWord(w, rawState))) {
30155
30066
  let targetVal;
30156
- let formatted;
30067
+ let formatted2;
30157
30068
  let lastArg = w0Plain;
30158
30069
  let fastFailed = false;
30159
30070
  try {
30160
30071
  if (command.words.length <= this.budget.maxExpansionFieldsSmi) {
30161
30072
  if (w0Plain === "echo" && command.words.length === 1) {
30162
30073
  targetVal = this.fastValueWord(r0.target, state, originalIO, true, false, false, true, void 0, diagnosticLine);
30163
- formatted = "\n";
30074
+ formatted2 = "\n";
30164
30075
  } else if (w0Plain === "echo" && command.words.length === 2) {
30165
30076
  const arg0 = this.fastValueWord(command.words[1], state, originalIO, true, false, false, true, void 0, diagnosticLine);
30166
30077
  if (typeof arg0 === "string" && !arg0.startsWith("-") && !arg0.includes("\0")) {
30167
30078
  targetVal = this.fastValueWord(r0.target, state, originalIO, true, false, false, true, void 0, diagnosticLine);
30168
- formatted = `${arg0}
30079
+ formatted2 = `${arg0}
30169
30080
  `;
30170
30081
  lastArg = arg0;
30171
30082
  }
@@ -30182,14 +30093,14 @@ ${s1}
30182
30093
  }
30183
30094
  if (allStrings) {
30184
30095
  if (fastSubScratchArgs.length > 0) lastArg = fastSubScratchArgs[fastSubScratchArgs.length - 1];
30185
- if (w0Plain === "printf") formatted = tryFastPrintf(fastSubScratchArgs);
30096
+ if (w0Plain === "printf") formatted2 = tryFastPrintf(fastSubScratchArgs);
30186
30097
  else if (!fastSubScratchArgs[0]?.startsWith("-")) {
30187
30098
  const joined = `${fastSubScratchArgs.join(" ")}
30188
30099
  `;
30189
- if (!joined.includes("\0")) formatted = joined;
30100
+ if (!joined.includes("\0")) formatted2 = joined;
30190
30101
  }
30191
30102
  fastSubScratchArgs.length = 0;
30192
- if (formatted !== void 0) targetVal = this.fastValueWord(r0.target, state, originalIO, true, false, false, true, void 0, diagnosticLine);
30103
+ if (formatted2 !== void 0) targetVal = this.fastValueWord(r0.target, state, originalIO, true, false, false, true, void 0, diagnosticLine);
30193
30104
  } else fastSubScratchArgs.length = 0;
30194
30105
  }
30195
30106
  }
@@ -30197,10 +30108,10 @@ ${s1}
30197
30108
  fastSubScratchArgs.length = 0;
30198
30109
  fastFailed = true;
30199
30110
  }
30200
- if (!fastFailed && formatted !== void 0 && typeof targetVal === "string" && targetVal.length > 0 && !targetVal.includes("\0")) {
30111
+ if (!fastFailed && formatted2 !== void 0 && typeof targetVal === "string" && targetVal.length > 0 && !targetVal.includes("\0")) {
30201
30112
  const path = pathOf(state, targetVal);
30202
30113
  if (!path.startsWith("/dev/") && path !== "/dev") {
30203
- const encoded = formatted.length * 3 <= fastRedirectScratchBytes.byteLength ? fastRedirectScratchBytes.subarray(0, fastSharedTextEncoder.encodeInto(formatted, fastRedirectScratchBytes).written) : fastSharedTextEncoder.encode(formatted);
30114
+ const encoded = formatted2.length * 3 <= fastRedirectScratchBytes.byteLength ? fastRedirectScratchBytes.subarray(0, fastSharedTextEncoder.encodeInto(formatted2, fastRedirectScratchBytes).written) : fastSharedTextEncoder.encode(formatted2);
30204
30115
  const byteLength = encoded.byteLength;
30205
30116
  if (byteLength <= this.budget.limits.maxOutputBytes - this.budget.bytes && this.budget.canFileSystemOperation()) {
30206
30117
  let writeSucceeded = false;
@@ -30416,6 +30327,7 @@ ${s1}
30416
30327
  try {
30417
30328
  child.extensions = forkExtensions(state.extensions, "subshell");
30418
30329
  child.isolated = true;
30330
+ child.variables.BASH_SUBSHELL = String(Number(state.variables.BASH_SUBSHELL ?? 0) + 1);
30419
30331
  child.loopDepth = 0;
30420
30332
  if (state.extensions?.checkpoints.length) await this.extensionCheckpoint("child-job-install", state, io);
30421
30333
  started = true;
@@ -31128,11 +31040,11 @@ ${s1}
31128
31040
  }
31129
31041
  return currentIO();
31130
31042
  }
31131
- async fileOperation(path, operation) {
31043
+ async fileOperation(path, operation2) {
31132
31044
  const previous = this.fileWrites.get(path) ?? Promise.resolve();
31133
31045
  const pending = previous.catch(() => void 0).then(() => {
31134
31046
  this.signal.throwIfAborted();
31135
- return operation();
31047
+ return operation2();
31136
31048
  });
31137
31049
  this.fileWrites.set(path, pending);
31138
31050
  try {
@@ -31563,6 +31475,7 @@ ${s1}
31563
31475
  }
31564
31476
  async dispatchFastFunction(name2, body, args, state, io, pendingResume) {
31565
31477
  if (!pendingResume && state.depth >= this.budget.limits.maxSubstitutionDepth) this.budget.fail("maxSubstitutionDepth");
31478
+ if (!pendingResume && state.functionDepth >= this.budget.limits.maxFunctionDepth) this.budget.fail("maxFunctionDepth");
31566
31479
  const scope = io[invocationScope].child();
31567
31480
  try {
31568
31481
  const monitor = stateMonitor(state);
@@ -31737,11 +31650,11 @@ ${s1}
31737
31650
  else if (name2 === "echo" && (args.length === 0 || !args[0].startsWith("-"))) {
31738
31651
  const def = this.commands.get("echo");
31739
31652
  if (def && defaultEchoExecutors.has(def.execute)) {
31740
- const text2 = args.length === 0 ? "\n" : args.length === 1 ? `${args[0]}
31653
+ const text3 = args.length === 0 ? "\n" : args.length === 1 ? `${args[0]}
31741
31654
  ` : `${args.join(" ")}
31742
31655
  `;
31743
31656
  const targetSink = io.descriptors?.get(1)?.output ?? io.stdout;
31744
- await writeBytes(targetSink, fastSharedTextEncoder.encode(text2), this.commandSignal);
31657
+ await writeBytes(targetSink, fastSharedTextEncoder.encode(text3), this.commandSignal);
31745
31658
  return 0;
31746
31659
  }
31747
31660
  } else if (name2 === "read" && !hasActiveVariableAttributes(state) && io.stdin instanceof ShellInput) {
@@ -32056,6 +31969,7 @@ ${s1}
32056
31969
  if (body) {
32057
31970
  ensureRuntimeContext();
32058
31971
  if (state.depth >= this.budget.limits.maxSubstitutionDepth) this.budget.fail("maxSubstitutionDepth");
31972
+ if (state.functionDepth >= this.budget.limits.maxFunctionDepth) this.budget.fail("maxFunctionDepth");
32059
31973
  const positional = state.positional;
32060
31974
  const savedPositionals = stateMonitor(state).positionals.clone();
32061
31975
  const positionalSetVersion = state.positionalSetVersion ?? 0;
@@ -32467,18 +32381,18 @@ ${s1}
32467
32381
  found++;
32468
32382
  for (const match of matches) {
32469
32383
  if (mode === "path" && match.kind !== "file") continue;
32470
- let text2;
32384
+ let text3;
32471
32385
  if (mode === "kind") {
32472
32386
  const kind = match.kind === "command" ? shellBuiltinNames.has(name2) ? "builtin" : "file" : match.kind === "interpreter" ? "file" : match.kind;
32473
- text2 = `${kind}
32387
+ text3 = `${kind}
32474
32388
  `;
32475
- } else if (mode === "name" || mode === "path") text2 = `${match.name}
32389
+ } else if (mode === "name" || mode === "path") text3 = `${match.name}
32476
32390
  `;
32477
- else if (match.kind === "function") text2 = `${name2} is a function
32391
+ else if (match.kind === "function") text3 = `${name2} is a function
32478
32392
  ${functionDisplay(name2, state.functions.get(name2))}`;
32479
- else text2 = `${name2} is ${match.kind === "keyword" ? "a shell keyword" : match.kind === "builtin" ? "a shell builtin" : match.kind === "command" ? "a registered command" : match.kind === "interpreter" ? "a virtual shell interpreter" : match.name}
32393
+ else text3 = `${name2} is ${match.kind === "keyword" ? "a shell keyword" : match.kind === "builtin" ? "a shell builtin" : match.kind === "command" ? "a registered command" : match.kind === "interpreter" ? "a virtual shell interpreter" : match.name}
32480
32394
  `;
32481
- await writeText(context.stdout, text2);
32395
+ await writeText(context.stdout, text3);
32482
32396
  }
32483
32397
  }
32484
32398
  return (command ? found > 0 || args.length === 0 : found === args.length) ? 0 : 1;
@@ -32565,13 +32479,20 @@ ${functionDisplay(name2, state.functions.get(name2))}`;
32565
32479
  while (args.length && (args[0].startsWith("-") || args[0].startsWith("+"))) {
32566
32480
  const option = args.shift();
32567
32481
  if (option === "--" || option === "-") break;
32482
+ if (option === "--version") {
32483
+ await writeDiagnostic(context.stdout, "safe-bash (poe-code)\n");
32484
+ return 0;
32485
+ }
32486
+ if (option === "--login" || option === "--norc" || option === "--noprofile" || option === "--posix") {
32487
+ continue;
32488
+ }
32568
32489
  const enabled = option[0] === "-";
32569
32490
  if ((option === "-o" || option === "+o") && Object.hasOwn(options, args[0] ?? "")) {
32570
32491
  options[args.shift()] = enabled;
32571
32492
  continue;
32572
32493
  }
32573
32494
  const flags = option.slice(1);
32574
- if (!flags.length || [...flags].some((flag) => !Object.hasOwn(flagsByName, flag) && !(enabled && (flag === "c" || flag === "s")))) {
32495
+ if (!flags.length || [...flags].some((flag) => !Object.hasOwn(flagsByName, flag) && !(enabled && (flag === "c" || flag === "s" || flag === "l" || flag === "i")))) {
32575
32496
  await writeDiagnostic(context.stderr, `${context.command}: ${option}: unsupported option; supported flags are -c, -s, +/-a, +/-e, +/-u, +/-n, +/-B, +/-f, +/-C and +/-o ${Object.keys(options).join(", ")}
32576
32497
  `);
32577
32498
  return 2;
@@ -33592,8 +33513,8 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
33592
33513
  } catch (error) {
33593
33514
  this.signal.throwIfAborted();
33594
33515
  const description = filesystemDiagnostic(error, "", this.budget.onInternalError);
33595
- const text2 = description ? "" : message(error, this.budget.onInternalError);
33596
- diagnose?.(error, cdDiagnostic(description ? [name2, ": ", target, description] : stackHooks && text2.startsWith("cd: ") ? [name2, text2.slice(2)] : [text2], this.budget.limits.maxDirectoryDiagnosticBytes));
33516
+ const text3 = description ? "" : message(error, this.budget.onInternalError);
33517
+ diagnose?.(error, cdDiagnostic(description ? [name2, ": ", target, description] : stackHooks && text3.startsWith("cd: ") ? [name2, text3.slice(2)] : [text3], this.budget.limits.maxDirectoryDiagnosticBytes));
33597
33518
  throw error;
33598
33519
  }
33599
33520
  this.signal.throwIfAborted();
@@ -33645,7 +33566,7 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
33645
33566
  for (let index = 0; index < length; index++) entries[index] = entry(index);
33646
33567
  return { entries, bytes };
33647
33568
  };
33648
- const publish2 = async (next) => {
33569
+ const publish3 = async (next) => {
33649
33570
  await work.flushWork();
33650
33571
  state.directoryStack = next;
33651
33572
  };
@@ -33656,13 +33577,13 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
33656
33577
  onCwdPublished() {
33657
33578
  state.directoryStackCwdPublication = /* @__PURE__ */ Symbol();
33658
33579
  },
33659
- async emit(text2) {
33660
- await work.emit(text2);
33580
+ async emit(text3) {
33581
+ await work.emit(text3);
33661
33582
  await work.flushOutput();
33662
33583
  }
33663
33584
  });
33664
33585
  };
33665
- const display = async (index) => {
33586
+ const display2 = async (index) => {
33666
33587
  await work.display(state.cwd, state.directoryStack?.entries ?? [], { long, lines, verbose, ...index !== void 0 ? { index } : {} }, state.variables.HOME);
33667
33588
  };
33668
33589
  try {
@@ -33704,8 +33625,8 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
33704
33625
  break;
33705
33626
  }
33706
33627
  if (command === "dirs") {
33707
- if (clear) await publish2({ entries: [], bytes: 0 });
33708
- else await display(selected === void 0 ? void 0 : boundedIndex(selected));
33628
+ if (clear) await publish3({ entries: [], bytes: 0 });
33629
+ else await display2(selected === void 0 ? void 0 : boundedIndex(selected));
33709
33630
  } else if (command === "pushd") {
33710
33631
  if (selected !== void 0) {
33711
33632
  const index = boundedIndex(selected);
@@ -33713,11 +33634,11 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
33713
33634
  const cwd = state.cwd;
33714
33635
  const at = (fullIndex) => fullIndex === 0 ? cwd : tail.entries[fullIndex - 1];
33715
33636
  const next = await plan(count, index === 0 ? void 0 : index - 1, index === 0 ? void 0 : cwd, void 0, (slot) => at((index + slot + 1) % (count + 1)));
33716
- await publish2(next);
33637
+ await publish3(next);
33717
33638
  if (!noCd) {
33718
33639
  const status = await cd(at(index));
33719
33640
  if (status !== 0) return status;
33720
- await display();
33641
+ await display2();
33721
33642
  }
33722
33643
  }
33723
33644
  } else if (target !== void 0) {
@@ -33727,16 +33648,16 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
33727
33648
  const status = await cd(target);
33728
33649
  if (status !== 0) return status;
33729
33650
  }
33730
- await publish2(next);
33731
- await display();
33651
+ await publish3(next);
33652
+ await display2();
33732
33653
  } else if (!noCd) {
33733
33654
  if (!count) work.fail("no other directory");
33734
33655
  const cwd = state.cwd;
33735
33656
  const next = await plan(count, 0, cwd, void 0, (slot) => slot === 0 ? cwd : tail.entries[slot]);
33736
- await publish2(next);
33657
+ await publish3(next);
33737
33658
  const status = await cd(tail.entries[0]);
33738
33659
  if (status !== 0) return status;
33739
- await display();
33660
+ await display2();
33740
33661
  }
33741
33662
  } else {
33742
33663
  const index = boundedIndex(selected ?? 0n);
@@ -33747,8 +33668,8 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
33747
33668
  const status = await cd(tail.entries[0]);
33748
33669
  if (status !== 0) return status;
33749
33670
  }
33750
- await publish2(next);
33751
- await display();
33671
+ await publish3(next);
33672
+ await display2();
33752
33673
  }
33753
33674
  return 0;
33754
33675
  } finally {
@@ -33760,7 +33681,7 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
33760
33681
  let print = false;
33761
33682
  let quiet = false;
33762
33683
  let set = false;
33763
- let unset = false;
33684
+ let unset2 = false;
33764
33685
  let index = 0;
33765
33686
  for (; index < context.args.length; index++) {
33766
33687
  this.signal.throwIfAborted();
@@ -33775,7 +33696,7 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
33775
33696
  if (flag === "p") print = true;
33776
33697
  else if (flag === "q") quiet = true;
33777
33698
  else if (flag === "s") set = true;
33778
- else if (flag === "u") unset = true;
33699
+ else if (flag === "u") unset2 = true;
33779
33700
  else if (flag === "o") setNamespace = true;
33780
33701
  else {
33781
33702
  await this.diagnostic(context, `shopt: ${option.startsWith("--") ? option : `-${flag}`}: unsupported option`);
@@ -33784,7 +33705,7 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
33784
33705
  }
33785
33706
  }
33786
33707
  }
33787
- if (set && unset) {
33708
+ if (set && unset2) {
33788
33709
  await this.diagnostic(context, "shopt: cannot set and unset shell options simultaneously");
33789
33710
  return 1;
33790
33711
  }
@@ -33807,7 +33728,7 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
33807
33728
  `);
33808
33729
  };
33809
33730
  if (index === context.args.length) {
33810
- for (const [name2, option] of options) if ((!set || option.enabled) && (!unset || !option.enabled)) await emit(name2, option.enabled);
33731
+ for (const [name2, option] of options) if ((!set || option.enabled) && (!unset2 || !option.enabled)) await emit(name2, option.enabled);
33811
33732
  return 0;
33812
33733
  }
33813
33734
  let status = 0;
@@ -33818,7 +33739,7 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
33818
33739
  if (!option) {
33819
33740
  await this.diagnostic(context, `shopt: ${name2}: unsupported shell option name (supported: ${[...options.keys()].join(", ")})`);
33820
33741
  status = 1;
33821
- } else if (set || unset) option.enabled = set;
33742
+ } else if (set || unset2) option.enabled = set;
33822
33743
  else {
33823
33744
  await emit(name2, option.enabled);
33824
33745
  if (!option.enabled) status = 1;
@@ -33833,19 +33754,19 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
33833
33754
  const length = shellValueByteLength(value);
33834
33755
  allocation.reserve(length * 8 + 16, 1);
33835
33756
  const bytes = shellValueBytes(value, allocation);
33836
- let text2;
33757
+ let text3;
33837
33758
  if (!byteLocale(state.variables)) {
33838
33759
  try {
33839
- text2 = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(bytes);
33760
+ text3 = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(bytes);
33840
33761
  } catch {
33841
- text2 = void 0;
33762
+ text3 = void 0;
33842
33763
  }
33843
33764
  }
33844
- const ansi = text2 === void 0 ? bytes.some((byte) => byte < 32 || byte >= 127) : /[\p{C}\p{Zl}\p{Zp}]/u.test(text2);
33765
+ const ansi = text3 === void 0 ? bytes.some((byte) => byte < 32 || byte >= 127) : /[\p{C}\p{Zl}\p{Zp}]/u.test(text3);
33845
33766
  let quoted = ansi ? "$'" : '"';
33846
33767
  const controls = ["", "", "", "", "", "", "", "\\a", "\\b", "\\t", "\\n", "\\v", "\\f", "\\r"];
33847
33768
  let visited = 0;
33848
- for (const item of text2 ?? bytes) {
33769
+ for (const item of text3 ?? bytes) {
33849
33770
  if (visited++ % 1024 === 0) {
33850
33771
  this.budget.cpuCheckpoint();
33851
33772
  await yieldTurn(this.signal);
@@ -33854,8 +33775,8 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
33854
33775
  const code = character.codePointAt(0);
33855
33776
  if (ansi && controls[code]) quoted += controls[code];
33856
33777
  else if (ansi && code === 27) quoted += "\\E";
33857
- else if (ansi && (code < 32 || code === 127 || text2 === void 0 && code >= 128 || /[\p{C}\p{Zl}\p{Zp}]/u.test(character))) {
33858
- const encoded = text2 === void 0 ? [code] : new TextEncoder().encode(character);
33778
+ else if (ansi && (code < 32 || code === 127 || text3 === void 0 && code >= 128 || /[\p{C}\p{Zl}\p{Zp}]/u.test(character))) {
33779
+ const encoded = text3 === void 0 ? [code] : new TextEncoder().encode(character);
33859
33780
  for (const byte of encoded) quoted += `\\${byte.toString(8).padStart(3, "0")}`;
33860
33781
  } else if (character === "\\" || (ansi ? character === "'" : character === '"' || character === "$" || character === "`")) quoted += `\\${character}`;
33861
33782
  else quoted += character;
@@ -33946,6 +33867,7 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
33946
33867
  `);
33947
33868
  return 1;
33948
33869
  }
33870
+ if (name2 === "FUNCNAME") return status;
33949
33871
  if (index || arrayStore(state)?.get(name2)) {
33950
33872
  const decoder = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
33951
33873
  const decode = (bytes) => {
@@ -33957,17 +33879,17 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
33957
33879
  return void 0;
33958
33880
  }
33959
33881
  };
33960
- let text2 = decode(shellValueBytes(value, allocation));
33961
- if (text2 !== void 0 && index && numericIndex(index) !== 0 && !arrayStore(state)?.get(name2) && state.variables[name2] !== void 0) {
33882
+ let text3 = decode(shellValueBytes(value, allocation));
33883
+ if (text3 !== void 0 && index && numericIndex(index) !== 0 && !arrayStore(state)?.get(name2) && state.variables[name2] !== void 0) {
33962
33884
  const previous2 = stateMonitor(state).values.get(name2, state.variables[name2]);
33963
- if (decode(shellValueBytes(previous2, allocation)) === void 0) text2 = void 0;
33885
+ if (decode(shellValueBytes(previous2, allocation)) === void 0) text3 = void 0;
33964
33886
  }
33965
- if (text2 === void 0) {
33887
+ if (text3 === void 0) {
33966
33888
  await writeDiagnostic(context.stderr, "printf: indexed variables do not support non-UTF-8 bytes\n");
33967
33889
  return 1;
33968
33890
  }
33969
- if (index) await this.arrayAssignment({ kind: "element", name: name2, index, append: false, value: { offset: 0, parts: [{ kind: "text", value: text2, quoted: true }] } }, state, context);
33970
- else await this.assignVariable(state, name2, text2, context);
33891
+ if (index) await this.arrayAssignment({ kind: "element", name: name2, index, append: false, value: { offset: 0, parts: [{ kind: "text", value: text3, quoted: true }] } }, state, context);
33892
+ else await this.assignVariable(state, name2, text3, context);
33971
33893
  } else await this.writeVariable(state, name2, value, context);
33972
33894
  const previous = assignments2.get(name2);
33973
33895
  if (previous) {
@@ -34033,15 +33955,15 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
34033
33955
  pinned = entry.binding.retain();
34034
33956
  await previous.release();
34035
33957
  }
34036
- const operation = ArrayOwner.create(store.owner.ledger, store.owner);
33958
+ const operation2 = ArrayOwner.create(store.owner.ledger, store.owner);
34037
33959
  let staged;
34038
33960
  try {
34039
33961
  const current = pinned;
34040
33962
  const attached = store.bindings.get(options.name) === entry;
34041
- const watch = attached ? await store.watch(options.name, operation, this.signal) : void 0;
34042
- const supersede = attached ? await stateMonitor(state).prepareTypedPublication(options.name, operation, this.signal) : void 0;
34043
- if (attached) await this.prepareArrayObservers(state, operation);
34044
- const tickets = operation.reserve({ generation: true, version: true, epoch: true, work: 8 });
33963
+ const watch = attached ? await store.watch(options.name, operation2, this.signal) : void 0;
33964
+ const supersede = attached ? await stateMonitor(state).prepareTypedPublication(options.name, operation2, this.signal) : void 0;
33965
+ if (attached) await this.prepareArrayObservers(state, operation2);
33966
+ const tickets = operation2.reserve({ generation: true, version: true, epoch: true, work: 8 });
34045
33967
  staged = current.references > (attached ? 2 : 1) ? await current.copy(this.signal) : current.retain();
34046
33968
  const token = await valueToken(staged.owner, value, this.signal);
34047
33969
  try {
@@ -34071,7 +33993,7 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
34071
33993
  try {
34072
33994
  await staged?.release();
34073
33995
  } finally {
34074
- await operation.close();
33996
+ await operation2.close();
34075
33997
  }
34076
33998
  }
34077
33999
  },
@@ -34631,7 +34553,7 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
34631
34553
  if (controlNames.has(name2)) throw new ArrayFailure("control binding cannot be indexed");
34632
34554
  const existingLocal = locals?.get(name2);
34633
34555
  const saved = !locals || existingLocal ? void 0 : assignments2.get(name2) ?? saveVariable(state, name2);
34634
- let operation;
34556
+ let operation2;
34635
34557
  let holding;
34636
34558
  let shadow;
34637
34559
  let preparedExisting = false;
@@ -34657,17 +34579,17 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
34657
34579
  assignments2.delete(name2);
34658
34580
  } else {
34659
34581
  const store = requireArrays(state);
34660
- operation = ArrayOwner.create(store.owner.ledger, store.owner);
34582
+ operation2 = ArrayOwner.create(store.owner.ledger, store.owner);
34661
34583
  holding = store.owner.hold();
34662
- const watch = await store.watch(name2, operation, this.signal);
34663
- const tickets = operation.reserve({ generation: true, version: true, epoch: true, work: 8 });
34664
- const prepared = await store.prepareName(name2, operation, this.signal);
34584
+ const watch = await store.watch(name2, operation2, this.signal);
34585
+ const tickets = operation2.reserve({ generation: true, version: true, epoch: true, work: 8 });
34586
+ const prepared = await store.prepareName(name2, operation2, this.signal);
34665
34587
  const current = store.get(name2);
34666
34588
  if (!saved && current && current.associative !== associativeDeclaration) throw new ArrayFailure("cannot convert array kind");
34667
34589
  shadow = !saved && current ? await current.copy(this.signal) : IndexedBinding.create(store.owner, associativeDeclaration);
34668
34590
  let value = match[2] !== void 0 ? assignedValue() : !saved && !current && Object.hasOwn(state.variables, name2) ? stateMonitor(state)?.values.get(name2, state.variables[name2]) ?? state.variables[name2] : void 0;
34669
34591
  if (value !== void 0) {
34670
- const index = associativeDeclaration ? await shadow.keyIndex("0", operation, this.signal, true) : 0;
34592
+ const index = associativeDeclaration ? await shadow.keyIndex("0", operation2, this.signal, true) : 0;
34671
34593
  if (append) {
34672
34594
  const previous2 = shadow.getValue(index) ?? "";
34673
34595
  value = state.variableAttributes?.get(name2)?.includes("i") ? concatShellValues([`(${shellValueText(previous2) || "0"})+(`, value, ")"], context[valueScope]) : concatShellValues([previous2, value], context[valueScope]);
@@ -34713,7 +34635,7 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
34713
34635
  if (preparedSaved && saved && !locals.has(name2)) await cleanup(() => this.discardVariable(saved));
34714
34636
  if (preparedExisting && existingLocal && !published) await cleanup(() => this.discardVariable(existingLocal));
34715
34637
  await cleanup(() => shadow?.release());
34716
- await cleanup(() => operation?.close());
34638
+ await cleanup(() => operation2?.close());
34717
34639
  await cleanup(() => holding?.release());
34718
34640
  }
34719
34641
  if (primaryPresent) throw primary;
@@ -34730,12 +34652,12 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
34730
34652
  if (name2 === "PIPESTATUS" && arrayStore(state)?.get(name2)) {
34731
34653
  await this.prepareVariable(state, name2, saved);
34732
34654
  const store = requireArrays(state);
34733
- const operation = ArrayOwner.create(store.owner.ledger, store.owner);
34655
+ const operation2 = ArrayOwner.create(store.owner.ledger, store.owner);
34734
34656
  const holding = store.owner.hold();
34735
34657
  try {
34736
- const tickets = operation.reserve({ generation: true, version: true, epoch: true, work: 8 });
34658
+ const tickets = operation2.reserve({ generation: true, version: true, epoch: true, work: 8 });
34737
34659
  const value = match[2] ?? "";
34738
- await textToken(operation, value, this.signal);
34660
+ await textToken(operation2, value, this.signal);
34739
34661
  this.signal.throwIfAborted();
34740
34662
  if (state.readonlyVariables?.has(name2)) throw new ArrayFailure("readonly binding");
34741
34663
  if (!typedSavedVariables.get(saved).watch.valid()) throw new ArrayFailure("stale binding");
@@ -34748,7 +34670,7 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
34748
34670
  await released;
34749
34671
  } finally {
34750
34672
  try {
34751
- await operation.close();
34673
+ await operation2.close();
34752
34674
  } finally {
34753
34675
  holding.release();
34754
34676
  }
@@ -34759,26 +34681,26 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
34759
34681
  if (arrayStore(state)?.get(name2)) {
34760
34682
  await this.prepareVariable(state, name2, saved);
34761
34683
  const store = requireArrays(state);
34762
- const operation = ArrayOwner.create(store.owner.ledger, store.owner);
34684
+ const operation2 = ArrayOwner.create(store.owner.ledger, store.owner);
34763
34685
  const holding = store.owner.hold();
34764
34686
  let shadow;
34765
34687
  try {
34766
- const tickets = operation.reserve({ generation: true, version: true, epoch: true, work: 8 });
34767
- shadow = IndexedBinding.create(store.owner);
34688
+ const tickets = operation2.reserve({ generation: true, version: true, epoch: true, work: 8 });
34689
+ if (enabled.has("I")) shadow = await store.get(name2).copy(this.signal);
34768
34690
  this.signal.throwIfAborted();
34769
34691
  if (state.readonlyVariables?.has(name2)) throw new ArrayFailure("readonly binding");
34770
34692
  if (!typedSavedVariables.get(saved).watch.valid()) throw new ArrayFailure("stale binding");
34771
34693
  let released;
34772
34694
  stateMonitor(state).publish(tickets, name2, () => {
34773
34695
  locals.set(name2, saved);
34774
- released = store.publish(name2, shadow, tickets);
34696
+ released = shadow ? store.publish(name2, shadow, tickets) : store.remove(name2, tickets);
34775
34697
  });
34776
34698
  shadow = void 0;
34777
34699
  await released;
34778
34700
  } finally {
34779
34701
  try {
34780
34702
  await shadow?.release();
34781
- await operation.close();
34703
+ await operation2.close();
34782
34704
  } finally {
34783
34705
  holding.release();
34784
34706
  }
@@ -35467,16 +35389,16 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
35467
35389
  }
35468
35390
  async transformValue(value, operator, state, io) {
35469
35391
  if (operator === "u" || operator === "U" || operator === "L") {
35470
- const text2 = shellValueText(value);
35471
- if (operator === "U") return text2.toUpperCase();
35472
- if (operator === "L") return text2.toLowerCase();
35473
- if (!text2.length) return "";
35474
- const first = [...text2][0];
35475
- return first.toUpperCase() + text2.slice(first.length);
35392
+ const text3 = shellValueText(value);
35393
+ if (operator === "U") return text3.toUpperCase();
35394
+ if (operator === "L") return text3.toLowerCase();
35395
+ if (!text3.length) return "";
35396
+ const first = [...text3][0];
35397
+ return first.toUpperCase() + text3.slice(first.length);
35476
35398
  }
35477
35399
  if (operator === "P") {
35478
- const text2 = shellValueText(value).replace(/\\n/gu, "\n").replace(/\\r/gu, "\r").replace(/\\t/gu, " ").replace(/\\[eE]/gu, "\x1B").replace(/\\a/gu, "\x07").replace(/\\\$/gu, "$").replace(/\\\\/gu, "\\");
35479
- const word = parseArithmeticExpansion(text2, this.budget.parsing, byteLocale(state.variables), state.depth + (io.parameterDepth ?? 0), io.diagnosticLine ?? 1, state.extensions?.syntax);
35400
+ const text3 = shellValueText(value).replace(/\\n/gu, "\n").replace(/\\r/gu, "\r").replace(/\\t/gu, " ").replace(/\\[eE]/gu, "\x1B").replace(/\\a/gu, "\x07").replace(/\\\$/gu, "$").replace(/\\\\/gu, "\\");
35401
+ const word = parseArithmeticExpansion(text3, this.budget.parsing, byteLocale(state.variables), state.depth + (io.parameterDepth ?? 0), io.diagnosticLine ?? 1, state.extensions?.syntax);
35480
35402
  const fields = await this.valueWord(word, state, this.parameterOperandIO(word, state, io), false, false, true);
35481
35403
  return concatShellValues(fields, io[valueScope]);
35482
35404
  }
@@ -35528,6 +35450,7 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
35528
35450
  const capture = new Capture();
35529
35451
  const child = await cloneState(state, this.signal);
35530
35452
  child.isolated = true;
35453
+ child.variables.BASH_SUBSHELL = String(Number(state.variables.BASH_SUBSHELL ?? 0) + 1);
35531
35454
  child.extensions = forkExtensions(state.extensions, "substitution");
35532
35455
  if (state.profile !== "sh") child.errexit = false;
35533
35456
  delete child.redirectAssignments;
@@ -35576,6 +35499,7 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
35576
35499
  }
35577
35500
  const child = await cloneState(state, this.signal);
35578
35501
  child.isolated = true;
35502
+ child.variables.BASH_SUBSHELL = String(Number(state.variables.BASH_SUBSHELL ?? 0) + 1);
35579
35503
  child.extensions = forkExtensions(state.extensions, "substitution");
35580
35504
  if (state.profile !== "sh") child.errexit = false;
35581
35505
  delete child.redirectAssignments;
@@ -35622,6 +35546,7 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
35622
35546
  const capture = new Capture();
35623
35547
  const child = await cloneState(state, this.signal);
35624
35548
  child.isolated = true;
35549
+ child.variables.BASH_SUBSHELL = String(Number(state.variables.BASH_SUBSHELL ?? 0) + 1);
35625
35550
  child.extensions = forkExtensions(state.extensions, "substitution");
35626
35551
  if (state.profile !== "sh") child.errexit = false;
35627
35552
  for (const [name2, value2] of state.redirectAssignments ?? []) {
@@ -35712,7 +35637,7 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
35712
35637
  }
35713
35638
  if (part.length) return String(binding?.values.size ?? (part.name === "FUNCNAME" && state.variables.FUNCNAME === void 0 ? state.functionNames?.length ?? 0 : state.variables[part.name] === void 0 ? 0 : 1));
35714
35639
  const values = await this.arrayMembers(part.name, state, io, selector.kind === "keys" || part.keys === true, part.substring);
35715
- const space = selector.kind === "keys" || part.keys === true ? Boolean(hereDocument || (selector.separator === "@" ? !part.quoted && !split || state.variables.IFS === "" : !part.quoted && split && state.variables.IFS === "")) : !split && selector.separator === "@";
35640
+ const space = selector.kind === "keys" || part.keys === true ? Boolean(hereDocument || (selector.separator === "@" ? !part.quoted && !split || state.variables.IFS === "" : !part.quoted && split && state.variables.IFS === "")) : !split && selector.separator === "@" && (!part.substring || !part.quoted || state.variables.IFS === "");
35716
35641
  return this.arrayJoin(store.owner, values, space ? " " : this.ifsSeparator(state, io));
35717
35642
  }
35718
35643
  if (part.substring && (part.name === "@" || part.name === "*")) {
@@ -35795,8 +35720,8 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
35795
35720
  return String(length);
35796
35721
  }
35797
35722
  ifsSeparator(state, io) {
35798
- const text2 = state.variables.IFS ?? " ";
35799
- const value = stateMonitor(state)?.values.get("IFS", text2) ?? text2;
35723
+ const text3 = state.variables.IFS ?? " ";
35724
+ const value = stateMonitor(state)?.values.get("IFS", text3) ?? text3;
35800
35725
  const byteCount = byteLocale(state.variables);
35801
35726
  if (typeof value === "string" && (!byteCount || !value || value.charCodeAt(0) < 128)) return value ? String.fromCodePoint(value.codePointAt(0)) : "";
35802
35727
  const bytes = shellValueBytes(value, io[valueScope]);
@@ -35826,14 +35751,14 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
35826
35751
  let retained;
35827
35752
  for (const entry of word.parts) {
35828
35753
  this.signal.throwIfAborted();
35829
- const text3 = entry.kind === "text" ? entry.value : await this.part(entry, state, operandIO);
35830
- bytes2 += shellValueByteLength(text3);
35754
+ const text4 = entry.kind === "text" ? entry.value : await this.part(entry, state, operandIO);
35755
+ bytes2 += shellValueByteLength(text4);
35831
35756
  if (bytes2 > limit) this.budget.fail("maxExpansionBytes");
35832
- owner?.reserve({ metadata: 32, payload: bytes2, work: text3.length + 4 });
35833
- const pending = stringCheckpoint(work, text3.length + 1);
35757
+ owner?.reserve({ metadata: 32, payload: bytes2, work: text4.length + 4 });
35758
+ const pending = stringCheckpoint(work, text4.length + 1);
35834
35759
  if (pending) await pending;
35835
- const next = scratch.reserve((source.length + text3.length) * 2, 0);
35836
- source += text3;
35760
+ const next = scratch.reserve((source.length + text4.length) * 2, 0);
35761
+ source += text4;
35837
35762
  retained?.release();
35838
35763
  retained = next;
35839
35764
  }
@@ -35852,8 +35777,8 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
35852
35777
  if (byteLocale(state.variables)) {
35853
35778
  bytes = shellValueBytes(value, scratch);
35854
35779
  }
35855
- const text2 = shellValueText(value);
35856
- const size = BigInt(bytes?.byteLength ?? (await scanString(text2, work)).count);
35780
+ const text3 = shellValueText(value);
35781
+ const size = BigInt(bytes?.byteLength ?? (await scanString(text3, work)).count);
35857
35782
  const offset = offsetExpression.value < 0n ? size + offsetExpression.value : offsetExpression.value;
35858
35783
  if (offset < 0n || offset > size) return "";
35859
35784
  let end = size;
@@ -35865,10 +35790,10 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
35865
35790
  }
35866
35791
  this.signal.throwIfAborted();
35867
35792
  if (!bytes) {
35868
- const start = (await scanString(text2, work, 0, text2.length, Number(offset))).end;
35869
- const finish = (await scanString(text2, work, start, text2.length, Number(end - offset))).end;
35793
+ const start = (await scanString(text3, work, 0, text3.length, Number(offset))).end;
35794
+ const finish = (await scanString(text3, work, start, text3.length, Number(end - offset))).end;
35870
35795
  if (finish > start) scratch.reserve((finish - start) * 2, 0);
35871
- return text2.slice(start, finish);
35796
+ return text3.slice(start, finish);
35872
35797
  }
35873
35798
  return shellValueFromBytes(bytes.subarray(Number(offset), Number(end)), io[valueScope]);
35874
35799
  } finally {
@@ -35937,7 +35862,7 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
35937
35862
  });
35938
35863
  return await trimParameter(value, parts, part.operator, byteLocale(state.variables), work, io[valueScope], limit, !!state.extglob);
35939
35864
  }
35940
- const text2 = shellValueText(value);
35865
+ const text3 = shellValueText(value);
35941
35866
  const anchored = part.operator === "/#" || part.operator === "/%";
35942
35867
  const patternWord = anchored ? { ...part.alternate, parts: [{ kind: "text", value: "", quoted: true }, ...part.alternate.parts] } : part.alternate;
35943
35868
  const patternFields = await this.word(patternWord, state, this.parameterOperandIO(part.alternate, state, io), false, true, hereString);
@@ -35949,7 +35874,7 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
35949
35874
  }
35950
35875
  scratch.reserve(patternUnits * 2, 0);
35951
35876
  const pattern = patternFields.join("");
35952
- await scanString(text2, work);
35877
+ await scanString(text3, work);
35953
35878
  const boundaries = await compilePatternBoundaries(pattern, work, !!state.nocasematch, !!state.extglob);
35954
35879
  const operator = part.operator;
35955
35880
  scratch.reserve(64, 0);
@@ -35970,7 +35895,7 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
35970
35895
  scratch.reserve(64 + value2.length * 2, 0);
35971
35896
  replacements.push({ value: value2, quoted: entry.quoted });
35972
35897
  }
35973
- if (!pattern && operator !== "/#" && operator !== "/%") return text2;
35898
+ if (!pattern && operator !== "/#" && operator !== "/%") return text3;
35974
35899
  let result = "";
35975
35900
  let resultBytes = 0;
35976
35901
  let retained;
@@ -35985,20 +35910,20 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
35985
35910
  retained?.release();
35986
35911
  retained = next;
35987
35912
  };
35988
- const ends = await boundaries(text2, false, operator === "/%");
35913
+ const ends = await boundaries(text3, false, operator === "/%");
35989
35914
  let position = 0;
35990
- while (position <= text2.length) {
35915
+ while (position <= text3.length) {
35991
35916
  let found = false;
35992
- for (let start = position; start <= text2.length; start = nextCodePointOffset(text2, start)) {
35917
+ for (let start = position; start <= text3.length; start = nextCodePointOffset(text3, start)) {
35993
35918
  if (operator === "/#" && start !== 0) break;
35994
35919
  const pending = stringCheckpoint(work);
35995
35920
  if (pending) await pending;
35996
35921
  const end = ends[start];
35997
35922
  if (end < 0) {
35998
- if (start === text2.length) break;
35923
+ if (start === text3.length) break;
35999
35924
  continue;
36000
35925
  }
36001
- await append(text2, position, start);
35926
+ await append(text3, position, start);
36002
35927
  for (const replacement of replacements) {
36003
35928
  if (replacement.quoted) await append(replacement.value);
36004
35929
  else {
@@ -36015,7 +35940,7 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
36015
35940
  }
36016
35941
  if (replacement.value[cursor] !== "&") continue;
36017
35942
  await append(replacement.value, fragment, cursor);
36018
- await append(text2, start, end);
35943
+ await append(text3, start, end);
36019
35944
  fragment = cursor + 1;
36020
35945
  }
36021
35946
  await append(replacement.value, fragment);
@@ -36023,19 +35948,19 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
36023
35948
  }
36024
35949
  position = end;
36025
35950
  found = true;
36026
- if (operator !== "//" || end === text2.length) {
36027
- await append(text2, end);
35951
+ if (operator !== "//" || end === text3.length) {
35952
+ await append(text3, end);
36028
35953
  return result;
36029
35954
  }
36030
35955
  if (end === start) {
36031
- position = nextCodePointOffset(text2, end);
36032
- await append(text2, end, position);
35956
+ position = nextCodePointOffset(text3, end);
35957
+ await append(text3, end, position);
36033
35958
  }
36034
35959
  break;
36035
35960
  }
36036
35961
  if (!found) {
36037
- if (position === 0) return text2;
36038
- await append(text2, position);
35962
+ if (position === 0) return text3;
35963
+ await append(text3, position);
36039
35964
  break;
36040
35965
  }
36041
35966
  }
@@ -36211,7 +36136,7 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
36211
36136
  continue;
36212
36137
  }
36213
36138
  if (part.indirect || part.specialParameter) return void 0;
36214
- if (part.name === "@" || part.name === "*" || part.name === "PIPESTATUS" || part.name === "LINENO" || part.name === "_" || part.name === "FUNCNAME" || part.name === "DIRSTACK") return void 0;
36139
+ if (part.name === "@" || part.name === "*" || part.name === "PIPESTATUS" || part.name === "LINENO" || part.name === "BASH_SUBSHELL" || part.name === "_" || part.name === "FUNCNAME" || part.name === "DIRSTACK") return void 0;
36215
36140
  if (!isShellIdentifier(part.name)) return void 0;
36216
36141
  const selector = getArraySelector(part);
36217
36142
  const arrayBinding = activeArrayStore?.get(part.name);
@@ -36278,7 +36203,7 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
36278
36203
  }
36279
36204
  const ifsVal = monitor?.values.get("IFS", rawVars.IFS ?? " ") ?? rawVars.IFS ?? " ";
36280
36205
  if (validElemOp && typeof ifsVal === "string" && (ifsVal.length === 0 || ifsVal.charCodeAt(0) < 128)) {
36281
- const sep = selector.separator === "@" && (ifsVal.length === 0 || !isKeys && part.operator === void 0) ? " " : ifsVal.length > 0 ? ifsVal[0] : "";
36206
+ const sep = selector.separator === "@" && (ifsVal.length === 0 || !isKeys && part.operator === void 0 && !part.substring) ? " " : ifsVal.length > 0 ? ifsVal[0] : "";
36282
36207
  const parameterLine = part.line ?? overrideDiagnosticLine;
36283
36208
  const evalSliceInt = (w) => {
36284
36209
  if (w.parts.length === 0) return 0;
@@ -36363,18 +36288,8 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
36363
36288
  return void 0;
36364
36289
  }
36365
36290
  if (selector.kind === "element") {
36366
- const cachedSub = selector.index;
36367
- let subWord = selector.index.word ?? (cachedSub._cachedSyntax === rawState.extensions?.syntax ? cachedSub._cachedWord : void 0);
36368
- if (!subWord) {
36369
- if (byteLocale(rawVars) || rawState.depth >= 24) return void 0;
36370
- try {
36371
- subWord = parseArraySubscript(selector.index.source ?? selector.index.decimal, this.budget.parsing, false, rawState.depth, false, rawState.extensions?.syntax);
36372
- cachedSub._cachedWord = subWord;
36373
- cachedSub._cachedSyntax = rawState.extensions?.syntax;
36374
- } catch {
36375
- return void 0;
36376
- }
36377
- }
36291
+ const subWord = this.syncArraySubscriptWord(selector.index, rawState);
36292
+ if (!subWord) return void 0;
36378
36293
  const subVal = this.fastValueWord(subWord, rawState, io, false, false, false, false, void 0, part.line ?? overrideDiagnosticLine);
36379
36294
  if (typeof subVal !== "string") return void 0;
36380
36295
  let elemVal;
@@ -36497,6 +36412,12 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
36497
36412
  if (part.length || part.operator !== void 0 || this.budget.limits.maxExpansionBytes !== Infinity || rawState.depth + (io.parameterDepth ?? 0) >= 60 || !part.substring.offset.parts.every((p) => p.kind === "text" || p.kind === "arithmetic" || p.kind === "variable" && !p.operator && !p.substring) || part.substring.length && !part.substring.length.parts.every((p) => p.kind === "text" || p.kind === "arithmetic" || p.kind === "variable" && !p.operator && !p.substring) || ValueScope.prototype.reserve !== defaultValueScopeReserve || String.prototype.codePointAt !== defaultStringCodePointAt || globalThis.Float64Array !== defaultFloat64Array || !part.substring.offset.parts.length && !part.substring.length) {
36498
36413
  return void 0;
36499
36414
  }
36415
+ const raw2 = rawVars[part.name];
36416
+ this.requireParameter(raw2, part.name, state, io, part.line ?? overrideDiagnosticLine);
36417
+ if (raw2 === void 0) {
36418
+ if (split && !part.quoted) return void 0;
36419
+ continue;
36420
+ }
36500
36421
  const parameterLine = part.line ?? overrideDiagnosticLine;
36501
36422
  const evalSubInt = (w) => {
36502
36423
  if (w.parts.length === 0) return 0;
@@ -36515,12 +36436,6 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
36515
36436
  if (offsetNum === void 0) return void 0;
36516
36437
  const lenNum = part.substring.length ? evalSubInt(part.substring.length) : void 0;
36517
36438
  if (part.substring.length && lenNum === void 0) return void 0;
36518
- const raw2 = rawVars[part.name];
36519
- this.requireParameter(raw2, part.name, state, io, part.line ?? overrideDiagnosticLine);
36520
- if (raw2 === void 0) {
36521
- if (split && !part.quoted) return void 0;
36522
- continue;
36523
- }
36524
36439
  const val2 = this._syncArithRawWriteOnly && this._syncArithTouched?.has(part.name) ? raw2 : monitor?.values.get(part.name, raw2) ?? raw2;
36525
36440
  if (typeof val2 !== "string" || val2.length > this.budget.limits.maxExpansionBytes) return void 0;
36526
36441
  for (let k = 0; k < val2.length; k++) {
@@ -39754,9 +39669,9 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
39754
39669
  return void 0;
39755
39670
  }
39756
39671
  evalSyncAwk(rawLines, opArgs) {
39757
- for (const text2 of [...rawLines, ...opArgs]) {
39758
- for (let i = 0; i < text2.length; i++) {
39759
- if (text2.charCodeAt(i) > 127) return void 0;
39672
+ for (const text3 of [...rawLines, ...opArgs]) {
39673
+ for (let i = 0; i < text3.length; i++) {
39674
+ if (text3.charCodeAt(i) > 127) return void 0;
39760
39675
  }
39761
39676
  }
39762
39677
  if (opArgs.length < 1 || opArgs.length > 8) return void 0;
@@ -40449,10 +40364,10 @@ ${prefix} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
40449
40364
  }
40450
40365
  return out + "'";
40451
40366
  }
40452
- wcMaxLineWidth(text2, singleByte) {
40367
+ wcMaxLineWidth(text3, singleByte) {
40453
40368
  let columns = 0;
40454
40369
  let maximum = 0;
40455
- for (const char of text2) {
40370
+ for (const char of text3) {
40456
40371
  const point = char.codePointAt(0);
40457
40372
  if (point === 10 || point === 13 || point === 12) {
40458
40373
  maximum = Math.max(maximum, columns);
@@ -43274,8 +43189,8 @@ unsigned int ${ident}_len = ${view.byteLength};
43274
43189
  const parseG = (s) => {
43275
43190
  let start = 0;
43276
43191
  while (start < s.length && (s.charCodeAt(start) === 32 || s.charCodeAt(start) >= 9 && s.charCodeAt(start) <= 13)) start++;
43277
- const text2 = s.slice(start);
43278
- const lower = text2.toLowerCase();
43192
+ const text3 = s.slice(start);
43193
+ const lower = text3.toLowerCase();
43279
43194
  const unsigned = lower[0] === "+" || lower[0] === "-" ? lower.slice(1) : lower;
43280
43195
  if (unsigned.startsWith("nan")) return { rank: 1, value: 0 };
43281
43196
  if (unsigned.startsWith("inf")) return { rank: 2, value: lower[0] === "-" ? -Infinity : Infinity };
@@ -43305,7 +43220,7 @@ unsigned int ${ident}_len = ${view.byteLength};
43305
43220
  return { rank: 2, value: lower[0] === "-" ? -value2 : value2 };
43306
43221
  }
43307
43222
  }
43308
- const value = Number.parseFloat(text2);
43223
+ const value = Number.parseFloat(text3);
43309
43224
  return { rank: Number.isNaN(value) ? 0 : 2, value: Number.isNaN(value) ? 0 : value };
43310
43225
  };
43311
43226
  const ga = parseG(sa), gb = parseG(sb);
@@ -43821,6 +43736,7 @@ unsigned int ${ident}_len = ${view.byteLength};
43821
43736
  const p = word.parts[i];
43822
43737
  if (p.kind === "text") continue;
43823
43738
  if (p.kind === "variable") {
43739
+ if (p.name === "BASH_SUBSHELL") return false;
43824
43740
  if (!p.indirect && !p.prefixNames && !p.length && !p.substring && !p.transform && p.operator === void 0 && getArraySelector(p) === void 0 && (p.name === "?" || p.name === "#" || p.name.length === 1 && p.name >= "1" && p.name <= "9")) {
43825
43741
  const activePos = this._fastSubPositional ?? rawState.positional;
43826
43742
  if (rawState.nounset && p.name >= "1" && p.name <= "9" && activePos[p.name.charCodeAt(0) - 49] === void 0) return false;
@@ -46564,17 +46480,17 @@ unsigned int ${ident}_len = ${view.byteLength};
46564
46480
  if (typeof val !== "string") return void 0;
46565
46481
  subArgs.push(val);
46566
46482
  }
46567
- let formatted;
46568
- if (w0Plain === "printf") formatted = tryFastPrintf(subArgs);
46569
- else if (w0Plain === "echo") formatted = tryFastEcho(subArgs);
46483
+ let formatted2;
46484
+ if (w0Plain === "printf") formatted2 = tryFastPrintf(subArgs);
46485
+ else if (w0Plain === "echo") formatted2 = tryFastEcho(subArgs);
46570
46486
  else {
46571
46487
  if (subArgs[0]?.startsWith("-")) return void 0;
46572
- formatted = `${subArgs.join(" ")}
46488
+ formatted2 = `${subArgs.join(" ")}
46573
46489
  `;
46574
- if (formatted.includes("\0")) return void 0;
46490
+ if (formatted2.includes("\0")) return void 0;
46575
46491
  }
46576
- if (formatted === void 0) return void 0;
46577
- const byteLength = shellValueByteLength(formatted);
46492
+ if (formatted2 === void 0) return void 0;
46493
+ const byteLength = shellValueByteLength(formatted2);
46578
46494
  const nextBytes = this.budget.bytes + byteLength;
46579
46495
  if (nextBytes > this.budget.maxOutputBytesSmi && byteLength > this.budget.limits.maxOutputBytes - this.budget.bytes) this.budget.fail("maxOutputBytes");
46580
46496
  this.budget.bytes = nextBytes;
@@ -46582,9 +46498,9 @@ unsigned int ${ident}_len = ${view.byteLength};
46582
46498
  rawState.substitutionStatus = 0;
46583
46499
  rawState.status = 0;
46584
46500
  if (fnPositional !== void 0) this.budget.tick();
46585
- let end = formatted.length;
46586
- while (end > 0 && formatted.charCodeAt(end - 1) === 10) end--;
46587
- return end === formatted.length ? formatted : formatted.slice(0, end);
46501
+ let end = formatted2.length;
46502
+ while (end > 0 && formatted2.charCodeAt(end - 1) === 10) end--;
46503
+ return end === formatted2.length ? formatted2 : formatted2.slice(0, end);
46588
46504
  } finally {
46589
46505
  this._fastSubPositional = prevFastSubPos;
46590
46506
  }
@@ -46646,7 +46562,7 @@ unsigned int ${ident}_len = ${view.byteLength};
46646
46562
  let expansionBytes = 0;
46647
46563
  const append = (value, glob, present) => {
46648
46564
  if (splitBoundary && present) addField();
46649
- const text2 = shellValueText(value);
46565
+ const text3 = shellValueText(value);
46650
46566
  const size = shellValueByteLength(value);
46651
46567
  if (size > this.budget.limits.maxExpansionBytes - expansionBytes) this.budget.fail("maxExpansionBytes");
46652
46568
  expansionBytes += size;
@@ -46654,24 +46570,24 @@ unsigned int ${ident}_len = ${view.byteLength};
46654
46570
  let escapes2 = 0;
46655
46571
  if (!glob) {
46656
46572
  const special = conditionalPattern || state.extglob ? "\\*?[]-^()|+!@:" : "\\*?[]-^!:";
46657
- for (const character of text2) if (special.includes(character)) escapes2++;
46573
+ for (const character of text3) if (special.includes(character)) escapes2++;
46658
46574
  }
46659
46575
  scratch?.reserve(32, 0);
46660
- if (owner) owner.reserve({ payload: size + (escapes2 ? size + escapes2 : 0), metadata: 64, work: text2.length + 8 });
46576
+ if (owner) owner.reserve({ payload: size + (escapes2 ? size + escapes2 : 0), metadata: 64, work: text3.length + 8 });
46661
46577
  if (escapes2) {
46662
- scratch?.reserve((field.patterns ? 32 : 32 * (field.fragments.length + 1)) + (text2.length + escapes2) * 2, 0);
46578
+ scratch?.reserve((field.patterns ? 32 : 32 * (field.fragments.length + 1)) + (text3.length + escapes2) * 2, 0);
46663
46579
  field.patterns ??= field.fragments.map(shellValueText);
46664
- field.patterns.push(text2.replace(conditionalPattern || state.extglob ? /[\\*?[\]\-^()|+!@:]/gu : /[\\*?[\]\-^!:]/gu, "\\$&"));
46580
+ field.patterns.push(text3.replace(conditionalPattern || state.extglob ? /[\\*?[\]\-^()|+!@:]/gu : /[\\*?[\]\-^!:]/gu, "\\$&"));
46665
46581
  } else if (field.patterns) {
46666
46582
  scratch?.reserve(32, 0);
46667
- field.patterns.push(text2);
46583
+ field.patterns.push(text3);
46668
46584
  }
46669
46585
  if (typeof value !== "string" || field.bytes) {
46670
46586
  if (!scratch) io[valueScope]?.reserve(32 * (field.bytes ? 1 : field.fragments.length + 1), field.bytes ? 1 : field.fragments.length + 1);
46671
46587
  if (typeof value !== "string") io[valueScope]?.hold(value);
46672
46588
  field.bytes = true;
46673
46589
  }
46674
- regexAppend?.(text2, !glob, value);
46590
+ regexAppend?.(text3, !glob, value);
46675
46591
  field.fragments.push(value);
46676
46592
  field.present ||= present;
46677
46593
  if (present) {
@@ -46878,12 +46794,12 @@ unsigned int ${ident}_len = ${view.byteLength};
46878
46794
  scratch?.reserve(field.fragments.length * 32, 0);
46879
46795
  field.patterns = field.fragments.map(shellValueText);
46880
46796
  }
46881
- if (scratch && field.patterns && field.patterns.length > 1) scratch.reserve(field.patterns.reduce((bytes, text2) => bytes + text2.length * 2, 0), 0);
46797
+ if (scratch && field.patterns && field.patterns.length > 1) scratch.reserve(field.patterns.reduce((bytes, text3) => bytes + text3.length * 2, 0), 0);
46882
46798
  const fieldPattern = field.patterns ? field.patterns.join("") : projection;
46883
46799
  const expanded = split ? await this.glob(projection, fieldPattern, state) : [pattern ? fieldPattern : projection];
46884
- for (const text2 of expanded) {
46800
+ for (const text3 of expanded) {
46885
46801
  if (result.length >= this.budget.limits.maxExpansionFields) this.budget.fail("maxExpansionFields");
46886
- const value = !pattern && expanded.length === 1 && text2 === projection ? assembled : text2;
46802
+ const value = !pattern && expanded.length === 1 && text3 === projection ? assembled : text3;
46887
46803
  const size = shellValueByteLength(value);
46888
46804
  if (size > this.budget.limits.maxExpansionBytes - resultBytes) this.budget.fail("maxExpansionBytes");
46889
46805
  resultBytes += size;
@@ -46904,15 +46820,15 @@ unsigned int ${ident}_len = ${view.byteLength};
46904
46820
  this.budget.cpuCheckpoint();
46905
46821
  const work = this.splitWork ??= { scanned: 0 };
46906
46822
  if (typeof value === "string" || !asciiSeparators) {
46907
- const text2 = shellValueText(value);
46823
+ const text3 = shellValueText(value);
46908
46824
  const slice = (start3, end) => {
46909
- if (start3 === 0 && end === text2.length) return text2;
46825
+ if (start3 === 0 && end === text3.length) return text3;
46910
46826
  scratch?.reserve((end - start3) * 2, 0);
46911
- return text2.slice(start3, end);
46827
+ return text3.slice(start3, end);
46912
46828
  };
46913
46829
  let start2 = 0;
46914
- for (let index = 0; index < text2.length; ) {
46915
- const point = text2.codePointAt(index);
46830
+ for (let index = 0; index < text3.length; ) {
46831
+ const point = text3.codePointAt(index);
46916
46832
  const character = String.fromCodePoint(point);
46917
46833
  const end = index + character.length;
46918
46834
  if (separators.has(point)) {
@@ -46930,7 +46846,7 @@ unsigned int ${ident}_len = ${view.byteLength};
46930
46846
  await yieldTurn(this.signal);
46931
46847
  }
46932
46848
  }
46933
- if (start2 < text2.length) yield slice(start2, text2.length);
46849
+ if (start2 < text3.length) yield slice(start2, text3.length);
46934
46850
  return;
46935
46851
  }
46936
46852
  const bytes = shellValueBytes(value, io[valueScope]);
@@ -47003,10 +46919,10 @@ unsigned int ${ident}_len = ${view.byteLength};
47003
46919
  positionalValues(state) {
47004
46920
  const store = stateMonitor(state)?.positionals;
47005
46921
  if (!store || !store.hasObjectValues()) return state.positional.slice();
47006
- return state.positional.map((text2, index) => store.get(String(index), text2));
46922
+ return state.positional.map((text3, index) => store.get(String(index), text3));
47007
46923
  }
47008
46924
  replacePositionals(state, values, action, initialArg0) {
47009
- const publish2 = action ?? (() => {
46925
+ const publish3 = action ?? (() => {
47010
46926
  state.positional = values.map(shellValueText);
47011
46927
  });
47012
46928
  const store = stateMonitor(state)?.positionals;
@@ -47029,8 +46945,8 @@ unsigned int ${ident}_len = ${view.byteLength};
47029
46945
  }
47030
46946
  const entries = values.map((value, index) => [String(index), value]);
47031
46947
  if (typeof zero !== "string") entries.push([zeroPositionKey, zero]);
47032
- store.replace(entries, publish2);
47033
- } else publish2();
46948
+ store.replace(entries, publish3);
46949
+ } else publish3();
47034
46950
  }
47035
46951
  admitArguments(values, allocation) {
47036
46952
  if (!values.some((value) => typeof value !== "string")) return createCommandArguments(values);
@@ -47055,8 +46971,8 @@ unsigned int ${ident}_len = ${view.byteLength};
47055
46971
  for (let index = Number(offset); index < end; index++) {
47056
46972
  if (values.length >= this.budget.limits.maxExpansionFields) this.budget.fail("maxExpansionFields");
47057
46973
  io[valueScope]?.reserve(32, 0);
47058
- const text2 = index === 0 ? state.arg0 ?? "virtual-bash" : state.positional[index - 1];
47059
- values.push(stateMonitor(state)?.positionals.get(index === 0 ? zeroPositionKey : String(index - 1), text2) ?? text2);
46974
+ const text3 = index === 0 ? state.arg0 ?? "virtual-bash" : state.positional[index - 1];
46975
+ values.push(stateMonitor(state)?.positionals.get(index === 0 ? zeroPositionKey : String(index - 1), text3) ?? text3);
47060
46976
  if (index % 4096 === 0) await yieldTurn(this.signal);
47061
46977
  }
47062
46978
  return values;
@@ -47092,8 +47008,8 @@ unsigned int ${ident}_len = ${view.byteLength};
47092
47008
  const sliced = stack.slice(start, end);
47093
47009
  return keys ? sliced.map((_v, idx) => String(start + idx)) : sliced;
47094
47010
  }
47095
- const text2 = state.variables[name2];
47096
- const value = text2 === void 0 ? void 0 : keys ? "0" : stateMonitor(state)?.values.get(name2, text2) ?? text2;
47011
+ const text3 = state.variables[name2];
47012
+ const value = text3 === void 0 ? void 0 : keys ? "0" : stateMonitor(state)?.values.get(name2, text3) ?? text3;
47097
47013
  if (value === void 0 || offset > 0n) return [];
47098
47014
  store.owner.reserve({ metadata: 32, allocatedSlots: 1, work: 3 });
47099
47015
  await textToken(store.owner, value, this.signal);
@@ -47346,7 +47262,7 @@ unsigned int ${ident}_len = ${view.byteLength};
47346
47262
  return found.length ? found : state.nullglob ? [] : [value];
47347
47263
  }
47348
47264
  };
47349
- Object.assign(Budget.prototype, {
47265
+ Object.assign(Budget2.prototype, {
47350
47266
  hasInfiniteFsOps: true,
47351
47267
  canRedirect1: true,
47352
47268
  maxSourceBytesSmi: 1073741823,
@@ -47623,19 +47539,19 @@ async function restoreShellSessionState(state, snapshot, explicitOptions, budget
47623
47539
  if (snapshot.arrays && Object.keys(snapshot.arrays).length > 0) {
47624
47540
  tracked = trackState(state, budget, scope);
47625
47541
  const store = requireArrays(tracked);
47626
- const operation = ArrayOwner.create(store.owner.ledger, store.owner);
47542
+ const operation2 = ArrayOwner.create(store.owner.ledger, store.owner);
47627
47543
  const holding = store.owner.hold();
47628
47544
  try {
47629
47545
  for (const [name2, arr] of Object.entries(snapshot.arrays)) {
47630
47546
  delete tracked.variables[name2];
47631
47547
  const isAssoc = arr.kind === "associative";
47632
- const prepared = await store.prepareName(name2, operation, budget.signal);
47633
- const tickets = operation.reserve({ generation: true, version: true, epoch: true, work: 8 });
47548
+ const prepared = await store.prepareName(name2, operation2, budget.signal);
47549
+ const tickets = operation2.reserve({ generation: true, version: true, epoch: true, work: 8 });
47634
47550
  const binding = IndexedBinding.create(store.owner, isAssoc);
47635
47551
  binding.assigned = arr.assigned !== false;
47636
47552
  if (isAssoc) {
47637
47553
  for (const [key, val] of Object.entries(arr.elements)) {
47638
- const index = await binding.keyIndex(key, operation, budget.signal, true);
47554
+ const index = await binding.keyIndex(key, operation2, budget.signal, true);
47639
47555
  if (index !== void 0) {
47640
47556
  const token = await valueToken(binding.owner, val, budget.signal);
47641
47557
  try {
@@ -47664,7 +47580,7 @@ async function restoreShellSessionState(state, snapshot, explicitOptions, budget
47664
47580
  }
47665
47581
  } finally {
47666
47582
  try {
47667
- await operation.close();
47583
+ await operation2.close();
47668
47584
  } finally {
47669
47585
  holding.release();
47670
47586
  }
@@ -48427,7 +48343,7 @@ var Shell = class _Shell {
48427
48343
  }
48428
48344
  }
48429
48345
  const limits = options.limits === void 0 ? this.#resolvedLimits : resolveLimits(this.#options.limits, options.limits);
48430
- const budget = warm ? warm.budget : new Budget(limits, options.signal, options.onInternalError ?? this.#options.onInternalError);
48346
+ const budget = warm ? warm.budget : new Budget2(limits, options.signal, options.onInternalError ?? this.#options.onInternalError);
48431
48347
  const scope = warm ? warm.scope : new InvocationScope(options.signal);
48432
48348
  const cancellationState = warm ? warm.cancellationState : new RuntimeCancellationState();
48433
48349
  const owner = warm ? warm.owner : new RootInvocationCancellationOwner(scope);
@@ -48913,6 +48829,7 @@ var cloudflareWorkerLimits = Object.freeze({
48913
48829
  maxPipelineStages: 64,
48914
48830
  maxLoopIterations: 1e3,
48915
48831
  maxSubstitutionDepth: 16,
48832
+ maxFunctionDepth: 16,
48916
48833
  maxSourceBytes: 256 * 1024,
48917
48834
  maxExpansionFields: 1e3,
48918
48835
  maxExpansionBytes: 4 * 1024 * 1024,