From b1bc2a04a4679659c69b35b8f24ea161b5d828fa Mon Sep 17 00:00:00 2001 From: Diego Jornada Date: Wed, 12 Feb 2020 23:13:21 -0300 Subject: [PATCH] feat(installer): Ask for permission escalation during installation, if needed (#914) --- install/install.sh | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/install/install.sh b/install/install.sh index 298a3da1..bc190fda 100755 --- a/install/install.sh +++ b/install/install.sh @@ -82,6 +82,24 @@ fetch() { fi } +install() { + local sudo + local msg + if [ -w "$BIN_DIR" ]; then + sudo="" + msg="Installing Starship, please wait…" + else + warn "Escalated permission are required to install to ${BIN_DIR}" + sudo -v || (error "Aborting installation (Please provide root password)";exit 1) + sudo="sudo" + msg="Installing Starship as root, please wait…" + fi + info "$msg" + fetch "${URL}" \ + | ${sudo} tar xzf${VERBOSE} - \ + -C "${BIN_DIR}" +} + # Currently supporting: # - win (Git Bash) # - darwin @@ -238,13 +256,9 @@ info "Tarball URL: ${UNDERLINE}${BLUE}${URL}${NO_COLOR}" check_bin_dir "${BIN_DIR}" confirm "Install Starship ${GREEN}latest${NO_COLOR} to ${BOLD}${GREEN}${BIN_DIR}${NO_COLOR}?" -info "Installing Starship, please wait…" - -fetch "${URL}" \ - | tar xzf${VERBOSE} - \ - -C "${BIN_DIR}" - +install complete "Starship installed" + echo info "Please follow the steps for your shell to complete the installation: