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.zig46
1 files changed, 22 insertions, 24 deletions
diff --git a/src/host_io.zig b/src/host_io.zig
index b7e58506..86df754b 100644
--- a/src/host_io.zig
+++ b/src/host_io.zig
@@ -1841,8 +1841,8 @@ pub const ChildEnv = struct {
/// Which pager a child is given where the user's environment names none:
/// a command pane's one-shot shell `cat` (its output is a pane already),
- /// a terminal's shell `pardes -` (a +Pager pane) unless `Pager off`.
- pub const Paging = enum { command, terminal, terminal_off };
+ /// a terminal's shell `pardes -` (a +Pager pane).
+ pub const Paging = enum { command, terminal };
pub fn build(slots: *Slots, paging: Paging) ?[*:null]const ?[*:0]const u8 {
var n: usize = 0;
@@ -1865,7 +1865,6 @@ pub const ChildEnv = struct {
const defaults: []const [*:0]const u8 = switch (paging) {
.command => &cat_pagers,
.terminal => pardesPagers(),
- .terminal_off => &.{},
};
for (defaults) |default| {
const set = for (libc.environ[0..i]) |entry| {
@@ -1962,28 +1961,26 @@ test "the child environment replaces the launcher's terminal identity exactly on
var slots: ChildEnv.Slots = undefined;
// Where the user named no pager: a terminal's shell pages into a
- // +Pager pane (`pardes -`), or, Pager off, as the environment says; a
- // command pane's through cat. A pager the user named is kept.
- for ([_]ChildEnv.Paging{ .terminal, .terminal_off }) |paging| {
- var shell_slots: ChildEnv.Slots = undefined;
- const shell_envp = ChildEnv.build(&shell_slots, paging) orelse return error.EnvironmentTooLarge;
- var said: usize = 0;
- var systemd: usize = 0;
- var j: usize = 0;
- while (shell_envp[j]) |entry| : (j += 1) {
- const line = std.mem.span(entry);
- if (std.c.getenv("SYSTEMD_PAGER") == null and std.mem.startsWith(u8, line, "SYSTEMD_PAGER=")) systemd += 1;
- if (std.c.getenv("SYSTEMD_PAGERSECURE") == null and std.mem.eql(u8, line, "SYSTEMD_PAGERSECURE=0")) systemd += 1;
- if (std.mem.startsWith(u8, line, "PAGER=") and std.c.getenv("PAGER") == null) {
- try std.testing.expect(paging == .terminal and std.mem.endsWith(u8, line, " -"));
- said += 1;
- }
+ // +Pager pane (`pardes -`); a command pane's through cat. A pager the
+ // user named is kept.
+ var shell_slots: ChildEnv.Slots = undefined;
+ const shell_envp = ChildEnv.build(&shell_slots, .terminal) orelse return error.EnvironmentTooLarge;
+ var said: usize = 0;
+ var systemd: usize = 0;
+ var j: usize = 0;
+ while (shell_envp[j]) |entry| : (j += 1) {
+ const line = std.mem.span(entry);
+ if (std.c.getenv("SYSTEMD_PAGER") == null and std.mem.startsWith(u8, line, "SYSTEMD_PAGER=")) systemd += 1;
+ if (std.c.getenv("SYSTEMD_PAGERSECURE") == null and std.mem.eql(u8, line, "SYSTEMD_PAGERSECURE=0")) systemd += 1;
+ if (std.mem.startsWith(u8, line, "PAGER=") and std.c.getenv("PAGER") == null) {
+ try std.testing.expect(std.mem.endsWith(u8, line, " -"));
+ said += 1;
}
- if (std.c.getenv("PAGER") == null) try std.testing.expectEqual(@as(usize, if (paging == .terminal) 1 else 0), said);
- // systemd's pager and its secure mode off, with ours only.
- if (std.c.getenv("SYSTEMD_PAGER") == null and std.c.getenv("SYSTEMD_PAGERSECURE") == null)
- try std.testing.expectEqual(@as(usize, if (paging == .terminal) 2 else 0), systemd);
}
+ if (std.c.getenv("PAGER") == null) try std.testing.expectEqual(@as(usize, 1), said);
+ // systemd's pager and its secure mode off, with ours only.
+ if (std.c.getenv("SYSTEMD_PAGER") == null and std.c.getenv("SYSTEMD_PAGERSECURE") == null)
+ try std.testing.expectEqual(@as(usize, 2), systemd);
const envp = ChildEnv.build(&slots, .command) orelse return error.EnvironmentTooLarge;
var terms: usize = 0;
var colorterms: usize = 0;
@@ -2126,7 +2123,8 @@ pub fn forkShell(
const pages = if (core) |c| if (c.panes[pane]) |pn| pn.command_pages else false else false;
const paging: ChildEnv.Paging = if (one_line != null and !pages)
.command
- else if (core) |c| (if (c.settings.pager == .off) .terminal_off else .terminal) else .terminal;
+ else
+ .terminal;
const envp = ChildEnv.build(&env_slots, paging);
const ws = ptyWinsize(core, cols, rows);
// The child says here why it could not become the shell (its chdir or