diff options
Diffstat (limited to 'collectors/charts.d.plugin/charts.d.dryrun-helper.sh')
-rwxr-xr-x | collectors/charts.d.plugin/charts.d.dryrun-helper.sh | 58 |
1 files changed, 26 insertions, 32 deletions
diff --git a/collectors/charts.d.plugin/charts.d.dryrun-helper.sh b/collectors/charts.d.plugin/charts.d.dryrun-helper.sh index 67496c1bd..91af2c542 100755 --- a/collectors/charts.d.plugin/charts.d.dryrun-helper.sh +++ b/collectors/charts.d.plugin/charts.d.dryrun-helper.sh @@ -17,7 +17,7 @@ tmp1="$(mktemp)" tmp2="$(mktemp)" myset() { - set | grep -v "^_=" | grep -v "^PIPESTATUS=" | grep -v "^BASH_LINENO=" + set | grep -v "^_=" | grep -v "^PIPESTATUS=" | grep -v "^BASH_LINENO=" } # save 2 'set' @@ -26,52 +26,46 @@ myset >"$tmp2" # make sure they don't differ diff "$tmp1" "$tmp2" >/dev/null 2>&1 -if [ $? -ne 0 ] -then - # they differ, we cannot do the check - echo >&2 "$me: cannot check with diff." - can_diff=0 +if [ $? -ne 0 ]; then + # they differ, we cannot do the check + echo >&2 "$me: cannot check with diff." + can_diff=0 fi # do it again, now including the script myset >"$tmp1" # include the plugin and its config -if [ -f "$conf" ] -then - # shellcheck source=/dev/null - . "$conf" - if [ $? -ne 0 ] - then - echo >&2 "$me: cannot load config file $conf" - rm "$tmp1" "$tmp2" - exit 1 - fi +if [ -f "$conf" ]; then + # shellcheck source=/dev/null + . "$conf" + if [ $? -ne 0 ]; then + echo >&2 "$me: cannot load config file $conf" + rm "$tmp1" "$tmp2" + exit 1 + fi fi # shellcheck source=/dev/null . "$chart" -if [ $? -ne 0 ] -then - echo >&2 "$me: cannot load chart file $chart" - rm "$tmp1" "$tmp2" - exit 1 +if [ $? -ne 0 ]; then + echo >&2 "$me: cannot load chart file $chart" + rm "$tmp1" "$tmp2" + exit 1 fi # remove all variables starting with the plugin name myset | grep -v "^$name" >"$tmp2" -if [ $can_diff -eq 1 ] -then - # check if they are different - # make sure they don't differ - diff "$tmp1" "$tmp2" >&2 - if [ $? -ne 0 ] - then - # they differ - rm "$tmp1" "$tmp2" - exit 1 - fi +if [ $can_diff -eq 1 ]; then + # check if they are different + # make sure they don't differ + diff "$tmp1" "$tmp2" >&2 + if [ $? -ne 0 ]; then + # they differ + rm "$tmp1" "$tmp2" + exit 1 + fi fi rm "$tmp1" "$tmp2" |