Add support of '=' char to define value.

This commit is contained in:
nemo 2019-06-01 11:36:56 +02:00
parent 7443c41234
commit 5976e4c7bd

View file

@ -45,7 +45,7 @@ check_value_in_conf_file () {
# If multiple expected values # If multiple expected values
local list_search_ok=(${search_ok}) local list_search_ok=(${search_ok})
local search_ok_to_grep="^[[:space:]]*"${param_key}"[[:space:]]*:\?[[:space:]]*"${search_ok}"[[:space:]]*$" local search_ok_to_grep="^[[:space:]]*"${param_key}"[[:space:]]*:\?=\?[[:space:]]*"${search_ok}"[[:space:]]*$"
# If there is more than one unexpected values # If there is more than one unexpected values
if [ ${#list_search_ok[@]} -gt 1 ] if [ ${#list_search_ok[@]} -gt 1 ]
@ -54,7 +54,7 @@ check_value_in_conf_file () {
for var_search_ok in ${list_search_ok[@]} for var_search_ok in ${list_search_ok[@]}
do do
search_ok_to_grep=${search_ok_to_grep}'-e '"^[[:space:]]*${param_key}[[:space:]]*:\?[[:space:]]*${var_search_ok}[[:space:]]*$"' ' search_ok_to_grep=${search_ok_to_grep}'-e '"^[[:space:]]*${param_key}[[:space:]]*:\?=\?[[:space:]]*${var_search_ok}[[:space:]]*$"' '
done done
fi fi
@ -72,7 +72,7 @@ check_value_in_conf_file () {
# Unexpected value is not set # Unexpected value is not set
else else
search_ok_to_grep="^[[:space:]]*"${param_key}"[[:space:]]*:\?[[:space:]]*"${search_ok}"[[:space:]]*$" search_ok_to_grep="^[[:space:]]*"${param_key}"[[:space:]]*:\?=\?[[:space:]]*"${search_ok}"[[:space:]]*$"
# Boolean for final Return Code, if one return code in the loop -ne 0 -> set finalRC=1 # Boolean for final Return Code, if one return code in the loop -ne 0 -> set finalRC=1
local finalRC=0 local finalRC=0
@ -82,7 +82,7 @@ check_value_in_conf_file () {
then then
for var_search_ok in ${list_search_ok[@]} for var_search_ok in ${list_search_ok[@]}
do do
grep -q "^[[:space:]]*"${param_key}"[[:space:]]*:\?[[:space:]]*"${var_search_ok}"[[:space:]]*$" ${conf_file} grep -q "^[[:space:]]*"${param_key}"[[:space:]]*:\?=\?[[:space:]]*"${var_search_ok}"[[:space:]]*$" ${conf_file}
RC=${?} RC=${?}
@ -96,7 +96,7 @@ check_value_in_conf_file () {
# Else : do classical check # Else : do classical check
else else
# Check if OK value is set (success if return code = 0) # Check if OK value is set (success if return code = 0)
grep -q "^[[:space:]]*"${param_key}"[[:space:]]*:\?[[:space:]]*"${search_ok}"[[:space:]]*$" ${conf_file} grep -q "^[[:space:]]*"${param_key}"[[:space:]]*:\?=\?[[:space:]]*"${search_ok}"[[:space:]]*$" ${conf_file}
# Return Code # Return Code
finalRC=${?} finalRC=${?}