aboutsummaryrefslogtreecommitdiffstats
path: root/bib-ls
blob: 0ed7236ca8bf9825c442f8d6e6bc568d9098b533 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/sh
# bib-ls - list the entries in a bibtex database
#
# usage: bib-ls [-l] [file ...]   (stdin if no file given)
#   -l  long format: key, type, author, year, title (tab-separated)

usage() {
  printf 'usage: bib-ls [-l] [file ...]\n' >&2
  exit 2
}

if [ -n "$BIBUTILS_LIB" ]; then
  LIB=$BIBUTILS_LIB
elif [ -d "$(dirname "$0")/lib" ]; then
  LIB=$(dirname "$0")/lib
else
  LIB=/usr/local/share/bibutils
fi

long=0
while getopts l opt; do
  case $opt in
    l) long=1 ;;
    *) usage ;;
  esac
done
shift $((OPTIND - 1))

exec awk -f "$LIB/bib-parse.awk" -f "$LIB/bib-canon.awk" \
         -f "$LIB/bib-ls.awk" -v long="$long" "$@"