@poe-platform/safe-bash 0.1.630 → 0.1.631

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 (357) hide show
  1. package/README.md +1 -0
  2. package/dist/office-package/compression.d.ts +19 -0
  3. package/dist/office-package/compression.js +186 -0
  4. package/dist/office-package/runtime.d.ts +11 -0
  5. package/dist/office-package/runtime.js +28 -0
  6. package/dist/safe-bash/chunks/{bz2-B2RXT4EX.js → bz2-ACU4EOVE.js} +2 -2
  7. package/dist/safe-bash/chunks/chunk-2E4KBFO6.js +239 -0
  8. package/dist/safe-bash/chunks/chunk-2E4KBFO6.js.map +7 -0
  9. package/dist/safe-bash/chunks/chunk-3E5M2WEL.js +33 -0
  10. package/dist/safe-bash/chunks/chunk-3E5M2WEL.js.map +7 -0
  11. package/dist/safe-bash/chunks/{chunk-KQ6J7JHQ.js → chunk-3LD67SER.js} +12 -10
  12. package/dist/safe-bash/chunks/{chunk-KQ6J7JHQ.js.map → chunk-3LD67SER.js.map} +1 -1
  13. package/dist/safe-bash/chunks/{chunk-6LSSEOG7.js → chunk-6HNK7Q66.js} +11 -7
  14. package/dist/safe-bash/chunks/{chunk-6LSSEOG7.js.map → chunk-6HNK7Q66.js.map} +1 -1
  15. package/dist/safe-bash/chunks/{chunk-AD7UAP5B.js → chunk-7EEWZY5S.js} +10 -8
  16. package/dist/safe-bash/chunks/{chunk-AD7UAP5B.js.map → chunk-7EEWZY5S.js.map} +1 -1
  17. package/dist/safe-bash/chunks/{chunk-RNKTWFEM.js → chunk-CDBQXRWL.js} +3 -3
  18. package/dist/safe-bash/chunks/{chunk-UYX72YHY.js → chunk-CHHAB5SS.js} +10 -74
  19. package/dist/safe-bash/chunks/{chunk-UYX72YHY.js.map → chunk-CHHAB5SS.js.map} +3 -3
  20. package/dist/safe-bash/chunks/{chunk-6YSBXTTJ.js → chunk-EI4X5ETX.js} +12 -10
  21. package/dist/safe-bash/chunks/{chunk-6YSBXTTJ.js.map → chunk-EI4X5ETX.js.map} +1 -1
  22. package/dist/safe-bash/chunks/{chunk-KZ7QCYNT.js → chunk-GIBLUW2U.js} +13 -9
  23. package/dist/safe-bash/chunks/{chunk-KZ7QCYNT.js.map → chunk-GIBLUW2U.js.map} +1 -1
  24. package/dist/safe-bash/chunks/chunk-GPV7ZFYS.js +1528 -0
  25. package/dist/safe-bash/chunks/chunk-GPV7ZFYS.js.map +7 -0
  26. package/dist/safe-bash/chunks/{chunk-N5CYTGBN.js → chunk-H3E67KTZ.js} +13 -9
  27. package/dist/safe-bash/chunks/{chunk-N5CYTGBN.js.map → chunk-H3E67KTZ.js.map} +1 -1
  28. package/dist/safe-bash/chunks/{chunk-AFH57PPL.js → chunk-IEKESMO4.js} +3 -3
  29. package/dist/safe-bash/chunks/{chunk-DPJWEGIX.js → chunk-JLBIUYT3.js} +2 -2
  30. package/dist/safe-bash/chunks/chunk-JZDO5MC3.js +77 -0
  31. package/dist/safe-bash/chunks/chunk-JZDO5MC3.js.map +7 -0
  32. package/dist/safe-bash/chunks/{chunk-GFZKQIPL.js → chunk-LA6BX562.js} +8 -6
  33. package/dist/safe-bash/chunks/{chunk-GFZKQIPL.js.map → chunk-LA6BX562.js.map} +1 -1
  34. package/dist/safe-bash/chunks/{chunk-PVJJFCGA.js → chunk-M3GPCYSP.js} +2 -2
  35. package/dist/safe-bash/chunks/{chunk-FWDMJTQO.js → chunk-NDCZ3UBP.js} +13 -9
  36. package/dist/safe-bash/chunks/{chunk-FWDMJTQO.js.map → chunk-NDCZ3UBP.js.map} +1 -1
  37. package/dist/safe-bash/chunks/{chunk-2KL6W6NB.js → chunk-O2EVBRKF.js} +1 -2
  38. package/dist/safe-bash/chunks/chunk-OFT77XIB.js +389 -0
  39. package/dist/safe-bash/chunks/chunk-OFT77XIB.js.map +7 -0
  40. package/dist/safe-bash/chunks/{chunk-PCLOK32J.js → chunk-PC6BEIAF.js} +13 -9
  41. package/dist/safe-bash/chunks/{chunk-PCLOK32J.js.map → chunk-PC6BEIAF.js.map} +1 -1
  42. package/dist/safe-bash/chunks/{chunk-3M5F7LD5.js → chunk-QWKP7ZU7.js} +13 -9
  43. package/dist/safe-bash/chunks/{chunk-3M5F7LD5.js.map → chunk-QWKP7ZU7.js.map} +1 -1
  44. package/dist/safe-bash/chunks/chunk-THXJ6CLF.js +53 -0
  45. package/dist/safe-bash/chunks/chunk-THXJ6CLF.js.map +7 -0
  46. package/dist/safe-bash/chunks/{chunk-K7W6Q6FN.js → chunk-V73A742N.js} +58 -16
  47. package/dist/safe-bash/chunks/chunk-V73A742N.js.map +7 -0
  48. package/dist/safe-bash/chunks/{chunk-4BYUV5PA.js → chunk-VN3ZGME3.js} +12 -8
  49. package/dist/safe-bash/chunks/{chunk-4BYUV5PA.js.map → chunk-VN3ZGME3.js.map} +1 -1
  50. package/dist/safe-bash/chunks/{chunk-3BZ5NQ73.js → chunk-WECHUK3Y.js} +369 -36
  51. package/dist/safe-bash/chunks/chunk-WECHUK3Y.js.map +7 -0
  52. package/dist/safe-bash/chunks/{chunk-X55AMTNM.js → chunk-WIOEUR7D.js} +14 -10
  53. package/dist/safe-bash/chunks/{chunk-X55AMTNM.js.map → chunk-WIOEUR7D.js.map} +1 -1
  54. package/dist/safe-bash/chunks/chunk-WPIOO4NX.js +443 -0
  55. package/dist/safe-bash/chunks/chunk-WPIOO4NX.js.map +7 -0
  56. package/dist/safe-bash/chunks/{chunk-C7QNJ3D4.js → chunk-WYTI64IU.js} +2 -2
  57. package/dist/safe-bash/chunks/{xz-AVXFDXW4.js → xz-U4QDTPZL.js} +2 -2
  58. package/dist/safe-bash/chunks/{zstd-R6RPHJYO.js → zstd-OG5RPYXO.js} +2 -2
  59. package/dist/safe-bash/commands/archive/zip/crc.d.ts +2 -0
  60. package/dist/safe-bash/commands/archive/zip/crc.d.ts.map +1 -0
  61. package/dist/safe-bash/commands/archive/zip/crc.js +7 -0
  62. package/dist/safe-bash/commands/archive/zip/crc.js.map +1 -0
  63. package/dist/safe-bash/commands/archive/zip/crypto.d.ts +4 -0
  64. package/dist/safe-bash/commands/archive/zip/crypto.d.ts.map +1 -0
  65. package/dist/safe-bash/commands/archive/zip/crypto.js +34 -0
  66. package/dist/safe-bash/commands/archive/zip/crypto.js.map +1 -0
  67. package/dist/safe-bash/commands/archive/zip/help.d.ts +3 -0
  68. package/dist/safe-bash/commands/archive/zip/help.d.ts.map +1 -0
  69. package/dist/safe-bash/commands/archive/zip/help.js +87 -0
  70. package/dist/safe-bash/commands/archive/zip/help.js.map +1 -0
  71. package/dist/safe-bash/commands/archive/zip/move.d.ts +12 -0
  72. package/dist/safe-bash/commands/archive/zip/move.d.ts.map +1 -0
  73. package/dist/safe-bash/commands/archive/zip/move.js +60 -0
  74. package/dist/safe-bash/commands/archive/zip/move.js.map +1 -0
  75. package/dist/safe-bash/commands/archive/zip/options.js +5 -5
  76. package/dist/safe-bash/commands/archive/zip/options.js.map +1 -1
  77. package/dist/safe-bash/commands/archive/zip-format.d.ts +1 -1
  78. package/dist/safe-bash/commands/archive/zip-format.d.ts.map +1 -1
  79. package/dist/safe-bash/commands/archive/zip-format.js +14 -17
  80. package/dist/safe-bash/commands/archive/zip-format.js.map +1 -1
  81. package/dist/safe-bash/commands/archive/zip.d.ts.map +1 -1
  82. package/dist/safe-bash/commands/archive/zip.js +45 -15
  83. package/dist/safe-bash/commands/archive/zip.js.map +1 -1
  84. package/dist/safe-bash/commands/bytes/compression/bounded-codec.d.ts +2 -0
  85. package/dist/safe-bash/commands/bytes/compression/bounded-codec.d.ts.map +1 -1
  86. package/dist/safe-bash/commands/bytes/compression/bounded-codec.js +4 -0
  87. package/dist/safe-bash/commands/bytes/compression/bounded-codec.js.map +1 -1
  88. package/dist/safe-bash/commands/bytes/compression/codec.d.ts +4 -24
  89. package/dist/safe-bash/commands/bytes/compression/codec.d.ts.map +1 -1
  90. package/dist/safe-bash/commands/bytes/compression/codec.js +12 -168
  91. package/dist/safe-bash/commands/bytes/compression/codec.js.map +1 -1
  92. package/dist/safe-bash/commands/cmp.js +1 -1
  93. package/dist/safe-bash/commands/cmp.js.map +1 -1
  94. package/dist/safe-bash/commands/csplit/index.browser.js +10 -7
  95. package/dist/safe-bash/commands/docx/index.browser.js +54 -0
  96. package/dist/safe-bash/commands/docx/index.browser.js.map +7 -0
  97. package/dist/safe-bash/commands/docx/index.d.ts +25 -0
  98. package/dist/safe-bash/commands/docx/index.d.ts.map +1 -0
  99. package/dist/safe-bash/commands/docx/index.js +42 -0
  100. package/dist/safe-bash/commands/docx/index.js.map +1 -0
  101. package/dist/safe-bash/commands/docx/io.d.ts +15 -0
  102. package/dist/safe-bash/commands/docx/io.d.ts.map +1 -0
  103. package/dist/safe-bash/commands/docx/io.js +16 -0
  104. package/dist/safe-bash/commands/docx/io.js.map +1 -0
  105. package/dist/safe-bash/commands/factor/index.browser.js +7 -5
  106. package/dist/safe-bash/commands/filesystem.d.ts.map +1 -1
  107. package/dist/safe-bash/commands/filesystem.js +9 -1
  108. package/dist/safe-bash/commands/filesystem.js.map +1 -1
  109. package/dist/safe-bash/commands/getopt/index.browser.js +7 -5
  110. package/dist/safe-bash/commands/hexdump/index.browser.js +8 -6
  111. package/dist/safe-bash/commands/iconv/index.browser.js +8 -6
  112. package/dist/safe-bash/commands/line-endings/index.browser.js +10 -7
  113. package/dist/safe-bash/commands/llm/index.browser.js +10 -8
  114. package/dist/safe-bash/commands/llm/providers/index.browser.js +3 -3
  115. package/dist/safe-bash/commands/network/index.browser.js +11 -8
  116. package/dist/safe-bash/commands/node/index.browser.js +8 -6
  117. package/dist/safe-bash/commands/op/index.browser.js +3 -3
  118. package/dist/safe-bash/commands/op/index.js +0 -1
  119. package/dist/safe-bash/commands/op/index.js.map +2 -2
  120. package/dist/safe-bash/commands/pptx/index.d.ts +29 -0
  121. package/dist/safe-bash/commands/pptx/index.d.ts.map +1 -0
  122. package/dist/safe-bash/commands/pptx/index.js +153 -0
  123. package/dist/safe-bash/commands/pptx/index.js.map +1 -0
  124. package/dist/safe-bash/commands/pr/index.browser.js +8 -6
  125. package/dist/safe-bash/commands/predicates.js +1 -1
  126. package/dist/safe-bash/commands/python/execution.d.ts +3 -0
  127. package/dist/safe-bash/commands/python/execution.d.ts.map +1 -0
  128. package/dist/safe-bash/commands/python/execution.js +193 -0
  129. package/dist/safe-bash/commands/python/execution.js.map +1 -0
  130. package/dist/safe-bash/commands/python/index.browser.js +21 -0
  131. package/dist/safe-bash/commands/python/index.browser.js.map +7 -0
  132. package/dist/safe-bash/commands/python/index.d.ts +49 -0
  133. package/dist/safe-bash/commands/python/index.d.ts.map +1 -0
  134. package/dist/safe-bash/commands/python/index.js +317 -0
  135. package/dist/safe-bash/commands/python/index.js.map +1 -0
  136. package/dist/safe-bash/commands/python/installation.d.ts +9 -0
  137. package/dist/safe-bash/commands/python/installation.d.ts.map +1 -0
  138. package/dist/safe-bash/commands/python/installation.js +80 -0
  139. package/dist/safe-bash/commands/python/installation.js.map +1 -0
  140. package/dist/safe-bash/commands/python/invocation.d.ts +10 -0
  141. package/dist/safe-bash/commands/python/invocation.d.ts.map +1 -0
  142. package/dist/safe-bash/commands/python/invocation.js +81 -0
  143. package/dist/safe-bash/commands/python/invocation.js.map +1 -0
  144. package/dist/safe-bash/commands/python/node.d.ts +12 -0
  145. package/dist/safe-bash/commands/python/node.d.ts.map +1 -0
  146. package/dist/safe-bash/commands/python/node.js +33 -0
  147. package/dist/safe-bash/commands/python/node.js.map +1 -0
  148. package/dist/safe-bash/commands/python/provisioning-runtime.d.ts +5 -0
  149. package/dist/safe-bash/commands/python/provisioning-runtime.d.ts.map +1 -0
  150. package/dist/safe-bash/commands/python/provisioning-runtime.js +179 -0
  151. package/dist/safe-bash/commands/python/provisioning-runtime.js.map +1 -0
  152. package/dist/safe-bash/commands/python/provisioning.d.ts +49 -0
  153. package/dist/safe-bash/commands/python/provisioning.d.ts.map +1 -0
  154. package/dist/safe-bash/commands/python/provisioning.js +320 -0
  155. package/dist/safe-bash/commands/python/provisioning.js.map +1 -0
  156. package/dist/safe-bash/commands/python/reply.d.ts +3 -0
  157. package/dist/safe-bash/commands/python/reply.d.ts.map +1 -0
  158. package/dist/safe-bash/commands/python/reply.js +103 -0
  159. package/dist/safe-bash/commands/python/reply.js.map +1 -0
  160. package/dist/safe-bash/commands/python/worker.browser.js +736 -0
  161. package/dist/safe-bash/commands/python/worker.browser.js.map +7 -0
  162. package/dist/safe-bash/commands/python/worker.d.ts +47 -0
  163. package/dist/safe-bash/commands/python/worker.d.ts.map +1 -0
  164. package/dist/safe-bash/commands/python/worker.js +373 -0
  165. package/dist/safe-bash/commands/python/worker.js.map +1 -0
  166. package/dist/safe-bash/commands/tsort/index.browser.js +8 -6
  167. package/dist/safe-bash/commands/xml/index.browser.js +9 -7
  168. package/dist/safe-bash/commands/yq/index.browser.js +10 -8
  169. package/dist/safe-bash/commands/yq/index.d.ts.map +1 -1
  170. package/dist/safe-bash/commands/yq/index.js +32 -4
  171. package/dist/safe-bash/commands/yq/index.js.map +1 -1
  172. package/dist/safe-bash/commands/yq/parser.d.ts.map +1 -1
  173. package/dist/safe-bash/commands/yq/parser.js +21 -5
  174. package/dist/safe-bash/commands/yq/parser.js.map +1 -1
  175. package/dist/safe-bash/contracts/command.d.ts +2 -0
  176. package/dist/safe-bash/contracts/command.d.ts.map +1 -1
  177. package/dist/safe-bash/contracts/command.js +6 -2
  178. package/dist/safe-bash/contracts/command.js.map +1 -1
  179. package/dist/safe-bash/contracts/filesystem-descriptor.d.ts +13 -0
  180. package/dist/safe-bash/contracts/filesystem-descriptor.d.ts.map +1 -0
  181. package/dist/safe-bash/contracts/filesystem-descriptor.js +189 -0
  182. package/dist/safe-bash/contracts/filesystem-descriptor.js.map +1 -0
  183. package/dist/safe-bash/contracts/filesystem-output-budget.d.ts +15 -0
  184. package/dist/safe-bash/contracts/filesystem-output-budget.d.ts.map +1 -0
  185. package/dist/safe-bash/contracts/filesystem-output-budget.js +69 -0
  186. package/dist/safe-bash/contracts/filesystem-output-budget.js.map +1 -0
  187. package/dist/safe-bash/contracts/filesystem-output.d.ts +11 -5
  188. package/dist/safe-bash/contracts/filesystem-output.d.ts.map +1 -1
  189. package/dist/safe-bash/contracts/filesystem-output.js +229 -20
  190. package/dist/safe-bash/contracts/filesystem-output.js.map +1 -1
  191. package/dist/safe-bash/contracts/io.d.ts +29 -0
  192. package/dist/safe-bash/contracts/io.d.ts.map +1 -1
  193. package/dist/safe-bash/contracts/io.js +317 -37
  194. package/dist/safe-bash/contracts/io.js.map +1 -1
  195. package/dist/safe-bash/core.browser.js +5502 -2210
  196. package/dist/safe-bash/core.browser.js.map +4 -4
  197. package/dist/safe-bash/core.d.ts +1 -0
  198. package/dist/safe-bash/core.d.ts.map +1 -1
  199. package/dist/safe-bash/core.js +1 -0
  200. package/dist/safe-bash/core.js.map +1 -1
  201. package/dist/safe-bash/opt-in/commands/cmp/compare.js +95 -0
  202. package/dist/safe-bash/opt-in/commands/cmp/index.d.ts +6 -0
  203. package/dist/safe-bash/opt-in/commands/cmp/index.js +99 -0
  204. package/dist/safe-bash/opt-in/commands/cmp/io.js +218 -0
  205. package/dist/safe-bash/opt-in/commands/cmp/options.d.ts +24 -0
  206. package/dist/safe-bash/opt-in/commands/cmp/options.js +195 -0
  207. package/dist/safe-bash/opt-in/commands/dd/conversions.js +152 -0
  208. package/dist/safe-bash/opt-in/commands/dd/index.d.ts +18 -0
  209. package/dist/safe-bash/opt-in/commands/dd/index.js +561 -0
  210. package/dist/safe-bash/opt-in/commands/dd/io.d.ts +31 -0
  211. package/dist/safe-bash/opt-in/commands/dd/io.js +244 -0
  212. package/dist/safe-bash/opt-in/commands/dd/options.js +184 -0
  213. package/dist/safe-bash/opt-in/commands/dd/report.js +69 -0
  214. package/dist/safe-bash/opt-in/commands/install/arguments.js +224 -0
  215. package/dist/safe-bash/opt-in/commands/install/index.d.ts +6 -0
  216. package/dist/safe-bash/opt-in/commands/install/index.js +678 -0
  217. package/dist/safe-bash/opt-in/commands/install/mode.js +71 -0
  218. package/dist/safe-bash/opt-in/commands/install/options.d.ts +36 -0
  219. package/dist/safe-bash/opt-in/commands/install/options.js +27 -0
  220. package/dist/safe-bash/opt-in/commands/shuf/args.js +179 -0
  221. package/dist/safe-bash/opt-in/commands/shuf/index.d.ts +6 -0
  222. package/dist/safe-bash/opt-in/commands/shuf/index.js +20 -0
  223. package/dist/safe-bash/opt-in/commands/shuf/input.js +93 -0
  224. package/dist/safe-bash/opt-in/commands/shuf/options.d.ts +9 -0
  225. package/dist/safe-bash/opt-in/commands/shuf/options.js +8 -0
  226. package/dist/safe-bash/opt-in/commands/shuf/random.js +114 -0
  227. package/dist/safe-bash/opt-in/commands/shuf/shuf.d.ts +3 -0
  228. package/dist/safe-bash/opt-in/commands/shuf/shuf.js +230 -0
  229. package/dist/safe-bash/opt-in/commands/shuf/usage.js +24 -0
  230. package/dist/safe-bash/opt-in/commands/truncate/arguments.js +186 -0
  231. package/dist/safe-bash/opt-in/commands/truncate/index.d.ts +9 -0
  232. package/dist/safe-bash/opt-in/commands/truncate/index.js +244 -0
  233. package/dist/safe-bash/opt-in/commands/yes/index.d.ts +11 -0
  234. package/dist/safe-bash/opt-in/commands/yes/index.js +167 -0
  235. package/dist/safe-bash/opt-in/commands/yq/arguments.js +177 -0
  236. package/dist/safe-bash/opt-in/commands/yq/evaluate.js +564 -0
  237. package/dist/safe-bash/opt-in/commands/yq/expression.js +183 -0
  238. package/dist/safe-bash/opt-in/commands/yq/inplace.js +65 -0
  239. package/dist/safe-bash/opt-in/commands/yq/mike.d.ts +9 -0
  240. package/dist/safe-bash/opt-in/commands/yq/mike.js +192 -0
  241. package/dist/safe-bash/opt-in/commands/yq/native-encoder.js +165 -0
  242. package/dist/safe-bash/opt-in/commands/yq/native-work.d.ts +44 -0
  243. package/dist/safe-bash/opt-in/commands/yq/native-work.js +188 -0
  244. package/dist/safe-bash/opt-in/commands/yq/nodes.js +621 -0
  245. package/dist/safe-bash/opt-in/entrypoints/arrays.d.ts +1 -0
  246. package/dist/safe-bash/opt-in/entrypoints/arrays.js +1 -0
  247. package/dist/safe-bash/opt-in/entrypoints/cmp.d.ts +2 -0
  248. package/dist/safe-bash/opt-in/entrypoints/cmp.js +1 -0
  249. package/dist/safe-bash/opt-in/entrypoints/dd.d.ts +2 -0
  250. package/dist/safe-bash/opt-in/entrypoints/dd.js +1 -0
  251. package/dist/safe-bash/opt-in/entrypoints/devices.d.ts +2 -0
  252. package/dist/safe-bash/opt-in/entrypoints/devices.js +1 -0
  253. package/dist/safe-bash/opt-in/entrypoints/install.d.ts +2 -0
  254. package/dist/safe-bash/opt-in/entrypoints/install.js +1 -0
  255. package/dist/safe-bash/opt-in/entrypoints/jobs.d.ts +1 -0
  256. package/dist/safe-bash/opt-in/entrypoints/jobs.js +1 -0
  257. package/dist/safe-bash/opt-in/entrypoints/mapfile.d.ts +1 -0
  258. package/dist/safe-bash/opt-in/entrypoints/mapfile.js +1 -0
  259. package/dist/safe-bash/opt-in/entrypoints/read.d.ts +2 -0
  260. package/dist/safe-bash/opt-in/entrypoints/read.js +1 -0
  261. package/dist/safe-bash/opt-in/entrypoints/shuf.d.ts +2 -0
  262. package/dist/safe-bash/opt-in/entrypoints/shuf.js +1 -0
  263. package/dist/safe-bash/opt-in/entrypoints/trap.d.ts +2 -0
  264. package/dist/safe-bash/opt-in/entrypoints/trap.js +1 -0
  265. package/dist/safe-bash/opt-in/entrypoints/truncate.d.ts +2 -0
  266. package/dist/safe-bash/opt-in/entrypoints/truncate.js +1 -0
  267. package/dist/safe-bash/opt-in/entrypoints/yes.d.ts +2 -0
  268. package/dist/safe-bash/opt-in/entrypoints/yes.js +1 -0
  269. package/dist/safe-bash/opt-in/entrypoints/yq.d.ts +3 -0
  270. package/dist/safe-bash/opt-in/entrypoints/yq.js +1 -0
  271. package/dist/safe-bash/opt-in/fs/devices/index.d.ts +8 -0
  272. package/dist/safe-bash/opt-in/fs/devices/index.js +292 -0
  273. package/dist/safe-bash/opt-in/optional.d.ts +28 -0
  274. package/dist/safe-bash/opt-in/optional.js +14 -0
  275. package/dist/safe-bash/opt-in/shell/extensions/arrays/index.d.ts +2 -0
  276. package/dist/safe-bash/opt-in/shell/extensions/arrays/index.js +4 -0
  277. package/dist/safe-bash/opt-in/shell/extensions/jobs/index.d.ts +2 -0
  278. package/dist/safe-bash/opt-in/shell/extensions/jobs/index.js +291 -0
  279. package/dist/safe-bash/opt-in/shell/extensions/jobs/state.js +374 -0
  280. package/dist/safe-bash/opt-in/shell/extensions/mapfile/index.d.ts +24 -0
  281. package/dist/safe-bash/opt-in/shell/extensions/mapfile/index.js +338 -0
  282. package/dist/safe-bash/opt-in/shell/extensions/read/index.d.ts +5 -0
  283. package/dist/safe-bash/opt-in/shell/extensions/read/index.js +351 -0
  284. package/dist/safe-bash/opt-in/shell/extensions/trap/index.d.ts +9 -0
  285. package/dist/safe-bash/opt-in/shell/extensions/trap/index.js +210 -0
  286. package/dist/safe-bash/optional-host.d.ts +5 -0
  287. package/dist/safe-bash/optional-host.d.ts.map +1 -0
  288. package/dist/safe-bash/optional-host.js +3 -0
  289. package/dist/safe-bash/optional-host.js.map +1 -0
  290. package/dist/safe-bash/shell/arrays/bindings.d.ts +15 -5
  291. package/dist/safe-bash/shell/arrays/bindings.d.ts.map +1 -1
  292. package/dist/safe-bash/shell/arrays/bindings.js +131 -23
  293. package/dist/safe-bash/shell/arrays/bindings.js.map +1 -1
  294. package/dist/safe-bash/shell/arrays/ledger.d.ts +1 -0
  295. package/dist/safe-bash/shell/arrays/ledger.d.ts.map +1 -1
  296. package/dist/safe-bash/shell/arrays/ledger.js +19 -0
  297. package/dist/safe-bash/shell/arrays/ledger.js.map +1 -1
  298. package/dist/safe-bash/shell/arrays/state.d.ts.map +1 -1
  299. package/dist/safe-bash/shell/arrays/state.js +3 -1
  300. package/dist/safe-bash/shell/arrays/state.js.map +1 -1
  301. package/dist/safe-bash/shell/arrays/syntax.d.ts +4 -1
  302. package/dist/safe-bash/shell/arrays/syntax.d.ts.map +1 -1
  303. package/dist/safe-bash/shell/arrays/syntax.js +3 -3
  304. package/dist/safe-bash/shell/arrays/syntax.js.map +1 -1
  305. package/dist/safe-bash/shell/conditional.js +1 -1
  306. package/dist/safe-bash/shell/descriptors.d.ts +31 -0
  307. package/dist/safe-bash/shell/descriptors.d.ts.map +1 -0
  308. package/dist/safe-bash/shell/descriptors.js +234 -0
  309. package/dist/safe-bash/shell/descriptors.js.map +1 -0
  310. package/dist/safe-bash/shell/diagnostic-name-ranges.d.ts +2 -0
  311. package/dist/safe-bash/shell/diagnostic-name-ranges.d.ts.map +1 -0
  312. package/dist/safe-bash/shell/diagnostic-name-ranges.js +717 -0
  313. package/dist/safe-bash/shell/diagnostic-name-ranges.js.map +1 -0
  314. package/dist/safe-bash/shell/diagnostic-name.d.ts +3 -0
  315. package/dist/safe-bash/shell/diagnostic-name.d.ts.map +1 -0
  316. package/dist/safe-bash/shell/diagnostic-name.js +89 -0
  317. package/dist/safe-bash/shell/diagnostic-name.js.map +1 -0
  318. package/dist/safe-bash/shell/display.js +1 -1
  319. package/dist/safe-bash/shell/display.js.map +1 -1
  320. package/dist/safe-bash/shell/extensions.d.ts +188 -0
  321. package/dist/safe-bash/shell/extensions.d.ts.map +1 -0
  322. package/dist/safe-bash/shell/extensions.js +141 -0
  323. package/dist/safe-bash/shell/extensions.js.map +1 -0
  324. package/dist/safe-bash/shell/input.d.ts +66 -14
  325. package/dist/safe-bash/shell/input.d.ts.map +1 -1
  326. package/dist/safe-bash/shell/input.js +947 -173
  327. package/dist/safe-bash/shell/input.js.map +1 -1
  328. package/dist/safe-bash/shell/parser.d.ts +38 -6
  329. package/dist/safe-bash/shell/parser.d.ts.map +1 -1
  330. package/dist/safe-bash/shell/parser.js +339 -52
  331. package/dist/safe-bash/shell/parser.js.map +1 -1
  332. package/dist/safe-bash/shell/runtime.d.ts +92 -20
  333. package/dist/safe-bash/shell/runtime.d.ts.map +1 -1
  334. package/dist/safe-bash/shell/runtime.js +2547 -689
  335. package/dist/safe-bash/shell/runtime.js.map +1 -1
  336. package/dist/safe-bash/shell/shell.d.ts.map +1 -1
  337. package/dist/safe-bash/shell/shell.js +52 -21
  338. package/dist/safe-bash/shell/shell.js.map +1 -1
  339. package/dist/safe-bash/shell/types.d.ts +4 -0
  340. package/dist/safe-bash/shell/types.d.ts.map +1 -1
  341. package/dist/safe-bash/shell/types.js.map +1 -1
  342. package/package.json +92 -4
  343. package/dist/safe-bash/chunks/chunk-3BZ5NQ73.js.map +0 -7
  344. package/dist/safe-bash/chunks/chunk-4DBWBEU7.js +0 -194
  345. package/dist/safe-bash/chunks/chunk-4DBWBEU7.js.map +0 -7
  346. package/dist/safe-bash/chunks/chunk-CXMIIXJA.js +0 -178
  347. package/dist/safe-bash/chunks/chunk-CXMIIXJA.js.map +0 -7
  348. package/dist/safe-bash/chunks/chunk-K7W6Q6FN.js.map +0 -7
  349. /package/dist/safe-bash/chunks/{bz2-B2RXT4EX.js.map → bz2-ACU4EOVE.js.map} +0 -0
  350. /package/dist/safe-bash/chunks/{chunk-RNKTWFEM.js.map → chunk-CDBQXRWL.js.map} +0 -0
  351. /package/dist/safe-bash/chunks/{chunk-AFH57PPL.js.map → chunk-IEKESMO4.js.map} +0 -0
  352. /package/dist/safe-bash/chunks/{chunk-DPJWEGIX.js.map → chunk-JLBIUYT3.js.map} +0 -0
  353. /package/dist/safe-bash/chunks/{chunk-PVJJFCGA.js.map → chunk-M3GPCYSP.js.map} +0 -0
  354. /package/dist/safe-bash/chunks/{chunk-2KL6W6NB.js.map → chunk-O2EVBRKF.js.map} +0 -0
  355. /package/dist/safe-bash/chunks/{chunk-C7QNJ3D4.js.map → chunk-WYTI64IU.js.map} +0 -0
  356. /package/dist/safe-bash/chunks/{xz-AVXFDXW4.js.map → xz-U4QDTPZL.js.map} +0 -0
  357. /package/dist/safe-bash/chunks/{zstd-R6RPHJYO.js.map → zstd-OG5RPYXO.js.map} +0 -0
