@poe-platform/safe-bash 0.1.787 → 0.1.789

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 (199) hide show
  1. package/README.md +1 -1
  2. package/dist/safe-bash/chunks/{chunk-WHURJBET.js → chunk-2MUJ7RLZ.js} +1 -1
  3. package/dist/safe-bash/chunks/{chunk-PYTLIUST.js → chunk-CTUHLNJM.js} +2 -2
  4. package/dist/safe-bash/chunks/{chunk-Z3HX3ZBA.js → chunk-D4PHJK4T.js} +1 -1
  5. package/dist/safe-bash/chunks/{chunk-O6356Z27.js → chunk-H7MMJS26.js} +2 -2
  6. package/dist/safe-bash/chunks/{chunk-Q3E6C3DX.js → chunk-KHJGUF2W.js} +14 -0
  7. package/dist/safe-bash/chunks/{chunk-FJZNUUOQ.js → chunk-VUVKC6HV.js} +1 -1
  8. package/dist/safe-bash/chunks/{chunk-ZMYVCRAF.js → chunk-X5ZCECM6.js} +2 -2
  9. package/dist/safe-bash/chunks/{git-UFNPAOYZ.js → git-HO7WDPHZ.js} +2 -2
  10. package/dist/safe-bash/command-chunks/{chunk-PFBJR2PY.js → chunk-2KRKKW5S.js} +2 -2
  11. package/dist/safe-bash/command-chunks/{chunk-4DSJDVBM.js → chunk-32F3RBUW.js} +10 -749
  12. package/dist/safe-bash/command-chunks/{chunk-WVWWRMFD.js → chunk-3KROFHBT.js} +1 -1
  13. package/dist/safe-bash/command-chunks/{chunk-L3MLMXL4.js → chunk-3ZK5F23O.js} +1 -1
  14. package/dist/safe-bash/command-chunks/{chunk-4QX6XCDD.js → chunk-4RNIZ3RT.js} +79 -0
  15. package/dist/safe-bash/command-chunks/{chunk-IFUNAM4D.js → chunk-5L62A5RO.js} +1 -1
  16. package/dist/safe-bash/command-chunks/{chunk-D7TADAYG.js → chunk-64LG3EVJ.js} +17 -0
  17. package/dist/safe-bash/command-chunks/{chunk-JUDOV5MJ.js → chunk-6F7QJMJ3.js} +1 -1
  18. package/dist/safe-bash/command-chunks/{chunk-IJ3FXP4Q.js → chunk-A3ZX6SCY.js} +1 -1
  19. package/dist/safe-bash/command-chunks/{chunk-DREUDEQG.js → chunk-AT6ZSOE6.js} +3 -3
  20. package/dist/safe-bash/command-chunks/{chunk-BUKYQBXO.js → chunk-BJ6DGYJA.js} +12 -12
  21. package/dist/safe-bash/command-chunks/{chunk-KSIGF4AG.js → chunk-BK4CMEE6.js} +1 -1
  22. package/dist/safe-bash/command-chunks/{chunk-NSEUBSOD.js → chunk-CXMOCPPH.js} +2 -2
  23. package/dist/safe-bash/command-chunks/{chunk-XGMWWUHV.js → chunk-CZ5DAK4K.js} +1 -1
  24. package/dist/safe-bash/command-chunks/{chunk-Z57TV6TC.js → chunk-EZ2DTOLI.js} +4 -2
  25. package/dist/safe-bash/command-chunks/{chunk-ADCGH6A7.js → chunk-FH3D75FC.js} +1 -1
  26. package/dist/safe-bash/command-chunks/{chunk-WYJTWJZ5.js → chunk-G3G6W5ZE.js} +1 -1
  27. package/dist/safe-bash/command-chunks/{chunk-3HDIDEUJ.js → chunk-GF54KE2M.js} +1 -1
  28. package/dist/safe-bash/command-chunks/{chunk-3JS4FOLB.js → chunk-HETU7MYN.js} +1 -1
  29. package/dist/safe-bash/command-chunks/{chunk-Z7TYZG3A.js → chunk-IHHTTQX6.js} +5 -3
  30. package/dist/safe-bash/command-chunks/{chunk-INDIFLBW.js → chunk-JTAGNROA.js} +4 -0
  31. package/dist/safe-bash/command-chunks/{chunk-Z47EO74H.js → chunk-MYKK3Q5G.js} +1 -1
  32. package/dist/safe-bash/command-chunks/{chunk-GZOUGVVV.js → chunk-OYZ534IK.js} +1 -1
  33. package/dist/safe-bash/command-chunks/chunk-PGEYORBZ.js +25 -0
  34. package/dist/safe-bash/command-chunks/chunk-QM4UZF3C.js +753 -0
  35. package/dist/safe-bash/command-chunks/{chunk-TOSM3T3A.js → chunk-UJOO6DKY.js} +20 -9
  36. package/dist/safe-bash/command-chunks/{chunk-TFZEYNMX.js → chunk-VQLFJCG7.js} +1 -1
  37. package/dist/safe-bash/command-chunks/{chunk-BIXN77VL.js → chunk-VUG324ER.js} +10 -0
  38. package/dist/safe-bash/command-chunks/{chunk-2LP3VMPA.js → chunk-WFDW4XXD.js} +1 -17
  39. package/dist/safe-bash/command-chunks/chunk-WR37IS4O.js +318 -0
  40. package/dist/safe-bash/command-chunks/{chunk-Y5IHIAY3.js → chunk-XNHSCU6I.js} +7 -3
  41. package/dist/safe-bash/commands/basic.js +148 -48
  42. package/dist/safe-bash/commands/bytes/compression/index.js +5 -6
  43. package/dist/safe-bash/commands/cmp.d.ts +2 -3
  44. package/dist/safe-bash/commands/cmp.js +2 -689
  45. package/dist/safe-bash/commands/docx/index.browser.js +3 -46
  46. package/dist/safe-bash/commands/docx/index.d.ts +2 -24
  47. package/dist/safe-bash/commands/docx/index.js +2 -41
  48. package/dist/safe-bash/commands/docx/io.d.ts +1 -14
  49. package/dist/safe-bash/commands/docx/io.js +1 -15
  50. package/dist/safe-bash/commands/llm/index.browser.js +3 -3
  51. package/dist/safe-bash/commands/network/index.browser.js +3 -3
  52. package/dist/safe-bash/commands/node/index.browser.js +3 -3
  53. package/dist/safe-bash/commands/pptx/index.d.ts +2 -28
  54. package/dist/safe-bash/commands/pptx/index.js +2 -152
  55. package/dist/safe-bash/commands/printf-float.d.ts +1 -0
  56. package/dist/safe-bash/commands/printf-float.js +48 -38
  57. package/dist/safe-bash/commands/printf-format.js +9 -6
  58. package/dist/safe-bash/commands/printf-quote.d.ts +3 -0
  59. package/dist/safe-bash/commands/printf-quote.js +62 -0
  60. package/dist/safe-bash/commands/printf-wide.d.ts +5 -0
  61. package/dist/safe-bash/commands/printf-wide.js +41 -0
  62. package/dist/safe-bash/commands/python/index.browser.js +2 -2
  63. package/dist/safe-bash/commands/truncate.d.ts +2 -3
  64. package/dist/safe-bash/commands/truncate.js +2 -686
  65. package/dist/safe-bash/contracts/diagnostics.d.ts +2 -0
  66. package/dist/safe-bash/contracts/diagnostics.js +2 -0
  67. package/dist/safe-bash/contracts/runtime-control.d.ts +2 -0
  68. package/dist/safe-bash/contracts/runtime-control.js +2 -0
  69. package/dist/safe-bash/core.browser.d.ts +1 -1
  70. package/dist/safe-bash/core.browser.js +2651 -4871
  71. package/dist/safe-bash/core.d.ts +10 -0
  72. package/dist/safe-bash/opt-in/commands/cmp/index.d.ts +6 -2
  73. package/dist/safe-bash/opt-in/commands/cmp/index.js +776 -79
  74. package/dist/safe-bash/opt-in/commands/cmp/options.d.ts +0 -12
  75. package/dist/safe-bash/opt-in/commands/cmp/options.js +0 -153
  76. package/dist/safe-bash/opt-in/commands/truncate/index.d.ts +8 -3
  77. package/dist/safe-bash/opt-in/commands/truncate/index.js +790 -272
  78. package/dist/safe-bash/opt-in/commands/truncate/sync.d.ts +1 -0
  79. package/dist/safe-bash/opt-in/commands/truncate/sync.js +60 -0
  80. package/dist/safe-bash/optional-host.browser.js +9 -1
  81. package/dist/safe-bash/optional-host.d.ts +3 -1
  82. package/dist/safe-bash/optional-host.js +3 -1
  83. package/dist/safe-bash/shell/runtime.js +10 -6
  84. package/dist/safe-bash-checksum-engine/index.d.ts +1 -1
  85. package/dist/safe-bash-checksum-engine/index.js +14 -2
  86. package/dist/safe-bash-command-bzip2/index.js +2 -1
  87. package/dist/safe-bash-command-cmp/index.d.ts +10 -0
  88. package/dist/safe-bash-command-cmp/index.js +796 -0
  89. package/dist/safe-bash-command-cmp/options.d.ts +12 -0
  90. package/dist/safe-bash-command-cmp/options.js +42 -0
  91. package/dist/safe-bash-command-csvcut/index.js +11 -8
  92. package/dist/safe-bash-command-csvgrep/index.js +35 -7
  93. package/dist/safe-bash-command-csvkit/codecs/python.js +4 -3
  94. package/dist/safe-bash-command-csvkit/codecs/utf8.js +3 -2
  95. package/dist/safe-bash-command-csvkit/index.js +80 -324
  96. package/dist/safe-bash-command-csvkit/python-regex.d.ts +5 -0
  97. package/dist/safe-bash-command-csvkit/python-regex.js +14 -0
  98. package/dist/safe-bash-command-csvkit/runtime.d.ts +1 -0
  99. package/dist/safe-bash-command-csvkit/sync-support.js +4 -2
  100. package/dist/safe-bash-command-diff3/index.js +3 -0
  101. package/dist/safe-bash-command-docx/LICENSE +21 -0
  102. package/dist/safe-bash-command-docx/index.d.ts +30 -0
  103. package/dist/safe-bash-command-docx/index.js +67 -0
  104. package/dist/safe-bash-command-docx/io.d.ts +14 -0
  105. package/dist/safe-bash-command-docx/io.js +26 -0
  106. package/dist/safe-bash-command-envsubst/index.js +34 -3
  107. package/dist/safe-bash-command-exiftool/index.js +3 -0
  108. package/dist/safe-bash-command-ffmpeg/index.js +1102 -1088
  109. package/dist/safe-bash-command-fold/family.js +1 -1
  110. package/dist/safe-bash-command-fold/index.js +1 -1
  111. package/dist/safe-bash-command-htmlq/index.js +5 -0
  112. package/dist/safe-bash-command-imagemagick/index.d.ts +25 -21
  113. package/dist/safe-bash-command-imagemagick/index.js +669 -271
  114. package/dist/safe-bash-command-mmdc/index.js +48 -10
  115. package/dist/safe-bash-command-mmdc/svg.d.ts +1 -0
  116. package/dist/safe-bash-command-op/index.js +19 -14
  117. package/dist/safe-bash-command-pandoc/command.js +1 -1
  118. package/dist/safe-bash-command-pandoc/index.js +1 -1
  119. package/dist/safe-bash-command-pdfimages/index.d.ts +7 -1
  120. package/dist/safe-bash-command-pdfimages/index.js +63 -33
  121. package/dist/safe-bash-command-pdfinfo/index.d.ts +24 -20
  122. package/dist/safe-bash-command-pdfinfo/index.js +370 -161
  123. package/dist/safe-bash-command-pdftk/index.d.ts +7 -3
  124. package/dist/safe-bash-command-pdftk/index.js +114 -45
  125. package/dist/safe-bash-command-pdftoppm/index.d.ts +15 -7
  126. package/dist/safe-bash-command-pdftoppm/index.js +179 -109
  127. package/dist/safe-bash-command-pdftotext/index.d.ts +9 -5
  128. package/dist/safe-bash-command-pdftotext/index.js +90 -27
  129. package/dist/safe-bash-command-pptx/LICENSE +21 -0
  130. package/dist/safe-bash-command-pptx/index.d.ts +33 -0
  131. package/dist/safe-bash-command-pptx/index.js +168 -0
  132. package/dist/safe-bash-command-qpdf/index.d.ts +9 -3
  133. package/dist/safe-bash-command-qpdf/index.js +80 -29
  134. package/dist/safe-bash-command-sha512sum/index.js +12 -475
  135. package/dist/safe-bash-command-sips/index.d.ts +9 -5
  136. package/dist/safe-bash-command-sips/index.js +63 -44
  137. package/dist/safe-bash-command-soffice/index.d.ts +9 -3
  138. package/dist/safe-bash-command-soffice/index.js +65 -24
  139. package/dist/safe-bash-command-sqlite3/engine.d.ts +9 -0
  140. package/dist/safe-bash-command-sqlite3/index.d.ts +1 -0
  141. package/dist/safe-bash-command-sqlite3/index.js +851 -352
  142. package/dist/safe-bash-command-ssconvert/formats/xls.js +3 -3
  143. package/dist/safe-bash-command-timeout/index.js +3 -3
  144. package/dist/safe-bash-command-truncate/index.d.ts +8 -3
  145. package/dist/safe-bash-command-truncate/index.js +790 -272
  146. package/dist/safe-bash-command-truncate/sync.d.ts +1 -0
  147. package/dist/safe-bash-command-truncate/sync.js +60 -0
  148. package/dist/safe-bash-command-wkhtmltopdf/index.js +92 -38
  149. package/dist/safe-bash-command-wkhtmltopdf/pdf-renderer.d.ts +1 -1
  150. package/dist/safe-bash-command-xxd/index.js +78 -20
  151. package/dist/safe-bash-command-xz/command.d.ts +4 -0
  152. package/dist/safe-bash-command-xz/index.d.ts +1 -1
  153. package/dist/safe-bash-command-xz/index.js +1 -1
  154. package/dist/safe-bash-compression-engine/bounded-codec.js +3 -3
  155. package/dist/safe-bash-compression-engine/codec-loader.js +2 -2
  156. package/dist/safe-bash-compression-engine/files.js +6 -6
  157. package/dist/safe-bash-compression-engine/index.js +5 -5
  158. package/dist/safe-bash-compression-engine/operand.js +6 -6
  159. package/dist/safe-bash-compression-engine/stream.js +5 -5
  160. package/dist/safe-bash-compression-engine/zstd-decode.js +4 -4
  161. package/dist/safe-bash-contracts/command.js +3 -3
  162. package/dist/safe-bash-contracts/diagnostics.js +3 -3
  163. package/dist/safe-bash-contracts/escaping.js +9 -9
  164. package/dist/safe-bash-contracts/filesystem-descriptor.js +3 -3
  165. package/dist/safe-bash-contracts/filesystem-output.js +8 -8
  166. package/dist/safe-bash-contracts/index.js +21 -19
  167. package/dist/safe-bash-contracts/io.d.ts +12 -0
  168. package/dist/safe-bash-contracts/io.js +4 -1
  169. package/dist/safe-bash-contracts/output.js +3 -2
  170. package/dist/safe-bash-contracts/runtime-control.js +2 -2
  171. package/dist/safe-bash-contracts/signals.js +1 -1
  172. package/dist/safe-bash-contracts/yield.d.ts +1 -0
  173. package/dist/safe-bash-contracts/yield.js +3 -1
  174. package/dist/safe-bash-csv-engine/index.d.ts +10 -1
  175. package/dist/safe-bash-csv-engine/index.js +78 -6
  176. package/dist/safe-bash-io-engine/commands/search/requirements.js +3 -3
  177. package/dist/safe-bash-io-engine/commands/text-programs/shared.js +3 -3
  178. package/dist/safe-bash-io-engine/gnu-information.js +1 -1
  179. package/dist/safe-bash-io-engine/internal.d.ts +1 -1
  180. package/dist/safe-bash-io-engine/internal.js +2 -2
  181. package/dist/safe-bash-mcp/index.browser.d.ts +875 -0
  182. package/dist/safe-bash-mcp/index.browser.js +8740 -0
  183. package/dist/safe-bash-mcp/index.js +32 -31
  184. package/dist/safe-bash-query-engine/capture.js +3 -3
  185. package/dist/safe-bash-query-engine/delpaths.js +3 -3
  186. package/dist/safe-bash-query-engine/formats.js +2 -2
  187. package/dist/safe-bash-query-engine/index.js +12 -12
  188. package/dist/safe-bash-query-engine/indices.js +3 -3
  189. package/dist/safe-bash-query-engine/input.js +1 -1
  190. package/dist/safe-bash-query-engine/interpreter.js +10 -10
  191. package/dist/safe-bash-query-engine/query-core.js +12 -12
  192. package/dist/safe-bash-query-engine/regex.js +3 -3
  193. package/dist/safe-bash-query-engine/splits.js +4 -4
  194. package/dist/safe-bash-query-engine/values.js +2 -2
  195. package/package.json +9 -3
  196. package/dist/safe-bash/opt-in/commands/cmp/compare.js +0 -95
  197. package/dist/safe-bash/opt-in/commands/cmp/io.js +0 -218
  198. package/dist/safe-bash/command-chunks/{chunk-FXYWQ6S4.js → chunk-2VTMZTV3.js} +0 -0
  199. package/dist/safe-bash/command-chunks/{chunk-DEH3CMGL.js → chunk-QJ3ONEBI.js} +3 -3
