#!/bin/sh -e # # Copyright (C) 2008 Grigory Batalov # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # rehash condition found= # get texmf directory list kpsewhich=/usr/bin/kpsewhich [ -x "$kpsewhich" ] && dirs=`"$kpsewhich" --show-path=ls-R` [ -n "$dirs" ] || exit 0 # get a list of files while read -r f; do if [ -n "$found" ]; then break fi # directories are separated with the colon OLDIFS="$IFS" IFS=: for i in $dirs; do # check if the file starts with a known directory if [ "${f#$i/}" != "$f" ]; then found=1 break fi done IFS="$OLDIFS" done # rehash all directories # TODO: it is possible to specify necessary directories # as arguments to texhash texhash=/usr/bin/texhash if [ -n "$found" ] && [ -x "$texhash" ]; then "$texhash" fi