Skip to content
This repository was archived by the owner on Mar 28, 2024. It is now read-only.

Commit b5bc797

Browse files
committed
Pass errret to setupterm
The setupterm(3) manual states: If errret is not null, then setupterm returns OK or ERR and stores a status value in the integer pointed to by errret. ... If errret is null, setupterm prints an error message upon finding an error and exits. Since less(1) passes NULL, it will not return on error but instead terminate the program. Checking the returned value against ERR requires including curses.h which causes a naming conflict with the existing beep function. Therefore kept the condition as is. The error message is borrowed from setupterm when errret is NULL and does currently not distinguish between error code 0 and -1.
1 parent ba28d35 commit b5bc797

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

screen.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ get_term(void)
273273
{
274274
char *t1, *t2;
275275
char *term;
276+
int errret;
276277

277278
/*
278279
* Find out what kind of terminal this is.
@@ -281,8 +282,13 @@ get_term(void)
281282
term = DEFAULT_TERM;
282283
hardcopy = 0;
283284

284-
if (setupterm(term, 1, NULL) < 0) {
285-
hardcopy = 1;
285+
if (setupterm(term, 1, &errret) < 0) {
286+
if (errret == 1) {
287+
hardcopy = 1;
288+
} else {
289+
fprintf(stderr, "%s: unknown terminal type\n", term);
290+
exit(1);
291+
}
286292
}
287293
if (hard_copy == 1)
288294
hardcopy = 1;

0 commit comments

Comments
 (0)