Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.10.16

Bug #12553 System::find() does not find exact filename matches
Submitted: 2007-11-29 17:37 UTC
From: jorrit Assigned: cellog
Status: Closed Package: PEAR (version 1.6.2)
PHP Version: 5.2.4 OS: Windows/Gentoo Linux
Roadmaps: 1.7.0    
Subscription  


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 13 + 17 = ?

 
 [2007-11-29 17:37 UTC] jorrit (Jorrit Schippers)
Description: ------------ The System::find() method mimics the important parts of the common find utility on unix. If you would execute find . -name "something" you would get files and directories named "something" located in or below the current directory. The System::find() utility however works slightly differently: when executing a search on an exact filename (by which I mean: without an operator such as *) only files are returned of which the complete path matches the given input. This is not what the user expects and not useful at all. The patch I will attach contains a fix that allows matching on every path component below the given path (the first argument to the method). Besides that, it will prevent errors due to regular expression characters being given as an expression and it will allow the ? character to match a single character, just as bash does. I added a test file. I tried to use test.phpt but the test file and some System.php methods are completely bugged when used with paths with a space in it (cat()). test-online.phpt even caused my c:\ drive to fill up trying to put a gazillion times the html source of pear.php.net in a file called c:\Documents Test script: --------------- A test case can be found at lines 173-175 from PEAR/Command/Test.php: $dir = System::find(array($p, '-type', 'f', '-maxdepth', $depth, '-name', 'AllTests.php')); This will never work because 'AllTests.php' is matched against the complete path, for instance: /home/jorrit/pear/Net_FTP/tests/AllTests.php Expected result: ---------------- The expected result is that the filename /home/jorrit/pear/Net_FTP/tests/AllTests.php is returned, if executed in the proper environment. Actual result: -------------- No files are returned.

Comments

 [2007-12-03 01:41 UTC] cellog (Greg Beaver)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. the patch, although a good start, contained many critical bugs. I also fixed a problem in the test on my system. Fix is committed however, which should solve the problem.