@@ -177,35 +177,35 @@ get_config_value() {
177177 local file=${1}
178178 local option=${2}
179179
180- while read -r line; do
181- if [[ $line =~ ^([^= ]+)[[:space:]]([^= ]+)$ ]]; then
182- # Test first word (= option name)...
183- if [[ $option = ${BASH_REMATCH[1]} ]]; then
184- # ... to get the second word (= value of the option)
185- echo " ${BASH_REMATCH[2]} " # As this is a string, we use echo to return the value
186- break
187- fi
188- else
189- break
190- fi
191- done < " $file "
192-
193-
194180 # while read -r line; do
195- # # Avoid reading comments and empty lines
196- # if [[ ${line:0:1} != "#" ]] && [[ ${line:0:1} != "" ]]; then
197-
198- # if [[ $line =~ ^([^=]+)[[:space:]]([^=]+)$ ]]; then
199- # # Test first word (= option name)...
200- # if [[ $option = ${BASH_REMATCH[1]} ]]; then
201- # # ... to get the second word (= value of the option)
202- # echo "${BASH_REMATCH[2]}" # As this is a string, we use echo to return the value
203- # break
204- # fi
181+ # if [[ $line =~ ^([^=]+)[[:space:]]([^=]+)$ ]]; then
182+ # # Test first word (= option name)...
183+ # if [[ $option = ${BASH_REMATCH[1]} ]]; then
184+ # # ... to get the second word (= value of the option)
185+ # echo "${BASH_REMATCH[2]}" # As this is a string, we use echo to return the value
186+ # break
205187 # fi
188+ # else
189+ # break
190+ # fi
191+ # done < "$file"
192+
206193
207- # fi
208- # done < "$file_config_current"
194+ while read -r line; do
195+ # Avoid reading comments and empty lines
196+ if [[ ${line: 0: 1} != " #" ]] && [[ ${line: 0: 1} != " " ]]; then
197+
198+ if [[ $line =~ ^([^= ]+)[[:space:]]([^= ]+)$ ]]; then
199+ # Test first word (= option name)...
200+ if [[ $option = ${BASH_REMATCH[1]} ]]; then
201+ # ... to get the second word (= value of the option)
202+ echo " ${BASH_REMATCH[2]} " # As this is a string, we use echo to return the value
203+ break
204+ fi
205+ fi
206+
207+ fi
208+ done < " $file_config_current "
209209}
210210export -f get_config_value
211211
0 commit comments