From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22218 invoked from network); 3 Mar 2009 16:51:25 -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.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 3 Mar 2009 16:51:25 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 46918 invoked from network); 3 Mar 2009 16:51:21 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 3 Mar 2009 16:51:21 -0000 Received: (qmail 23964 invoked by alias); 3 Mar 2009 16:51:16 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 26672 Received: (qmail 23950 invoked from network); 3 Mar 2009 16:51:15 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 3 Mar 2009 16:51:15 -0000 Received: from mail-ew0-f172.google.com (mail-ew0-f172.google.com [209.85.219.172]) by bifrost.dotsrc.org (Postfix) with ESMTP id 7AB908058F82 for ; Tue, 3 Mar 2009 17:51:10 +0100 (CET) Received: by ewy20 with SMTP id 20so2223463ewy.45 for ; Tue, 03 Mar 2009 08:51:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=HIMY3fPPAAMsW1Ac8J2p9UyGjg4xL/p+3d7CPZpIuxg=; b=MKGCLC8Kfb8kjrMIbu9oD1Czj1ZFqj8oiTgmrFKp9MFQZKUZc4elnaGJwzj+pytixZ 70PN8lNBmRMulrlhvpvKuL3saski6ivtKc7KysR/hsYVZXT0C59kblAc62gSYd8W4zWA vUUO6M0kjmiZN6PtoomEVvJ0xleeD0sOP3yT8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=J+lOAUQP0o31q1kXpMhrMMmQ0DBn6pl3Ykd+0xTEMtizZbLCK+rWEI/wuAZV9202WS Xdo9XMp53xhbREsFoGW/lKfkhH/bzaTx46lBa9fWIX+Hk9UYnASuLIzwOWMiobhaPtOQ EaW9cwSSSUfqYsCT74h+kcHDtLMUSDZYbwK5s= MIME-Version: 1.0 Received: by 10.210.58.17 with SMTP id g17mr4302453eba.42.1236099069943; Tue, 03 Mar 2009 08:51:09 -0800 (PST) In-Reply-To: <20090303163526.533995be@news01> References: <20090303121253.61f5e2ec@news01> <20090303163526.533995be@news01> Date: Tue, 3 Mar 2009 17:51:09 +0100 Message-ID: <237967ef0903030851gc26620ficfc908628a4b3be2@mail.gmail.com> Subject: Re: [wip patch] new zsh/attr module From: Mikael Magnusson To: zsh workers Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV 0.92.1/9065/Tue Mar 3 11:43:41 2009 on bifrost X-Virus-Status: Clean 2009/3/3 Peter Stephenson : > On Tue, 3 Mar 2009 15:43:29 +0100 (CET) > Mikael Magnusson wrote: >> I've written some basic entries for the builtins, it doesn't seem to show >> up properly in man zshmodules though, in the summary list at the top it >> doesn't appear, but it does appear below with the details. > > It might be just a dependency problem; it all seems to be there in my case. Okay, I'll see if it works after some more make cleaning. >> It's trivial if you know how the standard builtin handling code works, >> less so otherwise :). I will look into it later. I think I want a -h >> option for not dereferencing symlinks. > > You need a string containing "h" where the builtin is declared and to test > OPT_ISSET(ops,'h') in the function for the builtin. > >> I didn't quite figure out how to best set an array parameter, so for now I >> still only handle one file, and the zlistattr function sets the whole >> string with nulls in the parameter, so you have to use ${(0)REPLY} to >> split it. I looked a little at bin_read since i know read can set an array >> parameter, but it is probably not very well suited as an easy to >> understand example since it does so many other things too. > > The use of setaparam() in stat.c is probably a good example, it's doing > something very similar, and there are some hash examples down there, too. > Remember all the bits come from permanently allocated memory. > >> I think I got this right now, but I haven't tested the case where the >> stuff isn't found. > > It looks OK. I'll see if I can find a Solaris machine left over to try it > on when I've committed the patch at the bottom. > >> It looks like I have to re-metafy the string when using zwarnnam, I pass >> in the parameter that says the buffer is large enough, since it did >> contain the metafied version of the string some milliseconds earlier. That >> should work, right? > > It's better to pass in the right length in case of embedded NULs---there > shouldn't be any since the filesystem calls wouldn't handle them, but it's > more consistent. That's an easy change. > > Something strange happened with some of the whitespace in the patch so I > applied various bits by hand. Ah, I didn't really expect anyone to actually apply it yet but I did send it through alpine so it's odd that the whitespace was corrupted. > There are various minor tweaks below: expand the filename in completion in > case it's got a ~ in it The completer also needs to check if the file exists before calling zgetattr, or simply 2> /dev/null I guess. > reformat the .distfiles (I've been gradually doing > this to all of them since one file per line is much easier to maintain); > handle lengths when metafying; don't report errors unless system calls > returned a negative value; remove an unused variable. I know the codestyle is a bit questionable but I already check 0 < len in the first if, so the else will be all negative lengths already. Another thing that needs to be done (for small values of need) is to allocate larger buffers in case the actual attributes take up more space than 256 bytes (or whatever value is a good default first try). I'll look at the other stuff a little later, thanks for your help so far. -- Mikael Magnusson