Skip to content

Commit 3a08708

Browse files
committed
fix(exec): avoid r2 inline eval collision
1 parent f420505 commit 3a08708

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ describe("exec inline eval detection", () => {
7070
expect(detectInterpreterInlineEvalArgv(["node", "script.js"])).toBeNull();
7171
expect(detectInterpreterInlineEvalArgv(["php", "-F", "filter.php"])).toBeNull();
7272
expect(detectInterpreterInlineEvalArgv(["Rscript", "script.R"])).toBeNull();
73+
expect(detectInterpreterInlineEvalArgv(["r2", "-e", "bin.cache=true", "program"])).toBeNull();
7374
expect(detectInterpreterInlineEvalArgv(["awk", "-f", "script.awk", "data.csv"])).toBeNull();
7475
expect(detectInterpreterInlineEvalArgv(["find", ".", "-name", "*.ts"])).toBeNull();
7576
expect(detectInterpreterInlineEvalArgv(["xargs", "-0"])).toBeNull();
@@ -90,6 +91,7 @@ describe("exec inline eval detection", () => {
9091
expect(isInterpreterLikeAllowlistPattern("pypy3.10")).toBe(true);
9192
expect(isInterpreterLikeAllowlistPattern("**/node")).toBe(true);
9293
expect(isInterpreterLikeAllowlistPattern("Rscript")).toBe(true);
94+
expect(isInterpreterLikeAllowlistPattern("r2")).toBe(false);
9395
expect(isInterpreterLikeAllowlistPattern("/usr/bin/awk")).toBe(true);
9496
expect(isInterpreterLikeAllowlistPattern("**/gawk")).toBe(true);
9597
expect(isInterpreterLikeAllowlistPattern("/usr/bin/mawk")).toBe(true);

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,9 @@ function stripInterpreterVersionSuffix(value: string): string {
172172

173173
function interpreterNameVariants(value: string): readonly string[] {
174174
const stripped = stripInterpreterVersionSuffix(value);
175-
return stripped === value ? [value] : [value, stripped];
175+
// Do not synthesize one-letter interpreter names: commands like r2 can use
176+
// their own eval flags and must not be mistaken for R inline execution.
177+
return stripped === value || stripped.length < 2 ? [value] : [value, stripped];
176178
}
177179

178180
function specNamesInclude(names: readonly string[], normalizedExecutable: string): boolean {

0 commit comments

Comments
 (0)