-
-
- /* not use inputing from terminal if usage: more > outfile */
- if(isatty(fileno(stdout))) {
- cin = fopen(CURRENT_TTY, "r");
- if (!cin)
- cin = xfopen(CONSOLE_DEV, "r");
- please_display_more_prompt = 0;
-#ifdef BB_FEATURE_USE_TERMIOS
- getTermSettings(fileno(cin), &initial_settings);
- new_settings = initial_settings;
- new_settings.c_lflag &= ~ICANON;
- new_settings.c_lflag &= ~ECHO;
-#ifndef linux
- /* Hmm, in linux c_cc[] not parsed if set ~ICANON */
- new_settings.c_cc[VMIN] = 1;
- new_settings.c_cc[VTIME] = 0;
-#endif
- setTermSettings(fileno(cin), &new_settings);
- atexit(set_tty_to_initial_mode);
- (void) signal(SIGINT, gotsig);
- (void) signal(SIGQUIT, gotsig);
- (void) signal(SIGTERM, gotsig);
+ /* Another popular pager, most, detects when stdout
+ * is not a tty and turns into cat. This makes sense. */
+ if (!isatty(STDOUT_FILENO))
+ return bb_cat(argv);
+ cin = fopen(CURRENT_TTY, "r");
+ if (!cin)
+ return bb_cat(argv);
+
+#if ENABLE_FEATURE_USE_TERMIOS
+ cin_fileno = fileno(cin);
+ getTermSettings(cin_fileno, &initial_settings);
+ new_settings = initial_settings;
+ new_settings.c_lflag &= ~ICANON;
+ new_settings.c_lflag &= ~ECHO;
+ new_settings.c_cc[VMIN] = 1;
+ new_settings.c_cc[VTIME] = 0;
+ setTermSettings(cin_fileno, &new_settings);
+ atexit(set_tty_to_initial_mode);
+ signal(SIGINT, gotsig);
+ signal(SIGQUIT, gotsig);
+ signal(SIGTERM, gotsig);