From 180c4c049c60c963378da8f9582937eb1682870e Mon Sep 17 00:00:00 2001 From: Phil Pennock Date: Wed, 7 Aug 2013 03:50:14 -0400 Subject: 31634: run-help compat with alias to noglob/nocorrect 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(+) (limited to 'Functions') diff --git a/Functions/Misc/run-help b/Functions/Misc/run-help index 6a9abb3cf..c817b67d6 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} -- cgit 1.4.1