Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
radicle-term: Inline `termion::get_tty` for Unix
Lorenz Leutgeb committed 10 months ago
commit ee8ffcc79961d34a88ca0abc2268a23959e2fe15
parent ec47566cb0af0fab62e00a65fd1f5aff7a867e79
1 file changed +10 -2
modified crates/radicle-term/src/editor.rs
@@ -133,11 +133,19 @@ impl Editor {
        let stderr = unsafe { libc::dup(stderr) };
        let stdin = if io::stdin().is_terminal() {
            process::Stdio::inherit()
-
        } else {
-
            let tty = termion::get_tty()?;
+
        } else if cfg!(unix) {
            // If standard input is not a terminal device, the editor won't work correctly.
            // In that case, we use the terminal device, eg. `/dev/tty` as standard input.
+
            let tty = fs::OpenOptions::new()
+
                .read(true)
+
                .write(true)
+
                .open("/dev/tty")?;
            process::Stdio::from(tty)
+
        } else {
+
            return Err(io::Error::new(
+
                io::ErrorKind::Unsupported,
+
                format!("standard input is not a terminal, refusing to execute editor {cmd:?}"),
+
            ));
        };

        process::Command::new(program)