@poe-platform/safe-bash 0.1.750 → 0.1.751
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/safe-bash/chunks/{chunk-4GK4FAT6.js → chunk-637A2MLA.js} +8 -6
- package/dist/safe-bash/chunks/{chunk-MUWJPSGN.js → chunk-B7IBQSD4.js} +7 -5
- package/dist/safe-bash/chunks/{chunk-U7DRVFRD.js → chunk-ILHNFAZE.js} +28 -5
- package/dist/safe-bash/chunks/{src-YKSQQDD3.js → src-XXKXVO7T.js} +2 -2
- package/dist/safe-bash/commands/pr/index.browser.js +1 -1
- package/dist/safe-bash/commands/time-env/shared.d.ts +1 -0
- package/dist/safe-bash/commands/time-env/shared.js +6 -5
- package/dist/safe-bash/commands/time-env/sleep.js +6 -3
- package/dist/safe-bash/core.browser.js +101 -97
- package/dist/safe-bash/shell/pattern.js +6 -1
- package/dist/safe-bash/shell/runtime.d.ts +1 -0
- package/dist/safe-bash/shell/runtime.js +134 -116
- package/dist/safe-bash-command-ssconvert/index.js +27 -4
- package/package.json +2 -2
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
command,
|
|
6
6
|
createPrCommand,
|
|
7
7
|
createPrCommands,
|
|
8
|
+
defaultSleepScheduler,
|
|
8
9
|
emit,
|
|
9
10
|
formatDate,
|
|
10
11
|
millisecondsInstant,
|
|
@@ -12,7 +13,7 @@ import {
|
|
|
12
13
|
parseDate,
|
|
13
14
|
prCommands,
|
|
14
15
|
settings
|
|
15
|
-
} from "./chunks/chunk-
|
|
16
|
+
} from "./chunks/chunk-B7IBQSD4.js";
|
|
16
17
|
import {
|
|
17
18
|
createTsortCommand,
|
|
18
19
|
createTsortCommands,
|
|
@@ -13388,7 +13389,11 @@ function getCompiledSyncPatternRegex(pattern) {
|
|
|
13388
13389
|
contents2 = "^";
|
|
13389
13390
|
cursor++;
|
|
13390
13391
|
}
|
|
13391
|
-
if (
|
|
13392
|
+
if (pattern.charCodeAt(cursor) === 93) {
|
|
13393
|
+
contents2 += "\\]";
|
|
13394
|
+
cursor++;
|
|
13395
|
+
}
|
|
13396
|
+
if (cursor >= pattern.length) {
|
|
13392
13397
|
syncPatternRegexCache.set(pattern, null);
|
|
13393
13398
|
return null;
|
|
13394
13399
|
}
|
|
@@ -47527,7 +47532,9 @@ function delay(milliseconds, signal, configuration) {
|
|
|
47527
47532
|
if (!Number.isFinite(now) || Math.abs(now) > Number.MAX_SAFE_INTEGER || previous !== void 0 && now < previous) {
|
|
47528
47533
|
throw new RangeError("sleep scheduler must supply finite monotonic milliseconds");
|
|
47529
47534
|
}
|
|
47530
|
-
if (previous !== void 0)
|
|
47535
|
+
if (previous !== void 0) {
|
|
47536
|
+
remaining -= scheduler === defaultSleepScheduler ? now - previous : Math.max(step, now - previous);
|
|
47537
|
+
}
|
|
47531
47538
|
previous = now;
|
|
47532
47539
|
if (remaining <= 0) {
|
|
47533
47540
|
finish(false);
|
|
@@ -75887,9 +75894,15 @@ var Runtime = class _Runtime {
|
|
|
75887
75894
|
if (expr.kind === "unary") return (expr.operator === "-n" || expr.operator === "-z" || expr.operator === "-v" || syncConditionalFileUnaryOps.has(expr.operator)) && okWord(expr.operand);
|
|
75888
75895
|
if (expr.kind === "binary") {
|
|
75889
75896
|
if (!okWord(expr.left) || !okWord(expr.right)) return false;
|
|
75890
|
-
if (expr.operator === "=~") return depth === 0 && this.extractSimpleErePattern(expr.right, rawState) !== void 0;
|
|
75897
|
+
if (expr.operator === "=~") return !requireTotal && depth === 0 && this.extractSimpleErePattern(expr.right, rawState) !== void 0;
|
|
75891
75898
|
if (expr.operator === "==" || expr.operator === "=" || expr.operator === "!=") {
|
|
75892
75899
|
if (expr.right.parts.length > 0 && expr.right.parts.every((p) => p.quoted)) return true;
|
|
75900
|
+
if (requireTotal) {
|
|
75901
|
+
if (!expr.right.parts.every((p, idx) => p.kind === "text" && !p.byteValue && (p.quoted || idx > 0 || !p.value.startsWith("~")))) return false;
|
|
75902
|
+
const pattern = expr.right.parts.map((p) => p.kind === "text" ? p.quoted ? p.value.replace(/[\\*?[\]()]/g, "\\$&") : p.value : "").join("");
|
|
75903
|
+
const work = { remaining: 4096, signal: this.signal, exhausted: () => this.budget.fail("maxExpansionBytes") };
|
|
75904
|
+
return tryMatchesPatternSync(pattern, "", work, false, true) !== void 0;
|
|
75905
|
+
}
|
|
75893
75906
|
if (expr.right.parts.length > 0 && expr.right.parts.every(
|
|
75894
75907
|
(p, idx) => p.kind === "text" && !p.byteValue && (p.quoted || idx > 0 || !p.value.startsWith("~")) || p.kind === "variable" && !p.indirect && !p.prefixNames && !p.length && !p.substring && !p.transform && p.operator === void 0 && getArraySelector(p) === void 0
|
|
75895
75908
|
)) return true;
|
|
@@ -76040,19 +76053,23 @@ var Runtime = class _Runtime {
|
|
|
76040
76053
|
if (typeof right !== "string") return void 0;
|
|
76041
76054
|
const syncTouched = this._syncArithRawWriteOnly ? this._syncArithTouched : void 0;
|
|
76042
76055
|
const lTrim = left.trim() || "0";
|
|
76043
|
-
let lNum = resolveSimpleArithOperand(lTrim, rawState, monitor, store, syncTouched);
|
|
76056
|
+
let lNum = lTrim.length > 13 && /^-?[0-9]{1,19}$/.test(lTrim) ? BigInt.asIntN(64, BigInt(lTrim)) : resolveSimpleArithOperand(lTrim, rawState, monitor, store, syncTouched);
|
|
76044
76057
|
if (lNum === void 0) {
|
|
76045
76058
|
const lExpr = tryEvalSimpleExpandedArith(lTrim, rawState, monitor, store, syncTouched);
|
|
76046
76059
|
if (lExpr !== void 0) lNum = Number(lExpr);
|
|
76047
76060
|
}
|
|
76048
76061
|
if (lNum === void 0) return void 0;
|
|
76049
76062
|
const rTrim = right.trim() || "0";
|
|
76050
|
-
let rNum = resolveSimpleArithOperand(rTrim, rawState, monitor, store, syncTouched);
|
|
76063
|
+
let rNum = rTrim.length > 13 && /^-?[0-9]{1,19}$/.test(rTrim) ? BigInt.asIntN(64, BigInt(rTrim)) : resolveSimpleArithOperand(rTrim, rawState, monitor, store, syncTouched);
|
|
76051
76064
|
if (rNum === void 0) {
|
|
76052
76065
|
const rExpr = tryEvalSimpleExpandedArith(rTrim, rawState, monitor, store, syncTouched);
|
|
76053
76066
|
if (rExpr !== void 0) rNum = Number(rExpr);
|
|
76054
76067
|
}
|
|
76055
76068
|
if (rNum === void 0) return void 0;
|
|
76069
|
+
if (typeof lNum !== typeof rNum) {
|
|
76070
|
+
lNum = BigInt(lNum);
|
|
76071
|
+
rNum = BigInt(rNum);
|
|
76072
|
+
}
|
|
76056
76073
|
let ok;
|
|
76057
76074
|
switch (expr.operator) {
|
|
76058
76075
|
case "-eq":
|
|
@@ -78501,7 +78518,6 @@ var Runtime = class _Runtime {
|
|
|
78501
78518
|
this.budget.tick();
|
|
78502
78519
|
rawState.substitutionStatus = 0;
|
|
78503
78520
|
if (rawState.variables._ !== void 0) delete rawState.variables._;
|
|
78504
|
-
rawState.lastArgument = fnArgs.length > 0 ? fnArgs[fnArgs.length - 1] : w0Plain;
|
|
78505
78521
|
const positional = rawState.positional;
|
|
78506
78522
|
let fnArgsBytes = 0;
|
|
78507
78523
|
for (let i = 0; i < fnArgs.length; i++) fnArgsBytes += fnArgs[i].length;
|
|
@@ -78682,7 +78698,6 @@ var Runtime = class _Runtime {
|
|
|
78682
78698
|
this.budget.tick();
|
|
78683
78699
|
rawState.substitutionStatus = 0;
|
|
78684
78700
|
if (rawState.variables._ !== void 0) delete rawState.variables._;
|
|
78685
|
-
rawState.lastArgument = lastCmdArg;
|
|
78686
78701
|
rawState.depth++;
|
|
78687
78702
|
let evalStatus;
|
|
78688
78703
|
try {
|
|
@@ -78691,6 +78706,7 @@ var Runtime = class _Runtime {
|
|
|
78691
78706
|
rawState.depth--;
|
|
78692
78707
|
}
|
|
78693
78708
|
if (typeof evalStatus === "number") {
|
|
78709
|
+
rawState.lastArgument = lastCmdArg;
|
|
78694
78710
|
if (cachedUnit.script.lists.length === 0) {
|
|
78695
78711
|
const activeStore = monitor.store;
|
|
78696
78712
|
const activeExisting = activeStore?.get("PIPESTATUS");
|
|
@@ -78981,6 +78997,7 @@ var Runtime = class _Runtime {
|
|
|
78981
78997
|
continue;
|
|
78982
78998
|
}
|
|
78983
78999
|
if (part.kind === "variable") {
|
|
79000
|
+
if (stateMonitor(rawState)?.store?.get(part.name)) return false;
|
|
78984
79001
|
if (this._syncLoopFnCheckDepth > 0 && (part.substring || getArraySelector(part)?.kind === "element")) return false;
|
|
78985
79002
|
if (part.prefixNames !== void 0) {
|
|
78986
79003
|
if (part.prefixNames === "@") return false;
|
|
@@ -79167,10 +79184,10 @@ var Runtime = class _Runtime {
|
|
|
79167
79184
|
if ((isNumOp || isStrOp) && safeArgWord(args[0]) && safeArgWord(args[2])) {
|
|
79168
79185
|
if (isNumOp && checkIntVars) {
|
|
79169
79186
|
const isGuaranteedIntWord = (w) => {
|
|
79170
|
-
if (w.plain !== void 0) return /^-?[0-9]
|
|
79187
|
+
if (w.plain !== void 0) return /^-?[0-9]{1,16}$/.test(w.plain);
|
|
79171
79188
|
if (w.parts.length === 1) {
|
|
79172
79189
|
const p02 = w.parts[0];
|
|
79173
|
-
if (p02.kind === "arithmetic") return
|
|
79190
|
+
if (p02.kind === "arithmetic") return false;
|
|
79174
79191
|
if (p02.kind === "variable" && !p02.indirect && !p02.prefixNames && !p02.substring && !p02.transform && p02.operator === void 0 && getArraySelector(p02) === void 0) {
|
|
79175
79192
|
if (script2) {
|
|
79176
79193
|
for (const lst of script2.lists) {
|
|
@@ -79178,13 +79195,13 @@ var Runtime = class _Runtime {
|
|
|
79178
79195
|
const c0 = pl.commands[0];
|
|
79179
79196
|
if (c0?.kind === "simple" && c0.words.length === 1) {
|
|
79180
79197
|
const asg = this.assignment(c0.words[0]);
|
|
79181
|
-
if (asg?.name === p02.name && (!asg.value.plain || !/^-?[0-9]
|
|
79198
|
+
if (asg?.name === p02.name && (!asg.value.plain || !/^-?[0-9]{1,16}$/.test(asg.value.plain))) return false;
|
|
79182
79199
|
}
|
|
79183
79200
|
}
|
|
79184
79201
|
}
|
|
79185
79202
|
}
|
|
79186
79203
|
const cur = rawState.variables[p02.name];
|
|
79187
|
-
return cur === void 0 || /^-?[0-9]
|
|
79204
|
+
return cur === void 0 || /^-?[0-9]{1,16}$/.test(cur);
|
|
79188
79205
|
}
|
|
79189
79206
|
}
|
|
79190
79207
|
return false;
|
|
@@ -79668,7 +79685,11 @@ var Runtime = class _Runtime {
|
|
|
79668
79685
|
const w0DevPlain = cmd.words[0].plain;
|
|
79669
79686
|
if (r0Check.descriptor === 1 && !r0Check.move && !r0Check.document && (r0Check.operator === ">" || r0Check.operator === ">>") && r0Check.target.plain === "/dev/null" && this.sourceFs !== this.backingFs && this.budget.canRedirect1 && w0DevPlain !== void 0 && (w0DevPlain === "pwd" || w0DevPlain === "dirname" || w0DevPlain === "basename" || w0DevPlain === "echo") && !hasShellFunction(rawState, w0DevPlain) && !rawState.extensions?.builtins.has(w0DevPlain) && (w0DevPlain === "pwd" || this.commands.has(w0DevPlain))) {
|
|
79670
79687
|
const devWordOk = (w) => this.isPureSyncValueWord(w, rawState) && w.parts.every((p2) => p2.quoted || p2.kind === "text" && p2.value.length > 0 && !p2.value.includes(" ") && !p2.value.includes(" ") && !p2.value.includes("\n") && !p2.value.includes("{") && !hasGlobOrEscape(p2.value, true));
|
|
79671
|
-
const
|
|
79688
|
+
const devOperandOk = (w) => {
|
|
79689
|
+
const first = w.parts[0];
|
|
79690
|
+
return first?.kind === "text" && first.value.length > 0 && !first.value.startsWith("-") && devWordOk(w);
|
|
79691
|
+
};
|
|
79692
|
+
const devShapeOk = w0DevPlain === "pwd" && cmd.words.length === 1 || (w0DevPlain === "dirname" || w0DevPlain === "echo") && cmd.words.length === 2 && devOperandOk(cmd.words[1]) || w0DevPlain === "basename" && (cmd.words.length === 2 && devOperandOk(cmd.words[1]) || cmd.words.length === 3 && devOperandOk(cmd.words[1]) && devWordOk(cmd.words[2]) || cmd.words.length === 4 && cmd.words[1].plain === "-s" && cmd.words[2].plain !== void 0 && devOperandOk(cmd.words[3]));
|
|
79672
79693
|
if (devShapeOk) continue;
|
|
79673
79694
|
}
|
|
79674
79695
|
if (this.extractSyncReadHereStringSpec(cmd, rawState) !== void 0) continue;
|
|
@@ -81500,15 +81521,23 @@ ${s1}
|
|
|
81500
81521
|
return false;
|
|
81501
81522
|
}
|
|
81502
81523
|
if (command7.kind !== "simple" || hasShellFunction(rawState, command7.words[0]?.plain ?? "") || command7.words.some((word) => getArrayAssignment(word) !== void 0)) return false;
|
|
81503
|
-
|
|
81524
|
+
let commandIndex = 0;
|
|
81525
|
+
while (commandIndex < command7.words.length && this.assignment(command7.words[commandIndex])) commandIndex++;
|
|
81526
|
+
const commandWord = command7.words[commandIndex];
|
|
81527
|
+
if (!commandWord?.parts.every((part) => part.kind === "text")) return false;
|
|
81528
|
+
const w0 = commandWord.parts.map((part) => part.kind === "text" ? part.value : "").join("");
|
|
81529
|
+
if (w0 === "read") return false;
|
|
81530
|
+
if (w0 === "printf") {
|
|
81531
|
+
const option = command7.words[commandIndex + 1];
|
|
81532
|
+
if (!option?.parts.every((part) => part.kind === "text")) return false;
|
|
81533
|
+
if (option.parts.map((part) => part.kind === "text" ? part.value : "").join("") === "-v") return false;
|
|
81534
|
+
}
|
|
81504
81535
|
if (w0 === "let" || w0 === "declare" || w0 === "typeset" || w0 === "local" || w0 === "export" || w0 === "unset" || w0 === "mapfile" || w0 === "readarray") return false;
|
|
81505
81536
|
if (inductionName !== void 0) {
|
|
81506
81537
|
if (command7.words.some((w) => {
|
|
81507
81538
|
const p02 = w.parts[0];
|
|
81508
81539
|
return p02?.kind === "text" && !p02.quoted && (p02.value.startsWith(inductionName + "=") || p02.value.startsWith(inductionName + "+="));
|
|
81509
81540
|
})) return false;
|
|
81510
|
-
if (w0 === "read" && (inductionName === "REPLY" || command7.words.slice(1).some((w) => w.plain === inductionName || w.plain === "-a" || w.plain === "-ra" || w.plain === "-ar"))) return false;
|
|
81511
|
-
if (w0 === "printf" && command7.words[1]?.plain === "-v" && command7.words[2]?.plain === inductionName) return false;
|
|
81512
81541
|
}
|
|
81513
81542
|
for (const word of [...command7.words, ...command7.redirects.map((redirect) => redirect.target)]) for (const part of word.parts) {
|
|
81514
81543
|
if (part.kind === "text") continue;
|
|
@@ -81726,6 +81755,7 @@ ${s1}
|
|
|
81726
81755
|
execSyncLocalDeclStep(decl, rawState, io, monitor, touched, line) {
|
|
81727
81756
|
const locals = (decl.kind === "local" || decl.kind === "declare") && rawState.locals.length > 0 ? rawState.locals[rawState.locals.length - 1] : void 0;
|
|
81728
81757
|
let lastArg = decl.kind;
|
|
81758
|
+
const values = decl.items.map((item) => item.value === void 0 ? void 0 : this.fastValueWord(item.value, rawState, io, false, false, false, rawState.braceexpand !== false, 0, line));
|
|
81729
81759
|
for (let i = 0; i < decl.items.length; i++) {
|
|
81730
81760
|
const item = decl.items[i];
|
|
81731
81761
|
const isNewLocal = locals ? !locals.has(item.name) : false;
|
|
@@ -81741,7 +81771,7 @@ ${s1}
|
|
|
81741
81771
|
touched.add(item.name);
|
|
81742
81772
|
}
|
|
81743
81773
|
if (item.value !== void 0) {
|
|
81744
|
-
const val =
|
|
81774
|
+
const val = values[i];
|
|
81745
81775
|
if (item.append) {
|
|
81746
81776
|
const curRaw = rawState.variables[item.name];
|
|
81747
81777
|
const curStr = curRaw === void 0 ? "" : touched.has(item.name) ? curRaw : monitor.values.get(item.name, curRaw) ?? curRaw;
|
|
@@ -81750,7 +81780,7 @@ ${s1}
|
|
|
81750
81780
|
rawState.variables[item.name] = val;
|
|
81751
81781
|
}
|
|
81752
81782
|
touched.add(item.name);
|
|
81753
|
-
lastArg = `${item.name}
|
|
81783
|
+
lastArg = `${item.name}${item.append ? "+=" : "="}${val}`;
|
|
81754
81784
|
} else {
|
|
81755
81785
|
lastArg = item.name;
|
|
81756
81786
|
}
|
|
@@ -81835,7 +81865,22 @@ ${s1}
|
|
|
81835
81865
|
this._syncStdoutBatch += text3;
|
|
81836
81866
|
if (this._syncStdoutBatch.length >= 8192) this.flushSyncStdoutBatch(io);
|
|
81837
81867
|
}
|
|
81868
|
+
runSyncDiscardStep(step, rawState, io) {
|
|
81869
|
+
this.budget.fileSystemOperation();
|
|
81870
|
+
const args = step.discardWords.map((word) => this.fastValueWord(word, rawState, io, false, false, false, false, 0, step.line));
|
|
81871
|
+
const cmdName = step.cmd.words[0].plain;
|
|
81872
|
+
let output2;
|
|
81873
|
+
if (cmdName === "pwd") output2 = rawState.variables.PWD ?? rawState.cwd;
|
|
81874
|
+
else if (cmdName === "echo") output2 = args[0];
|
|
81875
|
+
else if (cmdName === "dirname") output2 = this.evalSyncDirname(args);
|
|
81876
|
+
else output2 = this.evalSyncBasename(step.discardSuffix === void 0 ? args : ["-s", step.discardSuffix, ...args]);
|
|
81877
|
+
const bytes2 = shellValueByteLength(output2) + 1;
|
|
81878
|
+
if (this.budget.bytes + bytes2 > this.budget.maxOutputBytesSmi && bytes2 > this.budget.limits.maxOutputBytes - this.budget.bytes) this.budget.fail("maxOutputBytes");
|
|
81879
|
+
this.budget.bytes += bytes2;
|
|
81880
|
+
return args[args.length - 1] ?? cmdName;
|
|
81881
|
+
}
|
|
81838
81882
|
writeSyncRedirectStep(step, encoded2, append, mode, rawState, io) {
|
|
81883
|
+
if (this.budget.bytes + encoded2.byteLength > this.budget.maxOutputBytesSmi && encoded2.byteLength > this.budget.limits.maxOutputBytes - this.budget.bytes) this.budget.fail("maxOutputBytes");
|
|
81839
81884
|
encoded2 = encoded2.slice();
|
|
81840
81885
|
if (step.targetDirPrefix !== void 0 && step.targetNamePrefix !== void 0) {
|
|
81841
81886
|
const fileName = this.evalSyncRedirectSuffix(step.targetWord, step.targetDirPrefix, step.targetNamePrefix, rawState, io);
|
|
@@ -81988,27 +82033,7 @@ ${s1}
|
|
|
81988
82033
|
touched.add(step.name);
|
|
81989
82034
|
lastArg = pLastArg;
|
|
81990
82035
|
} else if (step.isDiscardDevNull && step.discardWords !== void 0) {
|
|
81991
|
-
this.
|
|
81992
|
-
const dw = step.discardWords;
|
|
81993
|
-
const cmdName = step.cmd.words[0].plain;
|
|
81994
|
-
let evalFirst = "";
|
|
81995
|
-
let evalLast = cmdName;
|
|
81996
|
-
for (let wi = 0; wi < dw.length; wi++) {
|
|
81997
|
-
const v = this.fastValueWord(dw[wi], rawState, io, false, false, false, false, 0, step.line);
|
|
81998
|
-
if (wi === 0) evalFirst = v;
|
|
81999
|
-
evalLast = v;
|
|
82000
|
-
}
|
|
82001
|
-
let outChars = 0;
|
|
82002
|
-
if (cmdName === "pwd") outChars = (rawState.variables.PWD ?? rawState.cwd).length + 1;
|
|
82003
|
-
else if (cmdName === "echo") outChars = evalFirst.length + 1;
|
|
82004
|
-
else if (cmdName === "dirname") outChars = dirname(evalFirst).length + 1;
|
|
82005
|
-
else if (cmdName === "basename") {
|
|
82006
|
-
const sfx = step.discardSuffix !== void 0 ? step.discardSuffix : dw.length === 2 ? evalLast : void 0;
|
|
82007
|
-
const baseStr = /^\/+$/u.test(evalFirst) ? "/" : basename(evalFirst);
|
|
82008
|
-
outChars = (sfx && baseStr !== sfx && baseStr.endsWith(sfx) ? baseStr.length - sfx.length : baseStr.length) + 1;
|
|
82009
|
-
}
|
|
82010
|
-
this.budget.bytes += outChars;
|
|
82011
|
-
lastArg = step.discardSuffix !== void 0 ? evalLast : dw.length > 0 ? evalLast : cmdName;
|
|
82036
|
+
lastArg = this.runSyncDiscardStep(step, rawState, io);
|
|
82012
82037
|
} else if (step.name !== void 0 && step.value !== void 0) {
|
|
82013
82038
|
rawState.substitutionStatus = 0;
|
|
82014
82039
|
const val = this.fastValueWord(step.value, rawState, io, false, false, false, false, 0, step.line);
|
|
@@ -82497,27 +82522,7 @@ ${s1}
|
|
|
82497
82522
|
touched.add(step.name);
|
|
82498
82523
|
lastArg = pLastArg;
|
|
82499
82524
|
} else if (step.isDiscardDevNull && step.discardWords !== void 0) {
|
|
82500
|
-
this.
|
|
82501
|
-
const dw = step.discardWords;
|
|
82502
|
-
const cmdName = step.cmd.words[0].plain;
|
|
82503
|
-
let evalFirst = "";
|
|
82504
|
-
let evalLast = cmdName;
|
|
82505
|
-
for (let wi = 0; wi < dw.length; wi++) {
|
|
82506
|
-
const v = this.fastValueWord(dw[wi], rawState, io, false, false, false, false, 0, step.line);
|
|
82507
|
-
if (wi === 0) evalFirst = v;
|
|
82508
|
-
evalLast = v;
|
|
82509
|
-
}
|
|
82510
|
-
let outChars = 0;
|
|
82511
|
-
if (cmdName === "pwd") outChars = (rawState.variables.PWD ?? rawState.cwd).length + 1;
|
|
82512
|
-
else if (cmdName === "echo") outChars = evalFirst.length + 1;
|
|
82513
|
-
else if (cmdName === "dirname") outChars = dirname(evalFirst).length + 1;
|
|
82514
|
-
else if (cmdName === "basename") {
|
|
82515
|
-
const sfx = step.discardSuffix !== void 0 ? step.discardSuffix : dw.length === 2 ? evalLast : void 0;
|
|
82516
|
-
const baseStr = /^\/+$/u.test(evalFirst) ? "/" : basename(evalFirst);
|
|
82517
|
-
outChars = (sfx && baseStr !== sfx && baseStr.endsWith(sfx) ? baseStr.length - sfx.length : baseStr.length) + 1;
|
|
82518
|
-
}
|
|
82519
|
-
this.budget.bytes += outChars;
|
|
82520
|
-
lastArg = step.discardSuffix !== void 0 ? evalLast : dw.length > 0 ? evalLast : cmdName;
|
|
82525
|
+
lastArg = this.runSyncDiscardStep(step, rawState, io);
|
|
82521
82526
|
} else if (step.name !== void 0 && step.value !== void 0) {
|
|
82522
82527
|
rawState.substitutionStatus = 0;
|
|
82523
82528
|
const val = this.fastValueWord(step.value, rawState, io, false, false, false, false, 0, step.line);
|
|
@@ -82662,27 +82667,7 @@ ${s1}
|
|
|
82662
82667
|
touched.add(step.name);
|
|
82663
82668
|
lastArg = pLastArg;
|
|
82664
82669
|
} else if (step.isDiscardDevNull && step.discardWords !== void 0) {
|
|
82665
|
-
this.
|
|
82666
|
-
const dw = step.discardWords;
|
|
82667
|
-
const cmdName = step.cmd.words[0].plain;
|
|
82668
|
-
let evalFirst = "";
|
|
82669
|
-
let evalLast = cmdName;
|
|
82670
|
-
for (let wi = 0; wi < dw.length; wi++) {
|
|
82671
|
-
const v = this.fastValueWord(dw[wi], rawState, io, false, false, false, false, 0, step.line);
|
|
82672
|
-
if (wi === 0) evalFirst = v;
|
|
82673
|
-
evalLast = v;
|
|
82674
|
-
}
|
|
82675
|
-
let outChars = 0;
|
|
82676
|
-
if (cmdName === "pwd") outChars = (rawState.variables.PWD ?? rawState.cwd).length + 1;
|
|
82677
|
-
else if (cmdName === "echo") outChars = evalFirst.length + 1;
|
|
82678
|
-
else if (cmdName === "dirname") outChars = dirname(evalFirst).length + 1;
|
|
82679
|
-
else if (cmdName === "basename") {
|
|
82680
|
-
const sfx = step.discardSuffix !== void 0 ? step.discardSuffix : dw.length === 2 ? evalLast : void 0;
|
|
82681
|
-
const baseStr = /^\/+$/u.test(evalFirst) ? "/" : basename(evalFirst);
|
|
82682
|
-
outChars = (sfx && baseStr !== sfx && baseStr.endsWith(sfx) ? baseStr.length - sfx.length : baseStr.length) + 1;
|
|
82683
|
-
}
|
|
82684
|
-
this.budget.bytes += outChars;
|
|
82685
|
-
lastArg = step.discardSuffix !== void 0 ? evalLast : dw.length > 0 ? evalLast : cmdName;
|
|
82670
|
+
lastArg = this.runSyncDiscardStep(step, rawState, io);
|
|
82686
82671
|
} else if (step.name !== void 0 && step.value !== void 0) {
|
|
82687
82672
|
rawState.substitutionStatus = 0;
|
|
82688
82673
|
const val = this.fastValueWord(step.value, rawState, io, false, false, false, false, 0, step.line);
|
|
@@ -83491,8 +83476,6 @@ ${s1}
|
|
|
83491
83476
|
state.substitutionStatus = 0;
|
|
83492
83477
|
const rawState = stateMonitor(state)?.raw ?? state;
|
|
83493
83478
|
if (rawState.variables._ !== void 0) delete rawState.variables._;
|
|
83494
|
-
rawState.lastArgument = wordValues[wordValues.length - 1] ?? w0Plain;
|
|
83495
|
-
state.lastArgument = rawState.lastArgument;
|
|
83496
83479
|
return await this.dispatchFastFunction(w0Plain, state.functions.get(w0Plain), wordValues.slice(1), state, originalIO);
|
|
83497
83480
|
}
|
|
83498
83481
|
}
|
|
@@ -84603,8 +84586,10 @@ ${s1}
|
|
|
84603
84586
|
}
|
|
84604
84587
|
const rawState = stateMonitor(state)?.raw ?? state;
|
|
84605
84588
|
if (!state._readOnlyStage && rawState.variables._ !== void 0) delete rawState.variables._;
|
|
84606
|
-
|
|
84607
|
-
|
|
84589
|
+
if (!state.functions.has(words[0] ?? "") && !["eval", ".", "source"].includes(words[declarationIndex] ?? "")) {
|
|
84590
|
+
rawState.lastArgument = words.at(-1) ?? "";
|
|
84591
|
+
state.lastArgument = rawState.lastArgument;
|
|
84592
|
+
}
|
|
84608
84593
|
if (!words.length) return state.substitutionStatus;
|
|
84609
84594
|
const args = words.slice(1);
|
|
84610
84595
|
const argValues = allStrings ? args : wordValues.slice(1);
|
|
@@ -84828,8 +84813,10 @@ ${s1}
|
|
|
84828
84813
|
if (!snapshotScope) {
|
|
84829
84814
|
const rawState = stateMonitor(state)?.raw ?? state;
|
|
84830
84815
|
if (rawState.variables._ !== void 0 && !assignments2.some((assignment) => assignment.name === "_")) delete rawState.variables._;
|
|
84831
|
-
|
|
84832
|
-
|
|
84816
|
+
if (!functionCommand && !["eval", ".", "source"].includes(words[declarationIndex] ?? "")) {
|
|
84817
|
+
rawState.lastArgument = words.at(-1) ?? "";
|
|
84818
|
+
state.lastArgument = rawState.lastArgument;
|
|
84819
|
+
}
|
|
84833
84820
|
}
|
|
84834
84821
|
if (!words.length) return state.substitutionStatus;
|
|
84835
84822
|
const args = words.slice(1);
|
|
@@ -85633,8 +85620,16 @@ ${s1}
|
|
|
85633
85620
|
return { exitCode: status2 };
|
|
85634
85621
|
}
|
|
85635
85622
|
if (context3.command === "command" || context3.command === "builtin" || context3.command === "type") return { exitCode: await this.discoveryBuiltin(context3, state, io, assignments2, defaultPath) };
|
|
85636
|
-
if (context3.command === "." || context3.command === "source")
|
|
85637
|
-
|
|
85623
|
+
if (context3.command === "." || context3.command === "source") {
|
|
85624
|
+
const exitCode = await this.sourceBuiltin(context3, state, { ...io, ...context3 }, special);
|
|
85625
|
+
state.lastArgument = context3.args.at(-1) ?? context3.command;
|
|
85626
|
+
return { exitCode };
|
|
85627
|
+
}
|
|
85628
|
+
if (context3.command === "eval") {
|
|
85629
|
+
const exitCode = await this.evalBuiltin(context3, state, { ...io, ...context3 }, special);
|
|
85630
|
+
state.lastArgument = context3.args.at(-1) ?? context3.command;
|
|
85631
|
+
return { exitCode };
|
|
85632
|
+
}
|
|
85638
85633
|
const builtinWork = this.builtin({ ...context3, [declarationArrays]: io[declarationArrays] }, state, assignments2, (error, diagnostic4) => {
|
|
85639
85634
|
builtinFailure = { error, diagnostic: diagnostic4 };
|
|
85640
85635
|
}, bypassFunctions);
|
|
@@ -91120,6 +91115,7 @@ ${prefix3} line ${offset + line}: \`${source2.split("\n")[line - 1] ?? ""}'
|
|
|
91120
91115
|
const anchorEnd = core1.endsWith("$");
|
|
91121
91116
|
const core = anchorEnd ? core1.slice(0, -1) : core1;
|
|
91122
91117
|
if (core.length === 0 && !anchorStart && !anchorEnd) return void 0;
|
|
91118
|
+
if (core.includes("[:") || core.includes("[.") || core.includes("[=") || core.includes("[]") || core.includes("[^]") || isExtended && core.includes("|")) return void 0;
|
|
91123
91119
|
let reSrc;
|
|
91124
91120
|
if (/^[a-zA-Z0-9_ :;,=-]*$/.test(core)) {
|
|
91125
91121
|
if (/\\[1-9]/.test(rep)) return void 0;
|
|
@@ -91282,7 +91278,7 @@ ${prefix3} line ${offset + line}: \`${source2.split("\n")[line - 1] ?? ""}'
|
|
|
91282
91278
|
const isExtended = mode.includes("E");
|
|
91283
91279
|
const isFixed = mode.includes("F");
|
|
91284
91280
|
const isOnlyMatching = mode.includes("o");
|
|
91285
|
-
if (
|
|
91281
|
+
if (!isFixed && rawPatterns.some((pattern) => pattern.includes("[:") || pattern.includes("[.") || pattern.includes("[=") || pattern.includes("[]") || pattern.includes("[^]") || isExtended && pattern.includes("[") && pattern.includes("|"))) return void 0;
|
|
91286
91282
|
if (isCount && (isLineNumber || isOnlyMatching || beforeCtx > 0 || afterCtx > 0)) return void 0;
|
|
91287
91283
|
if (isOnlyMatching && (beforeCtx > 0 || afterCtx > 0)) return void 0;
|
|
91288
91284
|
if (isOnlyMatching) {
|
|
@@ -91305,15 +91301,18 @@ ${prefix3} line ${offset + line}: \`${source2.split("\n")[line - 1] ?? ""}'
|
|
|
91305
91301
|
}
|
|
91306
91302
|
if (!re) return void 0;
|
|
91307
91303
|
const out = [];
|
|
91304
|
+
let matched2 = false;
|
|
91308
91305
|
for (let li = 0; li < rawLines.length; li++) {
|
|
91309
91306
|
const matches2 = rawLines[li].match(re);
|
|
91310
91307
|
if (matches2) {
|
|
91308
|
+
matched2 = true;
|
|
91311
91309
|
for (let mi = 0; mi < matches2.length; mi++) {
|
|
91310
|
+
if (matches2[mi].length === 0) continue;
|
|
91312
91311
|
out.push(isLineNumber ? `${li + 1}:${matches2[mi]}` : matches2[mi]);
|
|
91313
91312
|
}
|
|
91314
91313
|
}
|
|
91315
91314
|
}
|
|
91316
|
-
return { lines: out, status:
|
|
91315
|
+
return { lines: out, status: matched2 ? 0 : 1 };
|
|
91317
91316
|
}
|
|
91318
91317
|
if (isExtended && isFixed) return void 0;
|
|
91319
91318
|
const branches = [];
|
|
@@ -92341,6 +92340,7 @@ ${prefix3} line ${offset + line}: \`${source2.split("\n")[line - 1] ?? ""}'
|
|
|
92341
92340
|
return this.evalSyncSort(rawLines, flag !== void 0 ? [flag] : [], false) ?? [...rawLines];
|
|
92342
92341
|
}
|
|
92343
92342
|
translateSyncTr(input3, set1Spec, set2Spec, truncateSet1 = false) {
|
|
92343
|
+
if (set2Spec.includes("[:") && !(set1Spec === "[:lower:]" && set2Spec === "[:upper:]") && !(set1Spec === "[:upper:]" && set2Spec === "[:lower:]")) return void 0;
|
|
92344
92344
|
if ((set1Spec === "a-z" || set1Spec === "[:lower:]") && (set2Spec === "A-Z" || set2Spec === "[:upper:]")) {
|
|
92345
92345
|
return input3.replace(/[a-z]/g, (ch) => String.fromCharCode(ch.charCodeAt(0) - 32));
|
|
92346
92346
|
}
|
|
@@ -92616,7 +92616,7 @@ ${prefix3} line ${offset + line}: \`${source2.split("\n")[line - 1] ?? ""}'
|
|
|
92616
92616
|
const firstName = stageNames[sIdx];
|
|
92617
92617
|
const extDef = stageDefs[sIdx];
|
|
92618
92618
|
const stageArgs = stageArgsList[sIdx];
|
|
92619
|
-
|
|
92619
|
+
let nextBuf = (index & 1) === 0 ? sharedSyncPipeBuf0 : sharedSyncPipeBuf1;
|
|
92620
92620
|
const isInlineCutField = firstName === "cut";
|
|
92621
92621
|
const isInlineTr = firstName === "tr";
|
|
92622
92622
|
const isInlineAwk = firstName === "awk";
|
|
@@ -92644,6 +92644,7 @@ ${prefix3} line ${offset + line}: \`${source2.split("\n")[line - 1] ?? ""}'
|
|
|
92644
92644
|
const nextTotalBytes2 = this.budget.bytes + sub.byteLength;
|
|
92645
92645
|
if (nextTotalBytes2 > this.budget.maxOutputBytesSmi && sub.byteLength > this.budget.limits.maxOutputBytes - this.budget.bytes) this.budget.fail("maxOutputBytes");
|
|
92646
92646
|
this.budget.bytes = nextTotalBytes2;
|
|
92647
|
+
if (sub.byteLength > nextBuf.byteLength) nextBuf = new Uint8Array(sub.byteLength);
|
|
92647
92648
|
nextBuf.set(sub, 0);
|
|
92648
92649
|
prevBuf = nextBuf;
|
|
92649
92650
|
prevLen = sub.byteLength;
|
|
@@ -92680,10 +92681,10 @@ ${prefix3} line ${offset + line}: \`${source2.split("\n")[line - 1] ?? ""}'
|
|
|
92680
92681
|
const transformed = this.evalSyncTr(inStr, stageArgs);
|
|
92681
92682
|
if (transformed === void 0) return void 0;
|
|
92682
92683
|
const outByteLen2 = shellValueByteLength(transformed);
|
|
92683
|
-
if (outByteLen2 > nextBuf.byteLength) return void 0;
|
|
92684
92684
|
const nextTotalBytes2 = this.budget.bytes + outByteLen2;
|
|
92685
92685
|
if (nextTotalBytes2 > this.budget.maxOutputBytesSmi && outByteLen2 > this.budget.limits.maxOutputBytes - this.budget.bytes) this.budget.fail("maxOutputBytes");
|
|
92686
92686
|
this.budget.bytes = nextTotalBytes2;
|
|
92687
|
+
if (outByteLen2 > nextBuf.byteLength) nextBuf = new Uint8Array(outByteLen2);
|
|
92687
92688
|
const written2 = transformed.length === 0 ? 0 : fastSharedTextEncoder.encodeInto(transformed, nextBuf).written;
|
|
92688
92689
|
prevBuf = nextBuf;
|
|
92689
92690
|
prevLen = written2;
|
|
@@ -92710,8 +92711,10 @@ ${prefix3} line ${offset + line}: \`${source2.split("\n")[line - 1] ?? ""}'
|
|
|
92710
92711
|
if (stageStatus !== 0) failureStatus = stageStatus;
|
|
92711
92712
|
outLines = grepRes.lines;
|
|
92712
92713
|
} else if (isInlineTac) {
|
|
92713
|
-
if (inStr.length > 0 && !inStr.endsWith("\n")) return void 0;
|
|
92714
92714
|
outLines = [...rawLines].reverse();
|
|
92715
|
+
if (!inStr.endsWith("\n") && outLines.length > 1) {
|
|
92716
|
+
outLines.splice(0, 2, outLines[0] + outLines[1]);
|
|
92717
|
+
}
|
|
92715
92718
|
} else if (isInlineNl) {
|
|
92716
92719
|
const nlRes = this.evalSyncNl(rawLines, stageArgs);
|
|
92717
92720
|
if (nlRes === void 0) return void 0;
|
|
@@ -92732,10 +92735,11 @@ ${prefix3} line ${offset + line}: \`${source2.split("\n")[line - 1] ?? ""}'
|
|
|
92732
92735
|
const cleaned = inStr.replace(/[ \t\r\n]+/g, "");
|
|
92733
92736
|
if (cleaned.length % 4 !== 0 || cleaned.length > 0 && !/^[A-Za-z0-9+/]+={0,2}$/.test(cleaned)) return void 0;
|
|
92734
92737
|
const decoded = this.syncBase64DecodeBytes(cleaned);
|
|
92735
|
-
if (decoded.some((byte) => byte === 0 || byte >= 128)
|
|
92738
|
+
if (decoded.some((byte) => byte === 0 || byte >= 128)) return void 0;
|
|
92736
92739
|
const nextTotalBytes2 = this.budget.bytes + decoded.byteLength;
|
|
92737
92740
|
if (nextTotalBytes2 > this.budget.maxOutputBytesSmi && decoded.byteLength > this.budget.limits.maxOutputBytes - this.budget.bytes) this.budget.fail("maxOutputBytes");
|
|
92738
92741
|
this.budget.bytes = nextTotalBytes2;
|
|
92742
|
+
if (decoded.byteLength > nextBuf.byteLength) nextBuf = new Uint8Array(decoded.byteLength);
|
|
92739
92743
|
nextBuf.set(decoded, 0);
|
|
92740
92744
|
prevBuf = nextBuf;
|
|
92741
92745
|
prevLen = decoded.byteLength;
|
|
@@ -92747,13 +92751,13 @@ ${prefix3} line ${offset + line}: \`${source2.split("\n")[line - 1] ?? ""}'
|
|
|
92747
92751
|
outLines = jqRes;
|
|
92748
92752
|
}
|
|
92749
92753
|
const preservesTerminator = firstName === "head" || firstName === "tail" || firstName === "rev" || firstName === "sed";
|
|
92750
|
-
const terminated = sedTerminated || !preservesTerminator || inStr.endsWith("\n") || firstName === "head" && outLines.length < rawLines.length;
|
|
92754
|
+
const terminated = isInlineTac ? inStr.includes("\n") : sedTerminated || !preservesTerminator || inStr.endsWith("\n") || firstName === "head" && outLines.length < rawLines.length;
|
|
92751
92755
|
const outStr2 = outLines.length > 0 ? outLines.join("\n") + (terminated ? "\n" : "") : "";
|
|
92752
92756
|
const outByteLen = shellValueByteLength(outStr2);
|
|
92753
|
-
if (outByteLen > nextBuf.byteLength) return void 0;
|
|
92754
92757
|
const nextTotalBytes = this.budget.bytes + outByteLen;
|
|
92755
92758
|
if (nextTotalBytes > this.budget.maxOutputBytesSmi && outByteLen > this.budget.limits.maxOutputBytes - this.budget.bytes) this.budget.fail("maxOutputBytes");
|
|
92756
92759
|
this.budget.bytes = nextTotalBytes;
|
|
92760
|
+
if (outByteLen > nextBuf.byteLength) nextBuf = new Uint8Array(outByteLen);
|
|
92757
92761
|
const written = outStr2.length === 0 ? 0 : fastSharedTextEncoder.encodeInto(outStr2, nextBuf).written;
|
|
92758
92762
|
prevBuf = nextBuf;
|
|
92759
92763
|
prevLen = written;
|
|
@@ -335,7 +335,12 @@ function getCompiledSyncPatternRegex(pattern) {
|
|
|
335
335
|
contents = "^";
|
|
336
336
|
cursor++;
|
|
337
337
|
}
|
|
338
|
-
|
|
338
|
+
// Bash treats a closing bracket at the start of a class as a member.
|
|
339
|
+
if (pattern.charCodeAt(cursor) === 93) {
|
|
340
|
+
contents += "\\]";
|
|
341
|
+
cursor++;
|
|
342
|
+
}
|
|
343
|
+
if (cursor >= pattern.length) {
|
|
339
344
|
syncPatternRegexCache.set(pattern, null);
|
|
340
345
|
return null;
|
|
341
346
|
}
|
|
@@ -542,6 +542,7 @@ export declare class Runtime {
|
|
|
542
542
|
private _syncLoopAction;
|
|
543
543
|
private flushSyncStdoutBatch;
|
|
544
544
|
private writeSyncStdoutText;
|
|
545
|
+
private runSyncDiscardStep;
|
|
545
546
|
private writeSyncRedirectStep;
|
|
546
547
|
private runSyncArithForFallback;
|
|
547
548
|
private _syncLoopFnCheckDepth;
|