diff options
| -rw-r--r-- | src/exec.zig | 4 | ||||
| -rw-r--r-- | src/ninep/addr.zig | 5 | ||||
| -rw-r--r-- | src/ninep/ctl.zig | 1 |
3 files changed, 7 insertions, 3 deletions
diff --git a/src/exec.zig b/src/exec.zig index 953ae0f3..d7a88ecc 100644 --- a/src/exec.zig +++ b/src/exec.zig @@ -805,7 +805,9 @@ pub fn applySettingBuiltin(p: *Pardes, setting: config.Runtime.Setting, arg: ?[] if (want.len == 0) { p.settings.shell.requested.clear(); p.settings.shell.pending = true; - return; + if (!p.announce) return; + var said: [320]u8 = undefined; + return p.setMessage(p.active, std.fmt.bufPrint(&said, "Shell: the default again, {s} ($SHELL, else /bin/sh)", .{config.defaultShell()}) catch "Shell: the default again"); } if (comptime pardes.hosted) { var why: [320]u8 = undefined; diff --git a/src/ninep/addr.zig b/src/ninep/addr.zig index 15f23a55..989571a5 100644 --- a/src/ninep/addr.zig +++ b/src/ninep/addr.zig @@ -13,6 +13,7 @@ fn clip(n: usize) u32 { pub const e_no_match = "no match for regexp"; pub const e_range = "address out of range"; +pub const e_col_zero = "address out of range: a column counts from 1"; pub const e_regexp = "bad regular expression"; /// Not "took too long": 9ns reads errors by their words, and that would be /// ENAMETOOLONG. @@ -104,7 +105,7 @@ pub const Addr = struct { col = @min(col * 10 + (a.expr[a.i] - '0'), std.math.maxInt(u32)); const lines = modal.cursorLineCount(a.text); if (n == 0 or n > lines or col == 0) { - a.err = e_range; + a.err = if (col == 0) e_col_zero else e_range; return null; } const q = clip(modal.runeOffsetAt(a.text, .{ .row = @intCast(n - 1), .col = @intCast(col - 1) })); @@ -483,7 +484,7 @@ test "the address language, form by form" { for ([_][2][]const u8{ .{ "zzz", e_syntax }, .{ "/nomatch/", e_no_match }, .{ "99", e_range }, .{ "#999", e_range }, .{ "/a[/", e_regexp }, .{ "/(a/", e_regexp }, - .{ "/*a/", e_regexp }, .{ "99:1", e_range }, .{ "2:0", e_range }, + .{ "/*a/", e_regexp }, .{ "99:1", e_range }, .{ "2:0", e_col_zero }, }) |c| { _ = th.wr(p, addr, "#0"); try testing.expectEqualStrings(c[1], th.wr(p, addr, c[0]).reply.ename); diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index 424245eb..fac1e5eb 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -1473,6 +1473,7 @@ test "Shell refuses a path that is no executable, and bare it goes back to the d try testing.expectEqualStrings("/bin/sh", p.settings.shell.requested.get()); try testing.expectEqual(Status.ok, wr(p, root_ctl, "Shell\n").reply.status); try testing.expectEqualStrings("", p.settings.shell.requested.get()); + try testing.expect(th.logHas(p, "Shell: the default again, ")); var want: [300]u8 = undefined; try testing.expect(std.mem.indexOf(u8, rd(p, root_ctl, 0, 8192).bytes, try std.fmt.bufPrint(&want, "Shell {s}\n", .{config.defaultShell()})) != null); } |
