Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zig run: Empty string arguments aren't forwarded on Windows #19236

Closed
castholm opened this issue Mar 10, 2024 · 1 comment
Closed

zig run: Empty string arguments aren't forwarded on Windows #19236

castholm opened this issue Mar 10, 2024 · 1 comment
Labels
bug Observed behavior contradicts documented or intended behavior

Comments

@castholm
Copy link
Contributor

castholm commented Mar 10, 2024

Zig Version

0.12.0-dev.3161+377ecc6af

Steps to Reproduce and Observed Behavior

// repro.zig
const std = @import("std");
pub fn main() !void {
    var arena_state = std.heap.ArenaAllocator.init(std.heap.page_allocator);
    defer arena_state.deinit();
    const arena = arena_state.allocator();
    const args = try std.process.argsAlloc(arena);
    for (args, 0..) |arg, i| std.debug.print("args[{}]: \"{s}\"\n", .{ i, arg });
}
zig run .\repro.zig -- hello "" world
args[0]: "C:\...\repro.exe"
args[1]: "hello"
args[2]: "world"

Running the executable directly works.

C:\...\repro.exe hello "" world
args[0]: "C:\...\repro.exe"
args[1]: "hello"
args[2]: ""
args[3]: "world"

Invoking the executable directly from Zig using std.process.Child.init(&.{ repro_path, "hello", "", "world" }, arena) also works, so it doesn't appear to be a bug in the argv-to-command line serialization logic.

Appears to be a Windows-only bug, people on Discord helped me verify that it works correctly on Linux and macOS.

zig build run (where run is a Step.Run) is also affected.

Expected Behavior

The empty string is passed to the spawned process.

@castholm castholm added the bug Observed behavior contradicts documented or intended behavior label Mar 10, 2024
@castholm
Copy link
Contributor Author

False alarm; I was using an older build of zigup from before command-line serialization was fixed by #18309
On Windows zigup creates a proxy exe that forwards invocations to the true zig.exe and it hasn't caught up with recent developments yet. Invoking the real zig.exe itself works as expected.

@castholm castholm closed this as not planned Won't fix, can't repro, duplicate, stale Mar 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior
Projects
None yet
Development

No branches or pull requests

1 participant