@@ -0,0 +1 @@
1
+ export declare function evalSyncTruncate(opArgs: readonly string[], readFileSync?: (filePath: string) => Uint8Array | undefined, writeFileSync?: (filePath: string, bytes: Uint8Array) => boolean): string | undefined;
@@ -0,0 +1,60 @@
1
+ import { parseArguments, helpText } from "./arguments.js";
2
+ import { syncCommandEvaluators } from "@poe-platform/safe-bash/optional-host";
3
+ export function evalSyncTruncate(opArgs, readFileSync, writeFileSync) {
4
+ try {
5
+ const args = parseArguments(opArgs, false);
6
+ if (args.display === "help")
7
+ return helpText;
8
+ if (args.display === "version")
9
+ return "truncate (safe-bash; GNU coreutils 9.7 semantics)\n";
10
+ if (!writeFileSync || args.files.length === 0)
11
+ return undefined;
12
+ const blockFactor = args.ioBlocks ? 4096n : 1n;
13
+ let refSize;
14
+ if (args.reference !== undefined) {
15
+ const refBytes = readFileSync?.(args.reference);
16
+ if (!refBytes)
17
+ return undefined;
18
+ refSize = BigInt(refBytes.length);
19
+ }
20
+ for (const file of args.files) {
21
+ const existing = readFileSync?.(file);
22
+ if (!existing && args.noCreate)
23
+ continue;
24
+ const curSize = BigInt(existing?.length ?? 0);
25
+ const base = refSize ?? curSize;
26
+ const scaledSize = args.size === undefined ? undefined : args.size * blockFactor;
27
+ let target;
28
+ if (scaledSize === undefined)
29
+ target = refSize;
30
+ else if (args.mode === "absolute")
31
+ target = scaledSize;
32
+ else if (args.mode === "relative")
33
+ target = base + scaledSize;
34
+ else if (args.mode === "<")
35
+ target = base < scaledSize ? base : scaledSize;
36
+ else if (args.mode === ">")
37
+ target = base > scaledSize ? base : scaledSize;
38
+ else if (args.mode === "/")
39
+ target = (base / scaledSize) * scaledSize;
40
+ else
41
+ target = ((base + scaledSize - 1n) / scaledSize) * scaledSize;
42
+ if (target < 0n)
43
+ target = 0n;
44
+ if (target > 1048576n)
45
+ return undefined;
46
+ const n = Number(target);
47
+ const out = new Uint8Array(n);
48
+ if (existing && existing.length > 0) {
49
+ out.set(existing.subarray(0, Math.min(existing.length, n)));
50
+ }
51
+ if (!writeFileSync(file, out))
52
+ return undefined;
53
+ }
54
+ return "";
55
+ }
56
+ catch {
57
+ return undefined;
58
+ }
59
+ }
60
+ syncCommandEvaluators.evalSyncTruncate = evalSyncTruncate;
@@ -3,12 +3,14 @@ import {
3
3
  compareCopyIdentity,
4
4
  compareObservedEntries,
5
5
  errors_exports,
6
+ input_budget_exports,
6
7
  limits_exports,
7
8
  matcher_exports,
8
9
  portableTrapExtension,
10
+ portable_requirements_exports,
9
11
  syntax_exports,
10
12
  timeout_exports
11
- } from "./chunks/chunk-Q3E6C3DX.js";
13
+ } from "./chunks/chunk-KHJGUF2W.js";
12
14
  import {
13
15
  jobsExtension
14
16
  } from "./chunks/chunk-2AYZCT5X.js";
