mirror of
https://github.com/notwa/rc
synced 2025-01-03 02:28:08 -08:00
simplify some error-checking syntax
This commit is contained in:
parent
0772cdef9e
commit
74d7d9e207
1 changed files with 12 additions and 19 deletions
31
update
31
update
|
@ -59,17 +59,15 @@ printf >dummy.sha256sum '%s *%s\n' \
|
||||||
1b577383bcfb9f191c785497f4ac34a8fb546807bd1094ef65d0ce9a5a63423e dummy ||
|
1b577383bcfb9f191c785497f4ac34a8fb546807bd1094ef65d0ce9a5a63423e dummy ||
|
||||||
die 'failed to write file'
|
die 'failed to write file'
|
||||||
|
|
||||||
if ! sha256sum -c dummy.sha256sum >/dev/null; then
|
sha256sum -c dummy.sha256sum >/dev/null ||
|
||||||
die 'failed to validate dummy file'
|
die 'failed to validate dummy file'
|
||||||
fi
|
|
||||||
|
|
||||||
clean
|
clean
|
||||||
|
|
||||||
do_clean() { rm update.tar.gz; }
|
do_clean() { rm update.tar.gz; }
|
||||||
|
|
||||||
if ! __obtain_url "$remote" > update.tar.gz; then
|
__obtain_url "$remote" > update.tar.gz ||
|
||||||
die 'failed to download new version'
|
die 'failed to download new version'
|
||||||
fi
|
|
||||||
|
|
||||||
do_clean() { rm -r update.tar.gz _new_$$; }
|
do_clean() { rm -r update.tar.gz _new_$$; }
|
||||||
|
|
||||||
|
@ -86,9 +84,7 @@ rename() {
|
||||||
|
|
||||||
do_clean() { if [ -d _new ]; then rm -r _new_$$ _new; else rm -r _new_$$; fi; }
|
do_clean() { if [ -d _new ]; then rm -r _new_$$ _new; else rm -r _new_$$; fi; }
|
||||||
|
|
||||||
if ! rename; then
|
rename || die 'failed to move update files'
|
||||||
die 'failed to move update files'
|
|
||||||
fi
|
|
||||||
|
|
||||||
do_clean() { rm -r _new _new_$$; }
|
do_clean() { rm -r _new _new_$$; }
|
||||||
|
|
||||||
|
@ -123,7 +119,7 @@ desire() {
|
||||||
(vim/swp/*) false;;
|
(vim/swp/*) false;;
|
||||||
(vim/undo/*) false;;
|
(vim/undo/*) false;;
|
||||||
(*) true
|
(*) true
|
||||||
esac
|
|esac
|
||||||
}
|
}
|
||||||
|
|
||||||
backup() {
|
backup() {
|
||||||
|
@ -138,17 +134,14 @@ backup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
for d in home sh vim; do
|
for d in home sh vim; do
|
||||||
if ! discover "$d" > _new/hashes.txt; then
|
discover "$d" > _new/hashes.txt ||
|
||||||
die 'failed to find new files'
|
die 'failed to find new files'
|
||||||
fi
|
|
||||||
|
|
||||||
if ! different < _new/hashes.txt > _new/updates.txt; then
|
different < _new/hashes.txt > _new/updates.txt ||
|
||||||
die 'failed to compare files'
|
die 'failed to compare files'
|
||||||
fi
|
|
||||||
|
|
||||||
if ! LC_ALL=C sort < _new/updates.txt > _new/sorted.txt; then
|
LC_ALL=C sort < _new/updates.txt > _new/sorted.txt ||
|
||||||
die 'failed to sort file paths'
|
die 'failed to sort file paths'
|
||||||
fi
|
|
||||||
|
|
||||||
while read -r f; do
|
while read -r f; do
|
||||||
desire "$f" || continue
|
desire "$f" || continue
|
||||||
|
|
Loading…
Reference in a new issue