Skip to content

Commit 0fcea6d

Browse files
author
Sengorius
committed
ignored commented lines, when printing hosts
1 parent cf72ceb commit 0fcea6d

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/main.sh

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,21 @@ function print_hosts() {
1111
if [[ -n "$HOSTS" ]]; then
1212
print_info "Following hosts have been booted:"
1313
echo "$HOSTS" | while read -r line; do
14+
# skip, if line is empty
15+
[[ -z "$line" ]] && continue
16+
17+
# skip, if the line contains commented code
18+
[[ "$line" =~ ^[[:space:]]*# ]] && continue
19+
20+
# check for a list of domains
1421
[[ "$line" =~ VIRTUAL_HOST.[[:space:]]*(.*)$ ]]
22+
[[ -z "${BASH_REMATCH[1]}" ]] && continue
1523

16-
if [[ -n "$line" && -n "${BASH_REMATCH[1]}" ]]; then
17-
publish_single_entry_hosts_file "${BASH_REMATCH[1]}"
24+
publish_single_entry_hosts_file "${BASH_REMATCH[1]}"
1825

19-
for addr in $(echo "${BASH_REMATCH[1]}" | tr -d '[:space:]' | tr "," "\n"); do
20-
echo " https://$addr"
21-
done
22-
fi
26+
for addr in $(echo "${BASH_REMATCH[1]}" | tr -d '[:space:]' | tr "," "\n"); do
27+
echo " https://$addr"
28+
done
2329
done
2430
fi
2531
}

0 commit comments

Comments
 (0)