From: "Jörg Sommer" <joerg@alea.gnuu.de>
To: zsh-workers@zsh.org
Cc: "Jörg Sommer" <joerg@alea.gnuu.de>
Subject: [PATCH] run-help: ugly workaround for run-help-$X with alias for $X
Date: Mon, 7 Dec 2009 01:57:10 +0100 [thread overview]
Message-ID: <a355a85f3bdb0aac910702825eeb0b302ba155a9.1260147415.git.joerg@alea.gnuu.de> (raw)
If you're very lazy and define an alias for git, e.g. g, and have the
function run-help-git defined, run-help will fail to strip everything up
to the expanded command from the commandline. In the first call of
run-help, the alias g gets expanded to git and run-help is called for
git. But the test of the while loop will never succed, because the
commandline fetched with getln doesn't contain the expanded command git.
Hence everything gets shifted from the array cmd_args until shift cries
forever
run-help:shift:101: shift count must be <= $#
I know, this solution is a dirty hack, but it's quick. The better way is
to fix zsh to call run-help with the whole commandline where the alias
gets expanded and this commandline gets passed to the second run-help
call.
---
Functions/Misc/run-help | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/Functions/Misc/run-help b/Functions/Misc/run-help
index 8e88089..a974664 100644
--- a/Functions/Misc/run-help
+++ b/Functions/Misc/run-help
@@ -56,7 +56,8 @@ do
builtin print -r $what
case $what in
(*( is an alias)*)
- [[ ${what[(w)6]:t} != ${what[(w)1]} ]] && run-help ${what[(w)6]:t}
+ [[ ${what[(w)6]:t} != ${what[(w)1]} ]] \
+ && run_help_orig_cmd=${what[(w)1]} run-help ${what[(w)6]:t}
;;
(*( is a * function))
case ${what[(w)1]} in
@@ -96,10 +97,11 @@ do
builtin print -z "$cmd_args"
cmd_args=( ${(z)cmd_args} )
# Discard environment assignments, etc.
- while [[ $cmd_args[1] != $1 ]]
+ while [[ $cmd_args[1] != ${run_help_orig_cmd:-$1} ]]
do
- shift cmd_args
+ shift cmd_args || exit 1
done
+ unset run_help_orig_cmd
eval "run-help-$1:t ${(qq@)cmd_args[2,-1]}"
else
POSIXLY_CORRECT=1 man $@:t
--
1.6.5
next reply other threads:[~2009-12-07 1:16 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-07 0:57 Jörg Sommer [this message]
2009-12-10 9:49 ` Peter Stephenson
2009-12-16 11:59 ` run-help as a widget Peter Stephenson
2009-12-16 17:14 ` Greg Klanderman
2009-12-18 16:59 ` Jörg Sommer
2009-12-18 23:28 ` Mikael Magnusson
2009-12-14 11:40 [PATCH] run-help: ugly workaround for run-help-$X with alias for $X Jörg Sommer
2009-12-14 13:42 ` Peter Stephenson
2009-12-14 15:50 ` Bart Schaefer
2009-12-14 16:38 ` Andrey Borzenkov
2009-12-14 17:01 ` Bart Schaefer
2009-12-16 10:57 ` Peter Stephenson
2009-12-18 13:51 ` Jörg Sommer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a355a85f3bdb0aac910702825eeb0b302ba155a9.1260147415.git.joerg@alea.gnuu.de \
--to=joerg@alea.gnuu.de \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).