@@ -0,0 +1,230 @@
1
+ import { commandRuntimeIdentity, getCommandArguments, isFsError, toByteSource, writeBytes, } from "@poe-platform/safe-bash/contracts/index";
2
+ import { openFileOutput } from "@poe-platform/safe-bash/contracts/filesystem-output";
3
+ import { yieldTurn } from "@poe-platform/safe-bash/contracts/yield";
4
+ import { countMax, Diagnostic, fileQuote, parse, quote } from "./args.js";
5
+ import { ownedBytes, records, virtualPath } from "./input.js";
6
+ import { settings } from "./options.js";
7
+ import { RandomIntegers } from "./random.js";
8
+ import { shellValueByteLength } from "@poe-platform/safe-bash/contracts/value";
9
+ const encoder = new TextEncoder();
10
+ const errors = {
11
+ ENOENT: "No such file or directory", EACCES: "Permission denied", EPERM: "Operation not permitted",
12
+ EISDIR: "Is a directory", ENOTDIR: "Not a directory", EROFS: "Read-only file system",
13
+ EIO: "Input/output error", ENOSPC: "No space left on device", EPIPE: "Broken pipe",
14
+ ELOOP: "Too many levels of symbolic links", EBADF: "Bad file descriptor", ENAMETOOLONG: "File name too long",
15
+ EINVAL: "Invalid argument", EFBIG: "File too large", ENOTSUP: "Operation not supported",
16
+ };
17
+ export function createShufCommand(options = {}) {
18
+ const limits = settings(options);
19
+ return Object.freeze({
20
+ name: "shuf",
21
+ runtimeIdentity: commandRuntimeIdentity,
22
+ description: "Write a random permutation of input records",
23
+ async execute(context) {
24
+ let random;
25
+ let output;
26
+ let source;
27
+ let inputSource;
28
+ let openingInput;
29
+ const inputController = new AbortController();
30
+ const inputSignal = AbortSignal.any([context.signal, inputController.signal]);
31
+ let diagnostic = "read error";
32
+ let openingRootOutput = false;
33
+ let cleanup;
34
+ let closed = false;
35
+ let executionFailed = false;
36
+ const close = () => {
37
+ closed = true;
38
+ inputController.abort(new Error("shuf input is closed"));
39
+ return cleanup ??= (async () => {
40
+ await openingInput?.catch(() => { });
41
+ const results = await Promise.allSettled([source?.return(undefined), inputSource?.return(undefined), random?.close()]);
42
+ const failed = results.find(result => result.status === "rejected");
43
+ if (failed?.status === "rejected")
44
+ throw failed.reason;
45
+ })();
46
+ };
47
+ context.registerCleanup?.(close);
48
+ try {
49
+ context.signal.throwIfAborted();
50
+ const parsed = parse(context);
51
+ if (parsed.action) {
52
+ const { help, version } = await import("./usage.js");
53
+ await writeBytes(context.stdout, encoder.encode(parsed.action === "help" ? help : version), context.signal);
54
+ return { exitCode: 0 };
55
+ }
56
+ const lines = [];
57
+ let totalBytes = 0;
58
+ let size = parsed.count === 0n ? 0n : parsed.range?.size ?? 0n;
59
+ let reservoir = false;
60
+ if (parsed.count !== 0n && parsed.echo) {
61
+ const argumentsOwned = getCommandArguments(context);
62
+ for (const index of parsed.operands) {
63
+ if (lines.length >= limits.maxSampleSize)
64
+ throw new Diagnostic("shuf: maxSampleSize limit exceeded\n");
65
+ totalBytes += shellValueByteLength(argumentsOwned.values[index]) + 1;
66
+ if (totalBytes > limits.maxInputBytes)
67
+ throw new Diagnostic("shuf: maxInputBytes limit exceeded\n");
68
+ const bytes = argumentsOwned.bytes(index);
69
+ const line = new Uint8Array(bytes.length + 1);
70
+ line.set(bytes);
71
+ line[bytes.length] = parsed.delimiter;
72
+ lines.push(line);
73
+ }
74
+ size = BigInt(lines.length);
75
+ }
76
+ else if (parsed.count !== 0n && !parsed.range) {
77
+ const name = parsed.operands.length ? context.args[parsed.operands[0]] : "-";
78
+ let inputSize = Infinity;
79
+ openingInput = Promise.resolve().then(async () => {
80
+ inputSignal.throwIfAborted();
81
+ let input;
82
+ if (name === "-")
83
+ input = context.stdin;
84
+ else {
85
+ diagnostic = fileQuote(name);
86
+ const path = virtualPath(context.cwd, name);
87
+ const stat = await context.fs.stat(path, { signal: inputSignal });
88
+ if (stat.type === "file" && Number.isSafeInteger(stat.size) && stat.size >= 0)
89
+ inputSize = stat.size;
90
+ inputSignal.throwIfAborted();
91
+ await context.fs.access(path, 4, { signal: inputSignal });
92
+ inputSignal.throwIfAborted();
93
+ if (context.fs.readStream)
94
+ input = context.fs.readStream(path, { signal: inputSignal });
95
+ else {
96
+ const bytes = await context.fs.readFile(path, { signal: inputSignal, maxBytes: limits.maxInputBytes });
97
+ if (bytes.byteLength > limits.maxInputBytes)
98
+ throw new Diagnostic("shuf: maxInputBytes limit exceeded\n");
99
+ input = toByteSource(bytes);
100
+ }
101
+ }
102
+ inputSource = ownedBytes(input, inputSignal);
103
+ inputSignal.throwIfAborted();
104
+ if (closed)
105
+ throw new Error("shuf input is closed");
106
+ source = records(inputSource, parsed.delimiter, limits.maxInputBytes, context.signal);
107
+ });
108
+ await openingInput;
109
+ diagnostic = "read error";
110
+ reservoir = !parsed.repeat && parsed.count < countMax && inputSize > 8 * 1024 * 1024;
111
+ if (!reservoir) {
112
+ for await (const line of source) {
113
+ totalBytes += line.length;
114
+ if (totalBytes > limits.maxInputBytes)
115
+ throw new Diagnostic("shuf: maxInputBytes limit exceeded\n");
116
+ if (lines.length >= limits.maxSampleSize)
117
+ throw new Diagnostic("shuf: maxSampleSize limit exceeded\n");
118
+ lines.push(line);
119
+ }
120
+ size = BigInt(lines.length);
121
+ }
122
+ }
123
+ random = new RandomIntegers(context, parsed.random, limits.maxInputBytes);
124
+ const count = parsed.repeat || parsed.count < size ? parsed.count : size;
125
+ diagnostic = fileQuote(parsed.random ?? "getrandom");
126
+ if (reservoir || parsed.repeat || count > 0n)
127
+ await random.open();
128
+ diagnostic = parsed.random === undefined ? "getrandom" : `${quote(parsed.random)}: read error`;
129
+ if (reservoir) {
130
+ let seen = 0n;
131
+ while (seen < parsed.count) {
132
+ diagnostic = "read error";
133
+ const next = await source.next();
134
+ if (next.done)
135
+ break;
136
+ totalBytes += next.value.length;
137
+ if (totalBytes > limits.maxInputBytes)
138
+ throw new Diagnostic("shuf: maxInputBytes limit exceeded\n");
139
+ if (lines.length >= limits.maxSampleSize)
140
+ throw new Diagnostic("shuf: maxSampleSize limit exceeded\n");
141
+ lines.push(next.value);
142
+ seen++;
143
+ }
144
+ if (seen === parsed.count) {
145
+ while (true) {
146
+ diagnostic = parsed.random === undefined ? "getrandom" : `${quote(parsed.random)}: read error`;
147
+ const chosen = await random.choose(seen + 1n);
148
+ diagnostic = "read error";
149
+ const next = await source.next();
150
+ if (next.done)
151
+ break;
152
+ if (chosen < parsed.count) {
153
+ const index = Number(chosen);
154
+ totalBytes += next.value.length - lines[index].length;
155
+ if (totalBytes > limits.maxInputBytes)
156
+ throw new Diagnostic("shuf: maxInputBytes limit exceeded\n");
157
+ lines[index] = next.value;
158
+ }
159
+ seen++;
160
+ if (seen % 1024n === 0n)
161
+ await yieldTurn(context.signal);
162
+ }
163
+ }
164
+ size = BigInt(lines.length);
165
+ }
166
+ const ahead = parsed.repeat || parsed.count < size ? parsed.count : size;
167
+ const permutation = [];
168
+ diagnostic = parsed.random === undefined ? "getrandom" : `${quote(parsed.random)}: read error`;
169
+ if (!parsed.repeat) {
170
+ if (ahead > BigInt(limits.maxSampleSize))
171
+ throw new Diagnostic("shuf: maxSampleSize limit exceeded\n");
172
+ const swaps = new Map();
173
+ for (let index = 0n; index < ahead; index++) {
174
+ const chosen = index + await random.choose(size - index);
175
+ permutation.push(swaps.get(chosen) ?? chosen);
176
+ swaps.set(chosen, swaps.get(index) ?? index);
177
+ swaps.delete(index);
178
+ if (index % 1024n === 1023n)
179
+ await yieldTurn(context.signal);
180
+ }
181
+ }
182
+ if (parsed.output !== undefined) {
183
+ diagnostic = fileQuote(parsed.output);
184
+ openingRootOutput = parsed.output.length > 0 && Array.from(parsed.output).every(character => character === "/");
185
+ output = await openFileOutput(context, virtualPath(context.cwd, parsed.output), "w");
186
+ openingRootOutput = false;
187
+ }
188
+ if (parsed.repeat && parsed.count > 0n && size === 0n)
189
+ throw new Diagnostic("shuf: no lines to repeat\n");
190
+ const sink = output?.sink ?? context.stdout;
191
+ for (let index = 0n; index < ahead; index++) {
192
+ context.signal.throwIfAborted();
193
+ diagnostic = parsed.random === undefined ? "getrandom" : `${quote(parsed.random)}: read error`;
194
+ const chosen = parsed.repeat ? await random.choose(size) : permutation[Number(index)];
195
+ const line = parsed.range ? encoder.encode(`${parsed.range.low + chosen}${parsed.delimiter === 0 ? "\0" : "\n"}`) : lines[Number(chosen)];
196
+ diagnostic = "write error";
197
+ await writeBytes(sink, line, context.signal);
198
+ if (index % 256n === 255n)
199
+ await yieldTurn(context.signal);
200
+ }
201
+ if (output)
202
+ await output.finish();
203
+ context.signal.throwIfAborted();
204
+ return { exitCode: 0 };
205
+ }
206
+ catch (error) {
207
+ executionFailed = true;
208
+ if (output)
209
+ await output.abort(error);
210
+ context.signal.throwIfAborted();
211
+ if (isFsError(error) && error.code === "EPIPE" && diagnostic === "write error")
212
+ return { exitCode: 141 };
213
+ if (!(error instanceof Diagnostic) && !isFsError(error))
214
+ throw error;
215
+ const message = error instanceof Diagnostic ? error.message : `shuf: ${diagnostic}: ${openingRootOutput && error.code === "EISDIR" ? "File exists" : errors[error.code] ?? error.code}\n`;
216
+ await writeBytes(context.stderr, error instanceof Diagnostic && error.bytes ? error.bytes : encoder.encode(message), context.signal);
217
+ return { exitCode: 1 };
218
+ }
219
+ finally {
220
+ try {
221
+ await close().catch(error => { if (!executionFailed)
222
+ throw error; });
223
+ }
224
+ finally {
225
+ context.signal.throwIfAborted();
226
+ }
227
+ }
228
+ },
229
+ });
230
+ }
@@ -0,0 +1,24 @@
1
+ export const help = `Usage: shuf [OPTION]... [FILE]
2
+ or: shuf -e [OPTION]... [ARG]...
3
+ or: shuf -i LO-HI [OPTION]...
4
+ Write a random permutation of the input lines to standard output.
5
+
6
+ With no FILE, or when FILE is -, read standard input.
7
+
8
+ Mandatory arguments to long options are mandatory for short options too.
9
+ -e, --echo treat each ARG as an input line
10
+ -i, --input-range=LO-HI treat each number LO through HI as an input line
11
+ -n, --head-count=COUNT output at most COUNT lines
12
+ -o, --output=FILE write result to FILE instead of standard output
13
+ --random-source=FILE get random bytes from FILE
14
+ -r, --repeat output lines can be repeated
15
+ -z, --zero-terminated line delimiter is NUL, not newline
16
+ --help display this help and exit
17
+ --version output version information and exit
18
+
19
+ GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
20
+ Report any translation bugs to <https://translationproject.org/team/>
21
+ Full documentation <https://www.gnu.org/software/coreutils/shuf>
22
+ or available locally via: info '(coreutils) shuf invocation'
23
+ `;
24
+ export const version = "shuf (virtual-bash, GNU coreutils 9.7 profile)\n";
@@ -0,0 +1,186 @@
1
+ export const maximumSize = (1n << 63n) - 1n;
2
+ export const minimumSize = -(1n << 63n);
3
+ export class TruncateError extends Error {
4
+ usage;
5
+ raw;
6
+ constructor(message, usage = false, raw = false) {
7
+ super(message);
8
+ this.usage = usage;
9
+ this.raw = raw;
10
+ }
11
+ }
12
+ export function argumentBytes(value) {
13
+ return Uint8Array.from(value, character => character.charCodeAt(0));
14
+ }
15
+ const escapes = new Map([[7, "a"], [8, "b"], [9, "t"], [10, "n"], [11, "v"], [12, "f"], [13, "r"]]);
16
+ export function quote(value, numeric = false) {
17
+ const bytes = argumentBytes(value);
18
+ if (!numeric && bytes.every(byte => byte >= 32 && byte < 127)) {
19
+ return value.includes("'") && !["\"", "$", "`", "\\"].some(character => value.includes(character))
20
+ ? `"${value}"` : `'${value.replaceAll("'", "'\\''")}'`;
21
+ }
22
+ let result = "'", escaped = false;
23
+ for (const byte of bytes) {
24
+ const special = byte < 32 || byte >= 127;
25
+ if (!numeric && special !== escaped) {
26
+ result += special ? "'$'" : "''";
27
+ escaped = special;
28
+ }
29
+ result += special ? `\\${escapes.get(byte) ?? byte.toString(8).padStart(3, "0")}`
30
+ : numeric && (byte === 39 || byte === 92) ? `\\${String.fromCharCode(byte)}`
31
+ : byte === 39 ? "'\\''" : String.fromCharCode(byte);
32
+ }
33
+ return `${result}'`;
34
+ }
35
+ function skipSpace(value) {
36
+ let offset = 0;
37
+ while (offset < value.length && " \t\n\r\v\f".includes(value[offset]))
38
+ offset++;
39
+ return value.slice(offset);
40
+ }
41
+ function parseSize(value, previousMode) {
42
+ let text = skipSpace(value), mode = previousMode;
43
+ if (text[0] === "<" || text[0] === ">" || text[0] === "/" || text[0] === "%") {
44
+ mode = text[0];
45
+ text = skipSpace(text.slice(1));
46
+ }
47
+ if (text[0] === "+" || text[0] === "-") {
48
+ if (mode !== "absolute")
49
+ throw new TruncateError("multiple relative modifiers specified", true);
50
+ mode = "relative";
51
+ }
52
+ const negative = text[0] === "-", signed = negative || text[0] === "+";
53
+ let offset = signed ? 1 : 0, amount = 0n;
54
+ const start = offset;
55
+ while (offset < text.length && text[offset] >= "0" && text[offset] <= "9") {
56
+ if (amount <= maximumSize + 1n)
57
+ amount = amount * 10n + BigInt(text.charCodeAt(offset) - 48);
58
+ offset++;
59
+ }
60
+ const suffix = text.slice(offset);
61
+ const invalid = () => new TruncateError(`Invalid number: ${quote(text, true)}`);
62
+ if (offset === start) {
63
+ if (signed || !suffix)
64
+ throw invalid();
65
+ amount = 1n;
66
+ }
67
+ if (suffix) {
68
+ const powers = { k: 1, K: 1, m: 2, M: 2, g: 3, G: 3, t: 4, T: 4, P: 5, E: 6, Z: 7, Y: 8, R: 9, Q: 10 };
69
+ const power = powers[suffix[0]], tail = suffix.slice(1);
70
+ if (power === undefined || (tail !== "" && tail !== "B" && tail !== "D" && tail !== "iB"))
71
+ throw invalid();
72
+ amount *= (tail === "B" || tail === "D" ? 1000n : 1024n) ** BigInt(power);
73
+ }
74
+ if (negative)
75
+ amount = -amount;
76
+ if (amount < minimumSize || amount > maximumSize)
77
+ throw new TruncateError(`Invalid number: ${quote(text, true)}: Value too large to be stored in data type`);
78
+ if ((mode === "/" || mode === "%") && amount === 0n)
79
+ throw new TruncateError("division by zero");
80
+ return { size: amount, mode };
81
+ }
82
+ export function parseArguments(args, posix, owned) {
83
+ const readArgument = (index) => {
84
+ const value = args[index];
85
+ if (value === undefined)
86
+ return undefined;
87
+ return Array.from(owned?.bytes(index) ?? new TextEncoder().encode(value), byte => String.fromCharCode(byte)).join("");
88
+ };
89
+ const files = [];
90
+ let noCreate = false, ioBlocks = false, ended = false;
91
+ let reference, size, mode = "absolute";
92
+ const longOptions = { "no-create": "c", "io-blocks": "o", reference: "r", size: "s", help: "help", version: "version" };
93
+ for (let index = 0; index < args.length; index++) {
94
+ const argument = readArgument(index);
95
+ if (ended || argument === "-" || !argument.startsWith("-")) {
96
+ files.push(argument);
97
+ if (posix)
98
+ ended = true;
99
+ continue;
100
+ }
101
+ if (argument === "--") {
102
+ ended = true;
103
+ continue;
104
+ }
105
+ const long = argument.startsWith("--");
106
+ const equals = argument.indexOf("=");
107
+ let name = argument.slice(2, equals < 0 ? undefined : equals);
108
+ let keys = argument.slice(1);
109
+ if (long) {
110
+ const matching = Object.keys(longOptions).filter(option => option.startsWith(name));
111
+ const matched = Object.hasOwn(longOptions, name) ? name : matching[0];
112
+ if (!matched)
113
+ throw new TruncateError(`unrecognized option '${argument}'`, true, true);
114
+ if (!Object.hasOwn(longOptions, name) && matching.length > 1)
115
+ throw new TruncateError(`option '${argument}' is ambiguous; possibilities: ${matching.map(option => `'--${option}'`).join(" ")}`, true, true);
116
+ keys = longOptions[matched];
117
+ name = matched;
118
+ }
119
+ if (long && (keys === "help" || keys === "version")) {
120
+ if (equals >= 0)
121
+ throw new TruncateError(`option '--${name}' doesn't allow an argument`, true);
122
+ return { files, noCreate, ioBlocks, mode, display: keys };
123
+ }
124
+ for (let offset = 0; offset < keys.length; offset++) {
125
+ const key = keys[offset];
126
+ if (key !== "c" && key !== "o" && key !== "r" && key !== "s")
127
+ throw new TruncateError(`invalid option -- '${key}'`, true, true);
128
+ if (key === "c" || key === "o") {
129
+ if (long && equals >= 0)
130
+ throw new TruncateError(`option '--${name}' doesn't allow an argument`, true);
131
+ if (key === "c")
132
+ noCreate = true;
133
+ else
134
+ ioBlocks = true;
135
+ continue;
136
+ }
137
+ const value = long ? equals >= 0 ? argument.slice(equals + 1) : readArgument(++index) : keys.slice(offset + 1) || readArgument(++index);
138
+ if (value === undefined)
139
+ throw new TruncateError(long ? `option '--${name}' requires an argument` : `option requires an argument -- '${key}'`, true);
140
+ if (key === "r")
141
+ reference = value;
142
+ else
143
+ ({ size, mode } = parseSize(value, mode));
144
+ break;
145
+ }
146
+ }
147
+ if (reference === undefined && size === undefined)
148
+ throw new TruncateError("you must specify either '--size' or '--reference'", true);
149
+ if (reference !== undefined && size !== undefined && mode === "absolute")
150
+ throw new TruncateError("you must specify a relative '--size' with '--reference'", true);
151
+ if (ioBlocks && size === undefined)
152
+ throw new TruncateError("'--io-blocks' was specified but '--size' was not", true);
153
+ if (files.length === 0)
154
+ throw new TruncateError("missing file operand", true);
155
+ return { files, noCreate, ioBlocks, mode, ...(reference === undefined ? {} : { reference }), ...(size === undefined ? {} : { size }) };
156
+ }
157
+ export const helpText = `Usage: truncate OPTION... FILE...
158
+ Shrink or extend the size of each FILE to the specified size
159
+
160
+ A FILE argument that does not exist is created.
161
+
162
+ If a FILE is larger than the specified size, the extra data is lost.
163
+ If a FILE is shorter, it is extended and the sparse extended part (hole)
164
+ reads as zero bytes.
165
+
166
+ Mandatory arguments to long options are mandatory for short options too.
167
+ -c, --no-create do not create any files
168
+ -o, --io-blocks treat SIZE as number of IO blocks instead of bytes
169
+ -r, --reference=RFILE base size on RFILE
170
+ -s, --size=SIZE set or adjust the file size by SIZE bytes
171
+ --help display this help and exit
172
+ --version output version information and exit
173
+
174
+ The SIZE argument is an integer and optional unit (example: 10K is 10*1024).
175
+ Units are K,M,G,T,P,E,Z,Y,R,Q (powers of 1024) or KB,MB,... (powers of 1000).
176
+ Binary prefixes can be used, too: KiB=K, MiB=M, and so on.
177
+
178
+ SIZE may also be prefixed by one of the following modifying characters:
179
+ '+' extend by, '-' reduce by, '<' at most, '>' at least,
180
+ '/' round down to multiple of, '%' round up to multiple of.
181
+
182
+ GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
183
+ Report any translation bugs to <https://translationproject.org/team/>
184
+ Full documentation <https://www.gnu.org/software/coreutils/truncate>
185
+ or available locally via: info '(coreutils) truncate invocation'
186
+ `;
@@ -0,0 +1,9 @@
1
+ import { type CommandContext, type CommandDefinition, type FileStat, type VirtualShellPlugin } from "@poe-platform/safe-bash/contracts/index";
2
+ export interface TruncateCommandsOptions {
3
+ readonly replace?: boolean;
4
+ readonly ioBlockSize?: (path: string, stat: FileStat, context: CommandContext) => number | Promise<number>;
5
+ readonly seekEnd?: (path: string, stat: FileStat, context: CommandContext) => number | Promise<number>;
6
+ }
7
+ export declare function createTruncateCommand(options?: TruncateCommandsOptions): CommandDefinition;
8
+ export declare function createTruncateCommands(options?: TruncateCommandsOptions): readonly CommandDefinition[];
9
+ export declare function truncateCommands(options?: TruncateCommandsOptions): VirtualShellPlugin;