From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2106 invoked from network); 31 Dec 2007 04:02:40 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.3 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 31 Dec 2007 04:02:40 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 88212 invoked from network); 31 Dec 2007 04:02:31 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 31 Dec 2007 04:02:31 -0000 Received: (qmail 10666 invoked by alias); 31 Dec 2007 04:02:27 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 24328 Received: (qmail 10649 invoked from network); 31 Dec 2007 04:02:27 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 31 Dec 2007 04:02:27 -0000 Received: from virusfilter.dotsrc.org (bifrost [127.0.0.1]) by spamfilter.dotsrc.org (Postfix) with ESMTP id B53AA8058FA9 for ; Mon, 31 Dec 2007 05:02:24 +0100 (CET) Received: from vms046pub.verizon.net (vms046pub.verizon.net [206.46.252.46]) by bifrost.dotsrc.org (Postfix) with ESMTP for ; Mon, 31 Dec 2007 05:02:24 +0100 (CET) Received: from torch.brasslantern.com ([71.121.18.67]) by vms046.mailsrvcs.net (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) with ESMTPA id <0JTW004YPB7MRYK0@vms046.mailsrvcs.net> for zsh-workers@sunsite.dk; Sun, 30 Dec 2007 22:02:13 -0600 (CST) Received: from torch.brasslantern.com (localhost.localdomain [127.0.0.1]) by torch.brasslantern.com (8.13.1/8.13.1) with ESMTP id lBV425IL032488; Sun, 30 Dec 2007 20:02:06 -0800 Received: (from schaefer@localhost) by torch.brasslantern.com (8.13.1/8.13.1/Submit) id lBV424wr032487; Sun, 30 Dec 2007 20:02:04 -0800 Date: Sun, 30 Dec 2007 20:02:04 -0800 From: Bart Schaefer Subject: Re: run-help: Support for svn and git In-reply-to: To: , zsh-workers@sunsite.dk Message-id: <071230200204.ZM32486@torch.brasslantern.com> MIME-version: 1.0 X-Mailer: OpenZMail Classic (0.9.2 24April2005) Content-type: text/plain; charset=us-ascii References: Comments: In reply to ( Text in unknown character set UTF-8 not shown ) Sommer "run-help: Support for svn and git" (Dec 30, 7:19pm) X-Virus-Scanned: ClamAV using ClamSMTP On Dec 30, 7:19pm, joerg@alea.gnuu.de wrote: } } calling run-help for svn or git is often not very helpful. } } Would you include this change? I don't think there's any reason to give git and/or svn any special treatment that isn't applied to (say) cvs or apt or yum or ztcp or zftp or any other command that uses "subcommands". I also don't think it's the right approach to build special knowledge into run-help of all possible commands that have subcommands. If we're going to make a change for this it should be one that can also be applied to "perl someprog.plx" or "sh yourscript.sh". So, how about the below (which replaces the patch I sent in 243260). This looks for a function (or alias or command) named "run-help-$1", e.g. run-help-git or run-help-svn or run-help-perl or whatever. If one is found, it invokes that, otherwise it invokes "man" as always. Then one can do: run-help-svn () { local cmd_args cmd_args=( ${@:#-*} ) svn help $cmd_args[1] } And something similar for git. Of course at this point we ought to add something to the manual (in the contributions section, perhaps?) about the run-help function and its, um, helpers. Index: Functions/Misc/run-help =================================================================== diff -c -r1.3 run-help --- Functions/Misc/run-help 30 May 2007 03:36:56 -0000 1.3 +++ Functions/Misc/run-help 31 Dec 2007 02:51:44 -0000 @@ -85,7 +85,20 @@ man zshmisc ;; (*) - ((! didman++)) && man $@ + set -- $@:t + if ((! didman++)) + then + if whence -w "run-help-$1" >/dev/null + then + local cmd_args + builtin getln cmd_args + builtin print -z "$cmd_args" + cmd_args=( ${${(z)cmd_args}[2,-1]} ) + eval "run-help-$1 $cmd_args[@]" + else + man $1 + fi + fi ;; esac if ((i < $#places && ! didman))