From cc2c83c998a252ac9242c49c5399164b786e6b5d Mon Sep 17 00:00:00 2001 From: Ken Matsui <26405363+ken-matsui@users.noreply.github.com> Date: Mon, 18 Nov 2024 18:52:23 -0500 Subject: [PATCH] install.sh: use case --- install.sh | 52 +++++++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/install.sh b/install.sh index 8871cdc..3aeae7b 100644 --- a/install.sh +++ b/install.sh @@ -4,31 +4,37 @@ set -eu cd $HOME echo 'Installing dotfiles ...' -if [ "$(uname)" == Darwin ]; then - # Ask for the administrator password upfront - printf 'Password for your PC [\e[32m?\e[m] ' && sudo -v - # Keep-alive: update existing `sudo` time stamp until this script has finished - while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null & - echo '' - - echo 'Installing Xcode command line tools ...' - check="$(xcode-select --install 2>&1)" - str='xcode-select: note: install requested for command line developer tools' - while [ "$check" == "$str" ]; do +case "$(uname)" in + Darwin) + # Ask for the administrator password upfront + printf 'Password for your PC [\e[32m?\e[m] ' && sudo -v + # Keep-alive: update existing `sudo` time stamp until this script has finished + while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null & + echo '' + + echo 'Installing Xcode command line tools ...' check="$(xcode-select --install 2>&1)" - sleep 1 - done -elif [ "$(uname)" == Linux ]; then - # https://askubuntu.com/a/459425 - local _distrotype="$(awk -F= '/^NAME/{print $2}' /etc/os-release)" - if [ "$_distrotype" != '"Manjaro Linux"' ]; then - echo "$_distrotype is not supported." + str='xcode-select: note: install requested for command line developer tools' + while [ "$check" == "$str" ]; do + check="$(xcode-select --install 2>&1)" + sleep 1 + done + ;; + + Linux) + # https://askubuntu.com/a/459425 + local _distrotype="$(awk -F= '/^NAME/{print $2}' /etc/os-release)" + if [ "$_distrotype" != '"Manjaro Linux"' ]; then + echo "$_distrotype is not supported." + exit 1 + fi + ;; + + *) + echo "'$(uname)' is not supported." exit 1 - fi -else - echo "'$(uname)' is not supported." - exit 1 -fi + ;; +esac echo 'Downloading ken-matsui/dotfiles ...' git clone https://github.com/ken-matsui/dotfiles.git