From 1d5ef285eb0e339c6f412c1b03253e16eb470e7f Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Fri, 30 Oct 2015 12:55:44 +0100 Subject: [PATCH] Handle systems where /etc/shells does not exist --- tools/install.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tools/install.sh b/tools/install.sh index 8cba5208..40f507c1 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -24,10 +24,12 @@ main() { # which may fail on systems lacking tput or terminfo set -e - CHECK_ZSH_INSTALLED=$(grep /zsh$ /etc/shells | wc -l) - if [ ! $CHECK_ZSH_INSTALLED -ge 1 ]; then - printf "${YELLOW}Zsh is not installed!${NORMAL} Please install zsh first!\n" - exit + if [ -f /etc/shells ]; then + CHECK_ZSH_INSTALLED=$(grep /zsh$ /etc/shells | wc -l) + if [ ! $CHECK_ZSH_INSTALLED -ge 1 ]; then + printf "${YELLOW}Zsh is not installed!${NORMAL} Please install zsh first!\n" + exit + fi fi unset CHECK_ZSH_INSTALLED @@ -90,12 +92,12 @@ main() { TEST_CURRENT_SHELL=$(expr "$SHELL" : '.*/\(.*\)') if [ "$TEST_CURRENT_SHELL" != "zsh" ]; then # If this platform provides a "chsh" command (not Cygwin), do it, man! - if hash chsh >/dev/null 2>&1; then + if [ -f /etc/shells ] && hash chsh >/dev/null 2>&1; then printf "${BLUE}Time to change your default shell to zsh!${NORMAL}\n" chsh -s $(grep /zsh$ /etc/shells | tail -1) # Else, suggest the user do so manually. else - printf "I can't change your shell automatically because this system does not have chsh.\n" + printf "I can't change your shell automatically because this system does not have chsh and /etc/shells.\n" printf "${BLUE}Please manually change your default shell to zsh!${NORMAL}\n" fi fi