nnn

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 25fab4cb2ef20140d2b2ac484e9ef6aa8171390a
parent 3a98dfb0b0008e45ff4d51cc30c1b749bb162a41
Author: Arun Prakash Jana <engineerarun@gmail.com>
Date:   Fri, 23 Jul 2021 23:46:20 +0530

Open controlling terminal for input when run in a script

Diffstat:
Msrc/nnn.c | 8+++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/nnn.c b/src/nnn.c @@ -8225,7 +8225,13 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; /* We return to tty */ - dup2(STDOUT_FILENO, STDIN_FILENO); + if (!isatty(STDOUT_FILENO)) { + fd = open(ctermid(NULL), O_RDWR, 0400); + dup2(fd, STDOUT_FILENO); + dup2(fd, STDIN_FILENO); + close(fd); + } else + dup2(STDOUT_FILENO, STDIN_FILENO); if (session) session = NULL;