Skip to content

Commit 7e5a682

Browse files
committed
fix(exec): cover legacy gawk source abbreviation
1 parent c0a4d51 commit 7e5a682

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

‎src/infra/command-analysis/inline-eval.test.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,10 @@ describe("exec inline eval detection", () => {
218218
argv: ["gawk", "-f", "library.awk", '--source=BEGIN{system("id")}', "/dev/null"],
219219
expected: "gawk --source",
220220
},
221+
{
222+
argv: ["gawk", "-f", "library.awk", '--s=BEGIN{system("id")}', "/dev/null"],
223+
expected: "gawk --source",
224+
},
221225
{
222226
argv: ["gawk", "-f", "library.awk", '--so=BEGIN{system("id")}', "/dev/null"],
223227
expected: "gawk --source",
@@ -301,7 +305,6 @@ describe("exec inline eval detection", () => {
301305
expect(detectInterpreterInlineEvalArgv(["expect", "script.exp"])).toBeNull();
302306
expect(detectInterpreterInlineEvalArgv(["r2", "-e", "bin.cache=true", "program"])).toBeNull();
303307
expect(detectInterpreterInlineEvalArgv(["awk", "-f", "script.awk", "data.csv"])).toBeNull();
304-
expect(detectInterpreterInlineEvalArgv(["gawk", "--s=BEGIN{print 1}"])).toBeNull();
305308
expect(detectInterpreterInlineEvalArgv(["find", ".", "-name", "*.ts"])).toBeNull();
306309
expect(detectInterpreterInlineEvalArgv(["xargs", "-0"])).toBeNull();
307310
expect(detectInterpreterInlineEvalArgv(["make", "test"])).toBeNull();

‎src/infra/command-analysis/inline-eval.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ const FLAG_INTERPRETER_INLINE_EVAL_SPECS: readonly InterpreterFlagSpec[] = [
9191
{
9292
names: ["awk", "gawk", "mawk", "nawk"],
9393
exactFlags: new Set(["-e", "--source"]),
94-
// GNU long options accept unique abbreviations; "--s" remains ambiguous
95-
// with "--sandbox", while "--so" identifies "--source".
96-
abbreviatedFlags: [{ label: "--source", full: "--source", min: "--so" }],
94+
// gawk before 4.0 accepted "--s" for "--source"; modern releases reject it
95+
// as ambiguous with "--sandbox", so the older executable case sets the floor.
96+
abbreviatedFlags: [{ label: "--source", full: "--source", min: "--s" }],
9797
prefixFlags: [{ label: "--source", prefix: "--source=" }],
9898
},
9999
{

‎src/node-host/invoke-system-run.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3375,7 +3375,7 @@ describe("handleSystemRunInvoke mac app exec host routing", () => {
33753375

33763376
const abbreviated = await runSystemInvoke({
33773377
preferMacAppExecHost: false,
3378-
command: [executablePath, '--so=BEGIN{system("id")}', "/dev/null"],
3378+
command: [executablePath, '--s=BEGIN{system("id")}', "/dev/null"],
33793379
cwd: tempDir,
33803380
security: "allowlist",
33813381
ask: "on-miss",

0 commit comments

Comments
 (0)