]> source.dussan.org Git - sonarqube.git/commitdiff
[scripts] declare bash function in portable fashion
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Wed, 30 May 2018 14:10:05 +0000 (16:10 +0200)
committerSonarTech <sonartech@sonarsource.com>
Tue, 12 Jun 2018 18:21:01 +0000 (20:21 +0200)
scripts/editions.sh
scripts/generate_batch_reports.sh
scripts/logs.sh
scripts/property_utils.sh
scripts/stop.sh
travis.sh

index fadf5cbe03ac318f9e53bf40d360ef65d1c9f6f5..4f001c0617c66c1b48d0c618c0692bb49f9b4795 100755 (executable)
@@ -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
index 247fd1580f24f37dc0489cfbb2c64afade42de5f..acd64769c28c07afd455e5a1e9e4093d47780a0e 100755 (executable)
 
 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
index e023847fb8b879c7f8e57e541f9e7fc39b2d1cec..f5078ee47fa75316e1ee85570094a65851b39645 100755 (executable)
@@ -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")
index 57b94f23ee590f51c56ecc49af10525e7106936c..0232d0cd1d1d014b719bd8ce49225541dc84498e 100755 (executable)
@@ -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
index 8b94cd2d2a7cb2e5a7fc874ef7051968933c5d10..8c2cdd8a9364580c50b2050a3e330bbefcc546d8 100755 (executable)
@@ -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
index a954284405633690983360bbb07b00c55099d1a2..85748c6cae18df22711a66c65bf58683d5c556bb 100755 (executable)
--- a/travis.sh
+++ b/travis.sh
@@ -9,7 +9,7 @@ set -euo pipefail
 # JDK is kept in cache. It does not need to be downloaded from Oracle
 # at each build.
 #
-function installJdk8 {
+installJdk8() {
   echo "Setup JDK 1.8u171"
   mkdir -p ~/jvm
   pushd ~/jvm > /dev/null
@@ -26,7 +26,7 @@ function installJdk8 {
 #
 # Configure Maven settings and install some script utilities
 #
-function configureTravis {
+configureTravis() {
   mkdir -p ~/.local
   curl -sSL https://github.com/SonarSource/travis-utils/tarball/v47 | tar zx --strip-components 1 -C ~/.local
   source ~/.local/bin/install
@@ -35,10 +35,10 @@ configureTravis
 
 #
 # Travis fails on timeout when build does not print logs
-# during 10 minutes. This function aims to bypass this
+# during 10 minutes. This aims to bypass this
 # behavior when building the slow sonar-server sub-project.
 #
-function keep_alive() {
+keep_alive() {
   while true; do
     echo -en "\a"
     sleep 60