filter fields in functions
This commit is contained in:
@ -40,17 +40,18 @@ print_array_field() {
|
||||
}
|
||||
|
||||
# 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() {
|
||||
if [[ -n $1 ]]; then
|
||||
suffix="_$1"
|
||||
else
|
||||
suffix=""
|
||||
fi
|
||||
if [[ ! "$(type -t "package$suffix")" = function ]]; then return; fi
|
||||
# eval only variable assignments in package function
|
||||
while read -r line; do
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user