From 8d7b716ea77a118a1ad4e4c28a2e879fd58a2d6b Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Tue, 27 Sep 2022 11:48:42 +0200 Subject: [PATCH] startup: quit when standard input is not a TTY (after handling arguments) Not quitting would make nano hang for several seconds (which is very annoying) and then die and save an emergency file (which is useless). This fixes https://savannah.gnu.org/bugs/?63109. Bug existed chiefly since version 5.9, commit 8d1a666d, but basically existed since before version 2.0.0. --- src/nano.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/nano.c b/src/nano.c index 390cd77b..62aa2771 100644 --- a/src/nano.c +++ b/src/nano.c @@ -2512,6 +2512,10 @@ int main(int argc, char **argv) /* After handling the files on the command line, allow inserting files. */ UNSET(NOREAD_MODE); + /* Nano is a hands-on editor -- it needs a keyboard. */ + if (!isatty(STDIN_FILENO)) + die(_("Standard input is not a terminal\n")); + /* If no filenames were given, or all of them were invalid things like * directories, then open a blank buffer and allow editing. Otherwise, * switch from the last opened file to the next, that is: the first. */