#28656 [Bgs->Opn]: the glob() function does not match the same as shell wildcarding does
| From: | phpbugs at atu dot cjb dot net | Date: | Tue, 08 Jun 2004 02:55:46 +0000 |
| Subject: | #28656 [Bgs->Opn]: the glob() function does not match the same as shell wildcarding does | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-60535@lists.php.net to get a copy of this message | ||
ID: 28656
User updated by: phpbugs at atu dot cjb dot net
Reported By: phpbugs at atu dot cjb dot net
-Status: Bogus
+Status: Open
Bug Type: Filesystem function related
Operating System: GNU/Linux
PHP Version: 4.3.6
New Comment:
"The glob() function searches for all the pathnames matching pattern
according to the rules used by the shell. No tilde expansion or
parameter substitution is done."
This is from the manual page on php.net, but it is not correct. The
example I gave has nothing at all to do with "ls", as iliaa suggested.
It is "matching pattern according to the rules used by the shell",
exactly as the description states. Go to a shell and type in the
command I said:
echo Dir/*/
That is pure shell wildcard expansion -- nothing to do with ls or any
other shell command. Clearly globbing "*/" should not match "*" as it
currently does, if the objective is to use standard UNIX wildcard
expansion.
Previous Comments:
------------------------------------------------------------------------
[2004-06-07 15:53:07] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
glob() function returns the same output as the glob() libc
function. The output of ls is something different and
unrelated.
------------------------------------------------------------------------
[2004-06-07 00:33:52] phpbugs at atu dot cjb dot net
Description:
------------
A trailing forward slash is ignored by glob(), but is not with standard
UNIX wildcard matching.
ls -lp Dir
drwx------ 2 raven users 48 Jun 6 15:26 CSS/
drwx------ 2 raven users 48 Jun 6 15:26 Extra/
drwx------ 2 raven users 48 Jun 6 15:26 Images/
-rw------- 1 raven users 0 Jun 6 15:26 Main.data
-rw------- 1 raven users 0 Jun 6 15:26 index.php
echo Dir/*/
Dir/CSS/ Dir/Extra/ Dir/Images/
Reproduce code:
---------------
foreach (glob("Dir/*/") as $Dir) { echo "$Dir "; }
Expected result:
----------------
Dir/CSS/ Dir/Extra/ Dir/Images/
Actual result:
--------------
Dir/CSS/ Dir/Extra/ Dir/Images/ Dir/Main.data Dir/index.php
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=28656&edit=1