All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Waite <alexqw85@gmail.com>
To: dash@vger.kernel.org
Subject: dash and ANSI escape sequences
Date: Tue, 18 Feb 2014 12:54:29 +0100	[thread overview]
Message-ID: <ldvhl7$ns2$1@ger.gmane.org> (raw)

I come here in search of someone who understands dash/portable scripting 
better than I do. Today, my Google-foo is failing me.

I am in the process of cleaning up someone else's semi-portable shell 
script (originally written on FreeBSD). The original script uses colors, 
in the form of

echo -e "\e[1;32mpassed\e[0m"

"echo" should be avoided in general and any option passed to "echo" is 
non-portable. In bash, I can easily port this to printf

printf '%b' "\x1b[32;1mpassed\x1b[0m\n"

However, this approach does not work in dash. I have read both the echo 
and printf sections of the dash manual, and it seems that both "\e" and 
"\x" are unsupported. Using "%b" allows additional backslash-escape 
sequences, but only \c and \0.

I know the purpose of dash is to provide an efficient POSIX compliant 
shell. Is there really no POSIX compliant way to use color? It seems 
so... 80s. Dash's manpage does state that it supports "backslash 
notation as defined in ANSI X3.159-1989 (“ANSI C89”)", but I can't find 
a copy of ANSI C89 online to confirm whether it includes display 
attributes. ANSI C89 is old, but still... too old for color?

Am I somehow missing some hidden functionality in printf, or is there 
really no POSIX compliant method of printing colors, or is Dash simply 
incomplete with its POSIX support in this regard?

Any insight is most appreciated.

---Alex


             reply	other threads:[~2014-02-18 12:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-18 11:54 Alex Waite [this message]
2014-02-18 13:11 ` dash and ANSI escape sequences Guido Berhoerster
2014-02-18 13:22   ` Steffen Nurpmeso
2014-02-18 13:27   ` Alex Waite
2014-02-18 13:16 ` Steffen Nurpmeso

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='ldvhl7$ns2$1@ger.gmane.org' \
    --to=alexqw85@gmail.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.