mirror of
https://github.com/starship/starship.git
synced 2026-06-23 02:05:51 +07:00
feat(install.sh): handle installation directory prompt responses case-insensitively (#6866)
This commit is contained in:
+29
-2
@@ -257,12 +257,18 @@ detect_target() {
|
|||||||
printf '%s' "${target}"
|
printf '%s' "${target}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set_interrupt_handler() {
|
||||||
|
trap 'echo; error "Interrupted (please re-run with the '--yes' option)"; exit 130' INT
|
||||||
|
}
|
||||||
|
|
||||||
confirm() {
|
confirm() {
|
||||||
if [ -z "${FORCE-}" ]; then
|
if [ -z "${FORCE-}" ]; then
|
||||||
|
set_interrupt_handler
|
||||||
printf "%s " "${MAGENTA}?${NO_COLOR} $* ${BOLD}[y/N]${NO_COLOR}"
|
printf "%s " "${MAGENTA}?${NO_COLOR} $* ${BOLD}[y/N]${NO_COLOR}"
|
||||||
set +e
|
set +e
|
||||||
read -r yn </dev/tty
|
read -r yn </dev/tty
|
||||||
|
trap - INT
|
||||||
|
yn=$(echo "$yn" | tr '[:upper:]' '[:lower:]')
|
||||||
rc=$?
|
rc=$?
|
||||||
set -e
|
set -e
|
||||||
if [ $rc -ne 0 ]; then
|
if [ $rc -ne 0 ]; then
|
||||||
@@ -270,8 +276,29 @@ confirm() {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [ "$yn" != "y" ] && [ "$yn" != "yes" ]; then
|
if [ "$yn" != "y" ] && [ "$yn" != "yes" ]; then
|
||||||
error 'Aborting (please answer "yes" to continue)'
|
if [ "$yn" = "n" ] || [ "$yn" = "no" ]; then
|
||||||
exit 1
|
set_interrupt_handler
|
||||||
|
set +e
|
||||||
|
printf "Where would you like to install Starship? ${GREY}(e.g., /usr/local/bin)${NO_COLOR}\n"
|
||||||
|
read -p "> Install Starship ${GREEN}${VERSION}${NO_COLOR} to: " path
|
||||||
|
trap - INT
|
||||||
|
rc=$?
|
||||||
|
set -e
|
||||||
|
BIN_DIR=$path
|
||||||
|
if [ $rc != 0 ] || [ -z "$path" ]; then
|
||||||
|
if [ -z "$path" ]; then
|
||||||
|
echo
|
||||||
|
fi
|
||||||
|
error "Error reading from prompt (please re-run with '--yes' or provide path)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [ -z "$yn" ]; then
|
||||||
|
echo
|
||||||
|
fi
|
||||||
|
error 'Aborting (please answer "yes" to continue)'
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user