aboutsummaryrefslogtreecommitdiffstats
path: root/bib-extract
diff options
context:
space:
mode:
authorDouglas B. Rumbaugh <doug@douglasrumbaugh.com>2026-06-06 13:44:00 -0400
committerDouglas B. Rumbaugh <doug@douglasrumbaugh.com>2026-06-06 13:44:00 -0400
commitc102ab995f9a86a77e40b9a952b2b23c0bd7de74 (patch)
treed51b9a8f1a55f7f6e6e5afb89d524b9baa350f45 /bib-extract
parentb56c273d8198ae6cee69bbc9fe5a6a61da4074e4 (diff)
downloadbibutils-c102ab995f9a86a77e40b9a952b2b23c0bd7de74.tar.gz
Fuzzing with associated fixes
Diffstat (limited to 'bib-extract')
-rwxr-xr-xbib-extract13
1 files changed, 8 insertions, 5 deletions
diff --git a/bib-extract b/bib-extract
index 297588a..ac0363d 100755
--- a/bib-extract
+++ b/bib-extract
@@ -23,7 +23,10 @@ aux=$1
shift
[ -r "$aux" ] || { printf 'bib-extract: cannot read %s\n' "$aux" >&2; exit 1; }
-keys=$(awk '
+keyfile=$(mktemp) || exit 1
+trap 'rm -f "$keyfile"' EXIT INT TERM
+
+awk '
# classic bibtex: \citation{key,key,...}
{
line = $0
@@ -46,10 +49,10 @@ keys=$(awk '
print s
line = substr(line, RSTART + RLENGTH)
}
- }' "$aux" | sort -u | paste -sd, -)
+ }' "$aux" | sort -u > "$keyfile"
-[ -n "$keys" ] || exit 0
+[ -s "$keyfile" ] || exit 0
# a key of "*" (from \nocite{*}) selects the whole database
-exec awk -f "$LIB/bib-parse.awk" -f "$LIB/bib-canon.awk" \
- -f "$LIB/bib-select.awk" -v keys="$keys" -v invert=0 "$@"
+awk -f "$LIB/bib-parse.awk" -f "$LIB/bib-canon.awk" \
+ -f "$LIB/bib-select.awk" -v keyfile="$keyfile" -v invert=0 "$@"