mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
This is necessary in two cases: * On POSIX, the exe path (`argv[0]`) must contain a path separator * Some programs might treat a file named e.g. `-foo` as a flag, which can be avoided by passing `./-foo` Rather than detecting these two cases, just always include the prefix; there's no harm in it. Also, if the cwd is specified, include it in the manifest. If the user has set the cwd of a Run step, it is clearly because this affects the behavior of the executable somehow, so that cwd path should be a part of the step's manifest. Resolves: #24216
14 lines
401 B
Zig
14 lines
401 B
Zig
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);
|
|
|
|
if (args.len != 2) return error.BadUsage;
|
|
const path = args[1];
|
|
|
|
std.fs.cwd().access(path, .{}) catch return error.AccessFailed;
|
|
}
|
|
|
|
const std = @import("std");
|