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

Handle less in a portable way #290

Merged
merged 1 commit into from
Sep 7, 2018
Merged

Handle less in a portable way #290

merged 1 commit into from
Sep 7, 2018

Conversation

Aankhen
Copy link
Contributor

@Aankhen Aankhen commented Sep 7, 2018

The current logic for special-casing less relies on the pager being specified as the literal string or using Unix-style paths. It also ignores the actual pager specified when calling it, so even if you set PAGER/BAT_PAGER to /my/path/to/less, bat will simply call less.

This PR treats any specified pager as a path and checks only the file stem so that C:\foo\bar\less.exe, /foo/bar/less, and less are all recognized. It also uses the specified less.

I managed to write a test for this by creating a stub bin/less.rs that verifies its arguments and the environment. However, this binary was installed along with bat when running cargo install. I haven’t yet found a way to test the behaviour without this issue, so for the moment I can only offer the fix without the test (but with the assurance that I’ve tested its behaviour both manually and automatically).

Copy link
Owner

@sharkdp sharkdp left a comment

Choose a reason for hiding this comment

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

Fantastic stuff, thank you very much!

@sharkdp
Copy link
Owner

sharkdp commented Sep 7, 2018

for the moment I can only offer the fix without the test (but with the assurance that I’ve tested its behaviour both manually and automatically).

Thank you for thinking about the tests! I'm fine with merging this without tests for now, as I still plan to extend our integration tests anyway.

@sharkdp sharkdp merged commit 76df41f into sharkdp:master Sep 7, 2018
@Aankhen Aankhen deleted the portable-less-behaviour branch September 7, 2018 20:04
@Aankhen
Copy link
Contributor Author

Aankhen commented Sep 7, 2018

Excellent!

@sharkdp
Copy link
Owner

sharkdp commented Sep 12, 2018

Released in v0.7.0.

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.

2 participants