Control: tags -1 +patch > dash's builtin version of printf doesn't support '\e' (escape), and > literaly outputs the 2 characters as-is. As is well known, this sequence > is useful, for example, when outputting ANSI escape sequences.
In fact, every shell other than dash (including posh whose main purpose is to be POSIXly correct) does support '\e'. So does every scripting language I've looked at (perl python php lua ruby ...). And so does every C compiler I've checked other than MSVC. Thus, a big majority of people assumes \e works; this includes shell scripts that come from non-Debian derivatives where #!/bin/sh is bash or mksh. I've sent upstream a patch in 2014, they rejected it because POSIX doesn't require \e (but neither forbids it); I now see they added some support anyway. As you probably don't want to update dash to a new upstream release at this point before the freeze, please apply my old patch as it works (just re-tested) with 0.5.8. Meow! -- The bill declaring Jesus as the King of Poland fails to specify whether the addition is at the top or end of the list of kings. What should the historians do?
From: Adam Borowski <kilob...@angband.pl> Date: Sat, 28 Jun 2014 06:29:56 +0200 Subject: [PATCH] Support \e in "echo" and "printf" builtins. Signed-off-by: Adam Borowski <kilob...@angband.pl> --- src/bltin/printf.c | 1 + src/dash.1 | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/bltin/printf.c b/src/bltin/printf.c index 893295c..98d954c 100644 --- a/src/bltin/printf.c +++ b/src/bltin/printf.c @@ -300,6 +300,7 @@ conv_escape(char *str, int *conv_ch) case '\\': value = '\\'; break; /* backslash */ case 'a': value = '\a'; break; /* alert */ case 'b': value = '\b'; break; /* backspace */ + case 'e': value = '\e'; break; /* escape */ case 'f': value = '\f'; break; /* form-feed */ case 'n': value = '\n'; break; /* newline */ case 'r': value = '\r'; break; /* carriage-return */ diff --git a/src/dash.1 b/src/dash.1 index 3847d98..7107faa 100644 --- a/src/dash.1 +++ b/src/dash.1 @@ -1199,6 +1199,8 @@ Subsequent output is suppressed. This is normally used at the end of the last argument to suppress the trailing newline that .Ic echo would otherwise output. +.It Li \ee +Outputs an escape character (ESC). .It Li \ef Output a form feed. .It Li \en @@ -1573,6 +1575,8 @@ The characters and their meanings are as follows: Write a \*[Lt]bell\*[Gt] character. .It Cm \eb Write a \*[Lt]backspace\*[Gt] character. +.It Cm \ee +Write an \*[Lt]escape\*[Gt] (ESC) character. .It Cm \ef Write a \*[Lt]form-feed\*[Gt] character. .It Cm \en -- 2.0.0