From 6346a0deaac94708d798f851c209a7b9ec38dd48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Lesimple?= Date: Fri, 2 Feb 2018 10:59:49 +0100 Subject: [PATCH] fix: --no-color workaround for android's sed --- spectre-meltdown-checker.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/spectre-meltdown-checker.sh b/spectre-meltdown-checker.sh index 6352f06..6ee4463 100755 --- a/spectre-meltdown-checker.sh +++ b/spectre-meltdown-checker.sh @@ -8,7 +8,7 @@ # # Stephane Lesimple # -VERSION='0.34' +VERSION='0.34+' show_usage() { @@ -123,7 +123,10 @@ __echo() if [ "$opt_no_color" = 1 ] ; then # strip ANSI color codes - _msg=$($echo_cmd -e "$_msg" | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g") + # some sed versions (i.e. toybox) can't seem to handle + # \033 aka \x1B correctly, so do it for them. + _ctrlchar=$($echo_cmd -e "\033") + _msg=$($echo_cmd -e "$_msg" | sed -r "s/$_ctrlchar\[([0-9][0-9]?(;[0-9][0-9]?)?)?m//g") fi # shellcheck disable=SC2086 $echo_cmd $opt -e "$_msg"