Open kjloveless opened 2 months ago
const std = @import("std");
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
const allocator = gpa.allocator();
const env = try std.process.getEnvMap(allocator);
var it = env.hash_map.iterator();
while (it.next()) |entry| {
const key = entry.key_ptr.*;
const value = entry.value_ptr.*;
std.debug.print("{s}: {s}\n", .{key, value});
}
std.debug.print("{s}", .{env.get("NAME").?});
}
Was messing around and came with the preceding snippet, should be useful in argument expansion.
Mistakenly thought echo was a native program we could rely on...
Noticed that it functions like this currently:
Found this stackoverflow post when looking into this problem
Furthermore I found this function in Zig std
Looking at some other shells (bash & fish) we may want to expand environment variables before executing the utility.