-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 $LESSOPEN
tests and behavior
#2662
Conversation
In the absence of a better solution, I ignored I'll make sure to take another look at the test later when I get a chance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the quick update. I'm not sure about needing --lessopen
to enable. Long term we want to let the LESSOPEN
env var decide if the feature is on or off, I think? Or could someone want LESSOPEN
set but not want bat
to process it?
CHANGELOG.md
Outdated
|
||
## Bugfixes | ||
|
||
- Fix `more` not being found on Windows when provided via `BAT_PAGER`, see #2570, #2580, and #2651 (@mataha) | ||
- Fix `less` preprocessing with `LESSOPEN` again and causing a test to intermittently fail, and incorrect `LESSOPEN` behavior see #2444, #2602, and #2662 (@Anomalocaridid) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was was never present in a release version of bat, right? In that case I don't think we should have this as a bugfix. But feel free to list the PRs in the "Features" item.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved the PRs to the "Features" item. How is it now?
Cargo.toml
Outdated
@@ -21,6 +21,7 @@ application = [ | |||
"build-assets", | |||
"git", | |||
"minimal-application", | |||
"lessopen", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually think we should give this feature some more testing before we enable it by default. I plan on making a release in 1-4 weeks, and let's keep it disabled. Then right after the release we can enable it again on the git master branch so it gets some testing. Once it has been enabled by default on git master without any serious bugs reported, we can enable it by default on an official release.
Note that it will still be possible to enable the features in the upcoming official release like this: cargo install bat --features lessopen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that you mention it, that seems like a much better option. I have removed the commit that re-enabled the lessopen
feature by default.
@@ -32,10 +35,18 @@ enum LessOpenKind { | |||
|
|||
impl LessOpenPreprocessor { | |||
/// Create a new instance of LessOpenPreprocessor | |||
/// Will return Ok if and only if $LESSOPEN is set | |||
/// Will return Ok if and only if $LESSOPEN is set and contains exactly one %s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean with "exactly one %s"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's say you want to use batpipe
as to preprocess less
or bat
's input.
batpipe %s
is a valid command for $LESSOPEN
.
The following are not valid and will result in less
/bat
ignoring it and printing a warning:
batpipe
batpipe %s %s
batpipe %s %s (...) %s
); | ||
|
||
bat() | ||
.env("LESSOPEN", "|echo File is %s") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am completely unfamiliar LESSOPEN and with %s. Can you link to a good online resource where I can learn more please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend the INPUT PREPROCESSOR
section of the less(1)
man page. It is what I used to implement $LESSOPEN
support.
Actually, there is a use case where one would want Of course, if you still have reservations, we could try alternative approaches, like this suggestion to use separate variables like Or maybe something else entirely if you have any suggestions. |
Thanks! Let's merge this. |
Thank you @Anomalocaridid the update and @Enselic for the review. |
Thank both of you as well! |
This PR has a handful of fixes for the
$LESSOPEN
functionality that addresses concerns brought up in #2444 and #2602:--no-lessopen
toless
to prevent it from preprocessing input a second file.This should fix the intermittently failing test, assuming we correctly figured out the cause.Unfortunately, this did not appear to fix the intermittently failing test.$LESSOPEN
support opt-in rather than on by default. I added a--lessopen
flag to enable this and kept the--no-lessopen
flag for people that add--lessopen
to their config file, but want to override it for whatever reason. Also changed the tests, man page, and completions accordingly.$LESSOPEN
has exactly one%s
, otherwise ignoring it and with a warning message much likeless
does. Also changed the tests accordingly.$LESSOPEN
PR from v0.22.0 to the unreleased features section since it wasn't updated before it was merged recently.I re-added thePer @Enselic's request, I removed it so it has a chance to get more testing before being enabled by default.lessopen
feature todefault
since you need to enable it with an option now anyways. I made sure to have this in its own commit so it can be easily removed if anyone objects to it.