filter fields in functions
This commit is contained in:
@ -40,17 +40,18 @@ print_array_field() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# load section content from its package function
|
# load section content from its package function
|
||||||
|
for field in "${section_fields[@]}"; do
|
||||||
|
_load_section_content_fields_pattern="$field|$_load_section_content_fields_pattern"
|
||||||
|
done
|
||||||
load_section_content() {
|
load_section_content() {
|
||||||
if [[ -n $1 ]]; then
|
if [[ -n $1 ]]; then
|
||||||
suffix="_$1"
|
suffix="_$1"
|
||||||
else
|
|
||||||
suffix=""
|
|
||||||
fi
|
fi
|
||||||
if [[ ! "$(type -t "package$suffix")" = function ]]; then return; fi
|
if [[ ! "$(type -t "package$suffix")" = function ]]; then return; fi
|
||||||
# eval only variable assignments in package function
|
# eval only variable assignments in package function
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
eval "$line"
|
eval "$line"
|
||||||
done < <(declare -f "package$suffix" | grep -E '^[[:space:]]*(declare +)?[[:alnum:]_]*=')
|
done < <(declare -f "package$suffix" | grep -E "^[[:space:]]*(declare +)?($_load_section_content_fields_pattern)=" | sed 's/^[[:space:]]*(declare +)?//')
|
||||||
}
|
}
|
||||||
|
|
||||||
# print fields for a section
|
# print fields for a section
|
||||||
|
|||||||
Reference in New Issue
Block a user