From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7839 invoked by alias); 7 Aug 2013 08:00:26 -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: X-Seq: 31634 Received: (qmail 5223 invoked from network); 7 Aug 2013 08:00:21 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at spodhuis.org does not designate permitted sender hosts) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=spodhuis.org; s=d201210; h=Message-Id:Date:Subject:To:From; bh=6j9/WgVvGygaG0g2NjLC8Pxthi+22EoWRV6u4F5fcgM=; b=AktuPZw87w5AmQ0h0ds1WzXXhj6iH+Hdp1Icpr3f0Ia85Zt6YwCi+Z4JdUc1dmVyvq0ghTfLpajzjoyc+pT/z1jBR7z7vNDtwHqRyppsuzKVaWuOx5ctDUuqk9Olp+QzkzSDh2Hr+BDHTgJVol7hh6a3PmpJtdI26vHT0DdQi7w=; From: Phil Pennock To: zsh-workers@zsh.org Subject: [PATCH] run-help compat with alias to noglob/nocorrect Date: Wed, 7 Aug 2013 03:50:14 -0400 Message-Id: <1375861814-92270-1-git-send-email-zsh-workers+phil.pennock@spodhuis.org> X-Mailer: git-send-email 1.8.0.1 From: Phil Pennock Given `alias fetch='noglob fetch'`, without this change `run-help fetch` recurses to invoke itself on the noglob command, bringing up the help for noglob. Similarly for nocorrect. Thus the user would have to quit out of the pager, then avoid quitting out of the loop, so that they can go into the second iteration and see the help for the second instance found by `whence -a`, which happens to be the target of the alias. With common pagers, that's thus 'q', 'not-q'. Somewhat frustrating. Without this change, `alias foo='noglob bar'` where `foo` is not otherwise a command would _never_ show the help for `bar`, since it only showed the help for `noglob` and there was no second line of whence output to trigger the second pass. With this change, aliases to `noglob|nocorrect` of a command somewhat ignore the presence of that precommand modifier; if a command is aliased to `noglob $itself`, then the result is that the first line of whence output is shown, no pager is used, the user can immediately see a prompt to continue and press something other-than-q to see the help for the command. If given `alias foo='noglob bar'` then `run-help foo` will immediately show the help for bar. This behaviour was chosen to be consistent with the existing alias support, but just working better with the precommand modifier. --- Functions/Misc/run-help | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Functions/Misc/run-help b/Functions/Misc/run-help index 6a9abb3..c817b67 100644 --- a/Functions/Misc/run-help +++ b/Functions/Misc/run-help @@ -56,6 +56,10 @@ do [[ -n $noalias && $what = *" is an alias "* ]] && continue builtin print -r $what case $what in + (*( is an alias for (noglob|nocorrect))*) + [[ ${what[(w)7]:t} != ${what[(w)1]} ]] && + run_help_orig_cmd=${what[(w)1]} run-help ${what[(w)7]:t} + ;; (*( is an alias)*) [[ ${what[(w)6]:t} != ${what[(w)1]} ]] && run_help_orig_cmd=${what[(w)1]} run-help ${what[(w)6]:t} -- 1.8.0.1