aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStéphane Lesimple <speed47_github@speed47.net>2018-01-24 17:55:36 +0100
committerStéphane Lesimple <speed47_github@speed47.net>2018-01-24 17:57:19 +0100
commitd1c1f0f0f0e9fa69206605c4d38f0bcc9fa55ff4 (patch)
tree77c161c8da1324b3b4af4342afa0295ab6567dd1
parentacf12a6d2d0187acc1ec9c028d9eb632f8259804 (diff)
downloadspectre-meltdown-checker-d1c1f0f0f0e9fa69206605c4d38f0bcc9fa55ff4.tar.lz
spectre-meltdown-checker-d1c1f0f0f0e9fa69206605c4d38f0bcc9fa55ff4.tar.xz
spectre-meltdown-checker-d1c1f0f0f0e9fa69206605c4d38f0bcc9fa55ff4.zip
fix(batch): fix regression introduced by acf12a6
In batch mode, $echo_cmd was not initialized early enough, and caused this error: ./spectre-meltdown-checker.sh: 899: ./spectre-meltdown-checker.sh: -ne: not found Fix it by initing echo_cmd unconditionally at the start
-rwxr-xr-xspectre-meltdown-checker.sh24
1 files changed, 10 insertions, 14 deletions
diff --git a/spectre-meltdown-checker.sh b/spectre-meltdown-checker.sh
index 9bdd086..cdde101 100755
--- a/spectre-meltdown-checker.sh
+++ b/spectre-meltdown-checker.sh
@@ -99,26 +99,22 @@ global_critical=0
global_unknown=0
nrpe_vuln=""
-echo_cmd=''
+# 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
__echo()
{
opt="$1"
shift
_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
# strip ANSI color codes
_msg=$($echo_cmd -e "$_msg" | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g")