[bug #20970] Trailing slash on directory arguments breaks -name

2007-11-26 Thread James Youngman

Update of bug #20970 (project findutils):

  Status:   Confirmed = Fixed  
 Assigned to:   ericb = jay


___

Reply to this item at:

  http://savannah.gnu.org/bugs/?20970

___
  Message sent via/by Savannah
  http://savannah.gnu.org/





[bug #20970] Trailing slash on directory arguments breaks -name

2007-11-20 Thread Geoff Clare

Follow-up Comment #6, bug #20970 (project findutils):

The Austin Group interpretation was issued/approved today.

http://www.opengroup.org/austin/interps/uploads/40/14959/AI-186.txt

___

Reply to this item at:

  http://savannah.gnu.org/bugs/?20970

___
  Message sent via/by Savannah
  http://savannah.gnu.org/





[bug #20970] Trailing slash on directory arguments breaks -name

2007-09-08 Thread James Youngman

Follow-up Comment #4, bug #20970 (project findutils):

Partly because we currently seem to be following common practice, I would be
inclined to ask for a POSIX interp (i.e. for the current issues standard), or
at least comment from the Austin Group, before changing our current behaviour.
 

The issue with -wholename you mention at the foot of your 09/04/2007 comment
probably also merits discussion with the Austin Group, since -path is being
standardised.


___

Reply to this item at:

  http://savannah.gnu.org/bugs/?20970

___
  Message sent via/by Savannah
  http://savannah.gnu.org/





[bug #20970] Trailing slash on directory arguments breaks -name

2007-09-08 Thread Eric Blake

Follow-up Comment #5, bug #20970 (project findutils):

I've raised the issue with the Austin Group.  Hopefully an interp will be
reached before POSIX 200x is finalized:

https://www.opengroup.org/sophocles/show_mail.tpl?CALLER=index.tplsource=Llistname=austin-review-lid=2512


___

Reply to this item at:

  http://savannah.gnu.org/bugs/?20970

___
  Message sent via/by Savannah
  http://savannah.gnu.org/





[bug #20970] Trailing slash on directory arguments breaks -name

2007-09-04 Thread Eric Blake

Update of bug #20970 (project findutils):

  Depends on: = bugs #20688

___

Follow-up Comment #1:

Part of me was inclined to mark this as invalid, since other implementations
that claim to implement POSIX do likewise (for example, on Solaris):

$ mkdir -p foo/bar
$ /usr/xpg4/bin/find foo -name foo
foo
$ /usr/xpg4/bin/find foo/ -name foo
$

and changing behavior would only be introducing gratuitous incompatibilities.
 But on a closer look, the wording in POSIX is:

The primary shall evaluate as true if the basename of the filename being
examined matches pattern

and POSIX is clear (for both basename(1) and basename(3)) that trailing
slashes are stripped when determining the basename, which means Solaris find
has the same bug.

However, remember that foo and foo/ are different files when foo is a
symlink to a directory, so, modulo the -H and -L options, the output should
not strip trailing slashes for directories listed on the command line. 
However, since foo/bar and foo//bar are required to name the same file, I
would prefer reducing the amount of output, and always output foo/bar,
regardless of how many trailing slashes were given on the command line.

Therefore, I think the correct behavior is:

$ find foo
foo
foo/bar
$ find foo/
foo/
foo/bar
$ find foo/
foo/
foo/bar
$ find foo -name foo
foo
$ find foo/ -name foo
foo
$ find foo/ -name foo/
find/find: warning: Unix filenames usually don't contain slashes (though
pathnames do).  That means that '-name foo/' will probably evaluate to false
all the time on this system.  You might find the '-wholename' test more
useful, or perhaps '-samefile'.  Alternatively, if you are using GNU grep, you
could use 'find ... -print0 | grep -FzZ foo/'.
$

As I most recently touched this area of code for bug 20688, I'll provide a
patch.

___

Reply to this item at:

  http://savannah.gnu.org/bugs/?20970

___
  Message sent via/by Savannah
  http://savannah.gnu.org/





[bug #20970] Trailing slash on directory arguments breaks -name

2007-09-04 Thread Eric Blake

Update of bug #20970 (project findutils):

  Status:None = Confirmed  
 Assigned to:None = ericb  


___

Reply to this item at:

  http://savannah.gnu.org/bugs/?20970

___
  Message sent via/by Savannah
  http://savannah.gnu.org/





[bug #20970] Trailing slash on directory arguments breaks -name

2007-09-04 Thread Ross Kendall Axe

Follow-up Comment #2, bug #20970 (project findutils):

Just for fun, I tried it on FreeBSD as well, with identical results to GNU
find.  I had intuitively assumed that the -name thing was a no-brainer, for
basically the reasons you mentioned (though I don't have a copy of POSIX
available), but it seems like this odd behaviour is quite common.  Either way,
I was surprised as hell when find /usr/man/ -name 'man?*' matched /usr/man
itself, and I shall try to avoid trailing slashes in my scripts or use
-wholename or -samefile from now on to work around this corner case.

As for the trailing slash in the output, that's a good point about symlinks. 
I'm even more convinced now that that's probably best left alone.

Two things immediately spring to mind about multiple trailing slashes in the
output:
1) I would expect find foo// -wholename foo// to match, so maybe some care
would need to be taken (should find foo// -wholename foo/ also match?), and
2) Processing the output with sed or somesuch might break for similar reasons
if the extra slashes were removed (although -printf is probably better for
most things you could do with sed).

Things like that make me think that probably only -name is worth changing,
especially since tr -s / gets rid of the extra slashes easily enough. :-)

___

Reply to this item at:

  http://savannah.gnu.org/bugs/?20970

___
  Message sent via/by Savannah
  http://savannah.gnu.org/