Match gcc, perl, bash, ksh, tcsh, ... in supporting \e.
* src/printf.c (print_escape_char): Output \x1B when \e encountered.
* src/echo.c (main): Likewise.
* src/stat.c (print_escape_char): Likewise.
* doc/coreutils.texi (echo invocation): Add \e to the list.
* tests/misc/printf: Verify that \e outputs \x1B.
* NEWS: Mention the change in behaviour.
with the invoked command failing with status 1. Likewise, nohup
fails with status 125 instead of 127.
+ echo and printf now interpret \e as the Escape character (0x1B).
+
** New features
env and printenv now accept the option --null (-0), as a means to
backspace
@item \c
produce no further output
+@item \e
+escape
@item \f
form feed
@item \n
"), stdout);
fputs (_("\
\\c produce no further output\n\
+ \\e escape\n\
\\f form feed\n\
\\n new line\n\
\\r carriage return\n\
case 'a': c = '\a'; break;
case 'b': c = '\b'; break;
case 'c': exit (EXIT_SUCCESS);
+ case 'e': c = '\x1B'; break;
case 'f': c = '\f'; break;
case 'n': c = '\n'; break;
case 'r': c = '\r'; break;
\a = alert (bell)
\b = backspace
\c = produce no further output
+ \e = escape
\f = form feed
\n = new line
\r = carriage return
\\a alert (BEL)\n\
\\b backspace\n\
\\c produce no further output\n\
+ \\e escape\n\
\\f form feed\n\
"), stdout);
fputs (_("\
case 'c': /* Cancel the rest of the output. */
exit (EXIT_SUCCESS);
break;
+ case 'e': /* Escape. */
+ putchar ('\x1B');
+ break;
case 'f': /* Form feed. */
putchar ('\f');
break;
esc_value = esc_value * 8 + octtobin (*p);
putchar (esc_value);
}
- else if (*p && strchr ("\"\\abcfnrtv", *p))
+ else if (*p && strchr ("\"\\abcefnrtv", *p))
print_esc_char (*p++);
else if (*p == 'u' || *p == 'U')
{
case 'b': /* Backspace. */
c ='\b';
break;
+ case 'e': /* Escape. */
+ c ='\x1B';
+ break;
case 'f': /* Form feed. */
c ='\f';
break;
fail=0
+# Verify the 3 methods of specifying "Escape":
+test $("$prog" "\x1b\n\33\n\e\n" | uniq -u) && fail=1
+
# This would fail (by printing the `--') for printf in sh-utils
# and in coreutils 4.5.1.
"$prog" -- 'foo\n' > out || fail=1