Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix guessChromeBinaryPath on Ubuntu Linux + add Chromium #595

Closed
wants to merge 7 commits into from

Conversation

divinity76
Copy link
Contributor

on Ubutu Linux, "command" is a bash builtin, not a standalone binary, and shell_exec() tries to find the "command" binary and fails, thus the original code never worked on Ubuntu Linux (I think the same is true for the entire Debian-derived family of operating systems, but don't quote me on that), fixing that by doing bash -c 'command... instead.

Also added chromium support, for those who have Chromium but not Chrome installed.

It will look for Chrome first, and if it cannot find Chrome, it will look for Chromium second, and if all fails, it falls back to hardcoded "chrome".

on Ubutu Linux, "command" is a bash builtin, not a standalone binary, and shell_exec() tries to find the "command" binary and fails, thus the original code never worked on Ubuntu Linux
(I think the same is true for the entire Debian-derived family of operating systems, but don't quote me on that), 
fixing that by doing `bash -c 'command...`  instead.

Also added chromium support, for those who have Chromium but not Chrome installed.

It will look for Chrome first, and if it cannot find Chrome, it will look for Chromium second, and if all fails, it falls back to hardcoded "chrome".
there is also a FOSS game by the name chromium iirc..
@enricodias
Copy link
Member

I use Ubuntu and it works fine here 🤔

λ command -v google-chrome
/usr/bin/google-chrome

@divinity76
Copy link
Contributor Author

divinity76 commented Jan 11, 2024

I use Ubuntu and it works fine here 🤔

λ command -v google-chrome
/usr/bin/google-chrome

yeah in your shell with your shell builtins, but try

php -r 'var_dump(shell_exec("command -v google-chrome"));'

and then try

php -r 'var_dump(shell_exec("bash -c '\''command -v google-chrome'\''"));'

@enricodias
Copy link
Member

Same thing in both:

λ php -r 'var_dump(shell_exec("command -v google-chrome"));'  
string(23) "/usr/bin/google-chrome
"
λ php -r 'var_dump(shell_exec("bash -c '\''command -v google-chrome'\''"));'  
string(23) "/usr/bin/google-chrome
"

@divinity76
Copy link
Contributor Author

divinity76 commented Jan 11, 2024

@enricodias well that confuses me, what do you get by

type command;
php -r 'var_dump(shell_exec("which command"));'

?

When I do it, I get

hans@DESKTOP-EE15SLU:/$ type command; php -r 'var_dump(shell_exec("which command"));'
command is a shell builtin
NULL

@enricodias
Copy link
Member

I got the same;

command is a shell builtin
NULL

It is a builtin, but shell_exec can still use it.

@divinity76
Copy link
Contributor Author

divinity76 commented Jan 12, 2024

@enricodias wow.. you're entirely correct!

I could've sworn that
php -r 'var_dump(shell_exec("command -v google-chrome"));'
didn't work for me yesterday, and concluded that shell_exec() doesn't have access to shell builtins,
... but it does work now! nevermind 🤷‍♂️ and sorry

@divinity76 divinity76 closed this Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants