mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-04-16 06:18:47 +02:00
Try stderr if we're asking for terminal size if stdout is not connected to a tty.
This commit is contained in:
@@ -3848,9 +3848,10 @@ integer.
|
||||
.TP
|
||||
.B columns([s_arg])
|
||||
If called with no arguments, \fBcolumns()\fR behaves as follows:
|
||||
If standard output is a TTY, returns the width of the terminal in columns.
|
||||
If standard output is not a TTY, attempts to open "/dev/tty" to obtain
|
||||
the terminal size. If this fails, returns -1.
|
||||
If either standard output or standard error is a TTY, returns the
|
||||
width of the terminal in columns. If neither standard output nor
|
||||
standard error is a TTY, attempts to open "/dev/tty" to obtain the
|
||||
terminal size. If this fails, returns -1.
|
||||
.RS
|
||||
.PP
|
||||
If called with a single string argument, \fBcolumns(str)\fR returns
|
||||
@@ -4638,9 +4639,10 @@ Returns the date as provided by the operating system. This is in contrast to
|
||||
in calendar mode, or if a date has been supplied on the command line.
|
||||
.TP
|
||||
.B rows()
|
||||
If standard output is a TTY, returns the height of the terminal in rows.
|
||||
If standard output is not a TTY, attempts to open "/dev/tty" to obtain
|
||||
the terminal size. If this fails, returns -1.
|
||||
If either standard output or standard error is a TTY, returns the
|
||||
height of the terminal in rows. If neither standard output nor
|
||||
standard error is a TTY, attempts to open "/dev/tty" to obtain the
|
||||
terminal size. If this fails, returns -1.
|
||||
.TP
|
||||
.B sgn(i_num)
|
||||
Returns \-1 if \fInum\fR is negative, 1 if \fInum\fR is positive,
|
||||
|
||||
@@ -4889,10 +4889,13 @@ rows_or_cols(func_info *info, int want_rows)
|
||||
{
|
||||
struct winsize w;
|
||||
int fd = STDOUT_FILENO;
|
||||
|
||||
int opened = 0;
|
||||
|
||||
RetVal.type = INT_TYPE;
|
||||
if (!isatty(fd)) {
|
||||
/* Try STDERR fd if STDOUT fd is not a tty */
|
||||
fd = STDERR_FILENO;
|
||||
}
|
||||
if (!isatty(fd)) {
|
||||
fd = open("/dev/tty", O_RDONLY);
|
||||
if (fd < 0) {
|
||||
|
||||
Reference in New Issue
Block a user