Improve choice messages and loop until proper answer is given
This commit is contained in:
parent
5d323c1140
commit
b3feba0cd4
@ -96,41 +96,33 @@ if [ -z "${BOOTSTRAP_HASKELL_NONINTERACTIVE}" ] ; then
|
|||||||
echo "You may want to source '$GHCUP_INSTALL_BASE_PREFIX/.ghcup/env' in your shell"
|
echo "You may want to source '$GHCUP_INSTALL_BASE_PREFIX/.ghcup/env' in your shell"
|
||||||
echo "configuration to do so (e.g. ~/.bashrc)."
|
echo "configuration to do so (e.g. ~/.bashrc)."
|
||||||
|
|
||||||
if [ -e "$HOME/.bashrc" ] ; then
|
if [ -f "$HOME/.bashrc" ] ; then
|
||||||
printf "\\033[0;35m%s\\033[0m\\n" ""
|
GHCUP_PROFILE_FILE="$HOME/.bashrc"
|
||||||
printf "\\033[0;35m%s\\033[0m\\n" "Detected ~/.bashrc on your system..."
|
elif [ -f "$HOME/.bash_profile" ] ; then
|
||||||
printf "\\033[0;35m%s\\033[0m\\n" "If you want ghcup to automatically fix your ~/.bashrc to include the required PATH variable"
|
GHCUP_PROFILE_FILE="$HOME/.bash_profile"
|
||||||
printf "\\033[0;35m%s\\033[0m\\n" "answer with YES and press ENTER."
|
fi
|
||||||
printf "\\033[0;35m%s\\033[0m\\n" "Otherwise press ctrl-c to abort."
|
|
||||||
printf "\\033[0;35m%s\\033[0m\\n" ""
|
|
||||||
|
|
||||||
read -r next_answer </dev/tty
|
if [ -n "${GHCUP_PROFILE_FILE}" ] && [ -f "${GHCUP_PROFILE_FILE}" ] ; then
|
||||||
|
printf "\\033[0;35m%s\\033[0m\\n" ""
|
||||||
|
printf "\\033[0;35m%s\\033[0m\\n" "Detected \"${GHCUP_PROFILE_FILE}\" on your system..."
|
||||||
|
printf "\\033[0;35m%s\\033[0m\\n" "If you want ghcup to automatically fix your \"${GHCUP_PROFILE_FILE}\" to include the required PATH variable"
|
||||||
|
printf "\\033[0;35m%s\\033[0m\\n" "answer with YES, otherwise with NO and press ENTER."
|
||||||
|
printf "\\033[0;35m%s\\033[0m\\n" ""
|
||||||
|
|
||||||
case $next_answer in
|
while true; do
|
||||||
[Yy]*)
|
read -r next_answer </dev/tty
|
||||||
echo "source $GHCUP_INSTALL_BASE_PREFIX/.ghcup/env" >> "${HOME}/.bashrc"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
exit 0;;
|
|
||||||
esac
|
|
||||||
elif [ -e "$HOME/.bash_profile" ] ; then
|
|
||||||
printf "\\033[0;35m%s\\033[0m\\n" ""
|
|
||||||
printf "\\033[0;35m%s\\033[0m\\n" "Detected ~/.bash_profile on your system..."
|
|
||||||
printf "\\033[0;35m%s\\033[0m\\n" "If you want ghcup to automatically fix your ~/.bash_profile to include the required PATH variable"
|
|
||||||
printf "\\033[0;35m%s\\033[0m\\n" "answer with YES and press ENTER."
|
|
||||||
printf "\\033[0;35m%s\\033[0m\\n" "Otherwise press ctrl-c to abort."
|
|
||||||
printf "\\033[0;35m%s\\033[0m\\n" ""
|
|
||||||
|
|
||||||
read -r next_answer </dev/tty
|
case $next_answer in
|
||||||
|
[Yy]*)
|
||||||
case $next_answer in
|
echo "source $GHCUP_INSTALL_BASE_PREFIX/.ghcup/env" >> "${GHCUP_PROFILE_FILE}"
|
||||||
[Yy]*)
|
exit 0;;
|
||||||
echo "source $GHCUP_INSTALL_BASE_PREFIX/.ghcup/env" >> "${HOME}/.bash_profile"
|
[Nn]*)
|
||||||
;;
|
exit 0;;
|
||||||
*)
|
*)
|
||||||
exit 0;;
|
echo "Please type YES or NO and press enter.";;
|
||||||
esac
|
esac
|
||||||
fi
|
done
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user