]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWGPP/benchmark/benchmark.sh
handle bash args properly using arrays
[u/mrichter/AliRoot.git] / PWGPP / benchmark / benchmark.sh
index ca34a37e01eb70d2fc60151c8b4704d4a5f700f7..9a3ef06779f7a952299b1c7196ae850814d40ed1 100755 (executable)
@@ -2242,13 +2242,16 @@ parseConfig()
     echo "config file ${configFile} not found!, skipping..."
   fi
 
-  #then, parse the options as theya override the optionf from file
-  for ((i=0;i<${#args[@]};i++)) ;do
-    local var="${args[i]%%=*}"
-    local value="${args[i]#*=}"
-    echo exporting ${var}="${value}"
+  #then, parse the options as they override the options from file
+  for opt in "${args[@]}"; do
+    if [[ ! "${opt}" =~ .*=.* ]]; then
+      echo "badly formatted option ${var}, should be: option=value, stopping..."
+      return 1
+    fi
+    local var="${opt%%=*}"
+    local value="${opt#*=}"
+    echo "${var} = ${value}"
     export ${var}="${value}"
-    shift
   done
 
   #do some checking