From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27501 invoked from network); 14 May 2008 15:55:30 -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 15:55:30 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 97564 invoked from network); 14 May 2008 15:55:26 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 14 May 2008 15:55:26 -0000 Received: (qmail 15362 invoked by alias); 14 May 2008 15:55:22 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 25029 Received: (qmail 15348 invoked from network); 14 May 2008 15:55:22 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 14 May 2008 15:55:22 -0000 Received: from vms173003pub.verizon.net (vms173003pub.verizon.net [206.46.173.3]) by bifrost.dotsrc.org (Postfix) with ESMTP id EE7FE80ED172 for ; Wed, 14 May 2008 17:55:17 +0200 (CEST) Received: from torch.brasslantern.com ([71.116.113.54]) by vms173003.mailsrvcs.net (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) with ESMTPA id <0K0V00DCT83ARIN4@vms173003.mailsrvcs.net> for zsh-workers@sunsite.dk; Wed, 14 May 2008 10:52:24 -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 m4EFtBhM011899 for ; Wed, 14 May 2008 08:55:12 -0700 Received: (from schaefer@localhost) by torch.brasslantern.com (8.13.1/8.13.1/Submit) id m4EFtBoX011898 for zsh-workers@sunsite.dk; Wed, 14 May 2008 08:55:11 -0700 Date: Wed, 14 May 2008 08:55:11 -0700 From: Bart Schaefer Subject: Re: functions/Completion/Linux/_modutils In-reply-to: <482AF445.3080909@sergio.spb.ru> To: zsh-workers@sunsite.dk Message-id: <080514085511.ZM11897@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> <080513201714.ZM10079@torch.brasslantern.com> <482AF445.3080909@sergio.spb.ru> Comments: In reply to sergio "Re: functions/Completion/Linux/_modutils" (May 14, 6:16pm) X-Virus-Scanned: ClamAV 0.91.2/7121/Wed May 14 16:17:09 2008 on bifrost X-Virus-Status: Clean On May 14, 6:16pm, sergio wrote: } } sudo modprobe should list all available modules (may be all not } loaded modules) but it doesn't. Aha. So the problem is with the completion for sudo, not the completion for modprobe. Calling "_normal" is not adequate when the environment in which the command will run is not the same as the environment in which the completer is running. I can't advocate breaking _modutils (and everything else, one at a time) for all ordinary cases, just to fix this for "sudo". So how about this? % zstyle :complete:sudo: environ \ PATH="/sbin:/usr/sbin:$PATH" HOME="/root" % sudo modprobe The environ style is an array of VAR=value which are exported into the local environment before the completion for the target command is invoked. If this looks OK and nobody beats me to it, I'll add some documentation, too. Of course it would be preferable if "sudo -H /tmp/foo" would export HOME=/tmp/foo, and if the style could be specialized to the target user for "sudo -u" and so on, but I'm not prepared to go that far overboard just now. Index: Completion/Unix/Command/_sudo =================================================================== RCS file: /extra/cvsroot/zsh/zsh-4.0/Completion/Unix/Command/_sudo,v retrieving revision 1.1.1.1 diff -c -r1.1.1.1 _sudo --- zsh-4.3/Completion/Unix/Command/_sudo 9 Apr 2001 20:14:09 -0000 1.1.1.1 +++ _sudo 14 May 2008 15:22:23 -0000 @@ -1,5 +1,12 @@ #compdef sudo +local curcontext="$curcontext" environ e +zstyle -a "$curcontext" environ environ + +for e in "${environ[@]}" +do local -x "$e" +done + _arguments \ '-V[show version]' \ '-l[list allowed commands]' \