diff options
author | Bart Schaefer <schaefer@zsh.org> | 2023-05-10 21:17:51 -0700 |
---|---|---|
committer | Bart Schaefer <schaefer@zsh.org> | 2023-05-10 21:17:51 -0700 |
commit | b2421219836d571b4f0ffa9568740922fa7005b8 (patch) | |
tree | 9ef7baa013e8e03e25266a7662422d37fb89bead /Functions | |
parent | 7f2bdf55a3fc09f7615f84119c135458c3e75a74 (diff) | |
download | zsh-b2421219836d571b4f0ffa9568740922fa7005b8.tar.gz zsh-b2421219836d571b4f0ffa9568740922fa7005b8.tar.xz zsh-b2421219836d571b4f0ffa9568740922fa7005b8.zip |
51593: improve search for command name after skipping prefix assignments
This is aimed mostly at use of run-help as a standalone function rather than as a widget. When run-help is invoked outside widget context, there's no source line to search for the original command name, so this attempts searching the arguments.
Diffstat (limited to 'Functions')
-rw-r--r-- | Functions/Misc/run-help | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Functions/Misc/run-help b/Functions/Misc/run-help index 14d09bd65..462044b72 100644 --- a/Functions/Misc/run-help +++ b/Functions/Misc/run-help @@ -58,11 +58,11 @@ do 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} + run_help_orig_cmd=${what[(w)1]} run-help ${what[(w)7]:t} ${(z)${what[(w)8,-1]}} ;; (*( is an alias)*) [[ ${what[(w)6]:t} != ${what[(w)1]} ]] && - run_help_orig_cmd=${what[(w)1]} run-help ${what[(w)6]:t} + run_help_orig_cmd=${what[(w)1]} run-help ${what[(w)6]:t} ${(z)${what[(w)7,-1]}} ;; (*( is a * function)) case ${what[(w)1]} in @@ -103,7 +103,7 @@ do cmd_args=( ${(z)${cmd_args:-"$*"}} ) # Discard the command itself & everything before it. - shift $cmd_args[(i)${run_help_orig_cmd:-$1}] cmd_args || + shift $cmd_args[(i)(${run_help_orig_cmd}|$1)] cmd_args 2>/dev/null || continue # Discard options, parameter assignments & paths. |