Skip to content
This repository has been archived by the owner on Jan 6, 2021. It is now read-only.

Commit

Permalink
Read confirmation from bash/zsh properly, using readline where possible.
Browse files Browse the repository at this point in the history
  • Loading branch information
benhoskings committed Oct 21, 2012
1 parent e470cc0 commit 3963196
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions app/views/bootstrap/up.sh.erb
Expand Up @@ -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"

Expand Down Expand Up @@ -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;;
Expand Down

0 comments on commit 3963196

Please sign in to comment.