]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
Brought bash code to Google coding standard
authorAndrei Pavel <andrei.pavel@qualitance.com>
Fri, 23 Dec 2016 14:47:05 +0000 (16:47 +0200)
committerAndrei Pavel <andrei.pavel@qualitance.com>
Fri, 23 Dec 2016 14:47:05 +0000 (16:47 +0200)
src/bin/admin/admin-utils.sh

index 3df7d4fc4efde98f5f18cfdd82992253c403e9bc..5c8be36f9bde8b8ec4bd5d6c7ac901f0910a1be8 100755 (executable)
@@ -19,10 +19,10 @@ mysql_execute() {
     QUERY=$1
     shift
     if [ $# -gt 1 ]; then
-        mysql -N -B  $* -e "${QUERY}"
+        mysql -N -B "$@" -e "${QUERY}"
         retcode=$?
     else
-        mysql -N -B --user=$db_user --password=$db_password -e "${QUERY}" $db_name
+        mysql -N -B --database=${db_name} --user=${db_user} --password=${db_password} -e "${QUERY}"
         retcode="$?"
     fi
 
@@ -48,11 +48,11 @@ pgsql_execute() {
     QUERY=$1
     shift
     if [ $# -gt 0 ]; then
-        echo $QUERY | psql --set ON_ERROR_STOP=1 -A -t -h localhost -q $*
+        echo "${QUERY}" | psql --set ON_ERROR_STOP=1 -A -t -h localhost -q "#@"
         retcode=$?
     else
         export PGPASSWORD=$db_password
-        echo $QUERY | psql --set ON_ERROR_STOP=1 -A -t -h localhost -q -U $db_user -d $db_name
+        echo "${QUERY}" | psql --set ON_ERROR_STOP=1 -A -t -h localhost -q -U "${db_user}" -d "${db_name}"
         retcode=$?
     fi
     return $retcode
@@ -72,11 +72,11 @@ pgsql_execute_script() {
     file=$1
     shift
     if [ $# -gt 0 ]; then
-        psql --set ON_ERROR_STOP=1 -A -t -h localhost -q -f $file $*
+        psql --set ON_ERROR_STOP=1 -A -t -h localhost -q -f "${file}" "$@"
         retcode=$?
     else
         export PGPASSWORD=$db_password
-        psql --set ON_ERROR_STOP=1 -A -t -h localhost -q -U $db_user -d $db_name -f $file
+        psql --set ON_ERROR_STOP=1 -A -t -h localhost -q -U "${db_user}" -d "${db_name}" -f "${file}"
         retcode=$?
     fi
     return $retcode
@@ -91,15 +91,15 @@ cql_execute() {
     query=$1
     shift
     if [ $# -gt 1 ]; then
-        cqlsh $* -e "$query"
+        cqlsh "$@" -e "$query"
         retcode=$?
     else
-        cqlsh -u $db_user -p $db_password -k $db_name -e "$query"
+        cqlsh -u "${db_user}" -p "${db_password}" -k "${db_name}" -e "${query}"
         retcode=$?
     fi
 
     if [ $retcode -ne 0 ]; then
-        printf "cqlsh returned with exit status $retcode\n"
+        printf "cqlsh returned with exit status %s\n" "${retcode}"
         exit $retcode
     fi
 
@@ -110,15 +110,15 @@ cql_execute_script() {
     file=$1
     shift
     if [ $# -gt 1 ]; then
-        cqlsh $* -e "$file"
+        cqlsh "$@" -e "$file"
         retcode=$?
     else
-        cqlsh -u $db_user -p $db_password -k $db_name -f "$file"
+        cqlsh -u "${db_user}" -p "${db_password}" -k "${db_name}" -f "${file}"
         retcode=$?
     fi
 
     if [ $retcode -ne 0 ]; then
-        printf "cqlsh returned with exit status $retcode\n"
+        printf "cqlsh returned with exit status %s\n" "${retcode}"
         exit $retcode
     fi
 
@@ -126,8 +126,8 @@ cql_execute_script() {
 }
 
 cql_version() {
-    version=`cql_execute "SELECT version, minor FROM schema_version" "$@"`
-    version=`echo "$version" | grep -A 1 "+" | grep -v "+" | tr -d ' ' | cut -d "|" -f 1-2 --output-delimiter="."`
-    echo $version
+    version=$(cql_execute "SELECT version, minor FROM schema_version" "$@")
+    version=$(echo "$version" | grep -A 1 "+" | grep -v "+" | tr -d ' ' | cut -d "|" -f 1-2 --output-delimiter=".")
+    echo "${version}"
     return $?
 }