60 lines
1.4 KiB
Bash
Executable File
60 lines
1.4 KiB
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# latexd.sh, version 1.3, 05/10/2010
|
|
# Copyright © 2006-2008, 2010 Matteo Cypriani
|
|
#
|
|
# This program is free software. It comes without any warranty, to
|
|
# the extent permitted by applicable law. You can redistribute it
|
|
# and/or modify it under the terms of the Do What The Fuck You Want
|
|
# To Public License, Version 2, as published by Sam Hocevar. See
|
|
# http://sam.zoy.org/wtfpl/COPYING for more details.
|
|
#
|
|
# This scripts calls "make" when the watched file is modified.
|
|
# ----
|
|
# Lancement de la commande "make" à chaque fois que le fichier
|
|
# surveillé est modifié.
|
|
#
|
|
# Historique des versions :
|
|
# version 1.3, 05/10/2010 :
|
|
# - 80 caractères max par ligne
|
|
# - WTFPL
|
|
# - ajout au dépôt scripts.git
|
|
# version 1.2, 22/09/2008 : adaptation pour FreeBSD.
|
|
# version 1.1, 21/03/2007.
|
|
# version 1.0, 2006 (?).
|
|
|
|
case $(uname -s) in
|
|
"FreeBSD") MD5=md5 ;;
|
|
"Linux") MD5=md5sum ;;
|
|
*) MD5=md5sum ;;
|
|
esac
|
|
|
|
ERR_NBARG=1
|
|
ERR_FICH=2
|
|
|
|
if [ $# -ne 1 ] ; then
|
|
echo "Erreur ! Mauvais nombre d'arguments." >&2
|
|
exit $ERR_NBARG
|
|
fi
|
|
|
|
fich="$1"
|
|
|
|
if [ ! -f "$fich" ] ; then
|
|
echo "Erreur ! Le fichier « $fich » n'existe pas ou n'est pas \
|
|
un fichier ordinaire." >&2
|
|
exit $ERR_FICH
|
|
fi
|
|
|
|
somme_a=""
|
|
somme=$("$MD5" "$fich")
|
|
|
|
while : ; do
|
|
if [ "$somme" != "$somme_a" ] ; then
|
|
make && echo \
|
|
'****************************** TERMINÉ ******************************'
|
|
fi
|
|
sleep 5
|
|
somme_a="$somme"
|
|
somme=$("$MD5" "$fich")
|
|
done
|