MIAOU-BASH is a collection of settings and helpers for leveraging BASH. Developer-friendly, it may be used as solo package with or without the miaou project.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

10 lines
396 B

6 months ago
  1. #!/bin/bash
  2. ping_cancelled=false # Keep track of whether the loop was cancelled, or succeeded
  3. until ping -w1 -c1 "$1" >/dev/null 2>&1; do :; done & # The "&" backgrounds it
  4. trap "kill $!; ping_cancelled=true" SIGINT
  5. wait $! # Wait for the loop to exit, one way or another
  6. trap - SIGINT # Remove the trap, now we're done with it
  7. echo "Done pinging, cancelled=$ping_cancelled"