diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-28 15:53:29 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:15 -0300 |
| commit | b67dce15e662ae44de3286686f5a0afc147b918d (patch) | |
| tree | 9f9dac843b61501bf778bf1d07ed7ee598b26db6 /src/builtins.zig | |
| parent | 2868137e34c973a47cbf667a431e885ca23cd9a2 (diff) | |
| download | pardes-b67dce15e662ae44de3286686f5a0afc147b918d.tar.gz pardes-b67dce15e662ae44de3286686f5a0afc147b918d.zip | |
A REPL takes text only while its program has the terminal
A binding outlived its program: a command pane reused kept the REPL of the
command before, a done command pane could be bound, a document pane (a
terminal with no emulator) was accepted, and after Ctrl-D in python3 the text
went to the shell, which ran import os as ImageMagick's. A command pane's
binding now ends with its command and a done one is refused, a pane with no
emulator is refused, and an interactive terminal's REPL is live only while a
program other than its shell holds the tty (the host's tty_taken); when none
of the language's REPLs is, nothing is sent or run and the pane says so.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/builtins.zig')
| -rw-r--r-- | src/builtins.zig | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/builtins.zig b/src/builtins.zig index 751d4026..a9bc38f9 100644 --- a/src/builtins.zig +++ b/src/builtins.zig @@ -914,7 +914,10 @@ pub const Repl = struct { pub const takes_arg = true; pub fn run(c: Ctx) void { const pane = c.pane; - if (!pane.isTerminal()) return c.p.reportFailure(c.id, "Repl: only a terminal is a REPL"); + // A terminal with its emulator -- not a document pane -- and not + // a command pane whose command, the REPL it would be, is done. + if (!pane.isTerminal() or pane.terminal == null) return c.p.reportFailure(c.id, "Repl: only a terminal is a REPL"); + if (pane.command != null and pane.command_done) return c.p.reportFailure(c.id, "Repl: its command is done; a REPL is a running program"); const arg = std.mem.trim(u8, c.arg orelse "", " \t\r\n"); var buf: [320]u8 = undefined; var idbuf: [48]u8 = undefined; |
