dash.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* ANSI escape codes in printf don't work
@ 2022-02-07 15:36 Subhaditya Nath
  2022-02-07 15:55 ` Harald van Dijk
  0 siblings, 1 reply; 2+ messages in thread
From: Subhaditya Nath @ 2022-02-07 15:36 UTC (permalink / raw)
  To: dash

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: ANSI escape codes in printf don't work
  2022-02-07 15:36 ANSI escape codes in printf don't work Subhaditya Nath
@ 2022-02-07 15:55 ` Harald van Dijk
  0 siblings, 0 replies; 2+ messages in thread
From: Harald van Dijk @ 2022-02-07 15:55 UTC (permalink / raw)
  To: Subhaditya Nath, dash

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-02-07 16:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-07 15:36 ANSI escape codes in printf don't work Subhaditya Nath
2022-02-07 15:55 ` Harald van Dijk

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).