zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH 1/4] run-help: Support variables in aliases
@ 2023-05-17 22:12 Jörg Sommer
  2023-05-17 22:12 ` [PATCH 2/4] run-help-ip: Reduce the match for link to l Jörg Sommer
                   ` (4 more replies)
  0 siblings, 5 replies; 13+ messages in thread
From: Jörg Sommer @ 2023-05-17 22:12 UTC (permalink / raw)
  To: zsh-workers; +Cc: Jörg Sommer

If the alias definition starts with a variable assignment, run-help fails,
because it sees the variable assignment as command. Hence, skip all
variable assignments and noglob|nocorrect thereafter.

Example:

% alias LCC='LC_ALL=C'
% alias T='LCC true'
% run-help T
---
 Functions/Misc/run-help | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)

diff --git a/Functions/Misc/run-help b/Functions/Misc/run-help
index 462044b72..438f76122 100644
--- a/Functions/Misc/run-help
+++ b/Functions/Misc/run-help
@@ -56,13 +56,28 @@ 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} ${(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} ${(z)${what[(w)7,-1]}}
+        local expansion=( ${${=what}[6,-1]} )
+        while true
+        do
+            if [[ $expansion[1] == *=* ]]
+            then
+                shift expansion
+            elif [[ $expansion[1] == (noglob|nocorrect) ]]
+            then
+                shift expansion
+                break
+            elif [[ $expansion[1] != $1 ]] && alias $expansion[1] >/dev/null
+            then
+                expansion=( ${=$(builtin whence $expansion[1])} $expansion[2,-1] )
+            else
+                break
+            fi
+        done
+
+        expansion[1]=$expansion[1]:t
+        [[ $expansion[1] != ${what[(w)1]} ]] &&
+          run_help_orig_cmd=${what[(w)1]} run-help $expansion[@]
 	;;
     (*( is a * function))
 	case ${what[(w)1]} in
-- 
2.40.1



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2023-09-24  7:32 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-17 22:12 [PATCH 1/4] run-help: Support variables in aliases Jörg Sommer
2023-05-17 22:12 ` [PATCH 2/4] run-help-ip: Reduce the match for link to l Jörg Sommer
2023-05-17 22:12 ` [PATCH 3/4] run-help-openssl: Reduce the code Jörg Sommer
2023-05-17 22:12 ` [PATCH 4/4] run-help for docker, perf, podman, ssh, svnadmin Jörg Sommer
2023-05-31 17:45   ` [PATCH v2] " Jörg Sommer
2023-09-20 22:41     ` Oliver Kiddle
2023-09-23  7:16       ` Jörg Sommer
2023-09-23 15:57         ` Bart Schaefer
2023-09-24  7:31           ` Jörg Sommer
2023-05-17 22:45 ` [PATCH 1/4] run-help: Support variables in aliases Bart Schaefer
2023-05-18  6:52   ` Jörg Sommer
2023-05-18  9:02   ` Peter Stephenson
2023-05-23 16:25 ` [PATCH v2] run-help-openssl: Reduce code and use new manpages Jörg Sommer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).