summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/texlive-extra/kpsetool.sh
blob: 463097fd4a97ba3b94f09d6434788a5595b01cc7 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/sh

# kpsetool. Script to make teTeX-style kpsetool, kpsexpand and kpsepath
# available. Web2C's kpsewhich offers a superset of the functionality.
# For compatibilty with old versions of teTeX, this script provides the
# old command line interface of kpsetool, kpsexpand and kpsepath. All the
# real work is done inside Web2C's kpsewhich.
# Thomas Esser <te@dbs.uni-hannover.de>, Mar 1997, public domain.

export PATH

usage="
Usage: kpsexpand [options] string
Usage: kpsetool -w [options] pathtype filename
Usage: kpsepath  [options] pathtype

Valid options are the following:
  -n progname  : pretend to be progname to kpathsea
  -m mode      : set Metafont mode
  -w           : locate files (similar to kpsewhich)
  -p           : act like kpsepath
  -v           : act like kpsexpand

Valid pathtypes are:
  gf            : generic font bitmap
  pk            : packed bitmap font
  base          : Metafont memory dump
  bib           : BibTeX bibliography source
  bst           : BibTeX style files
  cnf           : Kpathsea runtime configuration files
  fmt           : TeX memory dump
  mem           : MetaPost memory dump
  mf            : Metafont source
  mfpool        : Metafont program strings
  mp            : MetaPost source
  mppool        : MetaPost program strings
  mpsupport     : MetaPost support files
  pict          : Other kinds of figures
  tex           : TeX source
  texpool       : TeX program strings
  tfm           : TeX font metrics
  vf            : virtual font
  dvips_config  : dvips config files
  dvips_header  : dvips header files
  troff_font    : troff fonts
"

action=kpsexpand
case $0 in
  */kpsewhich) action=kpsewhich;;
  */kpsepath)  action=kpsepath;;
esac

progname=`echo $0 | sed 's@.*/@@'`
flags=''

while true; do
  case x"$1" in
    x-n)
      if test $# = 1; then
        echo "$progname: missing argument for -n."
        echo "$usage"; exit 1
      else
        flags="$flags -progname=$2"; shift; shift
      fi;;
    x-m)
      if test $# = 1; then
        echo "$progname: missing argument for -m."
        echo "$usage"; exit 1
      else
        flags="$flags -mode=$2"; shift; shift
      fi;;
    x-w) action=kpsewhich; shift;; 
    x-p) action=kpsepath; shift;;
    x-v) action=kpsexpand; shift;;
    *) break;;
  esac
done

case "$action" in
  kpsewhich|kpsepath)
    case "$1" in
      gf)		format='gf';;
      pk)		format='pk';;
      base)		format='.base';;
      bib)		format='.bib';;
      bst)		format='.bst';;
      cnf)		format='.cnf';;
      fmt)		format='.fmt';;
      mem)		format='.mem';;
      mf)		format='.mf';;
      mfpool)		format='.pool';;
      mp)		format='.mp';;
      mppool)		format='.pool';;
      mpsupport)	format='MetaPost support';;
      pict)		format='.eps';;
      tex)		format='.tex';;
      texpool)		format='.pool';;
      tfm)		format='.tfm';;
      vf)		format='.vf';;
      dvips_config)	format='dvips config';;
      dvips_header)	format='.pro';;
      troff_font)	format='Troff fonts';;
      *)		echo "$progname: $1: unknown format"; echo "$usage"; exit 1;;
    esac
    shift;;
esac

case "$action" in
  kpsewhich)
    test $# = 1 || { echo "$progname: missing filename"; echo "$usage"; exit 1; }
    kpsewhich $flags -format="$format" "$1";;
  kpsepath)
    kpsewhich $flags -show-path="$format";;
  kpsexpand)
    test $# = 1 || { echo "$progname: missing string"; echo "$usage"; exit 1; }
    kpsewhich $flags -expand-var="$1";;
esac