]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
agetty: support \e{name} for issue file
authorKarel Zak <kzak@redhat.com>
Wed, 17 Feb 2016 11:53:20 +0000 (12:53 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 17 Feb 2016 11:53:20 +0000 (12:53 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
term-utils/agetty.8
term-utils/agetty.c

index bb2feea399c1728a016db52c5d30ad8f67d0edd5..02bf21925d555343fc3543778a67fc2f6192057e 100644 (file)
@@ -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'.
index d55b2e62a9093cbbe32da67015e035352d8005b5..d88cdc1c0c69812293f79416f04df9c9ea46b30a 100644 (file)
@@ -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;