| 1 | #!/bin/sh |
| 2 | |
| 3 | # kpsetool. Script to make teTeX-style kpsetool, kpsexpand and kpsepath |
| 4 | # available. Web2C's kpsewhich offers a superset of the functionality. |
| 5 | # For compatibilty with old versions of teTeX, this script provides the |
| 6 | # old command line interface of kpsetool, kpsexpand and kpsepath. All the |
| 7 | # real work is done inside Web2C's kpsewhich. |
| 8 | # Thomas Esser <[email protected]>, Mar 1997, public domain. |
| 9 | |
| 10 | export PATH |
| 11 | |
| 12 | usage=" |
| 13 | Usage: kpsexpand [options] string |
| 14 | Usage: kpsetool -w [options] pathtype filename |
| 15 | Usage: kpsepath [options] pathtype |
| 16 | |
| 17 | Valid options are the following: |
| 18 | -n progname : pretend to be progname to kpathsea |
| 19 | -m mode : set Metafont mode |
| 20 | -w : locate files (similar to kpsewhich) |
| 21 | -p : act like kpsepath |
| 22 | -v : act like kpsexpand |
| 23 | |
| 24 | Valid pathtypes are: |
| 25 | gf : generic font bitmap |
| 26 | pk : packed bitmap font |
| 27 | base : Metafont memory dump |
| 28 | bib : BibTeX bibliography source |
| 29 | bst : BibTeX style files |
| 30 | cnf : Kpathsea runtime configuration files |
| 31 | fmt : TeX memory dump |
| 32 | mem : MetaPost memory dump |
| 33 | mf : Metafont source |
| 34 | mfpool : Metafont program strings |
| 35 | mp : MetaPost source |
| 36 | mppool : MetaPost program strings |
| 37 | mpsupport : MetaPost support files |
| 38 | pict : Other kinds of figures |
| 39 | tex : TeX source |
| 40 | texpool : TeX program strings |
| 41 | tfm : TeX font metrics |
| 42 | vf : virtual font |
| 43 | dvips_config : dvips config files |
| 44 | dvips_header : dvips header files |
| 45 | troff_font : troff fonts |
| 46 | " |
| 47 | |
| 48 | action=kpsexpand |
| 49 | case $0 in |
| 50 | */kpsewhich) action=kpsewhich;; |
| 51 | */kpsepath) action=kpsepath;; |
| 52 | esac |
| 53 | |
| 54 | progname=`echo $0 | sed 's@.*/@@'` |
| 55 | flags='' |
| 56 | |
| 57 | while true; do |
| 58 | case x"$1" in |
| 59 | x-n) |
| 60 | if test $# = 1; then |
| 61 | echo "$progname: missing argument for -n." |
| 62 | echo "$usage"; exit 1 |
| 63 | else |
| 64 | flags="$flags -progname=$2"; shift; shift |
| 65 | fi;; |
| 66 | x-m) |
| 67 | if test $# = 1; then |
| 68 | echo "$progname: missing argument for -m." |
| 69 | echo "$usage"; exit 1 |
| 70 | else |
| 71 | flags="$flags -mode=$2"; shift; shift |
| 72 | fi;; |
| 73 | x-w) action=kpsewhich; shift;; |
| 74 | x-p) action=kpsepath; shift;; |
| 75 | x-v) action=kpsexpand; shift;; |
| 76 | *) break;; |
| 77 | esac |
| 78 | done |
| 79 | |
| 80 | case "$action" in |
| 81 | kpsewhich|kpsepath) |
| 82 | case "$1" in |
| 83 | gf) format='gf';; |
| 84 | pk) format='pk';; |
| 85 | base) format='.base';; |
| 86 | bib) format='.bib';; |
| 87 | bst) format='.bst';; |
| 88 | cnf) format='.cnf';; |
| 89 | fmt) format='.fmt';; |
| 90 | mem) format='.mem';; |
| 91 | mf) format='.mf';; |
| 92 | mfpool) format='.pool';; |
| 93 | mp) format='.mp';; |
| 94 | mppool) format='.pool';; |
| 95 | mpsupport) format='MetaPost support';; |
| 96 | pict) format='.eps';; |
| 97 | tex) format='.tex';; |
| 98 | texpool) format='.pool';; |
| 99 | tfm) format='.tfm';; |
| 100 | vf) format='.vf';; |
| 101 | dvips_config) format='dvips config';; |
| 102 | dvips_header) format='.pro';; |
| 103 | troff_font) format='Troff fonts';; |
| 104 | *) echo "$progname: $1: unknown format"; echo "$usage"; exit 1;; |
| 105 | esac |
| 106 | shift;; |
| 107 | esac |
| 108 | |
| 109 | case "$action" in |
| 110 | kpsewhich) |
| 111 | test $# = 1 || { echo "$progname: missing filename"; echo "$usage"; exit 1; } |
| 112 | kpsewhich $flags -format="$format" "$1";; |
| 113 | kpsepath) |
| 114 | kpsewhich $flags -show-path="$format";; |
| 115 | kpsexpand) |
| 116 | test $# = 1 || { echo "$progname: missing string"; echo "$usage"; exit 1; } |
| 117 | kpsewhich $flags -expand-var="$1";; |
| 118 | esac |