@poe-platform/safe-bash 0.1.788 → 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.
- package/README.md +1 -1
- package/dist/safe-bash/chunks/{chunk-WHURJBET.js → chunk-2MUJ7RLZ.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-PYTLIUST.js → chunk-CTUHLNJM.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-Z3HX3ZBA.js → chunk-D4PHJK4T.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-O6356Z27.js → chunk-H7MMJS26.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-Q3E6C3DX.js → chunk-KHJGUF2W.js} +14 -0
- package/dist/safe-bash/chunks/{chunk-FJZNUUOQ.js → chunk-VUVKC6HV.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-ZMYVCRAF.js → chunk-X5ZCECM6.js} +2 -2
- package/dist/safe-bash/chunks/{git-UFNPAOYZ.js → git-HO7WDPHZ.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-PFBJR2PY.js → chunk-2KRKKW5S.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-4DSJDVBM.js → chunk-32F3RBUW.js} +10 -749
- package/dist/safe-bash/command-chunks/{chunk-L3MLMXL4.js → chunk-3ZK5F23O.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-4QX6XCDD.js → chunk-4RNIZ3RT.js} +79 -0
- package/dist/safe-bash/command-chunks/{chunk-D7TADAYG.js → chunk-64LG3EVJ.js} +17 -0
- package/dist/safe-bash/command-chunks/{chunk-JUDOV5MJ.js → chunk-6F7QJMJ3.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-IJ3FXP4Q.js → chunk-A3ZX6SCY.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-YNT4ZJHW.js → chunk-AT6ZSOE6.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-KSIGF4AG.js → chunk-BK4CMEE6.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-XGMWWUHV.js → chunk-CZ5DAK4K.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-Z57TV6TC.js → chunk-EZ2DTOLI.js} +4 -2
- package/dist/safe-bash/command-chunks/{chunk-ADCGH6A7.js → chunk-FH3D75FC.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-WYJTWJZ5.js → chunk-G3G6W5ZE.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-3HDIDEUJ.js → chunk-GF54KE2M.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-Z7TYZG3A.js → chunk-IHHTTQX6.js} +5 -3
- package/dist/safe-bash/command-chunks/{chunk-INDIFLBW.js → chunk-JTAGNROA.js} +4 -0
- package/dist/safe-bash/command-chunks/chunk-PGEYORBZ.js +25 -0
- package/dist/safe-bash/command-chunks/chunk-QM4UZF3C.js +753 -0
- package/dist/safe-bash/command-chunks/{chunk-TOSM3T3A.js → chunk-UJOO6DKY.js} +20 -9
- package/dist/safe-bash/command-chunks/{chunk-2LP3VMPA.js → chunk-WFDW4XXD.js} +1 -17
- package/dist/safe-bash/command-chunks/chunk-WR37IS4O.js +318 -0
- package/dist/safe-bash/command-chunks/{chunk-Y5IHIAY3.js → chunk-XNHSCU6I.js} +7 -3
- package/dist/safe-bash/commands/basic.js +148 -48
- package/dist/safe-bash/commands/bytes/compression/index.js +5 -6
- package/dist/safe-bash/commands/cmp.d.ts +2 -3
- package/dist/safe-bash/commands/cmp.js +2 -689
- package/dist/safe-bash/commands/docx/index.browser.js +3 -46
- package/dist/safe-bash/commands/docx/index.d.ts +2 -24
- package/dist/safe-bash/commands/docx/index.js +2 -41
- package/dist/safe-bash/commands/docx/io.d.ts +1 -14
- package/dist/safe-bash/commands/docx/io.js +1 -15
- package/dist/safe-bash/commands/llm/index.browser.js +3 -3
- package/dist/safe-bash/commands/network/index.browser.js +3 -3
- package/dist/safe-bash/commands/node/index.browser.js +3 -3
- package/dist/safe-bash/commands/pptx/index.d.ts +2 -28
- package/dist/safe-bash/commands/pptx/index.js +2 -152
- package/dist/safe-bash/commands/printf-float.d.ts +1 -0
- package/dist/safe-bash/commands/printf-float.js +48 -38
- package/dist/safe-bash/commands/printf-format.js +9 -6
- package/dist/safe-bash/commands/printf-quote.d.ts +3 -0
- package/dist/safe-bash/commands/printf-quote.js +62 -0
- package/dist/safe-bash/commands/printf-wide.d.ts +5 -0
- package/dist/safe-bash/commands/printf-wide.js +41 -0
- package/dist/safe-bash/commands/python/index.browser.js +2 -2
- package/dist/safe-bash/commands/truncate.d.ts +2 -3
- package/dist/safe-bash/commands/truncate.js +2 -686
- package/dist/safe-bash/contracts/diagnostics.d.ts +2 -0
- package/dist/safe-bash/contracts/diagnostics.js +2 -0
- package/dist/safe-bash/contracts/runtime-control.d.ts +2 -0
- package/dist/safe-bash/contracts/runtime-control.js +2 -0
- package/dist/safe-bash/core.browser.d.ts +1 -1
- package/dist/safe-bash/core.browser.js +2651 -4871
- package/dist/safe-bash/core.d.ts +10 -0
- package/dist/safe-bash/opt-in/commands/cmp/index.d.ts +6 -2
- package/dist/safe-bash/opt-in/commands/cmp/index.js +776 -79
- package/dist/safe-bash/opt-in/commands/cmp/options.d.ts +0 -12
- package/dist/safe-bash/opt-in/commands/cmp/options.js +0 -153
- package/dist/safe-bash/opt-in/commands/truncate/index.d.ts +8 -3
- package/dist/safe-bash/opt-in/commands/truncate/index.js +790 -272
- package/dist/safe-bash/opt-in/commands/truncate/sync.d.ts +1 -0
- package/dist/safe-bash/opt-in/commands/truncate/sync.js +60 -0
- package/dist/safe-bash/optional-host.browser.js +9 -1
- package/dist/safe-bash/optional-host.d.ts +3 -1
- package/dist/safe-bash/optional-host.js +3 -1
- package/dist/safe-bash/shell/runtime.js +10 -6
- package/dist/safe-bash-checksum-engine/index.d.ts +1 -1
- package/dist/safe-bash-checksum-engine/index.js +14 -2
- package/dist/safe-bash-command-bzip2/index.js +2 -1
- package/dist/safe-bash-command-cmp/index.d.ts +10 -0
- package/dist/safe-bash-command-cmp/index.js +796 -0
- package/dist/safe-bash-command-cmp/options.d.ts +12 -0
- package/dist/safe-bash-command-cmp/options.js +42 -0
- package/dist/safe-bash-command-csvcut/index.js +11 -8
- package/dist/safe-bash-command-csvgrep/index.js +35 -7
- package/dist/safe-bash-command-csvkit/codecs/python.js +4 -3
- package/dist/safe-bash-command-csvkit/codecs/utf8.js +3 -2
- package/dist/safe-bash-command-csvkit/index.js +80 -324
- package/dist/safe-bash-command-csvkit/python-regex.d.ts +5 -0
- package/dist/safe-bash-command-csvkit/python-regex.js +14 -0
- package/dist/safe-bash-command-csvkit/runtime.d.ts +1 -0
- package/dist/safe-bash-command-csvkit/sync-support.js +4 -2
- package/dist/safe-bash-command-diff3/index.js +3 -0
- package/dist/safe-bash-command-docx/LICENSE +21 -0
- package/dist/safe-bash-command-docx/index.d.ts +30 -0
- package/dist/safe-bash-command-docx/index.js +67 -0
- package/dist/safe-bash-command-docx/io.d.ts +14 -0
- package/dist/safe-bash-command-docx/io.js +26 -0
- package/dist/safe-bash-command-envsubst/index.js +34 -3
- package/dist/safe-bash-command-exiftool/index.js +3 -0
- package/dist/safe-bash-command-ffmpeg/index.js +1102 -1088
- package/dist/safe-bash-command-fold/family.js +1 -1
- package/dist/safe-bash-command-fold/index.js +1 -1
- package/dist/safe-bash-command-htmlq/index.js +5 -0
- package/dist/safe-bash-command-imagemagick/index.d.ts +25 -21
- package/dist/safe-bash-command-imagemagick/index.js +669 -271
- package/dist/safe-bash-command-mmdc/index.js +48 -10
- package/dist/safe-bash-command-mmdc/svg.d.ts +1 -0
- package/dist/safe-bash-command-op/index.js +19 -14
- package/dist/safe-bash-command-pandoc/command.js +1 -1
- package/dist/safe-bash-command-pandoc/index.js +1 -1
- package/dist/safe-bash-command-pdfimages/index.d.ts +7 -1
- package/dist/safe-bash-command-pdfimages/index.js +63 -33
- package/dist/safe-bash-command-pdfinfo/index.d.ts +24 -20
- package/dist/safe-bash-command-pdfinfo/index.js +370 -161
- package/dist/safe-bash-command-pdftk/index.d.ts +7 -3
- package/dist/safe-bash-command-pdftk/index.js +114 -45
- package/dist/safe-bash-command-pdftoppm/index.d.ts +15 -7
- package/dist/safe-bash-command-pdftoppm/index.js +179 -109
- package/dist/safe-bash-command-pdftotext/index.d.ts +9 -5
- package/dist/safe-bash-command-pdftotext/index.js +90 -27
- package/dist/safe-bash-command-pptx/LICENSE +21 -0
- package/dist/safe-bash-command-pptx/index.d.ts +33 -0
- package/dist/safe-bash-command-pptx/index.js +168 -0
- package/dist/safe-bash-command-qpdf/index.d.ts +9 -3
- package/dist/safe-bash-command-qpdf/index.js +80 -29
- package/dist/safe-bash-command-sha512sum/index.js +12 -475
- package/dist/safe-bash-command-sips/index.d.ts +9 -5
- package/dist/safe-bash-command-sips/index.js +63 -44
- package/dist/safe-bash-command-soffice/index.d.ts +9 -3
- package/dist/safe-bash-command-soffice/index.js +65 -24
- package/dist/safe-bash-command-sqlite3/engine.d.ts +9 -0
- package/dist/safe-bash-command-sqlite3/index.d.ts +1 -0
- package/dist/safe-bash-command-sqlite3/index.js +851 -352
- package/dist/safe-bash-command-ssconvert/formats/xls.js +3 -3
- package/dist/safe-bash-command-timeout/index.js +3 -3
- package/dist/safe-bash-command-truncate/index.d.ts +8 -3
- package/dist/safe-bash-command-truncate/index.js +790 -272
- package/dist/safe-bash-command-truncate/sync.d.ts +1 -0
- package/dist/safe-bash-command-truncate/sync.js +60 -0
- package/dist/safe-bash-command-wkhtmltopdf/index.js +92 -38
- package/dist/safe-bash-command-wkhtmltopdf/pdf-renderer.d.ts +1 -1
- package/dist/safe-bash-command-xxd/index.js +78 -20
- package/dist/safe-bash-command-xz/command.d.ts +4 -0
- package/dist/safe-bash-command-xz/index.d.ts +1 -1
- package/dist/safe-bash-command-xz/index.js +1 -1
- package/dist/safe-bash-compression-engine/bounded-codec.js +3 -3
- package/dist/safe-bash-compression-engine/codec-loader.js +2 -2
- package/dist/safe-bash-compression-engine/files.js +6 -6
- package/dist/safe-bash-compression-engine/index.js +5 -5
- package/dist/safe-bash-compression-engine/operand.js +6 -6
- package/dist/safe-bash-compression-engine/stream.js +5 -5
- package/dist/safe-bash-compression-engine/zstd-decode.js +4 -4
- package/dist/safe-bash-contracts/command.js +3 -3
- package/dist/safe-bash-contracts/diagnostics.js +3 -3
- package/dist/safe-bash-contracts/escaping.js +9 -9
- package/dist/safe-bash-contracts/filesystem-descriptor.js +3 -3
- package/dist/safe-bash-contracts/filesystem-output.js +8 -8
- package/dist/safe-bash-contracts/index.js +21 -19
- package/dist/safe-bash-contracts/io.d.ts +12 -0
- package/dist/safe-bash-contracts/io.js +4 -1
- package/dist/safe-bash-contracts/output.js +3 -2
- package/dist/safe-bash-contracts/runtime-control.js +2 -2
- package/dist/safe-bash-contracts/signals.js +1 -1
- package/dist/safe-bash-contracts/yield.d.ts +1 -0
- package/dist/safe-bash-contracts/yield.js +3 -1
- package/dist/safe-bash-csv-engine/index.d.ts +10 -1
- package/dist/safe-bash-csv-engine/index.js +78 -6
- package/dist/safe-bash-io-engine/commands/search/requirements.js +3 -3
- package/dist/safe-bash-io-engine/commands/text-programs/shared.js +3 -3
- package/dist/safe-bash-io-engine/gnu-information.js +1 -1
- package/dist/safe-bash-io-engine/internal.d.ts +1 -1
- package/dist/safe-bash-io-engine/internal.js +2 -2
- package/dist/safe-bash-query-engine/index.js +4 -4
- package/dist/safe-bash-query-engine/interpreter.js +2 -2
- package/dist/safe-bash-query-engine/query-core.js +4 -4
- package/package.json +2 -2
- package/dist/safe-bash/opt-in/commands/cmp/compare.js +0 -95
- package/dist/safe-bash/opt-in/commands/cmp/io.js +0 -218
- package/dist/safe-bash/command-chunks/{chunk-FXYWQ6S4.js → chunk-2VTMZTV3.js} +0 -0
- package/dist/safe-bash/command-chunks/{chunk-RTOJNFFL.js → chunk-BJ6DGYJA.js} +4 -4
- 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-
|
|
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
|
|
517
|
-
chunks.push(encoder.encode(
|
|
518
|
-
index +=
|
|
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
|
-
|
|
543
|
-
|
|
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;
|
|
@@ -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
|
}
|