Re: ANSI escape codes in printf don't work

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux