Skip to content

Commit c02a080

Browse files
authored
fix: open /dev/tty in write mode to query keyboard enhancement flags (#1026)
This check would always fail because the file was being opened as read-only.
1 parent ccf7075 commit c02a080

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/terminal/sys/unix.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,13 @@ fn query_keyboard_enhancement_flags_raw() -> io::Result<Option<KeyboardEnhanceme
230230
// ESC [ c Query primary device attributes.
231231
const QUERY: &[u8] = b"\x1B[?u\x1B[c";
232232

233-
let result = File::open("/dev/tty").and_then(|mut file| {
234-
file.write_all(QUERY)?;
235-
file.flush()
236-
});
233+
let result = File::options()
234+
.write(true)
235+
.open("/dev/tty")
236+
.and_then(|mut file| {
237+
file.write_all(QUERY)?;
238+
file.flush()
239+
});
237240
if result.is_err() {
238241
let mut stdout = io::stdout();
239242
stdout.write_all(QUERY)?;

0 commit comments

Comments
 (0)