mirror of
https://github.com/robbyrussell/oh-my-zsh.git
synced 2026-09-29 14:36:04 +02:00
fix(installer): fail safely on history backup errors
Co-authored-by: robbyrussell <257+robbyrussell@users.noreply.github.com>
This commit is contained in:
co-authored by
robbyrussell
parent
296fbb8b69
commit
6749d0825b
@@ -417,6 +417,14 @@ setup_zshrc() {
|
|||||||
hist_backup="${hist}.pre-oh-my-zsh"
|
hist_backup="${hist}.pre-oh-my-zsh"
|
||||||
if [ -e "$hist_backup" ]; then
|
if [ -e "$hist_backup" ]; then
|
||||||
hist_backup="${hist_backup}-$(date +%Y-%m-%d_%H-%M-%S)"
|
hist_backup="${hist_backup}-$(date +%Y-%m-%d_%H-%M-%S)"
|
||||||
|
if [ -e "$hist_backup" ]; then
|
||||||
|
fmt_error "$hist_backup exists. Can't back up $hist"
|
||||||
|
fmt_error "re-run the installer again in a couple of seconds"
|
||||||
|
if ! mv "$OLD_ZSHRC" "$zdot/.zshrc"; then
|
||||||
|
fmt_error "could not restore $zdot/.zshrc from backup"
|
||||||
|
fi
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
if cp "$hist" "$hist_backup"; then
|
if cp "$hist" "$hist_backup"; then
|
||||||
echo "${FMT_GREEN}Backing up your command history to ${hist_backup}${FMT_RESET}"
|
echo "${FMT_GREEN}Backing up your command history to ${hist_backup}${FMT_RESET}"
|
||||||
@@ -425,6 +433,10 @@ setup_zshrc() {
|
|||||||
# a half-written file would look like a usable backup
|
# a half-written file would look like a usable backup
|
||||||
rm -f "$hist_backup"
|
rm -f "$hist_backup"
|
||||||
fmt_error "could not back up $hist"
|
fmt_error "could not back up $hist"
|
||||||
|
if ! mv "$OLD_ZSHRC" "$zdot/.zshrc"; then
|
||||||
|
fmt_error "could not restore $zdot/.zshrc from backup"
|
||||||
|
fi
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user