public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: Steve Long <slong@rathaus.eclipse.co.uk>
To: gentoo-dev@lists.gentoo.org
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	[thread overview]
Message-ID: <ff0q6e$tu0$1@ger.gmane.org> (raw)
In-Reply-To: 1192439259.1277.9.camel@uberlaptop.development.ltl

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



  reply	other threads:[~2007-10-15 22:54 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E1IhKZ7-000421-Hg@stork.gentoo.org>
2007-10-15  7:42 ` [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in app-misc/note: ChangeLog note-1.3.3.ebuild Donnie Berkholz
2007-10-15  7:56   ` Bo Ørsted Andresen
2007-10-15  8:01     ` Donnie Berkholz
2007-10-15  8:40       ` Roy Marples
2007-10-15  8:07     ` Ulrich Mueller
2007-10-15  8:35     ` Roy Marples
2007-10-15  8:43       ` Fabian Groffen
2007-10-15  9:07         ` Roy Marples
2007-10-15 22:43           ` Steve Long [this message]
2007-10-15 23:48             ` [gentoo-dev] " Gilles Dartiguelongue
2007-10-16  2:14               ` [gentoo-dev] " Steve Long
2007-10-16  2:32                 ` Elias Pipping

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='ff0q6e$tu0$1@ger.gmane.org' \
    --to=slong@rathaus.eclipse.co.uk \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox