diff options
author | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2017-01-05 10:35:15 +0100 |
---|---|---|
committer | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2017-01-10 12:01:57 +0100 |
commit | c8b1a4508b3edd61293300b55818f88ae773b3a4 (patch) | |
tree | e3b09413d2bc564e96951767ddd748f52af6dc7b /scripts | |
parent | f2fb3f2d6710906709cefb9b5ffd5880432abbea (diff) | |
download | sonarqube-c8b1a4508b3edd61293300b55818f88ae773b3a4.tar.gz sonarqube-c8b1a4508b3edd61293300b55818f88ae773b3a4.zip |
[script] fix logs.sh to not require bash 4
because mac bundles bash 3.2 by default rather than bash 4
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/logs.sh | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/scripts/logs.sh b/scripts/logs.sh index 1a6f62a88a1..24a7a5e26a7 100755 --- a/scripts/logs.sh +++ b/scripts/logs.sh @@ -13,29 +13,40 @@ set -euo pipefail DEFAULT_LOG="all" DEFAULT_LINES="25" LOGS="sonar web ce es" + +function toLower() { + echo "$1" | tr '[:upper:]' '[:lower:]' +} + function checkLogArgument() { local logArg="$1" - if [ "${logArg,,}" == "$DEFAULT_LOG" ]; then + local lowerLogArg=$(toLower $logArg) + + if [ "$lowerLogArg" == "$DEFAULT_LOG" ]; then return fi + for t in $LOGS; do - if [ "${logArg,,}" == "$t" ]; then + if [ "$lowerLogArg" == "$t" ]; then return fi done + echo "Unsupported -l argument $logArg" exit 1 } function buildTailArgs() { - local logArg="$1" + local logArg=$(toLower $logArg) local logLines="$2" local res="" + for t in $LOGS; do - if [ "${logArg,,}" == "$DEFAULT_LOG" ] || [ "${logArg,,}" == "$t" ]; then + if [ "$logArg" == "$DEFAULT_LOG" ] || [ "$logArg" == "$t" ]; then res="$res -Fn $logLines $SQ_HOME/logs/$t.log" fi done + echo "$res" } |