summaryrefslogtreecommitdiff
path: root/src/host_io.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/host_io.zig')
-rw-r--r--src/host_io.zig14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/host_io.zig b/src/host_io.zig
index ee503061..7314affc 100644
--- a/src/host_io.zig
+++ b/src/host_io.zig
@@ -1469,6 +1469,20 @@ test "the child environment replaces the launcher's terminal identity exactly on
extern "c" fn unsetenv(name: [*:0]const u8) c_int;
+/// The environment a pane's command is given (exportPaneEnv, `$winid`,
+/// ChildEnv), as `NAME=value` lines in `arena`, for a command that is not a
+/// pane's: an Edit's filters, run from pane `serial`.
+pub fn commandEnv(arena: std.mem.Allocator, serial: u32, adopts: bool) ![]const []const u8 {
+ ninep_io.exportSessionEnv(serial, adopts);
+ exportWinid(serial);
+ var slots: ChildEnv.Slots = undefined;
+ const envp = ChildEnv.build(&slots, .command) orelse return error.EnvironmentTooLarge;
+ var out: std.ArrayList([]const u8) = .empty;
+ var i: usize = 0;
+ while (envp[i]) |entry| : (i += 1) try out.append(arena, try arena.dupe(u8, std.mem.span(entry)));
+ return out.items;
+}
+
fn exportWinid(serial: u32) void {
var buf: [16]u8 = undefined;
if (serial != 0) if (std.fmt.bufPrintSentinel(&buf, "{d}", .{serial}, 0)) |text| {