Skip to content

Commit

Permalink
internet reverse reorder and keep unique (fixes #2137)
Browse files Browse the repository at this point in the history
  • Loading branch information
JLKwong committed Mar 26, 2021
1 parent e6f025c commit 06d7fd0
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions modules/internet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ function internet {
fi
info="$(curl -s ipinfo.io | grep -o '"[^"]*"\s*:\s*"[^"]*"')"
echo "$info" | grep -E '"(ip)"'
echo "$info" | grep -E '"(org)"'
if ! echo "$info" | grep -E 'postal'; then
echo "$info" | grep -E '"(city|country)"' | tr '\n' ',' | sed 's/,$/, "postal": "n\/a"\n/' | sed 's/\",\"/\", \"/g'
echo "$info" | grep -E '"(country|city)"' | tr '\n' ',' | sed 's/,$/, "postal": "n\/a"\n/' | sed 's/\",\"/\", \"/g'
else
echo "$info" | grep -E '"(city|country|postal)"' | tr '\n' ',' | sed 's/,$/\n/' | sed 's/\",\"/\", \"/g'
echo "$info" | grep -E '"(country|city|postal)"' | tr '\n' ',' | sed 's/,$/\n/' | sed 's/\",\"/\", \"/g'
fi
echo "$info" | grep -E '"(org|timezone)"'
echo "$info" | grep -E '"(timezone)"'
;;
*)
log_help_and_exit1 "ERROR: incorrect command" internet
Expand Down

0 comments on commit 06d7fd0

Please sign in to comment.