X-Git-Url: https://arthur.barton.de/gitweb/?a=blobdiff_plain;f=plugins.d%2Fcharts.d.dryrun-helper.sh;h=8142f9882b6aa79573d45eb744ba04496f9a0085;hb=65cd61cc91763c1d95c2c2d2701c1f7be49a3a4c;hp=3d0bcb3732261e25eb558f439a6780a73c919366;hpb=648e4ae9540b2b6bed15839b319d456e8ba01674;p=netdata.git diff --git a/plugins.d/charts.d.dryrun-helper.sh b/plugins.d/charts.d.dryrun-helper.sh index 3d0bcb37..8142f988 100755 --- a/plugins.d/charts.d.dryrun-helper.sh +++ b/plugins.d/charts.d.dryrun-helper.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env bash # will stop the script for any error set -e @@ -10,11 +10,11 @@ conf="$3" can_diff=1 -tmp1=`mktemp` -tmp2=`mktemp` +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' @@ -25,9 +25,9 @@ myset >"$tmp2" 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 + # 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 @@ -36,21 +36,21 @@ myset >"$tmp1" # include the plugin and its config if [ -f "$conf" ] then - . "$conf" - if [ $? -ne 0 ] - then - echo >&2 "$me: cannot load config file $conf" - rm "$tmp1" "$tmp2" - exit 1 - fi + . "$conf" + if [ $? -ne 0 ] + then + echo >&2 "$me: cannot load config file $conf" + rm "$tmp1" "$tmp2" + exit 1 + fi fi . "$chart" if [ $? -ne 0 ] then - echo >&2 "$me: cannot load chart file $chart" - rm "$tmp1" "$tmp2" - exit 1 + echo >&2 "$me: cannot load chart file $chart" + rm "$tmp1" "$tmp2" + exit 1 fi # remove all variables starting with the plugin name @@ -58,15 +58,15 @@ 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 + # 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"