Skip to content

browser: handle launcher paths that contain spaces#223

Open
c-tonneslan wants to merge 1 commit into
cli:trunkfrom
c-tonneslan:fix/browser-launcher-with-spaces
Open

browser: handle launcher paths that contain spaces#223
c-tonneslan wants to merge 1 commit into
cli:trunkfrom
c-tonneslan:fix/browser-launcher-with-spaces

Conversation

@c-tonneslan
Copy link
Copy Markdown

Closes #174.

The launcher was always passed through `shlex.Split`, so a path like `C:\Program Files\Google\Chrome\Application\chrome.exe` became `C:` + `Program` + `Files...` and the lookup blew up because `C:` wasn't on PATH. The reported workaround was to move the executable somewhere with no spaces.

Try the launcher as a literal path first. If `LookPath` finds it, use it directly. Otherwise fall back to the existing shlex-based split so launchers with extra args (`firefox --private-window`, `open -a 'Google Chrome'`) keep working.

Added two new tests:

  • `TestSplitLauncherPathWithSpaces` covers the regression by dropping a fake executable into a directory with a space and asserting the literal path resolves cleanly.
  • `TestSplitLauncherWithArgs` locks in the shlex fallback for launchers that come with arguments.

The launcher was always run through shlex.Split, which turned a path
like C:\Program Files\Google\Chrome\Application\chrome.exe into "C:"
+ "Program" + "Files..." and then complained that "C:" couldn't be
found on PATH. Users had to either quote the path themselves or move
the executable somewhere without spaces.

Try the launcher as a literal path first. If LookPath finds it, use
it directly with no extra arguments. Otherwise fall back to the
existing shlex-based split so `firefox --private-window` style
launchers keep working.

Closes cli#174.

Signed-off-by: Charlie Tonneslan <cst0520@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

browse() error when launcher has whitespace

1 participant