eef04c62c2dfbd81f9fee6752e3b7e0b9c3bf617

Author
Marc Cornellà <marc.cornella@live.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

fix(installer): fix error message if $ZSH exists when installing

Also prefix all formatting functions with fmt_

Related: #9427

Diff

This diff is truncated to protect this page.

  1diff --git a/.editorconfig b/.editorconfig
  2index aa18e0e5cde98f57ffe1ea57610902d37993ae2d..b5321de59eab105519a7635c51dd5e67655b9e80 100644
  3--- a/.editorconfig
  4+++ b/.editorconfig
  5@@ -4,7 +4,5 @@ root = true
  6 end_of_line = lf
  7 insert_final_newline = true
  8 charset = utf-8
  9-
 10-[*.sh]
 11-indent_size = 4
 12-indent_style = tab
 13+indent_size = 2
 14+indent_style = space
 15diff --git a/tools/install.sh b/tools/install.sh
 16index 61b21cb9eadfc0b75d89485eee60a3dfd932c5ea..953c68baf78692f7a8e07c6fe2d507a54da46510 100755
 17--- a/tools/install.sh
 18+++ b/tools/install.sh
 19@@ -37,6 +37,9 @@
 20 #
 21 set -e
 22 
 23+# Track if $ZSH was provided
 24+custom_zsh=${ZSH:+yes}
 25+
 26 # Default settings
 27 ZSH=${ZSH:-~/.oh-my-zsh}
 28 REPO=${REPO:-ohmyzsh/ohmyzsh}
 29@@ -53,12 +56,16 @@ command_exists() {
 30 	command -v "$@" >/dev/null 2>&1
 31 }
 32 
 33-error() {
 34-	echo ${RED}"Error: $@"${RESET} >&2
 35+fmt_error() {
 36+  echo ${RED}"Error: $@"${RESET} >&2
 37+}
 38+
 39+fmt_underline() {
 40+  echo "$(printf '\033[4m')$@$(printf '\033[24m')"
 41 }
 42 
 43-underline() {
 44-	echo "$(printf '\033[4m')$@$(printf '\033[24m')"
 45+fmt_code() {
 46+  echo "\`$(printf '\033[38;5;247m')$@${RESET}\`"
 47 }
 48 
 49 setup_color() {
 50@@ -81,71 +88,71 @@ setup_color() {
 51 }
 52 
 53 setup_ohmyzsh() {
 54-	# Prevent the cloned repository from having insecure permissions. Failing to do
 55-	# so causes compinit() calls to fail with "command not found: compdef" errors
 56-	# for users with insecure umasks (e.g., "002", allowing group writability). Note
 57-	# that this will be ignored under Cygwin by default, as Windows ACLs take
 58-	# precedence over umasks except for filesystems mounted with option "noacl".
 59-	umask g-w,o-w
 60-
 61-	echo "${BLUE}Cloning Oh My Zsh...${RESET}"
 62-
 63-	command_exists git || {
 64-		error "git is not installed"
 65-		exit 1
 66-	}
 67-
 68-	if [ "$OSTYPE" = cygwin ] && git --version | grep -q msysgit; then
 69-		error "Windows/MSYS Git is not supported on Cygwin"
 70-		error "Make sure the Cygwin git package is installed and is first on the \$PATH"
 71-		exit 1
 72-	fi
 73-
 74-	git clone -c core.eol=lf -c core.autocrlf=false \
 75-		-c fsck.zeroPaddedFilemode=ignore \
 76-		-c fetch.fsck.zeroPaddedFilemode=ignore \
 77-		-c receive.fsck.zeroPaddedFilemode=ignore \
 78-		--depth=1 --branch "$BRANCH" "$REMOTE" "$ZSH" || {
 79-		error "git clone of oh-my-zsh repo failed"
 80-		exit 1
 81-	}
 82-
 83-	echo
 84+  # Prevent the cloned repository from having insecure permissions. Failing to do
 85+  # so causes compinit() calls to fail with "command not found: compdef" errors
 86+  # for users with insecure umasks (e.g., "002", allowing group writability). Note
 87+  # that this will be ignored under Cygwin by default, as Windows ACLs take
 88+  # precedence over umasks except for filesystems mounted with option "noacl".
 89+  umask g-w,o-w
 90+
 91+  echo "${BLUE}Cloning Oh My Zsh...${RESET}"
 92+
 93+  command_exists git || {
 94+    fmt_error "git is not installed"
 95+    exit 1
 96+  }
 97+
 98+  if [ "$OSTYPE" = cygwin ] && git --version | grep -q msysgit; then
 99+    fmt_error "Windows/MSYS Git is not supported on Cygwin"
100+    fmt_error "Make sure the Cygwin git package is installed and is first on the \$PATH"
101+    exit 1
102+  fi
103+
104+  git clone -c core.eol=lf -c core.autocrlf=false \
105+    -c fsck.zeroPaddedFilemode=ignore \
106+    -c fetch.fsck.zeroPaddedFilemode=ignore \
107+    -c receive.fsck.zeroPaddedFilemode=ignore \
108+    --depth=1 --branch "$BRANCH" "$REMOTE" "$ZSH" || {
109+    fmt_error "git clone of oh-my-zsh repo failed"
110+    exit 1
111+  }
112+
113+  echo
114 }
115 
116 setup_zshrc() {
117-	# Keep most recent old .zshrc at .zshrc.pre-oh-my-zsh, and older ones
118-	# with datestamp of installation that moved them aside, so we never actually