#!/bin/bash set -e cd "$(dirname "$0")" teile_params=( # ' - Schütz - Magnificat SWV 426' 'Freude_grosze_Freude' 'Macht_hoch_die_Tuer' # 'Drei_Koenge_wandern' Nr. 9 (Drei Kön'ge) 'Als_die_Welt_verloren' 'Stern_ueber_Bethlehem' 'Die_Botschaft' 'Das_grosze_Wunder_hat_ganz_klein_begonnen' 'O_du_froehliche:OBERSTIMME=1' 'Lobsinget_Gott_dem_Herrn' 'Freuet_euch_allezeit' ) rm -f *.pre for teil_params in "${teile_params[@]}" do if [ -z "${teil_params%%'"'*}" ]; then continue fi teil="${teil_params%%:*}" params="${teil_params#${teil}}" params="${params#:}" ( cd ../../${teil} sed -n ' s/^\([^:]*%\|'"${teil##*/}"'\)\.pdf.*:\s*// T :a /\\$/ { N s/\\\n/ / ta } s/\n.*$// s/%/'"${teil##*/}"'/g p ' Makefile | \ tr ' ' '\n' | \ grep '\.pre$' | \ xargs -r make ${params} "$@" ) done { printf '\n\n' cat alles.ly printf '\n\n' } | \ while read -r line do if [[ "${line}" = '%LOOP%'* ]] then loopLines="${loopLines} ${line#%LOOP%}" else if [ -n "${loopLines}" ] then for teil_param in "${teile_params[@]}" do teil="${teil_param%%:*}" echo "${loopLines}" | \ if [ -z ${teil%%'"'*} ]; then sed ' s/\\include "[^"]*"/\\markup { '"${teil_param}"'" }/g ' else cat fi | \ sed " s|%TEIL%|${teil}|g s|%TEIL-BASE%|${teil##*/}|g /%IF \([^=%]\+\)!=\1%/d s|%IF [^=%]\+!=[^=%]\+%||g s|%IF \([^=%]*[^=!%]\)=\1%||g /%IF [^=%]\+=[^=%]\+%/d " done unset loopLines fi echo "${line}" fi done > alles.pre lilypond alles.pre #ps2pdf -sPAPERSIZE=a4 - empty.pdf