Created
January 5, 2016 23:57
-
-
Save Alanaktion/0cc19d286a542fed49b6 to your computer and use it in GitHub Desktop.
A basic prompt function for bash scripts
This file contains 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
#!/bin/bash | |
function prompt() { | |
echo -n $1 | |
echo -n " [y/n] " | |
read prompt_response | |
if [ $prompt_response == 'y' ]; then | |
return 0 | |
else | |
return 1 | |
fi | |
} | |
prompt "I can haz cheezburger?" | |
if [ $? == 0 ]; then | |
echo 'Yay, cheezburger!' | |
else | |
echo 'Awww... :(' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment