#pinger.sh by Leif Messinger
#./pinger.sh [ADDRESS] to search
#./pinger.sh [ADDRESS] & to search in the background
ping_cancelled=false # Keep track of whether the loop was cancelled, or succeeded
until ping -c1 "$1" >/dev/null 2>&1; do :; done & # The "&" backgrounds it
trap "kill $!; ping_cancelled=true" SIGINT
wait $! # Wait for the loop to exit, one way or another
trap - SIGINT # Remove the trap, now we're done with it
if [ "$ping_cancelled" == true ] #https://stackoverflow.com/a/21210966/10141528
printf "The pinger for $1 just closed bro.\n"
printf "$1 IS UP BROOO\a\n"