From 38ed64db3793bad6c5599333a90e52af07a660ea Mon Sep 17 00:00:00 2001 From: Alexandre Dupas Date: Sun, 28 Nov 2010 21:35:17 +0100 Subject: [PATCH] Improve langbook script running time and change to non-interactive mode --- utils/{header-en => header-english} | 0 utils/{header-fr => header-french} | 0 utils/langbooks.sh | 48 ++++++++++------------------- 3 files changed, 16 insertions(+), 32 deletions(-) rename utils/{header-en => header-english} (100%) rename utils/{header-fr => header-french} (100%) diff --git a/utils/header-en b/utils/header-english similarity index 100% rename from utils/header-en rename to utils/header-english diff --git a/utils/header-fr b/utils/header-french similarity index 100% rename from utils/header-fr rename to utils/header-french diff --git a/utils/langbooks.sh b/utils/langbooks.sh index 6aaf9bfa..8bbafe60 100755 --- a/utils/langbooks.sh +++ b/utils/langbooks.sh @@ -4,35 +4,19 @@ #Date: 14/11/2010 #Description: Generate an sb file containing all the songs in a given language -echo "Build songbook file for songs in english (1), french (2)" -read answer -case "$answer" in - 1) - cat ./utils/header-en > english.sb - for song in songs/*/*.sg; - do - if grep -q "selectlanguage{english}" $song - then - echo "\t\""`ls $song | sed "s/songs\\///g"`"\"," >> english.sb - fi - done - #remove last coma before bracket - truncate --size=-2 english.sb - #close json values for key "songs" - echo "]\n}" >> english.sb - ;; - 2) - cat ./utils/header-fr > french.sb - for song in songs/*/*.sg; - do - if grep -q "selectlanguage{french}" $song - then - echo "\t\""`ls $song | sed "s/songs\\///g"`"\"," >> french.sb - fi - done - #remove last coma before bracket - truncate --size=-2 french.sb - #close json values for key "songs" - echo "]\n}" >> french.sb - ;; -esac +if [ $# -ne 1 ]; +then + echo "Usage: $0 LANG" + exit 1 +fi; + +LANG=$1 + +if [ $LANG="english" -o $LANG="french" ]; +then + cp "./utils/header-$LANG" "$LANG.sb" + grep "selectlanguage{$LANG}" songs/*/*.sg | sed 's|songs/\(.*\):.*| \"\1\",|; $ s|,$|\n ]\n}\n|' >> "$LANG.sb" +else + echo "Error: $LANG is not a supported language" + exit 2 +fi;