dash.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Harald van Dijk <harald@gigawatt.nl>
To: Subhaditya Nath <sn03.general@gmail.com>, dash@vger.kernel.org
Subject: Re: ANSI escape codes in printf don't work
Date: Mon, 7 Feb 2022 15:55:03 +0000	[thread overview]
Message-ID: <d89a498d-f0c7-99c5-c6e5-901734abdc42@gigawatt.nl> (raw)
In-Reply-To: <CAPHxB8tN-aCb1vUTPPWqakyA5wVJfzXXQrr97fPE00fTQPuwkg@mail.gmail.com>

Hi,

On 07/02/2022 15:36, Subhaditya Nath wrote:
> Run this -
> 
>      /usr/bin/printf '\x1b[31m%s\x1b[m\n' FAIL
> 
> It should print FAIL in red foreground color.
> It does, on other shells.
> In dash, it doesn't.

Hexadecimal escape sequences are not specified by POSIX. They are a 
common extension in other shells as you noticed but dash generally 
limits itself to what POSIX specifies. Octal escape sequences are part 
of the standard and supported by dash, and offer the same functionality:

   printf '\033[31m%s\033[m\n' FAIL

Cheers,
Harald van Dijk

      reply	other threads:[~2022-02-07 16:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-07 15:36 ANSI escape codes in printf don't work Subhaditya Nath
2022-02-07 15:55 ` Harald van Dijk [this message]

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=d89a498d-f0c7-99c5-c6e5-901734abdc42@gigawatt.nl \
    --to=harald@gigawatt.nl \
    --cc=dash@vger.kernel.org \
    --cc=sn03.general@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).