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:
Georgijs
2024-01-24 20:54:01 -08:00
committed by GitHub
parent 0bf8a25d50
commit 80bd3254cc
12 changed files with 49 additions and 59 deletions

View File

@@ -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)) {