Skip to content

Instantly share code, notes, and snippets.

@isaaclw
Created November 21, 2019 20:42
Show Gist options
  • Save isaaclw/f4e04516425dfd1ef0e2573f0bec87d1 to your computer and use it in GitHub Desktop.
Save isaaclw/f4e04516425dfd1ef0e2573f0bec87d1 to your computer and use it in GitHub Desktop.
Confirm a command
#!/bin/bash
echo -n "Do you want to run '$*'? [N/y] "
read -N 1 REPLY
echo
if test "$REPLY" = "y" -o "$REPLY" = "Y"; then
"$@"
else
echo "Cancelled by user"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment