From e3aa71c38cbecb24e6333411ee19814796a5b1d0 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 15 Nov 2010 23:49:02 +0100 Subject: exec: automatically determine right TERM= setting based on tty name --- src/util.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/util.c') diff --git a/src/util.c b/src/util.c index 7f9f2b36a2..fb2eea341c 100644 --- a/src/util.c +++ b/src/util.c @@ -3470,6 +3470,21 @@ void filter_environ(const char *prefix) { environ[j] = NULL; } +const char *default_term_for_tty(const char *tty) { + assert(tty); + + if (startswith(tty, "/dev/")) + tty += 5; + + if (startswith(tty, "tty") && + tty[3] >= '0' && tty[3] <= '9') + return "TERM=linux"; + + /* FIXME: Proper handling of /dev/console would be cool */ + + return "TERM=vt100-nav"; +} + static const char *const ioprio_class_table[] = { [IOPRIO_CLASS_NONE] = "none", [IOPRIO_CLASS_RT] = "realtime", -- cgit v1.2.3-54-g00ecf