@sjawhar/pi-legion-envoy 5.17.4 → 5.17.5
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/legion.js +216 -47
- package/package.json +1 -1
package/dist/legion.js
CHANGED
|
@@ -33473,7 +33473,7 @@ import { logger } from "@oh-my-pi/pi-utils";
|
|
|
33473
33473
|
// package.json
|
|
33474
33474
|
var package_default = {
|
|
33475
33475
|
name: "@sjawhar/pi-legion-envoy",
|
|
33476
|
-
version: "5.17.
|
|
33476
|
+
version: "5.17.5",
|
|
33477
33477
|
type: "module",
|
|
33478
33478
|
omp: {
|
|
33479
33479
|
extensions: [
|
|
@@ -34780,6 +34780,7 @@ import {
|
|
|
34780
34780
|
opendirSync,
|
|
34781
34781
|
openSync,
|
|
34782
34782
|
readFileSync as readFileSync3,
|
|
34783
|
+
readlinkSync,
|
|
34783
34784
|
readSync,
|
|
34784
34785
|
realpathSync,
|
|
34785
34786
|
statSync
|
|
@@ -41624,6 +41625,70 @@ function realish(abs, followFinal) {
|
|
|
41624
41625
|
return realExisting(resolved);
|
|
41625
41626
|
return path4.join(realExisting(path4.dirname(resolved)), path4.basename(resolved));
|
|
41626
41627
|
}
|
|
41628
|
+
function readlinkTarget(link) {
|
|
41629
|
+
try {
|
|
41630
|
+
return readlinkSync(link);
|
|
41631
|
+
} catch {
|
|
41632
|
+
return "a target the guard cannot read";
|
|
41633
|
+
}
|
|
41634
|
+
}
|
|
41635
|
+
function physical(cwd, text, followFinal) {
|
|
41636
|
+
const joined = text.startsWith("/") ? text : `${cwd}/${text}`;
|
|
41637
|
+
const parts = joined.split("/");
|
|
41638
|
+
const last = parts.findLastIndex((part) => part !== "" && part !== ".");
|
|
41639
|
+
const pending = [];
|
|
41640
|
+
let real = "/";
|
|
41641
|
+
for (let i = 0;i < parts.length; i += 1) {
|
|
41642
|
+
const part = parts[i];
|
|
41643
|
+
if (part === "" || part === ".")
|
|
41644
|
+
continue;
|
|
41645
|
+
if (pending.length > 0) {
|
|
41646
|
+
if (part === "..") {
|
|
41647
|
+
return {
|
|
41648
|
+
unknown: `\`${path4.join(real, ...pending)}\`, which does not exist yet, so the guard ` + "cannot know where the `..` after it leads"
|
|
41649
|
+
};
|
|
41650
|
+
}
|
|
41651
|
+
pending.push(part);
|
|
41652
|
+
continue;
|
|
41653
|
+
}
|
|
41654
|
+
if (part === "..") {
|
|
41655
|
+
real = path4.dirname(real);
|
|
41656
|
+
continue;
|
|
41657
|
+
}
|
|
41658
|
+
const candidate = real === "/" ? `/${part}` : `${real}/${part}`;
|
|
41659
|
+
if (!followFinal && i === last) {
|
|
41660
|
+
return { real: candidate };
|
|
41661
|
+
}
|
|
41662
|
+
let link;
|
|
41663
|
+
try {
|
|
41664
|
+
link = lstatSync(candidate).isSymbolicLink();
|
|
41665
|
+
} catch (error48) {
|
|
41666
|
+
if (error48.code !== "ENOENT") {
|
|
41667
|
+
return { unknown: `\`${candidate}\`, which the guard cannot read (${messageFor(error48)})` };
|
|
41668
|
+
}
|
|
41669
|
+
pending.push(part);
|
|
41670
|
+
continue;
|
|
41671
|
+
}
|
|
41672
|
+
if (!link) {
|
|
41673
|
+
real = candidate;
|
|
41674
|
+
continue;
|
|
41675
|
+
}
|
|
41676
|
+
try {
|
|
41677
|
+
real = realpathSync(candidate);
|
|
41678
|
+
} catch (error48) {
|
|
41679
|
+
const code = error48.code;
|
|
41680
|
+
const why = code === "ENOENT" ? `points at \`${readlinkTarget(candidate)}\`, which is not there` : `cannot be followed (${messageFor(error48)})`;
|
|
41681
|
+
return { unknown: `the link \`${candidate}\` ${why}, so the guard cannot resolve this path` };
|
|
41682
|
+
}
|
|
41683
|
+
}
|
|
41684
|
+
return { real: pending.length === 0 ? real : path4.join(real, ...pending) };
|
|
41685
|
+
}
|
|
41686
|
+
function kernelPath(from, text) {
|
|
41687
|
+
if (from === undefined && !text.startsWith("/"))
|
|
41688
|
+
return;
|
|
41689
|
+
const resolved = physical(from ?? "/", text, true);
|
|
41690
|
+
return "unknown" in resolved ? undefined : resolved.real;
|
|
41691
|
+
}
|
|
41627
41692
|
function isProtectedScratchComponent(component, roots, partial2 = false) {
|
|
41628
41693
|
return roots.protectedScratch.some((name) => component.startsWith(name) || partial2 && name.startsWith(component)) || roots.protectedDirectories.some((name) => component === name || partial2 && name.startsWith(component));
|
|
41629
41694
|
}
|
|
@@ -41656,12 +41721,16 @@ function judgePath(exp, st, ctx, options) {
|
|
|
41656
41721
|
resolution: `relative to a working directory unknown after ${st.cwdWhy}`
|
|
41657
41722
|
};
|
|
41658
41723
|
}
|
|
41659
|
-
const
|
|
41660
|
-
|
|
41724
|
+
const resolved2 = physical(st.cwd ?? "/", text, options.follow || text.endsWith("/"));
|
|
41725
|
+
if ("unknown" in resolved2) {
|
|
41726
|
+
return { ok: false, resolution: resolved2.unknown, unresolved: true };
|
|
41727
|
+
}
|
|
41728
|
+
const real2 = resolved2.real;
|
|
41661
41729
|
if (inWorkspace(real2, roots) || inScratch(real2, roots))
|
|
41662
41730
|
return { ok: true };
|
|
41663
41731
|
if (options.overwrite && !existsSync(real2))
|
|
41664
41732
|
return { ok: true };
|
|
41733
|
+
const abs = path4.resolve(st.cwd ?? "/", text);
|
|
41665
41734
|
return { ok: false, resolution: real2 === abs ? real2 : `${abs}, which resolves to ${real2}` };
|
|
41666
41735
|
}
|
|
41667
41736
|
const piece = exp[open];
|
|
@@ -41676,11 +41745,13 @@ function judgePath(exp, st, ctx, options) {
|
|
|
41676
41745
|
return { ok: false, resolution: `relative to a working directory unknown after ${st.cwdWhy}` };
|
|
41677
41746
|
}
|
|
41678
41747
|
const component = prefix.slice(slash + 1);
|
|
41679
|
-
|
|
41680
|
-
|
|
41681
|
-
|
|
41748
|
+
const stemText = slash === -1 ? "." : slash === 0 ? "/" : prefix.slice(0, slash);
|
|
41749
|
+
const resolved = physical(st.cwd ?? "/", stemText, true);
|
|
41750
|
+
if ("unknown" in resolved) {
|
|
41751
|
+
return { ok: false, resolution: resolved.unknown, unresolved: true };
|
|
41682
41752
|
}
|
|
41683
|
-
const
|
|
41753
|
+
const dotGlob = piece.kind === "glob" && (component === "" ? piece.text : component).startsWith(".");
|
|
41754
|
+
const real = dotGlob ? path4.dirname(resolved.real) : resolved.real;
|
|
41684
41755
|
const allowed = inWorkspace(real, roots) || inScratch(real, roots) || real === roots.scratch && component !== "" && !isProtectedScratchComponent(component, roots, true);
|
|
41685
41756
|
if (allowed)
|
|
41686
41757
|
return { ok: true };
|
|
@@ -42014,12 +42085,13 @@ function patternExpansion(part, quoted, st, ctx) {
|
|
|
42014
42085
|
return [unquotedLiteral(result.replaceAll("\\", "\\\\"), undefined, st, ctx)];
|
|
42015
42086
|
}
|
|
42016
42087
|
function substitution(script, text, st, ctx) {
|
|
42017
|
-
const pidRead = /^\$\(
|
|
42018
|
-
const variableRead = /^\$\(
|
|
42088
|
+
const pidRead = /^\$\(<\s*(.+?)\s*\)$/.exec(text);
|
|
42089
|
+
const variableRead = /^\$\(<\s*"?\$([A-Za-z_][A-Za-z0-9_]*)"?\s*\)$/.exec(text);
|
|
42019
42090
|
const directFile = pidRead?.[1]?.includes("$") === true ? undefined : pidRead?.[1];
|
|
42020
42091
|
const file2 = directFile ?? (variableRead === null ? undefined : literalText(lookup(variableRead[1], st, ctx)));
|
|
42021
|
-
|
|
42022
|
-
|
|
42092
|
+
const pidFile = file2 === undefined ? undefined : kernelPath(st.cwd, file2);
|
|
42093
|
+
if (pidFile !== undefined) {
|
|
42094
|
+
const pid = st.pidFiles.get(pidFile);
|
|
42023
42095
|
if (pid !== undefined)
|
|
42024
42096
|
return [[...pid]];
|
|
42025
42097
|
}
|
|
@@ -42073,22 +42145,70 @@ function substitutionInvocation(node, st, ctx) {
|
|
|
42073
42145
|
return;
|
|
42074
42146
|
return { base: path4.basename(name), command: node, rest: argv.slice(1) };
|
|
42075
42147
|
}
|
|
42148
|
+
function gnuDirname(text) {
|
|
42149
|
+
const trimmed = text.replace(/\/+$/, "");
|
|
42150
|
+
if (trimmed === "")
|
|
42151
|
+
return "/";
|
|
42152
|
+
const cut = trimmed.replace(/\/+[^/]+$/, "");
|
|
42153
|
+
if (cut === trimmed)
|
|
42154
|
+
return ".";
|
|
42155
|
+
return cut === "" ? "/" : cut;
|
|
42156
|
+
}
|
|
42157
|
+
function gnuBasename(text) {
|
|
42158
|
+
const trimmed = text.replace(/\/+$/, "");
|
|
42159
|
+
if (trimmed === "")
|
|
42160
|
+
return text === "" ? "" : "/";
|
|
42161
|
+
return trimmed.slice(trimmed.lastIndexOf("/") + 1);
|
|
42162
|
+
}
|
|
42076
42163
|
function substitutionPath(base, list, st) {
|
|
42077
42164
|
if (!["dirname", "basename", "realpath", "readlink"].includes(base))
|
|
42078
42165
|
return;
|
|
42079
|
-
const
|
|
42080
|
-
if (
|
|
42166
|
+
const found = operands(list, "");
|
|
42167
|
+
if (base === "basename" && found.options.some((option) => option === "--multiple" || option.startsWith("--suffix") || /^-[^-]*[as]/.test(option))) {
|
|
42168
|
+
return;
|
|
42169
|
+
}
|
|
42170
|
+
const suffixed = base === "basename" && found.operands.length === 2;
|
|
42171
|
+
if (found.operands.length !== 1 && !suffixed)
|
|
42172
|
+
return;
|
|
42173
|
+
const target = literalText(found.operands[0]?.exp);
|
|
42174
|
+
const suffix = suffixed ? literalText(found.operands[1]?.exp) : "";
|
|
42175
|
+
if (target === undefined || suffix === undefined || st.cwd === undefined)
|
|
42081
42176
|
return;
|
|
42082
42177
|
if (target === "")
|
|
42083
42178
|
return base === "dirname" ? "." : "";
|
|
42084
|
-
const abs = path4.resolve(st.cwd, target);
|
|
42085
42179
|
if (base === "dirname")
|
|
42086
|
-
return
|
|
42087
|
-
if (base === "basename")
|
|
42088
|
-
|
|
42089
|
-
|
|
42090
|
-
|
|
42091
|
-
|
|
42180
|
+
return gnuDirname(target);
|
|
42181
|
+
if (base === "basename") {
|
|
42182
|
+
const name = gnuBasename(target);
|
|
42183
|
+
return suffix !== "" && name !== suffix && name.endsWith(suffix) ? name.slice(0, -suffix.length) : name;
|
|
42184
|
+
}
|
|
42185
|
+
if (base === "readlink") {
|
|
42186
|
+
const mode = lastModeFlag(found.options, "fem", {
|
|
42187
|
+
"--canonicalize": "f",
|
|
42188
|
+
"--canonicalize-existing": "e",
|
|
42189
|
+
"--canonicalize-missing": "m"
|
|
42190
|
+
});
|
|
42191
|
+
if (mode !== "f" && mode !== "m")
|
|
42192
|
+
return;
|
|
42193
|
+
}
|
|
42194
|
+
if (base === "realpath") {
|
|
42195
|
+
if (found.options.some((option) => option.startsWith("--relative")))
|
|
42196
|
+
return;
|
|
42197
|
+
const mode = lastModeFlag(found.options, "sLP", {
|
|
42198
|
+
"--strip": "s",
|
|
42199
|
+
"--no-symlinks": "s",
|
|
42200
|
+
"--logical": "L",
|
|
42201
|
+
"--physical": "P"
|
|
42202
|
+
});
|
|
42203
|
+
if (mode === "s" || mode === "L") {
|
|
42204
|
+
const here = kernelPath("/", st.cwd);
|
|
42205
|
+
if (here === undefined)
|
|
42206
|
+
return;
|
|
42207
|
+
const lexical = path4.resolve(here, target);
|
|
42208
|
+
return mode === "s" ? lexical : kernelPath("/", lexical);
|
|
42209
|
+
}
|
|
42210
|
+
}
|
|
42211
|
+
return kernelPath(st.cwd, target);
|
|
42092
42212
|
}
|
|
42093
42213
|
function mktempPath(command, st, ctx) {
|
|
42094
42214
|
const words = command.suffix;
|
|
@@ -42107,7 +42227,7 @@ function mktempPath(command, st, ctx) {
|
|
|
42107
42227
|
else if (value.startsWith("-p") && value.length > 2)
|
|
42108
42228
|
directory = [literal2(value.slice(2))];
|
|
42109
42229
|
else if (!value.startsWith("-") && value.includes("/")) {
|
|
42110
|
-
directory = [literal2(path4.
|
|
42230
|
+
directory = [literal2(path4.dirname(value))];
|
|
42111
42231
|
}
|
|
42112
42232
|
}
|
|
42113
42233
|
const base = directory ?? [literal2(ctx.env.TMPDIR ?? "/tmp")];
|
|
@@ -42553,6 +42673,10 @@ function modelPidFile(st, ctx, file2, pid) {
|
|
|
42553
42673
|
model.set(file2, [unknown2("a pid a branch or loop body wrote to this file", true)]);
|
|
42554
42674
|
}
|
|
42555
42675
|
}
|
|
42676
|
+
function forgetFileModels(st, ctx, why) {
|
|
42677
|
+
st.pidFiles.clear();
|
|
42678
|
+
ctx.unnameableWrite.why ??= why;
|
|
42679
|
+
}
|
|
42556
42680
|
function handlerVars(trap, vars) {
|
|
42557
42681
|
const { vars: branch, merged } = trap;
|
|
42558
42682
|
if (branch === undefined || merged === undefined)
|
|
@@ -42944,13 +43068,15 @@ function checkRedirects(redirects, command, site, st, ctx) {
|
|
|
42944
43068
|
if (writes || operator === ">&") {
|
|
42945
43069
|
const verdict = judgePath(exp, st, ctx, { follow: true, overwrite: true });
|
|
42946
43070
|
if (!verdict.ok) {
|
|
42947
|
-
throw refusal(site, `the redirection \`${operator}\` would overwrite \`${redirect.target.text}\` (${verdict.resolution})`, ctx);
|
|
43071
|
+
throw refusal(site, `the redirection \`${operator}\` would overwrite \`${redirect.target.text}\` (${verdict.resolution})`, ctx, verdict.unresolved);
|
|
42948
43072
|
}
|
|
42949
43073
|
}
|
|
42950
43074
|
const target = literalText(exp);
|
|
42951
|
-
|
|
43075
|
+
const file2 = target === undefined ? undefined : kernelPath(st.cwd, target);
|
|
43076
|
+
if (file2 === undefined) {
|
|
43077
|
+
forgetFileModels(st, ctx, `the redirection \`${operator} ${redirect.target.text}\``);
|
|
42952
43078
|
continue;
|
|
42953
|
-
|
|
43079
|
+
}
|
|
42954
43080
|
let content = null;
|
|
42955
43081
|
if (command?.name === "cat" && command.args.length === 0) {
|
|
42956
43082
|
if (heredoc !== undefined)
|
|
@@ -42984,9 +43110,9 @@ function groupOutputFile(statement, st, ctx) {
|
|
|
42984
43110
|
}
|
|
42985
43111
|
const targets = expandWord(redirect.target, st, ctx);
|
|
42986
43112
|
const target = targets.length === 1 ? literalText(targets[0]) : undefined;
|
|
42987
|
-
if (target === undefined
|
|
43113
|
+
if (target === undefined)
|
|
42988
43114
|
return;
|
|
42989
|
-
return
|
|
43115
|
+
return kernelPath(st.cwd, target);
|
|
42990
43116
|
}
|
|
42991
43117
|
function walkRenderingGroup(group, st, ctx) {
|
|
42992
43118
|
let content = "";
|
|
@@ -43105,8 +43231,10 @@ function printfText(list, limit, script = false) {
|
|
|
43105
43231
|
} while (conversions > 0 && index < values.length);
|
|
43106
43232
|
return out;
|
|
43107
43233
|
}
|
|
43108
|
-
function refusal(site, detail, ctx) {
|
|
43109
|
-
|
|
43234
|
+
function refusal(site, detail, ctx, unresolved = false) {
|
|
43235
|
+
const where = unresolved ? `. Every target is resolved as the kernel resolves it, against ${describeRoots(ctx.roots)}` : `, outside ${describeRoots(ctx.roots)}`;
|
|
43236
|
+
const hint = unresolved ? "Make the unresolved path component resolvable in an earlier command \u2014 create it, make " + "it readable, or fix a dangling or looping symlink \u2014 then run this command." : HINT;
|
|
43237
|
+
return new Refusal(site.snippet, site.line, `${detail}${where}. ${hint}`);
|
|
43110
43238
|
}
|
|
43111
43239
|
function handleCommand(command, st, ctx, pipeIn) {
|
|
43112
43240
|
const site = siteOf(command, st);
|
|
@@ -43204,6 +43332,16 @@ function operands(list, valued, longValued = []) {
|
|
|
43204
43332
|
}
|
|
43205
43333
|
return { options, operands: found };
|
|
43206
43334
|
}
|
|
43335
|
+
function lastModeFlag(options, letters, long = {}) {
|
|
43336
|
+
return options.flatMap((option) => {
|
|
43337
|
+
const named = long[option];
|
|
43338
|
+
if (named !== undefined)
|
|
43339
|
+
return [named];
|
|
43340
|
+
if (!/^-[a-zA-Z]+$/.test(option))
|
|
43341
|
+
return [];
|
|
43342
|
+
return [...option.slice(1)].filter((letter) => letters.includes(letter));
|
|
43343
|
+
}).at(-1);
|
|
43344
|
+
}
|
|
43207
43345
|
function unwrap2(argv, st, ctx, site) {
|
|
43208
43346
|
const alts = [];
|
|
43209
43347
|
let list = argv;
|
|
@@ -43287,10 +43425,10 @@ function unwrap2(argv, st, ctx, site) {
|
|
|
43287
43425
|
i += 1;
|
|
43288
43426
|
} else if (text === "-C" || text === "--chdir") {
|
|
43289
43427
|
const dir = literalText(rest[i + 1]?.exp);
|
|
43290
|
-
cwd = dir === undefined
|
|
43428
|
+
cwd = dir === undefined ? undefined : kernelPath(state.cwd, dir);
|
|
43291
43429
|
i += 1;
|
|
43292
43430
|
} else if (text?.startsWith("--chdir=")) {
|
|
43293
|
-
cwd =
|
|
43431
|
+
cwd = kernelPath(state.cwd, text.slice(8));
|
|
43294
43432
|
} else if (text === "-S" || text === "--split-string") {
|
|
43295
43433
|
const split = literalText(rest[i + 1]?.exp);
|
|
43296
43434
|
const tail = rest.slice(i + 2);
|
|
@@ -43457,10 +43595,25 @@ function dispatch(invocation, outer, ctx) {
|
|
|
43457
43595
|
outer.output = rest.length === 1 && rest[0] !== undefined ? [...outer.output, rest[0].exp] : undefined;
|
|
43458
43596
|
}
|
|
43459
43597
|
return;
|
|
43460
|
-
case "cd":
|
|
43598
|
+
case "cd": {
|
|
43599
|
+
const found = operands(rest, "");
|
|
43600
|
+
if (found.options.some((option) => !/^-[LPe]+$/.test(option))) {
|
|
43601
|
+
outer.cwd = undefined;
|
|
43602
|
+
outer.cwdWhy = "`cd` with an option the guard does not model";
|
|
43603
|
+
return;
|
|
43604
|
+
}
|
|
43605
|
+
changeDirectory(found.operands[0], lastModeFlag(found.options, "LP") === "P", outer, ctx);
|
|
43606
|
+
return;
|
|
43607
|
+
}
|
|
43461
43608
|
case "pushd": {
|
|
43462
|
-
const
|
|
43463
|
-
|
|
43609
|
+
const found = operands(rest, "");
|
|
43610
|
+
const operand = literalText(found.operands[0]?.exp);
|
|
43611
|
+
if (found.options.length > 0 || found.operands[0] === undefined || operand?.startsWith("+") === true) {
|
|
43612
|
+
outer.cwd = undefined;
|
|
43613
|
+
outer.cwdWhy = "`pushd` with a directory stack or option the guard does not model";
|
|
43614
|
+
return;
|
|
43615
|
+
}
|
|
43616
|
+
changeDirectory(found.operands[0], false, outer, ctx);
|
|
43464
43617
|
return;
|
|
43465
43618
|
}
|
|
43466
43619
|
case "popd":
|
|
@@ -43812,16 +43965,18 @@ function dispatch(invocation, outer, ctx) {
|
|
|
43812
43965
|
if (!append) {
|
|
43813
43966
|
const verdict = judgePath(arg.exp, st, ctx, { follow: true, overwrite: true });
|
|
43814
43967
|
if (!verdict.ok) {
|
|
43815
|
-
throw refusal(site, `tee would overwrite \`${arg.text}\` (${verdict.resolution})`, ctx);
|
|
43968
|
+
throw refusal(site, `tee would overwrite \`${arg.text}\` (${verdict.resolution})`, ctx, verdict.unresolved);
|
|
43816
43969
|
}
|
|
43817
43970
|
}
|
|
43818
43971
|
const target = literalText(arg.exp);
|
|
43819
|
-
|
|
43820
|
-
|
|
43821
|
-
st.
|
|
43822
|
-
|
|
43823
|
-
modelWrite(st, ctx, file2, append ? UNREAD_FILE : text === null ? UNRENDERED_WRITE : readable(text) ?? OVERLONG_WRITE);
|
|
43972
|
+
const file2 = target === undefined ? undefined : kernelPath(st.cwd, target);
|
|
43973
|
+
if (file2 === undefined) {
|
|
43974
|
+
forgetFileModels(st, ctx, `\`tee ${arg.text}\``);
|
|
43975
|
+
continue;
|
|
43824
43976
|
}
|
|
43977
|
+
st.pidFiles.delete(file2);
|
|
43978
|
+
const text = heredoc === undefined ? null : heredocText(heredoc);
|
|
43979
|
+
modelWrite(st, ctx, file2, append ? UNREAD_FILE : text === null ? UNRENDERED_WRITE : readable(text) ?? OVERLONG_WRITE);
|
|
43825
43980
|
}
|
|
43826
43981
|
return;
|
|
43827
43982
|
}
|
|
@@ -43946,7 +44101,7 @@ function dispatch(invocation, outer, ctx) {
|
|
|
43946
44101
|
runFile(argv[0], rest, childState(st, invocation.overlay), ctx, site, "auto");
|
|
43947
44102
|
}
|
|
43948
44103
|
}
|
|
43949
|
-
function changeDirectory(target, st, ctx) {
|
|
44104
|
+
function changeDirectory(target, physicalMode, st, ctx) {
|
|
43950
44105
|
if (target === undefined) {
|
|
43951
44106
|
const home = literalText(lookup("HOME", st, ctx));
|
|
43952
44107
|
st.cwd = home;
|
|
@@ -43959,7 +44114,13 @@ function changeDirectory(target, st, ctx) {
|
|
|
43959
44114
|
st.cwdWhy = `\`cd ${target.text}\``;
|
|
43960
44115
|
return;
|
|
43961
44116
|
}
|
|
43962
|
-
|
|
44117
|
+
if (!physicalMode) {
|
|
44118
|
+
st.cwd = path4.resolve(st.cwd, text);
|
|
44119
|
+
return;
|
|
44120
|
+
}
|
|
44121
|
+
st.cwd = kernelPath(st.cwd, text);
|
|
44122
|
+
if (st.cwd === undefined)
|
|
44123
|
+
st.cwdWhy = `\`cd -P ${target.text}\``;
|
|
43963
44124
|
}
|
|
43964
44125
|
function declaration(builtin, list, st, ctx, site) {
|
|
43965
44126
|
const options = list.map((arg) => literalText(arg.exp) ?? "").filter((text) => /^[-+][a-zA-Z]+$/.test(text));
|
|
@@ -44155,13 +44316,13 @@ function checkTargets(program, verb, targets, reach, st, ctx, site) {
|
|
|
44155
44316
|
continue;
|
|
44156
44317
|
const verdict = judgePath(target.exp, st, ctx, { follow, overwrite: reach.overwrite });
|
|
44157
44318
|
if (!verdict.ok) {
|
|
44158
|
-
throw refusal(site, `${program} would ${verb} \`${target.text}\` (${verdict.resolution})`, ctx);
|
|
44319
|
+
throw refusal(site, `${program} would ${verb} \`${target.text}\` (${verdict.resolution})`, ctx, verdict.unresolved);
|
|
44159
44320
|
}
|
|
44160
44321
|
}
|
|
44161
44322
|
const text = literalText(target.exp);
|
|
44162
|
-
|
|
44163
|
-
|
|
44164
|
-
|
|
44323
|
+
const file2 = text === undefined ? undefined : kernelPath(st.cwd, text);
|
|
44324
|
+
if (file2 !== undefined)
|
|
44325
|
+
st.pidFiles.delete(file2);
|
|
44165
44326
|
}
|
|
44166
44327
|
}
|
|
44167
44328
|
function completeName(prefix, names) {
|
|
@@ -44917,7 +45078,14 @@ function runFile(file2, positional, st, ctx, site, kind, source = false) {
|
|
|
44917
45078
|
if (text === undefined || !text.startsWith("/") && st.cwd === undefined) {
|
|
44918
45079
|
throw new Refusal(site.snippet, site.line, `the guard cannot resolve the script \`${file2.text}\` (${file2.exp.find((p) => p.kind !== "literal")?.why ?? `a working directory unknown after ${st.cwdWhy}`}), so it cannot read what it runs`);
|
|
44919
45080
|
}
|
|
44920
|
-
|
|
45081
|
+
if (ctx.unnameableWrite.why !== undefined) {
|
|
45082
|
+
throw new Refusal(site.snippet, site.line, `${ctx.unnameableWrite.why} writes a file the guard cannot name, so it cannot tell whether \`${file2.text}\` is the file that was written`);
|
|
45083
|
+
}
|
|
45084
|
+
const resolved = physical(st.cwd ?? "/", text, true);
|
|
45085
|
+
if ("unknown" in resolved) {
|
|
45086
|
+
throw new Refusal(site.snippet, site.line, `the guard cannot resolve the script \`${file2.text}\` (${resolved.unknown}), so it cannot read what it runs`);
|
|
45087
|
+
}
|
|
45088
|
+
const abs = resolved.real;
|
|
44921
45089
|
let content;
|
|
44922
45090
|
if (st.files.has(abs)) {
|
|
44923
45091
|
const written = st.files.get(abs);
|
|
@@ -45045,7 +45213,7 @@ function checkCode(language, code, st, ctx, ipython = false) {
|
|
|
45045
45213
|
overwrite: verb === "overwrite"
|
|
45046
45214
|
});
|
|
45047
45215
|
if (!verdict.ok) {
|
|
45048
|
-
throw refusal({ snippet: call, line: 1 }, `${call} would ${verb} ${verdict.resolution}`, ctx);
|
|
45216
|
+
throw refusal({ snippet: call, line: 1 }, `${call} would ${verb} ${verdict.resolution}`, ctx, verdict.unresolved);
|
|
45049
45217
|
}
|
|
45050
45218
|
},
|
|
45051
45219
|
signal: (call, pid, group) => {
|
|
@@ -45116,6 +45284,7 @@ function createPaneGuard(options) {
|
|
|
45116
45284
|
ompPid: options.ompPid,
|
|
45117
45285
|
parentOf: options.parentOf ?? procParent,
|
|
45118
45286
|
steps: { count: 0 },
|
|
45287
|
+
unnameableWrite: { why: undefined },
|
|
45119
45288
|
uncertain: { depth: 0 }
|
|
45120
45289
|
});
|
|
45121
45290
|
const initial = (cwd, source) => ({
|