Refactor display_results to be DRY
This commit is contained in:
parent
58c6db8185
commit
3447439d54
24
inventory.sh
24
inventory.sh
|
@ -92,18 +92,20 @@ display_results() {
|
||||||
|
|
||||||
# Types: Vhost, System, Htaccess, Template
|
# Types: Vhost, System, Htaccess, Template
|
||||||
printf 'File\tAllow\tOrder\tDeny\tSatsify\tTotal (directives)\tCGI\tType (V|S|H|T)\n' >&2
|
printf 'File\tAllow\tOrder\tDeny\tSatsify\tTotal (directives)\tCGI\tType (V|S|H|T)\n' >&2
|
||||||
|
|
||||||
|
set -- \
|
||||||
|
"$confs_vhost" V \
|
||||||
|
"$confs_system" S \
|
||||||
|
"$confs_htaccess" H \
|
||||||
|
"$confs_template" T
|
||||||
|
# For each types of confs
|
||||||
|
while [ "$#" -gt 0 ]; do
|
||||||
|
# For each confs file of that type
|
||||||
while IFS= read -r file; do
|
while IFS= read -r file; do
|
||||||
count_directives "$file" V | tee -a "$result"
|
count_directives "$file" "$2" | tee -a "$result"
|
||||||
done < "$confs_vhost"
|
done < "$1"
|
||||||
while IFS= read -r file; do
|
shift 2
|
||||||
count_directives "$file" S | tee -a "$result"
|
done
|
||||||
done < "$confs_system"
|
|
||||||
while IFS= read -r file; do
|
|
||||||
count_directives "$file" H | tee -a "$result"
|
|
||||||
done < "$confs_htaccess"
|
|
||||||
while IFS= read -r file; do
|
|
||||||
count_directives "$file" T | tee -a "$result"
|
|
||||||
done < "$confs_template"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# One line machine summary of the results
|
# One line machine summary of the results
|
||||||
|
|
Loading…
Reference in a new issue