fix(setup): improve error handling
This commit is contained in:
@@ -87,7 +87,7 @@ remove_symlink() {
|
|||||||
error "object to be removed is not a symlink:"
|
error "object to be removed is not a symlink:"
|
||||||
error "${link}: $(stat -c '%F' -- "$link")"
|
error "${link}: $(stat -c '%F' -- "$link")"
|
||||||
|
|
||||||
return
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,13 +107,13 @@ create_symlink() {
|
|||||||
if test -z "$1"; then
|
if test -z "$1"; then
|
||||||
error "missing src argument:"
|
error "missing src argument:"
|
||||||
error "$0 $1 $2"
|
error "$0 $1 $2"
|
||||||
return
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test -z "$2"; then
|
if test -z "$2"; then
|
||||||
error "missing dst argument:"
|
error "missing dst argument:"
|
||||||
error "$0 $1 $2"
|
error "$0 $1 $2"
|
||||||
return
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
src="${SCRIPT_DIR}/$1"
|
src="${SCRIPT_DIR}/$1"
|
||||||
@@ -123,7 +123,7 @@ create_symlink() {
|
|||||||
if ! test -e "$src"; then
|
if ! test -e "$src"; then
|
||||||
error "the following source path does not exist:"
|
error "the following source path does not exist:"
|
||||||
error "$src"
|
error "$src"
|
||||||
return
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! test -d "$dst_parent"; then
|
if ! test -d "$dst_parent"; then
|
||||||
@@ -133,18 +133,22 @@ create_symlink() {
|
|||||||
|
|
||||||
if test -L "$dst"; then
|
if test -L "$dst"; then
|
||||||
if $FORCE; then
|
if $FORCE; then
|
||||||
|
if test "$(readlink -f "$dst")" != "$src"; then
|
||||||
remove_symlink "$2"
|
remove_symlink "$2"
|
||||||
|
else
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
elif $IGNORE_EXISTING; then
|
elif $IGNORE_EXISTING; then
|
||||||
return
|
return 0
|
||||||
else
|
else
|
||||||
error "path already exists:"
|
error "path already exists:"
|
||||||
error "$dst"
|
error "$dst"
|
||||||
return
|
return 1
|
||||||
fi
|
fi
|
||||||
elif test -e "$dst"; then
|
elif test -e "$dst"; then
|
||||||
error "path already exists and is not a symlink:"
|
error "path already exists and is not a symlink:"
|
||||||
error "${dst}: $(stat -c '%F' -- "$dst")"
|
error "${dst}: $(stat -c '%F' -- "$dst")"
|
||||||
return
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Creating link: $dst -> $src"
|
echo "Creating link: $dst -> $src"
|
||||||
@@ -164,10 +168,7 @@ create_all_symlinks() {
|
|||||||
check_terminfo() {
|
check_terminfo() {
|
||||||
if ! infocmp tmux-256color > /dev/null; then
|
if ! infocmp tmux-256color > /dev/null; then
|
||||||
error "Missing terminfo for tmux-256color. Try installing ncurses-term."
|
error "Missing terminfo for tmux-256color. Try installing ncurses-term."
|
||||||
fi
|
return 1
|
||||||
|
|
||||||
if $ERROR; then
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user