diff options
author | Patrice Clement <monsieurp@gentoo.org> | 2016-07-26 11:02:28 +0200 |
---|---|---|
committer | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2016-08-18 10:01:25 +0200 |
commit | 81c8363c0967dac5ed5320dd5e60ed16b3df2ef6 (patch) | |
tree | 12158fa4c21a4219a6986204e4eddfc9300aceef | |
parent | 7e603f78464cc9ce6ba87a56bd92e2e69205b6a4 (diff) | |
download | sonarqube-81c8363c0967dac5ed5320dd5e60ed16b3df2ef6.tar.gz sonarqube-81c8363c0967dac5ed5320dd5e60ed16b3df2ef6.zip |
Variables should be local to each function to avoid clashing in the global namespace.
Signed-off-by: Sébastien Lesaint <sebastien.lesaint@sonarsource.com>
-rwxr-xr-x | scripts/property_utils.sh | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/scripts/property_utils.sh b/scripts/property_utils.sh index 3644fa992fa..8ac285af760 100755 --- a/scripts/property_utils.sh +++ b/scripts/property_utils.sh @@ -9,14 +9,14 @@ set -euo pipefail function cnt_lines() { - FILE=$1 + local FILE=$1 cat $FILE | wc -l } function write_prop() { - PROPERTY=$1 - VALUE=$2 - FILE=$3 + local PROPERTY=$1 + local VALUE=$2 + local FILE=$3 # uncomment below to help debug calls to set_property #echo "setting property $PROPERTY to value $VALUE in $FILE" @@ -26,11 +26,11 @@ function write_prop() { } function set_property() { - PROPERTY=$1 - VALUE=$2 - FILE=$3 + local PROPERTY=$1 + local VALUE=$2 + local FILE=$3 - REGEXP="${PROPERTY//\./\\.}\\s*=" + local REGEXP="${PROPERTY//\./\\.}\\s*=" if grep -q "$REGEXP" "$FILE"; then # delete line of specified property @@ -43,7 +43,7 @@ function set_property() { fi # add property if at least one line deleted - NEW_LINE_COUNT=$(cnt_lines $FILE) + local NEW_LINE_COUNT=$(cnt_lines $FILE) if [[ $LINE_COUNT -gt $NEW_LINE_COUNT ]]; then write_prop $PROPERTY $VALUE $FILE @@ -53,5 +53,3 @@ function set_property() { write_prop $PROPERTY $VALUE $FILE fi } - - |