Skip to content

Commit b548cb7

Browse files
committed
[Lint]: Fix shellcheck linter
1 parent 6e448df commit b548cb7

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

0x10-https_ssl/0-world_wide_web

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
11
#!/usr/bin/env bash
22
# script to dig subdomain `A` records
3+
# shellcheck disable=SC2027
4+
# shellcheck disable=SC2086
35

46
function get_a_records(){
7+
if [[ -n "$2" ]]; then
8+
response="$(dig "$2.$1" | grep -i -A1 "answer section" | tail -n 1)"
9+
destination="$(echo "$response" | awk '{ print $5 }')"
10+
record_type="$(echo "$response" | awk '{ print $4 }')"
11+
echo "The subdomain "$2" is a "$record_type" record and points to "$destination""
512

13+
else
14+
subdomains=(www lb-01 web-01 web-01)
15+
for sub_d in "${subdomains[@]}"; do
16+
response="$(dig "$sub_d.$1" | grep -i -A1 "answer section" | tail -n 1)"
17+
destination="$(echo ""$response"" | awk '{ print $5 }')"
18+
record_type="$(echo """$response""" | awk '{ print $4 }')"
19+
echo "The subdomain ""$sub_d"" is a ""$record_type"" record and points to ""$destination"""
20+
21+
done
22+
fi
23+
624
}
7-
get_a_records;
25+
get_a_records "$1" "$2";

0 commit comments

Comments
 (0)