Skip to content

Commit

Permalink
fix(shell/interpreter): don't always pass absolute path to spawn
Browse files Browse the repository at this point in the history
  • Loading branch information
SunsetTechuila committed May 24, 2024
1 parent 6c9b3de commit 1c05351
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/shell/interpreter.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4621,12 +4621,15 @@ pub const Interpreter = struct {
}

var path_buf: bun.PathBuffer = undefined;
const resolved = which(&path_buf, spawn_args.PATH, spawn_args.cwd, first_arg_real) orelse blk: {
if (bun.strings.eqlComptime(first_arg_real, "bun") or bun.strings.eqlComptime(first_arg_real, "bun-debug")) blk2: {
break :blk bun.selfExePath() catch break :blk2;
}
this.writeFailingError("bun: command not found: {s}\n", .{first_arg});
return;
const resolved = blk: {
const absolute_path = which(&path_buf, spawn_args.PATH, spawn_args.cwd, first_arg_real) orelse blk2: {
if (bun.strings.eqlComptime(first_arg_real, "bun") or bun.strings.eqlComptime(first_arg_real, "bun-debug")) blk3: {
break :blk2 bun.selfExePath() catch break :blk3;
}
this.writeFailingError("bun: command not found: {s}\n", .{first_arg});
return;
};
break :blk std.fs.path.basename(absolute_path);
};

const duped = arena_allocator.dupeZ(u8, bun.span(resolved)) catch bun.outOfMemory();
Expand Down
5 changes: 5 additions & 0 deletions test/js/bun/shell/bunshell.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,11 @@ ${temp_dir}`
.stdout("complex > command; $(execute)\n")
.runAsTest("complex_mixed_special_chars");
});

test("spaces in path and args", async () => {
const fields = "name scripts";
expect(async () => { await $`npm pkg get ${fields}` }).not.toThrow();
});
});

describe("deno_task", () => {
Expand Down

0 comments on commit 1c05351

Please sign in to comment.