Browse files

Read confirmation from bash/zsh properly, using readline where possible.

  • Loading branch information...
1 parent e470cc0 commit 396319607e3c9a0e5f2c46c38a6929ec68766634 @benhoskings committed Oct 21, 2012
Showing with 12 additions and 2 deletions.
  1. +12 −2 app/views/bootstrap/up.sh.erb
View
14 app/views/bootstrap/up.sh.erb
@@ -9,6 +9,9 @@ ref=<%= ref %>
# So: write a string in which ~$(whoami) is expanded, and run it in a subshell.
home=$(sh -c "echo ~$(whoami)")
+# The name of the shell we're running on.
+shell=$(ps -c -o command -p $$ | tail -n1 | sed -e 's/^\-//')
+
from="https://nodeload.github.com/benhoskings/babushka/tarball/$ref"
to="$home/.babushka/bootstrap"
@@ -105,8 +108,15 @@ welcome() {
if [ "$interactive" = 'true' ]; then
echo ""
- read -p "Sound good? [y/N] " f
- case $f in
+ confirmed=""
+ if [ "$shell" = "zsh" ]; then
+ vared -p "Sound good? [y/N] " confirmed
+ elif [ "$shell" = "bash" ]; then
+ read -e -p "Sound good? [y/N] " confirmed
+ else
+ read -p "Sound good? [y/N] " confirmed
+ fi
+ case $confirmed in
"y"*) true;;
"Y"*) true;;
*) false;;

0 comments on commit 3963196

Please sign in to comment.