Closed skotos closed 10 years ago
If you like the above patch, I can do a pull request on it.
@skotos I think normalizePath('./test')
should still give you test
.
That's what I thought. I'll submit a pull request after I tweak it.
Sorry, I accidently created the Pull Request as #3529
I've traced this to the \yii\helpers\BaseFileHelper::normalizePath function turning "." into a blank string. Should it instead leave a simple "." as a reference to the current directory?
isn't a blank string and .
equivalent for current dir?
Not in case when a command requires input. If it's .
it is considered an argument with current dir as a values. If it's empty it's considered as missing argument.
okay but what is the problem then? normalizePath is called after the arguments have been given.
$ php -r "var_dump(is_dir('.'));"
(true)
$ php -r "var_dump(is_dir(''));"
(false)
$ php -r "var_dump(scandir(''));"
PHP Warning: scandir(): Directory name cannot be empty in Command line code on line 1
bool(false)
$ php -r "var_dump(scandir('.'));"
array(4) {
[0]=>
string(1) "."
[1]=>
string(2) ".."
[2]=>
string(3) "bar"
[3]=>
string(3) "foo"
}
thanks, its clear now.
When I execute the following I get an error...
I've traced this to the \yii\helpers\BaseFileHelper::normalizePath function turning "." into a blank string. Should it instead leave a simple "." as a reference to the current directory?
The following patch would accomplish this, but it would also mean
normalizePath('./test') === "./test"
(not "test"). What would be best for the framework?