#!/bin/bash if [ -z "$1" ]; then >&2 echo 'too few arguments' exit 1 fi Groeszen=' Es_kommt_ein_Schiff_geladen:19 Macht_hoch_die_Tuer:18 Freuet_euch_allezeit:17 Lobsinget_Gott_dem_Herrn:17 Stern_ueber_Bethlehem_:20 Freut_euch_von_Herzen:18 Drei_Koenige_wandern:17 Als_die_Welt_verloren:17 Die_Nacht_ist_vorgedrungen:18 Das_grosze_Wunder_hat_ganz_klein_begonnen:17.5 ' if printf '%s\n' "$1" \ | grep -q '/\([^/]\+\)/\1\.ly$'; then base="${1%/*.ly}" sed ' s@\(include "\)\(\(artikulation\|stimmen\|texte\)\.ly"\)@\1'"${base}"'/\2@ t s@\(include "\)\(\(artikulation\|stimmen\|texte\)\.pre"\)@\1'"${base##*/}"'_\2@ ' \ <"$1" \ | case "${base##*/}" in 'Es_kommt_ein_Schiff_geladen') sed 's/%STR_[1-4]%//g' ;; 'Macht_hoch_die_Tuer') sed 's/%STR_[1-3]%//g' ;; *) cat ;; esac \ | if Groesze=$( printf '%s\n' "${Groeszen}" \ | grep "^${base##*/}:" ); then sed ' /^\s*\\layout\s\+{\s*$/ a #(layout-set-staff-size '"${Groesze#*:}"') ' else cat fi elif [ -z "${1##*/Macht_hoch_die_Tuer/stimmen.ly}" ]; then sed ' /%fermate$/ s/2\([_^]\?\\fermata\)\? /4 s / ' "$1" else >&2 printf 'unknown input "%s"\n' "$1" exit 1 fi