mirror of
https://github.com/speed47/spectre-meltdown-checker.git
synced 2024-12-26 20:10:31 +01:00
be smarter to find a usable echo command
This commit is contained in:
parent
995620a682
commit
3be5e90481
@ -97,17 +97,31 @@ global_critical=0
|
|||||||
global_unknown=0
|
global_unknown=0
|
||||||
nrpe_vuln=""
|
nrpe_vuln=""
|
||||||
|
|
||||||
|
echo_cmd=''
|
||||||
__echo()
|
__echo()
|
||||||
{
|
{
|
||||||
opt="$1"
|
opt="$1"
|
||||||
shift
|
shift
|
||||||
_msg="$@"
|
_msg="$@"
|
||||||
|
|
||||||
|
if [ -z "$echo_cmd" ]; then
|
||||||
|
# find a sane `echo` command
|
||||||
|
# we'll try to avoid using shell builtins that might not take options
|
||||||
|
if which echo >/dev/null 2>&1; then
|
||||||
|
echo_cmd=`which echo`
|
||||||
|
else
|
||||||
|
[ -x /bin/echo ] && echo_cmd=/bin/echo
|
||||||
|
[ -x /system/bin/echo ] && echo_cmd=/system/bin/echo
|
||||||
|
fi
|
||||||
|
# still empty ? fallback to builtin
|
||||||
|
[ -z "$echo_cmd" ] && echo_cmd=echo
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$opt_no_color" = 1 ] ; then
|
if [ "$opt_no_color" = 1 ] ; then
|
||||||
# strip ANSI color codes
|
# strip ANSI color codes
|
||||||
_msg=$(/bin/echo -e "$_msg" | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g")
|
_msg=$($echo_cmd -e "$_msg" | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g")
|
||||||
fi
|
fi
|
||||||
# explicitly call /bin/echo to avoid shell builtins that might not take options
|
$echo_cmd $opt -e "$_msg"
|
||||||
/bin/echo $opt -e "$_msg"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_echo()
|
_echo()
|
||||||
|
Loading…
Reference in New Issue
Block a user