From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10406 invoked by alias); 7 Dec 2009 01:16:22 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 27473 Received: (qmail 22882 invoked from network); 7 Dec 2009 01:16:10 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received-SPF: pass (ns1.primenet.com.au: SPF record at alea.gnuu.de designates 83.246.114.63 as permitted sender) X-DKIM: Sendmail DKIM Filter v2.5.2 uucp.gnuu.de 69911488035 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=gnuu.de; s=banki; t=1260148568; i=@alea.gnuu.de; bh=Ue90RWt3yS3O6MLgpUXtJJn1AeB+BfrSn GWO83jN89Q=; h=From:To:Cc:Subject:Date:Message-Id; b=YXVVsVTu6a3Jkk 0qox71QpZGvksu4Y+98Uphf0In4VDXWcxmtzLDty5KY0AeBL9sExXMKYQwS2sZxbgvc qf5sDuIqbTnwRyruZtDHtT+wzueh3jSUsluWG0MSs0od6DOe2pxFeWzuxwFFu9QkRAm CP+4Q+BhJUJDZClnZnWFHvQ= From: =?UTF-8?q?J=C3=B6rg=20Sommer?= To: zsh-workers@zsh.org Cc: =?UTF-8?q?J=C3=B6rg=20Sommer?= Subject: [PATCH] run-help: ugly workaround for run-help-$X with alias for $X Date: Mon, 7 Dec 2009 01:57:10 +0100 Message-Id: X-Mailer: git-send-email 1.6.5 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