Debian Bug report logs - #194160
reportbug: dubious behaviour of '-o' operator in 'find'

version graph

Package: findutils; Maintainer for findutils is Andreas Metzler <ametzler@debian.org>; Source for findutils is src:findutils (PTS, buildd, popcon).

Reported by: giuseppe bonacci <g.bonacci@libero.it>

Date: Wed, 21 May 2003 12:48:01 UTC

Severity: normal

Tags: upstream

Merged with 195940

Found in version 4.1.7-2.1

Done: Andreas Metzler <ametzler@debian.org>

Bug is archived. No further changes may be made.

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to debian-bugs-dist@lists.debian.org, Chris Lawrence <lawrencc@debian.org>, reportbug@packages.qa.debian.org:
Bug#194160; Package reportbug. (full text, mbox, link).


Acknowledgement sent to giuseppe bonacci <g.bonacci@libero.it>:
New Bug report received and forwarded. Copy sent to Chris Lawrence <lawrencc@debian.org>, reportbug@packages.qa.debian.org. (full text, mbox, link).


Message #5 received at submit@bugs.debian.org (full text, mbox, reply):

From: giuseppe bonacci <g.bonacci@libero.it>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: reportbug: dubious behaviour of '-o' operator in 'find'
Date: Wed, 21 May 2003 14:38:20 +0200
Package: reportbug
Version: 2.10.1
Severity: normal
Tags: upstream

according to the man-page and info, the expected output from the
following find commands should be identical: 

myhost# ls -lRgoF
.:
total 4
drwxr-xr-x    2     4096 May 21 12:51 b/
-rw-r--r--    1        0 May 21 12:51 c

./b:
total 0
-rw-r--r--    1        0 May 21 12:51 d
myhost# find . -name b -prune -o -type f -print
./c
myhost# find . -name b -prune -o -type f	# ABNORMAL
./b
./c
myhost# find . \( -name b -prune \) -o \( -type f -print \)
./c



-- Package-specific info:
** /home/giuseppe/.reportbugrc:
reportbug_version "2.10.1"
mode standard
ui text
realname "giuseppe bonacci"
email "g.bonacci@libero.it"

-- System Information:
Debian Release: testing/unstable
Architecture: i386
Kernel: Linux bonacci 2.4.20-1-686 #1 Sat Mar 22 13:16:21 EST 2003 i686
Locale: LANG=C, LC_CTYPE=C

Versions of packages reportbug depends on:
ii  python2.2                     2.2.2-6    An interactive object-oriented scr
ii  python2.2-optik               1.4.1-1    advanced command-line parsing libr

-- no debconf information




Information forwarded to debian-bugs-dist@lists.debian.org, Chris Lawrence <lawrencc@debian.org>:
Bug#194160; Package reportbug. (full text, mbox, link).


Acknowledgement sent to giuseppe bonacci <g.bonacci@libero.it>:
Extra info received and forwarded to list. Copy sent to Chris Lawrence <lawrencc@debian.org>. (full text, mbox, link).


Message #10 received at 194160@bugs.debian.org (full text, mbox, reply):

From: giuseppe bonacci <g.bonacci@libero.it>
To: Debian Bug Tracking System <194160@bugs.debian.org>
Subject: reportbug: Bug filed to the wrong package
Date: Tue, 03 Jun 2003 16:34:34 +0200
Package: reportbug
Version: 2.10.1
Followup-For: Bug #194160


This bug was intended for package findutils, and was filed to reportbug
by mistake. Sorry.
g.bonacci

-- Package-specific info:
** /home/giuseppe/.reportbugrc:
reportbug_version "2.10.1"
mode standard
ui text
realname "giuseppe bonacci"
email "g.bonacci@libero.it"

-- System Information:
Debian Release: testing/unstable
Architecture: i386
Kernel: Linux bonacci 2.4.20-1-686 #1 Sat Mar 22 13:16:21 EST 2003 i686
Locale: LANG=C, LC_CTYPE=C

Versions of packages reportbug depends on:
ii  python2.2                     2.2.2-6    An interactive object-oriented scr
ii  python2.2-optik               1.4.1-1    advanced command-line parsing libr

-- no debconf information




Bug reassigned from package `reportbug' to `findutils'. Request was from Rene Engelhard <rene@debian.org> to control@bugs.debian.org. (full text, mbox, link).


Merged 194160 195940. Request was from Rene Engelhard <rene@debian.org> to control@bugs.debian.org. (full text, mbox, link).


Information forwarded to debian-bugs-dist@lists.debian.org, Andreas Metzler <ametzler@debian.org>:
Bug#194160; Package findutils. (full text, mbox, link).


Acknowledgement sent to James Youngman <jay@gnu.org>:
Extra info received and forwarded to list. Copy sent to Andreas Metzler <ametzler@debian.org>. (full text, mbox, link).


Message #19 received at 194160@bugs.debian.org (full text, mbox, reply):

From: James Youngman <jay@gnu.org>
To: 194160@bugs.debian.org
Subject: [jay@gnu.org: Interaction between -o and the default-print]
Date: Sun, 31 Oct 2004 13:21:12 +0000
I don't think this is a bug, because "find xxx" is equivalent to "find
\( xxx \) -print" and not to "find xxx -print".  (This statement
applies if none of the actions in xxx include -print anyway).

So, I think the second command in the above example should be
equvalent to "find . \( -name b -prune -o -type f \) -print", not to
the first command.   Viz :-

$ find . -ls
590608    4 drwxr-xr-x   3 james    users        4096 Oct 31 13:09 .
590749    4 drwxr-xr-x   2 james    users        4096 Oct 31 13:09 ./b
590748    0 -rw-r--r--   1 james    users           0 Oct 31 13:09 ./c
$ find . -name b -prune -o -type f -print
./c
$ find . -name b -prune -o -type f
./b
./c
$ find . \( -name b -prune -o -type f \) -print
./b
./c

I've also sent this to bug-findutils@gnu.org in case someone there can
think of a reason why this is wrong..

Regards,
James.



Information stored:
Bug#194160; Package findutils. (full text, mbox, link).


Acknowledgement sent to bob@proulx.com (Bob Proulx):
Extra info received and filed, but not forwarded. (full text, mbox, link).


Message #24 received at 194160-quiet@bugs.debian.org (full text, mbox, reply):

From: bob@proulx.com (Bob Proulx)
To: bug-findutils@gnu.org
Cc: 194160-quiet@bugs.debian.org
Subject: Re: Interaction between -o and the default-print
Date: Sun, 31 Oct 2004 10:12:33 -0700
James Youngman wrote:
> giuseppe bonacci wrote:
> > according to the man-page and info, the expected output from the
> > following find commands should be identical:
> > [...]
> > myhost# find . -name b -prune -o -type f -print
> > [...]
> > myhost# find . -name b -prune -o -type f        # ABNORMAL
> > [...]
> 
> I don't think this is a bug, because "find xxx" is equivalent to "find
> \( xxx \) -print" and not to "find xxx -print".  (This statement
> applies if none of the actions in xxx include -print anyway).
> 
> So, I think the second command in the above example should be
> equvalent to "find . \( -name b -prune -o -type f \) -print", not to
> the first command.   Viz :-
> [...]
> I've also sent this to bug-findutils@gnu.org in case someone there can
> think of a reason why this is wrong..

Silence is not always the best form of agreement.  Let me say as a
crosscheck that I agree with your analysis.  This is not a bug in
find.  It is behaving as expected and required.

The POSIX docs say:

    If no expression is present, -print shall be used as the
    expression.  Otherwise, if the given expression does not contain
    any of the primaries -exec, -ok, or -print, the given expression
    shall be effectively replaced by:

    ( given_expression ) -print

