GNU bug report logs -
#21712
Suspected bug in find -exec '+'
Previous Next
Reported by: richard.white <at> embedded-expertise.com
Date: Mon, 19 Oct 2015 15:35:02 UTC
Severity: normal
Tags: notabug
Done: Eric Blake <eblake <at> redhat.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 21712 in the body.
You can then email your comments to 21712 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-coreutils <at> gnu.org
:
bug#21712
; Package
coreutils
.
(Mon, 19 Oct 2015 15:35:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
richard.white <at> embedded-expertise.com
:
New bug report received and forwarded. Copy sent to
bug-coreutils <at> gnu.org
.
(Mon, 19 Oct 2015 15:35:03 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
The find utility supports execution of a nominated command per file found. The command argument list is terminated with a ';' parameter.
The enhanced GNU version specifies an alternative version of the –exec option using a '+' list terminator. This option is provided to support an xargs-like batched execution of the nominated command resulting in greater efficiency.
It seems like find –exec ';' and find –exec '+' do not behave consistently with regard to '{}' argument expansion.
An example:
mkdir /tmp/test
cd /tmp/test
touch a b
find . –type f –exec echo Prefix{}Suffix ';'
è Prefix./bSuffix
è Prefix./aSuffix
find . –exec echo Prefix{}Suffix '+'
è ./b ./a
Is the latter result correct? I would have expected the same result as for the ';' version?
Richard White
Embedded
Expertise
Richard White, Director, <http://www.embedded-expertise.com/> Embedded Expertise Ltd
<mailto:richard.white <at> embedded-expertise.com> richard.white <at> embedded-expertise.com
t: +44 (0) 333 112 8740 m: +44 (0) 7973 393348
[Message part 2 (text/html, inline)]
Added tag(s) notabug.
Request was from
Eric Blake <eblake <at> redhat.com>
to
control <at> debbugs.gnu.org
.
(Mon, 19 Oct 2015 15:49:01 GMT)
Full text and
rfc822 format available.
Reply sent
to
Eric Blake <eblake <at> redhat.com>
:
You have taken responsibility.
(Mon, 19 Oct 2015 15:49:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
richard.white <at> embedded-expertise.com
:
bug acknowledged by developer.
(Mon, 19 Oct 2015 15:49:03 GMT)
Full text and
rfc822 format available.
Message #12 received at 21712-done <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
tag 21712 notabug
thanks
On 10/19/2015 05:33 AM, Richard White wrote:
> The find utility supports execution of a nominated command per file found.
Thanks for the report. However, you sent it to the coreutils list,
although find is maintained by the findutils project. Therefore, we
cannot address the bug here, and I'm marking the bug closed since it is
not a coreutils problem. Feel free to make further comments on this
thread, though.
> It seems like find –exec ';' and find –exec '+' do not behave consistently with regard to '{}' argument expansion.
Correct, they ARE different. And this is behavior described by POSIX:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/find.html
-exec utility_name [argument ...] ;
-exec utility_name [argument ...] {} +
The end of the primary expression shall be punctuated by a
<semicolon> or by a <plus-sign>. Only a <plus-sign> that immediately
follows an argument containing only the two characters "{}" shall
punctuate the end of the primary expression. Other uses of the
<plus-sign> shall not be treated as special.
If the primary expression is punctuated by a <semicolon>, the
utility utility_name shall be invoked once for each pathname and the
primary shall evaluate as true if the utility returns a zero value as
exit status. A utility_name or argument containing only the two
characters "{}" shall be replaced by the current pathname. If a
utility_name or argument string contains the two characters "{}", but
not just the two characters "{}", it is implementation-defined whether
find replaces those two characters or uses the string without change.
If the primary expression is punctuated by a <plus-sign>, the
primary shall always evaluate as true, and the pathnames for which the
primary is evaluated shall be aggregated into sets. The utility
utility_name shall be invoked once for each set of aggregated pathnames.
Each invocation shall begin after the last pathname in the set is
aggregated, and shall be completed before the find utility exits and
before the first pathname in the next set (if any) is aggregated for
this primary, but it is otherwise unspecified whether the invocation
occurs before, during, or after the evaluations of other primaries. If
any invocation returns a non-zero value as exit status, the find utility
shall return a non-zero exit status. An argument containing only the two
characters "{}" shall be replaced by the set of aggregated pathnames,
with each pathname passed as a separate argument to the invoked utility
in the same order that it was aggregated. The size of any set of two or
more pathnames shall be limited such that execution of the utility does
not cause the system's {ARG_MAX} limit to be exceeded. If more than one
argument containing the two characters "{}" is present, the behavior is
unspecified.
> Is the latter result correct? I would have expected the same result as for the ';' version?
As mentioned by the POSIX wording, you are attempting to do something
that is unspecified. So all bets are off, and it's hard to call it a
bug. In fact, I'd argue that:
find . -exec echo Prefix{}Suffix +
should be a usage error, rather than a valid find command, because there
is no terminating ';', and because the '+' is not proceeded by a lone
{}. The fact that it is not a usage error may be a particular GNU find
extension, but you probably shouldn't rely on it.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[signature.asc (application/pgp-signature, attachment)]
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#21712
; Package
coreutils
.
(Mon, 19 Oct 2015 16:41:02 GMT)
Full text and
rfc822 format available.
Message #15 received at 21712 <at> debbugs.gnu.org (full text, mbox):
On 10/19/2015 05:48 PM, Eric Blake wrote:
> [...]. In fact, I'd argue that:
>
> find . -exec echo Prefix{}Suffix +
>
> should be a usage error, [...]
It is:
$ find . -exec echo Prefix{}Suffix +
find: In ‘-exec ... {} +’ the ‘{}’ must appear by itself, but you specified ‘Prefix{}Suffix’
$ find --version
find (GNU findutils) 4.5.14
[...]
Have a nice day,
Berny
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Tue, 17 Nov 2015 12:24:07 GMT)
Full text and
rfc822 format available.
This bug report was last modified 9 years and 272 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.