Bug #80155 [Com]: basename("/tmp","tmp") fails
| From: | divinity76 at gmail dot com | Date: | Sun, 27 Sep 2020 14:35:48 +0000 |
| Subject: | Bug #80155 [Com]: basename("/tmp","tmp") fails | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-229236@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80155&edit=1
ID: 80155
Comment by: divinity76 at gmail dot com
Reported by: divinity76 at gmail dot com
Summary: basename("/tmp","tmp") fails
Status: Not a bug
Type: Bug
Package: *Directory/Filesystem functions
Operating System: both Windows and Linux
PHP Version: 7.4.10
Block user comment: N
Private report: N
New Comment:
it seems the GNU basename documentation (at https://www.gnu.org/software/coreutils/manual/html_node/basename-invocation.html#basename-invocation
) doesn't say anything about what happens when the suffix matches the whole name, much like the
PHP documentation
Previous Comments:
------------------------------------------------------------------------
[2020-09-27 14:29:54] divinity76 at gmail dot com
@ sjon@php.net
nowhere in the documentation do i see anything like "if the suffix is the whole name, it will
not be cut off", perhaps it is a documentation issue then?
wonder what the GNU basename documentation says about it, I'll take a look at that
------------------------------------------------------------------------
[2020-09-27 12:44:10] sjon@php.net
.
------------------------------------------------------------------------
[2020-09-27 12:43:35] sjon@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
while unexpected - this behavior matches what GNU's basename returns, see:
$ basename /tmp mp
t
$ basename /tmp tmp
tmp
I assume this is because once the entire pathname is removed, it would no longer be a suffix
------------------------------------------------------------------------
[2020-09-27 11:43:38] divinity76 at gmail dot com
Description:
------------
running basename("/tmp","tmp") fails to remove the "tmp" suffix from
the end of the name.
tested on PHP 8.0.0 beta3 running on Linux, and PHP 7.3.7 running on Windows 10.
Test script:
---------------
<?php
var_dump(basename("/tmp","mp"));
var_dump(basename("/tmp","tmp"));
Expected result:
----------------
string(1) "t"
string(0) ""
Actual result:
--------------
string(1) "t"
string(3) "tmp"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80155&edit=1