From 6b866f54740bf9969b2c22459d659dc6276e5a61 Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Thu, 18 Sep 2025 23:29:26 +0200 Subject: [PATCH] bin:no-ansi*: Use printf for escape byte I dislike having the raw escape byte in these scripts. Unfortunately `sed` does not support interpreting it via an escape sequence, so use printf for that. To remain POSIX compatible use `\033` and not `\e` or `\x1b` since I couldn't find these in the printf(1p) manpage. Unfortunately this brings a second layer of escaping. --- .local/bin/no-ansi | 2 +- .local/bin/no-ansi-sgr | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.local/bin/no-ansi b/.local/bin/no-ansi index b544661..46f54d8 100755 --- a/.local/bin/no-ansi +++ b/.local/bin/no-ansi @@ -4,4 +4,4 @@ # # Remove ANSI escape sequences. -env LC_ALL=C sed 's/\[[0-?]*[ -/]*[@-~]//g' +env LC_ALL=C sed "$(printf 's/\033\\[[0-?]*[ -/]*[@-~]//g')" diff --git a/.local/bin/no-ansi-sgr b/.local/bin/no-ansi-sgr index fdf8892..d8d6f38 100755 --- a/.local/bin/no-ansi-sgr +++ b/.local/bin/no-ansi-sgr @@ -5,4 +5,4 @@ # Remove ANSI SGR (Select Graphic Rendition) escape sequences, e.g. setting # color or bold font. -env LC_ALL=C sed 's/\[[0-?]*[ -/]*m//g' +env LC_ALL=C sed "$(printf 's/\033\\[[0-?]*[ -/]*m//g')"