@poe-platform/safe-bash 0.1.803 → 0.1.804

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 (696) hide show
  1. package/README.md +56 -31
  2. package/dist/image-ast/ast.d.ts +1 -0
  3. package/dist/image-ast/browser/ast.d.ts +1 -0
  4. package/dist/image-ast/browser/codecs/jpeg.d.ts +2 -2
  5. package/dist/image-ast/codecs/jpeg.d.ts +2 -2
  6. package/dist/image-ast/index.browser.js +692 -8364
  7. package/dist/image-ast/index.js +692 -8364
  8. package/dist/mp4-ast/codecs.d.ts +7 -2
  9. package/dist/safe-bash/chunks/{chunk-CHYGPFVM.js → chunk-22SX3F2R.js} +1 -1
  10. package/dist/safe-bash/chunks/{chunk-FBUCWVTE.js → chunk-2IVBJTBD.js} +1 -1
  11. package/dist/safe-bash/chunks/chunk-2POETUMB.js +190 -0
  12. package/dist/safe-bash/chunks/{chunk-XVOSKJE2.js → chunk-47D7WBJK.js} +1 -1
  13. package/dist/safe-bash/chunks/{chunk-VKNVHEX3.js → chunk-4ESI236Y.js} +1 -1
  14. package/dist/safe-bash/chunks/{chunk-74GHTNJA.js → chunk-4KTMKD5W.js} +1 -1
  15. package/dist/safe-bash/chunks/{chunk-55YJASTN.js → chunk-4T53AERN.js} +1 -1
  16. package/dist/safe-bash/chunks/{chunk-DQP3VHSB.js → chunk-5XIFJVOO.js} +1 -1
  17. package/dist/safe-bash/chunks/{chunk-5OHX7C2V.js → chunk-62BOHHJT.js} +1 -1
  18. package/dist/safe-bash/chunks/{chunk-HZAMGT5I.js → chunk-67WIFM3N.js} +17 -6
  19. package/dist/safe-bash/chunks/{chunk-4D4N7IU2.js → chunk-6LNFRPW5.js} +2 -2
  20. package/dist/safe-bash/chunks/{chunk-6O77NL2S.js → chunk-6SMICPI3.js} +1 -1
  21. package/dist/safe-bash/chunks/{chunk-4BSJLKNM.js → chunk-7O76UFQD.js} +1 -1
  22. package/dist/safe-bash/chunks/{chunk-PNBBUWSM.js → chunk-AW5KIT6V.js} +3488 -39
  23. package/dist/safe-bash/chunks/{chunk-JMMEIDPF.js → chunk-B2Z73HTZ.js} +52 -28
  24. package/dist/safe-bash/chunks/chunk-B3ZMOJVM.js +319 -0
  25. package/dist/safe-bash/chunks/{chunk-7ZBU7KYV.js → chunk-CFAWS3O4.js} +1 -1
  26. package/dist/safe-bash/chunks/{chunk-I5HZ4FGE.js → chunk-CL2FCTTO.js} +1 -1
  27. package/dist/safe-bash/chunks/{chunk-2LSAMQER.js → chunk-CTXNARJH.js} +1 -1
  28. package/dist/safe-bash/chunks/{chunk-TFIBK2GI.js → chunk-D5Q7NFWI.js} +1 -1
  29. package/dist/safe-bash/chunks/{chunk-OQRVVGR6.js → chunk-DSOOVZ6Q.js} +1 -1
  30. package/dist/safe-bash/chunks/{chunk-VTH3MLDU.js → chunk-DUTAG6ZD.js} +1 -1
  31. package/dist/safe-bash/chunks/{chunk-XAQMU6OY.js → chunk-EE5YGFIZ.js} +1 -1
  32. package/dist/safe-bash/chunks/{chunk-FZE4HW6G.js → chunk-EJOYT2ME.js} +1 -1
  33. package/dist/safe-bash/chunks/chunk-FAAIR6EJ.js +887 -0
  34. package/dist/safe-bash/chunks/{chunk-OV6IHKO6.js → chunk-FOB2FZR4.js} +2 -2
  35. package/dist/safe-bash/chunks/chunk-G6V4RRSQ.js +14 -0
  36. package/dist/safe-bash/chunks/{chunk-UTBUUFDM.js → chunk-GGQAGQXQ.js} +1 -1
  37. package/dist/safe-bash/chunks/{chunk-K6VCD7IY.js → chunk-HIIYIJ5G.js} +2 -4
  38. package/dist/safe-bash/chunks/{chunk-VBTDHOWC.js → chunk-IOHH2GTI.js} +4 -3
  39. package/dist/safe-bash/chunks/{chunk-CTVWDACF.js → chunk-IQW34XQT.js} +1 -1
  40. package/dist/safe-bash/chunks/{chunk-HZ7BWKQ3.js → chunk-IS572AAT.js} +1 -1
  41. package/dist/safe-bash/chunks/{chunk-AUSNDQTJ.js → chunk-JPSUHHOA.js} +1 -1
  42. package/dist/safe-bash/chunks/{chunk-ZVD5IS4V.js → chunk-KBZ4UB2O.js} +2 -2
  43. package/dist/safe-bash/chunks/{chunk-AM5ESLPH.js → chunk-KU5CVWKA.js} +1 -1
  44. package/dist/safe-bash/chunks/{chunk-RYFQ3LZG.js → chunk-LPOVNKNB.js} +173 -153
  45. package/dist/safe-bash/chunks/{chunk-46Z5E5EV.js → chunk-MBOC3LZ4.js} +1 -1
  46. package/dist/safe-bash/chunks/{chunk-6PAVEFT3.js → chunk-N4BQFD3P.js} +1 -1
  47. package/dist/safe-bash/chunks/{chunk-CS4MNM6I.js → chunk-NGKCVNWS.js} +1 -1
  48. package/dist/safe-bash/chunks/{chunk-7R5BDCG7.js → chunk-OHML2BEU.js} +1 -1
  49. package/dist/safe-bash/chunks/{chunk-C5OWC2TL.js → chunk-OQ3AGYCZ.js} +1 -1
  50. package/dist/safe-bash/chunks/{chunk-B7TAL7S5.js → chunk-PTAEWLSE.js} +0 -2
  51. package/dist/safe-bash/chunks/{chunk-LVOBFF4D.js → chunk-Q4FNLOTI.js} +1 -1
  52. package/dist/safe-bash/chunks/chunk-Q5XO3NAS.js +1036 -0
  53. package/dist/safe-bash/chunks/{chunk-GEG3BWGE.js → chunk-RHFRJIWQ.js} +1 -1
  54. package/dist/safe-bash/chunks/chunk-RUR6J33T.js +11 -0
  55. package/dist/safe-bash/chunks/{chunk-EEEWOYEG.js → chunk-S4RFUUXO.js} +839 -24
  56. package/dist/safe-bash/chunks/{chunk-RRR7AQ24.js → chunk-SD2ISU5L.js} +1 -1
  57. package/dist/safe-bash/chunks/{chunk-3NDIFSNM.js → chunk-SUJ3NTMH.js} +3 -3
  58. package/dist/safe-bash/chunks/{chunk-R3NAKOED.js → chunk-SZRUU5HS.js} +2 -2
  59. package/dist/safe-bash/chunks/{chunk-PH63PLPZ.js → chunk-TC3F4UFF.js} +1 -1
  60. package/dist/safe-bash/chunks/{chunk-3R3AANOR.js → chunk-TCKYOLUE.js} +1 -1
  61. package/dist/safe-bash/chunks/{chunk-D3ANYGMC.js → chunk-UV4X32QU.js} +1 -1
  62. package/dist/safe-bash/chunks/{chunk-E7OYNDGL.js → chunk-V7QT2RWC.js} +1 -1
  63. package/dist/safe-bash/chunks/{chunk-B7PIL77G.js → chunk-W2IYOVHK.js} +804 -1195
  64. package/dist/safe-bash/chunks/{chunk-3HQU4OJO.js → chunk-XNGVOSGI.js} +1 -1
  65. package/dist/safe-bash/chunks/{chunk-J42RIHHJ.js → chunk-XQWCQSRN.js} +1 -1
  66. package/dist/safe-bash/chunks/{chunk-A7XEHALN.js → chunk-Y7FW6GLT.js} +6 -6
  67. package/dist/safe-bash/chunks/{chunk-QGUV42T5.js → chunk-YL3GBUG4.js} +1 -1
  68. package/dist/safe-bash/chunks/chunk-YOXUCJER.js +389 -0
  69. package/dist/safe-bash/chunks/{chunk-HBCN24ZA.js → chunk-Z2AAYYJN.js} +2 -2
  70. package/dist/safe-bash/chunks/chunk-ZKYKJCZZ.js +30 -0
  71. package/dist/safe-bash/chunks/core-IE3AFIDX.js +85806 -0
  72. package/dist/safe-bash/chunks/{ffmpeg-WTC3TEFI.js → ffmpeg-YANDK6HU.js} +2 -2
  73. package/dist/safe-bash/chunks/{gh-6WU6PXL4.js → gh-4MBJ2S5V.js} +2 -2
  74. package/dist/safe-bash/chunks/{git-EFZIGJW4.js → git-2QONJNRQ.js} +2 -2
  75. package/dist/safe-bash/chunks/{imagemagick-EIEYGWPF.js → imagemagick-JLEHGYSN.js} +2 -2
  76. package/dist/safe-bash/chunks/{mmdc-ROQJT5HQ.js → mmdc-6LD7A6ND.js} +2 -2
  77. package/dist/safe-bash/chunks/{pdfimages-DW7LWXFI.js → pdfimages-RSHL7LOP.js} +2 -2
  78. package/dist/safe-bash/chunks/{pdfinfo-TIP6XLUQ.js → pdfinfo-L3SGWPNG.js} +2 -2
  79. package/dist/safe-bash/chunks/{pdftk-DMG22ITZ.js → pdftk-LFBJNU5A.js} +2 -2
  80. package/dist/safe-bash/chunks/{pdftoppm-WNDYR72T.js → pdftoppm-NXXFUIHG.js} +2 -2
  81. package/dist/safe-bash/chunks/{pdftotext-5IPZ4NI7.js → pdftotext-4IHNWT6F.js} +2 -2
  82. package/dist/safe-bash/chunks/{qpdf-TTX2DIUA.js → qpdf-ZEIREV63.js} +2 -2
  83. package/dist/safe-bash/chunks/read-builtin-A4QKAT45.js +9 -0
  84. package/dist/safe-bash/chunks/{sips-XYS46JPJ.js → sips-D5YBG2V3.js} +2 -2
  85. package/dist/safe-bash/chunks/{soffice-TU73E5KL.js → soffice-RAJU3JUT.js} +2 -2
  86. package/dist/safe-bash/chunks/source-files-3XWRRHFA.js +7 -0
  87. package/dist/safe-bash/chunks/{wkhtmltopdf-FSZ2CHGE.js → wkhtmltopdf-7UE4FORZ.js} +2 -2
  88. package/dist/safe-bash/command-chunks/{chunk-7KWZXKY6.js → chunk-26RTBV2I.js} +1 -0
  89. package/dist/safe-bash/command-chunks/{chunk-AQJ2ROJO.js → chunk-2WYNMZR2.js} +10 -8
  90. package/dist/safe-bash/command-chunks/{chunk-BDSMROQZ.js → chunk-36GFRF2N.js} +2 -1
  91. package/dist/safe-bash/command-chunks/{chunk-GC5TJZOF.js → chunk-3VIA2IA7.js} +114 -31
  92. package/dist/safe-bash/command-chunks/{chunk-NKFYQSES.js → chunk-4CTI3ZTX.js} +1 -0
  93. package/dist/safe-bash/command-chunks/{chunk-WH627NJL.js → chunk-4MYP2FX4.js} +2 -1
  94. package/dist/safe-bash/command-chunks/{chunk-ZDN7MJE6.js → chunk-4R5ADJM5.js} +11 -1
  95. package/dist/safe-bash/command-chunks/{chunk-P2N33UMN.js → chunk-5MIKM54M.js} +4 -4
  96. package/dist/safe-bash/command-chunks/{chunk-DB453IE6.js → chunk-6FZQUOSJ.js} +1 -1
  97. package/dist/safe-bash/command-chunks/{chunk-PICVQ6B5.js → chunk-6GKYHPJG.js} +1 -1
  98. package/dist/safe-bash/command-chunks/{chunk-7K6JYKPJ.js → chunk-6M2ELGEN.js} +17 -15
  99. package/dist/safe-bash/command-chunks/{chunk-PXEIT2O4.js → chunk-6UR7V3ET.js} +8 -1
  100. package/dist/safe-bash/command-chunks/{chunk-6KJ3LPI2.js → chunk-6XBS5B46.js} +26 -3
  101. package/dist/safe-bash/command-chunks/{chunk-5PWJG2UK.js → chunk-6YXLZX7L.js} +2 -2
  102. package/dist/safe-bash/command-chunks/{chunk-EK6YNAXT.js → chunk-753YOR54.js} +31 -5
  103. package/dist/safe-bash/command-chunks/{chunk-RMWQAAO5.js → chunk-7IR4NRNE.js} +2 -2
  104. package/dist/safe-bash/command-chunks/{chunk-FZTK4MFI.js → chunk-7NM73SVK.js} +8 -8
  105. package/dist/safe-bash/command-chunks/{chunk-NXEQ3ESQ.js → chunk-7QD5YY4F.js} +6 -11
  106. package/dist/safe-bash/command-chunks/{chunk-EMPU65ZK.js → chunk-A5LBSJGH.js} +1 -0
  107. package/dist/safe-bash/command-chunks/{chunk-4FEVBOL5.js → chunk-ARZMP2L2.js} +2 -2
  108. package/dist/safe-bash/command-chunks/{chunk-NKIELG7Y.js → chunk-BAKFZ477.js} +40 -19
  109. package/dist/safe-bash/command-chunks/{chunk-QRRYN2KO.js → chunk-BC7BK6R6.js} +0 -2424
  110. package/dist/safe-bash/command-chunks/{chunk-CQHP3I66.js → chunk-BOEOJS2Q.js} +1 -1
  111. package/dist/safe-bash/command-chunks/{chunk-XS72HTMA.js → chunk-BWGGLYEB.js} +5 -22
  112. package/dist/safe-bash/command-chunks/{chunk-PMBFZXTK.js → chunk-C5ZZKP7V.js} +1 -1
  113. package/dist/safe-bash/command-chunks/{chunk-LHIOAFWW.js → chunk-C7SEB6WU.js} +1 -1
  114. package/dist/safe-bash/command-chunks/{chunk-XPT2UGBF.js → chunk-CHJKFRT7.js} +1 -1
  115. package/dist/safe-bash/command-chunks/{chunk-TIOCQVUQ.js → chunk-CON26Q2O.js} +1 -1
  116. package/dist/safe-bash/command-chunks/{chunk-E55UKBIE.js → chunk-DBAT3IK2.js} +1 -1
  117. package/dist/safe-bash/command-chunks/{chunk-Z45N42QC.js → chunk-DPAYAVMS.js} +15 -1
  118. package/dist/safe-bash/command-chunks/chunk-DS3NXVUM.js +368 -0
  119. package/dist/safe-bash/command-chunks/{chunk-5ZMZ573Q.js → chunk-DSJ3VRL3.js} +16 -4
  120. package/dist/safe-bash/command-chunks/{chunk-K2GDEMEU.js → chunk-EFRCFWVR.js} +4 -4
  121. package/dist/safe-bash/command-chunks/{chunk-DZCY63VJ.js → chunk-EV6HIJ5H.js} +6 -5
  122. package/dist/safe-bash/command-chunks/{chunk-JDYXY44P.js → chunk-FJURV46Y.js} +3 -3
  123. package/dist/safe-bash/command-chunks/{chunk-TZZ4WUKH.js → chunk-FZAWGKSE.js} +6 -4
  124. package/dist/safe-bash/command-chunks/{chunk-YHFXOX6U.js → chunk-GOCFQ6XV.js} +4 -4
  125. package/dist/safe-bash/command-chunks/{chunk-QVOS4YXL.js → chunk-HH5O7DJI.js} +1 -1
  126. package/dist/safe-bash/command-chunks/{chunk-3HHCU5YU.js → chunk-HK7F5SDC.js} +13 -0
  127. package/dist/safe-bash/command-chunks/{chunk-JNZ3CVAE.js → chunk-HQBXIZC7.js} +8 -3
  128. package/dist/safe-bash/command-chunks/{chunk-V4K2JDYU.js → chunk-I63DBZXZ.js} +2 -2
  129. package/dist/safe-bash/command-chunks/{chunk-WNE7FPVR.js → chunk-I64TLTIW.js} +24 -16
  130. package/dist/safe-bash/command-chunks/{chunk-GFC2NTDG.js → chunk-ICANWOXH.js} +5 -29
  131. package/dist/safe-bash/command-chunks/{chunk-SQRQW3CT.js → chunk-IJ6LGLXM.js} +1 -1
  132. package/dist/safe-bash/command-chunks/{chunk-TGSNCQSR.js → chunk-JT4RYCA6.js} +1771 -1663
  133. package/dist/safe-bash/command-chunks/{chunk-II77KPZN.js → chunk-JWW6FYBN.js} +2 -2
  134. package/dist/safe-bash/command-chunks/{chunk-ZYXH3B66.js → chunk-LCJWKTCJ.js} +250 -203
  135. package/dist/safe-bash/command-chunks/chunk-LU4HBPP2.js +97 -0
  136. package/dist/safe-bash/command-chunks/{chunk-XJXU3VVH.js → chunk-LWOE65OE.js} +20 -5
  137. package/dist/safe-bash/command-chunks/{chunk-GMIHJYDG.js → chunk-M32HFSX7.js} +22 -6
  138. package/dist/safe-bash/command-chunks/{chunk-YG4EPFWC.js → chunk-M3NINRDU.js} +2880 -172
  139. package/dist/safe-bash/command-chunks/chunk-MQREDAL6.js +164 -0
  140. package/dist/safe-bash/command-chunks/{chunk-LWS62ISU.js → chunk-N6DIASO2.js} +1 -1
  141. package/dist/safe-bash/command-chunks/chunk-NGL7YK7O.js +188 -0
  142. package/dist/safe-bash/command-chunks/{chunk-EARHPPPJ.js → chunk-NJYHWKIL.js} +39 -9
  143. package/dist/safe-bash/command-chunks/{chunk-6JSIFWYT.js → chunk-OJQRSCBP.js} +1 -1
  144. package/dist/safe-bash/command-chunks/{chunk-OQU6UT6X.js → chunk-OV3XREFN.js} +11 -0
  145. package/dist/safe-bash/command-chunks/{chunk-MIXBO6U7.js → chunk-PTZLF456.js} +2 -2
  146. package/dist/safe-bash/command-chunks/{chunk-ALDC4XP4.js → chunk-QILLRNES.js} +34 -10
  147. package/dist/safe-bash/command-chunks/{chunk-L22T3H7L.js → chunk-QR25JLKO.js} +1 -1
  148. package/dist/safe-bash/command-chunks/{chunk-NASVPT6F.js → chunk-R7C4MGZ5.js} +17 -224
  149. package/dist/safe-bash/command-chunks/{chunk-LCF3OB7P.js → chunk-RBME3JEH.js} +1 -1
  150. package/dist/safe-bash/command-chunks/{chunk-2KG2QLJE.js → chunk-RFWGYT7G.js} +3 -0
  151. package/dist/safe-bash/command-chunks/{chunk-5TBUOBDE.js → chunk-RZMVRT26.js} +27 -13
  152. package/dist/safe-bash/command-chunks/chunk-TFR6B3WB.js +44 -0
  153. package/dist/safe-bash/command-chunks/chunk-TOH3OF3O.js +179 -0
  154. package/dist/safe-bash/command-chunks/chunk-TT4DAFBT.js +13621 -0
  155. package/dist/safe-bash/command-chunks/{chunk-LWSBAWLT.js → chunk-TXI64OAG.js} +1 -1
  156. package/dist/safe-bash/command-chunks/{chunk-GIRNFXP3.js → chunk-TZRI7BJZ.js} +45 -15
  157. package/dist/safe-bash/command-chunks/{chunk-QOKBZFFD.js → chunk-U3MMODA5.js} +2 -7
  158. package/dist/safe-bash/command-chunks/{chunk-ZYHTWNAE.js → chunk-UAW423ZL.js} +11 -11
  159. package/dist/safe-bash/command-chunks/{chunk-C5YYCQHW.js → chunk-UXEEUGOV.js} +222 -12
  160. package/dist/safe-bash/command-chunks/{chunk-GY3BWK7K.js → chunk-VOZPMJRX.js} +87 -80
  161. package/dist/safe-bash/command-chunks/{chunk-ILX2NOLF.js → chunk-WPANOB4A.js} +20 -20
  162. package/dist/safe-bash/command-chunks/{chunk-Y2WBSJG6.js → chunk-X4QZQI5Q.js} +65 -64
  163. package/dist/safe-bash/command-chunks/{chunk-HDCNKOIX.js → chunk-XGI57GCN.js} +1 -1
  164. package/dist/safe-bash/command-chunks/{chunk-5UBXNSFZ.js → chunk-XUCU7QQT.js} +1281 -1278
  165. package/dist/safe-bash/command-chunks/chunk-Y22VXJBD.js +296 -0
  166. package/dist/safe-bash/command-chunks/{chunk-WVHONVZ4.js → chunk-YMFUUPDX.js} +5 -3
  167. package/dist/safe-bash/command-chunks/{chunk-IR2BY7EL.js → chunk-YYGIBXFZ.js} +2 -2
  168. package/dist/safe-bash/command-chunks/{chunk-MSFXC3OC.js → chunk-Z4FO6OHE.js} +2 -2
  169. package/dist/safe-bash/command-chunks/{chunk-WWIBP2ET.js → chunk-Z5ZZVDUD.js} +143 -22
  170. package/dist/safe-bash/command-chunks/{chunk-LOICUCHG.js → chunk-ZHN3QDCI.js} +1 -1
  171. package/dist/safe-bash/commands/alias/index.d.ts +2 -0
  172. package/dist/safe-bash/commands/alias/index.js +2 -0
  173. package/dist/safe-bash/commands/apply-patch/index.browser.js +2 -3
  174. package/dist/safe-bash/commands/apply-patch/index.d.ts +0 -1
  175. package/dist/safe-bash/commands/apply-patch/index.js +0 -1
  176. package/dist/safe-bash/commands/archive/index.browser.js +2 -3
  177. package/dist/safe-bash/commands/archive/index.d.ts +0 -1
  178. package/dist/safe-bash/commands/archive/index.js +0 -1
  179. package/dist/safe-bash/commands/bytes/index.js +2 -1
  180. package/dist/safe-bash/commands/chmod/index.browser.js +1 -1
  181. package/dist/safe-bash/commands/column/index.browser.js +2 -3
  182. package/dist/safe-bash/commands/column/index.d.ts +0 -1
  183. package/dist/safe-bash/commands/column/index.js +0 -1
  184. package/dist/safe-bash/commands/copy-source.js +1 -0
  185. package/dist/safe-bash/commands/csplit/index.browser.js +2 -2
  186. package/dist/safe-bash/commands/csvkit/index.browser.js +72 -0
  187. package/dist/safe-bash/commands/csvkit/index.d.ts +0 -5
  188. package/dist/safe-bash/commands/csvkit/index.js +0 -50
  189. package/dist/safe-bash/commands/docx/index.browser.js +5 -7
  190. package/dist/safe-bash/commands/du/index.browser.js +2 -3
  191. package/dist/safe-bash/commands/du/index.d.ts +0 -1
  192. package/dist/safe-bash/commands/du/index.js +0 -1
  193. package/dist/safe-bash/commands/expr/index.browser.js +2 -3
  194. package/dist/safe-bash/commands/expr/index.d.ts +0 -1
  195. package/dist/safe-bash/commands/expr/index.js +0 -1
  196. package/dist/safe-bash/commands/factor/index.browser.js +2 -2
  197. package/dist/safe-bash/commands/file/index.browser.js +2 -3
  198. package/dist/safe-bash/commands/file/index.d.ts +0 -1
  199. package/dist/safe-bash/commands/file/index.js +0 -1
  200. package/dist/safe-bash/commands/filesystem.js +1 -1
  201. package/dist/safe-bash/commands/getopt/index.browser.js +2 -2
  202. package/dist/safe-bash/commands/grep-aliases/index.browser.js +3 -3
  203. package/dist/safe-bash/commands/hexdump/index.browser.js +2 -2
  204. package/dist/safe-bash/commands/html-to-markdown/index.browser.js +2 -3
  205. package/dist/safe-bash/commands/html-to-markdown/index.d.ts +0 -1
  206. package/dist/safe-bash/commands/html-to-markdown/index.js +0 -1
  207. package/dist/safe-bash/commands/htmlq/index.d.ts +1 -5
  208. package/dist/safe-bash/commands/htmlq/index.js +1 -143
  209. package/dist/safe-bash/commands/iconv/index.browser.js +2 -2
  210. package/dist/safe-bash/commands/line-endings/index.browser.js +2 -2
  211. package/dist/safe-bash/commands/llm/index.browser.js +2 -2
  212. package/dist/safe-bash/commands/llm/providers/index.browser.js +1 -1
  213. package/dist/safe-bash/commands/mdq/index.browser.js +3 -3
  214. package/dist/safe-bash/commands/media/index.browser.js +4 -16314
  215. package/dist/safe-bash/commands/media/index.d.ts +1 -5
  216. package/dist/safe-bash/commands/media/index.js +1 -3
  217. package/dist/safe-bash/commands/media/plugin.d.ts +1 -18
  218. package/dist/safe-bash/commands/media/plugin.js +1 -90
  219. package/dist/safe-bash/commands/media/remote.d.ts +1 -63
  220. package/dist/safe-bash/commands/media/remote.js +1 -405
  221. package/dist/safe-bash/commands/media/settings.d.ts +1 -4
  222. package/dist/safe-bash/commands/media/settings.js +1 -26
  223. package/dist/safe-bash/commands/metadata/index.browser.js +3 -4
  224. package/dist/safe-bash/commands/metadata/index.d.ts +0 -1
  225. package/dist/safe-bash/commands/metadata/index.js +2 -2
  226. package/dist/safe-bash/commands/mktemp/index.browser.js +1 -1
  227. package/dist/safe-bash/commands/network/curl.js +1 -3
  228. package/dist/safe-bash/commands/network/index.browser.js +3 -4
  229. package/dist/safe-bash/commands/network/public.d.ts +0 -1
  230. package/dist/safe-bash/commands/network/public.js +0 -1
  231. package/dist/safe-bash/commands/network/transport.js +2 -1
  232. package/dist/safe-bash/commands/network/wget.js +1 -3
  233. package/dist/safe-bash/commands/node/browser.d.ts +0 -1
  234. package/dist/safe-bash/commands/node/browser.js +0 -1
  235. package/dist/safe-bash/commands/node/default-runtime.d.ts +3 -0
  236. package/dist/safe-bash/commands/node/default-runtime.js +15 -0
  237. package/dist/safe-bash/commands/node/index.browser.js +7 -8
  238. package/dist/safe-bash/commands/node/index.js +3 -3
  239. package/dist/safe-bash/commands/node/path.js +1 -1
  240. package/dist/safe-bash/commands/node/preload.d.ts +1 -1
  241. package/dist/safe-bash/commands/node/preload.js +4 -1
  242. package/dist/safe-bash/commands/node/quickjs.d.ts +2 -0
  243. package/dist/safe-bash/commands/node/quickjs.js +2 -0
  244. package/dist/safe-bash/commands/node/safejs.js +26 -12
  245. package/dist/safe-bash/commands/op/index.browser.js +2 -3
  246. package/dist/safe-bash/commands/op/index.d.ts +0 -11
  247. package/dist/safe-bash/commands/op/index.js +0 -84
  248. package/dist/safe-bash/commands/pandoc/index.browser.js +44 -0
  249. package/dist/safe-bash/commands/pandoc/index.d.ts +0 -1
  250. package/dist/safe-bash/commands/pandoc/index.js +0 -1
  251. package/dist/safe-bash/commands/pr/index.browser.js +2 -2
  252. package/dist/safe-bash/commands/python/docker-runner.js +4 -3
  253. package/dist/safe-bash/commands/python/docker.d.ts +1 -0
  254. package/dist/safe-bash/commands/python/docker.js +5 -2
  255. package/dist/safe-bash/commands/python/index.browser.js +17 -13
  256. package/dist/safe-bash/commands/python/index.d.ts +2 -1
  257. package/dist/safe-bash/commands/python/index.js +10 -8
  258. package/dist/safe-bash/commands/python/llm-capability.js +65 -2
  259. package/dist/safe-bash/commands/python/llm-dependencies.d.ts +27 -0
  260. package/dist/safe-bash/commands/python/llm-dependencies.js +66 -0
  261. package/dist/safe-bash/commands/python/llm-module.js +6 -4
  262. package/dist/safe-bash/commands/python/llm-reference-module.d.ts +3 -0
  263. package/dist/safe-bash/commands/python/llm-reference-module.js +690 -0
  264. package/dist/safe-bash/commands/python/worker.browser.js +2 -3
  265. package/dist/safe-bash/commands/python/worker.d.ts +0 -1
  266. package/dist/safe-bash/commands/python/worker.js +0 -1
  267. package/dist/safe-bash/commands/regex-execution/ere/transport/wire-engine.d.ts +1 -1
  268. package/dist/safe-bash/commands/regex-execution/ere/transport/wire-engine.js +3 -3
  269. package/dist/safe-bash/commands/regex-execution/public.browser.js +7 -7
  270. package/dist/safe-bash/commands/safejs/options.js +5 -1
  271. package/dist/safe-bash/commands/safejs/runtime.d.ts +1 -0
  272. package/dist/safe-bash/commands/safejs/runtime.js +1 -1
  273. package/dist/safe-bash/commands/split/index.browser.js +2 -3
  274. package/dist/safe-bash/commands/split/index.d.ts +0 -1
  275. package/dist/safe-bash/commands/split/index.js +0 -1
  276. package/dist/safe-bash/commands/ssconvert/index.browser.js +98 -0
  277. package/dist/safe-bash/commands/stat/index.browser.js +1 -1
  278. package/dist/safe-bash/commands/stream-format/index.browser.js +3 -4
  279. package/dist/safe-bash/commands/stream-format/index.d.ts +0 -1
  280. package/dist/safe-bash/commands/stream-format/index.js +0 -1
  281. package/dist/safe-bash/commands/stream-inspection/index.browser.js +3 -4
  282. package/dist/safe-bash/commands/stream-inspection/index.d.ts +0 -1
  283. package/dist/safe-bash/commands/stream-inspection/index.js +0 -1
  284. package/dist/safe-bash/commands/streams.js +2 -1
  285. package/dist/safe-bash/commands/table-text/index.browser.js +3 -4
  286. package/dist/safe-bash/commands/table-text/index.d.ts +0 -1
  287. package/dist/safe-bash/commands/table-text/index.js +0 -1
  288. package/dist/safe-bash/commands/text.js +28 -24
  289. package/dist/safe-bash/commands/time-env/index.browser.js +3 -4
  290. package/dist/safe-bash/commands/time-env/index.d.ts +0 -1
  291. package/dist/safe-bash/commands/time-env/index.js +0 -1
  292. package/dist/safe-bash/commands/tree/index.browser.js +2 -3
  293. package/dist/safe-bash/commands/tree/index.d.ts +0 -1
  294. package/dist/safe-bash/commands/tree/index.js +0 -1
  295. package/dist/safe-bash/commands/tsort/index.browser.js +2 -2
  296. package/dist/safe-bash/commands/unalias/index.d.ts +2 -0
  297. package/dist/safe-bash/commands/unalias/index.js +2 -0
  298. package/dist/safe-bash/commands/xml/index.browser.js +2 -2
  299. package/dist/safe-bash/commands/yq/index.browser.js +2 -2
  300. package/dist/safe-bash/core.browser.js +2 -2
  301. package/dist/safe-bash/core.d.ts +7 -1
  302. package/dist/safe-bash/core.js +7 -1
  303. package/dist/safe-bash/execution-runtime.js +2 -1
  304. package/dist/safe-bash/fs/s3/http/index.d.ts +2 -2
  305. package/dist/safe-bash/fs/s3/http/index.js +1 -1
  306. package/dist/safe-bash/full-core.browser.js +283 -945
  307. package/dist/safe-bash/internal/op/types.d.ts +1 -0
  308. package/dist/safe-bash/jobs.browser.js +5 -5
  309. package/dist/safe-bash/lazy-optional.d.ts +3 -3
  310. package/dist/safe-bash/lazy-optional.js +1 -1
  311. package/dist/safe-bash/opt-in/commands/cmp/index.js +7 -6
  312. package/dist/safe-bash/opt-in/commands/dd/index.js +1 -1
  313. package/dist/safe-bash/opt-in/commands/dd/io.js +51 -5
  314. package/dist/safe-bash/opt-in/commands/truncate/index.js +2 -2
  315. package/dist/safe-bash/opt-in/commands/yq/native-work.js +2 -0
  316. package/dist/safe-bash/opt-in/optional/commands/shuf/input.js +2 -1
  317. package/dist/safe-bash/opt-in/optional/commands/shuf/shuf.js +4 -2
  318. package/dist/safe-bash/opt-in/optional.d.ts +1 -1
  319. package/dist/safe-bash/opt-in/optional.js +1 -1
  320. package/dist/safe-bash/opt-in/shell/extensions/read/index.js +2 -344
  321. package/dist/safe-bash/optional-host.browser.js +23 -18
  322. package/dist/safe-bash/optional-host.d.ts +1 -0
  323. package/dist/safe-bash/optional-host.js +1 -0
  324. package/dist/safe-bash/playwright/controller.js +41 -3
  325. package/dist/safe-bash/playwright/native-storage-targets.js +4 -2
  326. package/dist/safe-bash/plugins/base.d.ts +1 -1
  327. package/dist/safe-bash/plugins/base.js +3 -3
  328. package/dist/safe-bash/plugins/composition.d.ts +5 -2
  329. package/dist/safe-bash/plugins/composition.js +10 -7
  330. package/dist/safe-bash/plugins/index.browser.js +44 -41
  331. package/dist/safe-bash/plugins/index.js +3 -2
  332. package/dist/safe-bash/plugins/portable-commands.d.ts +3 -0
  333. package/dist/safe-bash/plugins/portable-commands.js +31 -0
  334. package/dist/safe-bash/registry-entry.browser.js +41 -42
  335. package/dist/safe-bash/search.browser.js +32 -33
  336. package/dist/safe-bash/shell/arithmetic.js +19 -6
  337. package/dist/safe-bash/shell/arrays/state.js +1 -1
  338. package/dist/safe-bash/shell/arrays/syntax.js +4 -3
  339. package/dist/safe-bash/shell/index.d.ts +0 -1
  340. package/dist/safe-bash/shell/index.js +0 -1
  341. package/dist/safe-bash/shell/parser.d.ts +2 -2
  342. package/dist/safe-bash/shell/parser.js +268 -64
  343. package/dist/safe-bash/shell/read-builtin.d.ts +3 -0
  344. package/dist/safe-bash/shell/read-builtin.js +344 -0
  345. package/dist/safe-bash/shell/runtime.d.ts +21 -4
  346. package/dist/safe-bash/shell/runtime.js +373 -412
  347. package/dist/safe-bash/shell/session-state.js +25 -0
  348. package/dist/safe-bash/shell/shell.js +76 -154
  349. package/dist/safe-bash/shell/tilde-expansion.d.ts +1 -1
  350. package/dist/safe-bash/shell/tilde-expansion.js +2 -2
  351. package/dist/safe-bash/shell/types.d.ts +5 -0
  352. package/dist/safe-bash/shell/value-state.js +1 -1
  353. package/dist/safe-bash/shell-entry.browser.js +32 -33
  354. package/dist/safe-bash/trap.browser.js +4 -4
  355. package/dist/safe-bash/yq-browser/index.js +1 -1
  356. package/dist/safe-bash-calendar-engine/time-env/calendar.d.ts +1 -1
  357. package/dist/safe-bash-calendar-engine/time-env/calendar.js +1 -1
  358. package/dist/safe-bash-calendar-engine/time-env/format.js +1 -1
  359. package/dist/safe-bash-command-alias/index.d.ts +13 -0
  360. package/dist/safe-bash-command-alias/index.js +88 -0
  361. package/dist/safe-bash-command-apply-patch/apply.js +3 -3
  362. package/dist/safe-bash-command-apply-patch/index.js +3 -3
  363. package/dist/safe-bash-command-apply-patch/matcher.js +1 -1
  364. package/dist/safe-bash-command-apply-patch/parser.js +1 -1
  365. package/dist/safe-bash-command-awk/awk-pipes.js +2 -2
  366. package/dist/safe-bash-command-awk/awk-reader.js +1 -1
  367. package/dist/safe-bash-command-awk/awk-runtime.js +3 -3
  368. package/dist/safe-bash-command-awk/awk.js +5 -5
  369. package/dist/safe-bash-command-awk/index.js +5 -5
  370. package/dist/safe-bash-command-bc/index.js +206 -60
  371. package/dist/safe-bash-command-cmp/index.js +7 -6
  372. package/dist/safe-bash-command-column/column.js +3 -3
  373. package/dist/safe-bash-command-column/index.js +3 -3
  374. package/dist/safe-bash-command-column/layout.js +2 -2
  375. package/dist/safe-bash-command-csvkit/index.d.ts +1 -0
  376. package/dist/safe-bash-command-csvkit/index.js +1505 -7
  377. package/dist/safe-bash-command-csvkit/sync-support.js +2 -7
  378. package/dist/safe-bash-command-curl/curl.js +1 -1
  379. package/dist/safe-bash-command-curl/index.js +1 -1
  380. package/dist/safe-bash-command-date/date.js +1 -1
  381. package/dist/safe-bash-command-date/index.js +1 -1
  382. package/dist/safe-bash-command-dd/index.js +1 -1
  383. package/dist/safe-bash-command-dd/io.js +51 -5
  384. package/dist/safe-bash-command-diff/diff.js +1 -1
  385. package/dist/safe-bash-command-diff/index.js +1 -1
  386. package/dist/safe-bash-command-diff3/index.js +10 -13
  387. package/dist/safe-bash-command-exiftool/index.js +278 -50
  388. package/dist/safe-bash-command-exiftool/registry.d.ts +4 -2
  389. package/dist/safe-bash-command-factor/command.js +2 -2
  390. package/dist/safe-bash-command-factor/index.js +2 -2
  391. package/dist/safe-bash-command-fd/arguments.d.ts +2 -0
  392. package/dist/safe-bash-command-fd/index.js +42 -12
  393. package/dist/safe-bash-command-ffmpeg/index.js +356 -66
  394. package/dist/safe-bash-command-find/find-format.d.ts +3 -0
  395. package/dist/safe-bash-command-find/find-format.js +1 -1
  396. package/dist/safe-bash-command-find/find.js +2 -2
  397. package/dist/safe-bash-command-find/index.js +2 -2
  398. package/dist/safe-bash-command-fmt/index.js +1 -4
  399. package/dist/safe-bash-command-fold/engine.d.ts +1 -1
  400. package/dist/safe-bash-command-fold/family.js +2 -2
  401. package/dist/safe-bash-command-fold/index.js +1 -1
  402. package/dist/safe-bash-command-hexdump/command.js +2 -2
  403. package/dist/safe-bash-command-hexdump/index.js +2 -2
  404. package/dist/safe-bash-command-html-to-markdown/entities.js +1 -1
  405. package/dist/safe-bash-command-html-to-markdown/index.js +4 -4
  406. package/dist/safe-bash-command-html-to-markdown/input.js +3 -3
  407. package/dist/safe-bash-command-html-to-markdown/parser.js +2 -2
  408. package/dist/safe-bash-command-html-to-markdown/render.js +3 -3
  409. package/dist/safe-bash-command-htmlq/contracts.d.ts +5 -2
  410. package/dist/safe-bash-command-htmlq/index.d.ts +2 -1
  411. package/dist/safe-bash-command-htmlq/index.js +175 -49
  412. package/dist/safe-bash-command-htmlq/sync.d.ts +1 -0
  413. package/dist/safe-bash-command-imagemagick/index.js +56 -6
  414. package/dist/safe-bash-command-install/arguments.d.ts +27 -0
  415. package/dist/safe-bash-command-install/arguments.js +224 -0
  416. package/dist/safe-bash-command-install/index.d.ts +7 -0
  417. package/dist/safe-bash-command-install/index.js +942 -0
  418. package/dist/safe-bash-command-install/mode.d.ts +6 -0
  419. package/dist/safe-bash-command-install/mode.js +71 -0
  420. package/dist/safe-bash-command-install/options.d.ts +40 -0
  421. package/dist/safe-bash-command-install/options.js +27 -0
  422. package/dist/safe-bash-command-jq/index.js +1 -1
  423. package/dist/safe-bash-command-jq/jq.js +1 -1
  424. package/dist/safe-bash-command-less/index.js +37 -61
  425. package/dist/safe-bash-command-llm/command.js +1 -1
  426. package/dist/safe-bash-command-llm/elevenlabs.js +2 -2
  427. package/dist/safe-bash-command-llm/index.js +4 -4
  428. package/dist/safe-bash-command-llm/openai.js +2 -2
  429. package/dist/safe-bash-command-llm/providers/elevenlabs.js +2 -2
  430. package/dist/safe-bash-command-llm/providers/index.js +3 -3
  431. package/dist/safe-bash-command-llm/providers/openai.js +2 -2
  432. package/dist/safe-bash-command-llm/providers/shared.js +1 -1
  433. package/dist/{safe-bash-mcp → safe-bash-command-mcp}/index.browser.d.ts +463 -46
  434. package/dist/safe-bash-command-mcp/index.browser.js +19308 -0
  435. package/dist/{safe-bash-mcp → safe-bash-command-mcp}/index.d.ts +15 -6
  436. package/dist/{safe-bash-mcp → safe-bash-command-mcp}/index.js +2804 -2771
  437. package/dist/safe-bash-command-media/LICENSE +21 -0
  438. package/dist/safe-bash-command-media/index.d.ts +6 -0
  439. package/dist/safe-bash-command-media/index.js +30 -0
  440. package/dist/safe-bash-command-media/plugin.d.ts +18 -0
  441. package/dist/safe-bash-command-media/plugin.js +11 -0
  442. package/dist/safe-bash-command-media/remote.d.ts +63 -0
  443. package/dist/safe-bash-command-media/remote.js +11 -0
  444. package/dist/safe-bash-command-media/settings.d.ts +4 -0
  445. package/dist/safe-bash-command-media/settings.js +41 -0
  446. package/dist/safe-bash-command-mktemp/command.js +1 -1
  447. package/dist/safe-bash-command-mktemp/index.js +1 -1
  448. package/dist/safe-bash-command-mmdc/arguments.d.ts +1 -0
  449. package/dist/safe-bash-command-mmdc/command.d.ts +2 -0
  450. package/dist/safe-bash-command-mmdc/contracts.d.ts +8 -1
  451. package/dist/safe-bash-command-mmdc/index.js +359 -7
  452. package/dist/safe-bash-command-nl/index.js +1 -1
  453. package/dist/safe-bash-command-nl/nl.js +1 -1
  454. package/dist/safe-bash-command-node/LICENSE +21 -0
  455. package/dist/safe-bash-command-node/index.d.ts +17 -0
  456. package/dist/safe-bash-command-node/index.js +328 -0
  457. package/dist/safe-bash-command-numfmt/index.js +1 -0
  458. package/dist/safe-bash-command-od/index.js +10 -6
  459. package/dist/safe-bash-command-op/index.js +39 -32
  460. package/dist/safe-bash-command-op/types.d.ts +1 -0
  461. package/dist/safe-bash-command-pandoc/command.js +3 -3
  462. package/dist/safe-bash-command-pandoc/index.d.ts +1 -0
  463. package/dist/safe-bash-command-pandoc/index.js +5 -3
  464. package/dist/safe-bash-command-pandoc/sync.d.ts +1 -0
  465. package/dist/safe-bash-command-patch/index.js +4 -4
  466. package/dist/safe-bash-command-patch/patch.js +4 -4
  467. package/dist/safe-bash-command-pdfimages/index.js +1 -1
  468. package/dist/safe-bash-command-pdfinfo/index.js +30 -5
  469. package/dist/safe-bash-command-pdftk/index.js +21 -23
  470. package/dist/safe-bash-command-pdftoppm/index.js +17 -4
  471. package/dist/safe-bash-command-pdftotext/index.js +11 -14
  472. package/dist/safe-bash-command-qpdf/index.d.ts +1 -0
  473. package/dist/safe-bash-command-qpdf/index.js +9 -6
  474. package/dist/safe-bash-command-rg/index.js +1 -1
  475. package/dist/safe-bash-command-rg/rg-command.js +1 -1
  476. package/dist/safe-bash-command-sed/index.js +1 -1
  477. package/dist/safe-bash-command-sed/sed.js +1 -1
  478. package/dist/safe-bash-command-shuf/input.d.ts +2 -2
  479. package/dist/safe-bash-command-shuf/input.js +2 -1
  480. package/dist/safe-bash-command-shuf/shuf.js +4 -2
  481. package/dist/safe-bash-command-sips/index.js +2 -2
  482. package/dist/safe-bash-command-soffice/index.js +97 -12
  483. package/dist/safe-bash-command-sponge/index.js +4 -1
  484. package/dist/safe-bash-command-sqlite3/engine.d.ts +1 -0
  485. package/dist/safe-bash-command-sqlite3/index.js +510 -70
  486. package/dist/safe-bash-command-ssconvert/formats/xlsx.js +2 -2
  487. package/dist/safe-bash-command-ssconvert/index.js +44 -22
  488. package/dist/safe-bash-command-stat/command.js +1 -1
  489. package/dist/safe-bash-command-stat/index.js +1 -1
  490. package/dist/safe-bash-command-tar/create.d.ts +1 -0
  491. package/dist/safe-bash-command-tar/create.js +2 -2
  492. package/dist/safe-bash-command-tar/extract.js +2 -2
  493. package/dist/safe-bash-command-tar/index.js +4 -4
  494. package/dist/safe-bash-command-tar/modes.js +4 -4
  495. package/dist/safe-bash-command-tar/options.js +1 -1
  496. package/dist/safe-bash-command-truncate/index.js +2 -2
  497. package/dist/safe-bash-command-tsort/command.js +2 -2
  498. package/dist/safe-bash-command-tsort/index.js +2 -2
  499. package/dist/safe-bash-command-unalias/index.d.ts +12 -0
  500. package/dist/safe-bash-command-unalias/index.js +67 -0
  501. package/dist/safe-bash-command-unrtf/index.js +26 -4
  502. package/dist/safe-bash-command-xan/argv.d.ts +1 -1
  503. package/dist/safe-bash-command-xan/argv.js +2 -2
  504. package/dist/safe-bash-command-xan/budget.d.ts +0 -1
  505. package/dist/safe-bash-command-xan/budget.js +1 -1
  506. package/dist/safe-bash-command-xan/commands.js +6 -6
  507. package/dist/safe-bash-command-xan/csv.js +2 -2
  508. package/dist/safe-bash-command-xan/index.js +8 -9
  509. package/dist/safe-bash-command-xan/io.js +4 -4
  510. package/dist/safe-bash-command-xan/options.js +1 -1
  511. package/dist/safe-bash-command-xan/selector.js +2 -2
  512. package/dist/safe-bash-command-xmllint/index.js +45 -23
  513. package/dist/safe-bash-command-xxd/index.js +41 -10
  514. package/dist/safe-bash-command-yq/accounting.js +1 -1
  515. package/dist/safe-bash-command-yq/index.js +3 -2
  516. package/dist/safe-bash-command-yq/native-work.js +2 -0
  517. package/dist/safe-bash-command-yq/parser.js +2 -2
  518. package/dist/safe-bash-command-yq/query.js +5 -5
  519. package/dist/safe-bash-command-yq/toml.js +2 -2
  520. package/dist/safe-bash-command-zip/index.js +3 -3
  521. package/dist/safe-bash-compression-engine/bounded-codec.js +2 -2
  522. package/dist/safe-bash-compression-engine/codec-loader.js +1 -1
  523. package/dist/safe-bash-compression-engine/files.js +5 -5
  524. package/dist/safe-bash-compression-engine/index.js +4 -4
  525. package/dist/safe-bash-compression-engine/operand.js +5 -5
  526. package/dist/safe-bash-compression-engine/stream.js +4 -4
  527. package/dist/safe-bash-compression-engine/zstd-decode.js +3 -3
  528. package/dist/safe-bash-contracts/command.js +3 -3
  529. package/dist/safe-bash-contracts/default-executor.js +2 -2
  530. package/dist/safe-bash-contracts/diagnostics.js +3 -3
  531. package/dist/safe-bash-contracts/escaping.js +6 -6
  532. package/dist/safe-bash-contracts/filesystem-descriptor.js +3 -3
  533. package/dist/safe-bash-contracts/filesystem-output.js +5 -5
  534. package/dist/safe-bash-contracts/http.d.ts +7 -0
  535. package/dist/safe-bash-contracts/index.js +8 -8
  536. package/dist/safe-bash-contracts/io.js +2 -2
  537. package/dist/safe-bash-contracts/output.js +3 -3
  538. package/dist/safe-bash-contracts/runtime-control.d.ts +2 -2
  539. package/dist/safe-bash-contracts/runtime-control.js +4 -2
  540. package/dist/safe-bash-contracts/signals.d.ts +2 -0
  541. package/dist/safe-bash-contracts/signals.js +3 -1
  542. package/dist/safe-bash-contracts/yield.js +1 -1
  543. package/dist/safe-bash-csv-engine/index.d.ts +2 -1
  544. package/dist/safe-bash-csv-engine/index.js +21 -15
  545. package/dist/safe-bash-io-engine/commands/search/requirements.js +2 -2
  546. package/dist/safe-bash-io-engine/commands/text-programs/shared.js +6 -6
  547. package/dist/safe-bash-io-engine/internal.js +1 -1
  548. package/dist/safe-bash-io-engine/shell/pattern.js +38 -18
  549. package/dist/safe-bash-line-ending-engine/convert.js +9 -204
  550. package/dist/safe-bash-line-ending-engine/encoding.js +9 -42
  551. package/dist/safe-bash-line-ending-engine/index.js +48 -0
  552. package/dist/safe-bash-line-ending-engine/info.js +9 -90
  553. package/dist/safe-bash-line-ending-engine/internal.js +15 -160
  554. package/dist/safe-bash-line-ending-engine/io.js +12 -289
  555. package/dist/safe-bash-line-ending-engine/stage.js +10 -160
  556. package/dist/safe-bash-markdown-engine/index.js +3 -3
  557. package/dist/safe-bash-network-engine/args.d.ts +6 -0
  558. package/dist/safe-bash-network-engine/args.js +4 -2
  559. package/dist/safe-bash-network-engine/body.js +1 -1
  560. package/dist/safe-bash-network-engine/fetch-transport.js +3 -1
  561. package/dist/safe-bash-network-engine/index.js +3 -1
  562. package/dist/safe-bash-network-engine/input.js +2 -2
  563. package/dist/safe-bash-network-engine/platform-portable.js +3 -1
  564. package/dist/safe-bash-query-engine/dates.d.ts +1 -1
  565. package/dist/safe-bash-query-engine/dates.js +1 -1
  566. package/dist/safe-bash-query-engine/index.js +6 -6
  567. package/dist/safe-bash-query-engine/interpreter.js +4 -4
  568. package/dist/safe-bash-query-engine/parser.js +1 -1
  569. package/dist/safe-bash-query-engine/query-core.js +6 -6
  570. package/dist/safe-bash-regex-engine/execution/bounded-provider.js +10 -0
  571. package/dist/safe-bash-regex-engine/index.js +1 -1
  572. package/dist/safe-bash-regex-engine/text/regex.d.ts +1 -1
  573. package/dist/safe-bash-regex-engine/text/regex.js +1 -1
  574. package/dist/safe-bash-search-engine/ergonomic-regex.d.ts +1 -0
  575. package/dist/safe-bash-search-engine/ergonomic-regex.js +1 -1
  576. package/dist/safe-bash-search-engine/grep.js +16 -9
  577. package/dist/safe-bash-search-engine/matcher.d.ts +2 -2
  578. package/dist/safe-bash-search-engine/matcher.js +12 -8
  579. package/dist/safe-bash-search-engine/shared.js +1 -1
  580. package/dist/safe-bash-search-engine/walk.js +13 -1
  581. package/dist/safe-bash-text-stream-engine/stream-format/shared.d.ts +1 -1
  582. package/dist/safe-bash-text-stream-engine/stream-format/shared.js +2 -1
  583. package/dist/safe-bash-xml-engine/document.js +3 -3
  584. package/dist/safe-bash-xml-engine/evaluate.js +2 -2
  585. package/dist/safe-bash-xml-engine/index.js +4 -4
  586. package/dist/safe-bash-xml-engine/io.js +7 -2
  587. package/dist/safe-bash-xml-engine/limits.d.ts +0 -2
  588. package/dist/safe-bash-xml-engine/limits.js +1 -1
  589. package/dist/safe-bash-xml-engine/query.js +3 -3
  590. package/dist/safe-bash-zip-engine/index.js +3 -3
  591. package/dist/safe-bash-zip-engine/zip/repair.js +3 -3
  592. package/dist/safe-bash-zip-engine/zip/safety.js +1 -1
  593. package/dist/safe-bash-zip-engine/zip/sfx.js +3 -3
  594. package/dist/safe-bash-zip-engine/zip/volumes.js +1 -1
  595. package/dist/safe-bash-zip-engine/zip-format.js +3 -3
  596. package/dist/safe-playwright-cloudflare/browser-socket-closure.js +18 -3
  597. package/dist/safe-playwright-cloudflare/shell-browser-resource.js +1 -1
  598. package/dist/xlsx-ast/xlsx.js +6 -5
  599. package/package.json +86 -98
  600. package/dist/media-cli/bytes.d.ts +0 -8
  601. package/dist/media-cli/bytes.js +0 -40
  602. package/dist/media-cli/concat.d.ts +0 -30
  603. package/dist/media-cli/concat.js +0 -197
  604. package/dist/media-cli/content.js +0 -66
  605. package/dist/media-cli/dependency-grammars.d.ts +0 -12
  606. package/dist/media-cli/dependency-grammars.js +0 -557
  607. package/dist/media-cli/discover.js +0 -286
  608. package/dist/media-cli/engine.js +0 -190
  609. package/dist/media-cli/filename-expression.js +0 -147
  610. package/dist/media-cli/filesystem.js +0 -35
  611. package/dist/media-cli/frontend-contract.js +0 -8
  612. package/dist/media-cli/frontend-issues.d.ts +0 -6
  613. package/dist/media-cli/frontend-issues.js +0 -9
  614. package/dist/media-cli/imagemagick-operand.d.ts +0 -42
  615. package/dist/media-cli/imagemagick-operand.js +0 -229
  616. package/dist/media-cli/imagemagick-references.d.ts +0 -7
  617. package/dist/media-cli/imagemagick-references.js +0 -42
  618. package/dist/media-cli/imagemagick.generated.js +0 -3254
  619. package/dist/media-cli/imagemagick.js +0 -615
  620. package/dist/media-cli/index.js +0 -12
  621. package/dist/media-cli/mvg.d.ts +0 -10
  622. package/dist/media-cli/mvg.js +0 -102
  623. package/dist/media-cli/network.js +0 -78
  624. package/dist/media-cli/options.generated.js +0 -3312
  625. package/dist/media-cli/preset.d.ts +0 -11
  626. package/dist/media-cli/preset.js +0 -57
  627. package/dist/media-cli/resolution-path.d.ts +0 -23
  628. package/dist/media-cli/resolution-path.js +0 -217
  629. package/dist/media-cli/resolver.js +0 -494
  630. package/dist/media-cli/resources.d.ts +0 -16
  631. package/dist/media-cli/resources.js +0 -187
  632. package/dist/media-cli/shim.js +0 -52
  633. package/dist/media-cli/tee.d.ts +0 -6
  634. package/dist/media-cli/tee.js +0 -38
  635. package/dist/office-package/zip-sync.js +0 -111
  636. package/dist/remote-execution/binary.js +0 -178
  637. package/dist/remote-execution/callback-result.js +0 -26
  638. package/dist/remote-execution/canonical-capabilities.d.ts +0 -5
  639. package/dist/remote-execution/canonical-capabilities.js +0 -45
  640. package/dist/remote-execution/canonical-metadata.d.ts +0 -4
  641. package/dist/remote-execution/canonical-metadata.js +0 -32
  642. package/dist/remote-execution/client.js +0 -824
  643. package/dist/remote-execution/deployment.js +0 -131
  644. package/dist/remote-execution/descriptors.js +0 -267
  645. package/dist/remote-execution/effects.js +0 -357
  646. package/dist/remote-execution/endpoint.js +0 -224
  647. package/dist/remote-execution/files.js +0 -291
  648. package/dist/remote-execution/hosting-operation.js +0 -26
  649. package/dist/remote-execution/hosting-request.d.ts +0 -4
  650. package/dist/remote-execution/hosting-request.js +0 -12
  651. package/dist/remote-execution/hosting-stream.d.ts +0 -8
  652. package/dist/remote-execution/hosting-stream.js +0 -64
  653. package/dist/remote-execution/index.js +0 -18
  654. package/dist/remote-execution/invocation-admission.d.ts +0 -3
  655. package/dist/remote-execution/invocation-admission.js +0 -17
  656. package/dist/remote-execution/job-binding.js +0 -1269
  657. package/dist/remote-execution/materializations.js +0 -284
  658. package/dist/remote-execution/modal-driver.js +0 -90
  659. package/dist/remote-execution/native-result.d.ts +0 -3
  660. package/dist/remote-execution/native-result.js +0 -16
  661. package/dist/remote-execution/output-freshness.d.ts +0 -4
  662. package/dist/remote-execution/output-freshness.js +0 -19
  663. package/dist/remote-execution/output-retrieval.js +0 -474
  664. package/dist/remote-execution/process-http.js +0 -607
  665. package/dist/remote-execution/process.js +0 -577
  666. package/dist/remote-execution/protocol.js +0 -208
  667. package/dist/remote-execution/relay.js +0 -91
  668. package/dist/remote-execution/rest-driver.js +0 -93
  669. package/dist/remote-execution/upload-descriptor.js +0 -201
  670. package/dist/remote-execution/upload-protocol.js +0 -62
  671. package/dist/remote-execution/uploads.js +0 -324
  672. package/dist/remote-execution/wire-json.d.ts +0 -4
  673. package/dist/remote-execution/wire-json.js +0 -44
  674. package/dist/remote-execution/wire-validation.js +0 -131
  675. package/dist/remote-execution/wire.generated.js +0 -4224
  676. package/dist/safe-bash/chunks/chunk-GDYNCWRV.js +0 -161
  677. package/dist/safe-bash/chunks/chunk-IWDICZVK.js +0 -20
  678. package/dist/safe-bash/chunks/chunk-MHMMRCYC.js +0 -3464
  679. package/dist/safe-bash/chunks/chunk-UE5KZDEK.js +0 -77
  680. package/dist/safe-bash/chunks/csvkit-TACDU7FC.js +0 -1618
  681. package/dist/safe-bash/chunks/implementation-MLFHUQ5M.js +0 -133
  682. package/dist/safe-bash/commands/csvkit/sync.js +0 -1639
  683. package/dist/safe-bash/commands/node/unconfigured.d.ts +0 -3
  684. package/dist/safe-bash/commands/node/unconfigured.js +0 -10
  685. package/dist/safe-bash/commands/pandoc/implementation.d.ts +0 -8
  686. package/dist/safe-bash/commands/pandoc/implementation.js +0 -94
  687. package/dist/safe-bash-mcp/index.browser.js +0 -9167
  688. package/dist/safe-bash/command-chunks/{chunk-ZRRBXU3M.js → chunk-GIN5GUDP.js} +4 -4
  689. package/dist/safe-bash/command-chunks/{chunk-LAOM65EE.js → chunk-IEO4XVN6.js} +3 -3
  690. package/dist/safe-bash/command-chunks/{chunk-BXCXRYVU.js → chunk-JNANXVJV.js} +0 -0
  691. package/dist/safe-bash/command-chunks/{chunk-364TMWBT.js → chunk-MWREVL44.js} +6 -6
  692. package/dist/safe-bash/command-chunks/{chunk-464RVBGB.js → chunk-Q5TDKFHK.js} +3 -3
  693. package/dist/safe-bash/command-chunks/{chunk-AJR3AQYA.js → chunk-UKX3LZHR.js} +0 -0
  694. package/dist/safe-bash/command-chunks/{chunk-XIIBTGC5.js → chunk-XPXEQKRW.js} +9 -9
  695. package/dist/safe-bash/command-chunks/{chunk-FDBUV4HJ.js → chunk-Y4HGTG3E.js} +3 -3
  696. /package/dist/{safe-bash/commands/csvkit → safe-bash-command-csvkit}/sync.d.ts +0 -0
@@ -28,6 +28,8 @@ import { MemoryFileSystem, isCleanAbsolutePath, retargetScopedFileSystem, scopeF
28
28
  import { collectPureReadOnlySmiNames, compilePureSmiProgram, evaluateArithmetic, evaluateArithmeticReferences, evaluateArithmeticSync, evaluateArithmeticSyncNonZero, evaluateArithmeticSyncString, fastSafeInt, intToStr, isSafeSmiProgram, prepareArithmetic, runIntArithForLoop, runIntForLoop, sharedLoopIntRegs } from "./arithmetic.js";
29
29
  import { ParseBudget } from "./parse-budget.js";
30
30
  import { BraceExpansionFailure, expandBraces, tryFastExpandBraceRange } from "./brace-expansion.js";
31
+ import { createAliasCommand } from "../../safe-bash-command-alias/index.js";
32
+ import { createUnaliasCommand } from "../../safe-bash-command-unalias/index.js";
31
33
  import { expandTildes } from "./tilde-expansion.js";
32
34
  import { evaluatePositionalArithmetic } from "./arithmetic-parameters.js";
33
35
  import { compilePattern, compilePatternBoundaries, matchesPattern, tryMatchesPatternSync } from "./pattern.js";
@@ -178,7 +180,7 @@ export const defaultLimits = {
178
180
  pipeHighWaterMark: 64 * 1024,
179
181
  };
180
182
  const shellBuiltinNames = new Set([
181
- ":", "true", "false", "pwd", "cd", "set", "shift", "export", "local", "unset", "read", "declare", "typeset", "mapfile", "readarray", "umask", "exit", "return", "break", "continue", "command", "builtin", "type", "readonly", "echo", "printf", "test", "[", ".", "source", "eval", "getopts", "let", "pushd", "dirs", "popd", "shopt", "hash",
183
+ ":", "true", "false", "pwd", "cd", "set", "shift", "export", "local", "unset", "read", "declare", "typeset", "mapfile", "readarray", "umask", "exit", "return", "break", "continue", "command", "builtin", "type", "readonly", "echo", "printf", "test", "[", ".", "source", "eval", "exec", "getopts", "let", "pushd", "dirs", "popd", "shopt", "hash", "alias", "unalias",
182
184
  ]);
183
185
  const implementedBuiltins = new Set([...shellBuiltinNames].filter(name => !["echo", "printf", "test", "["].includes(name)));
184
186
  const extensionExitFailures = new WeakMap();
@@ -229,9 +231,10 @@ function publishCommandSpelling(state, description) {
229
231
  (monitor?.raw ?? state).variables.BASH_COMMAND = description;
230
232
  }
231
233
  export function resolveLimits(...limits) {
232
- const result = Object.assign({}, defaultLimits, ...limits);
234
+ const definedLimits = limits.map(layer => Object.fromEntries(Object.entries(layer ?? {}).filter(([, value]) => value !== undefined)));
235
+ const result = Object.assign({}, defaultLimits, ...definedLimits);
233
236
  const commandLimits = resolveCommandLimits(...limits.map(value => value?.commandLimits));
234
- for (const [key, value] of Object.entries(Object.assign({}, ...limits))) {
237
+ for (const [key, value] of Object.entries(Object.assign({}, ...definedLimits))) {
235
238
  if (key === "commandLimits")
236
239
  continue;
237
240
  if ((value !== Infinity || key === "pipeHighWaterMark") && (!Number.isSafeInteger(value) || value < (key === "pipeHighWaterMark" ? 1 : 0))) {
@@ -590,6 +593,8 @@ export class Budget {
590
593
  return this._wallClockDeadline;
591
594
  }
592
595
  close() {
596
+ if (this._hasExternalSignal)
597
+ releaseCombinedSignal(this.signal);
593
598
  const timer = this._wallClockTimer;
594
599
  if (timer === undefined)
595
600
  return;
@@ -1001,7 +1006,7 @@ export class Capture {
1001
1006
  if (same)
1002
1007
  return cachedCaptureAsciiStr;
1003
1008
  }
1004
- const decoded = typeof globalThis.Buffer === "function" ? globalThis.Buffer.prototype.utf8Slice.call(buf, 0, len) : sharedCaptureDecoder.decode(buf.subarray(0, len));
1009
+ const decoded = sharedCaptureDecoder.decode(buf.subarray(0, len));
1005
1010
  if (len <= 4096) {
1006
1011
  for (let i = 0; i < len; i++)
1007
1012
  cachedCaptureAsciiBytes[i] = buf[i];
@@ -1032,6 +1037,17 @@ const invokedValues = new WeakMap();
1032
1037
  const functionDiagnostics = new WeakMap();
1033
1038
  const childIdentities = new WeakMap();
1034
1039
  const declarationArrays = Symbol("declarationArrays");
1040
+ const execDescriptorFrames = new WeakMap();
1041
+ async function closeExecDescriptors(state) {
1042
+ const raw = stateMonitor(state)?.raw ?? state;
1043
+ const frame = execDescriptorFrames.get(raw);
1044
+ if (!frame)
1045
+ return;
1046
+ execDescriptorFrames.delete(raw);
1047
+ const results = await Promise.allSettled([...frame.releases.values()].map(release => release()));
1048
+ frame.releases.clear();
1049
+ throwCleanupFailures(results.filter(result => result.status === "rejected").map(result => result.reason));
1050
+ }
1035
1051
  class DescriptorLifetime {
1036
1052
  finalize;
1037
1053
  _references = 1;
@@ -1276,6 +1292,8 @@ class ExpansionFailure extends Error {
1276
1292
  this.line = line;
1277
1293
  }
1278
1294
  }
1295
+ class FailglobFailure extends ExpansionFailure {
1296
+ }
1279
1297
  class CommandFailure extends Error {
1280
1298
  status;
1281
1299
  constructor(message, status) {
@@ -1755,10 +1773,20 @@ function bindCommandIO(context, io, limits = {}) {
1755
1773
  });
1756
1774
  }
1757
1775
  class FastShellCommandContext {
1758
- constructor(runtime, state, io, scope, name, args, argumentValues, env, signalIsScoped) {
1759
- const directContext = FAST_DIRECT_CONTEXT_COMMANDS.has(name) || (name === "find" && !args.includes("-exec") && !args.includes("-ok"));
1776
+ get signal() {
1777
+ const self = this._self ?? this;
1778
+ return self._nativeSignal ??= toNativeAbortSignal(self._rawSignal);
1779
+ }
1780
+ set signal(signal) {
1781
+ const self = this._self ?? this;
1782
+ self._rawSignal = signal;
1783
+ self._nativeSignal = undefined;
1784
+ }
1785
+ constructor(runtime, state, io, scope, name, args, argumentValues, env, signalIsScoped, definition) {
1786
+ const directContext = builtInDirectContextExecutors.has(definition.execute) && !customRegisteredCommands.has(definition.execute)
1787
+ && (FAST_DIRECT_CONTEXT_COMMANDS.has(name) || (name === "find" && !args.includes("-exec") && !args.includes("-ok")));
1760
1788
  if (!directContext) {
1761
- const { [invocationScope]: ignoredScope, [valueScope]: ignoredAllocation, [declarationArrays]: ignoredArrays, argumentValues: ignoredArguments, ...publicIO } = io;
1789
+ const { [invocationScope]: ignoredScope, [valueScope]: ignoredAllocation, [declarationArrays]: ignoredArrays, argumentValues: ignoredArguments, signal: ignoredSignal, ...publicIO } = io;
1762
1790
  Object.defineProperties(this, Object.getOwnPropertyDescriptors(publicIO));
1763
1791
  }
1764
1792
  this._self = this;
@@ -1777,15 +1805,19 @@ class FastShellCommandContext {
1777
1805
  this._argumentValues = argumentValues;
1778
1806
  this._env = env;
1779
1807
  this.cwd = state.cwd;
1780
- this.signal = runtime._isMemoryBackingFs && runtime.commandSignal === runtime.signal ? runtime.commandSignal : toNativeAbortSignal(runtime.commandSignal);
1808
+ this.signal = runtime.commandSignal;
1781
1809
  this.onInternalError = runtime.budget.onInternalError;
1782
1810
  this.argv0 = io.argv0;
1783
1811
  this.capabilities = io.capabilities;
1784
1812
  this.processSignals = io.processSignals;
1785
1813
  this.diagnosticLine = io.diagnosticLine;
1786
1814
  this.scriptName = io.scriptName;
1787
- if (directContext)
1815
+ if (directContext) {
1816
+ Object.defineProperty(this, "signal", {
1817
+ ...Object.getOwnPropertyDescriptor(FastShellCommandContext.prototype, "signal"), enumerable: true,
1818
+ });
1788
1819
  return;
1820
+ }
1789
1821
  workerRuntimeContexts.set(this, {
1790
1822
  budget: runtime.budget, umask: state.umask ?? 0o022, ignoredSignals: captureIgnoredTrapSignals(state.extensions), get fs() { return runtime.getContextFsForFast(0, combineManagedSignals(runtime.signal, scope.signal)); },
1791
1823
  });
@@ -1818,7 +1850,7 @@ class FastShellCommandContext {
1818
1850
  this.command = name;
1819
1851
  this.args = args;
1820
1852
  this.cwd = state.cwd;
1821
- this.signal = runtime._isMemoryBackingFs ? signal : toNativeAbortSignal(signal);
1853
+ this.signal = signal;
1822
1854
  this.onInternalError = runtime.budget.onInternalError;
1823
1855
  this.argv0 = io.argv0;
1824
1856
  this.capabilities = io.capabilities;
@@ -1954,7 +1986,6 @@ class FastShellCommandContext {
1954
1986
  }
1955
1987
  get fs() {
1956
1988
  const self = this._self ?? this;
1957
- self.signal = toNativeAbortSignal(self.signal);
1958
1989
  if (!self._contextFs) {
1959
1990
  self._contextFs = self._runtime.getContextFsForFast(self._state.umask ?? 0o022, self._getScopedSignal());
1960
1991
  }
@@ -2018,7 +2049,7 @@ function isFastDirectCommand(name, words) {
2018
2049
  }
2019
2050
  return true;
2020
2051
  }
2021
- const fastShellCommandAccessors = ["env", "fs", "shellPredicates", "inputBudget", "executionScope", "registerCleanup", "invoke", "argumentValues"].map(key => [key, Object.getOwnPropertyDescriptor(FastShellCommandContext.prototype, key)]);
2052
+ const fastShellCommandAccessors = ["signal", "env", "fs", "shellPredicates", "inputBudget", "executionScope", "registerCleanup", "invoke", "argumentValues", "stdinInput", "stdoutFile"].map(key => [key, Object.getOwnPropertyDescriptor(FastShellCommandContext.prototype, key)]);
2022
2053
  function cloneRawState(raw, hasLocals) {
2023
2054
  const variables = Object.assign(Object.create(null), raw.variables);
2024
2055
  const exported = raw.exported.size ? new Set(raw.exported) : new Set();
@@ -2046,6 +2077,12 @@ function cloneRawState(raw, hasLocals) {
2046
2077
  cloned.getopts = cloneGetoptsBinding(raw);
2047
2078
  if (raw.functionNames)
2048
2079
  cloned.functionNames = [...raw.functionNames];
2080
+ if (raw.aliases)
2081
+ cloned.aliases = new Map(raw.aliases);
2082
+ if (raw.loopDepth > 0 || raw._subshellInLoop) {
2083
+ cloned._subshellInLoop = true;
2084
+ }
2085
+ cloned.loopDepth = 0;
2049
2086
  return cloned;
2050
2087
  }
2051
2088
  function tryCloneStateSync(state, scope, inheritLocals = true) {
@@ -2937,7 +2974,7 @@ export function warmDefaultRuntimeContextFs(sourceFs, backingFs) {
2937
2974
  void created.rm;
2938
2975
  reusableDefaultContextFsBySourceFs.set(sourceFs, { scoped: created, inUseBy: undefined });
2939
2976
  }
2940
- import { abortManagedController, addAbortSignalWaiter, combineManagedSignals, createManagedControlController, getRuntimeBackingFileSystem, interruptible, isSyncResolved, registerRuntimeBackingFileSystem, removeAbortSignalWaiter, toNativeAbortSignal } from "../../safe-bash-contracts/runtime-control.js";
2977
+ import { abortManagedController, addAbortSignalWaiter, combineManagedSignals, releaseCombinedSignal, createManagedControlController, getRuntimeBackingFileSystem, interruptible, isSyncResolved, registerRuntimeBackingFileSystem, removeAbortSignalWaiter, toNativeAbortSignal } from "../../safe-bash-contracts/runtime-control.js";
2941
2978
  export { getRuntimeBackingFileSystem, interruptible, registerRuntimeBackingFileSystem };
2942
2979
  const emptyWords = [];
2943
2980
  const emptyShellValues = [];
@@ -2982,7 +3019,6 @@ function hasGlobOrEscape(text, extglob = false) {
2982
3019
  }
2983
3020
  return false;
2984
3021
  }
2985
- let nextProcessSubstitutionId = 0;
2986
3022
  const fastSubScratchArgs = [];
2987
3023
  const defaultValueScopeReserve = ValueScope.prototype.reserve;
2988
3024
  const defaultStringCodePointAt = String.prototype.codePointAt;
@@ -3230,14 +3266,12 @@ class PooledSyncPipeWriter {
3230
3266
  signal;
3231
3267
  target = EMPTY_BYTES;
3232
3268
  used = 0;
3233
- overflowed = false;
3234
3269
  lineCountOnly = -1;
3235
3270
  reset(budget, signal, target, lineCountOnly = -1) {
3236
3271
  this.budget = budget;
3237
3272
  this.signal = signal;
3238
3273
  this.target = target;
3239
3274
  this.used = 0;
3240
- this.overflowed = false;
3241
3275
  this.lineCountOnly = lineCountOnly;
3242
3276
  }
3243
3277
  writeLineCountSync(count, totalBytes) {
@@ -3246,16 +3280,22 @@ class PooledSyncPipeWriter {
3246
3280
  const budget = this.budget;
3247
3281
  if (budget.bytes + totalBytes > budget.maxOutputBytesSmi && totalBytes > budget.limits.maxOutputBytes - budget.bytes)
3248
3282
  budget.fail("maxOutputBytes");
3249
- if (this.used + totalBytes > this.target.byteLength) {
3250
- this.overflowed = true;
3251
- return false;
3252
- }
3253
3283
  this.used += totalBytes;
3254
3284
  budget.bytes += totalBytes;
3255
3285
  }
3256
3286
  this.lineCountOnly = count;
3257
3287
  return true;
3258
3288
  }
3289
+ reserve(length) {
3290
+ const required = this.used + length;
3291
+ if (required <= this.target.byteLength)
3292
+ return;
3293
+ // Output admission precedes allocation; intermediate stages may exceed 64 KiB.
3294
+ const capacity = Math.min(this.budget.limits.maxOutputBytes, Math.max(required, this.target.byteLength * 2));
3295
+ const target = new Uint8Array(capacity);
3296
+ target.set(this.target.subarray(0, this.used));
3297
+ this.target = target;
3298
+ }
3259
3299
  writeSync(chunk) {
3260
3300
  this.signal.throwIfAborted();
3261
3301
  const len = chunk.byteLength;
@@ -3264,11 +3304,12 @@ class PooledSyncPipeWriter {
3264
3304
  const budget = this.budget;
3265
3305
  if (budget.bytes + len > budget.maxOutputBytesSmi && len > budget.limits.maxOutputBytes - budget.bytes)
3266
3306
  budget.fail("maxOutputBytes");
3267
- if (this.used + len > this.target.byteLength) {
3268
- this.overflowed = true;
3269
- return false;
3270
- }
3307
+ this.reserve(len);
3271
3308
  this.target.set(chunk, this.used);
3309
+ if (this.lineCountOnly >= 0)
3310
+ for (const byte of chunk)
3311
+ if (byte === 10)
3312
+ this.lineCountOnly++;
3272
3313
  this.used += len;
3273
3314
  budget.bytes += len;
3274
3315
  return true;
@@ -3280,23 +3321,23 @@ class PooledSyncPipeWriter {
3280
3321
  const budget = this.budget;
3281
3322
  if (budget.bytes + len > budget.maxOutputBytesSmi && len > budget.limits.maxOutputBytes - budget.bytes)
3282
3323
  budget.fail("maxOutputBytes");
3283
- if (this.used + len > this.target.byteLength) {
3284
- this.overflowed = true;
3285
- return false;
3286
- }
3324
+ this.reserve(len);
3287
3325
  const dst = this.target;
3288
3326
  const base = this.used;
3289
- for (let i = 0; i < len; i++)
3290
- dst[base + i] = src[i];
3327
+ for (let i = 0; i < len; i++) {
3328
+ const byte = src[i];
3329
+ dst[base + i] = byte;
3330
+ if (this.lineCountOnly >= 0 && byte === 10)
3331
+ this.lineCountOnly++;
3332
+ }
3291
3333
  this.used = base + len;
3292
3334
  budget.bytes += len;
3293
3335
  return true;
3294
3336
  }
3295
3337
  write(chunk) {
3296
3338
  try {
3297
- if (this.writeSync(chunk))
3298
- return resolvedVoid;
3299
- return Promise.reject(new Error("Sync pipe stage buffer overflow"));
3339
+ this.writeSync(chunk);
3340
+ return resolvedVoid;
3300
3341
  }
3301
3342
  catch (err) {
3302
3343
  return Promise.reject(err);
@@ -3715,6 +3756,19 @@ function getOrParseSingleEvalUnit(source, unitLocale, parseBudget) {
3715
3756
  }
3716
3757
  export class Runtime {
3717
3758
  reuseDefaultContextFs;
3759
+ persistentIO(state, io) {
3760
+ const frame = execDescriptorFrames.get(stateMonitor(state)?.raw ?? state);
3761
+ if (!frame || io.execFrame === frame && io.execVersion === frame.version)
3762
+ return io;
3763
+ const changed = new Map([...frame.descriptors].filter(([number]) => io.execFrame !== frame || (frame.revisions.get(number) ?? 0) > (io.execVersion ?? 0)));
3764
+ const descriptors = new Map(io.descriptors ?? [[0, { input: io.stdin }], [1, { output: io.stdout }], [2, { output: io.stderr }]]);
3765
+ for (const [number, descriptor] of changed)
3766
+ descriptors.set(number, descriptor);
3767
+ return { ...io, descriptors, execFrame: frame, execVersion: frame.version,
3768
+ ...(changed.has(0) ? { stdin: descriptors.get(0)?.closed ? closedSource : descriptors.get(0)?.input ?? closedSource, stdinIsDefault: false } : {}),
3769
+ ...(changed.has(1) ? { stdout: descriptors.get(1)?.closed ? closedSink : descriptors.get(1)?.output ?? closedSink } : {}),
3770
+ ...(changed.has(2) ? { stderr: descriptors.get(2)?.closed ? closedSink : descriptors.get(2)?.output ?? closedSink } : {}) };
3771
+ }
3718
3772
  static clearStaticPools() { clearRuntimePools(); }
3719
3773
  _syncReturnDepth = 0;
3720
3774
  _syncPendingReturnStatus;
@@ -3761,8 +3815,6 @@ export class Runtime {
3761
3815
  const method = Object.getOwnPropertyDescriptor(MemoryFileSystem.prototype, name)?.value;
3762
3816
  return typeof method !== "function" || Reflect.get(this.backingFs, name) === method;
3763
3817
  });
3764
- if (this._isMemoryBackingFs)
3765
- this.backingFs._activeRuntimeBudget = budget;
3766
3818
  registerInternalYieldCheckpoint(signal, budget.yieldCheckpoint);
3767
3819
  if (commandSignal !== signal) {
3768
3820
  inheritYieldCheckpoint(signal, commandSignal);
@@ -3784,6 +3836,7 @@ export class Runtime {
3784
3836
  const reusableEntry = reusableDefaultContextFsBySourceFs.get(this.sourceFs);
3785
3837
  if (reusableEntry && reusableEntry.inUseBy === this) {
3786
3838
  retargetScopedFileSystem(reusableEntry.scoped, noopFsCharge, NEVER_ABORTED_SIGNAL, noopFsCharge, 256);
3839
+ registerRuntimeBackingFileSystem(reusableEntry.scoped, this.backingFs);
3787
3840
  reusableEntry.inUseBy = undefined;
3788
3841
  }
3789
3842
  }
@@ -3802,7 +3855,7 @@ export class Runtime {
3802
3855
  if (!this._fs) {
3803
3856
  this._fs = scopeFileSystem(this._rawFs, this.budget.chargeFs, this.signal, this.budget.cleanupChargeFs, { maxPathComponents: this.budget.limits.maxPathnameComponents });
3804
3857
  runtimeFileSystems.set(this._fs, this.sourceFs);
3805
- registerRuntimeBackingFileSystem(this._fs, this.backingFs);
3858
+ registerRuntimeBackingFileSystem(this._fs, this.backingFs, this.budget.chargeFs);
3806
3859
  }
3807
3860
  return this._fs;
3808
3861
  }
@@ -3814,7 +3867,8 @@ export class Runtime {
3814
3867
  if (this.reuseDefaultContextFs && sig === this.signal && umask === 0o022 && !this._contextFs && this._isMemoryBackingFs) {
3815
3868
  const entry = reusableDefaultContextFsBySourceFs.get(this.sourceFs);
3816
3869
  if (entry && (entry.inUseBy === undefined || entry.inUseBy === this)) {
3817
- if (retargetScopedFileSystem(entry.scoped, this.budget.chargeFs, sig, this.budget.cleanupChargeFs, this.budget.limits.maxPathnameComponents)) {
3870
+ if (retargetScopedFileSystem(entry.scoped, this.budget.chargeFs, toNativeAbortSignal(sig), this.budget.cleanupChargeFs, this.budget.limits.maxPathnameComponents)) {
3871
+ registerRuntimeBackingFileSystem(entry.scoped, this.backingFs, this.budget.chargeFs);
3818
3872
  entry.inUseBy = this;
3819
3873
  this._contextFsMask = umask;
3820
3874
  this._contextFsSignal = sig;
@@ -3823,9 +3877,9 @@ export class Runtime {
3823
3877
  }
3824
3878
  }
3825
3879
  }
3826
- const created = scopeFileSystem(creationFileSystem(this.sourceFs, umask), this.budget.chargeFs, sig, this.budget.cleanupChargeFs, { maxPathComponents: this.budget.limits.maxPathnameComponents });
3880
+ const created = scopeFileSystem(creationFileSystem(this.sourceFs, umask), this.budget.chargeFs, toNativeAbortSignal(sig), this.budget.cleanupChargeFs, { maxPathComponents: this.budget.limits.maxPathnameComponents });
3827
3881
  runtimeFileSystems.set(created, this.sourceFs);
3828
- registerRuntimeBackingFileSystem(created, this.backingFs);
3882
+ registerRuntimeBackingFileSystem(created, this.backingFs, this.budget.chargeFs);
3829
3883
  this._contextFsMask = umask;
3830
3884
  this._contextFsSignal = sig;
3831
3885
  this._contextFs = created;
@@ -5051,6 +5105,10 @@ export class Runtime {
5051
5105
  }
5052
5106
  variable(state, name) {
5053
5107
  name = this.referenceName(state, name);
5108
+ if (name === "$" || name === "BASHPID")
5109
+ return "1";
5110
+ if (name === "!")
5111
+ return "";
5054
5112
  if (name === "RANDOM" || name === "SECONDS")
5055
5113
  return readDynamicVariable(stateMonitor(state)?.raw ?? state, name) ?? state.variables[name];
5056
5114
  const binding = arrayStore(state)?.get(name);
@@ -6397,8 +6455,14 @@ export class Runtime {
6397
6455
  // publication snapshot, and choose the append cursor from the new maximum.
6398
6456
  const expandedEntries = [];
6399
6457
  let elementFields;
6458
+ let attributedElement;
6400
6459
  if (assignment.kind === "element") {
6401
6460
  elementFields = await this.valueWord(assignment.value, state, io, false, false, false, false, undefined, false, false, 0);
6461
+ if (selectedIndex !== undefined && state.variableAttributes?.get(name)?.includes("i")) {
6462
+ const previous = assignment.append ? store.get(name)?.getValue(selectedIndex)
6463
+ ?? (selectedIndex === 0 ? state.variables[name] : undefined) ?? "" : undefined;
6464
+ attributedElement = await this.attributeValue(state, name, concatShellValues(elementFields, io[valueScope]), io, "assignment", previous);
6465
+ }
6402
6466
  }
6403
6467
  else
6404
6468
  for (const entry of assignment.entries) {
@@ -6422,6 +6486,32 @@ export class Runtime {
6422
6486
  }
6423
6487
  current = store.get(name);
6424
6488
  initialMaximum = current?.maximum ?? (state.variables[name] === undefined ? -1 : 0);
6489
+ // Arithmetic attributes and computed indices observe each preceding write.
6490
+ // Expand words against the original binding first, then use ordinary element
6491
+ // assignment publication so arithmetic reads the current array, not a draft.
6492
+ if (assignment.kind === "compound" && expandedEntries.length > 0
6493
+ && (state.variableAttributes?.get(name)?.includes("i")
6494
+ || !isAssociative && expandedEntries.some(({ entry }) => entry.index && numericIndex(entry.index) === undefined))) {
6495
+ let cursor = assignment.append ? initialMaximum + 1 : 0;
6496
+ if (!assignment.append)
6497
+ await this.arrayAssignment({ ...assignment, entries: [] }, state, io, undefined, origin, associative, true);
6498
+ for (const { entry, fields } of expandedEntries) {
6499
+ const values = entry.index ? [concatShellValues(fields, io[valueScope])] : fields;
6500
+ for (const value of values) {
6501
+ const index = entry.index && !isAssociative
6502
+ ? (await this.arrayIndex(store.get(name), entry.index, state, io, operation, true)) : cursor;
6503
+ const part = { kind: "text", value: shellValueText(value), quoted: true };
6504
+ if (typeof value !== "string")
6505
+ invokedValues.set(part, value);
6506
+ await this.arrayAssignment({ kind: "element", name, append: entry.append ?? false,
6507
+ index: isAssociative ? entry.index : { decimal: String(index) }, value: { offset: entry.value.offset, parts: [part] } }, state, io, undefined, origin, associative, true);
6508
+ cursor = index + 1;
6509
+ }
6510
+ }
6511
+ if (declaration)
6512
+ await this.arrayAssignment({ ...assignment, append: true, entries: [] }, state, io, declaration, origin, associative, true);
6513
+ return;
6514
+ }
6425
6515
  this.assertArrayWritable(state, name, origin);
6426
6516
  const watch = await store.watch(name, operation, this.signal);
6427
6517
  const supersede = await stateMonitor(state).prepareTypedPublication(name, operation, this.signal);
@@ -6459,7 +6549,9 @@ export class Runtime {
6459
6549
  const previous = append ? targetBinding.getValue(index) ?? "" : undefined;
6460
6550
  if (append && !state.variableAttributes?.get(name)?.includes("i"))
6461
6551
  value = await join([previous, value]);
6462
- if (state.variableAttributes?.get(name))
6552
+ if (attributedElement !== undefined)
6553
+ value = attributedElement;
6554
+ else if (state.variableAttributes?.get(name))
6463
6555
  value = await this.attributeValue(state, name, value, io, "assignment", previous);
6464
6556
  else if (shellValueByteLength(value) > this.budget.limits.maxExpansionBytes)
6465
6557
  this.budget.fail("maxExpansionBytes");
@@ -6626,7 +6718,12 @@ export class Runtime {
6626
6718
  }
6627
6719
  }
6628
6720
  async run(script, state, io) {
6629
- return this.finishShell(state, io, (await this.runUnit(script, state, io)).exitCode);
6721
+ try {
6722
+ return await this.finishShell(state, io, (await this.runUnit(script, state, io)).exitCode);
6723
+ }
6724
+ finally {
6725
+ await closeExecDescriptors(state);
6726
+ }
6630
6727
  }
6631
6728
  extensionContext(state, io, command = "", args = [], argumentValues = args) {
6632
6729
  const frame = state.extensions;
@@ -7720,7 +7817,7 @@ export class Runtime {
7720
7817
  throw error;
7721
7818
  throw error.reason;
7722
7819
  }
7723
- if (error instanceof Flow && error.kind === "exit") {
7820
+ if (error instanceof Flow && (error.kind === "exit" || error.kind === "return" || error.kind === "break" || error.kind === "continue")) {
7724
7821
  if (this.tryFinishShellSync(state))
7725
7822
  return { exitCode: error.status, terminated: true };
7726
7823
  return this.finishShell(monitor.proxy, io, error.status).then(exitCode => ({ exitCode, terminated: true }));
@@ -7748,7 +7845,7 @@ export class Runtime {
7748
7845
  throw error;
7749
7846
  throw error.reason;
7750
7847
  }
7751
- if (error instanceof Flow && error.kind === "exit")
7848
+ if (error instanceof Flow && (error.kind === "exit" || error.kind === "return" || error.kind === "break" || error.kind === "continue"))
7752
7849
  return { exitCode: await this.finishShell(state, io, error.status), terminated: true };
7753
7850
  throw error;
7754
7851
  }
@@ -7765,7 +7862,7 @@ export class Runtime {
7765
7862
  throw error;
7766
7863
  throw error.reason;
7767
7864
  }
7768
- if (error instanceof Flow && error.kind === "exit")
7865
+ if (error instanceof Flow && (error.kind === "exit" || error.kind === "return" || error.kind === "break" || error.kind === "continue"))
7769
7866
  return { exitCode: await this.finishShell(state, io, error.status), terminated: true };
7770
7867
  throw error;
7771
7868
  }
@@ -7856,8 +7953,11 @@ export class Runtime {
7856
7953
  try {
7857
7954
  for (let i = 1; i < command.words.length; i++) {
7858
7955
  const w = command.words[i];
7859
- if (w.plain === undefined && !(w.parts.length === 1 && w.parts[0].kind === "text" && w.parts[0].quoted === true && !w.parts[0].byteValue))
7956
+ if (w.plain !== undefined
7957
+ ? w.plain.includes("{") || w.plain.startsWith("~") || hasGlobOrEscape(w.plain, true)
7958
+ : !(w.parts.length === 1 && w.parts[0].kind === "text" && w.parts[0].quoted === true && !w.parts[0].byteValue)) {
7860
7959
  allPlain = false;
7960
+ }
7861
7961
  const v = this.fastValueWord(w, rawState, io, true, false, false, true, undefined, diagnosticLine);
7862
7962
  if (typeof v !== "string")
7863
7963
  return undefined;
@@ -7869,6 +7969,7 @@ export class Runtime {
7869
7969
  return undefined;
7870
7970
  }
7871
7971
  if (allPlain) {
7972
+ Object.freeze(args);
7872
7973
  command._cachedConstArgs = args;
7873
7974
  if (command.redirects.length === 0 || (command.redirects[0].target.plain !== undefined && (command.redirects[0].operator === ">" || command.redirects[0].operator === ">>"))) {
7874
7975
  command._cachedFastSingle = {
@@ -7941,7 +8042,7 @@ export class Runtime {
7941
8042
  }
7942
8043
  }
7943
8044
  else {
7944
- context = new FastShellCommandContext(this, rawState, io, scope, w0Plain, args, undefined, undefined, this._isMemoryBackingFs);
8045
+ context = new FastShellCommandContext(this, rawState, io, scope, w0Plain, args, undefined, undefined, this._isMemoryBackingFs, externalDef);
7945
8046
  if (redirectSink)
7946
8047
  context.stdout = redirectSink;
7947
8048
  }
@@ -7961,7 +8062,7 @@ export class Runtime {
7961
8062
  if (cmd.kind !== "simple" || !this.isPureExternalStageCommand(cmd, rawState) || cmd.words.length > this.budget.maxExpansionFieldsSmi)
7962
8063
  return undefined;
7963
8064
  }
7964
- return this.executeFastPurePipelineUnit(pipeline, state, rawState, monitor, io, ignored || pipeline.negate);
8065
+ return this.tryExecuteSyncPurePipelineUnit(pipeline, state, rawState, monitor, io, ignored || pipeline.negate);
7965
8066
  }
7966
8067
  return undefined;
7967
8068
  }
@@ -8012,18 +8113,20 @@ export class Runtime {
8012
8113
  }
8013
8114
  }
8014
8115
  catch (error) {
8015
- return this.finishFastSingleExternalUnitAsync(undefined, error, true, redirectSink, diagnosticLine, negate, ignored, monitor, rawState, existing, elem0, store, state, io, scope, restEpoch);
8116
+ return this.finishFastSingleExternalUnitAsync(context, undefined, error, true, redirectSink, diagnosticLine, negate, ignored, monitor, rawState, existing, elem0, store, state, io, scope, restEpoch);
8016
8117
  }
8017
- return this.finishFastSingleExternalUnitAsync(raw, undefined, false, redirectSink, diagnosticLine, negate, ignored, monitor, rawState, existing, elem0, store, state, io, scope, restEpoch);
8118
+ return this.finishFastSingleExternalUnitAsync(context, raw, undefined, false, redirectSink, diagnosticLine, negate, ignored, monitor, rawState, existing, elem0, store, state, io, scope, restEpoch);
8018
8119
  }
8019
- async finishFastSingleExternalUnitAsync(raw, initialError, hasInitialError, redirectSink, diagnosticLine, negate, ignored, monitor, rawState, existing, elem0, store, state, io, scope, restEpoch) {
8120
+ async finishFastSingleExternalUnitAsync(context, raw, initialError, hasInitialError, redirectSink, diagnosticLine, negate, ignored, monitor, rawState, existing, elem0, store, state, io, scope, restEpoch) {
8020
8121
  let rawStatus = 0;
8122
+ let commandSettled = hasInitialError;
8123
+ const pending = hasInitialError ? undefined : Promise.resolve(raw).then(result => { commandSettled = true; return result; }, error => { commandSettled = true; throw error; });
8021
8124
  try {
8022
8125
  if (hasInitialError)
8023
8126
  throw initialError;
8024
8127
  const res = this.budget._hasExternalSignal
8025
- ? await interruptible(Promise.resolve(raw), this.signal)
8026
- : await raw;
8128
+ ? await interruptible(pending, this.signal)
8129
+ : await pending;
8027
8130
  this.signal.throwIfAborted();
8028
8131
  if (redirectSink?.failedError !== undefined)
8029
8132
  throw redirectSink.failedError;
@@ -8051,6 +8154,12 @@ export class Runtime {
8051
8154
  this.budget.endPathLookupSuspension();
8052
8155
  scope.leaveWork();
8053
8156
  redirectSink?.handle.close();
8157
+ if (commandSettled)
8158
+ context.releaseDirectStage();
8159
+ else {
8160
+ // Cancellation may win before the command stops using its context.
8161
+ void pending.then(() => context.releaseDirectStage(), () => context.releaseDirectStage());
8162
+ }
8054
8163
  }
8055
8164
  if (!existing) {
8056
8165
  monitor.lazyPipeStatus = rawStatus === 0 ? singleStatusZero : rawStatus === 1 ? singleStatusOne : [rawStatus];
@@ -8074,9 +8183,6 @@ export class Runtime {
8074
8183
  }
8075
8184
  return finalStatus === 0 ? SYNC_UNIT_ZERO : finalStatus === 1 ? SYNC_UNIT_ONE : { exitCode: finalStatus, terminated: false };
8076
8185
  }
8077
- executeFastPurePipelineUnit(pipeline, state, rawState, monitor, io, ignored) {
8078
- return this.tryExecuteSyncPurePipelineUnit(pipeline, state, rawState, monitor, io, ignored);
8079
- }
8080
8186
  tryExecuteSyncPurePipelineUnit(pipeline, state, rawState, monitor, io, ignored) {
8081
8187
  const backing = this.backingFs;
8082
8188
  if (syncPurePipelineSlotInUse || !this._isMemoryBackingFs || !backing || backing.capabilitiesFor !== undefined || this.middleware.length > 0 || customRegisteredRegistries.has(this.commands) || !io.stdinIsDefault || this.signal.aborted || hasYieldCheckpoint(this.signal) || !this.budget.canSyncPurePipe || !(io.stdout instanceof Capture && io.stdout._scratch4k !== undefined && io.stdout.length === 0 && io.stdout.write === Capture.prototype.write) || !(io.stderr instanceof Capture && io.stderr.length === 0 && io.stderr.write === Capture.prototype.write)) {
@@ -8195,7 +8301,7 @@ export class Runtime {
8195
8301
  stageStdout = sharedSyncPipeWriter;
8196
8302
  }
8197
8303
  if (!context) {
8198
- context = new FastShellCommandContext(this, rawState, io, scope, firstName, stageArgs, undefined, undefined, true);
8304
+ context = new FastShellCommandContext(this, rawState, io, scope, firstName, stageArgs, undefined, undefined, true, extDef);
8199
8305
  pooledSyncPipeContext = context;
8200
8306
  }
8201
8307
  context.resetDirectStage(this, rawState, io, scope, firstName, stageArgs, inputSource, isFirst, stageStdout, this.signal);
@@ -8222,7 +8328,7 @@ export class Runtime {
8222
8328
  statuses ??= new Array(n).fill(0);
8223
8329
  statuses[index] = status;
8224
8330
  }
8225
- }).finally(() => scope.leaveWork()).then(() => runStages(index + 1, nextBuf, sharedSyncPipeWriter.used));
8331
+ }).finally(() => scope.leaveWork()).then(() => runStages(index + 1, sharedSyncPipeWriter.target, sharedSyncPipeWriter.used));
8226
8332
  }
8227
8333
  scope.leaveWork();
8228
8334
  this.signal.throwIfAborted();
@@ -8230,7 +8336,7 @@ export class Runtime {
8230
8336
  statuses ??= new Array(n).fill(0);
8231
8337
  statuses[index] = 1;
8232
8338
  }
8233
- prevBuf = nextBuf;
8339
+ prevBuf = sharedSyncPipeWriter.target;
8234
8340
  prevLen = sharedSyncPipeWriter.used;
8235
8341
  }
8236
8342
  };
@@ -8241,6 +8347,7 @@ export class Runtime {
8241
8347
  sharedSyncPipeWriter.signal = undefined;
8242
8348
  sharedSyncPipeWriter.target = EMPTY_BYTES;
8243
8349
  sharedSyncPipeReader.reset(EMPTY_BYTES, 0);
8350
+ sharedSyncPipeReader.clearViews();
8244
8351
  syncPurePipelineSlotInUse = false;
8245
8352
  this.budget.leavePipelineStages(n);
8246
8353
  };
@@ -8273,270 +8380,6 @@ export class Runtime {
8273
8380
  release();
8274
8381
  return finish();
8275
8382
  }
8276
- executeFastPurePipelineUnitSlow(pipeline, state, rawState, monitor, io, ignored) {
8277
- const n = pipeline.commands.length;
8278
- this.budget.enterPipelineStages(n);
8279
- this.budget.commands += n;
8280
- const pipeOptions = { highWaterMark: this.budget.limits.pipeHighWaterMark, signal: this.signal, admitWrite: this.budget.pipelineInput };
8281
- const pipes = new Array(n - 1);
8282
- for (let i = 0; i < n - 1; i++) {
8283
- pipes[i] = createBytePipe(pipeOptions);
8284
- }
8285
- const controllers = new Array(n);
8286
- for (let i = 0; i < n; i++) {
8287
- controllers[i] = createManagedControlController();
8288
- }
8289
- const onParentAbort = (reason) => {
8290
- for (let i = 0; i < n; i++)
8291
- abortManagedController(controllers[i], reason);
8292
- };
8293
- addAbortSignalWaiter(this.signal, onParentAbort);
8294
- const scope = io[invocationScope];
8295
- const onScopeSeal = () => {
8296
- const closedReason = new Error("Invocation is closed");
8297
- for (let i = 0; i < n; i++)
8298
- abortManagedController(controllers[i], closedReason);
8299
- for (let i = 0; i < n - 1; i++)
8300
- void pipes[i].abort(closedReason);
8301
- };
8302
- scope.addSealCallback(onScopeSeal);
8303
- const statuses = new Array(n);
8304
- let asyncTasks;
8305
- try {
8306
- for (let index = 0; index < n; index++) {
8307
- const cmd = pipeline.commands[index];
8308
- const firstName = cmd.words[0].plain;
8309
- const extDef = this.commands.get(firstName);
8310
- let stageArgs = cmd._cachedPlainArgs;
8311
- if (!stageArgs) {
8312
- stageArgs = new Array(cmd.words.length - 1);
8313
- for (let w = 1; w < cmd.words.length; w++) {
8314
- const word = cmd.words[w];
8315
- stageArgs[w - 1] = word.plain ?? word.parts.map(p => p.value).join("");
8316
- }
8317
- cmd._cachedPlainArgs = stageArgs;
8318
- }
8319
- const incoming = index > 0 ? pipes[index - 1] : undefined;
8320
- const outgoing = index < n - 1 ? pipes[index] : undefined;
8321
- const reading = incoming?.endpoints?.read;
8322
- const writing = outgoing?.endpoints?.write;
8323
- const stageSignal = controllers[index].signal;
8324
- let input;
8325
- if (incoming) {
8326
- reading.abortSignal = stageSignal;
8327
- input = reading;
8328
- }
8329
- else if (io.stdinIsDefault)
8330
- input = io.stdin;
8331
- else
8332
- input = new ShellInput(io.stdin, this.budget, stageSignal, undefined, true);
8333
- const writable = writing?.writable ?? outgoing?.writable;
8334
- const stageStdout = outgoing
8335
- ? new BudgetedPipeStageSink(this.budget, writable, stageSignal, undefined, index, controllers[index])
8336
- : signalSink(io.stdout, stageSignal);
8337
- const context = new FastShellCommandContext(this, rawState, io, scope, firstName, stageArgs, undefined, undefined, true);
8338
- context.stdin = input;
8339
- if (incoming)
8340
- context.stdinIsDefault = false;
8341
- context.stdout = stageStdout;
8342
- context.signal = this._isMemoryBackingFs ? stageSignal : toNativeAbortSignal(stageSignal);
8343
- context._scopedSignal = stageSignal;
8344
- if (asyncTasks === undefined) {
8345
- scope.enterWork();
8346
- this.budget.beginPathLookupSuspension();
8347
- let syncExitCode = -1;
8348
- let pendingRes;
8349
- let syncErr;
8350
- let hasSyncErr = false;
8351
- try {
8352
- const resPromise = extDef.execute(context);
8353
- if (resPromise === RESOLVED_EXIT_ZERO) {
8354
- stageSignal.throwIfAborted();
8355
- syncExitCode = 0;
8356
- }
8357
- else if (resPromise === RESOLVED_EXIT_ONE) {
8358
- stageSignal.throwIfAborted();
8359
- syncExitCode = 1;
8360
- }
8361
- else
8362
- pendingRes = Promise.resolve(resPromise);
8363
- }
8364
- catch (error) {
8365
- hasSyncErr = true;
8366
- syncErr = error;
8367
- }
8368
- if (syncExitCode >= 0) {
8369
- this.budget.endPathLookupSuspension();
8370
- scope.leaveWork();
8371
- let asyncCleanup;
8372
- if (!incoming && input !== io.stdin) {
8373
- const closedInput = input.close();
8374
- if (!isSyncResolved(closedInput))
8375
- asyncCleanup = closedInput;
8376
- }
8377
- if (!asyncCleanup && reading) {
8378
- const closedRead = reading.close();
8379
- if (!isSyncResolved(closedRead))
8380
- asyncCleanup = closedRead;
8381
- }
8382
- if (!asyncCleanup && writing) {
8383
- const closedWrite = writing.close();
8384
- if (!isSyncResolved(closedWrite))
8385
- asyncCleanup = closedWrite;
8386
- }
8387
- if (!asyncCleanup && outgoing && !writing) {
8388
- const closedOut = outgoing.close();
8389
- if (!isSyncResolved(closedOut))
8390
- asyncCleanup = closedOut;
8391
- }
8392
- if (!asyncCleanup) {
8393
- statuses[index] = syncExitCode;
8394
- continue;
8395
- }
8396
- asyncTasks = new Array(n);
8397
- for (let prev = 0; prev < index; prev++)
8398
- asyncTasks[prev] = Promise.resolve(statuses[prev]);
8399
- asyncTasks[index] = asyncCleanup.then(() => syncExitCode);
8400
- continue;
8401
- }
8402
- asyncTasks = new Array(n);
8403
- for (let prev = 0; prev < index; prev++)
8404
- asyncTasks[prev] = Promise.resolve(statuses[prev]);
8405
- asyncTasks[index] = this.finishFastPurePipelineStageAsync(cmd, context, incoming, outgoing, reading, writing, input, stageSignal, scope, io, pendingRes, hasSyncErr, syncErr);
8406
- continue;
8407
- }
8408
- scope.enterWork();
8409
- this.budget.beginPathLookupSuspension();
8410
- asyncTasks[index] = this.finishFastPurePipelineStageAsync(cmd, context, incoming, outgoing, reading, writing, input, stageSignal, scope, io, undefined, false, undefined, extDef);
8411
- }
8412
- if (asyncTasks !== undefined) {
8413
- return this.finishFastPurePipelineUnitAsync(asyncTasks, n, pipes, controllers, onParentAbort, onScopeSeal, scope, monitor, rawState, pipeline, state, io, ignored);
8414
- }
8415
- }
8416
- catch (syncFatal) {
8417
- scope.removeSealCallback(onScopeSeal);
8418
- removeAbortSignalWaiter(this.signal, onParentAbort);
8419
- for (let i = 0; i < n; i++)
8420
- abortManagedController(controllers[i], SHARED_PIPELINE_CLOSED);
8421
- for (let i = 0; i < n - 1; i++)
8422
- void pipes[i].abort();
8423
- this.budget.leavePipelineStages(n);
8424
- throw syncFatal;
8425
- }
8426
- scope.removeSealCallback(onScopeSeal);
8427
- removeAbortSignalWaiter(this.signal, onParentAbort);
8428
- for (let i = 0; i < n; i++) {
8429
- abortManagedController(controllers[i], SHARED_PIPELINE_CLOSED);
8430
- }
8431
- for (let i = 0; i < n - 1; i++) {
8432
- void pipes[i].abort();
8433
- }
8434
- this.budget.leavePipelineStages(n);
8435
- const restEpoch = monitor.chargeInternal(syncRestorationCharge, syncRestorationTickets).epoch;
8436
- monitor.lazyPipeStatus = statuses;
8437
- monitor.chargeInternal(syncPipeStatusCharge, syncPipeStatusTickets);
8438
- const rawStatus = rawState.pipefail ? statuses.findLast(s => s !== 0) ?? 0 : statuses[n - 1];
8439
- const finalStatus = pipeline.negate ? Number(rawStatus === 0) : rawStatus;
8440
- rawState.status = finalStatus;
8441
- monitor.epoch = restEpoch;
8442
- if (rawStatus !== 0 && !pipeline.negate && !ignored && rawState.errexit) {
8443
- if (this.tryFinishShellSync(state))
8444
- return { exitCode: finalStatus, terminated: true };
8445
- return this.finishShell(state, io, finalStatus).then(exitCode => ({ exitCode, terminated: true }));
8446
- }
8447
- return finalStatus === 0 ? SYNC_UNIT_ZERO : finalStatus === 1 ? SYNC_UNIT_ONE : { exitCode: finalStatus, terminated: false };
8448
- }
8449
- async finishFastPurePipelineStageAsync(cmd, context, incoming, outgoing, reading, writing, input, stageSignal, scope, io, pendingRes, hasSyncErr, syncErr, extDef) {
8450
- let exitCode = 0;
8451
- try {
8452
- if (hasSyncErr)
8453
- throw syncErr;
8454
- const res = await (pendingRes ?? extDef.execute(context));
8455
- stageSignal.throwIfAborted();
8456
- exitCode = validateExitCode(res.exitCode);
8457
- }
8458
- catch (error) {
8459
- if (error instanceof PipelineClosed || (stageSignal.aborted && Object.is(stageSignal.reason, SHARED_PIPELINE_CLOSED)))
8460
- exitCode = 141;
8461
- else if (errorCode(error) === "EPIPE" && !this.signal.aborted)
8462
- exitCode = 141;
8463
- else {
8464
- this.signal.throwIfAborted();
8465
- if (error instanceof Flow || error instanceof ShellLimitError || error instanceof ShellSyntaxError)
8466
- throw error;
8467
- const line = io.diagnosticCommandLines?.get(cmd) ?? (cmd.line ?? 1) + (io.diagnosticOffset ?? 0);
8468
- try {
8469
- await writeDiagnostic(context.stderr, `${io.scriptName ?? "shell"}: line ${line}: ${message(error, this.budget.onInternalError)}\n`);
8470
- }
8471
- catch (failure) {
8472
- this.signal.throwIfAborted();
8473
- publicDiagnosticMessage(failure, this.budget.onInternalError);
8474
- }
8475
- exitCode = error instanceof CommandFailure ? error.status : 1;
8476
- }
8477
- }
8478
- finally {
8479
- this.budget.endPathLookupSuspension();
8480
- scope.leaveWork();
8481
- if (!incoming && input !== io.stdin) {
8482
- const closedInput = input.close();
8483
- if (!isSyncResolved(closedInput)) {
8484
- await closedInput.catch((error) => { if (!(error instanceof PipelineClosed))
8485
- throw error; });
8486
- }
8487
- }
8488
- if (reading) {
8489
- const closedRead = reading.close();
8490
- if (!isSyncResolved(closedRead))
8491
- await closedRead;
8492
- }
8493
- if (writing) {
8494
- const closedWrite = writing.close();
8495
- if (!isSyncResolved(closedWrite))
8496
- await closedWrite;
8497
- }
8498
- if (outgoing && !writing) {
8499
- const closedOut = outgoing.close();
8500
- if (!isSyncResolved(closedOut))
8501
- await closedOut.catch(() => undefined);
8502
- }
8503
- }
8504
- return exitCode;
8505
- }
8506
- async finishFastPurePipelineUnitAsync(tasks, n, pipes, controllers, onParentAbort, onScopeSeal, scope, monitor, rawState, pipeline, state, io, ignored) {
8507
- let statuses;
8508
- try {
8509
- statuses = this.budget._hasExternalSignal
8510
- ? await interruptible(Promise.all(tasks), this.signal)
8511
- : await Promise.all(tasks);
8512
- }
8513
- finally {
8514
- scope.removeSealCallback(onScopeSeal);
8515
- removeAbortSignalWaiter(this.signal, onParentAbort);
8516
- for (let i = 0; i < n; i++) {
8517
- abortManagedController(controllers[i], SHARED_PIPELINE_CLOSED);
8518
- }
8519
- for (let i = 0; i < n - 1; i++) {
8520
- const ab = pipes[i].abort();
8521
- if (!isSyncResolved(ab))
8522
- await ab;
8523
- }
8524
- this.budget.leavePipelineStages(n);
8525
- }
8526
- const restEpoch = monitor.chargeInternal(syncRestorationCharge, syncRestorationTickets).epoch;
8527
- monitor.lazyPipeStatus = statuses;
8528
- monitor.chargeInternal(syncPipeStatusCharge, syncPipeStatusTickets);
8529
- const rawStatus = rawState.pipefail ? statuses.findLast(s => s !== 0) ?? 0 : statuses[n - 1];
8530
- const finalStatus = pipeline.negate ? Number(rawStatus === 0) : rawStatus;
8531
- rawState.status = finalStatus;
8532
- monitor.epoch = restEpoch;
8533
- if (rawStatus !== 0 && !pipeline.negate && !ignored && rawState.errexit) {
8534
- if (this.tryFinishShellSync(state))
8535
- return { exitCode: finalStatus, terminated: true };
8536
- return { exitCode: await this.finishShell(state, io, finalStatus), terminated: true };
8537
- }
8538
- return finalStatus === 0 ? SYNC_UNIT_ZERO : finalStatus === 1 ? SYNC_UNIT_ONE : { exitCode: finalStatus, terminated: false };
8539
- }
8540
8383
  async inputUnit(script, state, io, startListIndex = 0, startPipelineIndex = 0, skipFirstSync = false) {
8541
8384
  try {
8542
8385
  return await this.script(script, state, io, startListIndex, startPipelineIndex, skipFirstSync);
@@ -8551,6 +8394,7 @@ export class Runtime {
8551
8394
  }
8552
8395
  }
8553
8396
  trySyncPipeline(pipeline, state, io, ignored) {
8397
+ io = this.persistentIO(state, io);
8554
8398
  const _rawSt = (stateMonitor(state)?.raw ?? state);
8555
8399
  if ((_rawSt._syncPendingFunctionResumes?.length ?? 0) > 0 || _rawSt._syncPendingEvalResume !== undefined)
8556
8400
  return undefined;
@@ -8810,7 +8654,7 @@ export class Runtime {
8810
8654
  const uArg = wu.plain ?? (wu.parts.length === 1 && wu.parts[0].kind === "text" ? wu.parts[0].value : undefined);
8811
8655
  if (uArg !== undefined) {
8812
8656
  const br = uArg.indexOf("[");
8813
- if (br > 0 && uArg.endsWith("]") && (wu.parts[0]?.quoted || rawState.noglob || (!rawState.nullglob && this._isMemoryBackingFs && tryGetMemoryDirectoryEntryNamesSync(this.backingFs, rawState.cwd)?.size === 0))) {
8657
+ if (br > 0 && uArg.endsWith("]") && (wu.parts[0]?.quoted || rawState.noglob || (!rawState.nullglob && !rawState.failglob && this._isMemoryBackingFs && tryGetMemoryDirectoryEntryNamesSync(this.backingFs, rawState.cwd)?.size === 0))) {
8814
8658
  const arrName = uArg.slice(0, br);
8815
8659
  const subStr = uArg.slice(br + 1, -1);
8816
8660
  const b = isShellIdentifier(arrName) ? st?.get(arrName) : undefined;
@@ -9035,7 +8879,7 @@ export class Runtime {
9035
8879
  let targetOk = false;
9036
8880
  if (w2Plain !== undefined) {
9037
8881
  const br = w2Plain.indexOf("[");
9038
- if (br > 0 && w2Plain.endsWith("]") && (w2?.parts[0]?.quoted || rawState.noglob || (!rawState.nullglob && this._isMemoryBackingFs && tryGetMemoryDirectoryEntryNamesSync(this.backingFs, rawState.cwd)?.size === 0))) {
8882
+ if (br > 0 && w2Plain.endsWith("]") && (w2?.parts[0]?.quoted || rawState.noglob || (!rawState.nullglob && !rawState.failglob && this._isMemoryBackingFs && tryGetMemoryDirectoryEntryNamesSync(this.backingFs, rawState.cwd)?.size === 0))) {
9039
8883
  const arrName = w2Plain.slice(0, br);
9040
8884
  const subStr = w2Plain.slice(br + 1, -1);
9041
8885
  const b = isShellIdentifier(arrName) ? st?.get(arrName) : undefined;
@@ -10957,7 +10801,7 @@ export class Runtime {
10957
10801
  if (this.budget.limits.maxExpansionFields === Infinity && command.words.length >= 4 && w0Plain === "printf" && command.words[1]?.plain === "-v" && command.redirects.length === 0 && canMutatePipeStatus && (!pipeline.negate || ignored || !rawState.errexit) && !hasShellFunction(rawState, "printf") && !rawState.extensions?.builtins.has("printf")) {
10958
10802
  const def = this.commands.get("printf");
10959
10803
  if (def && def.execute === printfCommand.execute && command.words.length <= this.budget.maxExpansionFieldsSmi && (this.arePureArgWords(command.words, rawState) || command.words.every((w, idx) => idx < 4 ? this.isPureArgWord(w, rawState) : (this.isPureArgWord(w, rawState) || this.canSyncArrayMembersWord(w, rawState))))) {
10960
- let targetSpec = command.words[2]?.plain !== undefined && (rawState.noglob || !hasGlobOrEscape(command.words[2].plain, !!rawState.extglob) || (!rawState.nullglob && this._isMemoryBackingFs && tryGetMemoryDirectoryEntryNamesSync(this.backingFs, rawState.cwd)?.size === 0)) ? command.words[2].plain : undefined;
10804
+ let targetSpec = command.words[2]?.plain !== undefined && (rawState.noglob || !hasGlobOrEscape(command.words[2].plain, !!rawState.extglob) || (!rawState.nullglob && !rawState.failglob && this._isMemoryBackingFs && tryGetMemoryDirectoryEntryNamesSync(this.backingFs, rawState.cwd)?.size === 0)) ? command.words[2].plain : undefined;
10961
10805
  if (targetSpec === undefined) {
10962
10806
  try {
10963
10807
  targetSpec = this.fastValueWord(command.words[2], rawState, io, true, false, false, true, undefined, diagnosticLine);
@@ -12203,7 +12047,7 @@ export class Runtime {
12203
12047
  const ops = [];
12204
12048
  for (let ui = uStart; ui < command.words.length; ui++) {
12205
12049
  const wu = command.words[ui];
12206
- const canSkipGlobUnset = Boolean(wu.parts[0]?.quoted || rawState.noglob || (!rawState.nullglob && this._isMemoryBackingFs && tryGetMemoryDirectoryEntryNamesSync(this.backingFs, rawState.cwd)?.size === 0));
12050
+ const canSkipGlobUnset = Boolean(wu.parts[0]?.quoted || rawState.noglob || (!rawState.nullglob && !rawState.failglob && this._isMemoryBackingFs && tryGetMemoryDirectoryEntryNamesSync(this.backingFs, rawState.cwd)?.size === 0));
12207
12051
  let tExpanded;
12208
12052
  try {
12209
12053
  const fv = this.fastValueWord(wu, rawState, io, !canSkipGlobUnset, false, false, true, undefined, diagnosticLine);
@@ -13000,6 +12844,7 @@ export class Runtime {
13000
12844
  }
13001
12845
  }
13002
12846
  if (w0Plain === "eval" &&
12847
+ !rawState.expand_aliases &&
13003
12848
  canMutatePipeStatus &&
13004
12849
  !pipeline.negate &&
13005
12850
  !hasShellFunction(rawState, "eval") &&
@@ -13698,7 +13543,7 @@ export class Runtime {
13698
13543
  if (initializer?.kind !== "binary" || initializer.operator !== "=" || initializer.left.kind !== "name")
13699
13544
  return undefined;
13700
13545
  const induction = initializer.left.name;
13701
- const dynamicNames = new Set(["PIPESTATUS", "LINENO", "_", "FUNCNAME", "DIRSTACK", "BASH_SUBSHELL"]);
13546
+ const dynamicNames = new Set(["PIPESTATUS", "LINENO", "_", "FUNCNAME", "DIRSTACK", "BASH_SUBSHELL", "BASHPID"]);
13702
13547
  const assignments = [];
13703
13548
  const appends = new Map();
13704
13549
  for (const list of command.body.lists) {
@@ -13891,13 +13736,15 @@ export class Runtime {
13891
13736
  if (part.kind === "text") {
13892
13737
  if (part.byteValue || invokedValues.has(part))
13893
13738
  return false;
13739
+ if (!part.quoted && (part.value.includes("~") || part.value.includes("{") || hasGlobOrEscape(part.value, true)))
13740
+ return false;
13894
13741
  continue;
13895
13742
  }
13896
13743
  if (part.kind === "variable") {
13897
13744
  // Unsubscripted array references expand element zero through the normal
13898
13745
  // evaluator. fastValueWord cannot guarantee that expansion throughout
13899
13746
  // a loop, so reject it before executing any loop effects.
13900
- if (part.name === "RANDOM" || part.name === "SECONDS" || stateMonitor(rawState)?.store?.get(part.name))
13747
+ if (part.name === "RANDOM" || part.name === "SECONDS" || part.name === "BASHPID" || stateMonitor(rawState)?.store?.get(part.name))
13901
13748
  return false;
13902
13749
  // These expansions can require multiple fields or asynchronous quoting
13903
13750
  // as loop state changes. Decide before the loop produces any effects.
@@ -15961,8 +15808,8 @@ export class Runtime {
15961
15808
  rawState.status = 0;
15962
15809
  }
15963
15810
  runYieldCheckpoint(this.signal);
15964
- for (let r = 0; r < regNames.length; r++) {
15965
- rawState.variables[regNames[r]] = intToStr(sharedLoopIntRegs[r]);
15811
+ for (const name of touchedIntNamesList) {
15812
+ rawState.variables[name] = intToStr(sharedLoopIntRegs[regNames.indexOf(name)]);
15966
15813
  }
15967
15814
  regNames.length = 0;
15968
15815
  if (hasDeferredSteps && lastInductionInt !== undefined)
@@ -17519,9 +17366,9 @@ export class Runtime {
17519
17366
  encoded = encoded.slice();
17520
17367
  if (step.targetDirPrefix !== undefined && step.targetNamePrefix !== undefined) {
17521
17368
  const fileName = this.evalSyncRedirectSuffix(step.targetWord, step.targetDirPrefix, step.targetNamePrefix, rawState, io);
17522
- if (tryWriteMemoryFileInDirSync(this.backingFs, step.targetDirPrefix, fileName, encoded, append, mode, this.commandSignal))
17369
+ if (!fileName.includes("/") && fileName !== "." && fileName !== ".." && tryWriteMemoryFileInDirSync(this.backingFs, step.targetDirPrefix, fileName, encoded, append, mode, this.commandSignal))
17523
17370
  return;
17524
- tryWriteMemoryFileSync(this.backingFs, step.targetDirPrefix + fileName, encoded, append, mode, this.commandSignal);
17371
+ tryWriteMemoryFileSync(this.backingFs, normalizePath(step.targetDirPrefix + fileName, rawState.cwd), encoded, append, mode, this.commandSignal);
17525
17372
  return;
17526
17373
  }
17527
17374
  const targetVal = this.evalSyncRedirectWord(step.targetWord, rawState, io);
@@ -18157,6 +18004,7 @@ export class Runtime {
18157
18004
  }
18158
18005
  const firstIndex = listIndex === startListIndex ? startPipelineIndex : 0;
18159
18006
  for (let index = firstIndex; index < list.pipelines.length; index++) {
18007
+ io = this.persistentIO(state, io);
18160
18008
  if (state.noexec)
18161
18009
  throw new Flow("discard", 0);
18162
18010
  const operator = index > 0 ? list.operators[index - 1] : undefined;
@@ -18375,6 +18223,7 @@ export class Runtime {
18375
18223
  void installation.catch(() => undefined);
18376
18224
  }
18377
18225
  const tasks = pipeline.commands.map(async (command, index) => {
18226
+ const inCurrentShell = !!state.lastpipe && index === pipeline.commands.length - 1;
18378
18227
  let admitted = false;
18379
18228
  const admit = () => {
18380
18229
  if (admitted)
@@ -18410,7 +18259,7 @@ export class Runtime {
18410
18259
  let stageOwnsCleanup = false;
18411
18260
  try {
18412
18261
  const rawStateForChild = stateMonitor(state)?.raw ?? state;
18413
- const isPureStage = !terminal && !(io.descriptors && (io.descriptors.size > 3 || io.descriptors.get(0)?.closed || io.descriptors.get(1)?.closed || io.descriptors.get(2)?.closed)) && runtime.isPureExternalStageCommand(command, rawStateForChild);
18262
+ const isPureStage = !inCurrentShell && !terminal && !(io.descriptors && (io.descriptors.size > 3 || io.descriptors.get(0)?.closed || io.descriptors.get(1)?.closed || io.descriptors.get(2)?.closed)) && runtime.isPureExternalStageCommand(command, rawStateForChild);
18414
18263
  const references = isPureStage ? undefined : (cleanupRefs = new PipeDescriptorFrame(io[invocationScope]));
18415
18264
  const descriptorFrame = isPureStage ? undefined : (cleanupDescFrame = new PreparedDescriptorFrame(references, this.budget));
18416
18265
  const reading = incoming?.endpoints?.read;
@@ -18434,14 +18283,15 @@ export class Runtime {
18434
18283
  try {
18435
18284
  const isFastPure = isPureStage || runtime.isPureExternalStageCommand(command, rawStateForChild);
18436
18285
  const forkedExt = isFastPure ? forkExtensions(state.extensions, "pipeline") : undefined;
18437
- const child = isFastPure
18286
+ const child = inCurrentShell ? state : isFastPure
18438
18287
  ? Object.assign(cloneRawState(rawStateForChild, false), {
18439
18288
  extensions: forkedExt, isolated: true, _readOnlyStage: true,
18440
18289
  })
18441
18290
  : (tryCloneStateSync(state) ?? await cloneState(state, this.signal));
18442
- preparedChild = child;
18443
- child.variables.BASH_SUBSHELL = String(Number(state.variables.BASH_SUBSHELL ?? 0) + 1);
18444
- if (!child._readOnlyStage) {
18291
+ preparedChild = inCurrentShell ? undefined : child;
18292
+ if (!inCurrentShell)
18293
+ child.variables.BASH_SUBSHELL = String(Number(state.variables.BASH_SUBSHELL ?? 0) + 1);
18294
+ if (!inCurrentShell && !child._readOnlyStage) {
18445
18295
  child.extensions = undefined;
18446
18296
  child.extensions = forkExtensions(state.extensions, "pipeline");
18447
18297
  child.isolated = true;
@@ -18472,7 +18322,9 @@ export class Runtime {
18472
18322
  await installation;
18473
18323
  signal.throwIfAborted();
18474
18324
  }
18475
- const work = runtime.runPipelineStageWork(command, child, childIO, io, reason => { checkpointFailure = reason; });
18325
+ const work = inCurrentShell
18326
+ ? runtime.command(command, child, { ...childIO, terminal: undefined })
18327
+ : runtime.runPipelineStageWork(command, child, childIO, io, reason => { checkpointFailure = reason; });
18476
18328
  preparedChild = undefined;
18477
18329
  started = true;
18478
18330
  retain(work);
@@ -18822,6 +18674,7 @@ export class Runtime {
18822
18674
  return status;
18823
18675
  }
18824
18676
  async executeCommand(command, state, originalIO, fileShortcut = false) {
18677
+ originalIO = this.persistentIO(state, originalIO);
18825
18678
  const terminal = originalIO.terminal?.target === command ? originalIO.terminal : undefined;
18826
18679
  if (!state._readOnlyStage)
18827
18680
  state = trackState(state, this.budget, originalIO[invocationScope]);
@@ -19186,6 +19039,20 @@ export class Runtime {
19186
19039
  let diagnosticFailure;
19187
19040
  let outputTracker;
19188
19041
  const snapshotHolder = {};
19042
+ const execState = stateMonitor(state)?.raw ?? state;
19043
+ const savedExecDescriptors = new Map();
19044
+ if (command.redirects.length) {
19045
+ const frame = execDescriptorFrames.get(execState);
19046
+ for (const redirect of command.redirects) {
19047
+ for (const number of redirect.operator === "&>" || redirect.operator === "&>>" ? [1, 2] : [redirect.descriptor]) {
19048
+ if (savedExecDescriptors.has(number))
19049
+ continue;
19050
+ const descriptor = originalIO.descriptors?.get(number)
19051
+ ?? (number === 0 ? { input: originalIO.stdin } : number === 1 ? { output: originalIO.stdout } : number === 2 ? { output: originalIO.stderr } : { closed: true });
19052
+ savedExecDescriptors.set(number, { descriptor, revision: frame?.revisions.get(number), release: descriptor.lifetime?.acquire() });
19053
+ }
19054
+ }
19055
+ }
19189
19056
  try {
19190
19057
  let status = 0;
19191
19058
  if (command.kind === "simple") {
@@ -19221,15 +19088,38 @@ export class Runtime {
19221
19088
  }
19222
19089
  finally {
19223
19090
  try {
19224
- if (!references && outputs.size === 0 && inputs.size === 0 && processSubstitutions.length === 0)
19225
- allocation.close();
19226
- else
19227
- await this.cleanupCommandResources(references, outputs, inputs, processSubstitutions, allocation, diagnosticFailure, io);
19091
+ const frame = execDescriptorFrames.get(execState);
19092
+ const retirements = [];
19093
+ for (const [number, saved] of savedExecDescriptors) {
19094
+ if (frame && !snapshotHolder.persistentRedirects && frame.revisions.get(number) !== saved.revision) {
19095
+ const release = frame.releases.get(number);
19096
+ if (saved.release)
19097
+ frame.releases.set(number, saved.release);
19098
+ else
19099
+ frame.releases.delete(number);
19100
+ frame.descriptors.set(number, saved.descriptor);
19101
+ frame.revisions.set(number, ++frame.version);
19102
+ if (release)
19103
+ retirements.push(release());
19104
+ }
19105
+ else if (saved.release)
19106
+ retirements.push(saved.release());
19107
+ }
19108
+ const retired = await Promise.allSettled(retirements);
19109
+ throwCleanupFailures(retired.filter(result => result.status === "rejected").map(result => result.reason));
19228
19110
  }
19229
19111
  finally {
19230
- snapshotHolder.finish?.();
19231
- if (snapshotHolder.scope)
19232
- await snapshotHolder.scope.close();
19112
+ try {
19113
+ if (!references && outputs.size === 0 && inputs.size === 0 && processSubstitutions.length === 0)
19114
+ allocation.close();
19115
+ else
19116
+ await this.cleanupCommandResources(references, outputs, inputs, processSubstitutions, allocation, diagnosticFailure, io);
19117
+ }
19118
+ finally {
19119
+ snapshotHolder.finish?.();
19120
+ if (snapshotHolder.scope)
19121
+ await snapshotHolder.scope.close();
19122
+ }
19233
19123
  }
19234
19124
  }
19235
19125
  }
@@ -19459,8 +19349,7 @@ export class Runtime {
19459
19349
  }
19460
19350
  if (!matched)
19461
19351
  continue;
19462
- if (clause.body.lists.length)
19463
- status = await this.script(clause.body, state, io);
19352
+ status = clause.body.lists.length ? await this.script(clause.body, state, io) : 0;
19464
19353
  if (clause.terminator === ";;" || clause.terminator === "esac")
19465
19354
  break;
19466
19355
  fallthrough = clause.terminator === ";&";
@@ -19486,8 +19375,7 @@ export class Runtime {
19486
19375
  }
19487
19376
  if (!matched)
19488
19377
  continue;
19489
- if (clause.body.lists.length)
19490
- status = await this.script(clause.body, state, io);
19378
+ status = clause.body.lists.length ? await this.script(clause.body, state, io) : 0;
19491
19379
  if (clause.terminator === ";;" || clause.terminator === "esac")
19492
19380
  break;
19493
19381
  fallthrough = clause.terminator === ";&";
@@ -19818,6 +19706,8 @@ export class Runtime {
19818
19706
  publicDiagnosticMessage(failure, this.budget.onInternalError);
19819
19707
  }
19820
19708
  }
19709
+ if (error instanceof FailglobFailure)
19710
+ throw completedExit(1, state.errexit ? "exit" : "discard");
19821
19711
  if (error instanceof ExpansionFailure || error instanceof BraceExpansionFailure)
19822
19712
  throw completedExit(error instanceof ParameterExpansionFailure && !state.isolated ? 127 : 1);
19823
19713
  if (error instanceof FatalCommandFailure)
@@ -19936,6 +19826,8 @@ export class Runtime {
19936
19826
  const descriptor = descriptors.get(0)?.closed ? undefined : descriptors.get(0);
19937
19827
  const stdinIsDefault = descriptor?.input ? descriptor.stdinIsDefault : false;
19938
19828
  return {
19829
+ ...(io.execVersion === undefined ? {} : { execVersion: io.execVersion }),
19830
+ ...(io.execFrame === undefined ? {} : { execFrame: io.execFrame }),
19939
19831
  capabilities: io.capabilities, ...(io.argv0 === undefined ? {} : { argv0: io.argv0 }), [invocationScope]: io[invocationScope], ...(io.admittedHandles === undefined ? {} : { admittedHandles: io.admittedHandles }), ...(io.processSignals === undefined ? {} : { processSignals: io.processSignals }), ...(io[valueScope] === undefined ? {} : { [valueScope]: io[valueScope] }), ...(io.execution === undefined ? {} : { execution: io.execution }), ...(io.diagnosticLine === undefined ? {} : { diagnosticLine: io.diagnosticLine }), ...(io.diagnosticOffset === undefined ? {} : { diagnosticOffset: io.diagnosticOffset }), ...(io.assignmentDiagnosticContext === undefined ? {} : { assignmentDiagnosticContext: io.assignmentDiagnosticContext }), ...(io.functionCommandLines === undefined ? {} : { functionCommandLines: io.functionCommandLines }), ...(io.diagnosticCommandLines === undefined ? {} : { diagnosticCommandLines: io.diagnosticCommandLines }), ...(io.scriptName === undefined ? {} : { scriptName: io.scriptName }), ...(io.substitutionDiagnosticLine === undefined ? {} : { substitutionDiagnosticLine: io.substitutionDiagnosticLine }), ...(io.substitutionDiagnosticLines === undefined ? {} : { substitutionDiagnosticLines: io.substitutionDiagnosticLines }), ...(io.processSubstitutions === undefined ? {} : { processSubstitutions: io.processSubstitutions }), stdin: descriptor?.input ?? closedSource, ...(stdinIsDefault === undefined ? {} : { stdinIsDefault }), stdout: descriptors.get(1)?.closed ? closedSink : descriptors.get(1)?.output ?? closedSink, stderr: descriptors.get(2)?.closed ? closedSink : descriptors.get(2)?.output ?? closedSink, descriptors,
19940
19832
  };
19941
19833
  };
@@ -20067,7 +19959,19 @@ export class Runtime {
20067
19959
  }
20068
19960
  else {
20069
19961
  const append = redirect.operator === ">>" || redirect.operator === "&>>";
20070
- const flag = append ? "a" : state.noclobber && redirect.operator !== ">|" ? "wx" : "w";
19962
+ let flag = append ? "a" : state.noclobber && redirect.operator !== ">|" ? "wx" : "w";
19963
+ if (flag === "wx") {
19964
+ try {
19965
+ const stat = await resourceFs.stat(path, options);
19966
+ if (stat.type !== "file" && stat.type !== "directory")
19967
+ flag = "w";
19968
+ }
19969
+ catch (error) {
19970
+ this.signal.throwIfAborted();
19971
+ if (!(error instanceof FsError) || error.code !== "ENOENT")
19972
+ throw error;
19973
+ }
19974
+ }
20071
19975
  const capabilities = await this.fs.capabilitiesFor?.(path, { ...options, ...(flag === "wx" ? { creation: "exclusive" } : {}) }) ?? this.fs.capabilities;
20072
19976
  const streaming = capabilities.preferStreamingRedirection === true && typeof this.fs.writeStream === "function"
20073
19977
  && (append ? capabilities.streamingAppend ?? capabilities.streamingWrite : capabilities.streamingWrite) === true;
@@ -20561,6 +20465,31 @@ export class Runtime {
20561
20465
  }
20562
20466
  if (!words.length)
20563
20467
  return state.substitutionStatus;
20468
+ if (words[declarationIndex] === "exec" && !functionCommand && !state.extensions?.builtins.has("exec")) {
20469
+ snapshotHolder.persistentRedirects = true;
20470
+ const raw = stateMonitor(state)?.raw ?? state;
20471
+ let frame = execDescriptorFrames.get(raw);
20472
+ if (!frame) {
20473
+ frame = { version: 0, descriptors: new Map(), revisions: new Map(), releases: new Map() };
20474
+ execDescriptorFrames.set(raw, frame);
20475
+ this.budget.executionCleanup.register(() => closeExecDescriptors(raw));
20476
+ }
20477
+ for (const redirect of command.redirects) {
20478
+ const numbers = redirect.operator === "&>" || redirect.operator === "&>>" ? [1, 2] : [redirect.descriptor];
20479
+ for (const number of numbers) {
20480
+ const descriptor = io.descriptors?.get(number) ?? { closed: true };
20481
+ const release = descriptor.lifetime?.acquire();
20482
+ const previousRelease = frame.releases.get(number);
20483
+ if (release)
20484
+ frame.releases.set(number, release);
20485
+ else
20486
+ frame.releases.delete(number);
20487
+ frame.descriptors.set(number, descriptor);
20488
+ frame.revisions.set(number, ++frame.version);
20489
+ await previousRelease?.();
20490
+ }
20491
+ }
20492
+ }
20564
20493
  const args = words.slice(1);
20565
20494
  const argValues = allStrings ? args : wordValues.slice(1);
20566
20495
  const dispatchIO = compounds ? { ...io, [declarationArrays]: compounds } : io;
@@ -20701,7 +20630,7 @@ export class Runtime {
20701
20630
  env[`BASH_FUNC_${key}%%`] = functionDisplay(key, body).slice(key.length + 1).trimEnd();
20702
20631
  }
20703
20632
  }
20704
- const context = new FastShellCommandContext(this, state, io, scope, name, values, undefined, env, this._isMemoryBackingFs);
20633
+ const context = new FastShellCommandContext(this, state, io, scope, name, values, undefined, env, this._isMemoryBackingFs, definition);
20705
20634
  const runtimeFrame = {};
20706
20635
  scope.enterWork();
20707
20636
  this.budget.beginPathLookupSuspension();
@@ -21442,6 +21371,37 @@ export class Runtime {
21442
21371
  state.lastArgument = context.args.at(-1) ?? context.command;
21443
21372
  return { exitCode };
21444
21373
  }
21374
+ if (context.command === "exec") {
21375
+ let execIdx = 0;
21376
+ while (execIdx < context.args.length) {
21377
+ const f = context.args[execIdx];
21378
+ if (f === "--") {
21379
+ execIdx += 1;
21380
+ break;
21381
+ }
21382
+ if (f === "-a" && execIdx + 1 < context.args.length) {
21383
+ execIdx += 2;
21384
+ continue;
21385
+ }
21386
+ if (f === "-c" || f === "-l") {
21387
+ execIdx += 1;
21388
+ continue;
21389
+ }
21390
+ break;
21391
+ }
21392
+ const execRest = context.args.slice(execIdx);
21393
+ const execCmd = execRest[0];
21394
+ if (execCmd === undefined) {
21395
+ return { exitCode: 0 };
21396
+ }
21397
+ const execArgs = execRest.slice(1);
21398
+ const status = await this.dispatch(execCmd, execArgs, state, { ...io, ...context }, assignments, true, context.argumentValues.values.slice(execIdx + 1));
21399
+ throw completedExit(status, "exit");
21400
+ }
21401
+ if (context.command === "read" && context.args.some(arg => arg.startsWith("-") && (arg.includes("u") || arg.includes("t")))) {
21402
+ const { executeRead } = await import("./read-builtin.js");
21403
+ return { exitCode: await executeRead(true, this.extensionContext(state, { ...io, ...context }, context.command, context.args, context.argumentValues.values)) };
21404
+ }
21445
21405
  const builtinWork = this.builtin({ ...context, [declarationArrays]: io[declarationArrays] }, state, assignments, (error, diagnostic) => { builtinFailure = { error, diagnostic }; }, bypassFunctions);
21446
21406
  const builtin = await interruptible(builtinWork, this.signal);
21447
21407
  if (builtin !== undefined) {
@@ -21875,7 +21835,7 @@ export class Runtime {
21875
21835
  try {
21876
21836
  do {
21877
21837
  this.signal.throwIfAborted();
21878
- const unit = parseShellUnit(source, position, byteLocale(state.variables), this.budget.parsing, lineIndex, undefined, false, state.extensions?.syntax);
21838
+ const unit = parseShellUnit(source, position, byteLocale(state.variables), this.budget.parsing, lineIndex, undefined, false, state.extensions?.syntax, state.expand_aliases ? state.aliases : undefined);
21879
21839
  for (const warning of unit.script.warnings ?? [])
21880
21840
  await writeDiagnostic(io.stderr, `${io.scriptName}: warning: ${warning}\n`);
21881
21841
  if (unit.script.lists.length) {
@@ -21922,7 +21882,7 @@ export class Runtime {
21922
21882
  }
21923
21883
  const unitIO = { ...io, diagnosticOffset: offset };
21924
21884
  try {
21925
- const unit = eof ? parseShellUnit(source, 0, byteLocale(state.variables), this.budget.parsing, lineIndex, undefined, false, state.extensions?.syntax) : parseShellInputUnit(source, byteLocale(state.variables), this.budget.parsing, lineIndex, state.extensions?.syntax);
21885
+ const unit = eof ? parseShellUnit(source, 0, byteLocale(state.variables), this.budget.parsing, lineIndex, undefined, false, state.extensions?.syntax, state.expand_aliases ? state.aliases : undefined) : parseShellInputUnit(source, byteLocale(state.variables), this.budget.parsing, lineIndex, state.extensions?.syntax, state.expand_aliases ? state.aliases : undefined);
21926
21886
  if (unit) {
21927
21887
  for (const warning of unit.script.warnings ?? [])
21928
21888
  await writeDiagnostic(io.stderr, `${io.scriptName}: warning: ${warning}\n`);
@@ -22158,8 +22118,10 @@ export class Runtime {
22158
22118
  else {
22159
22119
  const options = { signal: this.signal };
22160
22120
  const stat = await interruptible(this.fs.stat(path, options), this.signal);
22161
- if (stat.type !== "file")
22162
- throw new CommandFailure(`${target}: ${stat.type === "directory" ? "Is a directory" : "not a regular file"}`, 126);
22121
+ if (stat.type === "directory")
22122
+ throw new CommandFailure(`${target}: Is a directory`, 126);
22123
+ if (stat.type !== "file" && (direct || (stat.type !== "character" && stat.type !== "fifo")))
22124
+ throw new CommandFailure(`${target}: not a regular file`, 126);
22163
22125
  if (direct) {
22164
22126
  const capabilities = this.fs.capabilitiesFor
22165
22127
  ? await interruptible(this.fs.capabilitiesFor(path, options), this.signal) : this.fs.capabilities;
@@ -22241,7 +22203,7 @@ export class Runtime {
22241
22203
  this.signal.throwIfAborted();
22242
22204
  let unit;
22243
22205
  try {
22244
- unit = parseShellUnit(source, position, byteLocale(child.variables), this.budget.parsing, lineIndex, undefined, false, child.extensions?.syntax);
22206
+ unit = parseShellUnit(source, position, byteLocale(child.variables), this.budget.parsing, lineIndex, undefined, false, child.extensions?.syntax, child.expand_aliases ? child.aliases : undefined);
22245
22207
  }
22246
22208
  catch (error) {
22247
22209
  if (!(error instanceof ShellSyntaxError))
@@ -22267,7 +22229,7 @@ export class Runtime {
22267
22229
  }
22268
22230
  }
22269
22231
  async runCurrentText(source, state, io, fatalSyntax, syntaxName, byteSource = false, includeSyntaxContext = true, sourceValues) {
22270
- if (!sourceValues && !byteSource && isDefaultShellSyntax(state.extensions?.syntax) && source.length <= 4096) {
22232
+ if (!state.expand_aliases && !sourceValues && !byteSource && isDefaultShellSyntax(state.extensions?.syntax) && source.length <= 4096) {
22271
22233
  try {
22272
22234
  const cachedUnit = getOrParseSingleEvalUnit(source, byteLocale(state.variables), this.budget.parsing);
22273
22235
  if (cachedUnit) {
@@ -22298,7 +22260,7 @@ export class Runtime {
22298
22260
  try {
22299
22261
  do {
22300
22262
  this.signal.throwIfAborted();
22301
- const unit = parseShellUnit(source, position, byteLocale(state.variables), this.budget.parsing, lineIndex, sourceValues, byteSource, state.extensions?.syntax);
22263
+ const unit = parseShellUnit(source, position, byteLocale(state.variables), this.budget.parsing, lineIndex, sourceValues, byteSource, state.extensions?.syntax, state.expand_aliases ? state.aliases : undefined);
22302
22264
  for (const warning of unit.script.warnings ?? [])
22303
22265
  await writeDiagnostic(io.stderr, `${io.scriptName ?? "shell"}: warning: ${warning}\n`);
22304
22266
  if (unit.script.lists.length) {
@@ -22421,7 +22383,7 @@ export class Runtime {
22421
22383
  const stat = await interruptible(this.fs.stat(path, options), this.signal);
22422
22384
  if (stat.type === "directory")
22423
22385
  throw new CommandFailure(`${context.command}: ${target}: is a directory`, 1);
22424
- if (stat.type !== "file")
22386
+ if (stat.type !== "file" && stat.type !== "character" && stat.type !== "fifo")
22425
22387
  throw new CommandFailure(`${target}: not a regular file`, 1);
22426
22388
  await interruptible(this.fs.access(path, ACCESS_MODES.R_OK, options), this.signal);
22427
22389
  const maxBytes = this.budget.limits.maxSourceBytes - this.budget.sourceBytes;
@@ -23163,7 +23125,7 @@ export class Runtime {
23163
23125
  return 1;
23164
23126
  }
23165
23127
  const options = new Map();
23166
- for (const name of setNamespace ? ["allexport", "braceexpand", "errexit", "noclobber", "noexec", "noglob", "nounset", "pipefail"] : ["dotglob", "extglob", "globstar", "nocaseglob", "nocasematch", "nullglob"]) {
23128
+ for (const name of setNamespace ? ["allexport", "braceexpand", "errexit", "noclobber", "noexec", "noglob", "nounset", "pipefail"] : ["dotglob", "expand_aliases", "extglob", "failglob", "globstar", "inherit_errexit", "lastpipe", "nocaseglob", "nocasematch", "nullglob"]) {
23167
23129
  options.set(name, {
23168
23130
  get enabled() { return name === "braceexpand" ? state.braceexpand !== false : !!state[name]; }, set enabled(value) { state[name] = value; },
23169
23131
  });
@@ -23633,6 +23595,12 @@ export class Runtime {
23633
23595
  }
23634
23596
  if (command === "shopt")
23635
23597
  return this.shoptBuiltin(context, state);
23598
+ if (command === "alias" || command === "unalias") {
23599
+ const aliases = state.aliases ??= new Map();
23600
+ const limits = { maxArgumentBytes: this.budget.limits.maxExpansionBytes, maxAliasBytes: this.budget.limits.maxExpansionBytes };
23601
+ const definition = command === "alias" ? createAliasCommand({ aliases, limits }) : createUnaliasCommand({ aliases, limits });
23602
+ return (await definition.execute(context)).exitCode;
23603
+ }
23636
23604
  if (command === "let")
23637
23605
  return this.letBuiltin(context, state);
23638
23606
  if (command === "mapfile" || command === "readarray")
@@ -24645,6 +24613,8 @@ export class Runtime {
24645
24613
  }
24646
24614
  if (command === "break" || command === "continue") {
24647
24615
  if (!state.loopDepth) {
24616
+ if (state._subshellInLoop)
24617
+ throw completedExit(0, command, 1);
24648
24618
  await writeDiagnostic(stderr, `${command}: only meaningful in a loop\n`);
24649
24619
  return 0;
24650
24620
  }
@@ -24881,7 +24851,7 @@ export class Runtime {
24881
24851
  if (operator === "+" ? !missing : missing) {
24882
24852
  if (operator === "=")
24883
24853
  throw new ArrayFailure(`${part.name}[${memberSelector.separator}]: bad array subscript`);
24884
- const alternate = concatShellValues(await this.valueWord(part.alternate, state, this.parameterOperandIO(part.alternate, state, io), false, false, hereString, false, undefined, hereDocument), io[valueScope]);
24854
+ const alternate = concatShellValues(await this.valueWord(part.alternate, state, this.parameterOperandIO(part.alternate, state, io), false, false, hereString, false, undefined, hereDocument || part.quoted), io[valueScope]);
24885
24855
  if (operator === "?")
24886
24856
  throw new ParameterExpansionFailure(`${part.name}: ${shellValueText(alternate) || "parameter not set"}`, io.diagnosticLine ?? part.line);
24887
24857
  return alternate;
@@ -24905,12 +24875,13 @@ export class Runtime {
24905
24875
  if (operator === "+" ? !missing : missing) {
24906
24876
  const operandIO = this.parameterOperandIO(part.alternate, state, io);
24907
24877
  if (operator === "=") {
24908
- await this.arrayAssignment({ kind: "element", name: part.name, index: element.index, append: false, value: part.alternate }, state, operandIO);
24878
+ const elemAlt = part.quoted ? { ...part.alternate, parts: part.alternate.parts.map(p => ({ ...p, quoted: true })) } : part.alternate;
24879
+ await this.arrayAssignment({ kind: "element", name: part.name, index: element.index, append: false, value: elemAlt }, state, operandIO);
24909
24880
  const assigned = store.get(part.name);
24910
24881
  const assignedIndex = assigned.associative ? await this.arrayIndex(assigned, element.index, state, io, store.owner) : index;
24911
24882
  return assignedIndex === undefined ? "" : assigned.getValue(assignedIndex) ?? "";
24912
24883
  }
24913
- const alternate = concatShellValues(await this.valueWord(part.alternate, state, operandIO, false, false, hereString, false, undefined, hereDocument), io[valueScope]);
24884
+ const alternate = concatShellValues(await this.valueWord(part.alternate, state, operandIO, false, false, hereString, false, undefined, hereDocument || part.quoted), io[valueScope]);
24914
24885
  if (operator === "?")
24915
24886
  throw new ParameterExpansionFailure(`${part.name}: ${shellValueText(alternate) || (part.operator.startsWith(":") ? "parameter null or not set" : "parameter not set")}`, io.diagnosticLine ?? part.line);
24916
24887
  return alternate;
@@ -25157,13 +25128,32 @@ export class Runtime {
25157
25128
  if (state.depth >= this.budget.limits.maxSubstitutionDepth)
25158
25129
  this.budget.fail("maxSubstitutionDepth");
25159
25130
  this.signal.throwIfAborted();
25160
- const tempPath = `/.procsub-${++nextProcessSubstitutionId}`;
25131
+ const ids = state.processSubstitutionIds ??= { next: 0 };
25132
+ const requestedDirectory = pathOf(state, state.variables.TMPDIR || "/tmp");
25133
+ const directory = requestedDirectory === "/" ? "/tmp" : requestedDirectory;
25134
+ await this.sourceFs.mkdir(directory, { recursive: true, signal: this.signal });
25135
+ let tempPath = "";
25136
+ let owned = false;
25161
25137
  io[invocationScope].register(async () => {
25138
+ if (owned)
25139
+ try {
25140
+ await this.sourceFs.rm(tempPath, { force: true });
25141
+ }
25142
+ catch { }
25143
+ });
25144
+ while (!owned) {
25145
+ this.budget.tick();
25146
+ tempPath = pathOf(state, `${directory}/.procsub-${++ids.next}`);
25162
25147
  try {
25163
- await this.sourceFs.rm(tempPath, { force: true });
25148
+ await this.sourceFs.writeFile(tempPath, new Uint8Array(0), { flag: "wx", signal: this.signal });
25149
+ owned = true;
25164
25150
  }
25165
- catch { }
25166
- });
25151
+ catch (error) {
25152
+ this.signal.throwIfAborted();
25153
+ if (!(error instanceof FsError) || error.code !== "EEXIST")
25154
+ throw error;
25155
+ }
25156
+ }
25167
25157
  if (part.direction === "<") {
25168
25158
  const capture = new Capture();
25169
25159
  const child = await cloneState(state, this.signal);
@@ -25174,7 +25164,6 @@ export class Runtime {
25174
25164
  child.errexit = false;
25175
25165
  delete child.redirectAssignments;
25176
25166
  child.depth++;
25177
- child.loopDepth = 0;
25178
25167
  const references = new PipeDescriptorFrame(io[invocationScope]);
25179
25168
  const lifetime = new DescriptorLifetime();
25180
25169
  const captureIO = isolateIO({
@@ -25228,7 +25217,6 @@ export class Runtime {
25228
25217
  child.errexit = false;
25229
25218
  delete child.redirectAssignments;
25230
25219
  child.depth++;
25231
- child.loopDepth = 0;
25232
25220
  const prepared = prepareBytesInput(bytes, this.budget);
25233
25221
  const input = new ShellInput(prepared.source, this.budget, this.commandSignal, prepared.options);
25234
25222
  const lifetime = new DescriptorLifetime(async () => {
@@ -25278,7 +25266,7 @@ export class Runtime {
25278
25266
  child.isolated = true;
25279
25267
  child.variables.BASH_SUBSHELL = String(Number(state.variables.BASH_SUBSHELL ?? 0) + 1);
25280
25268
  child.extensions = forkExtensions(state.extensions, "substitution");
25281
- if (state.profile !== "sh")
25269
+ if (state.profile !== "sh" && !state.inherit_errexit)
25282
25270
  child.errexit = false;
25283
25271
  for (const [name, value] of state.redirectAssignments ?? []) {
25284
25272
  await this.writeVariable(child, name, value, io);
@@ -25286,7 +25274,6 @@ export class Runtime {
25286
25274
  }
25287
25275
  delete child.redirectAssignments;
25288
25276
  child.depth++;
25289
- child.loopDepth = 0;
25290
25277
  const pipeline = part.script.lists.length === 1 && part.script.lists[0].pipelines.length === 1 ? part.script.lists[0].pipelines[0] : undefined;
25291
25278
  const command = pipeline && !pipeline.negate && pipeline.commands.length === 1 ? pipeline.commands[0] : undefined;
25292
25279
  const fileShortcut = command?.kind === "simple" && command.words.length === 0 && command.redirects.length === 1 && command.redirects[0].operator === "<";
@@ -25429,16 +25416,19 @@ export class Runtime {
25429
25416
  if ((operator === "+" && !missing) || (operator !== "+" && missing)) {
25430
25417
  const operandIO = this.parameterOperandIO(part.alternate, state, io);
25431
25418
  let alternate;
25419
+ const altWord = !hereDocument && !part.quoted && operator === "="
25420
+ ? { ...part.alternate, parts: expandTildes(part.alternate.parts, state.variables, this.budget, undefined, true) }
25421
+ : part.alternate;
25432
25422
  if (operator === "=" && arrayStore(state)?.get(part.name)) {
25433
25423
  alternate = "";
25434
25424
  await this.arrayZero(state, part.name, io, async () => {
25435
- retained = await this.arrayJoin(requireArrays(state).owner, await this.valueWord(part.alternate, state, operandIO, false, false, hereString, false, undefined, hereDocument), "");
25425
+ retained = await this.arrayJoin(requireArrays(state).owner, await this.valueWord(altWord, state, operandIO, false, false, hereString, false, undefined, hereDocument || part.quoted || operator === "="), "");
25436
25426
  return retained;
25437
25427
  });
25438
25428
  value = shellValueText(retained);
25439
25429
  return part.length ? this.valueLength(retained, state, io) : retained;
25440
25430
  }
25441
- retained = concatShellValues(await this.valueWord(part.alternate, state, operandIO, false, false, hereString, false, undefined, hereDocument), io[valueScope]);
25431
+ retained = concatShellValues(await this.valueWord(altWord, state, operandIO, false, false, hereString, false, undefined, hereDocument || part.quoted || operator === "="), io[valueScope]);
25442
25432
  alternate = shellValueText(retained);
25443
25433
  if (operator === "?")
25444
25434
  throw new ParameterExpansionFailure(`${part.name}: ${alternate || (part.operator.startsWith(":") ? "parameter null or not set" : "parameter not set")}`, io.diagnosticLine ?? part.line);
@@ -26023,7 +26013,7 @@ export class Runtime {
26023
26013
  }
26024
26014
  if (part.indirect || part.specialParameter)
26025
26015
  return undefined;
26026
- if (part.name === "@" || part.name === "*" || part.name === "PIPESTATUS" || part.name === "LINENO" || part.name === "BASH_SUBSHELL" || part.name === "_" || part.name === "FUNCNAME" || part.name === "DIRSTACK")
26016
+ if (part.name === "@" || part.name === "*" || part.name === "PIPESTATUS" || part.name === "LINENO" || part.name === "BASH_SUBSHELL" || part.name === "BASHPID" || part.name === "_" || part.name === "FUNCNAME" || part.name === "DIRSTACK")
26027
26017
  return undefined;
26028
26018
  if (!isShellIdentifier(part.name))
26029
26019
  return undefined;
@@ -35462,7 +35452,7 @@ export class Runtime {
35462
35452
  if (p.kind === "text")
35463
35453
  continue;
35464
35454
  if (p.kind === "variable") {
35465
- if (p.name === "BASH_SUBSHELL" || p.name === "RANDOM" || p.name === "SECONDS")
35455
+ if (p.name === "BASH_SUBSHELL" || p.name === "BASHPID" || p.name === "RANDOM" || p.name === "SECONDS")
35466
35456
  return false;
35467
35457
  if (!p.indirect && !p.prefixNames && !p.length && !p.substring && !p.transform && p.operator === undefined && getArraySelector(p) === undefined && (p.name === "?" || p.name === "#" || (p.name.length === 1 && p.name >= "1" && p.name <= "9"))) {
35468
35458
  const activePos = this._fastSubPositional ?? rawState.positional;
@@ -35946,8 +35936,6 @@ export class Runtime {
35946
35936
  syncPurePipelineSlotInUse = true;
35947
35937
  this.budget.enterPipelineStages(n);
35948
35938
  this.budget.commands += n;
35949
- const scope = io[invocationScope];
35950
- let context = pooledSyncPipeContext;
35951
35939
  let prevBuf = sharedSyncPipeBuf0;
35952
35940
  let prevLen = fastSharedTextEncoder.encodeInto(stage0Formatted, sharedSyncPipeBuf0).written;
35953
35941
  try {
@@ -37034,35 +37022,9 @@ export class Runtime {
37034
37022
  prevLen = written;
37035
37023
  continue;
37036
37024
  }
37037
- sharedSyncPipeReader.reset(prevBuf, prevLen, this.signal, -1);
37038
- sharedSyncPipeWriter.reset(this.budget, this.signal, nextBuf, -1);
37039
- if (!context) {
37040
- context = new FastShellCommandContext(this, rawState, io, scope, firstName, stageArgs, undefined, undefined, true);
37041
- pooledSyncPipeContext = context;
37042
- }
37043
- context.resetDirectStage(this, rawState, io, scope, firstName, stageArgs, sharedSyncPipeReader, false, sharedSyncPipeWriter, this.signal);
37044
- sharedSyncPipeReader.abortSignal = context.signal;
37045
- scope.enterWork();
37046
- this.budget.beginPathLookupSuspension();
37047
- let resPromise;
37048
- try {
37049
- resPromise = extDef.execute(context);
37050
- }
37051
- finally {
37052
- this.budget.endPathLookupSuspension();
37053
- scope.leaveWork();
37054
- }
37055
- if (resPromise !== RESOLVED_EXIT_ZERO) {
37056
- if (resPromise && typeof resPromise.catch === "function") {
37057
- resPromise.catch(() => { });
37058
- }
37059
- pooledSyncPipeContext = undefined;
37060
- context = undefined;
37061
- return undefined;
37062
- }
37063
- this.signal.throwIfAborted();
37064
- prevBuf = nextBuf;
37065
- prevLen = sharedSyncPipeWriter.used;
37025
+ // A command executor may suspend. Decline before invoking it so the
37026
+ // ordinary pipeline owns its context and executes every stage once.
37027
+ return undefined;
37066
37028
  }
37067
37029
  if (prevBuf.subarray(0, prevLen).includes(0))
37068
37030
  return undefined;
@@ -37074,12 +37036,6 @@ export class Runtime {
37074
37036
  this.budget.bytes = previousBytes;
37075
37037
  this.budget.commands = previousCommands;
37076
37038
  }
37077
- if (context)
37078
- context.releaseDirectStage();
37079
- sharedSyncPipeWriter.budget = undefined;
37080
- sharedSyncPipeWriter.signal = undefined;
37081
- sharedSyncPipeWriter.target = EMPTY_BYTES;
37082
- sharedSyncPipeReader.reset(EMPTY_BYTES, 0);
37083
37039
  syncPurePipelineSlotInUse = false;
37084
37040
  this.budget.leavePipelineStages(n);
37085
37041
  }
@@ -40190,6 +40146,8 @@ export class Runtime {
40190
40146
  }
40191
40147
  }
40192
40148
  await sortExpansionStrings(found, work, true);
40149
+ if (!found.length && state.failglob)
40150
+ throw new FailglobFailure(`no match: ${value}`);
40193
40151
  return found.length ? found : state.nullglob ? [] : [value];
40194
40152
  }
40195
40153
  finally {
@@ -40284,6 +40242,8 @@ export class Runtime {
40284
40242
  remaining: Math.min(Number.MAX_SAFE_INTEGER, this.budget.limits.maxExpansionBytes * 4 * (Math.ceil(Math.log2(found.length + 1)) + 1) + 1024), signal: this.signal, exhausted: () => this.budget.fail("maxExpansionBytes"),
40285
40243
  };
40286
40244
  await sortExpansionStrings(found, sortingWork, true);
40245
+ if (!found.length && state.failglob)
40246
+ throw new FailglobFailure(`no match: ${value}`);
40287
40247
  return found.length ? found : state.nullglob ? [] : [value];
40288
40248
  }
40289
40249
  }
@@ -40303,6 +40263,7 @@ export class RootShellState {
40303
40263
  this.substitutionStatus = 0;
40304
40264
  this.lastArgument = "";
40305
40265
  this.secondsOrigin = Date.now();
40266
+ this.processSubstitutionIds = { next: 0 };
40306
40267
  }
40307
40268
  get exported() {
40308
40269
  const raw = stateMonitor(this)?.raw;