summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitchell Hashimoto <m@mitchellh.com>2025-02-13 12:27:13 -0800
committerGitHub <noreply@github.com>2025-02-13 12:27:13 -0800
commited60e0725777de2fba5f8474814f4975abb580eb (patch)
treeea7cec77cee5438f1f949f88d0b9d85fd9656fc6
parentc481bdf70461a8a4660678a819a69ac4f4934ac2 (diff)
parent1fea8028a3b303cce50dd7173ccace683cf0b877 (diff)
apprt: require envmap for exec-based termio (#5742)v1.1.1
Supercedes #5726
-rw-r--r--src/Surface.zig9
-rw-r--r--src/apprt/embedded.zig2
-rw-r--r--src/apprt/glfw.zig5
-rw-r--r--src/apprt/gtk/Surface.zig2
-rw-r--r--src/termio/Exec.zig5
5 files changed, 11 insertions, 12 deletions
diff --git a/src/Surface.zig b/src/Surface.zig
index 13436f9ff..3bee52196 100644
--- a/src/Surface.zig
+++ b/src/Surface.zig
@@ -519,17 +519,18 @@ pub fn init(
// This separate block ({}) is important because our errdefers must
// be scoped here to be valid.
{
- var env_ = rt_surface.defaultTermioEnv() catch |err| env: {
+ var env = rt_surface.defaultTermioEnv() catch |err| env: {
// If an error occurs, we don't want to block surface startup.
log.warn("error getting env map for surface err={}", .{err});
- break :env null;
+ break :env internal_os.getEnvMap(alloc) catch
+ std.process.EnvMap.init(alloc);
};
- errdefer if (env_) |*env| env.deinit();
+ errdefer env.deinit();
// Initialize our IO backend
var io_exec = try termio.Exec.init(alloc, .{
.command = command,
- .env = env_,
+ .env = env,
.shell_integration = config.@"shell-integration",
.shell_integration_features = config.@"shell-integration-features",
.working_directory = config.@"working-directory",
diff --git a/src/apprt/embedded.zig b/src/apprt/embedded.zig
index 4b9066355..ffcf7fdbe 100644
--- a/src/apprt/embedded.zig
+++ b/src/apprt/embedded.zig
@@ -1030,7 +1030,7 @@ pub const Surface = struct {
};
}
- pub fn defaultTermioEnv(self: *const Surface) !?std.process.EnvMap {
+ pub fn defaultTermioEnv(self: *const Surface) !std.process.EnvMap {
const alloc = self.app.core_app.alloc;
var env = try internal_os.getEnvMap(alloc);
errdefer env.deinit();
diff --git a/src/apprt/glfw.zig b/src/apprt/glfw.zig
index cb034cd86..39c6e058c 100644
--- a/src/apprt/glfw.zig
+++ b/src/apprt/glfw.zig
@@ -880,9 +880,8 @@ pub const Surface = struct {
};
}
- pub fn defaultTermioEnv(self: *Surface) !?std.process.EnvMap {
- _ = self;
- return null;
+ pub fn defaultTermioEnv(self: *Surface) !std.process.EnvMap {
+ return try internal_os.getEnvMap(self.app.app.alloc);
}
fn sizeCallback(window: glfw.Window, width: i32, height: i32) void {
diff --git a/src/apprt/gtk/Surface.zig b/src/apprt/gtk/Surface.zig
index c4b7717cc..6c39677d5 100644
--- a/src/apprt/gtk/Surface.zig
+++ b/src/apprt/gtk/Surface.zig
@@ -2254,7 +2254,7 @@ fn doPaste(self: *Surface, data: [:0]const u8) void {
};
}
-pub fn defaultTermioEnv(self: *Surface) !?std.process.EnvMap {
+pub fn defaultTermioEnv(self: *Surface) !std.process.EnvMap {
const alloc = self.app.core_app.alloc;
var env = try internal_os.getEnvMap(alloc);
errdefer env.deinit();
diff --git a/src/termio/Exec.zig b/src/termio/Exec.zig
index caef2229d..864f2e21c 100644
--- a/src/termio/Exec.zig
+++ b/src/termio/Exec.zig
@@ -682,7 +682,7 @@ pub const ThreadData = struct {
pub const Config = struct {
command: ?[]const u8 = null,
- env: ?EnvMap = null,
+ env: EnvMap,
shell_integration: configpkg.Config.ShellIntegration = .detect,
shell_integration_features: configpkg.Config.ShellIntegrationFeatures = .{},
working_directory: ?[]const u8 = null,
@@ -724,8 +724,7 @@ const Subprocess = struct {
// Get our env. If a default env isn't provided by the caller
// then we get it ourselves.
- var env = cfg.env orelse try internal_os.getEnvMap(alloc);
- errdefer if (cfg.env == null) env.deinit();
+ var env = cfg.env;
// If we have a resources dir then set our env var
if (cfg.resources_dir) |dir| {