From 7e59b1e27f80a5d466913a3b9040ee82d1ae2e52 Mon Sep 17 00:00:00 2001 From: Sébastien Lesaint Date: Wed, 30 May 2018 16:10:05 +0200 Subject: [scripts] declare bash function in portable fashion --- scripts/editions.sh | 10 +++++----- scripts/generate_batch_reports.sh | 8 ++++---- scripts/logs.sh | 8 ++++---- scripts/property_utils.sh | 6 +++--- scripts/stop.sh | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) (limited to 'scripts') diff --git a/scripts/editions.sh b/scripts/editions.sh index fadf5cbe03a..4f001c0617c 100755 --- a/scripts/editions.sh +++ b/scripts/editions.sh @@ -5,11 +5,11 @@ set -euo pipefail DEFAULT_EDITION="oss" EDITIONS="oss" -function toLower() { +toLower() { echo "$1" | tr '[:upper:]' '[:lower:]' } -function checkEditionArgument() { +checkEditionArgument() { local editionArg="$1" local lowerEditionArg=$(toLower $editionArg) @@ -27,7 +27,7 @@ function checkEditionArgument() { exit 1 } -function distributionDirOf() { +distributionDirOf() { local edition="$1" if [ "$edition" = "oss" ]; then @@ -38,7 +38,7 @@ function distributionDirOf() { fi } -function baseFileNameOf() { +baseFileNameOf() { local edition="$1" if [ "$edition" = "oss" ]; then @@ -49,7 +49,7 @@ function baseFileNameOf() { fi } -function targetDirOf() { +targetDirOf() { local edition="$1" if [ "$edition" = "oss" ]; then diff --git a/scripts/generate_batch_reports.sh b/scripts/generate_batch_reports.sh index 247fd1580f2..acd64769c28 100755 --- a/scripts/generate_batch_reports.sh +++ b/scripts/generate_batch_reports.sh @@ -16,11 +16,11 @@ set -euo pipefail -function clean() { +clean() { rm -Rf $BUILD_DIR } -function createPrivateClone() { +createPrivateClone() { BRANCH=$(git symbolic-ref -q HEAD) BRANCH=${BRANCH##refs/heads/} BRANCH=${BRANCH:-HEAD} @@ -39,7 +39,7 @@ function createPrivateClone() { cd ${BUILD_DIR}${RELATIVE_PATH} } -function showHelp() { +showHelp() { echo "Usage: $0 -d DIR_PATH [ -l integer ] [ -h URL ] [ -u string ] [ -p string ] -d : path to directory where batch report bumpds will be created -l : number of commit in the past (optional: default is $HISTORY_LENGTH) @@ -48,7 +48,7 @@ function showHelp() { -p : password to authentication on the SQ instance (optional: default is $SONAR_USER)" } -function checkOptions() { +checkOptions() { if [[ -z "$DUMP_DIR" ]]; then >&2 echo "-d option is mandatory" showHelp diff --git a/scripts/logs.sh b/scripts/logs.sh index e023847fb8b..f5078ee47fa 100755 --- a/scripts/logs.sh +++ b/scripts/logs.sh @@ -23,11 +23,11 @@ DEFAULT_LOG="all" DEFAULT_LINES="25" LOGS="sonar web ce es" -function toLower() { +toLower() { echo "$1" | tr '[:upper:]' '[:lower:]' } -function checkLogArgument() { +checkLogArgument() { local logArg="$1" local lowerLogArg=$(toLower $logArg) @@ -45,7 +45,7 @@ function checkLogArgument() { exit 1 } -function buildTailArgs() { +buildTailArgs() { local logArg="$(toLower $1)" local logLines="$2" local res="" @@ -59,7 +59,7 @@ function buildTailArgs() { echo "$res" } -function doTail() { +doTail() { local logArg="$1" local logLines="${2:-"$DEFAULT_LINES"}" TAIL_ARG=$(buildTailArgs "$logArg" "$logLines") diff --git a/scripts/property_utils.sh b/scripts/property_utils.sh index 57b94f23ee5..0232d0cd1d1 100755 --- a/scripts/property_utils.sh +++ b/scripts/property_utils.sh @@ -8,12 +8,12 @@ set -euo pipefail -function cnt_lines { +cnt_lines() { local FILE=$1 wc -l < "$FILE" } -function write_prop { +write_prop() { local PROPERTY=$1 local VALUE=$2 local FILE=$3 @@ -25,7 +25,7 @@ function write_prop { echo "${PROPERTY}=${VALUE}" >> "$FILE" } -function set_property { +set_property() { local PROPERTY=$1 local VALUE=$2 local FILE=$3 diff --git a/scripts/stop.sh b/scripts/stop.sh index 8b94cd2d2a7..8c2cdd8a936 100755 --- a/scripts/stop.sh +++ b/scripts/stop.sh @@ -17,7 +17,7 @@ else OS='linux-x86-64' fi -function stopAny() { +stopAny() { for edition in $EDITIONS; do SONAR_SH="$(distributionDirOf "$edition")/$(targetDirOf "$edition")/sonarqube-*/bin/$OS/sonar.sh" if ls $SONAR_SH &> /dev/null; then -- cgit v1.2.3