This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

interesting problem with "find"


One of my collegues just found an interesting behavior in "find". We are running 
cywin32 b18, cygwin.dll is Sergey's latest, and the find that comes with it on 
NT4.0. 

He has found that if you have nested directories of the same name eg) x/x/... or 
even x/y/x/... and type "find . -name '*' -print", nothing is found except the 
directories. Renaming the top level directory to anything else or specifying the 
top directory rather than using "." "fixes" the problem. However, the results 
are somewhat contradictory. Could someone explain the following series of 
results? (all within the b18 bash shell):

We start with a directory tree containing only:
x/y/x/zz.tmp then:

1) find . -name * -print
./x
./x/y/x
bash is globbing *->x and looking for that as expected, finding the 2 
directories.

2) find . -name "*" -print
./x
./x/y
./x/y/x
This should work, globbing is escaped. But it finds only the directories, not 
the file. Single or double quotes or backslash have the same behavior.

3) find . -name *.tmp -print
finds nothing: globbing again, can't find "x.tmp"

4) find . -name "*.tmp" -print
finds nothing. This should work.

Substituting "x" for "." in the four cases:

1) find x -name * -print
x
x/y/x
Get the expected result, looking for "x"

2) find x -name "*" -print
x
x/y
x/y/x
x/y/x/zz.tmp
This is what it should be. Why didn't it work with "."?

3) find x -name *.tmp -print
x/y/x/zz.tmp
I would have thought that this would fail. It should be looking for "x.tmp" or 
maybe "y.tmp" depending on which directory it's globbing in.

4) find x -name "*.tmp" -print
x/y/x/zz.tmp
This is as expected.

Renaming either of the "x" directories to z so that we have, for example:
z/y/x/zz.tmp (same result with x/y/z/zz.tmp)
1) find . -name * -print
./z
as expected after globbing.

2) and 4) give the results you'd expect, they find either all files or only the 
.tmp file since the "*" is escaped.

3) however works just like 4), as if the "*" were escaped.

Alan
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]