#!/bin/sh -x # syntax: remove_obsolete.sh [-d ] {...] # dirname is the name of the output directory, defaults to out # This script is invoked from a Makefile to remove the lilypond files # that depend on files that have changed, but that lilypond-book # doesn't know to rebuild. So the arguments are the list of filenames # that make considers to have changed, and the effect of running the # script is that any file in out/*.ly that refers to any of those # filenames is removed. so if you're using the directory out to store # anything valuable, this is a dangerous script, but if it's being # used as intended to just be a working directory for lilypond-book, # the worst that can happen is that lilypond-book might have to run # lilypond on more stuff than it should have to. FILES=$@ if [ "F$1" = "F-d" ] then DIR=$2 else DIR="out" fi ls $DIR/*.ly >/dev/null if [ "$?" != "0" ] then exit fi for FILE in $FILES do if [ "$FILE" = "allparts.lytex" ] then continue fi if [ "$FILE" = "-d" ] then continue fi grep -l "$FILE" $DIR/*.ly | xargs --verbose rm -f done