summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--term-utils/agetty.89
-rw-r--r--term-utils/agetty.c12
2 files changed, 18 insertions, 3 deletions
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 <sys/param.h>
@@ -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;