mirror of
https://github.com/notwa/rc
synced 2025-02-05 07:43:22 -08:00
improve error handling
This commit is contained in:
parent
4000e091a9
commit
762f7ffe35
1 changed files with 7 additions and 4 deletions
11
install
11
install
|
@ -4,6 +4,7 @@
|
|||
|
||||
VERBOSE=1
|
||||
|
||||
NAME="$0"
|
||||
[ -n "$ZSH_VERSION" -o -n "$BASH" ] || VERBOSE=0 # no colors for you
|
||||
|
||||
note() {
|
||||
|
@ -16,7 +17,7 @@ warn() {
|
|||
}
|
||||
|
||||
die() {
|
||||
warn "$@"
|
||||
warn "$NAME:" "$@"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
@ -118,12 +119,14 @@ softlink() {
|
|||
fi
|
||||
}
|
||||
|
||||
which readlink >/dev/null || exit 1 # sanity check
|
||||
which readlink >/dev/null || die 'failed sanity check (check your $PATH)'
|
||||
|
||||
rc="$(readlink -f "$(dirname "$0")" )"
|
||||
cd "$HOME" || exit 1
|
||||
rc="$(readlink -f "$(dirname "$NAME")" )"
|
||||
[ -d "$rc" ] || die 'failed to determine rc directory'
|
||||
cd "${HOME:?HOME variable empty or unset}" || die 'failed to change directory'
|
||||
|
||||
backup_dir="$rc/backup-$(date -u '+%s')"
|
||||
[ ! -d "$backup_dir" ] || die 'backup directory already exists'
|
||||
|
||||
for f in .bashrc .zshrc .-shrc .prezto-compinit .ls_colors \
|
||||
.vimrc .inputrc .Xresources .screenrc .tmux.conf; do
|
||||
|
|
Loading…
Add table
Reference in a new issue