[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #20970] Trailing slash on directory arguments breaks -name
From: |
Ross Kendall Axe |
Subject: |
[bug #20970] Trailing slash on directory arguments breaks -name |
Date: |
Tue, 04 Sep 2007 07:19:03 +0000 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6 |
URL:
<http://savannah.gnu.org/bugs/?20970>
Summary: Trailing slash on directory arguments breaks -name
Project: findutils
Submitted by: rossaxe
Submitted on: Tuesday 04/09/07 at 07:19
Category: find
Severity: 3 - Normal
Item Group: Wrong result
Status: None
Privacy: Public
Assigned to: None
Originator Name:
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release: 4.2.31
Fixed Release: None
_______________________________________________________
Details:
The following commands illustrate the problem:
$ mkdir -p foo/bar
$ find foo -name foo
foo
$ find foo/ -name foo
The first command returns the directory 'foo', as expected, but the second
one does not find it, apparently because the trailing / was considered to be
part of the filename. The following test seems to confirm this:
$ find foo/ -name foo/
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/'.
foo/
Despite the warning message about slashes in the -name match, it does in fact
work. This issue is probably related to the following oddity:
$ find foo
foo
foo/bar
$ find foo/
foo/
foo/bar
The first command is perfectly consistent in that it doesn't have trailing
slashes in the output, but the second command does have a trailing slash on
one directory, but not the other. I'm not entirely sure whether this
behaviour is a good thing or not. Possibly the second command should produce
'foo//bar' (2 slashes) for consistency.
There is a similar effect when using -wholename, but that may actually be the
best behaviour.
_______________________________________________________
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,
Ross Kendall Axe <=