DASH Shell discussions
 help / color / mirror / Atom feed
From: Adam Borowski <kilobyte@angband.pl>
To: dash@vger.kernel.org
Subject: Re: [PATCH] \e in "echo" and "printf" builtins
Date: Wed, 23 Jul 2014 11:11:17 +0200	[thread overview]
Message-ID: <20140723091117.GA30150@angband.pl> (raw)
In-Reply-To: <20140628172722.GA13451@angband.pl>

[-- Attachment #1: Type: text/plain, Size: 1099 bytes --]

On Sat, Jun 28, 2014 at 07:27:22PM +0200, Adam Borowski wrote:
> On Sat, Jun 28, 2014 at 06:52:51PM +0200, Harald van Dijk wrote:
> > On 28/06/14 06:56, Adam Borowski wrote:
> > > I'm not sure what's your policy towards extensions, but \e as \033 is
> > > something ubiquitous in the Unix world.  C compilers (gcc, clang, icc and
> > > tcc -- but not MSVC), perl, shells (bash and zsh -- but not dash), etc.
> > 
> > No comment on whether dash itself should accept \e, but [...]

So... can I has an answer whether dash should indeed accept \e ?
Being told "no" or "go away, we hate you" is fine, I just dislike having
patches rot forever.  And not having this shorthand is annoying if you
like using colour for highlights -- it works in perl and bash, then
suddenly Oops! not in /bin/sh = dash.


Meow!
-- 
// If you believe in so-called "intellectual property", please immediately
// cease using counterfeit alphabets.  Instead, contact the nearest temple
// of Amon, whose priests will provide you with scribal services for all
// your writing needs, for Reasonable and Non-Discriminatory prices.

[-- Attachment #2: 0001-Support-e-in-echo-and-printf-builtins.patch --]
[-- Type: text/x-diff, Size: 1568 bytes --]

From a6e6e7b6f3a725b4ca0514f22e9ee4cfe2c225e2 Mon Sep 17 00:00:00 2001
From: Adam Borowski <kilobyte@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 <kilobyte@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 = '\033';	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


  reply	other threads:[~2014-07-23  9:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-28  4:56 [PATCH] \e in "echo" and "printf" builtins Adam Borowski
2014-06-28 16:52 ` Harald van Dijk
2014-06-28 17:27   ` Adam Borowski
2014-07-23  9:11     ` Adam Borowski [this message]
2014-07-23 10:26       ` Jérémie Courrèges-Anglas
2014-06-28 17:33   ` Paul Gilmartin
2014-06-29  9:28     ` Harald van Dijk
2014-06-30 13:08     ` Eric Blake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140723091117.GA30150@angband.pl \
    --to=kilobyte@angband.pl \
    --cc=dash@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox