mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-23 17:01:05 +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:
parent
7f2bdf55a3
commit
b242121983
2 changed files with 8 additions and 3 deletions
|
@ -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>
|
2023-05-08 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>
|
||||||
|
|
||||||
* 51692: Test/C02cond.ztst: do not skip tests for [[ -r file ]]
|
* 51692: Test/C02cond.ztst: do not skip tests for [[ -r file ]]
|
||||||
|
|
|
@ -58,11 +58,11 @@ do
|
||||||
case $what in
|
case $what in
|
||||||
(*( is an alias for (noglob|nocorrect))*)
|
(*( is an alias for (noglob|nocorrect))*)
|
||||||
[[ ${what[(w)7]:t} != ${what[(w)1]} ]] &&
|
[[ ${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)*)
|
(*( is an alias)*)
|
||||||
[[ ${what[(w)6]:t} != ${what[(w)1]} ]] &&
|
[[ ${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))
|
(*( is a * function))
|
||||||
case ${what[(w)1]} in
|
case ${what[(w)1]} in
|
||||||
|
@ -103,7 +103,7 @@ do
|
||||||
cmd_args=( ${(z)${cmd_args:-"$*"}} )
|
cmd_args=( ${(z)${cmd_args:-"$*"}} )
|
||||||
|
|
||||||
# Discard the command itself & everything before it.
|
# 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
|
continue
|
||||||
|
|
||||||
# Discard options, parameter assignments & paths.
|
# Discard options, parameter assignments & paths.
|
||||||
|
|
Loading…
Reference in a new issue