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

Exit status should be independent of --passthrough #940

Closed
jzinn opened this issue Jun 6, 2018 · 1 comment · Fixed by #1017
Closed

Exit status should be independent of --passthrough #940

jzinn opened this issue Jun 6, 2018 · 1 comment · Fixed by #1017
Labels
bug A bug. question An issue that is lacking clarity on one or more points.

Comments

@jzinn
Copy link

jzinn commented Jun 6, 2018

What version of ripgrep are you using?

$ rg --version
ripgrep 0.8.1
-SIMD -AVX

How did you install ripgrep?

Homebrew

What operating system are you using ripgrep on?

macOS 10.13.4

Describe your question, feature request, or bug.

The command

rg --passthrough searchterm file.txt

should exit with the same code as when the command is run without the flag.

Both ack and ag work this way.

If this is a bug, what are the steps to reproduce the behavior?

$ echo hi > file
$ rg asdf file
$ echo $?
1
$ rg --passthrough asdf file
1:hi
$ echo $?
0

If this is a bug, what is the actual behavior?

ripgrep --passthrough always exits with 0 (unless the file is empty).

$ rg --passthrough --debug asdf file
DEBUG/grep::search/grep/src/search.rs:195: regex ast:
Alternate(
    [
        Literal {
            chars: [
                'a',
                's',
                'd',
                'f'
            ],
            casei: false
        },
        StartText
    ]
)
DEBUG/globset/globset/src/lib.rs:401: built glob set; 0 literals, 0 basenames, 0 extensions, 0 prefixes, 0 suffixes, 1 required extensions, 0 regexes
1:hi

If this is a bug, what is the expected behavior?

To exit with the same status as without the flag.

@BurntSushi
Copy link
Owner

This is an interesting bug. I will see what I can do about it, but this may require too much implementation complexity to fix.

Both ack and ag work this way.

It does appear that ack does, but I can't even get ag's passthrough option to work. In general, ag should not be used as a model for correctness.

@BurntSushi BurntSushi added bug A bug. question An issue that is lacking clarity on one or more points. labels Jun 6, 2018
BurntSushi added a commit that referenced this issue Aug 19, 2018
This commit updates the CHANGELOG to reflect all the work done to make
libripgrep a reality.

* Closes #162 (libripgrep)
* Closes #176 (multiline search)
* Closes #188 (opt-in PCRE2 support)
* Closes #244 (JSON output)
* Closes #416 (Windows CRLF support)
* Closes #917 (trim prefix whitespace)
* Closes #993 (add --null-data flag)
* Closes #997 (--passthru works with --replace)

* Fixes #2 (memory maps and context handling work)
* Fixes #200 (ripgrep stops when pipe is closed)
* Fixes #389 (more intuitive `-w/--word-regexp`)
* Fixes #643 (detection of stdin on Windows is better)
* Fixes #441, Fixes #690, Fixes #980 (empty matching lines are weird)
* Fixes #764 (coalesce color escapes)
* Fixes #922 (memory maps failing is no big deal)
* Fixes #937 (color escapes no longer used for empty matches)
* Fixes #940 (--passthru does not impact exit status)
* Fixes #1013 (show runtime CPU features in --version output)
BurntSushi added a commit that referenced this issue Aug 20, 2018
This commit updates the CHANGELOG to reflect all the work done to make
libripgrep a reality.

* Closes #162 (libripgrep)
* Closes #176 (multiline search)
* Closes #188 (opt-in PCRE2 support)
* Closes #244 (JSON output)
* Closes #416 (Windows CRLF support)
* Closes #917 (trim prefix whitespace)
* Closes #993 (add --null-data flag)
* Closes #997 (--passthru works with --replace)

* Fixes #2 (memory maps and context handling work)
* Fixes #200 (ripgrep stops when pipe is closed)
* Fixes #389 (more intuitive `-w/--word-regexp`)
* Fixes #643 (detection of stdin on Windows is better)
* Fixes #441, Fixes #690, Fixes #980 (empty matching lines are weird)
* Fixes #764 (coalesce color escapes)
* Fixes #922 (memory maps failing is no big deal)
* Fixes #937 (color escapes no longer used for empty matches)
* Fixes #940 (--passthru does not impact exit status)
* Fixes #1013 (show runtime CPU features in --version output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug. question An issue that is lacking clarity on one or more points.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants