util: when determining the right TERM for /dev/console consult /sys/class/tty/console/active
This commit is contained in:
parent
2633eb8317
commit
3030ccd79f
20
src/util.c
20
src/util.c
|
@ -3550,18 +3550,28 @@ void filter_environ(const char *prefix) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *default_term_for_tty(const char *tty) {
|
const char *default_term_for_tty(const char *tty) {
|
||||||
|
char *active = NULL;
|
||||||
|
const char *term;
|
||||||
|
|
||||||
assert(tty);
|
assert(tty);
|
||||||
|
|
||||||
if (startswith(tty, "/dev/"))
|
if (startswith(tty, "/dev/"))
|
||||||
tty += 5;
|
tty += 5;
|
||||||
|
|
||||||
if (startswith(tty, "tty") &&
|
/* Resolve where /dev/console is pointing when determining
|
||||||
tty[3] >= '0' && tty[3] <= '9')
|
* TERM */
|
||||||
return "TERM=linux";
|
if (streq(tty, "console"))
|
||||||
|
if (read_one_line_file("/sys/class/tty/console/active", &active) >= 0) {
|
||||||
|
truncate_nl(active);
|
||||||
|
tty = active;
|
||||||
|
}
|
||||||
|
|
||||||
/* FIXME: Proper handling of /dev/console would be cool */
|
term = (startswith(tty, "tty") &&
|
||||||
|
tty[3] >= '0' && tty[3] <= '9') ? "TERM=linux" : "TERM=vt100";
|
||||||
|
|
||||||
return "TERM=vt100";
|
free(active);
|
||||||
|
|
||||||
|
return term;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool running_in_vm(void) {
|
bool running_in_vm(void) {
|
||||||
|
|
Loading…
Reference in a new issue