dotfiles/private_dot_config/private_fish/functions/ping4.fish
Anton Volnuhin af05b9e245 ping: check IPv6 is actually usable, and split ping4 per platform
The ping wrapper only asked whether the *target* had an AAAA record, never
whether this machine could reach over IPv6, so `ping ya.ru` ran ping6 and
died with "No route to host" while IPv4 worked fine.

Checking for a default v6 route is not sufficient either: this Mac has one
while holding only ::1 and fe80:: link-locals. So require a global unicast
address (2000::/3) as well as the route, which is the condition that
actually fails here.

ping4 is now platform-split rather than branching internally, since macOS
ping rejects -4:
  macOS  ~/.local/bin/ping (wrapper) and ~/.local/bin/ping4 -> /sbin/ping
  Linux  a fish function running `ping -4`
.chezmoiignore gates each side so neither lands where it cannot work.
2026-08-06 03:38:12 +03:00

6 lines
218 B
Fish

function ping4 --description 'Ping over IPv4'
# Linux only -- .chezmoiignore keeps this off macOS, where ping has no -4
# flag and ~/.local/bin/ping4 points at /sbin/ping instead.
command ping -4 $argv
end