diff options
| author | Douglas B. Rumbaugh <doug@douglasrumbaugh.com> | 2026-06-06 12:02:41 -0400 |
|---|---|---|
| committer | Douglas B. Rumbaugh <doug@douglasrumbaugh.com> | 2026-06-06 12:02:41 -0400 |
| commit | eabf1f6d74dac497ce31e3e2f441cfa25e9f74f2 (patch) | |
| tree | 626d64c3574cfbc7cc38eae6d142ef22b21cf59b /lib/bib-select.awk | |
| parent | 8351a1da3f56cde9939b934bc5533a95aff1c95e (diff) | |
| download | bibutils-eabf1f6d74dac497ce31e3e2f441cfa25e9f74f2.tar.gz | |
Initial implementation (only a few years later!)
This is pure Claude. I'd written out the plan for
this suite of scripts eons ago, but never found the
time to actual do it. Remembered it this morning,
pointed Claude at the README, and had something
that appears to work in minutes.
caveat emptor: the design is mine, but the code is
purely LLM generated at this point.
Diffstat (limited to 'lib/bib-select.awk')
| -rw-r--r-- | lib/bib-select.awk | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/bib-select.awk b/lib/bib-select.awk new file mode 100644 index 0000000..1900390 --- /dev/null +++ b/lib/bib-select.awk @@ -0,0 +1,29 @@ +# bib-select.awk - emit entries selected by key, canonically +# +# Requires bib-parse.awk and bib-canon.awk. Variables (set with -v): +# keys - comma-separated list of entry keys +# invert - 0: emit entries whose key is in the list +# 1: emit entries whose key is NOT in the list +# +# With keys="" and invert=1 this acts as a canonicalizing filter for +# everything. @string and @preamble blocks always pass through. + +BEGIN { + bib_sel_n = split(keys, bib_sel_k, ",") + for (bib_sel_i = 1; bib_sel_i <= bib_sel_n; bib_sel_i++) + BIB_SEL[bib_sel_k[bib_sel_i]] = 1 +} + +function bib_pass(raw) { + if (bib_out_n++) + print "" + print raw +} + +function bib_entry(type, key) { + if ((key in BIB_SEL) != invert + 0) { + if (bib_out_n++) + print "" + bib_emit(type, key) + } +} |