From c7221c5f257fc42ec8f6c6a6463bc8a5da25b00f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Mon, 24 Jan 2022 15:41:40 +0100 Subject: [PATCH] style(installer): prefix formatting variables with `FMT_` --- tools/install.sh | 78 ++++++++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/tools/install.sh b/tools/install.sh index d3f1ee640..b4b90a62d 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -190,24 +190,24 @@ fmt_code() { } fmt_error() { - printf '%sError: %s%s\n' "$BOLD$RED" "$*" "$RESET" >&2 + printf '%sError: %s%s\n' "${FMT_BOLD}${FMT_RED}" "$*" "$FMT_RESET" >&2 } setup_color() { # Only use colors if connected to a terminal if ! is_tty; then - RAINBOW="" - RED="" - GREEN="" - YELLOW="" - BLUE="" - BOLD="" - RESET="" + FMT_RAINBOW="" + FMT_RED="" + FMT_GREEN="" + FMT_YELLOW="" + FMT_BLUE="" + FMT_BOLD="" + FMT_RESET="" return fi if supports_truecolor; then - RAINBOW=" + FMT_RAINBOW=" $(printf '\033[38;2;255;0;0m') $(printf '\033[38;2;255;97;0m') $(printf '\033[38;2;247;255;0m') @@ -217,7 +217,7 @@ setup_color() { $(printf '\033[38;2;245;0;172m') " else - RAINBOW=" + FMT_RAINBOW=" $(printf '\033[38;5;196m') $(printf '\033[38;5;202m') $(printf '\033[38;5;226m') @@ -228,12 +228,12 @@ setup_color() { " fi - RED=$(printf '\033[31m') - GREEN=$(printf '\033[32m') - YELLOW=$(printf '\033[33m') - BLUE=$(printf '\033[34m') - BOLD=$(printf '\033[1m') - RESET=$(printf '\033[0m') + FMT_RED=$(printf '\033[31m') + FMT_GREEN=$(printf '\033[32m') + FMT_YELLOW=$(printf '\033[33m') + FMT_BLUE=$(printf '\033[34m') + FMT_BOLD=$(printf '\033[1m') + FMT_RESET=$(printf '\033[0m') } setup_ohmyzsh() { @@ -244,7 +244,7 @@ setup_ohmyzsh() { # precedence over umasks except for filesystems mounted with option "noacl". umask g-w,o-w - echo "${BLUE}Cloning Oh My Zsh...${RESET}" + echo "${FMT_BLUE}Cloning Oh My Zsh...${FMT_RESET}" command_exists git || { fmt_error "git is not installed" @@ -276,14 +276,14 @@ setup_zshrc() { # Keep most recent old .zshrc at .zshrc.pre-oh-my-zsh, and older ones # with datestamp of installation that moved them aside, so we never actually # destroy a user's original zshrc - echo "${BLUE}Looking for an existing zsh config...${RESET}" + echo "${FMT_BLUE}Looking for an existing zsh config...${FMT_RESET}" # Must use this exact name so uninstall.sh can find it OLD_ZSHRC=~/.zshrc.pre-oh-my-zsh if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then # Skip this if the user doesn't want to replace an existing .zshrc if [ "$KEEP_ZSHRC" = yes ]; then - echo "${YELLOW}Found ~/.zshrc.${RESET} ${GREEN}Keeping...${RESET}" + echo "${FMT_YELLOW}Found ~/.zshrc.${FMT_RESET} ${FMT_GREEN}Keeping...${FMT_RESET}" return fi if [ -e "$OLD_ZSHRC" ]; then @@ -295,14 +295,14 @@ setup_zshrc() { fi mv "$OLD_ZSHRC" "${OLD_OLD_ZSHRC}" - echo "${YELLOW}Found old ~/.zshrc.pre-oh-my-zsh." \ - "${GREEN}Backing up to ${OLD_OLD_ZSHRC}${RESET}" + echo "${FMT_YELLOW}Found old ~/.zshrc.pre-oh-my-zsh." \ + "${FMT_GREEN}Backing up to ${OLD_OLD_ZSHRC}${FMT_RESET}" fi - echo "${YELLOW}Found ~/.zshrc.${RESET} ${GREEN}Backing up to ${OLD_ZSHRC}${RESET}" + echo "${FMT_YELLOW}Found ~/.zshrc.${FMT_RESET} ${FMT_GREEN}Backing up to ${OLD_ZSHRC}${FMT_RESET}" mv ~/.zshrc "$OLD_ZSHRC" fi - echo "${GREEN}Using the Oh My Zsh template file and adding it to ~/.zshrc.${RESET}" + echo "${FMT_GREEN}Using the Oh My Zsh template file and adding it to ~/.zshrc.${FMT_RESET}" # Replace $HOME path with '$HOME' in $ZSH variable in .zshrc file omz=$(echo "$ZSH" | sed "s|^$HOME/|\$HOME/|") @@ -327,16 +327,16 @@ setup_shell() { if ! command_exists chsh; then cat <