#!/bin/bash
# We need to find the lilypond executable, and 
# store the location in the LILYPOND variable. 
# First, see if we have Macports lilypond:
if [ -x ${PREFIX}/bin/lilypond ]; then
    LILYPOND=${PREFIX}/bin/lilypond

# next, check for LilyPond.app
elif [ -x /Applications/LilyPond.app/Contents/Resources/bin/lilypond ]; then
    LILYPOND=/Applications/LilyPond.app/Contents/Resources/bin/lilypond

# Last ditch effort: is it on the system path?
else
    LILYPOND=`which lilypond`
fi

# if it was none of these, the LILYPOND variable will be blank
if [ $LILYPOND ]; then
    echo "Passing file to Lilypond, just a moment..."
    $LILYPOND "$1"
else
    echo "Lilypond executable not found."
fi