@@ -48,11 +50,13 @@ var bytes_exports = {};
48
50
  init_platform();
49
51
  __reExport(bytes_exports, bytes_star);
50
52
  import * as bytes_star from "../safe-bash-query-engine/bytes.js";
53
+ var export_ByteInputBudget = input_budget_exports.ByteInputBudget;
51
54
  var export_Decimal = numbers_exports.Decimal;
52
55
  var export_EreLedger = limits_exports.EreLedger;
53
56
  var export_EreProfileLimitError = errors_exports.EreProfileLimitError;
54
57
  var export_EreSyntaxError = errors_exports.EreSyntaxError;
55
58
  var export_EreUnsupportedError = errors_exports.EreUnsupportedError;
59
+ var export_UsageError = internal_exports.UsageError;
56
60
  var export_YqLedger = accounting_exports.YqLedger;
57
61
  var export_builtInDirectContextExecutors = internal_exports.builtInDirectContextExecutors;
58
62
  var export_codeOf = internal_exports.codeOf;
@@ -61,6 +65,7 @@ var export_compileEre = syntax_exports.compileEre;
61
65
  var export_decodeBase64 = bytes_exports.decodeBase64;
62
66
  var export_decoder = internal_exports.decoder;
63
67
  var export_encodeBase64 = bytes_exports.encodeBase64;
