mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-12-29 00:10:12 +08:00
installer: abstract error messages
This commit is contained in:
parent
576499a5ad
commit
1fdd5351fb
@ -17,6 +17,10 @@ command_exists() {
|
|||||||
command -v "$@" >/dev/null 2>&1
|
command -v "$@" >/dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
error() {
|
||||||
|
echo "Error: $@" >&2
|
||||||
|
}
|
||||||
|
|
||||||
# Set up color sequences
|
# Set up color sequences
|
||||||
setup_color() {
|
setup_color() {
|
||||||
if command_exists tput; then
|
if command_exists tput; then
|
||||||
@ -54,20 +58,18 @@ setup_ohmyzsh() {
|
|||||||
echo "${BLUE}Cloning Oh My Zsh...${NORMAL}"
|
echo "${BLUE}Cloning Oh My Zsh...${NORMAL}"
|
||||||
|
|
||||||
command_exists git || {
|
command_exists git || {
|
||||||
echo "Error: git is not installed"
|
error "git is not installed"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ "$OSTYPE" = cygwin ] && git --version | grep -q msysgit; then
|
if [ "$OSTYPE" = cygwin ] && git --version | grep -q msysgit; then
|
||||||
cat <<-EOF
|
error "Windows/MSYS Git is not supported on Cygwin"
|
||||||
Error: Windows/MSYS Git is not supported on Cygwin
|
error "Make sure the Cygwin git package is installed and is first on the \$PATH"
|
||||||
Error: Make sure the Cygwin git package is installed and is first on the $PATH
|
|
||||||
EOF
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git clone --depth=1 https://github.com/robbyrussell/oh-my-zsh.git "$ZSH" || {
|
git clone --depth=1 https://github.com/robbyrussell/oh-my-zsh.git "$ZSH" || {
|
||||||
echo "Error: git clone of oh-my-zsh repo failed"
|
error "git clone of oh-my-zsh repo failed"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -96,7 +98,7 @@ setup_shell() {
|
|||||||
if command_exists chsh; then
|
if command_exists chsh; then
|
||||||
echo "${BLUE}Time to change your default shell to zsh!${NORMAL}"
|
echo "${BLUE}Time to change your default shell to zsh!${NORMAL}"
|
||||||
if ! chsh -s $(grep /zsh$ /etc/shells | tail -1); then
|
if ! chsh -s $(grep /zsh$ /etc/shells | tail -1); then
|
||||||
echo "Error: chsh command unsuccessful. Change your default shell manually."
|
error "chsh command unsuccessful. Change your default shell manually."
|
||||||
fi
|
fi
|
||||||
# Else, suggest the user do so manually.
|
# Else, suggest the user do so manually.
|
||||||
else
|
else
|
||||||
@ -119,7 +121,7 @@ main() {
|
|||||||
if [ -d "$ZSH" ]; then
|
if [ -d "$ZSH" ]; then
|
||||||
cat <<-EOF
|
cat <<-EOF
|
||||||
${YELLOW}You already have Oh My Zsh installed.${NORMAL}
|
${YELLOW}You already have Oh My Zsh installed.${NORMAL}
|
||||||
You'll need to remove $ZSH if you want to reinstall.
|
You'll need to remove '$ZSH' if you want to reinstall.
|
||||||
EOF
|
EOF
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user