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.
This commit is contained in:
Benno Schulenberg 2022-09-27 11:48:42 +02:00
parent 034af70a65
commit 8d7b716ea7

View File

@ -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. */