From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: zsh-workers-return-43685-ml=inbox.vuxu.org@zsh.org X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 5d0eea1c for ; Fri, 12 Oct 2018 13:41:34 +0000 (UTC) Received: (qmail 19688 invoked by alias); 12 Oct 2018 13:40:50 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 43685 Received: (qmail 9929 invoked by uid 1010); 12 Oct 2018 13:40:50 -0000 X-Qmail-Scanner-Diagnostics: from out3-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(66.111.4.27):SA:0(-2.6/5.0):. Processed in 3.997641 secs); 12 Oct 2018 13:40:50 -0000 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=from:to:subject:date:message-id; s=fm1; bh=L6nTyHjameyHcgZvCOz3bQzmUubzJ84HQMymMEWw7Q0=; b=Pflm8kDB7FFT Q2CLDBokTNqJVGuiK5fefboAJRzmtcsPwRKt5+f7Lp+QtNgAZG+yQULwKO2jEsQG D8WJXl9IADe3Dj8bargKRcRpMQUY3aLG1UrNIpbnxjPDSE0cNq3mhtxM+L5tFCRQ zp5wpuZL9g5YVf2d1cjq5cTc7HGIwmQR+wV29z8Emasnjbe3qpBjMcLfy/vBrCl0 vboKdtupFBRdFZ1z4B/Os2NRMe3vLBYMsHD2qgM7vFLcY53UpiZFT73AvQRX/rs9 cGnE31UIvvxpJ+8QAernmT5gfjxEPtOwQGX6SiA+ASWroE2txNmxtn33XvS2OPC+ Eo6jPwEqNw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=date:from:message-id:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=L6nTyHjameyHcgZvCOz3bQzmUubzJ84HQMymMEWw7Q0=; b=SZW42tzj DJFlPUGyu4qipJArNYYsy3dPbJ5GmyIZdUz1jZz0IBczMBZhALO/dtEYZrmP38N3 SLHhnzzEOScnlkUfJX4zcPyJu3Jn9OIAH16SKwhrj6dlJ/zDxchW8Od0hsOMnT+J Nc7drz+uuM++LUlQErEHZ4aEUHftmzDXiQ8nrt8fQMENtckKOuMMhhWk3TXf2tOf B97JQXPaY/PA6Hr8s3M9Dy8gZLO4uWbW24uU2hN33d3cPJUM/8xtqcMI0X9LhX/U 18ENXEyTmLdJYfxXwzxBO/WtZ5O5FG5z9X8R6eaq4fA4IknttoS5ALh3sC3iFQuu mtMfUyL4KLG/1Q== X-ME-Sender: X-ME-Proxy: From: Daniel Shahaf To: zsh-workers@zsh.org Subject: [PATCH 1/2] add-zle-hook-widget: Support running under NO_UNSET ('set -u'). Date: Fri, 12 Oct 2018 13:40:36 +0000 Message-Id: <20181012134037.16689-1-danielsh@tarpaulin.shahaf.local2> X-Mailer: git-send-email 2.11.0 --- 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