68
+ var export_inputRequirements = portable_requirements_exports.inputRequirements;
64
69
  var export_isDefaultCommandOptions = internal_exports.isDefaultCommandOptions;
65
70
  var export_latin1Text = byte_encoding_exports.latin1Text;
66
71
  var export_numberText = numbers_exports.numberText;
@@ -76,11 +81,13 @@ var export_utf8ByteLength = bytes_exports.utf8ByteLength;
76
81
  var export_utf8Decoder = bytes_exports.utf8Decoder;
77
82
  var export_utf8Encoder = bytes_exports.utf8Encoder;
78
83
  export {
84
+ export_ByteInputBudget as ByteInputBudget,
79
85
  export_Decimal as Decimal,
80
86
  export_EreLedger as EreLedger,
81
87
  export_EreProfileLimitError as EreProfileLimitError,
82
88
  export_EreSyntaxError as EreSyntaxError,
83
89
  export_EreUnsupportedError as EreUnsupportedError,
90
+ export_UsageError as UsageError,
84
91
  export_YqLedger as YqLedger,
85
92
  export_builtInDirectContextExecutors as builtInDirectContextExecutors,
86
93
  export_codeOf as codeOf,
@@ -91,6 +98,7 @@ export {
91
98
  export_decodeBase64 as decodeBase64,
92
99
  export_decoder as decoder,
93
100
  export_encodeBase64 as encodeBase64,
101
+ export_inputRequirements as inputRequirements,
94
102
  export_isDefaultCommandOptions as isDefaultCommandOptions,
95
103
  jobsExtension,
96
104
  export_latin1Text as latin1Text,
@@ -1,7 +1,7 @@
1
1
  export { signalName } from "./commands/timeout/index.js";
2
2
  export { latin1Text } from "./byte-encoding.js";
3
3
  export { jobsExtension } from "./shell/extensions/jobs/index.js";
4
- export { builtInDirectContextExecutors, codeOf, decoder, isDefaultCommandOptions, output, pathOf, registerDefaultExecutor, registerDefaultExecutors, syncCommandEvaluators, } from "./commands/internal.js";
4
+ export { builtInDirectContextExecutors, codeOf, decoder, isDefaultCommandOptions, output, pathOf, registerDefaultExecutor, registerDefaultExecutors, syncCommandEvaluators, UsageError, } from "./commands/internal.js";
5
5
  export { portableTrapExtension } from "./shell/trap.js";
6
6
  export type { TrapExtensionOptions, TrapSignalHost } from "./shell/trap.js";
7
7
  export { compareCopyIdentity, compareObservedEntries } from "./commands/copy-identity.js";
@@ -15,4 +15,6 @@ export { Decimal, numberText } from "./commands/structured/numbers.js";
15
15
  export { utf8ByteLength, utf8Encoder, utf8Decoder, encodeBase64, decodeBase64, compareBytes } from "./commands/structured/bytes.js";
16
16
  export type { PreparedShellChild, ShellBindingReference, ShellBindingResult, ShellChildPreparation, ShellExecutionCheckpoint, ShellExtension, ShellExtensionBuiltin, ShellExtensionContext, ShellExtensionEvent, ShellExtensionInstance, ShellExtensionOption, ShellExtensionScope, ShellIndexedWriter, ShellInputBorrow, ShellInputObserver, ShellListTerminatorContext, ShellListTerminatorHook, ShellSpecialParameterHook, } from "./shell/extensions.js";
17
17
  export type { RawRecord, ReadLine } from "./shell/input.js";
18
+ export { ByteInputBudget } from "./commands/bytes/input-budget.js";
19
+ export { inputRequirements } from "./commands/portable-requirements.js";
18
20
  //# sourceMappingURL=optional-host.d.ts.map
@@ -1,7 +1,7 @@
1
1
  export { signalName } from "./commands/timeout/index.js";
2
2
  export { latin1Text } from "./byte-encoding.js";
3
3
  export { jobsExtension } from "./shell/extensions/jobs/index.js";
4
- export { builtInDirectContextExecutors, codeOf, decoder, isDefaultCommandOptions, output, pathOf, registerDefaultExecutor, registerDefaultExecutors, syncCommandEvaluators, } from "./commands/internal.js";
4
+ export { builtInDirectContextExecutors, codeOf, decoder, isDefaultCommandOptions, output, pathOf, registerDefaultExecutor, registerDefaultExecutors, syncCommandEvaluators, UsageError, } from "./commands/internal.js";
5
5
  export { portableTrapExtension } from "./shell/trap.js";
6
6
  export { compareCopyIdentity, compareObservedEntries } from "./commands/copy-identity.js";
7
7
  export { EreLedger } from "./commands/regex-execution/ere/limits.js";
@@ -12,4 +12,6 @@ export { parseTomlDocument } from "./commands/yq/toml.js";
12
12
  export { YqLedger } from "./commands/yq/accounting.js";
13
13
  export { Decimal, numberText } from "./commands/structured/numbers.js";
14
14
  export { utf8ByteLength, utf8Encoder, utf8Decoder, encodeBase64, decodeBase64, compareBytes } from "./commands/structured/bytes.js";
15
+ export { ByteInputBudget } from "./commands/bytes/input-budget.js";
16
+ export { inputRequirements } from "./commands/portable-requirements.js";
15
17
  //# sourceMappingURL=optional-host.js.map
@@ -16311,7 +16311,9 @@ export class Runtime {
16311
16311
  !hasShellFunction(rawState, "getopts") &&
16312
16312
  !rawState.extensions?.builtins.has("getopts") &&
16313
16313
  !hasActiveVariableAttributes(rawState)) {
16314
- const optstring = condCmd.words[1].plain ?? this.fastValueWord(condCmd.words[1], rawState, io, true, false, false, true, undefined, diagnosticLine);
16314
+ // Expanded optstrings can change after each body execution. Keep them
16315
+ // on the normal path, which expands each getopts invocation.
16316
+ const optstring = condCmd.words[1].plain;
16315
16317
  const optVar = condCmd.words[2].plain;
16316
16318
  if (typeof optstring !== "string" ||
16317
16319
  !optVar ||
@@ -16559,6 +16561,7 @@ export class Runtime {
16559
16561
  lastCmd = condCmd;
16560
16562
  lastArg = this.fastValueWord(condCmd.words[condCmd.words.length - 1], rawState, io, false, false, false, true);
16561
16563
  }
16564
+ rawState.status = condNonZero ? 0 : 1;
16562
16565
  if (condNonZero !== (command.kind === "while"))
16563
16566
  break;
16564
16567
  ++iterCount;
@@ -18123,8 +18126,9 @@ export class Runtime {
18123
18126
  : this.evalSyncLoopArithStmt(nl.condArith, rawState, io, touched, nl.condLine);
18124
18127
  if (nl.condCmd?.kind === "simple") {
18125
18128
  innerLastCmd = nl.condCmd;
18126
- innerLastArg = "]";
18129
+ innerLastArg = this.fastValueWord(nl.condCmd.words[nl.condCmd.words.length - 1], rawState, io, false, false, false, true);
18127
18130
  }
18131
+ rawState.status = condOk ? 0 : 1;
18128
18132
  if (condOk !== (lc.kind === "while"))
18129
18133
  break;
18130
18134
  this.budget.loop();
@@ -18258,11 +18262,11 @@ export class Runtime {
18258
18262
  }
18259
18263
  else if (step.condStmt !== undefined) {
18260
18264
  const cStatus = this.tryEvalConditionalSync(step.condStmt, rawState, monitor, arrayStore(rawState), io, step.line) ?? 1;
18261
- rawState.status = cStatus;
18262
18265
  if (step.cmd.kind === "simple") {
18263
18266
  lastArg = this.fastValueWord(step.cmd.words[step.cmd.words.length - 1], rawState, io, false, false, false, true);
18264
18267
  onUpdate({ lastCmd, lastArg });
18265
18268
  }
18269
+ rawState.status = cStatus;
18266
18270
  continue;
18267
18271
  }
18268
18272
  else if (step.arithStmt !== undefined) {
@@ -21050,7 +21054,7 @@ export class Runtime {
21050
21054
  }
21051
21055
  const def = this.commands.get(name);
21052
21056
  let fastOut;
21053
- if (name === "echo" && def && defaultEchoExecutors.has(def.execute) && (args.length === 0 || !args[0].startsWith("-"))) {
21057
+ if (name === "echo" && (options.env ?? context.env).POSIXLY_CORRECT === undefined && def && defaultEchoExecutors.has(def.execute) && (args.length === 0 || !args[0].startsWith("-"))) {
21054
21058
  fastOut = args.join(" ") + "\n";
21055
21059
  }
21056
21060
  else if (name === "printf" && def?.execute === printfCommand.execute && args.length >= 1 && !args[0].startsWith("-"))
@@ -24845,8 +24849,8 @@ export class Runtime {
24845
24849
  this.signal.throwIfAborted();
24846
24850
  if (error instanceof ShellLimitError)
24847
24851
  throw error;
24848
- await this.diagnostic(context, "indexed array: unsupported subscript");
24849
- status = 2;
24852
+ await this.diagnostic(context, `unset: ${name}: bad array subscript`);
24853
+ status = 1;
24850
24854
  continue;
24851
24855
  }
24852
24856
  if (index === undefined) {
@@ -1,5 +1,5 @@
1
1
  import { type CommandDefinition } from "../safe-bash-contracts/index.js";
2
2
  type Algorithm = "sha512" | "sha384" | "sha256" | "sha224" | "sha1" | "md5" | "crc" | "bsd" | "sysv" | "crc32b" | "sm3" | "blake2b" | "sha3";
3
- export declare function command(name: string, algorithm: Algorithm, maxInputBytes: number): CommandDefinition;
3
+ export declare function command(name: string, algorithm: Algorithm, maxInputBytes: number, maxArgumentBytes?: number): CommandDefinition;
4
4
  export declare function evalSyncChecksum(name: string, inBytes: Uint8Array | undefined, opArgs: readonly string[], readFileSync?: (p: string) => Uint8Array | undefined, fileOperandName?: string): string | undefined;
5
5
  export {};
@@ -7,6 +7,7 @@ import {
7
7
 
8
8
  // packages/safe-bash-checksum-engine/dist/index.js
9
9
  init_buffer();
10
+ import { shellValueByteLength } from "../safe-bash-contracts/value.js";
10
11
  import { yieldTurn } from "../safe-bash-contracts/yield.js";
11
12
  import { blake2b } from "@noble/hashes/blake2.js";
12
13
  import { sha3_224, sha3_256, sha3_384, sha3_512 } from "@noble/hashes/sha3.js";
@@ -14,7 +15,7 @@ import { PublicDiagnostic } from "../safe-bash-contracts/diagnostics.js";
14
15
  import { md5, sha1 } from "@noble/hashes/legacy.js";
15
16
  import { sha224, sha256, sha384, sha512 } from "@noble/hashes/sha2.js";
16
17
  import { bytesToHex, hexToBytes } from "@noble/hashes/utils.js";
17
- import { FsError, readBytes, toByteSource } from "../safe-bash-contracts/index.js";
18
+ import { FsError, getCommandArguments, readBytes, toByteSource } from "../safe-bash-contracts/index.js";
18
19
  import { codeOf, define, diagnostic, encoder, options, output, pathOf, UsageError, value } from "../safe-bash-io-engine/internal.js";
19
20
  import { ByteInputBudget } from "../safe-bash-byte-input-engine/index.js";
20
21
  var blockBytes = 64 * 1024;
@@ -423,14 +424,25 @@ async function verify(context, manifest, algorithm, settings, state) {
423
424
  }
424
425
  return valid && matched && !failures && !mismatched && (!settings.strict || !malformed);
425
426
  }
426
- function command(name, algorithm, maxInputBytes) {
427
+ function command(name, algorithm, maxInputBytes, maxArgumentBytes = Infinity) {
427
428
  return define(name, async (context) => {
429
+ if (maxArgumentBytes !== Infinity) {
430
+ const arguments_ = getCommandArguments(context);
431
+ let argumentBytes = 0;
432
+ for (let index = 0; index < arguments_.args.length; index++) {
433
+ const bytes = shellValueByteLength(arguments_.values[index]);
434
+ if (bytes > maxArgumentBytes - argumentBytes)
435
+ throw new FsError("EFBIG", { message: "checksum argument limit exceeded" });
436
+ argumentBytes += bytes;
437
+ }
438
+ }
428
439
  const selected = name === "cksum" ? parseCksum(context.args) : { algorithm, settings: parse(context.args, algorithm) };
429
440
  const selectedAlgorithm = selected.algorithm;
430
441
  const settings = selected.settings;
431
442
  const state = { stdinUsed: false, budget: new ByteInputBudget(maxInputBytes) };
432
443
  let failed = false;
433
444
  for (const filename of settings.operands.length ? settings.operands : ["-"]) {
445
+ await yieldTurn(context.signal);
434
446
  context.signal.throwIfAborted();
435
447
  if (settings.check) {
436
448
  try {
@@ -10,6 +10,7 @@ import { codeOf, diagnostic, output } from "../safe-bash-compression-engine/inte
10
10
  import { runOperand } from "../safe-bash-compression-engine/operand.js";
11
11
  import { planOperands, verifyOperandDestinations } from "../safe-bash-compression-engine/files.js";
12
12
  import { parseOptions, profiles } from "../safe-bash-compression-engine/options.js";
13
+ import { CompressedDataError } from "../safe-bash-compression-engine/errors.js";
13
14
  import { DecodedBudget } from "../safe-bash-compression-engine/stream.js";
14
15
  function settings(options = {}) {
15
16
  const maxDecodedBytes = options.limits?.maxDecodedBytes ?? options.maxDecodedBytes ?? Infinity;
@@ -95,7 +96,7 @@ No FILE or FILE '-' uses stdin; file output uses private VFS staging.
95
96
  context.signal.throwIfAborted();
96
97
  if (parsed.quiet < 2)
97
98
  await diagnostic(context, error);
98
- exitCode = 1;
99
+ exitCode = Math.max(exitCode, error instanceof CompressedDataError ? 2 : 1);
99
100
  if (decodedBudget.exceeded)
100
101
  break;
101
102
  }
@@ -0,0 +1,10 @@
1
+ import { type CommandDefinition, type VirtualShellPlugin } from "../safe-bash-contracts/index.js";
2
+ import { type CmpCommandsOptions } from "./options.js";
3
+ export type { CmpLimits, CmpCommandsOptions } from "./options.js";
4
+ export declare function evalSyncCmp(inBytes: Uint8Array | undefined, opArgs: readonly string[], readFileSync?: (path: string) => Uint8Array | undefined): string | undefined;
5
+ /** Opt-in GNU comparison-block behavior; producer fragments do not define blocks. */
6
+ export declare const createCmpCommand: (options?: CmpCommandsOptions | undefined) => CommandDefinition;
7
+ /** Existing default-shell behavior, sharing the same retained-input engine. */
8
+ export declare const cmpCommand: (options?: CmpCommandsOptions | undefined) => CommandDefinition;
9
+ export declare function createCmpCommands(options?: CmpCommandsOptions): readonly CommandDefinition[];
10
+ export declare function cmpCommands(options?: CmpCommandsOptions): VirtualShellPlugin;