mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-18 10:04:20 +03:00
tests: bash-fu for lvmconf
Sqeeze about 0.1s out of every created conf and use internal bash associative arrays instead of lot of command forking
This commit is contained in:
parent
923902013c
commit
c5b4327f3d
@ -785,16 +785,29 @@ EOF
|
|||||||
echo "$v"
|
echo "$v"
|
||||||
done >> "$config_values"
|
done >> "$config_values"
|
||||||
|
|
||||||
local s
|
declare -A CONF
|
||||||
for s in $(cut -f1 -d/ "$config_values" | sort | uniq); do
|
local sec
|
||||||
echo "$s {"
|
local last_sec
|
||||||
local k
|
|
||||||
for k in $(grep ^"$s"/ "$config_values" | cut -f1 -d= | sed -e 's, *$,,' | sort | uniq); do
|
# read sequential list and put into associative array
|
||||||
grep "^$k" "$config_values" | tail -n 1 | sed -e "s,^$s/, ,"
|
while IFS=$IFS_NL read -r v; do
|
||||||
done
|
# trim white-space-chars via echo when inserting
|
||||||
echo "}"
|
CONF[$(echo ${v%%=*})]=${v##*=}
|
||||||
echo
|
done < "$config_values"
|
||||||
done | tee "$config" | sed -e "s,^,## LVMCONF: ,"
|
|
||||||
|
# sort by section and iterate through them
|
||||||
|
printf "%s\n" ${!CONF[@]} | sort | while read -r v ; do
|
||||||
|
sec=${v%%/*} # split on section'/'param_name
|
||||||
|
test "$sec" = "$last_sec" || {
|
||||||
|
test -z "$last_sec" || echo "}"
|
||||||
|
echo "$sec {"
|
||||||
|
last_sec=$sec
|
||||||
|
}
|
||||||
|
echo " ${v#*/} =${CONF[$v]}"
|
||||||
|
done > "$config"
|
||||||
|
echo "}" >> "$config"
|
||||||
|
|
||||||
|
sed -e "s,^,## LVMCONF: ," "$config"
|
||||||
}
|
}
|
||||||
|
|
||||||
lvmconf() {
|
lvmconf() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user