Skip to content

Conversation

@retlehs
Copy link
Member

@retlehs retlehs commented Dec 5, 2024

When running wp acorn acorn:install, at the last step you're prompted to star this repo. The command could fail in some instances, like when running the command from a Linux VM:

sh: 1: xdg-open: not found
INFO Thank you!

This PR adds a fallback to show the URL to this repo if the open command fails:

image

@retlehs retlehs self-assigned this Dec 5, 2024
$opened = match (PHP_OS_FAMILY) {
'Darwin' => shell_exec('open ' . $this->repoUrl . ' 2>/dev/null') !== null,
'Linux' => shell_exec('xdg-open ' . $this->repoUrl . ' 2>/dev/null') !== null,
'Windows' => shell_exec('start ' . $this->repoUrl . ' 2>nul') !== null,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be wrong about the behavior of shell_exec(), but afaik the first argument for start is the window title, i.e., start <title> <command>

Suggested change
'Windows' => shell_exec('start ' . $this->repoUrl . ' 2>nul') !== null,
'Windows' => shell_exec('start "" ' . $this->repoUrl . ' 2>nul') !== null,

If you just run start <url>, it will open a new cmd prompt with the URL as the title of the prompt.

start-url

Changing it to start "" <url> opens the URL in my default browser.

Again, I didn't test with shell_exec(), though, since I don't have PHP installed in Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants