From mboxrd@z Thu Jan  1 00:00:00 1970
Received: from lists.gentoo.org ([140.105.134.102] helo=robin.gentoo.org)
	by finch.gentoo.org with esmtp (Exim 4.60)
	(envelope-from <gentoo-dev+bounces-27186-garchives=archives.gentoo.org@gentoo.org>)
	id 1IhYpP-00040v-7J
	for garchives@archives.gentoo.org; Mon, 15 Oct 2007 22:54:27 +0000
Received: from robin.gentoo.org (localhost [127.0.0.1])
	by robin.gentoo.org (8.14.1/8.14.0) with SMTP id l9FMgiq3020257;
	Mon, 15 Oct 2007 22:42:44 GMT
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	by robin.gentoo.org (8.14.1/8.14.0) with ESMTP id l9FMe3Cj016787
	for <gentoo-dev@lists.gentoo.org>; Mon, 15 Oct 2007 22:40:04 GMT
Received: from localhost (localhost [127.0.0.1])
	by smtp.gentoo.org (Postfix) with ESMTP id 4EA8B64B62
	for <gentoo-dev@lists.gentoo.org>; Mon, 15 Oct 2007 22:40:03 +0000 (UTC)
X-Virus-Scanned: amavisd-new at gentoo.org
X-Spam-Score: -0.015
X-Spam-Level: 
X-Spam-Status: No, score=-0.015 required=5.5 tests=[AWL=0.517,
	BAYES_00=-2.599, RCVD_NUMERIC_HELO=2.067]
Received: from smtp.gentoo.org ([127.0.0.1])
	by localhost (smtp.gentoo.org [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id QeuzJ3meRIUZ for <gentoo-dev@lists.gentoo.org>;
	Mon, 15 Oct 2007 22:39:57 +0000 (UTC)
Received: from ciao.gmane.org (main.gmane.org [80.91.229.2])
	(using TLSv1 with cipher AES256-SHA (256/256 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTP id 3DE296503F
	for <gentoo-dev@gentoo.org>; Mon, 15 Oct 2007 22:39:56 +0000 (UTC)
Received: from list by ciao.gmane.org with local (Exim 4.43)
	id 1IhYas-0005qG-UV
	for gentoo-dev@gentoo.org; Mon, 15 Oct 2007 22:39:26 +0000
Received: from 82.153.64.56 ([82.153.64.56])
        by main.gmane.org with esmtp (Gmexim 0.1 (Debian))
        id 1AlnuQ-0007hv-00
        for <gentoo-dev@gentoo.org>; Mon, 15 Oct 2007 22:39:26 +0000
Received: from slong by 82.153.64.56 with local (Gmexim 0.1 (Debian))
        id 1AlnuQ-0007hv-00
        for <gentoo-dev@gentoo.org>; Mon, 15 Oct 2007 22:39:26 +0000
X-Injected-Via-Gmane: http://gmane.org/
To: gentoo-dev@lists.gentoo.org
From:  Steve Long <slong@rathaus.eclipse.co.uk>
Subject: [gentoo-dev]  Re: Re: [gentoo-commits] gentoo-x86 commit in app-misc/note: ChangeLog note-1.3.3.ebuild
Date:  Mon, 15 Oct 2007 23:43:12 +0100
Message-ID:  <ff0q6e$tu0$1@ger.gmane.org>
References:  <E1IhKZ7-000421-Hg@stork.gentoo.org> <20071015074250.GG23990@supernova> <200710150956.05673.bo.andresen@zlin.dk> <1192437335.1277.1.camel@uberlaptop.development.ltl> <20071015084353.GF30883@gentoo.org> <1192439259.1277.9.camel@uberlaptop.development.ltl>
Precedence: bulk
List-Post: <mailto:gentoo-dev@lists.gentoo.org>
List-Help: <mailto:gentoo-dev+help@gentoo.org>
List-Unsubscribe: <mailto:gentoo-dev+unsubscribe@gentoo.org>
List-Subscribe: <mailto:gentoo-dev+subscribe@gentoo.org>
List-Id: Gentoo Linux mail <gentoo-dev.gentoo.org>
X-BeenThere: gentoo-dev@gentoo.org
Reply-to: gentoo-dev@lists.gentoo.org
Mime-Version:  1.0
Content-Type:  text/plain; charset=us-ascii
Content-Transfer-Encoding:  7Bit
X-Complaints-To: usenet@ger.gmane.org
X-Gmane-NNTP-Posting-Host: 82.153.64.56
User-Agent: KNode/0.10.4
Sender: news <news@ger.gmane.org>
X-Archives-Salt: 69ffd6b0-29bf-4f66-8e73-7dccbf65c836
X-Archives-Hash: dcb261a85cb6cf0c179e3220ffa93622

Roy Marples wrote:

> On Mon, 2007-10-15 at 10:43 +0200, Fabian Groffen wrote:
>> On 15-10-2007 09:35:35 +0100, Roy Marples wrote:
>> > find "${D}" -type f -name *${v}.*pm -delete
>> 
>> Looks like you rely on your shell here to assume that you meant
>> "*${v}.*pm" because there is nothing that matches that pattern by
>> coincidence.  If it does, your find probably doesn't do what you expect
>> it to.
> 
> It was like that in the original code snippet, I assumed that is what
> the author intended? Anyway, you're probably right.
> 
Well if portability is a concern, -delete is not specified in POSIX[1]
afaict. -exec is, it turns out, including -exec blah {} + which really made
me wonder why people still have such a thing for xargs. It turns out GNU
didn't include this til recently, and it isn't in OpenBSD either for one[2]
(..disgraceful, if you ask me ;)

The unintended globbing is indeed unsafe, in the general case. I'd do this: 

find "$D" -type f -name '*'"$v"'.*pm' -exec rm {} +

The shell will still treat that all as one argument (this method is
typically used to insert variables into awk commands, or sed ones which
use ".) The + will make the command execution more efficient for commands
that take multiple filenames. The one caveat with + is that the {} must
appear at the end of the command.[3]

[1] http://www.opengroup.org/onlinepubs/009695399/utilities/find.html
[2]
http://www.openbsd.org/cgi-bin/man.cgi?query=find&apropos=0&sektion=1&manpath=OpenBSD+Current&arch=i386&format=html
[3] http://wooledge.org/mywiki/UsingFind (highly recommended)


-- 
gentoo-dev@gentoo.org mailing list