authorgravatar for semarie@online.frSébastien Marie <semarie@online.fr> 2020-10-11 12:23:52+00:00
committergravatar for semarie@online.frSébastien Marie <semarie@online.fr> 2020-10-11 12:23:52+00:00
loga6dc2b7fcc2e1e73130eb0e762cac4ab884d20c2
tree6c2ab1a03cbb3e971d96c961b870931729c9a73a
parent4c4211ea8e7c553c78ed25f52b60000f1f066503

openbsd: selfExePath adjustements


1 files changed, 5 insertions(+), 6 deletions(-)

lib/std/fs.zig+5-6
......@@ -2244,19 +2244,18 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 {
22442244 return error.NameTooLong;
22452245 mem.copy(u8, out_buffer, real_path);
22462246 return out_buffer[0..real_path.len];
2247
2248 } else if (os.argv[0][0] != '\x00') {
2247 } else if (argv0.len != 0) {
22492248 // argv[0] is not empty (and not a path): search it inside PATH
2250 const paths = std.os.getenv("PATH") orelse "";
2251 var path_it = mem.split(paths, ":");
2249 const PATH = std.os.getenv("PATH") orelse "";
2250 var path_it = mem.tokenize(PATH, &[_]u8{path.delimiter});
22522251 while (path_it.next()) |a_path| {
2253 var resolved_path_buf: [MAX_PATH_BYTES:0]u8 = undefined;
2252 var resolved_path_buf: [MAX_PATH_BYTES-1:0]u8 = undefined;
22542253 const resolved_path = std.fmt.bufPrint(&resolved_path_buf, "{}/{}\x00", .{
22552254 a_path,
22562255 os.argv[0],
22572256 }) catch "";
22582257
2259 var real_path_buf: [MAX_PATH_BYTES:0]u8 = undefined;
2258 var real_path_buf: [MAX_PATH_BYTES]u8 = undefined;
22602259 if (os.realpathZ(&resolved_path_buf, &real_path_buf) catch null) |real_path| {
22612260 // found a file, and hope it is the right file
22622261 if (real_path.len > out_buffer.len)