From 19a833c94e2066750d1ca3cca7ec538ed40b83ed Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Wed, 13 Mar 2019 19:12:07 +0100 Subject: [PATCH] startup: check again for a Linux console after reading all files When there is a dash among the files on the command line, nano will read data from standard input, which means that the latter is not connected to a terminal and thus cannot be recognized as a Linux VT until nano has finished reading the input and has reconnected the input source to the terminal. The first probe for a Linux VT is kept in place for now, so that nano can stop when there are errors in an rcfile while running on a VT. (This stopping will not work when data is read from standard input, of course, but that is a smaller fish.) This fixes https://savannah.gnu.org/bugs/?55912. Reported-by: Enrico Mioso Bug existed since the recognition of modified cursor keys on a Linux console was introduced, in version 2.6.3, commit 290d278f. --- src/nano.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/nano.c b/src/nano.c index 7c529372..ed5ee18f 100644 --- a/src/nano.c +++ b/src/nano.c @@ -2685,6 +2685,11 @@ int main(int argc, char **argv) } #endif +#ifdef __linux__ + /* Check again whether we're running on a Linux console. */ + on_a_vt = (ioctl(0, VT_GETSTATE, &dummy) == 0); +#endif + #ifdef DEBUG fprintf(stderr, "Main: show title bar, and enter main loop\n"); #endif