Created
September 6, 2013 06:37
-
-
Save jugyo/6460280 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env ruby | |
def ask(message) | |
print "#{message} [Y/n] " | |
case gets.strip | |
when /n/i | |
else | |
yield | |
end | |
end | |
def ask_and_execute(command) | |
ask("`#{command}`") do | |
system command | |
end | |
end | |
# Example | |
ask_and_execute 'cd ~' | |
ask_and_execute 'mkdir bar' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment