diff options
author | Marc Cornellà <hello@mcornella.com> | 2023-01-26 20:45:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-26 20:45:48 +0100 |
commit | e55e3f0f56ab4df21eb33e19569c295e7e5e71a4 (patch) | |
tree | aa1c0373fc6600ffe2075a5162d445efee9a2025 /plugins | |
parent | 657ad0523d5a29e0bdc8af0cd63c23ac597406e8 (diff) | |
download | zsh-e55e3f0f56ab4df21eb33e19569c295e7e5e71a4.tar.gz zsh-e55e3f0f56ab4df21eb33e19569c295e7e5e71a4.tar.bz2 zsh-e55e3f0f56ab4df21eb33e19569c295e7e5e71a4.zip |
fix(systemadmin): handle error for no IPv6 route in `geteip` (#11458)
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/systemadmin/systemadmin.plugin.zsh | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/plugins/systemadmin/systemadmin.plugin.zsh b/plugins/systemadmin/systemadmin.plugin.zsh index 9b5159ff1..7ce62bac1 100644 --- a/plugins/systemadmin/systemadmin.plugin.zsh +++ b/plugins/systemadmin/systemadmin.plugin.zsh @@ -140,7 +140,13 @@ function d0() { # gather external ip address function geteip() { curl -s -S -4 https://icanhazip.com - curl -s -S -6 https://icanhazip.com + + # handle case when there is no IPv6 external IP, which shows error + # curl: (7) Couldn't connect to server + curl -s -S -6 https://icanhazip.com 2>/dev/null + local ret=$? + (( ret == 7 )) && print -P -u2 "%F{red}error: no IPv6 route to host%f" + return $ret } # determine local IP address(es) |