1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-06-19 21:58:04 +02:00

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.
This commit is contained in:
Bart Schaefer 2023-05-10 21:17:51 -07:00
parent 7f2bdf55a3
commit b242121983
2 changed files with 8 additions and 3 deletions
ChangeLog
Functions/Misc

View file

@ -1,3 +1,8 @@
2023-05-10 Bart Schaefer <schaefer@zsh.org>
* 51593: Functions/Misc/run-help: improve search for original
command name after skipping prefix assignments
2023-05-08 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>
* 51692: Test/C02cond.ztst: do not skip tests for [[ -r file ]]

View file

@ -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.