[COMMON] Fix ${foo:3[:1]} bashisms 64/119064/22
authorGuillaume Lambert <guillaume.lambert@orange.com>
Wed, 10 Mar 2021 13:02:13 +0000 (14:02 +0100)
committerguillaume.lambert <guillaume.lambert@orange.com>
Mon, 6 Sep 2021 07:01:11 +0000 (09:01 +0200)
pointed out by checkbashisms

Issue-ID: OOM-264
Signed-off-by: Guillaume Lambert <guillaume.lambert@orange.com>
Change-Id: Ief3b2595a55f0e7a0a2e7ab05857848c99ce42f9

kubernetes/config/prepull_docker.sh
kubernetes/helm/plugins/deploy/deploy.sh
kubernetes/helm/plugins/undeploy/undeploy.sh
kubernetes/msb/components/msb-consul/resources/docker-entrypoint.sh
kubernetes/portal/components/portal-mariadb/resources/config/mariadb/docker-entrypoint.sh

index 590d651..efd0bd1 100755 (executable)
@@ -102,7 +102,7 @@ do
         for line in  `parse_yaml $filename`
         do
                 #skiping commented line
-                if [ "${line:0:1}" != '#' ]; then
+                if echo "$line" | grep -v '^#' >/dev/null; then
                         #find all image subtag inside converted values.yaml file's lines
                         if echo $line | grep -q $IMAGE_TEXT ; then
                                 #find imageName inside line
index d863a15..536be7b 100755 (executable)
@@ -96,9 +96,9 @@ deploy() {
 
   RELEASE=$1
   CHART_URL=$2
-  FLAGS=${@:3}
-  CHART_REPO="$(echo "$CHART_URL" |cut -d'/' -f1)"
-  CHART_NAME="$(echo "$CHART_URL" |cut -d'/' -f2)"
+  FLAGS=$(echo ${@} | sed 's/^ *[^ ]* *[^ ]* *//')
+  CHART_REPO="$(echo "$CHART_URL" | cut -d'/' -f1)"
+  CHART_NAME="$(echo "$CHART_URL" | cut -d'/' -f2)"
   if expr "$HELM_VER" : "v3\..*" ; then
     CACHE_DIR=~/.local/share/helm/plugins/deploy/cache
   else
@@ -287,7 +287,7 @@ case "${1:-"help"}" in
     usage
     ;;
   *)
-    deploy $1 $2 ${@:3}
+    deploy $1 $2 $(echo ${@} | sed 's/^ *[^ ]* *[^ ]* *//')
     ;;
 esac
 
index 35fc4ca..72c6424 100755 (executable)
@@ -45,7 +45,7 @@ case "${1:-"help"}" in
     usage
     ;;
   *)
-    undeploy $1 ${@:2}
+    undeploy $1 $(echo ${@} | sed 's/^ *[^ ]* *//')
     ;;
 esac
 
index 0cd4616..cbcbf7a 100755 (executable)
@@ -53,7 +53,7 @@ fi
 
 # If the user is trying to run Consul directly with some arguments, then
 # pass them to Consul.
-if [ "${1:0:1}" = '-' ]; then
+if echo "$1" | grep '^-' >/dev/null; then
     set -- consul "$@"
 fi
 
index 3d5e13f..b416fdd 100644 (file)
@@ -164,7 +164,7 @@ docker_init_database_dir() {
                installArgs=${installArgs}" --auth-root-authentication-method=normal"
        fi
        # "Other options are passed to mysqld." (so we pass all "mysqld" arguments directly here)
-       mysql_install_db ${installArgs} "${@:2}"
+       mysql_install_db ${installArgs} "$(echo ${@} | sed 's/^ *[^ ]* *//')"
        mysql_note "Database files initialized"
 }
 
@@ -313,7 +313,7 @@ _mysql_want_help() {
 
 _main() {
        # if command starts with an option, prepend mysqld
-       if [ "${1:0:1}" = '-' ]; then
+       if echo "$1" | grep '^-' >/dev/null; then
                set -- mysqld "$@"
        fi