Fix #282 use modern arithmetic expansion in shell
Fix also files not ending with .sh Use $((.*)) instead of $[.*] The later one is old syntax
Simon Nagl committed
Apr 29, 2016 at 03:35 UTC
316ff7dd13e31d12055ec4918648a6a828c9a6f1
1 file changed
+6
-6
plugins.d/charts.d.plugin
+6
-6
@@ -84,7 +84,7 @@ time_divisor=50
84
# number of seconds to run without restart
85
# after this time, charts.d.plugin will exit
86
# netdata will restart it
87
-restart_timeout=$[3600 * 4]
87
+restart_timeout=$((3600 * 4))
88
89
# check if the charts.d plugins are using global variables
90
# they should not.
@@ -247,7 +247,7 @@ float2int() {
247
# echo >&2 "value='${1}' f='${f}', m='${m}'"
248
249
# the length of the multiplier - 1
250
- l=$[ ${#m} - 1 ]
250
+ l=$(( ${#m} - 1 ))
251
252
# check if the number is in scientific notation
253
if [[ ${f} =~ ^[[:space:]]*(-)?[0-9.]+(e|E)(\+|-)[0-9]+ ]]
@@ -269,7 +269,7 @@ float2int() {
269
270
# strip leading zeros from the integer part
271
# base 10 convertion
272
- a=$[10#$a]
272
+ a=$((10#$a))
273
274
# check the length of the decimal part
275
# against the length of the multiplier
@@ -281,16 +281,16 @@ float2int() {
281
elif [ ${#b} -lt ${l} ]
282
then
283
# too few digits - pad with zero on the right
284
- local z="00000000000000000000000" r=$[l - ${#b}]
284
+ local z="00000000000000000000000" r=$((l - ${#b}))
285
b="${b}${z:0:${r}}"
286
fi
287
288
# strip leading zeros from the decimal part
289
# base 10 convertion
290
- b=$[10#$b]
290
+ b=$((10#$b))
291
292
# store the result
293
- FLOAT2INT_RESULT=$[ (a * m) + b ]
293
+ FLOAT2INT_RESULT=$(( (a * m) + b ))
294
#echo >&2 "FLOAT2INT_RESULT='${FLOAT2INT_RESULT}'"
295
}
296