fix loader for dash

This commit is contained in:
Patrick Stadler 2015-03-15 21:53:34 +01:00
parent 98e917a402
commit 3ba708dcfb
1 changed files with 15 additions and 13 deletions

View File

@ -1,10 +1,24 @@
#!/bin/sh
load_reporter_with_prefix () {
local prefix=$1
local file=$2
# dash will error if this variable is defined as `local`
content=$(sed \
-e 's/^[[:space:]]*\(init[ ]*()[ ]*{\)/'"$prefix"'\1/' \
-e 's/^[[:space:]]*\(report[ ]*()[ ]*{\)/'"$prefix"'\1/' \
-e 's/^[[:space:]]*\(terminate[ ]*()[ ]*{\)/'"$prefix"'\1/' \
-e 's/^[[:space:]]*\(docs[ ]*()[ ]*{\)/'"$prefix"'\1/' $file)
eval "$content"
}
load_metric_with_prefix () {
local prefix=$1
local file=$2
local content=$(sed \
# dash will error if this variable is defined as `local`
content=$(sed \
-e 's/^[[:space:]]*\(init[ ]*()[ ]*{\)/'"$prefix"'\1/' \
-e 's/^[[:space:]]*\(collect[ ]*()[ ]*{\)/'"$prefix"'\1/' \
-e 's/^[[:space:]]*\(terminate[ ]*()[ ]*{\)/'"$prefix"'\1/' \
@ -12,15 +26,3 @@ load_metric_with_prefix () {
eval "$content"
}
load_reporter_with_prefix () {
local prefix=$1
local file=$2
local content=$(sed \
-e 's/^[[:space:]]*\(init[ ]*()[ ]*{\)/'"$prefix"'\1/' \
-e 's/^[[:space:]]*\(report[ ]*()[ ]*{\)/'"$prefix"'\1/' \
-e 's/^[[:space:]]*\(terminate[ ]*()[ ]*{\)/'"$prefix"'\1/' \
-e 's/^[[:space:]]*\(docs[ ]*()[ ]*{\)/'"$prefix"'\1/' $file)
eval "$content"
}