diff options
author | William Boman <[email protected]> | 2022-04-23 09:39:25 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2022-04-23 09:39:25 +0200 |
commit | 84d91bd3be64db5b57744fe8e679da7e45e37055 (patch) | |
tree | 3e14db30e1e89734fae5118bc5181dca8809f99e /utils/installer/install.sh | |
parent | 8fdd4b46e8b91f62c11efd90153623e299748723 (diff) |
feat(installer): ensure correct responses when prompting user (#2506)
Diffstat (limited to 'utils/installer/install.sh')
-rwxr-xr-x | utils/installer/install.sh | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/utils/installer/install.sh b/utils/installer/install.sh index b44880bd..0d56fe30 100755 --- a/utils/installer/install.sh +++ b/utils/installer/install.sh @@ -85,6 +85,25 @@ function msg() { printf "%s\n" "$text" } +function confirm() { + local question="$1" + while true; do + msg "$question" + read -p "[y]es or [n]o (default: no) : " -r answer + case "$answer" in + y | Y | yes | YES | Yes) + return 0 + ;; + n | N | no | NO | No | *[[:blank:]]* | "") + return 1 + ;; + *) + msg "Please answer [y]es or [n]o." + ;; + esac + done +} + function main() { parse_arguments "$@" @@ -97,17 +116,15 @@ function main() { if [ "$ARGS_INSTALL_DEPENDENCIES" -eq 1 ]; then if [ "$INTERACTIVE_MODE" -eq 1 ]; then - msg "Would you like to install LunarVim's NodeJS dependencies?" - read -p "[y]es or [n]o (default: no) : " -r answer - [ "$answer" != "${answer#[Yy]}" ] && install_nodejs_deps - - msg "Would you like to install LunarVim's Python dependencies?" - read -p "[y]es or [n]o (default: no) : " -r answer - [ "$answer" != "${answer#[Yy]}" ] && install_python_deps - - msg "Would you like to install LunarVim's Rust dependencies?" - read -p "[y]es or [n]o (default: no) : " -r answer - [ "$answer" != "${answer#[Yy]}" ] && install_rust_deps + if confirm "Would you like to install LunarVim's NodeJS dependencies?"; then + install_nodejs_deps + fi + if confirm "Would you like to install LunarVim's Python dependencies?"; then + install_python_deps + fi + if confirm "Would you like to install LunarVim's Rust dependencies?"; then + install_rust_deps + fi else install_nodejs_deps install_python_deps |