| 1 | #!/bin/sh |
| 2 | # |
| 3 | # Thomas Esser, Hans Fredrik Nordhaug, 2003, 2004. |
| 4 | # Public domain. |
| 5 | # |
| 6 | # kpsewhere is an extension to kpsewhich (as where is for which in tcsh). |
| 7 | # The intention is to provide a way to check for conflicts/shadowed |
| 8 | # files. |
| 9 | # |
| 10 | # Original version by Hans Fredrik Nordhaug <[email protected]> |
| 11 | # |
| 12 | # Bugs / limitations: |
| 13 | # conflicts/shadowed files whithin each texmf tree are not found. |
| 14 | # |
| 15 | |
| 16 | |
| 17 | test -f /bin/sh5 && test -z "$RUNNING_SH5" \ |
| 18 | && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \ |
| 19 | && { RUNNING_SH5=true; export RUNNING_SH5; exec /bin/sh5 $0 ${1+"$@"}; } |
| 20 | unset RUNNING_SH5 |
| 21 | |
| 22 | test -f /bin/bsh && test -z "$RUNNING_BSH" \ |
| 23 | && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \ |
| 24 | && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; } |
| 25 | unset RUNNING_BSH |
| 26 | |
| 27 | export PATH |
| 28 | |
| 29 | help='Usage: kpsewhere [OPTION]... [FILENAME]... |
| 30 | Expanding kpsewhich to iterate over each texmf tree listed in $TEXMF |
| 31 | separately. |
| 32 | |
| 33 | See kpsewhich for help on options. |
| 34 | |
| 35 | --help show this help' |
| 36 | |
| 37 | options= |
| 38 | while |
| 39 | case $1 in |
| 40 | -h|-help|--help) |
| 41 | echo "$help" >&2 |
| 42 | exit 0;; |
| 43 | -*) options="${options} '${1}'";; |
| 44 | *) break;; |
| 45 | esac |
| 46 | do shift; done |
| 47 | |
| 48 | case $# in |
| 49 | 0) |
| 50 | echo "$help" >&2 |
| 51 | exit 1 |
| 52 | ;; |
| 53 | esac |
| 54 | |
| 55 | IFS=':' |
| 56 | for file |
| 57 | do |
| 58 | for path in `kpsewhich --expand-path='$TEXMF'` |
| 59 | do |
| 60 | eval TEXMF=\$path kpsewhich $options \"\$file\" |
| 61 | done |
| 62 | done |
| 63 | exit 0 |