Created
February 21, 2018 11:29
-
-
Save juanibiapina/88ce944af3608be95f203b5095617988 to your computer and use it in GitHub Desktop.
Helper command to ask for confirmation before running another command (with pipe support)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
cr=`echo $'\n.'` | |
cr=${cr%.} | |
read -p "Do you want to run $*? [N/y]${cr}${cr}" -s -N 1 REPLY | |
if test "$REPLY" = "y" -o "$REPLY" = "Y"; then | |
exec "$@" | |
else | |
>&2 echo "Cancelled by user" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment