Skip to content

Silence warnings #823

@rien333

Description

@rien333

I use bat to preview files in fzf. When bat is called on a binary file, it will display a warning:

$ bat foo.pdf 2> /dev/null
[bat warning]: Binary content from file 'foo.pdf' will not be printed to the terminal (but will be present if the output of 'bat' is piped). You can use 'bat -A' to show the binary file contents.

As you can see, there is no way to silence this warning. For my specific use case, using bat as a "previewer", I would rather it be silent than that it displays an "error". Would it be a good idea to make it possible to silence warnings somehow?

In terms of implementation, I was thinking one could implement the warnings of bat such they are directed to stderr (seemingly, they are directed to stdout now?). In that way, users that don't need the warnings, can redirect stderr to /dev/null, without a lot of changes to bat itself. Alternatively, one could add a new switch to bat, that makes it less verbose in case of warnings.

edit:

I'm not sure wether it's customary to print warnings to stderr, btw.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions