Add while block to allow correct choice

pull/641/head
Daniele Andreoli 2016-01-07 09:23:36 +01:00
parent 55245cc98e
commit fdc75e42b9
1 changed files with 22 additions and 16 deletions

View File

@ -32,22 +32,28 @@ if [ -e "$HOME/$BACKUP_FILE" ]; then
done done
fi fi
read -e -n 1 -r -p "Would you like to keep your $CONFIG_FILE and append bash-it templates at the end? [y/N] " choice while true
case $choice in do
[yY]) read -e -n 1 -r -p "Would you like to keep your $CONFIG_FILE and append bash-it templates at the end? [y/N] " choice
(sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" || tail -n +2) >> "$HOME/$CONFIG_FILE" case $choice in
echo -e "\033[0;32mBash-it template has been added to your $CONFIG_FILE\033[0m" [yY])
;; (sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" || tail -n +2) >> "$HOME/$CONFIG_FILE"
[nN]|"") echo -e "\033[0;32mBash-it template has been added to your $CONFIG_FILE\033[0m"
test -w "$HOME/$CONFIG_FILE" && break
cp -aL "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.bak" && ;;
echo -e "\033[0;32mYour original $CONFIG_FILE has been backed up to $CONFIG_FILE.bak\033[0m" [nN]|"")
sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" > "$HOME/$CONFIG_FILE" test -w "$HOME/$CONFIG_FILE" &&
;; cp -aL "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.bak" &&
*) echo -e "\033[0;32mYour original $CONFIG_FILE has been backed up to $CONFIG_FILE.bak\033[0m"
echo -e "\033[91mPlease choose y or n.\033[m" sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" > "$HOME/$CONFIG_FILE"
;; break
esac ;;
*)
echo -e "\033[91mPlease choose y or n.\033[m"
;;
esac
done
echo -e "\033[0;32mCopied the template $CONFIG_FILE into ~/$CONFIG_FILE, edit this file to customize bash-it\033[0m" echo -e "\033[0;32mCopied the template $CONFIG_FILE into ~/$CONFIG_FILE, edit this file to customize bash-it\033[0m"