From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27021 invoked from network); 14 May 2008 03:17:37 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) 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.4 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 14 May 2008 03:17:37 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 73610 invoked from network); 14 May 2008 03:17:29 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 14 May 2008 03:17:29 -0000 Received: (qmail 20667 invoked by alias); 14 May 2008 03:17:25 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 25022 Received: (qmail 20655 invoked from network); 14 May 2008 03:17:25 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 14 May 2008 03:17:25 -0000 Received: from vms173005pub.verizon.net (vms173005pub.verizon.net [206.46.173.5]) by bifrost.dotsrc.org (Postfix) with ESMTP id 9261680ED172 for ; Wed, 14 May 2008 05:17:20 +0200 (CEST) Received: from torch.brasslantern.com ([71.116.113.54]) by vms173005.mailsrvcs.net (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) with ESMTPA id <0K0U00AAL8UU1SB5@vms173005.mailsrvcs.net> for zsh-workers@sunsite.dk; Tue, 13 May 2008 22:11:19 -0500 (CDT) Received: from torch.brasslantern.com (localhost.localdomain [127.0.0.1]) by torch.brasslantern.com (8.13.1/8.13.1) with ESMTP id m4E3HEdQ010081 for ; Tue, 13 May 2008 20:17:18 -0700 Received: (from schaefer@localhost) by torch.brasslantern.com (8.13.1/8.13.1/Submit) id m4E3HEZ9010080 for zsh-workers@sunsite.dk; Tue, 13 May 2008 20:17:14 -0700 Date: Tue, 13 May 2008 20:17:14 -0700 From: Bart Schaefer Subject: Re: functions/Completion/Linux/_modutils In-reply-to: <4829BF7A.20203@sergio.spb.ru> To: zsh-workers@sunsite.dk Message-id: <080513201714.ZM10079@torch.brasslantern.com> MIME-version: 1.0 X-Mailer: OpenZMail Classic (0.9.2 24April2005) Content-type: text/plain; charset=us-ascii References: <4829BF7A.20203@sergio.spb.ru> Comments: In reply to sergio "functions/Completion/Linux/_modutils" (May 13, 8:19pm) X-Virus-Scanned: ClamAV 0.91.2/7115/Tue May 13 23:19:43 2008 on bifrost X-Virus-Status: Clean On May 13, 8:19pm, sergio wrote: } } When i'm not root modprobe is not in my path, so } in case "all_modules)" "modules" will be empty: When completing for what? An example command line would be helpful. } all_modules) } modules=( ${${${${(f)"$(_call_program modules } ${(M)words[1]##*/}modprobe -l 2>/dev/null)"}:#}##*/}%%.*} ) } } words --- what this? It's the command line broken out into an array of the $IFS-separated substrings. Each such substring is called a "word" in the semi-formal shell grammar described in the manual page. So ${(M)words[1]##*/} should be the path prefix of the command name. For example, if you are completing after /sbin/lsmod, then that expansion is /sbin/ which is then prefixed to modprobe. The idea is that if modprobe isn't in your path, the best place to look for it is in the same place as whatever other command (assumed also not to be in your path and therefore a full path name) you are completing. } with } modules=( ${${${${(f)"$(_call_program modules } ${(M)words[1]##*/}/sbin/modprobe -l 2>/dev/null)"}:#}##*/}%%.*} ) } all works fine Except if you complete after /sbin/rmmod, the completion will try to run /sbin//sbin/modprobe and break.