fix: handle PAGER paths with spaces on Windows#924
Open
muratclk wants to merge 1 commit intocharmbracelet:masterfrom
Open
fix: handle PAGER paths with spaces on Windows#924muratclk wants to merge 1 commit intocharmbracelet:masterfrom
muratclk wants to merge 1 commit intocharmbracelet:masterfrom
Conversation
Use the system shell to interpret the PAGER command instead of naive string splitting by spaces. On Windows, this delegates to cmd /c, and on Unix to sh -c, matching the behavior of git and other CLI tools. This fixes the issue where setting PAGER to a path containing spaces (e.g., "C:\Program Files\Git\usr\bin\less.exe" -r) would fail because the path was split incorrectly. Fixes charmbracelet#385
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #385
On Windows, setting
PAGERto a path containing spaces (e.g.,"C:\Program Files\Git\usr\bin\less.exe" -r) causes glow to fail because the command string is naively split by spaces usingstrings.Split.Changes
Instead of splitting the
PAGERstring by spaces and passing parts toexec.Command, delegate to the system shell:cmd /c <pager command>sh -c <pager command>This matches the behavior of
git,man, and other CLI tools that invoke$PAGER. The shell handles quoted paths, environment variable expansion, and argument parsing correctly.Test plan
PAGERto a path with spaces (e.g.,"C:\Program Files\Git\usr\bin\less.exe" -r) on Windowsglow -p README.mdPAGER="less -r"is unchanged