Skip to content

Commit

Permalink
fix: use correct return code in zinit-confirm
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Doster <mvdoster@gmail.com>
  • Loading branch information
vladdoster committed Feb 13, 2023
1 parent a679bc6 commit d467738
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion doc/zsdoc/zinit-autoload.zsh.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ ____
$2 - expression
____
Has 18 line(s). Calls functions:
Has 17 line(s). Calls functions:
.zinit-confirm
`-- zinit.zsh/+zinit-message
Expand Down
11 changes: 5 additions & 6 deletions zinit-autoload.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -2829,18 +2829,17 @@ builtin print -Pr \"\$ZINIT[col-obj]Done (with the exit code: \$_retval).%f%b\""
# $1 - question
# $2 - expression
.zinit-confirm() {
integer retval
if (( OPTS[opt_-y,--yes] )); then
integer retval
builtin eval "${2}"; retval=$?
(( OPTS[opt_-q,--quiet] )) || +zinit-message -lrP "{log-msg} Action executed (exit code: {num}${?}{rst})"
(( OPTS[opt_-q,--quiet] )) || +zinit-message -lrP "{log-msg} Action executed (exit code: {num}${retval}{rst})"
else
local choice prompt
builtin print -D -v prompt "$(+zinit-message '{log-info} Press [{opt}Y{rst}/{opt}y{rst}] to continue: ')"
builtin print -D -v prompt "$(+zinit-message '{log-info} Press [{opt}Y{rst}/{opt}y{rst}] to continue: {nl}')"
+zinit-message "${1}"
if builtin read -qs "choice?${prompt}"; then
builtin print
builtin eval "${2}"
+zinit-message "{log-msg} Action executed (exit code: {num}${?}{rst})"
builtin eval "${2}"; retval=$?
+zinit-message "{log-msg} Action executed (exit code: {num}${retval}{rst})"
return 0
else
+zinit-message "{log-msg} No action executed ('{opt}${choice}{rst}' not 'Y' or 'y')"
Expand Down

0 comments on commit d467738

Please sign in to comment.