poe-code 17.0.32 → 17.0.33
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/dist/{chunk-UC3KWJDL.js → chunk-4SR3FG2F.js} +8 -8
- package/dist/{chunk-GK6Z56OL.js → chunk-EW55GBOF.js} +2 -2
- package/dist/{chunk-54JM3XZC.js → chunk-NIIYLKZ6.js} +289 -38
- package/dist/chunk-NIIYLKZ6.js.map +7 -0
- package/dist/{core-BR637SCW.js → core-2UUUWCLM.js} +2 -2
- package/dist/index.js +2 -2
- package/dist/metafile.json +1 -1
- package/dist/{program-3DNB5ZIC.js → program-2FF4TQ2G.js} +3 -3
- package/dist/safe-bash.js +2 -2
- package/dist/{src-R4LATOF3.js → src-LTWZPB3P.js} +3 -3
- package/package.json +1 -1
- package/packages/package-lint/dist/bundle-policy.d.ts +3 -0
- package/packages/package-lint/dist/bundle-policy.js +4 -1
- package/packages/safe-bash/dist/chunks/{chunk-RVYQDJCC.js → chunk-4CEZRUSZ.js} +2 -2
- package/packages/safe-bash/dist/chunks/{chunk-MCBWPJRQ.js → chunk-MX6K5URO.js} +2 -2
- package/packages/safe-bash/dist/chunks/{chunk-WSCXISXW.js → chunk-RGSI3B5P.js} +2 -2
- package/packages/safe-bash/dist/chunks/{chunk-HC4S4QZD.js → chunk-TZ53QA73.js} +2 -2
- package/packages/safe-bash/dist/chunks/{chunk-LUQYNLH7.js → chunk-UKO4AP3K.js} +2 -2
- package/packages/safe-bash/dist/chunks/{chunk-JESM4RK2.js → chunk-UMCWCITQ.js} +4 -3
- package/packages/safe-bash/dist/chunks/chunk-UMCWCITQ.js.map +7 -0
- package/packages/safe-bash/dist/chunks/{chunk-BM3BGSH7.js → chunk-YJPA2BVP.js} +63 -20
- package/packages/safe-bash/dist/chunks/chunk-YJPA2BVP.js.map +7 -0
- package/packages/safe-bash/dist/commands/archive/index.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/archive/index.js +27 -0
- package/packages/safe-bash/dist/commands/archive/index.js.map +1 -1
- package/packages/safe-bash/dist/commands/archive/options.d.ts +1 -1
- package/packages/safe-bash/dist/commands/archive/options.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/archive/options.js +2 -0
- package/packages/safe-bash/dist/commands/archive/options.js.map +1 -1
- package/packages/safe-bash/dist/commands/csplit/index.browser.js +1 -1
- package/packages/safe-bash/dist/commands/internal.d.ts +1 -1
- package/packages/safe-bash/dist/commands/internal.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/internal.js +3 -2
- package/packages/safe-bash/dist/commands/internal.js.map +1 -1
- package/packages/safe-bash/dist/commands/llm/index.browser.js +2 -2
- package/packages/safe-bash/dist/commands/network/index.browser.js +2 -2
- package/packages/safe-bash/dist/commands/node/index.browser.js +2 -2
- package/packages/safe-bash/dist/commands/regex-execution/ascii.d.ts +2 -0
- package/packages/safe-bash/dist/commands/regex-execution/ascii.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/regex-execution/ascii.js +4 -0
- package/packages/safe-bash/dist/commands/regex-execution/ascii.js.map +1 -1
- package/packages/safe-bash/dist/commands/regex-execution/bounded-provider.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/regex-execution/bounded-provider.js +51 -21
- package/packages/safe-bash/dist/commands/regex-execution/bounded-provider.js.map +1 -1
- package/packages/safe-bash/dist/commands/regex-execution/ere/matcher.d.ts +2 -2
- package/packages/safe-bash/dist/commands/regex-execution/ere/matcher.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/regex-execution/ere/matcher.js +23 -9
- package/packages/safe-bash/dist/commands/regex-execution/ere/matcher.js.map +1 -1
- package/packages/safe-bash/dist/commands/search/grep.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/search/grep.js +99 -4
- package/packages/safe-bash/dist/commands/search/grep.js.map +1 -1
- package/packages/safe-bash/dist/commands/search/options.d.ts +1 -0
- package/packages/safe-bash/dist/commands/search/options.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/search/options.js +4 -1
- package/packages/safe-bash/dist/commands/search/options.js.map +1 -1
- package/packages/safe-bash/dist/commands/search/rg-command.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/search/rg-command.js +59 -0
- package/packages/safe-bash/dist/commands/search/rg-command.js.map +1 -1
- package/packages/safe-bash/dist/commands/streams.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/streams.js +32 -12
- package/packages/safe-bash/dist/commands/streams.js.map +1 -1
- package/packages/safe-bash/dist/commands/text-programs/sed.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/text-programs/sed.js +10 -1
- package/packages/safe-bash/dist/commands/text-programs/sed.js.map +1 -1
- package/packages/safe-bash/dist/commands/xml/index.browser.js +2 -2
- package/packages/safe-bash/dist/commands/yq/index.browser.js +2 -2
- package/packages/safe-bash/dist/core.browser.js +230 -23
- package/packages/safe-bash/dist/core.browser.js.map +3 -3
- package/dist/chunk-54JM3XZC.js.map +0 -7
- package/packages/safe-bash/dist/chunks/chunk-BM3BGSH7.js.map +0 -7
- package/packages/safe-bash/dist/chunks/chunk-JESM4RK2.js.map +0 -7
- /package/dist/{chunk-UC3KWJDL.js.map → chunk-4SR3FG2F.js.map} +0 -0
- /package/dist/{chunk-GK6Z56OL.js.map → chunk-EW55GBOF.js.map} +0 -0
- /package/dist/{core-BR637SCW.js.map → core-2UUUWCLM.js.map} +0 -0
- /package/dist/{program-3DNB5ZIC.js.map → program-2FF4TQ2G.js.map} +0 -0
- /package/dist/{src-R4LATOF3.js.map → src-LTWZPB3P.js.map} +0 -0
- /package/packages/safe-bash/dist/chunks/{chunk-RVYQDJCC.js.map → chunk-4CEZRUSZ.js.map} +0 -0
- /package/packages/safe-bash/dist/chunks/{chunk-MCBWPJRQ.js.map → chunk-MX6K5URO.js.map} +0 -0
- /package/packages/safe-bash/dist/chunks/{chunk-WSCXISXW.js.map → chunk-RGSI3B5P.js.map} +0 -0
- /package/packages/safe-bash/dist/chunks/{chunk-HC4S4QZD.js.map → chunk-TZ53QA73.js.map} +0 -0
- /package/packages/safe-bash/dist/chunks/{chunk-LUQYNLH7.js.map → chunk-UKO4AP3K.js.map} +0 -0
|
@@ -1264,6 +1264,9 @@ var AvailableRecords = class {
|
|
|
1264
1264
|
function foldAscii(code) {
|
|
1265
1265
|
return code >= 65 && code <= 90 ? code + 32 : code;
|
|
1266
1266
|
}
|
|
1267
|
+
function isAsciiWord(code) {
|
|
1268
|
+
return code >= 65 && code <= 90 || code >= 97 && code <= 122 || code >= 48 && code <= 57 || code === 95;
|
|
1269
|
+
}
|
|
1267
1270
|
|
|
1268
1271
|
// packages/safe-bash/src/contracts/yield.ts
|
|
1269
1272
|
var checkpoints = /* @__PURE__ */ new WeakMap();
|
|
@@ -9846,7 +9849,7 @@ async function matchEre(program, subject, ledger, signal) {
|
|
|
9846
9849
|
await admitAscii(subject, ledger, signal);
|
|
9847
9850
|
return runMatcher(program, subject, ledger, signal, 0, true);
|
|
9848
9851
|
}
|
|
9849
|
-
async function prepareUtf8EreSubject(bytes8, ledger, signal) {
|
|
9852
|
+
async function prepareUtf8EreSubject(bytes8, ledger, signal, leftmostFirst = false, word = false) {
|
|
9850
9853
|
ledger.check(signal);
|
|
9851
9854
|
ledger.admitInput("subjectBytes", bytes8.length, signal);
|
|
9852
9855
|
ledger.charge("allocationUnits", bytes8.length * 11 + 16, signal);
|
|
@@ -9857,7 +9860,7 @@ async function prepareUtf8EreSubject(bytes8, ledger, signal) {
|
|
|
9857
9860
|
const offsets = [];
|
|
9858
9861
|
for (let offset = 0; offset < owned.length; ) {
|
|
9859
9862
|
const first = owned[offset];
|
|
9860
|
-
const width = first < 128 ? 1 : first < 224 ? 2 : first < 240 ? 3 : 4;
|
|
9863
|
+
const width = word || first < 128 ? 1 : first < 224 ? 2 : first < 240 ? 3 : 4;
|
|
9861
9864
|
ledger.charge("work", width, signal);
|
|
9862
9865
|
await ledger.checkpoint(signal);
|
|
9863
9866
|
offsets.push(offset);
|
|
@@ -9882,14 +9885,14 @@ async function prepareUtf8EreSubject(bytes8, ledger, signal) {
|
|
|
9882
9885
|
else upper = middle;
|
|
9883
9886
|
}
|
|
9884
9887
|
if (offsets[lower] !== start) throw new RangeError("UTF-8 ERE cursor must be a scalar boundary");
|
|
9885
|
-
const span = await runMatcher(program, subject, ledger, signal, lower, false);
|
|
9888
|
+
const span = await runMatcher(program, subject, ledger, signal, lower, false, leftmostFirst, word);
|
|
9886
9889
|
if (!span) return void 0;
|
|
9887
9890
|
ledger.charge("allocationUnits", 2, signal);
|
|
9888
9891
|
return Object.freeze({ start: offsets[span.start], end: offsets[span.end] });
|
|
9889
9892
|
};
|
|
9890
9893
|
};
|
|
9891
9894
|
}
|
|
9892
|
-
async function runMatcher(program, subject, ledger, signal, from, materialize) {
|
|
9895
|
+
async function runMatcher(program, subject, ledger, signal, from, materialize, leftmostFirst = false, word = false) {
|
|
9893
9896
|
const root = resolveEreProgram(program, ledger);
|
|
9894
9897
|
const width = program.groups + 1;
|
|
9895
9898
|
ledger.charge("work", width * 2, signal);
|
|
@@ -9908,6 +9911,11 @@ async function runMatcher(program, subject, ledger, signal, from, materialize) {
|
|
|
9908
9911
|
pending.push({ position, task: next, captures, histories });
|
|
9909
9912
|
};
|
|
9910
9913
|
for (let start = from; start <= subject.length; start++) {
|
|
9914
|
+
if (word) {
|
|
9915
|
+
ledger.charge("work", 1, signal);
|
|
9916
|
+
await ledger.checkpoint(signal);
|
|
9917
|
+
if (isAsciiWord(subject.charCodeAt(start - 1))) continue;
|
|
9918
|
+
}
|
|
9911
9919
|
push(start, task(() => ({ kind: "node", node: root, next: null })), emptyCaptures, emptyHistories);
|
|
9912
9920
|
let best;
|
|
9913
9921
|
while (pending.length > 0) {
|
|
@@ -9916,6 +9924,11 @@ async function runMatcher(program, subject, ledger, signal, from, materialize) {
|
|
|
9916
9924
|
const state = pending.pop();
|
|
9917
9925
|
const current = state.task;
|
|
9918
9926
|
if (current === null) {
|
|
9927
|
+
if (word && isAsciiWord(subject.charCodeAt(state.position))) continue;
|
|
9928
|
+
if (leftmostFirst) {
|
|
9929
|
+
best = state;
|
|
9930
|
+
break;
|
|
9931
|
+
}
|
|
9919
9932
|
if (!best || await preferred(state, best, ledger, signal)) best = state;
|
|
9920
9933
|
continue;
|
|
9921
9934
|
}
|
|
@@ -9957,7 +9970,7 @@ async function runMatcher(program, subject, ledger, signal, from, materialize) {
|
|
|
9957
9970
|
case "literal":
|
|
9958
9971
|
case "set": {
|
|
9959
9972
|
const code = subject.charCodeAt(state.position);
|
|
9960
|
-
if (state.position < subject.length && (node.kind === "dot" || node.kind === "literal" && (node.insensitive ? foldAscii(node.code) === foldAscii(code) : node.code === code) || node.kind === "set" && (code < 128 ? node.members[code] : node.nonAscii))) {
|
|
9973
|
+
if (state.position < subject.length && (node.kind === "dot" && (!leftmostFirst || code !== 10) || node.kind === "literal" && (node.insensitive ? foldAscii(node.code) === foldAscii(code) : node.code === code) || node.kind === "set" && (code < 128 ? node.members[code] : node.nonAscii))) {
|
|
9961
9974
|
push(state.position + 1, current.next, state.captures, state.histories);
|
|
9962
9975
|
}
|
|
9963
9976
|
break;
|
|
@@ -10101,13 +10114,12 @@ function descriptor(value2, limits) {
|
|
|
10101
10114
|
if (value2 === null || typeof value2 !== "object") fail("protocol", "invalid descriptor");
|
|
10102
10115
|
const kind = Object.getOwnPropertyDescriptor(value2, "kind");
|
|
10103
10116
|
if (!kind || !("value" in kind)) fail("protocol", "invalid descriptor kind");
|
|
10104
|
-
if (kind.value !== "grep" && kind.value !== "rg") fail("unsupported", "only grep and
|
|
10117
|
+
if (kind.value !== "grep" && kind.value !== "rg") fail("unsupported", "only grep and rg selection descriptors are supported");
|
|
10105
10118
|
const flags4 = kind.value === "grep" ? ["fixed", "extended", "insensitive", "whole", "word"] : ["fixed", "whole", "word", "nullData"];
|
|
10106
10119
|
record(value2, ["kind", "patterns", ...flags4, ...kind.value === "rg" ? ["case"] : []]);
|
|
10107
10120
|
for (const flag of flags4) if (typeof value2[flag] !== "boolean") fail("protocol", `invalid ${flag} flag`);
|
|
10108
10121
|
if (kind.value === "rg" && !["sensitive", "insensitive", "smart"].includes(value2.case)) fail("protocol", "invalid case flag");
|
|
10109
|
-
if (
|
|
10110
|
-
if (kind.value === "rg" && !value2.fixed) fail("unsupported", "rg regex modes are unsupported; use fixed UTF-8 patterns");
|
|
10122
|
+
if (kind.value === "rg" && (value2.word || value2.case !== "sensitive")) fail("unsupported", "rg word matching and case-insensitive selection are unsupported");
|
|
10111
10123
|
array(value2.patterns, limits.maxPatterns, "pattern");
|
|
10112
10124
|
let bytes8 = 0;
|
|
10113
10125
|
for (let index = 0; index < value2.patterns.length; index++) {
|
|
@@ -10129,7 +10141,6 @@ function admit(input4, limits, signal) {
|
|
|
10129
10141
|
record(row, ["bytes", "all", "terminated"], ["directory", "ancestors"]);
|
|
10130
10142
|
if (!(row.bytes instanceof Uint8Array) || typeof row.all !== "boolean" || typeof row.terminated !== "boolean" || Object.hasOwn(row, "directory") && typeof row.directory !== "boolean" || Object.hasOwn(row, "ancestors") && typeof row.ancestors !== "boolean") fail("protocol", "invalid row");
|
|
10131
10143
|
if (Object.hasOwn(row, "directory") || Object.hasOwn(row, "ancestors")) fail("unsupported", "glob row flags are unsupported");
|
|
10132
|
-
if (row.all && selected.kind !== "grep") fail("unsupported", "rg all-match enumeration is unsupported");
|
|
10133
10144
|
const length2 = byteLength.call(row.bytes);
|
|
10134
10145
|
if (length2 > limits.maxInputBytes - bytes8) fail("limit", "aggregate input byte limit exceeded");
|
|
10135
10146
|
bytes8 += length2;
|
|
@@ -10313,17 +10324,28 @@ async function compileLiteral(bytes8, ledger, signal, insensitive = false) {
|
|
|
10313
10324
|
}
|
|
10314
10325
|
return { bytes: bytes8, fallback, insensitive };
|
|
10315
10326
|
}
|
|
10316
|
-
async function literalStart(program, subject, whole, ledger, signal, from = 0) {
|
|
10327
|
+
async function literalStart(program, subject, whole, word, ledger, signal, from = 0) {
|
|
10317
10328
|
const { bytes: bytes8, fallback } = program;
|
|
10318
10329
|
ledger.charge("work", 1, signal);
|
|
10319
10330
|
await ledger.checkpoint(signal);
|
|
10320
10331
|
if (whole && (from !== 0 || bytes8.length !== subject.length) || bytes8.length > subject.length - from) return -1;
|
|
10321
|
-
if (bytes8.length === 0)
|
|
10332
|
+
if (bytes8.length === 0) {
|
|
10333
|
+
for (let start = from; start <= subject.length; start++) {
|
|
10334
|
+
ledger.charge("work", 1, signal);
|
|
10335
|
+
await ledger.checkpoint(signal);
|
|
10336
|
+
if (!word || !isAsciiWord(subject[start - 1] ?? -1) && !isAsciiWord(subject[start] ?? -1)) return start;
|
|
10337
|
+
}
|
|
10338
|
+
return -1;
|
|
10339
|
+
}
|
|
10322
10340
|
for (let index = from, prefix3 = 0; index < subject.length; ) {
|
|
10323
10341
|
ledger.charge("work", 1, signal);
|
|
10324
10342
|
if ((program.insensitive ? foldAscii(subject[index]) : subject[index]) === bytes8[prefix3]) {
|
|
10325
10343
|
index++;
|
|
10326
|
-
if (++prefix3 === bytes8.length)
|
|
10344
|
+
if (++prefix3 === bytes8.length) {
|
|
10345
|
+
const start = index - prefix3;
|
|
10346
|
+
if (!word || !isAsciiWord(subject[start - 1] ?? -1) && !isAsciiWord(subject[index] ?? -1)) return start;
|
|
10347
|
+
prefix3 = fallback[prefix3 - 1];
|
|
10348
|
+
}
|
|
10327
10349
|
} else if (prefix3 > 0) prefix3 = fallback[prefix3 - 1];
|
|
10328
10350
|
else index++;
|
|
10329
10351
|
await ledger.checkpoint(signal);
|
|
@@ -10335,6 +10357,9 @@ async function enumerate(input4, row, finders, usage3, signal) {
|
|
|
10335
10357
|
ledger.charge("allocationUnits", finders.length + 2, signal);
|
|
10336
10358
|
const cached = new Array(finders.length);
|
|
10337
10359
|
const ranges2 = [];
|
|
10360
|
+
const byteEmpty = input4.descriptor.kind === "rg" && !input4.descriptor.whole && input4.descriptor.patterns.length === 1 && input4.descriptor.patterns[0] === "";
|
|
10361
|
+
const byteCursor = input4.descriptor.kind === "grep" && input4.descriptor.word;
|
|
10362
|
+
let previousEnd = -1;
|
|
10338
10363
|
for (let from = 0; from <= row.bytes.length; ) {
|
|
10339
10364
|
let best;
|
|
10340
10365
|
for (let index = 0; index < finders.length; index++) {
|
|
@@ -10345,9 +10370,14 @@ async function enumerate(input4, row, finders, usage3, signal) {
|
|
|
10345
10370
|
candidate = await finders[index](from) ?? null;
|
|
10346
10371
|
cached[index] = candidate;
|
|
10347
10372
|
}
|
|
10348
|
-
if (candidate && (!best || candidate.start < best.start || candidate.start === best.start && candidate.end > best.end)) best = candidate;
|
|
10373
|
+
if (candidate && (!best || candidate.start < best.start || input4.descriptor.kind === "grep" && candidate.start === best.start && candidate.end > best.end)) best = candidate;
|
|
10374
|
+
}
|
|
10375
|
+
if (!best || byteEmpty && !row.terminated && best.start === row.bytes.length) break;
|
|
10376
|
+
if (input4.descriptor.kind === "rg" && !byteEmpty && best.start === best.end && best.start === previousEnd) {
|
|
10377
|
+
const byte = row.bytes[best.end];
|
|
10378
|
+
from = best.end + (byte === void 0 || byte < 128 ? 1 : byte < 224 ? 2 : byte < 240 ? 3 : 4);
|
|
10379
|
+
continue;
|
|
10349
10380
|
}
|
|
10350
|
-
if (!best) break;
|
|
10351
10381
|
if (ranges2.length / 2 >= limits.maxMatchesPerLine) fail("limit", "matches per line limit exceeded");
|
|
10352
10382
|
if (usage3.count >= limits.maxTotalMatches) fail("limit", "total match limit exceeded");
|
|
10353
10383
|
if (usage3.count >= Math.floor(limits.maxResultBytes / 16)) fail("limit", "result byte limit exceeded");
|
|
@@ -10355,10 +10385,11 @@ async function enumerate(input4, row, finders, usage3, signal) {
|
|
|
10355
10385
|
ledger.charge("allocationUnits", 24, signal);
|
|
10356
10386
|
usage3.count++;
|
|
10357
10387
|
ranges2.push(best.start, best.end);
|
|
10388
|
+
previousEnd = best.end;
|
|
10358
10389
|
if (best.end > best.start) from = best.end;
|
|
10359
10390
|
else {
|
|
10360
10391
|
const byte = row.bytes[best.end];
|
|
10361
|
-
from = best.end + (byte === void 0 || byte < 128 ? 1 : byte < 224 ? 2 : byte < 240 ? 3 : 4);
|
|
10392
|
+
from = best.end + (byteEmpty || byteCursor || byte === void 0 || byte < 128 ? 1 : byte < 224 ? 2 : byte < 240 ? 3 : 4);
|
|
10362
10393
|
}
|
|
10363
10394
|
}
|
|
10364
10395
|
ledger.charge("work", ranges2.length, signal);
|
|
@@ -10379,7 +10410,7 @@ async function executeLiteral(input4, signal) {
|
|
|
10379
10410
|
if (row.all) {
|
|
10380
10411
|
ledger.charge("allocationUnits", programs2.length * 2, signal);
|
|
10381
10412
|
const finders = programs2.map((program) => async (from) => {
|
|
10382
|
-
const start2 = await literalStart(program, row.bytes, selected.whole, ledger, signal, from);
|
|
10413
|
+
const start2 = await literalStart(program, row.bytes, selected.whole, selected.word, ledger, signal, from);
|
|
10383
10414
|
if (start2 < 0) return void 0;
|
|
10384
10415
|
ledger.charge("allocationUnits", 2, signal);
|
|
10385
10416
|
return { start: start2, end: start2 + program.bytes.length };
|
|
@@ -10390,7 +10421,7 @@ async function executeLiteral(input4, signal) {
|
|
|
10390
10421
|
let start = -1;
|
|
10391
10422
|
let end = -1;
|
|
10392
10423
|
for (const program of programs2) {
|
|
10393
|
-
const candidate = await literalStart(program, row.bytes, selected.whole, ledger, signal);
|
|
10424
|
+
const candidate = await literalStart(program, row.bytes, selected.whole, selected.word, ledger, signal);
|
|
10394
10425
|
if (candidate < 0) continue;
|
|
10395
10426
|
if (start < 0 || candidate < start) {
|
|
10396
10427
|
start = candidate;
|
|
@@ -10409,7 +10440,19 @@ async function executeLiteral(input4, signal) {
|
|
|
10409
10440
|
}
|
|
10410
10441
|
async function execute(input4, signal) {
|
|
10411
10442
|
const { descriptor: selected, rows: rows2, ledger } = input4;
|
|
10412
|
-
|
|
10443
|
+
let literal = selected.fixed;
|
|
10444
|
+
if (!literal && selected.kind === "rg") {
|
|
10445
|
+
literal = true;
|
|
10446
|
+
patterns: for (const pattern of selected.patterns) {
|
|
10447
|
+
ledger.charge("work", pattern.length, signal);
|
|
10448
|
+
await ledger.checkpoint(signal);
|
|
10449
|
+
for (const character of pattern) if ("\\.^$[]()|*+?{}".includes(character)) {
|
|
10450
|
+
literal = false;
|
|
10451
|
+
break patterns;
|
|
10452
|
+
}
|
|
10453
|
+
}
|
|
10454
|
+
}
|
|
10455
|
+
if (literal) return executeLiteral(input4, signal);
|
|
10413
10456
|
const programs2 = [];
|
|
10414
10457
|
for (const pattern of selected.patterns) {
|
|
10415
10458
|
if (selected.kind === "rg" && !selected.nullData && pattern.includes("\n")) fail("unsupported", "rg multiline matching is unsupported");
|
|
@@ -10427,7 +10470,7 @@ async function execute(input4, signal) {
|
|
|
10427
10470
|
const results = [];
|
|
10428
10471
|
const usage3 = { count: 0 };
|
|
10429
10472
|
for (const row of rows2) {
|
|
10430
|
-
const subject = await prepareUtf8EreSubject(row.bytes, ledger, signal);
|
|
10473
|
+
const subject = await prepareUtf8EreSubject(row.bytes, ledger, signal, selected.kind === "rg", selected.word);
|
|
10431
10474
|
if (row.all) {
|
|
10432
10475
|
ledger.charge("allocationUnits", programs2.length + 1, signal);
|
|
10433
10476
|
const finders = [];
|
|
@@ -10727,8 +10770,9 @@ function options2(args, short, long = {}, stopAtOperand = false, onOperand, onVa
|
|
|
10727
10770
|
if (argument2.startsWith("--")) {
|
|
10728
10771
|
const equals = argument2.indexOf("=");
|
|
10729
10772
|
const name2 = argument2.slice(2, equals < 0 ? void 0 : equals);
|
|
10730
|
-
const
|
|
10731
|
-
|
|
10773
|
+
const alias2 = long[name2];
|
|
10774
|
+
const key = alias2 === false ? name2 : alias2;
|
|
10775
|
+
if (!key || alias2 !== false && !specifications.has(key)) throw new UsageError(`unrecognized option '${argument2}'`);
|
|
10732
10776
|
if (specifications.get(key)) {
|
|
10733
10777
|
const value2 = equals >= 0 ? argument2.slice(equals + 1) : args[++index];
|
|
10734
10778
|
if (value2 === void 0) throw new UsageError(`option '--${name2}' requires an argument`);
|
|
@@ -15138,7 +15182,7 @@ async function* combinedInput(context2, names, state) {
|
|
|
15138
15182
|
}
|
|
15139
15183
|
}
|
|
15140
15184
|
}
|
|
15141
|
-
async function prefix(context2, source2, count2, bytes8, skip) {
|
|
15185
|
+
async function prefix(context2, source2, count2, bytes8, skip, delimiter) {
|
|
15142
15186
|
let remaining = count2;
|
|
15143
15187
|
if (!remaining && !skip) return;
|
|
15144
15188
|
for await (const chunk of source2) {
|
|
@@ -15149,7 +15193,7 @@ async function prefix(context2, source2, count2, bytes8, skip) {
|
|
|
15149
15193
|
offset = Math.min(chunk.length, remaining);
|
|
15150
15194
|
remaining -= offset;
|
|
15151
15195
|
} else {
|
|
15152
|
-
for (; offset < chunk.length && remaining; offset++) if (chunk[offset] ===
|
|
15196
|
+
for (; offset < chunk.length && remaining; offset++) if (chunk[offset] === delimiter) remaining--;
|
|
15153
15197
|
}
|
|
15154
15198
|
}
|
|
15155
15199
|
if (skip) {
|
|
@@ -15160,12 +15204,12 @@ async function prefix(context2, source2, count2, bytes8, skip) {
|
|
|
15160
15204
|
}
|
|
15161
15205
|
}
|
|
15162
15206
|
}
|
|
15163
|
-
async function suffix(context2, source2, count2, bytes8, omit) {
|
|
15207
|
+
async function suffix(context2, source2, count2, bytes8, omit, delimiter) {
|
|
15164
15208
|
let pending = [];
|
|
15165
15209
|
let start = 0;
|
|
15166
15210
|
let size = 0;
|
|
15167
15211
|
const records5 = bytes8 ? source2 : (async function* () {
|
|
15168
|
-
for await (const line of lines(source2)) yield line.terminated ? concatenate([line.bytes, Uint8Array.of(
|
|
15212
|
+
for await (const line of lines(source2, delimiter)) yield line.terminated ? concatenate([line.bytes, Uint8Array.of(delimiter)]) : line.bytes;
|
|
15169
15213
|
})();
|
|
15170
15214
|
for await (const chunk of records5) {
|
|
15171
15215
|
context2.signal.throwIfAborted();
|
|
@@ -15240,9 +15284,10 @@ function headTail(name2, maxTailFollowHandles = 64) {
|
|
|
15240
15284
|
return define(name2, async (context2) => {
|
|
15241
15285
|
const args = context2.args[0] && /^-[0-9]+$/u.test(context2.args[0]) ? ["-n", context2.args[0].slice(1), ...context2.args.slice(1)] : context2.args;
|
|
15242
15286
|
const follow = name2 === "tail" ? parseTailFollow(args) : void 0;
|
|
15243
|
-
const parsed = options2(follow?.args ?? args, "n:c:
|
|
15287
|
+
const parsed = options2(follow?.args ?? args, "n:c:qvz", { lines: "n", bytes: "c", quiet: "q", silent: "q", verbose: "v", "zero-terminated": "z" });
|
|
15244
15288
|
if (parsed.flags.has("n") && parsed.flags.has("c")) throw new UsageError("cannot combine line and byte counts");
|
|
15245
15289
|
const bytes8 = parsed.flags.has("c");
|
|
15290
|
+
const delimiter = parsed.flags.has("z") ? 0 : 10;
|
|
15246
15291
|
const amount = value(parsed, bytes8 ? "c" : "n") ?? "10";
|
|
15247
15292
|
const positive = amount.startsWith("+");
|
|
15248
15293
|
const negative = amount.startsWith("-");
|
|
@@ -15256,7 +15301,7 @@ function headTail(name2, maxTailFollowHandles = 64) {
|
|
|
15256
15301
|
bytes: bytes8,
|
|
15257
15302
|
positive,
|
|
15258
15303
|
headers: parsed.flags.has("v") || names.length > 1 && !parsed.flags.has("q")
|
|
15259
|
-
}, maxTailFollowHandles, (target, source2) => positive ? prefix(target, source2, Math.max(0, count2 - 1), bytes8, true) : suffix(target, source2, count2, bytes8, false));
|
|
15304
|
+
}, maxTailFollowHandles, (target, source2) => positive ? prefix(target, source2, Math.max(0, count2 - 1), bytes8, true, delimiter) : suffix(target, source2, count2, bytes8, false, delimiter));
|
|
15260
15305
|
await assertInputRequirements(context2, names);
|
|
15261
15306
|
assertCommandRequirements(context2, inspectedInputRequirements, [names.some((name3) => name3 !== "-") ? "file" : "stdin"]);
|
|
15262
15307
|
let exitCode = 0;
|
|
@@ -15274,9 +15319,9 @@ function headTail(name2, maxTailFollowHandles = 64) {
|
|
|
15274
15319
|
`);
|
|
15275
15320
|
headerWritten = true;
|
|
15276
15321
|
}
|
|
15277
|
-
if (name2 === "head" && !negative) await prefix(context2, input(context2, file), count2, bytes8, false);
|
|
15278
|
-
else if (name2 === "tail" && positive) await prefix(context2, input(context2, file), Math.max(0, count2 - 1), bytes8, true);
|
|
15279
|
-
else await suffix(context2, input(context2, file), count2, bytes8, name2 === "head");
|
|
15322
|
+
if (name2 === "head" && !negative) await prefix(context2, input(context2, file), count2, bytes8, false, delimiter);
|
|
15323
|
+
else if (name2 === "tail" && positive) await prefix(context2, input(context2, file), Math.max(0, count2 - 1), bytes8, true, delimiter);
|
|
15324
|
+
else await suffix(context2, input(context2, file), count2, bytes8, name2 === "head", delimiter);
|
|
15280
15325
|
} catch (error) {
|
|
15281
15326
|
await diagnostic(context2, error);
|
|
15282
15327
|
exitCode = 1;
|
|
@@ -15345,7 +15390,26 @@ function streamCommands(maxTeeTargets = 64, maxTailFollowHandles = 64) {
|
|
|
15345
15390
|
}
|
|
15346
15391
|
return [
|
|
15347
15392
|
define("cat", async (context2) => {
|
|
15348
|
-
const parsed = options2(context2.args, "nbsvETAute", { number: "n", "number-nonblank": "b", "squeeze-blank": "s", "show-ends": "E", "show-tabs": "T", "show-nonprinting": "v", "show-all": "A" });
|
|
15393
|
+
const parsed = options2(context2.args, "nbsvETAute", { help: false, number: "n", "number-nonblank": "b", "squeeze-blank": "s", "show-ends": "E", "show-tabs": "T", "show-nonprinting": "v", "show-all": "A" });
|
|
15394
|
+
if (parsed.flags.has("help")) {
|
|
15395
|
+
await output(context2, `Usage: cat [OPTION]... [FILE]...
|
|
15396
|
+
Concatenate FILEs to standard output. With no FILE, or FILE -, read standard input.
|
|
15397
|
+
|
|
15398
|
+
-n, --number Number all output lines
|
|
15399
|
+
-b, --number-nonblank Number nonempty output lines (overrides -n)
|
|
15400
|
+
-s, --squeeze-blank Suppress repeated empty output lines
|
|
15401
|
+
-E, --show-ends Display $ at each line end
|
|
15402
|
+
-T, --show-tabs Display TAB characters as ^I
|
|
15403
|
+
-v, --show-nonprinting Display nonprinting characters
|
|
15404
|
+
-A, --show-all Equivalent to -vET
|
|
15405
|
+
-e Equivalent to -vE
|
|
15406
|
+
-t Equivalent to -vT
|
|
15407
|
+
-u Accepted for compatibility; ignored
|
|
15408
|
+
--help Display this help and exit
|
|
15409
|
+
-- End options; remaining arguments are filenames
|
|
15410
|
+
`);
|
|
15411
|
+
return { exitCode: 0 };
|
|
15412
|
+
}
|
|
15349
15413
|
await assertInputRequirements(context2, parsed.operands);
|
|
15350
15414
|
if (parsed.flags.has("A")) for (const flag of ["v", "E", "T"]) parsed.flags.add(flag);
|
|
15351
15415
|
if (parsed.flags.has("e")) {
|
|
@@ -25721,7 +25785,7 @@ async function execute2(program, context2, files, quiet, budget, separator, outp
|
|
|
25721
25785
|
const character = pattern[offset];
|
|
25722
25786
|
const lineEnd = character === "\n" && separator === "\n";
|
|
25723
25787
|
const token = character === void 0 || lineEnd ? "$" : escapes3[character] ?? (character.charCodeAt(0) < 32 || character.charCodeAt(0) >= 127 ? `\\${character.charCodeAt(0).toString(8).padStart(3, "0")}` : character);
|
|
25724
|
-
if (line.length + token.length >=
|
|
25788
|
+
if (character !== void 0 && !lineEnd && line.length + token.length >= 70) {
|
|
25725
25789
|
await emit2(line + "\\" + separator);
|
|
25726
25790
|
line = "";
|
|
25727
25791
|
}
|
|
@@ -25882,6 +25946,14 @@ function sedCommand(options3 = {}) {
|
|
|
25882
25946
|
separator = "\0";
|
|
25883
25947
|
continue;
|
|
25884
25948
|
}
|
|
25949
|
+
if (argument2 === "--quiet") {
|
|
25950
|
+
quiet = true;
|
|
25951
|
+
continue;
|
|
25952
|
+
}
|
|
25953
|
+
if (argument2 === "--regexp-extended") {
|
|
25954
|
+
extended = true;
|
|
25955
|
+
continue;
|
|
25956
|
+
}
|
|
25885
25957
|
if (argument2.startsWith("--")) throw new ProgramError(`unsupported option '${argument2}'`);
|
|
25886
25958
|
for (let position = 1; position < argument2.length; position++) {
|
|
25887
25959
|
const flag = argument2[position];
|
|
@@ -30315,6 +30387,9 @@ function parse6(args) {
|
|
|
30315
30387
|
return output3;
|
|
30316
30388
|
};
|
|
30317
30389
|
switch (flag) {
|
|
30390
|
+
case "help":
|
|
30391
|
+
result2.help = true;
|
|
30392
|
+
break;
|
|
30318
30393
|
case "e":
|
|
30319
30394
|
case "regexp":
|
|
30320
30395
|
result2.explicitPatterns = true;
|
|
@@ -30560,7 +30635,7 @@ function parse6(args) {
|
|
|
30560
30635
|
}
|
|
30561
30636
|
}
|
|
30562
30637
|
if (result2.before > 1e5 || result2.after > 1e5) throw new SearchError("context limit exceeded");
|
|
30563
|
-
if (result2.mode !== "files" && !result2.explicitPatterns) {
|
|
30638
|
+
if (!result2.help && result2.mode !== "files" && !result2.explicitPatterns) {
|
|
30564
30639
|
const pattern = operands.shift();
|
|
30565
30640
|
if (pattern === void 0) throw new SearchError("a search pattern is required");
|
|
30566
30641
|
result2.patterns.push(pattern);
|
|
@@ -31154,6 +31229,65 @@ function createRgCommand(executor, options3 = {}) {
|
|
|
31154
31229
|
try {
|
|
31155
31230
|
const limits = new Limits(context2, options3);
|
|
31156
31231
|
args = parse6(context2.args);
|
|
31232
|
+
if (args.help) {
|
|
31233
|
+
await limits.output(Buffer.from(`Usage: rg [OPTIONS] PATTERN [PATH ...]
|
|
31234
|
+
Search files for PATTERN. PATH - reads standard input.
|
|
31235
|
+
Default input depends on shell configuration.
|
|
31236
|
+
|
|
31237
|
+
-e, --regexp=PATTERN Add a pattern (repeatable)
|
|
31238
|
+
-f, --file=FILE Read patterns from FILE
|
|
31239
|
+
-F, --fixed-strings Use fixed strings
|
|
31240
|
+
-i, --ignore-case Ignore case distinctions
|
|
31241
|
+
-s, --case-sensitive Match case sensitively
|
|
31242
|
+
-S, --smart-case Infer case sensitivity from the pattern
|
|
31243
|
+
-v, --invert-match Select nonmatching lines
|
|
31244
|
+
-w, --word-regexp Match whole words
|
|
31245
|
+
-x, --line-regexp Match whole lines
|
|
31246
|
+
-n, --line-number Print line numbers
|
|
31247
|
+
-N, --no-line-number Suppress line numbers
|
|
31248
|
+
-H, --with-filename Print filenames
|
|
31249
|
+
-I, --no-filename Suppress filenames
|
|
31250
|
+
-o, --only-matching Print matching parts
|
|
31251
|
+
-l, --files-with-matches Print filenames with matches
|
|
31252
|
+
--files-without-match Print filenames without matches
|
|
31253
|
+
--files List files without searching
|
|
31254
|
+
-c, --count Print matching line counts
|
|
31255
|
+
--count-matches Print match counts
|
|
31256
|
+
--json Emit JSON events
|
|
31257
|
+
-q, --quiet Suppress normal output
|
|
31258
|
+
-g, --glob=GLOB Include or exclude paths (repeatable)
|
|
31259
|
+
--iglob=GLOB Case-insensitive glob
|
|
31260
|
+
-t, --type=TYPE Include a file type
|
|
31261
|
+
-T, --type-not=TYPE Exclude a file type
|
|
31262
|
+
-., --hidden Search hidden files
|
|
31263
|
+
-L, --follow Follow symbolic links
|
|
31264
|
+
--no-ignore Disable ignore-file filtering
|
|
31265
|
+
-u, --unrestricted Relax ignore, hidden and binary filtering (repeatable)
|
|
31266
|
+
-a, --text Search binary files as text
|
|
31267
|
+
-A, --after-context=NUM Print NUM lines after matches
|
|
31268
|
+
-B, --before-context=NUM Print NUM lines before matches
|
|
31269
|
+
-C, --context=NUM Print NUM lines before and after matches
|
|
31270
|
+
-m, --max-count=NUM Limit matching lines per file
|
|
31271
|
+
--max-depth=NUM Limit directory traversal depth (maximum 128)
|
|
31272
|
+
--column Print columns
|
|
31273
|
+
-b, --byte-offset Print byte offsets
|
|
31274
|
+
-0, --null NUL-terminate filenames
|
|
31275
|
+
--null-data Use NUL-delimited records
|
|
31276
|
+
--crlf Handle CRLF line endings
|
|
31277
|
+
--heading Group output by filename
|
|
31278
|
+
--sort=path Sort paths
|
|
31279
|
+
--color=never Disable color
|
|
31280
|
+
--help Display this help and exit
|
|
31281
|
+
-- End options
|
|
31282
|
+
|
|
31283
|
+
Exit status: 0 when a match is found, 1 when none is found, 2 on error.
|
|
31284
|
+
Regular expression support depends on the configured regex executor.
|
|
31285
|
+
The default supports UTF-8 literals and bounded ASCII regular expressions.
|
|
31286
|
+
Regex operators: . ^ $ [...] (...) | * + ? {n,m}; -F treats patterns literally.
|
|
31287
|
+
Word/case flags and extended regex syntax require a configured executor.
|
|
31288
|
+
`));
|
|
31289
|
+
return { exitCode: 0 };
|
|
31290
|
+
}
|
|
31157
31291
|
if (args.mode !== "files" && args.patternFiles.includes("-") && args.paths.includes("-")) {
|
|
31158
31292
|
throw new SearchError("cannot search stdin while also reading patterns from stdin");
|
|
31159
31293
|
}
|
|
@@ -31211,7 +31345,51 @@ var maxPatternCount = 1024;
|
|
|
31211
31345
|
function createGrepCommands(executor) {
|
|
31212
31346
|
return [{ name: "grep", filesystemRequirements: grepRequirements, execute: (context2) => withRegexSession(context2, executor, async (session) => {
|
|
31213
31347
|
try {
|
|
31214
|
-
const
|
|
31348
|
+
const contextLengths = /* @__PURE__ */ new Map();
|
|
31349
|
+
const parsed = options2(context2.args, "EFivnclLqhHowxae:f:m:szA:B:C:", { help: false, "extended-regexp": "E", "fixed-strings": "F", "ignore-case": "i", "invert-match": "v", "line-number": "n", count: "c", "files-with-matches": "l", "files-without-match": "L", quiet: "q", silent: "q", "no-filename": "h", "with-filename": "H", "only-matching": "o", "word-regexp": "w", "line-regexp": "x", regexp: "e", file: "f", "max-count": "m", "no-messages": "s", text: "a", "null-data": "z", "after-context": "A", "before-context": "B", context: "C" }, false, void 0, (key, index, offset) => {
|
|
31350
|
+
if (!["A", "B", "C"].includes(key)) return;
|
|
31351
|
+
const text4 = context2.args[index].slice(offset);
|
|
31352
|
+
try {
|
|
31353
|
+
contextLengths.set(key, integer2(text4));
|
|
31354
|
+
} catch {
|
|
31355
|
+
throw new UsageError(`${text4}: invalid context length argument`);
|
|
31356
|
+
}
|
|
31357
|
+
});
|
|
31358
|
+
if (parsed.flags.has("help")) {
|
|
31359
|
+
await output(context2, `Usage: grep [OPTION]... PATTERN [FILE]...
|
|
31360
|
+
Print lines matching PATTERN. With no FILE, or FILE -, read standard input.
|
|
31361
|
+
|
|
31362
|
+
-E, --extended-regexp Use extended regular expressions
|
|
31363
|
+
-F, --fixed-strings Use fixed strings
|
|
31364
|
+
-e, --regexp=PATTERN Add a pattern (repeatable)
|
|
31365
|
+
-f, --file=FILE Read patterns from FILE
|
|
31366
|
+
-i, --ignore-case Ignore case distinctions
|
|
31367
|
+
-v, --invert-match Select nonmatching lines
|
|
31368
|
+
-w, --word-regexp Match whole words
|
|
31369
|
+
-x, --line-regexp Match whole lines
|
|
31370
|
+
-n, --line-number Print line numbers
|
|
31371
|
+
-H, --with-filename Print filenames
|
|
31372
|
+
-h, --no-filename Suppress filenames
|
|
31373
|
+
-o, --only-matching Print only matching parts
|
|
31374
|
+
-c, --count Print matching line counts
|
|
31375
|
+
-l, --files-with-matches Print filenames with matches
|
|
31376
|
+
-L, --files-without-match Print filenames without matches
|
|
31377
|
+
-q, --quiet, --silent Suppress normal output
|
|
31378
|
+
-m, --max-count=NUM Stop after NUM selected lines per file
|
|
31379
|
+
-A, --after-context=NUM Print NUM lines after selected lines
|
|
31380
|
+
-B, --before-context=NUM Print NUM lines before selected lines
|
|
31381
|
+
-C, --context=NUM Print NUM lines before and after selected lines
|
|
31382
|
+
-s, --no-messages Suppress file error messages
|
|
31383
|
+
-a, --text Process input as text
|
|
31384
|
+
-z, --null-data Use NUL-delimited records
|
|
31385
|
+
--help Display this help and exit
|
|
31386
|
+
-- End options
|
|
31387
|
+
|
|
31388
|
+
Exit status: 0 when a line is selected, 1 when none is selected, 2 on error.
|
|
31389
|
+
Regular expression support depends on the configured regex executor.
|
|
31390
|
+
`);
|
|
31391
|
+
return { exitCode: 0 };
|
|
31392
|
+
}
|
|
31215
31393
|
let positionalPattern;
|
|
31216
31394
|
if (!parsed.flags.has("e") && !parsed.flags.has("f")) {
|
|
31217
31395
|
if (!parsed.operands.length) throw new UsageError("missing pattern");
|
|
@@ -31273,13 +31451,30 @@ function createGrepCommands(executor) {
|
|
|
31273
31451
|
const batchSize = Number.isFinite(maxCount) || parsed.flags.has("q") || parsed.flags.has("l") || parsed.flags.has("L") ? 1 : 128;
|
|
31274
31452
|
const delimiter = parsed.flags.has("z") ? "\0" : "\n";
|
|
31275
31453
|
const extractMatches = parsed.flags.has("o") && !["c", "q", "l", "L", "v"].some((flag) => parsed.flags.has(flag));
|
|
31454
|
+
const displayLines = !["c", "q", "l", "L"].some((flag) => parsed.flags.has(flag));
|
|
31455
|
+
const withContext = contextLengths.size > 0 && displayLines && !(parsed.flags.has("o") && parsed.flags.has("v"));
|
|
31456
|
+
const before = withContext ? contextLengths.get("B") ?? contextLengths.get("C") ?? 0 : 0;
|
|
31457
|
+
const after = withContext ? contextLengths.get("A") ?? contextLengths.get("C") ?? 0 : 0;
|
|
31458
|
+
let emittedGroup = false;
|
|
31276
31459
|
let anySelected = false;
|
|
31277
31460
|
let failed = false;
|
|
31278
31461
|
for (const name2 of names) {
|
|
31279
31462
|
let count2 = 0;
|
|
31280
31463
|
let number8 = 0;
|
|
31464
|
+
let lastCovered = 0;
|
|
31465
|
+
let remainingAfter = 0;
|
|
31466
|
+
let pendingBytes = 0;
|
|
31467
|
+
const pending = /* @__PURE__ */ new Map();
|
|
31281
31468
|
const named2 = name2 === "-" ? "(standard input)" : name2;
|
|
31282
|
-
const prefix3 = (lineNumber = false) => `${!parsed.flags.has("h") && (parsed.flags.has("H") || names.length > 1) ? `${named2}
|
|
31469
|
+
const prefix3 = (lineNumber = false, position = number8, separator = ":") => `${!parsed.flags.has("h") && (parsed.flags.has("H") || names.length > 1) ? `${named2}${separator}` : ""}${lineNumber && parsed.flags.has("n") ? `${position}${separator}` : ""}`;
|
|
31470
|
+
const emitContext = async (line, position) => {
|
|
31471
|
+
if (!parsed.flags.has("o")) {
|
|
31472
|
+
await output(context2, prefix3(true, position, "-"));
|
|
31473
|
+
await output(context2, line.bytes);
|
|
31474
|
+
await output(context2, delimiter);
|
|
31475
|
+
}
|
|
31476
|
+
lastCovered = position;
|
|
31477
|
+
};
|
|
31283
31478
|
try {
|
|
31284
31479
|
const available2 = new AvailableRecords(parsed.flags.has("z") ? 0 : 10, bufferLimit);
|
|
31285
31480
|
const source2 = name2 === "-" ? input(context2) : requiredFileInput(context2, grepRequirements, "file", name2, bufferLimit);
|
|
@@ -31290,12 +31485,40 @@ function createGrepCommands(executor) {
|
|
|
31290
31485
|
context2.signal.throwIfAborted();
|
|
31291
31486
|
number8++;
|
|
31292
31487
|
const found = results[index];
|
|
31293
|
-
|
|
31488
|
+
const selected = count2 < maxCount && found.length > 0 !== parsed.flags.has("v");
|
|
31489
|
+
if (!selected) {
|
|
31490
|
+
if (remainingAfter > 0) {
|
|
31491
|
+
await emitContext(line, number8);
|
|
31492
|
+
remainingAfter--;
|
|
31493
|
+
if (count2 >= maxCount && remainingAfter === 0) break records;
|
|
31494
|
+
} else if (before > 0) {
|
|
31495
|
+
if (pending.size >= before) {
|
|
31496
|
+
const oldest = pending.keys().next().value;
|
|
31497
|
+
pendingBytes -= pending.get(oldest).bytes.length + 1;
|
|
31498
|
+
pending.delete(oldest);
|
|
31499
|
+
}
|
|
31500
|
+
const size = line.bytes.length + 1;
|
|
31501
|
+
if (size > bufferLimit - pendingBytes) throw new UsageError(`context byte limit exceeded (${bufferLimit} bytes)`);
|
|
31502
|
+
pending.set(number8, { bytes: Uint8Array.from(line.bytes), terminated: line.terminated });
|
|
31503
|
+
pendingBytes += size;
|
|
31504
|
+
}
|
|
31505
|
+
continue;
|
|
31506
|
+
}
|
|
31294
31507
|
count2++;
|
|
31295
31508
|
if (!parsed.flags.has("L")) anySelected = true;
|
|
31296
31509
|
if (parsed.flags.has("q")) return { exitCode: 0 };
|
|
31297
31510
|
if (parsed.flags.has("l") || parsed.flags.has("L")) break records;
|
|
31298
31511
|
if (!parsed.flags.has("c")) {
|
|
31512
|
+
if (withContext) {
|
|
31513
|
+
const first = pending.keys().next().value ?? number8;
|
|
31514
|
+
if (emittedGroup && (lastCovered === 0 || first > lastCovered + 1)) await output(context2, "--\n");
|
|
31515
|
+
for (const [position, previous] of pending) await emitContext(previous, position);
|
|
31516
|
+
pending.clear();
|
|
31517
|
+
pendingBytes = 0;
|
|
31518
|
+
remainingAfter = after;
|
|
31519
|
+
lastCovered = number8;
|
|
31520
|
+
emittedGroup = true;
|
|
31521
|
+
}
|
|
31299
31522
|
if (parsed.flags.has("o")) {
|
|
31300
31523
|
if (!parsed.flags.has("v")) {
|
|
31301
31524
|
let end = -1;
|
|
@@ -31313,7 +31536,7 @@ function createGrepCommands(executor) {
|
|
|
31313
31536
|
await output(context2, delimiter);
|
|
31314
31537
|
}
|
|
31315
31538
|
}
|
|
31316
|
-
if (count2 >= maxCount) break records;
|
|
31539
|
+
if (count2 >= maxCount && remainingAfter === 0) break records;
|
|
31317
31540
|
}
|
|
31318
31541
|
}
|
|
31319
31542
|
if (parsed.flags.has("l") && count2 > 0 || parsed.flags.has("L") && count2 === 0) {
|
|
@@ -37886,6 +38109,7 @@ async function parseOptions2(context2, limits) {
|
|
|
37886
38109
|
if (values3.has(flag) && value2 === void 0) value2 = context2.args[++index];
|
|
37887
38110
|
if (values3.has(flag) && value2 === void 0) fail2(`missing argument for --${name2}`);
|
|
37888
38111
|
if (!values3.has(flag) && value2 !== void 0) fail2(`option --${name2} does not take an argument`);
|
|
38112
|
+
if (flag === "help") return "help";
|
|
37889
38113
|
await apply(flag, value2);
|
|
37890
38114
|
} else if (!end && (argument2.startsWith("-") && argument2 !== "-" || index === 0 && /^[ctxzvfCT]+$/u.test(argument2))) {
|
|
37891
38115
|
const old = !argument2.startsWith("-");
|
|
@@ -43621,6 +43845,33 @@ function createTarCommand(options3 = {}) {
|
|
|
43621
43845
|
const context2 = { ...original, signal };
|
|
43622
43846
|
try {
|
|
43623
43847
|
const parsed = await parseOptions2(context2, limits);
|
|
43848
|
+
if (parsed === "help") {
|
|
43849
|
+
await writeBytes(context2.stdout, Buffer.from(`Usage: tar [OPTION]... [FILE]...
|
|
43850
|
+
Create, list or extract USTAR/PAX archives in the virtual filesystem.
|
|
43851
|
+
|
|
43852
|
+
-c, --create Create an archive
|
|
43853
|
+
-t, --list List archive members
|
|
43854
|
+
-x, --extract, --get Extract archive members
|
|
43855
|
+
-f, --file=ARCHIVE Use ARCHIVE (default - for standard input/output)
|
|
43856
|
+
-z, --gzip Use gzip compression
|
|
43857
|
+
-v, --verbose List processed members
|
|
43858
|
+
-C, --directory=DIR Change directory for subsequent operands
|
|
43859
|
+
-T, --files-from=FILE Read filenames from FILE (- for standard input)
|
|
43860
|
+
--null Read NUL-delimited filenames; implies verbatim names
|
|
43861
|
+
--no-null Read newline-delimited filenames
|
|
43862
|
+
--verbatim-files-from Treat file-list entries as literal filenames
|
|
43863
|
+
--no-verbatim-files-from Enable supported file-list directory options
|
|
43864
|
+
--exclude=PATTERN Exclude paths (place before source operands)
|
|
43865
|
+
--strip-components=NUM Remove leading components when reading archives
|
|
43866
|
+
--format=FORMAT Create pax (default), posix or ustar archives
|
|
43867
|
+
--help Display this help and exit
|
|
43868
|
+
-- End options; remaining arguments are filenames
|
|
43869
|
+
|
|
43870
|
+
Exactly one of -c, -t or -x is required for archive operations.
|
|
43871
|
+
Examples: tar cf archive.tar file; tar tf archive.tar; tar xf archive.tar -C directory
|
|
43872
|
+
`), signal);
|
|
43873
|
+
return { exitCode: 0 };
|
|
43874
|
+
}
|
|
43624
43875
|
const budget = new Budget18(context2, limits);
|
|
43625
43876
|
if (parsed.mode === "c") {
|
|
43626
43877
|
const prepared = await manifest(context2, parsed, budget);
|
|
@@ -87918,4 +88169,4 @@ export {
|
|
|
87918
88169
|
isAbsolutePath3 as isAbsolutePath,
|
|
87919
88170
|
posixPath2 as posixPath
|
|
87920
88171
|
};
|
|
87921
|
-
//# sourceMappingURL=chunk-
|
|
88172
|
+
//# sourceMappingURL=chunk-NIIYLKZ6.js.map
|