more: fix -e in non-interactive mode
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
08273c672b
commit
2ae8b75754
|
@ -66,7 +66,7 @@ Prompt with "[Press space to continue, 'q' to quit.]", and display "[Press 'h' f
|
||||||
Do not pause after any line containing a *^L* (form feed).
|
Do not pause after any line containing a *^L* (form feed).
|
||||||
|
|
||||||
*-e*, *--exit-on-eof*::
|
*-e*, *--exit-on-eof*::
|
||||||
Exit on End-Of-File.
|
Exit on End-Of-File, enabled by default if not executed on terminal.
|
||||||
|
|
||||||
*-f*, *--no-pause*::
|
*-f*, *--no-pause*::
|
||||||
Count logical lines, rather than screen lines (i.e., long lines are not folded).
|
Count logical lines, rather than screen lines (i.e., long lines are not folded).
|
||||||
|
|
|
@ -219,6 +219,7 @@ struct more_control {
|
||||||
no_scroll:1, /* do not scroll, clear the screen and then display text */
|
no_scroll:1, /* do not scroll, clear the screen and then display text */
|
||||||
no_tty_in:1, /* is input in interactive mode */
|
no_tty_in:1, /* is input in interactive mode */
|
||||||
no_tty_out:1, /* is output in interactive mode */
|
no_tty_out:1, /* is output in interactive mode */
|
||||||
|
no_tty_err:1, /* is stderr terminal */
|
||||||
print_banner:1, /* print file name banner */
|
print_banner:1, /* print file name banner */
|
||||||
reading_num:1, /* are we reading leading_number */
|
reading_num:1, /* are we reading leading_number */
|
||||||
report_errors:1, /* is an error reported */
|
report_errors:1, /* is an error reported */
|
||||||
|
@ -1958,8 +1959,9 @@ static void initterm(struct more_control *ctl)
|
||||||
ctl->no_tty_out = tcgetattr(STDOUT_FILENO, &ctl->output_tty);
|
ctl->no_tty_out = tcgetattr(STDOUT_FILENO, &ctl->output_tty);
|
||||||
#endif
|
#endif
|
||||||
ctl->no_tty_in = tcgetattr(STDIN_FILENO, &ctl->output_tty);
|
ctl->no_tty_in = tcgetattr(STDIN_FILENO, &ctl->output_tty);
|
||||||
tcgetattr(STDERR_FILENO, &ctl->output_tty);
|
ctl->no_tty_err = tcgetattr(STDERR_FILENO, &ctl->output_tty);
|
||||||
ctl->original_tty = ctl->output_tty;
|
ctl->original_tty = ctl->output_tty;
|
||||||
|
|
||||||
ctl->hard_tabs = (ctl->output_tty.c_oflag & TABDLY) != TAB3;
|
ctl->hard_tabs = (ctl->output_tty.c_oflag & TABDLY) != TAB3;
|
||||||
if (ctl->no_tty_out)
|
if (ctl->no_tty_out)
|
||||||
return;
|
return;
|
||||||
|
@ -2058,6 +2060,10 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
initterm(&ctl);
|
initterm(&ctl);
|
||||||
|
|
||||||
|
if (ctl.no_tty_err)
|
||||||
|
/* exit when we cannot read user's input */
|
||||||
|
ctl.exit_on_eof = 1;
|
||||||
|
|
||||||
#ifdef HAVE_MAGIC
|
#ifdef HAVE_MAGIC
|
||||||
ctl.magic = magic_open(MAGIC_MIME_ENCODING | MAGIC_SYMLINK);
|
ctl.magic = magic_open(MAGIC_MIME_ENCODING | MAGIC_SYMLINK);
|
||||||
magic_load(ctl.magic, NULL);
|
magic_load(ctl.magic, NULL);
|
||||||
|
|
Loading…
Reference in New Issue