From owner-freebsd-hackers@FreeBSD.ORG Fri Sep 5 14:39:16 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 593AD10656A6 for ; Fri, 5 Sep 2008 14:39:16 +0000 (UTC) (envelope-from jdc@koitsu.dyndns.org) Received: from QMTA03.emeryville.ca.mail.comcast.net (qmta03.emeryville.ca.mail.comcast.net [76.96.30.32]) by mx1.freebsd.org (Postfix) with ESMTP id 401CA8FC16 for ; Fri, 5 Sep 2008 14:39:16 +0000 (UTC) (envelope-from jdc@koitsu.dyndns.org) Received: from OMTA06.emeryville.ca.mail.comcast.net ([76.96.30.51]) by QMTA03.emeryville.ca.mail.comcast.net with comcast id AzWQ1a00216AWCUA32fGt8; Fri, 05 Sep 2008 14:39:16 +0000 Received: from koitsu.dyndns.org ([67.180.253.227]) by OMTA06.emeryville.ca.mail.comcast.net with comcast id B2fF1a0034v8bD78S2fFgg; Fri, 05 Sep 2008 14:39:15 +0000 X-Authority-Analysis: v=1.0 c=1 a=KgNaWZNk1wsA:10 a=d-pe6f8hAAAA:8 a=QycZ5dHgAAAA:8 a=u4EwfqHMNk4GdPdDfYcA:9 a=ZCSos2YTJHuzVx0kQV4A:7 a=cHi0HIuRXPgQijr84tDhSsZ209wA:4 a=EoioJ0NPDVgA:10 a=LY0hPdMaydYA:10 Received: by icarus.home.lan (Postfix, from userid 1000) id 1328617B81A; Fri, 5 Sep 2008 07:39:15 -0700 (PDT) Date: Fri, 5 Sep 2008 07:39:15 -0700 From: Jeremy Chadwick To: freebsd-hackers@freebsd.org Message-ID: <20080905143915.GA60002@icarus.home.lan> References: <20080905101253.GA53396@icarus.home.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20080905101253.GA53396@icarus.home.lan> User-Agent: Mutt/1.5.18 (2008-05-17) Subject: Re: Extending find(1) to support -printf X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Sep 2008 14:39:16 -0000 On Fri, Sep 05, 2008 at 03:12:53AM -0700, Jeremy Chadwick wrote: > Also, some folks on #bsdports asked why I was bothering with this in the > first place: mutt supports backticks to run shell commands inside of > a muttrc file. See "Building a list of mailboxes on the fly" below: > > http://wiki.mutt.org/?ConfigTricks > > Note the find ... -printf '%h ' method. I can accomplish (just > about) the same using `echo $HOME/Maildir/*`, but if I want to > exclude an entry, I can't use | grep -v, because mutt doesn't support > pipes within backticks. :-) Follow-up: mutt's backtick support does in fact respect pipes. My echo|grep -v was doing exactly what I requested: the grep -v was removing all output of the echo, since echo returned the results in a space-delimited format, not one per line. Hence, "mailboxes" was being executed without any arguments. Equally as frustrating, mutt's backtick support will only honour the first line of input. If a backticked command returns multiple lines, only the first is read; the rest are ignored. This makes using BSD find annoying, since find always outputs results terminated with a newline. One of my peers uses find | perl -ne 'chomp; print "=", $_, " "' to deal with this limit, which is quite disgusting. I realise there are workarounds for the dilemma (e.g. write a shell script that provides the exact output needed), but it seems like one could kill two birds with one stone by extending BSD find to support -printf, which does not output a newline unless \n is used within the output formatting. (This also explains why the Mutt Wiki entry uses -printf '%h ', note the space.) -- | Jeremy Chadwick jdc at parodius.com | | Parodius Networking http://www.parodius.com/ | | UNIX Systems Administrator Mountain View, CA, USA | | Making life hard for others since 1977. PGP: 4BD6C0CB |