Therefore using the above case these two examples must be identical in
behavior.

  find . -name b -prune -o -type f
  find . \( -name b -prune -o -type f \) -print

Bob

-- 
Bob Proulx <bob@proulx.com>
http://www.proulx.com/~bob/
CP-ASEL-IA-Tailwheel-Glider



Information stored:
Bug#194160; Package findutils. (full text, mbox, link).


Acknowledgement sent to jay@excession.spiral-arm.org (James Youngman):
Extra info received and filed, but not forwarded. (full text, mbox, link).


Message #29 received at 194160-quiet@bugs.debian.org (full text, mbox, reply):

From: jay@excession.spiral-arm.org (James Youngman)
To: bug-findutils@gnu.org, 194160-quiet@bugs.debian.org
Subject: Re: Interaction between -o and the default-print
Date: Sun, 31 Oct 2004 19:48:27 +0000
On Sun, Oct 31, 2004 at 10:12:33AM -0700, Bob Proulx wrote:
> James Youngman wrote:

> > I don't think this is a bug, because "find xxx" is equivalent to "find
> > \( xxx \) -print" and not to "find xxx -print".  (This statement
> > applies if none of the actions in xxx include -print anyway).

> Silence is not always the best form of agreement.  Let me say as a
> crosscheck that I agree with your analysis.  This is not a bug in
> find.  It is behaving as expected and required.

I have modified the findutils development code (parser.c) so that if
the user specifies an option after a non-option, a warning message is
issued.  This does not occur for the -follow and -daystart options,
because those options affect only those tests appearing after them on
the command line, and to such positioning might be deliberate and
correct.




Information stored:
Bug#194160; Package findutils. (full text, mbox, link).


Acknowledgement sent to bob@proulx.com (Bob Proulx):
Extra info received and filed, but not forwarded. (full text, mbox, link).


Message #34 received at 194160-quiet@bugs.debian.org (full text, mbox, reply):

From: bob@proulx.com (Bob Proulx)
To: bug-findutils@gnu.org, 194160-quiet@bugs.debian.org
Subject: Re: Interaction between -o and the default-print
Date: Sun, 31 Oct 2004 16:14:38 -0700
James Youngman wrote:
> I have modified the findutils development code (parser.c) so that if
> the user specifies an option after a non-option, a warning message is
> issued.  This does not occur for the -follow and -daystart options,
> because those options affect only those tests appearing after them on
> the command line, and to such positioning might be deliberate and
> correct.

I am sorry but I did not quite follow the description.  Could you post
an example and show how your recent change affects it?  How it would
have behaved before and now after with this change?

Thanks
Bob



Information stored:
Bug#194160; Package findutils. (full text, mbox, link).


Acknowledgement sent to jay@excession.spiral-arm.org (James Youngman):
Extra info received and filed, but not forwarded. (full text, mbox, link).


Message #39 received at 194160-quiet@bugs.debian.org (full text, mbox, reply):

From: jay@excession.spiral-arm.org (James Youngman)
To: bug-findutils@gnu.org, 194160-quiet@bugs.debian.org
Subject: Re: Interaction between -o and the default-print
Date: Mon, 1 Nov 2004 00:00:13 +0000
On Sun, Oct 31, 2004 at 04:14:38PM -0700, Bob Proulx wrote:
> James Youngman wrote:
> > I have modified the findutils development code (parser.c) so that if
> > the user specifies an option after a non-option, a warning message is
> > issued.  This does not occur for the -follow and -daystart options,
> > because those options affect only those tests appearing after them on
> > the command line, and to such positioning might be deliberate and
> > correct.
> 
> I am sorry but I did not quite follow the description.  Could you post
> an example and show how your recent change affects it?  How it would
> have behaved before and now after with this change?

$ find . -mindepth 3 -ls >/dev/null
$ find . -ls -mindepth 3  >/dev/null
find: warning: you have specified the -mindepth option after a non-option argument -ls, but options are not positional (-mindepth affects tests specified before it as well as those specified after it).  Please specify options before other arguments.

