1
0
mirror of https://github.com/albfan/bash-ini-parser.git synced 2025-08-09 05:22:44 +03:00

bash: Extglob difference from bash 3 to 4

bash3 seems to be nongreedy
This commit is contained in:
Alberto Fanjul
2020-08-28 20:31:31 +02:00
parent 84977f91c3
commit 1135d4e95d

View File

@@ -42,7 +42,14 @@ function cfg_parser {
debug "removed ending whitespace"
ini=( ${ini[*]/%+([[:space:]])\\]/\\]} ) # remove non meaningful whitespace after sections
debug "removed whitespace after section name"
ini=( ${ini[*]/*([[:space:]])=*([[:space:]])/=} ) # remove whitespace around =
if [ $BASH_VERSINFO == 3 ]
then
ini=( ${ini[*]/+([[:space:]])=/=} ) # remove whitespace before =
ini=( ${ini[*]/=+([[:space:]])/=} ) # remove whitespace after =
ini=( ${ini[*]/+([[:space:]])=+([[:space:]])/=} ) # remove whitespace around =
else
ini=( ${ini[*]/*([[:space:]])=*([[:space:]])/=} ) # remove whitespace around =
fi
debug "removed space around ="
ini=( ${ini[*]/#\\[/\}$'\n'"$PREFIX"} ) # set section prefix
debug