8908e6d7207223d876b9a74f0be0f0ebb01b361f

Author
Nick Glenn <78454343+Sargates@users.noreply.github.com>
Committer
GitHub <noreply@github.com>
Date

Message

fix(history): fix logic error in prompt for `history -c` (#12500)

Logic error in `history -c` when prompting for confirmation caused history
to be deleted when typing anything but explicitly `n`, `N`, or sending `\n`.
New logic prevents deletion by pressing wrong key and only deletes
history when sending `y` or `Y`.

Co-authored-by: Sargates <nicholas.g.glenn@gmail.com>

Diff

 1diff --git a/lib/history.zsh b/lib/history.zsh
 2index b13e1807fc90a67cae9c600e3850e5b2ef0b2afe..1093ea80fb770c6053b35feac5b79edf82f9ec04 100644
 3--- a/lib/history.zsh
 4+++ b/lib/history.zsh
 5@@ -11,7 +11,7 @@ function omz_history {
 6     print -nu2 "This action will irreversibly delete your command history. Are you sure? [y/N] "
 7     builtin read -k1
 8     [[ "$REPLY" = $'\n' ]] || print -u2
 9-    [[ "$REPLY" != ([nN]|$'\n') ]] || return 0
10+    [[ "$REPLY" != ([yY]) ]] && return 0
11 
12     print -nu2 >| "$HISTFILE"
13     fc -p "$HISTFILE"