@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
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  gnuInformation,
6
6
  gnuInformationSync
7
- } from "./chunk-Y5IHIAY3.js";
7
+ } from "./chunk-XNHSCU6I.js";
8
8
  import {
9
9
  inputRequirements
10
10
  } from "./chunk-YAFQG4SC.js";
@@ -505,7 +505,7 @@ function replaceArgument(source, pattern, replacement) {
505
505
  chunks.push(source.subarray(start));
506
506
  return concatenate(chunks);
507
507
  }
508
- function escapeBytes(text, zeroOctal = false, bareOctal = false, unicode) {
508
+ function escapeBytes(text, zeroOctal = false, bareOctal = false, unicode, literalFormat = false) {
509
509
  if (unicode && typeof text === "string")
510
510
  text = encoder.encode(text);
511
511
  if (typeof text === "string") {
@@ -513,14 +513,19 @@ function escapeBytes(text, zeroOctal = false, bareOctal = false, unicode) {
513
513
  const control2 = { a: 7, b: 8, e: 27, E: 27, f: 12, n: 10, r: 13, t: 9, v: 11, "\\": 92 };
514
514
  for (let index = 0; index < text.length; ) {
515
515
  if (text[index] !== "\\" || index + 1 === text.length) {
516
- const character = String.fromCodePoint(text.codePointAt(index));
517
- chunks.push(encoder.encode(character));
518
- index += character.length;
516
+ const character2 = String.fromCodePoint(text.codePointAt(index));
517
+ chunks.push(encoder.encode(character2));
518
+ index += character2.length;
519
519
  continue;
520
520
  }
521
521
  const next = text[index + 1];
522
- if (next === "c")
522
+ if (!literalFormat && next === "c")
523
523
  return { bytes: concatenate(chunks), stop: true };
524
+ if (literalFormat && (next === "'" || next === '"' || next === "?")) {
525
+ chunks.push(encoder.encode(next));
526
+ index += 2;
527
+ continue;
528
+ }
524
529
  if (control2[next] !== void 0) {
525
530
  chunks.push(Uint8Array.of(control2[next]));
526
531
  index += 2;
@@ -539,8 +544,9 @@ function escapeBytes(text, zeroOctal = false, bareOctal = false, unicode) {
539
544
  index += 1 + hexadecimal[0].length;
540
545
  continue;
541
546
  }
542
- chunks.push(encoder.encode(`\\${next}`));
543
- index += 2;
547
+ const character = String.fromCodePoint(text.codePointAt(index + 1));
548
+ chunks.push(encoder.encode(`\\${character}`));
549
+ index += 1 + character.length;
544
550
  }
545
551
  return { bytes: concatenate(chunks), stop: false };
546
552
  }
@@ -554,8 +560,13 @@ function escapeBytes(text, zeroOctal = false, bareOctal = false, unicode) {
554
560
  continue;
555
561
  }
556
562
  const next = source[index + 1];
557
- if (next === 99)
563
+ if (!literalFormat && next === 99)
558
564
  return { bytes: bytes.subarray(0, size), stop: true };
565
+ if (literalFormat && (next === 39 || next === 34 || next === 63)) {
566
+ bytes[size++] = next;
567
+ index += 2;
568
+ continue;
569
+ }
559
570
  if (control[next] !== void 0) {
560
571
  bytes[size++] = control[next];
561
572
  index += 2;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  indexValue,
3
3
  type
4
- } from "./chunk-IFUNAM4D.js";
4
+ } from "./chunk-5L62A5RO.js";
5
5
  import {
6
6
  JqError,
7
7
  JqLimitError,
@@ -791,6 +791,11 @@ async function* readChunks(source, budget) {
791
791
  if (_p)
792
792
  await _p;
793
793
  }
794
+ if (chunk.byteLength === 0) {
795
+ const pending = budget.ensureFreshWindow();
796
+ if (pending)
797
+ await pending;
798
+ }
794
799
  budget.inputBytes += chunk.byteLength;
795
800
  if (budget.inputBytes > budget.limits.maxInputBytes)
796
801
  throw new JqLimitError("maxInputBytes");
@@ -1211,6 +1216,11 @@ async function* jsonValues(source, budget, options = {}) {
1211
1216
  break;
1212
1217
  }
1213
1218
  const rawChunk = res.value;
1219
+ if (rawChunk.byteLength === 0) {
1220
+ const pending = budget.ensureFreshWindow();
1221
+ if (pending)
1222
+ await pending;
1223
+ }
1214
1224
  const pt = budget.tickSync();
1215
1225
  if (pt)
1216
1226
  await pt;
@@ -33,26 +33,10 @@ var CsvkitCleanupError = class extends AggregateError {
33
33
  }
34
34
  };
35
35
 
36
- // packages/safe-bash-command-csvkit/dist/diagnostics/exception.js
37
- init_buffer();
38
- var PythonException = class extends CsvkitDiagnostic {
39
- exceptionClass;
40
- detail;
41
- traceback;
42
- constructor(exceptionClass, detail, traceback) {
43
- super(detail);
44
- this.exceptionClass = exceptionClass;
45
- this.detail = detail;
46
- this.traceback = traceback;
47
- this.name = exceptionClass;
48
- }
49
- };
50
-
51
36
  export {
52
37
  CsvkitDiagnostic,
53
38
  CsvkitBlocked,
54
39
  CsvkitOutputBudgetError,
55
40
  CsvkitWorkBudgetError,
56
- CsvkitCleanupError,
57
- PythonException
41
+ CsvkitCleanupError
58
42
  };
@@ -0,0 +1,318 @@
1
+ import {
2
+ decimalZeroes
3
+ } from "./chunk-QM4UZF3C.js";
4
+ import {
5
+ CsvkitBlocked
6
+ } from "./chunk-WFDW4XXD.js";
7
+ import {
8
+ init_buffer
9
+ } from "./chunk-HX3SHTCE.js";
10
+
11
+ // packages/safe-bash-command-csvkit/dist/python-regex.js
12
+ init_buffer();
13
+ function pythonWhitespace(char) {
14
+ const code = char.codePointAt(0);
15
+ return code >= 9 && code <= 13 || code >= 28 && code <= 32 || code === 133 || code === 160 || code === 5760 || code >= 8192 && code <= 8202 || code === 8232 || code === 8233 || code === 8239 || code === 8287 || code === 12288;
16
+ }
17
+ function fixedWidth(node) {
18
+ if (node.kind === "char")
19
+ return 1;
20
+ if (node.kind === "anchor" || node.kind === "assertion")
21
+ return 0;
22
+ if (node.kind === "repeat") {
23
+ const width = fixedWidth(node.node);
24
+ return width === 0 ? 0 : width !== void 0 && node.min === node.max ? width * node.min : void 0;
25
+ }
26
+ const widths = node.nodes.map(fixedWidth);
27
+ if (widths.some((width) => width === void 0))
28
+ return void 0;
29
+ if (node.kind === "alternative")
30
+ return widths.every((width) => width === widths[0]) ? widths[0] : void 0;
31
+ return widths.reduce((sum, width) => sum + width, 0);
32
+ }
33
+ function compilePythonSearch(pattern, step, maxWork, retain) {
34
+ retain(64 + pattern.length * 8);
35
+ const chars = Array.from(pattern);
36
+ let index = 0;
37
+ let insensitive = false;
38
+ let dotall = false;
39
+ let multiline = false;
40
+ let ascii = false;
41
+ let unicode = false;
42
+ const unsupported = () => {
43
+ throw new CsvkitBlocked("Python regex syntax or diagnostic outside qualified subset");
44
+ };
45
+ while (chars[index] === "(" && chars[index + 1] === "?") {
46
+ let end = index + 2;
47
+ while (chars[end] && "aimsu".includes(chars[end])) {
48
+ step();
49
+ end++;
50
+ }
51
+ if (end > index + 2 && chars[end] === ")") {
52
+ const flags = chars.slice(index + 2, end);
53
+ insensitive ||= flags.includes("i");
54
+ dotall ||= flags.includes("s");
55
+ multiline ||= flags.includes("m");
56
+ ascii ||= flags.includes("a");
57
+ unicode ||= flags.includes("u");
58
+ if (ascii && unicode)
59
+ unsupported();
60
+ index = end + 1;
61
+ } else
62
+ break;
63
+ }
64
+ const digit = (char) => ascii ? char >= "0" && char <= "9" : decimalZeroes.some((zero) => char.codePointAt(0) >= zero && char.codePointAt(0) < zero + 10);
65
+ const word = (char) => {
66
+ if (!ascii && char.codePointAt(0) > 127)
67
+ return unsupported();
68
+ return char === "_" || /^[a-zA-Z0-9]$/.test(char);
69
+ };
70
+ const space = (char) => ascii ? " \n\r\f\v".includes(char) : pythonWhitespace(char);
71
+ const literal = (value) => ({ kind: "char", test: (char) => {
72
+ if (insensitive && (value.codePointAt(0) > 127 || char.codePointAt(0) > 127))
73
+ unsupported();
74
+ return insensitive ? char.toLowerCase() === value.toLowerCase() : char === value;
75
+ } });
76
+ function escape(inClass = false) {
77
+ const value = chars[index++];
78
+ if (!value)
79
+ return unsupported();
80
+ if (value === "x" || value === "u" || value === "U") {
81
+ const length = value === "x" ? 2 : value === "u" ? 4 : 8;
82
+ let hex = "";
83
+ for (let count = 0; count < length; count++) {
84
+ step();
85
+ const digit2 = chars[index++];
86
+ if (!digit2 || !"0123456789abcdefABCDEF".includes(digit2))
87
+ return unsupported();
88
+ hex += digit2;
89
+ }
90
+ const code = Number.parseInt(hex, 16);
91
+ if (code > 1114111)
92
+ return unsupported();
93
+ return literal(String.fromCodePoint(code));
94
+ }
95
+ const predicate = { d: digit, s: space, w: word }[value.toLowerCase()];
96
+ if (predicate)
97
+ return { kind: "char", test: (char) => value === value.toLowerCase() ? predicate(char) : !predicate(char) };
98
+ if (!inClass && (value === "A" || value === "Z" || value === "z"))
99
+ return { kind: "anchor", test: (text, position) => value === "A" ? position === 0 : position === text.length };
100
+ if (!inClass && (value === "b" || value === "B"))
101
+ return { kind: "anchor", test: (text, position) => {
102
+ if (value === "B" && text.length === 0)
103
+ return true;
104
+ const boundary = (position > 0 && word(text[position - 1])) !== (position < text.length && word(text[position]));
105
+ return value === "b" ? boundary : !boundary;
106
+ } };
107
+ const control = { n: "\n", r: "\r", t: " ", f: "\f", v: "\v", a: "\x07", b: "\b" }[value];
108
+ if (control !== void 0)
109
+ return literal(control);
110
+ if (/^[a-zA-Z0-9]$/.test(value))
111
+ return unsupported();
112
+ return literal(value);
113
+ }
114
+ function atom() {
115
+ step();
116
+ const value = chars[index++];
117
+ if (!value)
118
+ return unsupported();
119
+ if (value === "\\")
120
+ return escape();
121
+ if (value === ".")
122
+ return { kind: "char", test: (char) => dotall || char !== "\n" };
123
+ if (value === "^")
124
+ return { kind: "anchor", test: (text, position) => position === 0 || multiline && text[position - 1] === "\n" };
125
+ if (value === "$")
126
+ return { kind: "anchor", test: (text, position) => position === text.length || text[position] === "\n" && (multiline || position === text.length - 1) };
127
+ if (value === "(") {
128
+ let assertion;
129
+ if (chars[index] === "?") {
130
+ const modifier = chars[index + 1];
131
+ if (modifier === ":")
132
+ index += 2;
133
+ else if (modifier === "=" || modifier === "!") {
134
+ assertion = { negative: modifier === "!", behind: false };
135
+ index += 2;
136
+ } else if (modifier === "<" && (chars[index + 2] === "=" || chars[index + 2] === "!")) {
137
+ assertion = { negative: chars[index + 2] === "!", behind: true };
138
+ index += 3;
139
+ } else
140
+ return unsupported();
141
+ }
142
+ const node = expression();
143
+ if (chars[index++] !== ")")
144
+ return unsupported();
145
+ if (assertion) {
146
+ const behind = assertion.behind ? fixedWidth(node) : void 0;
147
+ if (assertion.behind && behind === void 0)
148
+ return unsupported();
149
+ return { kind: "assertion", node, negative: assertion.negative, behind };
150
+ }
151
+ return node;
152
+ }
153
+ if (value === "[") {
154
+ if (chars[index] === "[")
155
+ return unsupported();
156
+ const negate = chars[index] === "^";
157
+ if (negate)
158
+ index++;
159
+ const tests = [];
160
+ while (index < chars.length && (chars[index] !== "]" || tests.length === 0)) {
161
+ const first = chars[index++];
162
+ if (first && "&|~".includes(first) && chars[index] === first)
163
+ return unsupported();
164
+ if (first === "-" && tests.length > 0 && chars[index] === "-")
165
+ return unsupported();
166
+ if (first === "\\") {
167
+ const escaped = escape(true);
168
+ if (escaped.kind !== "char")
169
+ return unsupported();
170
+ if (chars[index] === "-" && chars[index + 1] !== "]")
171
+ return unsupported();
172
+ tests.push(escaped.test);
173
+ } else if (chars[index] === "-" && chars[index + 1] !== "]" && chars[index + 1] !== void 0) {
174
+ index++;
175
+ const last = chars[index++];
176
+ if (!first || !last || last === "\\" || first.codePointAt(0) > last.codePointAt(0) || insensitive)
177
+ return unsupported();
178
+ tests.push((char) => char.codePointAt(0) >= first.codePointAt(0) && char.codePointAt(0) <= last.codePointAt(0));
179
+ } else {
180
+ const item = literal(first);
181
+ if (item.kind !== "char")
182
+ return unsupported();
183
+ tests.push(item.test);
184
+ }
185
+ }
186
+ if (chars[index++] !== "]")
187
+ return unsupported();
188
+ return { kind: "char", test: (char) => tests.some((test) => test(char)) !== negate };
189
+ }
190
+ if ("*+?{} )".includes(value) && value !== " ")
191
+ return unsupported();
192
+ return literal(value);
193
+ }
194
+ function expression() {
195
+ const alternatives = [];
196
+ do {
197
+ const nodes = [];
198
+ while (index < chars.length && chars[index] !== "|" && chars[index] !== ")") {
199
+ let node = atom();
200
+ const quantifier = chars[index];
201
+ if (quantifier && "*+?{".includes(quantifier)) {
202
+ if (node.kind === "anchor")
203
+ return unsupported();
204
+ index++;
205
+ let min = quantifier === "+" ? 1 : 0;
206
+ let max = quantifier === "?" ? 1 : Infinity;
207
+ if (quantifier === "{") {
208
+ let digits = "";
209
+ while (chars[index] && "0123456789".includes(chars[index])) {
210
+ step();
211
+ digits += chars[index++];
212
+ }
213
+ if (!digits && chars[index] !== ",")
214
+ return unsupported();
215
+ min = digits ? Number(digits) : 0;
216
+ max = min;
217
+ if (chars[index] === ",") {
218
+ index++;
219
+ digits = "";
220
+ while (chars[index] && "0123456789".includes(chars[index])) {
221
+ step();
222
+ digits += chars[index++];
223
+ }
224
+ max = digits ? Number(digits) : Infinity;
225
+ }
226
+ if (chars[index++] !== "}" || min > max || !Number.isSafeInteger(min) || min >= 4294967295 || max !== Infinity && (!Number.isSafeInteger(max) || max >= 4294967295))
227
+ return unsupported();
228
+ }
229
+ node = { kind: "repeat", node, min, max };
230
+ if (chars[index] === "?")
231
+ index++;
232
+ if (chars[index] === "+")
233
+ return unsupported();
234
+ }
235
+ nodes.push(node);
236
+ }
237
+ alternatives.push({ kind: "sequence", nodes });
238
+ if (chars[index] !== "|")
239
+ break;
240
+ index++;
241
+ } while (index <= chars.length);
242
+ return { kind: "alternative", nodes: alternatives };
243
+ }
244
+ const root = expression();
245
+ if (index !== chars.length)
246
+ unsupported();
247
+ let work = 0;
248
+ const tick = () => {
249
+ step();
250
+ if (++work > maxWork)
251
+ throw new CsvkitBlocked("Python regex work budget exceeded");
252
+ };
253
+ function* evaluate(node, text, position) {
254
+ tick();
255
+ if (node.kind === "char") {
256
+ if (position < text.length && node.test(text[position]))
257
+ yield position + 1;
258
+ } else if (node.kind === "anchor") {
259
+ if (node.test(text, position))
260
+ yield position;
261
+ } else if (node.kind === "assertion") {
262
+ const start = node.behind === void 0 ? position : position - node.behind;
263
+ let matched = false;
264
+ if (start >= 0)
265
+ for (const end of evaluate(node.node, text, start)) {
266
+ if (node.behind === void 0 || end === position) {
267
+ matched = true;
268
+ break;
269
+ }
270
+ }
271
+ if (matched !== node.negative)
272
+ yield position;
273
+ } else if (node.kind === "alternative") {
274
+ for (const child of node.nodes)
275
+ yield* evaluate(child, text, position);
276
+ } else if (node.kind === "sequence") {
277
+ const nodes = node.nodes;
278
+ function* sequence(index2, offset) {
279
+ tick();
280
+ if (index2 === nodes.length)
281
+ yield offset;
282
+ else
283
+ for (const next of evaluate(nodes[index2], text, offset))
284
+ yield* sequence(index2 + 1, next);
285
+ }
286
+ yield* sequence(0, position);
287
+ } else {
288
+ let positions = /* @__PURE__ */ new Set([position]);
289
+ for (let count = 0; count <= node.max && positions.size; count++) {
290
+ tick();
291
+ if (count >= node.min)
292
+ yield* positions;
293
+ const next = /* @__PURE__ */ new Set();
294
+ for (const offset of positions)
295
+ for (const end of evaluate(node.node, text, offset)) {
296
+ if (end !== offset || count < node.min)
297
+ next.add(end);
298
+ }
299
+ positions = next;
300
+ }
301
+ }
302
+ }
303
+ return (text) => {
304
+ retain(64 + text.length * 8);
305
+ const input = Array.from(text);
306
+ for (let start = 0; start <= input.length; start++)
307
+ for (const ignored of evaluate(root, input, start)) {
308
+ void ignored;
309
+ return true;
310
+ }
311
+ return false;
312
+ };
313
+ }
314
+
315
+ export {
316
+ pythonWhitespace,
317
+ compilePythonSearch
318
+ };
@@ -48,7 +48,7 @@ var information = {
48
48
  wc: { usage: "[OPTION]... [FILE]...", description: "Count input lines, words, bytes, characters or display width.", options: ["-l, --lines", "-w, --words", "-c, --bytes", "-m, --chars", "-L, --max-line-length"] },
49
49
  pwd: { usage: "[OPTION]...", description: "Print the full filename of the current working directory.", options: ["-L, --logical", "-P, --physical"] },
50
50
  true: { usage: "[ignored command line arguments]", description: "Exit with a status code indicating success.", options: [] },
51
- false: { usage: "[ignored command line arguments]", description: "Exit with a status code indicating failure.", options: [] },
51
+ false: { usage: "[ignored command line arguments]", description: "Exit with a status code indicating failure.", options: [], exitCode: 1 },
52
52
  echo: { usage: "[SHORT-OPTION]... [STRING]...", description: "Echo the STRING(s) to standard output.", options: ["-n", "-e", "-E"] },
53
53
  "[": { usage: "EXPRESSION ]", description: "Evaluate conditional expression.", options: [] }
54
54
  };
@@ -125,6 +125,10 @@ function gnuInformation(name, context) {
125
125
  return gnuInformationSlow(name, context);
126
126
  }
127
127
  async function gnuInformationSlow(name, context) {
128
+ if (name === "echo" && context.env.POSIXLY_CORRECT !== void 0)
129
+ return void 0;
130
+ if (name === "pwd" && !context.externalInvocation)
131
+ return void 0;
128
132
  if ((name === "true" || name === "false" || name === "echo" || name === "[") && (context.args.length !== 1 || !context.externalInvocation))
129
133
  return void 0;
130
134
  const info = information[name] ?? (["md5sum", "sha1sum", "sha224sum", "sha256sum", "sha384sum", "sha512sum"].includes(name) ? checksumInformation : void 0);
@@ -155,10 +159,10 @@ ${info.options.map((option) => ` ${option.split(", ").map((spelling) => spellin
155
159
  This is the safe-bash virtual implementation; filesystem operations require backend capabilities.
156
160
  `;
157
161
  await writeBytes(context.stdout, new TextEncoder().encode(text), context.signal);
158
- return { exitCode: 0 };
162
+ return { exitCode: info.exitCode ?? 0 };
159
163
  }
160
164
  if (!arg.startsWith("-") || arg === "-") {
161
- if (info.stopAtOperand)
165
+ if (info.stopAtOperand || name === "pwd" && context.env.POSIXLY_CORRECT !== void 0)
162
166
  break;
163
167
  continue;
164
168
  }