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

Option to supress log/error messages #149

Closed
cloudhead opened this issue Oct 5, 2016 · 11 comments
Closed

Option to supress log/error messages #149

cloudhead opened this issue Oct 5, 2016 · 11 comments
Labels
enhancement An enhancement to the functionality of the software.

Comments

@cloudhead
Copy link

cloudhead commented Oct 5, 2016

It would be nice to have an option to supress log messages and errors like in ag. This is useful for using ripgrep in scripts. This comes up when using ripgrep in directories where certain files are not readable.

In ag, there is:

--silent
 Suppress all log messages, including errors.

Since there is already a --quiet option, this might not be the best name for it, maybe --no-log?

@BurntSushi
Copy link
Owner

Which log messages do you want to see suppressed?

@cloudhead
Copy link
Author

Anything that isn't results. For example, when folders aren't readable, you currently get:

IO error for operation on ./lost+found: Permission denied (os error 13)

@BurntSushi
Copy link
Owner

But that's emitted to stderr. You could hide those messages by redirecting stderr to /dev/null. e.g., rg foo 2> /dev/null.

@cloudhead
Copy link
Author

Hm indeed! I guess if all non-result text is emitted on stderr, that should be a fine solution. Ripgrep isn't always used within a shell context though, but I guess there is always the possibility to control stderr.

@BurntSushi
Copy link
Owner

I think GNU find has the same behavior. I don't see an option to suppress these types of messages, but if it did, I'd consider that a stronger precedent than ag personally.

@cloudhead
Copy link
Author

grep has the following:

   -s, --no-messages
              Suppress error messages about nonexistent or unreadable files.

However, I do agree that it seems redundant if messages are properly sent to stderr.

@cloudhead
Copy link
Author

I'm guessing this exists because sending stderr to /dev/null is not always appropriate or possible, but can't think of any specific examples. My use-case is solved with redirection.

@BurntSushi
Copy link
Owner

@cloudhead I consider grep a very strong precedent for a feature like this, although the short -s option is already taken. I'd be fine adding a --no-messages option.

@BurntSushi BurntSushi added the enhancement An enhancement to the functionality of the software. label Oct 5, 2016
@cloudhead
Copy link
Author

Great. I don't think a short option is necessary.

@ElectricRCAircraftGuy
Copy link

But that's emitted to stderr. You could hide those messages by redirecting stderr to /dev/null. e.g., rg foo 2> /dev/null.

Perfect! Full example:

rg 'my regex search' 'path/to/search' 2> /dev/null

@thistehneisen
Copy link

Sorry for bringing back old topic, but I don't seem to find an option to suppress messages like:

WARNING: stopped searching binary file after match (found "\0" byte around offset 687940)
WARNING: stopped searching binary file after match (found "\0" byte around offset 881429)

Neither 2> works, nor --no-messages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement to the functionality of the software.
Projects
None yet
Development

No branches or pull requests

4 participants