mirror of
https://github.com/oven-sh/bun
synced 2026-02-13 12:29:07 +00:00
fix argv parsing on windows (#8458)
* fix argv parsing on windows * directly use zig stdlib * remove debug comments, fix double deinit * change bun.argv() to return slices, not null-terminated pointers * fix test on windows to escape file paths correctly --------- Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
This commit is contained in:
@@ -510,7 +510,7 @@ pub const RunCommand = struct {
|
||||
// if we are already an absolute path, use that
|
||||
// if the user started the application via a shebang, it's likely that the path is absolute already
|
||||
if (bun.argv()[0][0] == '/') {
|
||||
optional_bun_path.* = bun.span(bun.argv()[0]);
|
||||
optional_bun_path.* = bun.argv()[0];
|
||||
argv0 = bun.argv()[0];
|
||||
} else if (optional_bun_path.len == 0) {
|
||||
// otherwise, ask the OS for the absolute path
|
||||
@@ -1176,7 +1176,7 @@ pub const RunCommand = struct {
|
||||
|
||||
shebang = std.mem.trim(u8, shebang, " \r\n\t");
|
||||
if (strings.hasPrefixComptime(shebang, "#!")) {
|
||||
const first_arg: string = if (bun.argv().len > 0) bun.span(bun.argv()[0]) else "";
|
||||
const first_arg: string = if (bun.argv().len > 0) bun.argv()[0] else "";
|
||||
const filename = std.fs.path.basename(first_arg);
|
||||
// are we attempting to run the script with bun?
|
||||
if (!strings.contains(shebang, filename)) {
|
||||
|
||||
Reference in New Issue
Block a user