$ find . -ls -follow  >/dev/null
$


Previously, the second example would not have generated a warning
message.  Apart from this warning, the output is the same before and
after the change.

I do wonder though if this attempt to be helpful will simply be
irritating.  However, there are a couple of defect reports that have
been raised which would have been avoided if this error message had
been implemented.   Some people do seem to assume that things like 

 find . \( -name foo -print \) -o \( -mindepth 2 -type d -print \) 

will work, and print out instances of "foo" which are in the current
directory.


Regards,
James.



Information forwarded to debian-bugs-dist@lists.debian.org, Andreas Metzler <ametzler@debian.org>:
Bug#194160; Package findutils. (full text, mbox, link).


Acknowledgement sent to Andreas Metzler <gnu@downhill.at.eu.org>:
Extra info received and forwarded to list. Copy sent to Andreas Metzler <ametzler@debian.org>. (full text, mbox, link).


Message #44 received at 194160@bugs.debian.org (full text, mbox, reply):

From: Andreas Metzler <gnu@downhill.at.eu.org>
To: bug-findutils@gnu.org
Cc: 194160@bugs.debian.org
Subject: Re: Interaction between -o and the default-print
Date: Mon, 8 Nov 2004 12:53:49 +0100
On 2004-11-01 James Youngman <jay@excession.spiral-arm.org> wrote:
[...]
> $ find . -ls -mindepth 3  >/dev/null
> find: warning: you have specified the -mindepth option after a non-option argument -ls, but options are not positional (-mindepth affects tests specified before it as well as those specified after it).  Please specify options before other arguments.
[...]
> I do wonder though if this attempt to be helpful will simply be
> irritating.  However, there are a couple of defect reports that have
> been raised which would have been avoided if this error message had
> been implemented.   Some people do seem to assume that things like 

>  find . \( -name foo -print \) -o \( -mindepth 2 -type d -print \) 

> will work, and print out instances of "foo" which are in the current
> directory.

Hello,
While both is true I currently tend to "a lot more irritating than
useful".

find is used in countless scripts including lots of cronjobs and I
suspect lots of them would trigger this warning (Resulting in
a useless mail for every cronjob). (And yes I've already found a
instance after a single day.)

How about a -debug and asking people to use it before submitting a
bugreport?
   cu and- just my 2c -reas
-- 
"See, I told you they'd listen to Reason," [SPOILER] Svfurlr fnlf,
fuhggvat qbja gur juveyvat tha.
Neal Stephenson in "Snow Crash"



Information forwarded to debian-bugs-dist@lists.debian.org, Andreas Metzler <ametzler@debian.org>:
Bug#194160; Package findutils. (full text, mbox, link).


Acknowledgement sent to James Youngman <jay@gnu.org>:
Extra info received and forwarded to list. Copy sent to Andreas Metzler <ametzler@debian.org>. (full text, mbox, link).


Message #49 received at 194160@bugs.debian.org (full text, mbox, reply):

From: James Youngman <jay@gnu.org>
To: bug-findutils@gnu.org, 194160@bugs.debian.org
Subject: Re: Interaction between -o and the default-print
Date: Mon, 8 Nov 2004 13:24:24 +0000
On Mon, Nov 08, 2004 at 12:53:49PM +0100, Andreas Metzler wrote:
> On 2004-11-01 James Youngman <jay@excession.spiral-arm.org> wrote:
> [...]
> > $ find . -ls -mindepth 3  >/dev/null
> > find: warning: you have specified the -mindepth option after a non-option argument -ls, but options are not positional (-mindepth affects tests specified before it as well as those specified after it).  Please specify options before other arguments.
> [...]
> > I do wonder though if this attempt to be helpful will simply be
> > irritating.  However, there are a couple of defect reports that have
> > been raised which would have been avoided if this error message had
> > been implemented.   Some people do seem to assume that things like 
> 
> >  find . \( -name foo -print \) -o \( -mindepth 2 -type d -print \) 
> 
> > will work, and print out instances of "foo" which are in the current
> > directory.
> 
> Hello,
> While both is true I currently tend to "a lot more irritating than
> useful".
> 
> find is used in countless scripts including lots of cronjobs and I
> suspect lots of them would trigger this warning (Resulting in
> a useless mail for every cronjob). (And yes I've already found a
> instance after a single day.)
> 
> How about a -debug and asking people to use it before submitting a
> bugreport?

