Req #53787 [Opn->Wfx]: Add support for chdir() without any parameter called
| From: | pajoye@php.net | Date: | Wed, 19 Jan 2011 12:47:53 +0000 |
| Subject: | Req #53787 [Opn->Wfx]: Add support for chdir() without any parameter called | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-158003@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=53787&edit=1
ID: 53787
Updated by: pajoye@php.net
Reported by: rzufall36 at yahoo dot com
Summary: Add support for chdir() without any parameter called
-Status: Open
+Status: Wont fix
Type: Feature/Change Request
Package: Directory function related
Operating System: Ubuntu 10.04
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
chdir maps posix chdir, not Bash (or some other shells) specific
features.
Previous Comments:
------------------------------------------------------------------------
[2011-01-19 13:28:36] rzufall36 at yahoo dot com
Description:
------------
For consistency with the widely known 'cd' tool and existing
functionality from
other programming languages, e.g. Perl, I believe that a call to the
chdir()
function without any parameters should be supported. In Bash and Perl,
cd/chdir
without any parameters given, changes back to the home directory of the
user. As
this is pretty convenient (because you usually start in the home
directory and
can then easier get back), I believe that such a change would also be
pretty
useful within PHP.
Test script:
---------------
# dummy script, no useful functionality
# to be executed from command line
echo "Write something:\n";
$string = trim(fgets(STDIN));
chdir('somedir');
file_put_contents('file', $string);
chdir()
file_put_contents('file', $string);
# or just simply on the command line
php -r 'chdir();'
Expected result:
----------------
There should be no PHP warning (obviously), we should change back to the
user's
home directory and the last line
file_put_contents('file', $string);
should then write the $string variable to /home/johndoe/file
Actual result:
--------------
$string is written to /home/johndoe/somedir/file (just as expected),
however
chdir() gives a PHP Warning: chdir() expects exactly 1 parameter, 0
given and
aborts the programm.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=53787&edit=1