@poe-platform/safe-bash 0.1.747 → 0.1.748
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-JCXAGOEK.js → chunk-K3LGRJMX.js} +5 -4
- package/dist/safe-bash/chunks/{chunk-55AGFLG5.js → chunk-MSEZFB2F.js} +64 -18
- package/dist/safe-bash/chunks/{chunk-OF2PDE3W.js → chunk-RPNX7NO2.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-BS6QFRNX.js → chunk-XIWFKWNM.js} +2 -2
- package/dist/safe-bash/chunks/{src-T672TQJC.js → src-2MBSXQOA.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-6QU5OLPJ.js → chunk-4AWKMIU3.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-6742OVAC.js → chunk-WX5IUIQK.js} +4 -3
- package/dist/safe-bash/core.browser.js +60 -122
- package/dist/safe-bash/shell/pattern.js +1 -1
- package/dist/safe-bash/shell/runtime.d.ts +1 -1
- package/dist/safe-bash/shell/runtime.js +78 -157
- package/dist/safe-bash-command-ssconvert/index.js +63 -17
- package/dist/safe-bash-query-engine/index.js +2 -2
- package/dist/safe-bash-query-engine/interpreter.js +1 -1
- package/dist/safe-bash-query-engine/query-core.js +2 -2
- package/package.json +2 -2
|
@@ -13431,7 +13431,7 @@ function getCompiledSyncPatternRegex(pattern) {
|
|
|
13431
13431
|
return compiled;
|
|
13432
13432
|
}
|
|
13433
13433
|
function tryMatchesPatternSync(pattern, value2, work, ignoreCase = false, extglob = false) {
|
|
13434
|
-
if (Array.from !== defaultArrayFrom || ignoreCase || pattern.length >= 128
|
|
13434
|
+
if (Array.from !== defaultArrayFrom || ignoreCase || pattern.length >= 128) return void 0;
|
|
13435
13435
|
let hasBracketOrQmark = false;
|
|
13436
13436
|
for (let i = 0; i < pattern.length; i++) {
|
|
13437
13437
|
const c = pattern.charCodeAt(i);
|
|
@@ -78992,40 +78992,7 @@ var Runtime = class _Runtime {
|
|
|
78992
78992
|
if (part.indirect) {
|
|
78993
78993
|
return false;
|
|
78994
78994
|
}
|
|
78995
|
-
|
|
78996
|
-
if (sel !== void 0) {
|
|
78997
|
-
if (rawState.nounset) return false;
|
|
78998
|
-
if (sel.kind === "members" || sel.kind === "keys") {
|
|
78999
|
-
if (part.operator !== void 0) {
|
|
79000
|
-
if (sel.kind === "members" && !part.keys && !part.length && !part.substring && part.quoted && (sel.separator === "*" || allowAt && sel.separator === "@") && this.budget.limits.maxExpansionBytes === Infinity && !rawState.nocasematch) {
|
|
79001
|
-
if ((part.operator === "#" || part.operator === "##" || part.operator === "%" || part.operator === "%%") && part.alternate && part.alternate.parts.length === 1 && part.alternate.parts[0].kind === "text" && (!hasGlobOrEscape(part.alternate.parts[0].value, true) || !part.alternate.parts[0].quoted && Boolean(tryCompileTrimGlobToRegex(part.alternate.parts[0].value, part.operator, !!rawState.extglob)))) continue;
|
|
79002
|
-
if ((part.operator === "/" || part.operator === "//" || part.operator === "/#" || part.operator === "/%") && part.alternate && part.alternate.parts.length === 1 && part.alternate.parts[0].kind === "text" && part.alternate.parts[0].value.length > 0 && (!hasGlobOrEscape(part.alternate.parts[0].value, true) || !part.alternate.parts[0].quoted && Boolean(tryCompileFixedGlobToRegex(part.alternate.parts[0].value, part.operator, !!rawState.extglob))) && (!part.replacement || part.replacement.parts.length === 0 || part.replacement.parts.length === 1 && part.replacement.parts[0].kind === "text" && !part.replacement.parts[0].value.includes("&") && !part.replacement.parts[0].value.includes("\\") && !part.replacement.parts[0].value.startsWith("~"))) continue;
|
|
79003
|
-
if ((part.operator === "^" || part.operator === "^^" || part.operator === "," || part.operator === ",,") && (!part.alternate || part.alternate.parts.length === 0)) continue;
|
|
79004
|
-
}
|
|
79005
|
-
return false;
|
|
79006
|
-
}
|
|
79007
|
-
if (part.length) {
|
|
79008
|
-
if (part.substring) return false;
|
|
79009
|
-
continue;
|
|
79010
|
-
}
|
|
79011
|
-
if (part.quoted && (sel.separator === "*" || allowAt && sel.separator === "@") && this.budget.limits.maxExpansionBytes === Infinity && (!part.substring || sel.kind === "members" && part.substring.offset.parts.every((p) => p.kind === "text" || p.kind === "variable" && !p.operator && !p.substring && !p.length) && (!part.substring.length || part.substring.length.parts.every((p) => p.kind === "text" || p.kind === "variable" && !p.operator && !p.substring && !p.length)))) {
|
|
79012
|
-
continue;
|
|
79013
|
-
}
|
|
79014
|
-
return false;
|
|
79015
|
-
}
|
|
79016
|
-
if (sel.kind === "element") {
|
|
79017
|
-
if (part.substring) {
|
|
79018
|
-
return false;
|
|
79019
|
-
}
|
|
79020
|
-
if (part.operator === void 0) continue;
|
|
79021
|
-
if ((part.operator === "-" || part.operator === ":-" || part.operator === "+" || part.operator === ":+") && part.alternate && !part.length) continue;
|
|
79022
|
-
if ((part.operator === "^" || part.operator === "^^" || part.operator === "," || part.operator === ",,") && (!part.alternate || part.alternate.parts.length === 0) && !part.length) continue;
|
|
79023
|
-
if (!part.length && !rawState.nocasematch && this.budget.limits.maxExpansionBytes === Infinity) {
|
|
79024
|
-
if ((part.operator === "#" || part.operator === "##" || part.operator === "%" || part.operator === "%%") && part.alternate && part.alternate.parts.length === 1 && part.alternate.parts[0].kind === "text" && !hasGlobOrEscape(part.alternate.parts[0].value, true)) continue;
|
|
79025
|
-
if ((part.operator === "/" || part.operator === "//" || part.operator === "/#" || part.operator === "/%") && part.alternate && part.alternate.parts.length === 1 && part.alternate.parts[0].kind === "text" && part.alternate.parts[0].value.length > 0 && !hasGlobOrEscape(part.alternate.parts[0].value, true) && (!part.replacement || part.replacement.parts.length === 0 || part.replacement.parts.length === 1 && part.replacement.parts[0].kind === "text" && !part.replacement.parts[0].value.includes("&") && !part.replacement.parts[0].value.includes("\\") && !part.replacement.parts[0].value.startsWith("~"))) continue;
|
|
79026
|
-
}
|
|
79027
|
-
return false;
|
|
79028
|
-
}
|
|
78995
|
+
if (getArraySelector(part) !== void 0) {
|
|
79029
78996
|
return false;
|
|
79030
78997
|
}
|
|
79031
78998
|
if (part.length || part.substring || part.operator !== void 0) {
|
|
@@ -79164,10 +79131,14 @@ var Runtime = class _Runtime {
|
|
|
79164
79131
|
} else if (w0Plain === "grep") {
|
|
79165
79132
|
if (plainOps.length !== opCount || this.evalSyncGrep([], plainOps, Boolean(rawState.errexit)) === void 0) return false;
|
|
79166
79133
|
} else if (w0Plain === "awk") {
|
|
79167
|
-
|
|
79134
|
+
const input3 = this.extractLoopInvariantInput(cmd, hasSingleStdinRedir, hasSingleHereStringRedir, rawState);
|
|
79135
|
+
if (plainOps.length !== opCount || input3 === void 0) return false;
|
|
79136
|
+
const lines3 = input3.length === 0 ? [] : input3.split("\n");
|
|
79137
|
+
if (input3.endsWith("\n")) lines3.pop();
|
|
79138
|
+
if (this.evalSyncAwk(lines3, plainOps) === void 0) return false;
|
|
79168
79139
|
} else if (w0Plain === "jq") {
|
|
79169
79140
|
if (plainOps.length !== opCount) return false;
|
|
79170
|
-
const jqIn = this.
|
|
79141
|
+
const jqIn = this.extractLoopInvariantInput(cmd, hasSingleStdinRedir, hasSingleHereStringRedir, rawState)?.trim();
|
|
79171
79142
|
if (jqIn === void 0 || this.evalSyncJq(jqIn, plainOps) === void 0) return false;
|
|
79172
79143
|
} else if (w0Plain === "wc") {
|
|
79173
79144
|
if (opCount !== 1 || this.normalizeSyncWcFlag(op0) === void 0) return false;
|
|
@@ -79184,7 +79155,7 @@ var Runtime = class _Runtime {
|
|
|
79184
79155
|
} else if (w0Plain === "paste") {
|
|
79185
79156
|
if (plainOps.length !== opCount || this.evalSyncPaste([], plainOps) === void 0) return false;
|
|
79186
79157
|
} else if (w0Plain === "numfmt") {
|
|
79187
|
-
const nmCheck = this.
|
|
79158
|
+
const nmCheck = this.extractLoopInvariantInput(cmd, hasSingleStdinRedir, hasSingleHereStringRedir, rawState)?.trim();
|
|
79188
79159
|
if (nmCheck === void 0 || plainOps.length !== opCount || this.evalSyncNumfmt(nmCheck.split("\n"), plainOps) === void 0) return false;
|
|
79189
79160
|
}
|
|
79190
79161
|
}
|
|
@@ -79268,14 +79239,19 @@ var Runtime = class _Runtime {
|
|
|
79268
79239
|
} else if (sName === "sed") {
|
|
79269
79240
|
if (this.evalSyncSed([], sPlainArgs) === void 0) return false;
|
|
79270
79241
|
} else if (sName === "awk") {
|
|
79271
|
-
if (
|
|
79242
|
+
if (sIdx !== 1) return false;
|
|
79243
|
+
const input3 = this.extractLoopInvariantInput(cmd, hasSingleStdinRedir, hasSingleHereStringRedir, rawState);
|
|
79244
|
+
if (input3 === void 0) return false;
|
|
79245
|
+
const lines3 = input3.length === 0 ? [] : input3.split("\n");
|
|
79246
|
+
if (input3.endsWith("\n")) lines3.pop();
|
|
79247
|
+
if (this.evalSyncAwk(lines3, sPlainArgs) === void 0) return false;
|
|
79272
79248
|
} else if (sName === "grep") {
|
|
79273
79249
|
if (this.evalSyncGrep([], sPlainArgs, Boolean(rawState.errexit)) === void 0) return false;
|
|
79274
79250
|
} else if (sName === "tr") {
|
|
79275
79251
|
if (this.evalSyncTr("", sPlainArgs) === void 0) return false;
|
|
79276
79252
|
} else if (sName === "jq") {
|
|
79277
79253
|
if (sIdx !== 1) return false;
|
|
79278
|
-
const jqIn = this.
|
|
79254
|
+
const jqIn = this.extractLoopInvariantInput(cmd, hasSingleStdinRedir, hasSingleHereStringRedir, rawState)?.trim();
|
|
79279
79255
|
if (jqIn === void 0 || this.evalSyncJq(jqIn, sPlainArgs) === void 0) return false;
|
|
79280
79256
|
} else if (sName === "base64") {
|
|
79281
79257
|
if (sPlainArgs.length !== 0) return false;
|
|
@@ -79287,7 +79263,7 @@ var Runtime = class _Runtime {
|
|
|
79287
79263
|
if (this.evalSyncPaste([], sPlainArgs) === void 0) return false;
|
|
79288
79264
|
} else if (sName === "numfmt") {
|
|
79289
79265
|
if (sIdx !== 1) return false;
|
|
79290
|
-
const nmCheck = this.
|
|
79266
|
+
const nmCheck = this.extractLoopInvariantInput(cmd, hasSingleStdinRedir, hasSingleHereStringRedir, rawState)?.trim();
|
|
79291
79267
|
if (nmCheck === void 0 || this.evalSyncNumfmt(nmCheck.split("\n"), sPlainArgs) === void 0) return false;
|
|
79292
79268
|
} else if (sName === "rev") {
|
|
79293
79269
|
if (sPlainArgs.length !== 0) return false;
|
|
@@ -79351,46 +79327,15 @@ var Runtime = class _Runtime {
|
|
|
79351
79327
|
}
|
|
79352
79328
|
return void 0;
|
|
79353
79329
|
}
|
|
79354
|
-
execSyncUnsetStep(step, rawState,
|
|
79330
|
+
execSyncUnsetStep(step, rawState, monitor, touched) {
|
|
79355
79331
|
const uVars = step.unsetVars;
|
|
79356
|
-
const store = monitor.store;
|
|
79357
79332
|
let lastExpanded = "";
|
|
79358
|
-
for (
|
|
79359
|
-
|
|
79360
|
-
|
|
79361
|
-
|
|
79362
|
-
|
|
79363
|
-
|
|
79364
|
-
lastExpanded = tExpanded;
|
|
79365
|
-
const bracket = tExpanded.indexOf("[");
|
|
79366
|
-
if (bracket > 0 && tExpanded.endsWith("]") && store) {
|
|
79367
|
-
const arrName = tExpanded.slice(0, bracket);
|
|
79368
|
-
const subStr = tExpanded.slice(bracket + 1, -1);
|
|
79369
|
-
const binding = store.get(arrName);
|
|
79370
|
-
if (binding) {
|
|
79371
|
-
if (binding.associative) {
|
|
79372
|
-
const id = fastStringHexIdentity(subStr);
|
|
79373
|
-
const existingKey = binding.keys.get(id);
|
|
79374
|
-
if (existingKey !== void 0) {
|
|
79375
|
-
binding.remove(existingKey.index);
|
|
79376
|
-
store.changed(monitor.chargeInternal(syncRestorationCharge, syncRestorationTickets), arrName);
|
|
79377
|
-
}
|
|
79378
|
-
} else {
|
|
79379
|
-
const idxNum = /^(?:0|[1-9][0-9]{0,8})$/.test(subStr) ? Number(subStr) : resolveSimpleArithOperand(subStr, rawState, monitor, store, this._syncArithRawWriteOnly ? this._syncArithTouched : void 0);
|
|
79380
|
-
const resolvedIdx = idxNum !== void 0 ? idxNum >= 0 ? idxNum : binding.maximum + 1 + idxNum : void 0;
|
|
79381
|
-
if (resolvedIdx !== void 0 && resolvedIdx >= 0 && binding.values.has(resolvedIdx)) {
|
|
79382
|
-
binding.remove(resolvedIdx);
|
|
79383
|
-
store.changed(monitor.chargeInternal(syncRestorationCharge, syncRestorationTickets), arrName);
|
|
79384
|
-
}
|
|
79385
|
-
}
|
|
79386
|
-
}
|
|
79387
|
-
}
|
|
79388
|
-
} else {
|
|
79389
|
-
delete rawState.variables[uvn];
|
|
79390
|
-
monitor.proxy.exported.delete(uvn);
|
|
79391
|
-
touched.add(uvn);
|
|
79392
|
-
lastExpanded = uvn;
|
|
79393
|
-
}
|
|
79333
|
+
for (const uvn of uVars) {
|
|
79334
|
+
delete rawState.variables[uvn];
|
|
79335
|
+
rawState.exported.delete(uvn);
|
|
79336
|
+
monitor.proxy.exported.delete(uvn);
|
|
79337
|
+
touched.add(uvn);
|
|
79338
|
+
lastExpanded = uvn;
|
|
79394
79339
|
}
|
|
79395
79340
|
return lastExpanded;
|
|
79396
79341
|
}
|
|
@@ -79408,16 +79353,6 @@ var Runtime = class _Runtime {
|
|
|
79408
79353
|
const vn = cmd.words[i].plain;
|
|
79409
79354
|
if (vn && startIdx === 1 && hasShellFunction(rawState, vn)) return void 0;
|
|
79410
79355
|
if (!vn || vn.startsWith("-") || !isShellIdentifier(vn) || controlNames.has(vn) || vn === "OPTIND" || rawState.readonlyVariables?.has(vn) || rawState.variableAttributes?.get(vn) || store?.get(vn) || stateMonitor(rawState)?.hasOverlay(vn) || rawState.locals.some((f) => f.has(vn))) {
|
|
79411
|
-
const wu = cmd.words[i];
|
|
79412
|
-
const p02 = wu.parts[0];
|
|
79413
|
-
const pLast = wu.parts[wu.parts.length - 1];
|
|
79414
|
-
const m = p02?.kind === "text" ? /^([a-zA-Z_][a-zA-Z0-9_]*)\[/.exec(p02.value) : void 0;
|
|
79415
|
-
const arrName = m?.[1];
|
|
79416
|
-
const b = arrName ? store?.get(arrName) : void 0;
|
|
79417
|
-
if (arrName && b && b.references === 1 && !store.watches.has(arrName) && !rawState.readonlyVariables?.has(arrName) && !hasUnpreparedLocal(rawState, arrName) && !stateMonitor(rawState)?.hasOverlay(arrName) && pLast?.kind === "text" && pLast.value.endsWith("]") && this.isPureSyncValueWord(wu, rawState) && (p02.quoted || rawState.noglob || !rawState.nullglob && this._isMemoryBackingFs && tryGetMemoryDirectoryEntryNamesSync5(this.backingFs, rawState.cwd)?.size === 0)) {
|
|
79418
|
-
vars.push(`@${i}`);
|
|
79419
|
-
continue;
|
|
79420
|
-
}
|
|
79421
79356
|
return void 0;
|
|
79422
79357
|
}
|
|
79423
79358
|
vars.push(vn);
|
|
@@ -79970,6 +79905,7 @@ var Runtime = class _Runtime {
|
|
|
79970
79905
|
return false;
|
|
79971
79906
|
}
|
|
79972
79907
|
const assignment = this.assignment(w0);
|
|
79908
|
+
if (assignment && (assignment.name === "LC_ALL" || assignment.name === "LC_CTYPE" || assignment.name === "LC_COLLATE" || assignment.name === "LANG")) return false;
|
|
79973
79909
|
if (!assignment || assignment.append && this.budget.limits.maxExpansionBytes !== Infinity || assignment.name === "OPTIND" || assignment.name === "PIPESTATUS" || assignment.name.includes("[") || rawState.readonlyVariables?.has(assignment.name) || rawState.variableAttributes?.get(assignment.name) || store?.get(assignment.name) || !this.isPureSyncValueWord(assignment.value, rawState)) {
|
|
79974
79910
|
return false;
|
|
79975
79911
|
}
|
|
@@ -81558,7 +81494,7 @@ var Runtime = class _Runtime {
|
|
|
81558
81494
|
if (rawState.allexport) monitor.proxy.exported.add(varName);
|
|
81559
81495
|
} else {
|
|
81560
81496
|
monitor.values.invalidate(varName);
|
|
81561
|
-
monitor.proxy.exported.delete(varName);
|
|
81497
|
+
if (!rawState.exported.has(varName)) monitor.proxy.exported.delete(varName);
|
|
81562
81498
|
}
|
|
81563
81499
|
}
|
|
81564
81500
|
}
|
|
@@ -81781,7 +81717,7 @@ ${s1}
|
|
|
81781
81717
|
};
|
|
81782
81718
|
return visit(script2);
|
|
81783
81719
|
}
|
|
81784
|
-
|
|
81720
|
+
extractLoopInvariantInput(cmd, hasSingleStdinRedir, hasSingleHereStringRedir, rawState) {
|
|
81785
81721
|
const w0 = cmd.words[0]?.plain;
|
|
81786
81722
|
const resolveInvariantWord = (w) => {
|
|
81787
81723
|
if (w.plain !== void 0) return w.plain;
|
|
@@ -81795,10 +81731,10 @@ ${s1}
|
|
|
81795
81731
|
}
|
|
81796
81732
|
return void 0;
|
|
81797
81733
|
};
|
|
81798
|
-
if (w0 === "jq" || w0 === "numfmt") {
|
|
81734
|
+
if (w0 === "jq" || w0 === "numfmt" || w0 === "awk") {
|
|
81799
81735
|
if (hasSingleHereStringRedir) {
|
|
81800
81736
|
const resolved = resolveInvariantWord(cmd.redirects[0].target);
|
|
81801
|
-
return resolved !== void 0 ? resolved
|
|
81737
|
+
return resolved !== void 0 ? resolved + "\n" : void 0;
|
|
81802
81738
|
}
|
|
81803
81739
|
if (this._fileWrites?.size || this._outputFiles?.size) return void 0;
|
|
81804
81740
|
if ([this._activeLoopBodyScript, this._activeLoopCondScript].some((script2) => script2 && !this.isFileReadOnlyScript(script2, rawState))) return void 0;
|
|
@@ -81806,12 +81742,12 @@ ${s1}
|
|
|
81806
81742
|
if (!fPlain || fPlain.startsWith("-") || fPlain === "/dev/stdin") return void 0;
|
|
81807
81743
|
const vCheck = this.tryReadMemoryFileViewSync(resolvePath(rawState.cwd, fPlain), false);
|
|
81808
81744
|
if (!vCheck || vCheck.byteLength > 16384 || vCheck.includes(0)) return void 0;
|
|
81809
|
-
return sharedSyncPipeDecoder.decode(vCheck)
|
|
81745
|
+
return sharedSyncPipeDecoder.decode(vCheck);
|
|
81810
81746
|
}
|
|
81811
81747
|
if (w0 === "cat") {
|
|
81812
81748
|
if (hasSingleHereStringRedir) {
|
|
81813
81749
|
const resolved = resolveInvariantWord(cmd.redirects[0].target);
|
|
81814
|
-
return resolved !== void 0 ? resolved
|
|
81750
|
+
return resolved !== void 0 ? resolved + "\n" : void 0;
|
|
81815
81751
|
}
|
|
81816
81752
|
if (this._fileWrites?.size || this._outputFiles?.size) return void 0;
|
|
81817
81753
|
if ([this._activeLoopBodyScript, this._activeLoopCondScript].some((script2) => script2 && !this.isFileReadOnlyScript(script2, rawState))) return void 0;
|
|
@@ -81819,11 +81755,11 @@ ${s1}
|
|
|
81819
81755
|
if (!fPlain || fPlain.startsWith("-") || fPlain === "/dev/stdin") return void 0;
|
|
81820
81756
|
const vCheck = this.tryReadMemoryFileViewSync(resolvePath(rawState.cwd, fPlain), false);
|
|
81821
81757
|
if (!vCheck || vCheck.byteLength > 16384 || vCheck.includes(0)) return void 0;
|
|
81822
|
-
return sharedSyncPipeDecoder.decode(vCheck)
|
|
81758
|
+
return sharedSyncPipeDecoder.decode(vCheck);
|
|
81823
81759
|
}
|
|
81824
81760
|
if (w0 === "echo" && cmd.words.length === 2) {
|
|
81825
81761
|
const resolved = resolveInvariantWord(cmd.words[1]);
|
|
81826
|
-
if (resolved !== void 0 && !resolved.startsWith("-")) return resolved
|
|
81762
|
+
if (resolved !== void 0 && !resolved.startsWith("-")) return resolved + "\n";
|
|
81827
81763
|
return void 0;
|
|
81828
81764
|
}
|
|
81829
81765
|
if (w0 === "printf" && cmd.words.length >= 2) {
|
|
@@ -81834,7 +81770,7 @@ ${s1}
|
|
|
81834
81770
|
args.push(r);
|
|
81835
81771
|
}
|
|
81836
81772
|
const formatted3 = tryFastPrintf(args);
|
|
81837
|
-
return formatted3
|
|
81773
|
+
return formatted3;
|
|
81838
81774
|
}
|
|
81839
81775
|
return void 0;
|
|
81840
81776
|
}
|
|
@@ -82217,7 +82153,7 @@ ${s1}
|
|
|
82217
82153
|
break;
|
|
82218
82154
|
}
|
|
82219
82155
|
if (step.unsetVars !== void 0) {
|
|
82220
|
-
lastArg = this.execSyncUnsetStep(step, rawState,
|
|
82156
|
+
lastArg = this.execSyncUnsetStep(step, rawState, monitor, touched);
|
|
82221
82157
|
rawState.status = 0;
|
|
82222
82158
|
continue;
|
|
82223
82159
|
}
|
|
@@ -82720,7 +82656,7 @@ ${s1}
|
|
|
82720
82656
|
break;
|
|
82721
82657
|
}
|
|
82722
82658
|
if (step.unsetVars !== void 0) {
|
|
82723
|
-
lastArg = this.execSyncUnsetStep(step, rawState,
|
|
82659
|
+
lastArg = this.execSyncUnsetStep(step, rawState, monitor, touched);
|
|
82724
82660
|
rawState.status = 0;
|
|
82725
82661
|
onUpdate({ lastCmd, lastArg });
|
|
82726
82662
|
continue;
|
|
@@ -82894,7 +82830,7 @@ ${s1}
|
|
|
82894
82830
|
break;
|
|
82895
82831
|
}
|
|
82896
82832
|
if (step.unsetVars !== void 0) {
|
|
82897
|
-
lastArg = this.execSyncUnsetStep(step, rawState,
|
|
82833
|
+
lastArg = this.execSyncUnsetStep(step, rawState, monitor, touched);
|
|
82898
82834
|
rawState.status = 0;
|
|
82899
82835
|
continue;
|
|
82900
82836
|
}
|
|
@@ -90749,13 +90685,13 @@ ${prefix3} line ${offset + line}: \`${source2.split("\n")[line - 1] ?? ""}'
|
|
|
90749
90685
|
}
|
|
90750
90686
|
if (st === "floor") return typeof item === "number" ? [Math.floor(item)] : void 0;
|
|
90751
90687
|
if (st === "ceil") return typeof item === "number" ? [Math.ceil(item)] : void 0;
|
|
90752
|
-
if (st === "round") return typeof item === "number" ? [Math.round(item)] : void 0;
|
|
90688
|
+
if (st === "round") return typeof item === "number" ? [Math.sign(item) * Math.round(Math.abs(item))] : void 0;
|
|
90753
90689
|
if (st === "abs") return typeof item === "number" ? [Math.abs(item)] : void 0;
|
|
90754
|
-
if (st === "utf8bytelength") return typeof item === "string" ? [
|
|
90690
|
+
if (st === "utf8bytelength") return typeof item === "string" ? [fastSharedTextEncoder.encode(item).byteLength] : void 0;
|
|
90755
90691
|
if (st === "explode") return typeof item === "string" ? [Array.from(item, (c) => c.codePointAt(0))] : void 0;
|
|
90756
90692
|
if (st === "implode") {
|
|
90757
90693
|
if (!Array.isArray(item) || !item.every((x) => typeof x === "number" && Number.isInteger(x) && x >= 0 && x <= 1114111)) return void 0;
|
|
90758
|
-
return [String.fromCodePoint(
|
|
90694
|
+
return [item.map((cp) => String.fromCodePoint(cp >= 55296 && cp <= 57343 ? 65533 : cp)).join("")];
|
|
90759
90695
|
}
|
|
90760
90696
|
if (st === "transpose") {
|
|
90761
90697
|
if (!Array.isArray(item) || !item.every((row) => Array.isArray(row))) return void 0;
|
|
@@ -90768,14 +90704,18 @@ ${prefix3} line ${offset + line}: \`${source2.split("\n")[line - 1] ?? ""}'
|
|
|
90768
90704
|
return [trans];
|
|
90769
90705
|
}
|
|
90770
90706
|
const idxFnM = /^(index|rindex|indices)\(\s*"([^"\\]*)"\s*\)$/.exec(st);
|
|
90771
|
-
if (idxFnM && typeof item === "string") {
|
|
90707
|
+
if (idxFnM && (typeof item === "string" || Array.isArray(item))) {
|
|
90772
90708
|
const fn = idxFnM[1];
|
|
90773
90709
|
const sub = idxFnM[2];
|
|
90774
90710
|
const found = [];
|
|
90775
|
-
if (
|
|
90711
|
+
if (Array.isArray(item)) {
|
|
90712
|
+
for (let i = 0; i < item.length; i++) {
|
|
90713
|
+
if (item[i] === sub) found.push(i);
|
|
90714
|
+
}
|
|
90715
|
+
} else if (sub.length > 0) {
|
|
90776
90716
|
let pos = 0;
|
|
90777
90717
|
while ((pos = item.indexOf(sub, pos)) !== -1) {
|
|
90778
|
-
found.push(
|
|
90718
|
+
found.push(fastSharedTextEncoder.encode(item.slice(0, pos)).byteLength);
|
|
90779
90719
|
pos += 1;
|
|
90780
90720
|
}
|
|
90781
90721
|
}
|
|
@@ -91898,6 +91838,7 @@ ${prefix3} line ${offset + line}: \`${source2.split("\n")[line - 1] ?? ""}'
|
|
|
91898
91838
|
if (m[1] !== void 0) {
|
|
91899
91839
|
const tm = /^(\$(?:[0-9]+|NF)|NR|NF)\s*(==|!=|>=|<=|>|<)\s*(-?[0-9]+(?:\.[0-9]+)?|"[^"$\\]*")\s*\?\s*(\$(?:[0-9]+|NF)|"[^"$\\]*"|-?[0-9]+(?:\.[0-9]+)?)\s*:\s*(\$(?:[0-9]+|NF)|"[^"$\\]*"|-?[0-9]+(?:\.[0-9]+)?)$/.exec(m[1].trim());
|
|
91900
91840
|
if (!tm) return void 0;
|
|
91841
|
+
if (tm[2] === ">") return void 0;
|
|
91901
91842
|
parts.push({ kind: "ternary", lhs: tm[1], op: tm[2], rhs: tm[3], yes: tm[4], no: tm[5] });
|
|
91902
91843
|
} else if (m[2] !== void 0) parts.push({ kind: "int", token: m[2] });
|
|
91903
91844
|
else if (m[3] !== void 0) parts.push({ kind: "case", fn: m[3] === "toupper" ? "upper" : "lower", token: m[4] });
|
|
@@ -91980,8 +91921,9 @@ ${prefix3} line ${offset + line}: \`${source2.split("\n")[line - 1] ?? ""}'
|
|
|
91980
91921
|
} else if (p.kind === "int") {
|
|
91981
91922
|
const idx = p.token === "NF" ? fields3.length : Number(p.token);
|
|
91982
91923
|
const s = idx === 0 ? l : idx >= 1 && idx <= fields3.length ? fields3[idx - 1] : "";
|
|
91983
|
-
const n =
|
|
91984
|
-
|
|
91924
|
+
const n = number(inputValue(s));
|
|
91925
|
+
if (!Number.isFinite(n)) return void 0;
|
|
91926
|
+
out += text(numeric2(Math.trunc(n)));
|
|
91985
91927
|
} else if (p.kind === "ternary") {
|
|
91986
91928
|
const resolveAtom = (tok) => {
|
|
91987
91929
|
if (tok.startsWith('"') && tok.endsWith('"')) return tok.slice(1, -1);
|
|
@@ -91995,15 +91937,10 @@ ${prefix3} line ${offset + line}: \`${source2.split("\n")[line - 1] ?? ""}'
|
|
|
91995
91937
|
};
|
|
91996
91938
|
const lv = resolveAtom(p.lhs);
|
|
91997
91939
|
const rv = resolveAtom(p.rhs);
|
|
91998
|
-
const
|
|
91999
|
-
|
|
92000
|
-
|
|
92001
|
-
|
|
92002
|
-
} else {
|
|
92003
|
-
const ln = Number(lv) || 0;
|
|
92004
|
-
const rn = Number(rv) || 0;
|
|
92005
|
-
cond = p.op === "==" ? ln === rn : p.op === "!=" ? ln !== rn : p.op === ">" ? ln > rn : p.op === "<" ? ln < rn : p.op === ">=" ? ln >= rn : ln <= rn;
|
|
92006
|
-
}
|
|
91940
|
+
const left = p.lhs === "NR" || p.lhs === "NF" ? numeric2(Number(lv)) : inputValue(lv);
|
|
91941
|
+
const right = p.rhs.startsWith('"') ? string(rv) : numeric2(Number(rv));
|
|
91942
|
+
const comparison = compare2(left, right, "%.6g");
|
|
91943
|
+
const cond = p.op === "==" ? comparison === 0 : p.op === "!=" ? comparison !== 0 : p.op === ">" ? comparison > 0 : p.op === "<" ? comparison < 0 : p.op === ">=" ? comparison >= 0 : comparison <= 0;
|
|
92007
91944
|
out += resolveAtom(cond ? p.yes : p.no);
|
|
92008
91945
|
} else if (p.kind === "arith") {
|
|
92009
91946
|
const vals = [];
|
|
@@ -92222,12 +92159,13 @@ ${prefix3} line ${offset + line}: \`${source2.split("\n")[line - 1] ?? ""}'
|
|
|
92222
92159
|
const parseDelims = (s) => {
|
|
92223
92160
|
if (s.length === 0) return [""];
|
|
92224
92161
|
const res = [];
|
|
92162
|
+
const chars = Array.from(s);
|
|
92225
92163
|
const escapes2 = { b: "\b", f: "\f", n: "\n", r: "\r", t: " ", v: "\v", "0": "" };
|
|
92226
|
-
for (let i = 0; i <
|
|
92227
|
-
const ch =
|
|
92164
|
+
for (let i = 0; i < chars.length; i++) {
|
|
92165
|
+
const ch = chars[i];
|
|
92228
92166
|
if (ch === "\\") {
|
|
92229
|
-
if (i + 1 >=
|
|
92230
|
-
const esc =
|
|
92167
|
+
if (i + 1 >= chars.length) return void 0;
|
|
92168
|
+
const esc = chars[++i];
|
|
92231
92169
|
res.push(escapes2[esc] ?? esc);
|
|
92232
92170
|
} else {
|
|
92233
92171
|
res.push(ch);
|
|
@@ -381,7 +381,7 @@ function getCompiledSyncPatternRegex(pattern) {
|
|
|
381
381
|
return compiled;
|
|
382
382
|
}
|
|
383
383
|
export function tryMatchesPatternSync(pattern, value, work, ignoreCase = false, extglob = false) {
|
|
384
|
-
if (Array.from !== defaultArrayFrom || ignoreCase || pattern.length >= 128
|
|
384
|
+
if (Array.from !== defaultArrayFrom || ignoreCase || pattern.length >= 128)
|
|
385
385
|
return undefined;
|
|
386
386
|
let hasBracketOrQmark = false;
|
|
387
387
|
for (let i = 0; i < pattern.length; i++) {
|
|
@@ -532,7 +532,7 @@ export declare class Runtime {
|
|
|
532
532
|
private isVarUnmutatedInScript;
|
|
533
533
|
private isVarUnmutatedInActiveLoop;
|
|
534
534
|
private isFileReadOnlyScript;
|
|
535
|
-
private
|
|
535
|
+
private extractLoopInvariantInput;
|
|
536
536
|
private canSyncPrintfInductionBody;
|
|
537
537
|
private isSyncPrintfCallOk;
|
|
538
538
|
private isSimpleRedirectEchoWord;
|