summaryrefslogtreecommitdiff
path: root/Konzerte/2020_01_05/mangle-inputs
blob: 6c4ac50ab5635ec4b1a4f8c1ca8ffc6d2a145b79 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/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\|satz\|stimmen\|texte\)\.ly"\)@\1'"${base}"'/\2@
    t
    s@\(include "\)\(\(artikulation\|satz\|stimmen\|texte\)\.pre"\)@\1'"${base##*/}"'_\2@
  ' \
  <"$1" \
  | case "${base##*/}" in
    'O_du_froehliche')
      sed '
        s/%Oberstimme%//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##*/Freu_dich_Erd_und_Sternenzelt/stimmen.ly}" ] \
|| [ -z "${1##*/Freu_dich_Erd_und_Sternenzelt/texte.ly}" ]; then

  cat "$1"

elif [ -z "${1##*/Es_ist_ein_Ros_entsprungen/satz.ly}" ] \
|| [ -z "${1##*/Es_ist_ein_Ros_entsprungen/stimmen.ly}" ] \
|| [ -z "${1##*/Es_ist_ein_Ros_entsprungen/texte.ly}" ]; then

  sed '
    s/%STR_[1-3]%//
    s/%Variante_2%//
  ' "$1"

elif [ -z "${1##*/Freu_dich_Erd_und_Sternenzelt/satz.ly}" ]; then

  sed '
    s/%STR_[124]%//
  ' "$1"

else

  >&2 printf 'unknown input "%s"\n' "$1"
  exit 1

fi