summaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig31
1 files changed, 9 insertions, 22 deletions
diff --git a/src/main.zig b/src/main.zig
index 9abc04bf..050cee60 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -112,16 +112,6 @@ const nested_text =
\\
;
-/// $PARDES_PID named a live editor, so this shell IS inside one, but the Look
-/// never got there. Saying so beats quietly opening the second editor that
-/// $PARDES_PID exists to prevent.
-const unreachable_text =
- \\pardes: this shell is inside pardes, but that session did not take the
- \\file. Check that it is still running, or pass --nested to start a second
- \\editor in here anyway.
- \\
-;
-
// The browser runtime calls a C main (exported below); everything else keeps
// the std.process.Init entry.
pub const main = if (is_emscripten) webMain else nativeMain;
@@ -304,10 +294,13 @@ fn nativeMain(init: std.process.Init) !void {
if (serial == 0) break :reaching null;
break :reaching .{ .dial = dial, .serial = serial };
};
- const parent = found orelse {
- try std.Io.File.stderr().writeStreamingAll(init.io, unreachable_text);
- std.process.exit(1);
- };
+ // A pid we cannot reach is a session that is not answering: the shell
+ // says it is inside one, but there is nothing there to take the file.
+ // Starting an ordinary editor is what this did before the pid existed
+ // and is the more useful of the two answers -- refusing to start would
+ // leave a stale environment variable able to lock someone out of their
+ // own editor.
+ const parent = found orelse break :forwarding;
// The pane's `look` file: one line, and the line is the clicked text
// itself, which is what a right click in that pane would have been.
var look_buf: [64]u8 = undefined;
@@ -315,10 +308,7 @@ fn nativeMain(init: std.process.Init) !void {
const word = positional orelse {
var tag_buf: [64]u8 = undefined;
const tag = try std.fmt.bufPrint(&tag_buf, "/pane/{d}/tag", .{parent.serial});
- const contents = ninep_io.Client.read(arena, parent.dial, tag, tag) catch {
- try std.Io.File.stderr().writeStreamingAll(init.io, unreachable_text);
- std.process.exit(1);
- };
+ const contents = ninep_io.Client.read(arena, parent.dial, tag, tag) catch break :forwarding;
arena.free(contents);
try std.Io.File.stderr().writeStreamingAll(init.io, nested_text);
std.process.exit(1);
@@ -332,10 +322,7 @@ fn nativeMain(init: std.process.Init) !void {
const path = if (pardes.filesystem.isVirtual(target.path)) target.path else (pardes.filesystem.resolveOs(target.path, &realbuf) orelse break :forwarding).path;
var command_buf: [8192]u8 = undefined;
const command = std.fmt.bufPrint(&command_buf, "{s}{s}\n", .{ path, word[target.path.len..] }) catch break :forwarding;
- ninep_io.Client.write(arena, parent.dial, look, command) catch {
- try std.Io.File.stderr().writeStreamingAll(init.io, unreachable_text);
- std.process.exit(1);
- };
+ ninep_io.Client.write(arena, parent.dial, look, command) catch break :forwarding;
return;
}
if (positional) |a| {