ge-ne / bibtool

BibTool is a tool for manipulating BibTeX data bases. BibTeX provides a mean to integrate citations into LaTeX documents. BibTool allows the manipulation of BibTeX files which goes beyond the possibilities -- and intentions -- of BibTeX.
GNU General Public License v2.0
207 stars 32 forks source link

Quiet switch `-q` does not silence custom check.[,warning].rule #57

Closed kiryph closed 5 years ago

kiryph commented 5 years ago
❯ cat my2.bib
@Article{Dove:1997,
  author  = {Dove, Martin T.},
  title   = {{Theory of displacive phase transitions in minerals}},
  doi     = {10.2138/am-1997-3-401},
  issn    = {0003-004X},
  journal = {American Mineralogist}
  month   = {apr},
  number  = {3-4},
  pages   = {213--244},
  url     = {https://pubs.geoscienceworld.org/ammin/article/82/3-4/213-244/43266},
  volume  = {82},
  year    = {1997}
}

❯ cat bibtoolrsc
% Semantic checks
check.warning.rule { month "^[\"{]1?[0-9][\"}]$" }
check.warning.rule { month "" "Biber: month field in entry \$ is not an integer - this will probably not sort properly.\n" }

❯ bibtool -q -r bibtoolrsc  my2.bib
*** BibTool WARNING (line 1 in my2.bib): Biber: month field in entry dove:1997 is not an integer - this will probably not sort properly.

@Article{     dove:1997,
  author    = {Dove, Martin T.},
  title     = {{Theory of displacive phase transitions in minerals}},
  doi       = {10.2138/am-1997-3-401},
  issn      = {0003-004X},
  journal   = {American Mineralogist},
  month     = {apr},
  number    = {3-4},
  pages     = {213--244},
  url       = {https://pubs.geoscienceworld.org/ammin/article/82/3-4/213-244/43266},
  volume    = {82},
  year      = {1997}
}
ge-ne commented 5 years ago

This is intentional. If you don't want to see check results then don't specify rules..

kiryph commented 5 years ago

I see.

However, I would still argue that my proposal could also be intentional:

  1. command line switches have higher priority than config files in general
  2. there might be a global bibtoolrsc file which you want to silence for what you are doing.
  3. consistency: you can suppress all other warnings
  4. avoid modifying a git-tracked bibtoolrsc

Also the command line flag does not say anything about exceptions

❯ bibtool -h
BibTool Vers. 2.68 (C) 1996-2019 Gerd Neugebauer

bibtool [options] [-o outfile] [[-i] infile] ...

    Options:
[....]
    -o outfile  Specify output file as next argument
            If absent stdout is taken to write to.
    -q      Quiet mode. No warnings.
    -r resource Load resource file (several are possible).

Quoting the documentation A.5. of bibtool

The messages can roughly be divided in three categories: error messages, warnings, and status reports. Error messages indicate severe problems. They can not be suppressed. Warnings indicate possible problems which could (possibly) have been corrected. They are displayed by default but can be suppressed.

So I can understand that the newly introduced check.error.rule cannot be suppressed. But I do not see a reason whay check.warning.rule should not be suppressed.

This also allows to temporarily silence the warnings without altering the bibtoolrsc file which might be part of the git repository which you want to avoid making dirty.

Maybe you can add a scenario where the current situation is more useful.

ge-ne commented 5 years ago
  1. command line switches have higher priority than config files in general

There is a predefined sequence of processing steps in BibTool. The command line switches are nothing but abbreviations for resource instructions.

  1. there might be a global bibtoolrsc file which you want to silence for what you are doing.

As final resort you can always redirect the error stream to /dev/null.

  1. consistency: you can suppress all other warnings

That's a argument I can buy. I will think about it.

  1. avoid modifying a git-tracked bibtoolrsc

I don't know if I understand this one...

kiryph commented 5 years ago

There is a predefined sequence of processing steps in BibTool. The command line switches are nothing but abbreviations for resource instructions.

There is no difference between

$ bibtool -q -r bibtoolrsc my2.bib

and

$ bibtool -r bibtoolrsc -q my2.bib

Therefore, I think this is not about order of command line flags and processing of rsc lines but whether it is possible to silence check.warning.rule with -q at all.

I don't know if I understand this one...

I try to explain it a little bit better (hopefully):

I have a manuscript which I format with bibtool configured in a bibtoolrsc file. I have put the manuscript and the bibtoolrsc file under version control by git and mark the pdf with https://ctan.org/pkg/gitinfo2.

When I want to test run the formatting, I might want to silence the warnings I have configured in the bibtoolrsc file. You suggest I should edit the bibtoolrsc file to disable the warnings which means to modify a git-tracked file. As long as I do not reset the file, git status will report about a modified file. For example this affects https://ctan.org/pkg/gitinfo2 which will mark any created pdf file with the label [Dirty]. This means the pdf was generated from a dirty repository and it is unclear if this document can be regenerated from a certain git commit hash.

This might be not the most important thing.

But still modifying bibtoolrsc to silence the warnings when there is already the convenience switch -q seems unnecessarily complicated.

Also I do not see a use case of the combination -q and check.warning.rule visible.

As I said previously, I can understand that check.error.rule is treated as an error which cannot be silenced with -q.

Anyhow, as you said, there is the possibility to redirect to /dev/null.