Skip to content

Commit 01a22fe

Browse files
committed
Restore original directory on error
1 parent 1278970 commit 01a22fe

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

history-sync.plugin.zsh

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ history_sync_push() {
271271
[Yy]* )
272272
DIR=$(pwd)
273273
cd "$ZSH_HISTORY_PROJ" && GIT add * && GIT commit -m "$ZSH_HISTORY_COMMIT_MSG"
274+
local status=$?
274275

275276
if [[ $force = false ]]; then
276277
echo -n "$bold_color${fg[yellow]}Do you want to push to remote (y/N)?$reset_color "
@@ -283,19 +284,14 @@ history_sync_push() {
283284
case "$push" in
284285
[Yy]* )
285286
GIT push
286-
if [[ "$?" != 0 ]]; then
287-
_print_git_error_msg
288-
cd "$DIR"
289-
return
290-
fi
291-
cd "$DIR"
287+
status=$?
292288
;;
293289
esac
294290
fi
295291

296-
if [[ "$?" != 0 ]]; then
292+
cd "$DIR"
293+
if [[ "$status" != 0 ]]; then
297294
_print_git_error_msg
298-
cd "$DIR"
299295
return
300296
fi
301297
;;

0 commit comments

Comments
 (0)