I agree with the idea, though I might call the option -warn/-nowarn,
with the default being -nowarn, unless stdin is a tty.  Thoughts?






Information forwarded to debian-bugs-dist@lists.debian.org, Andreas Metzler <ametzler@debian.org>:
Bug#194160; Package findutils. (full text, mbox, link).


Acknowledgement sent to Andreas Metzler <gnu@downhill.at.eu.org>:
Extra info received and forwarded to list. Copy sent to Andreas Metzler <ametzler@debian.org>. (full text, mbox, link).


Message #54 received at 194160@bugs.debian.org (full text, mbox, reply):

From: Andreas Metzler <gnu@downhill.at.eu.org>
To: bug-findutils@gnu.org, 194160@bugs.debian.org
Subject: Re: Interaction between -o and the default-print
Date: Mon, 8 Nov 2004 15:21:22 +0100
On Mon, Nov 08, 2004 at 01:24:24PM +0000, James Youngman wrote:
> On Mon, Nov 08, 2004 at 12:53:49PM +0100, Andreas Metzler wrote:
[...]
> > How about a -debug and asking people to use it before submitting a
> > bugreport?

> I agree with the idea, though I might call the option -warn/-nowarn,
> with the default being -nowarn, unless stdin is a tty.  Thoughts?

Sounds good to me.
          cu andreas



Reply sent to Andreas Metzler <ametzler@debian.org>:
You have taken responsibility. (full text, mbox, link).


Notification sent to giuseppe bonacci <g.bonacci@libero.it>:
Bug acknowledged by developer. (full text, mbox, link).


Message #59 received at 194160-done@bugs.debian.org (full text, mbox, reply):

From: Andreas Metzler <ametzler@debian.org>
To: 194160-done@bugs.debian.org
Subject: Re: reportbug: dubious behaviour of '-o' operator in 'find'
Date: Sat, 11 Jun 2005 14:56:49 +0200
On 2003-05-21 giuseppe bonacci <g.bonacci@libero.it> wrote:
[...]
> according to the man-page and info, the expected output from the
> following find commands should be identical: 

> myhost# ls -lRgoF
> .:
> total 4
> drwxr-xr-x    2     4096 May 21 12:51 b/
> -rw-r--r--    1        0 May 21 12:51 c

> ./b:
> total 0
> -rw-r--r--    1        0 May 21 12:51 d
> myhost# find . -name b -prune -o -type f -print
> ./c
> myhost# find . -name b -prune -o -type f	# ABNORMAL
[...]

Hello,

As previously noted these two command should not generate the same
output, the latter is equivalent to:

find . \( -name b -prune -o -type f \) -print

(The documention says "If  the  expression  contains no actions other
than -prune, -print is performed on all files for which the expression
is true." which is different from "append -print to the given
commandline.)

            cu andreas

-- 
"See, I told you they'd listen to Reason," [SPOILER] Svfurlr fnlf,
fuhggvat qbja gur juveyvat tha.
Neal Stephenson in "Snow Crash"
                                           http://downhill.aus.cc/



Send a report that this bug log contains spam.


Debian bug tracking system administrator <owner@bugs.debian.org>. Last modified: Sat Dec 23 16:43:20 2023; Machine Name: buxtehude

Debian Bug tracking system

Debbugs is free software and licensed under the terms of the GNU Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.