summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKarel Zak2018-05-14 12:51:50 +0200
committerKarel Zak2018-05-14 12:51:50 +0200
commit4d9b788d64c8f9de8cb28e541d53676f26386f3a (patch)
treee9788854cb6ff305b0a80657542fe790f763b299 /lib
parentdocs: add hint about script (diff)
downloadkernel-qcow2-util-linux-4d9b788d64c8f9de8cb28e541d53676f26386f3a.tar.gz
kernel-qcow2-util-linux-4d9b788d64c8f9de8cb28e541d53676f26386f3a.tar.xz
kernel-qcow2-util-linux-4d9b788d64c8f9de8cb28e541d53676f26386f3a.zip
script: add more info to script header
This patch introduces [...] to store extra information about terminal to the typescript header. For example: Script started on 2018-05-14 12:52:32+02:00 [TERM="xterm-256color" TTY="/dev/pts/3" COLS="190" LINES="53"] or Script started on 2018-05-14 12:54:01+02:00 [<not executed on terminal>] if stdout is not terminal. Addresses: https://github.com/karelzak/util-linux/issues/583 Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/ttyutils.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/ttyutils.c b/lib/ttyutils.c
index 6a1e0e0f3..00a7903ca 100644
--- a/lib/ttyutils.c
+++ b/lib/ttyutils.c
@@ -113,6 +113,13 @@ int get_terminal_name(const char **path,
return 0;
}
+int get_terminal_type(const char **type)
+{
+ *type = getenv("TERM");
+ if (*type)
+ return -EINVAL;
+ return 0;
+}
#ifdef TEST_PROGRAM_TTYUTILS
# include <stdlib.h>