Closed plagasul closed 6 months ago
It's really hard to help here without a linux installation. Help is definitely appreciated.
The wildcard *
are already outside of shell quotes, just inside of PHP quotes. I think it's more an issue with the {.[!.],}
syntax. Whatever it is supposed to do, maybe it is supported by zsh
(the default shell on macOS) but not by bash
that is common as default shell on Linux systems (but also present on macOS).
Apologies, for I did not see the answers to this issue. If there is anything you want me to try, please let me know, I have, let's say, intermediate to high CLI knowledge, but REGEX are always a pain to understand :)
Hello again, @lukasbestle in a fresh installation of linux mint cinnamon 21.2 and using zsh and not bash I get exactly the same error
Please tell me what you'd like me to test, as said I can't troubleshoot that regex by myself.
I may have a hint on what is going on. I was trying to see which shell does php run when using exec(), and found out that POSIX requires exec() to run /bin/sh
which in turn is a symlink to /bin/dash
no zsh, no bash, dash, or Debian Almquist Shell
This is like this at least in Ubuntu, Debian and derivatives since 2006 it seems, dash being the shell that the system works with when booting etc, see here.
So it may well be that dash syntax, which should be POSIX, differs from bash or zsh syntax.
Nevertheless I am reading that since Catalina, OSX may be using dash as bin/sh aswell? as I assume that you people run osx machines, could you please check what shell does /bin/sh run in your system?
Thank you
Ok, I ran some additional tests.
If I change the unzip.php line 43 from
exec('mv ' . $to . '/*/{.[!.],}* ' . $to . '/');
to
exec("/bin/bash -c 'mv " . $to . "/*/{.[!.],}* " . $to . "/'");
...in order to ensure that bash (and not dash) is running the command, then the installation works.
Which leads me to believe that this command is not POSIX, because dash is. Then a solution may be to make the command POSIX? It seems that a subset of REGEX is POSIX.
Thanks
Thanks for the investigation. I guess the purpose of that syntax is to move both visible and invisible files (starting with a dot). I don't know a POSIX-compatible syntax from the top of my head, but a pretty simple solution could be two separate exec()
calls, one with .*
and one with *
.
As far as I've been able to tell, the shell globing pattern you originally use matches dotfiles where at least one character follows the dot, thus avoiding .
and ..
If you use a mere .*
that will match .
and ..
and that will return an error, because those cannot be moved. I assume that may interrupt the script ?
You are right.
Another alternative would be to create a random folder in sys_get_temp_dir()
, unzip inside that folder and move the whole directory.
Yes, same issue on my windows local machine. I just wonder why don't we just use Dir::move
method instead using mv
?
@afbora because Kirby is not necessarily installed yet and we don't add it as a dependency to avoid conflicts between two different installations. But we actually really might want to handle this via PHP anyway. Could you give it a go?
Really? I didn't realize that. I used the Kirby toolkit in the latest commands, because they already used in the old commands 🙈 Anyway, I'll try to convert it all to PHP native methods.
All kirby install variants fail with a 'mv' error:
mv: cannot stat '/path/to/folder/*/{.[!.],}*': No such file or directory
As I explain in this other issue, the error comes from the
unzip
command, line 43.exec('mv ' . $to . '/*/{.[!.],}* ' . $to . '/');
Simply trying to run
kirby unzip file folder
results in the same errorI am on linux mint 21 cinnamon, and this happens with both bash and zsh, PHP 8.1.16
I find two similar cases online where the issue is that * should go outside of the quotes, see here and here.
Thanks