* [PATCH 1/2] add-zle-hook-widget: Support running under NO_UNSET ('set -u').
@ 2018-10-12 13:40 Daniel Shahaf
2018-10-12 13:40 ` [PATCH 2/2] add-zle-hook-widget: Add a missing arithmetic evaluation to the new index's computation Daniel Shahaf
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Shahaf @ 2018-10-12 13:40 UTC (permalink / raw)
To: zsh-workers
---
Functions/Misc/add-zle-hook-widget | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/Functions/Misc/add-zle-hook-widget b/Functions/Misc/add-zle-hook-widget
index d8a3950fb..9cc35496f 100644
--- a/Functions/Misc/add-zle-hook-widget
+++ b/Functions/Misc/add-zle-hook-widget
@@ -129,7 +129,7 @@ function add-zle-hook-widget {
else
# Check whether attempting to add a widget named for the hook
if [[ "$fn" = "$hook" ]]; then
- if [[ -n "${widgets[$fn]}" ]]; then
+ if (( ${+widgets[$fn]} )); then
print -u2 "$funcstack[1]: Cannot hook $fn to itself"
return 1
fi
@@ -141,8 +141,8 @@ function add-zle-hook-widget {
integer i=${#options[ksharrays]}-2
zstyle -g extant_hooks "$hook" widgets
# Check for an existing widget, add it as the first hook
- if [[ ${widgets[$hook]} != "user:azhw:$hook" ]]; then
- if [[ -n ${widgets[$hook]} ]]; then
+ if [[ ${widgets[$hook]:-} != "user:azhw:$hook" ]]; then
+ if [[ -n ${widgets[$hook]:-} ]]; then
zle -A "$hook" "${widgets[$hook]}"
extant_hooks=(0:"${widgets[$hook]}" "${extant_hooks[@]}")
fi
@@ -152,17 +152,17 @@ function add-zle-hook-widget {
if [[ -z ${(M)extant_hooks[@]:#(<->:|)$fn} ]]; then
# no index and not already hooked
# assign largest existing index plus 1
- i=${${(On@)${(@M)extant_hooks[@]#<->:}%:}[i]}+1
+ i=${${(On@)${(@M)extant_hooks[@]#<->:}%:}[i]:-0}+1
else
return 0
fi
extant_hooks+=("${i}:${fn}")
zstyle -- "$hook" widgets "${extant_hooks[@]}"
- if [[ -z "${widgets[$fn]}" ]]; then
+ if (( ! ${+widgets[$fn]} )); then
autoload "${autoopts[@]}" -- "$fn"
zle -N -- "$fn"
fi
- if [[ -z "${widgets[$hook]}" ]]; then
+ if (( ! ${+widgets[$hook]} )); then
zle -N "$hook" azhw:"$hook"
fi
fi
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] add-zle-hook-widget: Add a missing arithmetic evaluation to the new index's computation.
2018-10-12 13:40 [PATCH 1/2] add-zle-hook-widget: Support running under NO_UNSET ('set -u') Daniel Shahaf
@ 2018-10-12 13:40 ` Daniel Shahaf
2018-10-12 13:43 ` Daniel Shahaf
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Shahaf @ 2018-10-12 13:40 UTC (permalink / raw)
To: zsh-workers
---
Functions/Misc/add-zle-hook-widget | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Functions/Misc/add-zle-hook-widget b/Functions/Misc/add-zle-hook-widget
index 9cc35496f..121cf0349 100644
--- a/Functions/Misc/add-zle-hook-widget
+++ b/Functions/Misc/add-zle-hook-widget
@@ -152,7 +152,7 @@ function add-zle-hook-widget {
if [[ -z ${(M)extant_hooks[@]:#(<->:|)$fn} ]]; then
# no index and not already hooked
# assign largest existing index plus 1
- i=${${(On@)${(@M)extant_hooks[@]#<->:}%:}[i]:-0}+1
+ (( i = ${${(On@)${(@M)extant_hooks[@]#<->:}%:}[i]:-0} + 1 ))
else
return 0
fi
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 2/2] add-zle-hook-widget: Add a missing arithmetic evaluation to the new index's computation.
2018-10-12 13:40 ` [PATCH 2/2] add-zle-hook-widget: Add a missing arithmetic evaluation to the new index's computation Daniel Shahaf
@ 2018-10-12 13:43 ` Daniel Shahaf
0 siblings, 0 replies; 3+ messages in thread
From: Daniel Shahaf @ 2018-10-12 13:43 UTC (permalink / raw)
To: zsh-workers
Daniel Shahaf wrote on Fri, 12 Oct 2018 13:40 +0000:
> +++ b/Functions/Misc/add-zle-hook-widget
> @@ -152,7 +152,7 @@ function add-zle-hook-widget {
> - i=${${(On@)${(@M)extant_hooks[@]#<->:}%:}[i]:-0}+1
> + (( i = ${${(On@)${(@M)extant_hooks[@]#<->:}%:}[i]:-0} + 1 ))
Never mind, Matthew just pointed out to me that the code was correct
as is (assigning to integers implicitly does evaluation). I'll skip
this patch.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-10-12 13:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-12 13:40 [PATCH 1/2] add-zle-hook-widget: Support running under NO_UNSET ('set -u') Daniel Shahaf
2018-10-12 13:40 ` [PATCH 2/2] add-zle-hook-widget: Add a missing arithmetic evaluation to the new index's computation Daniel Shahaf
2018-10-12 13:43 ` Daniel Shahaf
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).