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

Context output options (-A, -B, and -C) do not override the "--passthru" option #1868

Closed
lousyd opened this issue May 19, 2021 · 1 comment
Closed
Labels
bug A bug. rollup A PR that has been merged with many others in a rollup.

Comments

@lousyd
Copy link
Contributor

lousyd commented May 19, 2021

What version of ripgrep are you using?

ripgrep 12.1.1
-SIMD -AVX (compiled)
+SIMD +AVX (runtime)

How did you install ripgrep?

dnf install ripgrep

What operating system are you using ripgrep on?

GNU/Linux 5.11.18-300.fc34.x86_64 x86_64

Describe your bug.

The general approach of configuration and command line options seems to be that if two options conflict, the later one prevails and the earlier one is treated as if it were never given. For example, the "--binary" option will cancel out the "--no-binary" option if it appears later in the configuration file or later on the command line. Similarly, "--text" will override the "--binary" option if it appears later in the configuration file or command line, and vice versa. However, the context output options (-A, -B, and -C) do not similarly override and get overridden by the "--passthru" option. It seems as if they should override each other.

I encountered this when spitting out a bunch of JSON that I wanted to filter through ripgrep. I put together my command line to output the JSON, then piped it to rg with "--passthru" and my pattern. It worked as expected. Then I up-arrowed to get the same command line but added a "-C" to it. I didn't even think about the fact that I hadn't removed the previous "--passthru". I just thought, conceptually, that I was further refining the command line to filter down the results a little more. It confused me when I still got aaalllll of the JSON.

What are the steps to reproduce the behavior?

printf 'line 1\nline 2\nline 3\n' | rg --passthru -B1 3
printf 'line 1\nline 2\nline 3\n' | rg -B1 --passthru 3

What is the expected behavior?

It seems as if the context output options (-A, -B, and -C) should override the "--passthru" option, and vice versa, when given later in the configuration file or command line.

@BurntSushi
Copy link
Owner

Yes, I think I agree.

@BurntSushi BurntSushi added the bug A bug. label May 19, 2021
@BurntSushi BurntSushi added the rollup A PR that has been merged with many others in a rollup. label May 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug. rollup A PR that has been merged with many others in a rollup.
Projects
None yet
Development

No branches or pull requests

2 participants