diff --git a/src/files.c b/src/files.c index e1192340..30ef8d09 100644 --- a/src/files.c +++ b/src/files.c @@ -827,7 +827,7 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable) /* When reading from stdin, restore the terminal and reenter curses mode. */ if (isendwin()) { - if (!isatty(0)) + if (!isatty(STANDARD_INPUT)) reconnect_and_store_state(); terminal_init(); doupdate(); diff --git a/src/nano.c b/src/nano.c index 6bbf8d57..d6d35bd6 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1078,7 +1078,7 @@ void reconnect_and_store_state(void) if (thetty < 1) die(_("Could not reconnect stdin to keyboard\n")); - dup2(thetty, 0); + dup2(thetty, STANDARD_INPUT); close(thetty); /* If input was not cut short, store the current state of the terminal. */ @@ -1096,7 +1096,7 @@ bool scoop_stdin(void) tcsetattr(0, TCSANOW, &oldterm); /* When input comes from a terminal, show a helpful message. */ - if (isatty(0)) + if (isatty(STANDARD_INPUT)) fprintf(stderr, _("Reading data from keyboard; " "type ^D or ^D^D to finish.\n")); diff --git a/src/nano.h b/src/nano.h index 4522701f..9e144620 100644 --- a/src/nano.h +++ b/src/nano.h @@ -146,6 +146,8 @@ #define BAD_COLOR -2 #endif +#define STANDARD_INPUT 0 + /* Enumeration types. */ typedef enum { NIX_FILE, DOS_FILE, MAC_FILE