From owner-freebsd-hackers@FreeBSD.ORG Mon Sep 8 13:47:23 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 631771065679; Mon, 8 Sep 2008 13:47:23 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (unknown [IPv6:2a01:170:102f::2]) by mx1.freebsd.org (Postfix) with ESMTP id D45808FC14; Mon, 8 Sep 2008 13:47:22 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (localhost [127.0.0.1]) by lurza.secnetix.de (8.14.3/8.14.3) with ESMTP id m88DlKis074927; Mon, 8 Sep 2008 15:47:20 +0200 (CEST) (envelope-from oliver.fromme@secnetix.de) Received: (from olli@localhost) by lurza.secnetix.de (8.14.3/8.14.3/Submit) id m88DlK8T074926; Mon, 8 Sep 2008 15:47:20 +0200 (CEST) (envelope-from olli) Date: Mon, 8 Sep 2008 15:47:20 +0200 (CEST) Message-Id: <200809081347.m88DlK8T074926@lurza.secnetix.de> From: Oliver Fromme To: freebsd-hackers@FreeBSD.ORG, koitsu@FreeBSD.ORG In-Reply-To: <20080905143915.GA60002@icarus.home.lan> X-Newsgroups: list.freebsd-hackers User-Agent: tin/1.8.3-20070201 ("Scotasay") (UNIX) (FreeBSD/6.4-PRERELEASE-20080904 (i386)) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.1.2 (lurza.secnetix.de [127.0.0.1]); Mon, 08 Sep 2008 15:47:20 +0200 (CEST) Cc: Subject: Re: Extending find(1) to support -printf X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: freebsd-hackers@FreeBSD.ORG, koitsu@FreeBSD.ORG List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Sep 2008 13:47:23 -0000 Jeremy Chadwick wrote: > 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. Well, you can convert back and forth between spaces and newlines with tr(1): echo * | tr ' ' '\n' | grep -v whatever | tr '\n' ' ' It's not pretty, but it should work. Note that ls(1) prints one file name per line, so you can simplify the above line like this: ls | grep -v whatever | tr '\n' ' ' By the way, I often use zsh in such cases. It supports "extended globbing", for example, the wildcard expression *~*.(gz|bz2) matches all files _except_ the ones that end with .gz or .bz2. Best regards Oliver -- Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M. Handelsregister: Registergericht Muenchen, HRA 74606, Geschäftsfuehrung: secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün- chen, HRB 125758, Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart FreeBSD-Dienstleistungen, -Produkte und mehr: http://www.secnetix.de/bsd Perl is worse than Python because people wanted it worse. -- Larry Wall