From d689166b11c5ee89a754d46cc1ce09f27bde0a31 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Wed, 17 Feb 2016 12:53:20 +0100 Subject: agetty: support \e{name} for issue file Signed-off-by: Karel Zak --- term-utils/agetty.8 | 9 +++++++-- term-utils/agetty.c | 12 +++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) (limited to 'term-utils') diff --git a/term-utils/agetty.8 b/term-utils/agetty.8 index bb2feea39..02bf21925 100644 --- a/term-utils/agetty.8 +++ b/term-utils/agetty.8 @@ -333,8 +333,13 @@ Insert the baudrate of the current line. d Insert the current date. .TP -e -Insert \\033 to handle esc sequences, for example "\\e[31m RED \\e[0m" prints red text. +e or e{name} +Translate the human readable \fIname\fP to esc sequence and insert the sequence +(e.g. \\e{red}Alert text.\\e{reset}). If the name argument is not specified then +insert \\033. The currently supported names are: black, blink, blue, bold, brown, cyan, +darkgray, gray, green, halfbright, lightblue, lightcyan, lightgray, lightgreen, +lightmagenta, lightred, magenta, red, reset, reverse, and yellow. All unknown +names are silently ignored. .TP s Insert the system name, the name of the operating system. Same as `uname \-s'. diff --git a/term-utils/agetty.c b/term-utils/agetty.c index d55b2e62a..d88cdc1c0 100644 --- a/term-utils/agetty.c +++ b/term-utils/agetty.c @@ -44,6 +44,7 @@ #include "c.h" #include "widechar.h" #include "ttyutils.h" +#include "color-names.h" #ifdef HAVE_SYS_PARAM_H # include @@ -2340,8 +2341,17 @@ static void output_special_char(unsigned char c, struct options *op, switch (c) { case 'e': - fputs("\033", stdout); + { + char escname[UL_COLORNAME_MAXSZ]; + + if (get_escape_argument(fp, escname, sizeof(escname))) { + const char *esc = color_sequence_from_colorname(escname); + if (esc) + fputs(esc, stdout); + } else + fputs("\033", stdout); break; + } case 's': printf("%s", uts.sysname); break; -- cgit v1.2.3-55-g7522