@@ -14,6 +14,21 @@ FILES="\
1414 DerivedNormalizationProps.txt:ucd:b2c444c20730b097787fdf50bd7d6dd3fc5256ab8084f5b35b11c8776eca674c \
1515 NormalizationTest.txt:test/data:7cb30cc2abe6c29c292b99095865d379ce1213045c78c4ff59c7e9391bbe2331"
1616
17+ delete_file () {
18+ local pair=$1
19+ local file=$( echo $pair | cut -f1 -d' :' )
20+ local destination=" $( echo $pair | cut -f2 -d' :' ) /$file "
21+ rm " $destination "
22+ }
23+
24+ # Remove previous downloaded files
25+ delete_files () {
26+ for pair in $FILES
27+ do
28+ delete_file " $pair "
29+ done
30+ }
31+
1732# Download the files
1833
1934# Download $file from https://www.unicode.org/Public/$VERSION/$file
@@ -28,7 +43,7 @@ download_file() {
2843
2944 if test ! -e " $destination "
3045 then
31- wget -P ` dirname " $destination " ` " https://www.unicode.org/Public/$VERSION /ucd/$file "
46+ wget -P ` dirname " $destination " ` " https://www.unicode.org/Public/$VERSION /ucd/$file "
3247 fi
3348 if test -n " $VERIFY_CHECKSUM "
3449 then
@@ -52,26 +67,27 @@ download_files() {
5267 done
5368}
5469
70+ # Generate the Haskell files.
71+ run_generator () {
72+ # Compile and run ucd2haskell
73+ cabal run --flag ucd2haskell ucd2haskell -- \
74+ --input ./ucd/ \
75+ --output ./
76+ }
77+
5578# Print help text
5679print_help () {
5780 echo " Usage: ucd.sh <command>"
5881 echo
5982 echo " Available commands:"
83+ echo " clean: delete downloaded files"
6084 echo " download: downloads the text files required"
6185 echo " generate: generate the haskell files from the downloaded text files"
6286 echo
6387 echo " Example:"
6488 echo " $ ./ucd.sh download && ./ucd.sh generate"
6589}
6690
67- # Generate the Haskell files.
68- run_generator () {
69- # Compile and run ucd2haskell
70- cabal run --flag ucd2haskell ucd2haskell -- \
71- --input ./ucd/ \
72- --output ./
73- }
74-
7591# Main program
7692
7793# Export the version so it can be used by the executable
@@ -80,6 +96,7 @@ export UNICODE_VERSION="$VERSION"
8096# Parse command line
8197case $1 in
8298 -h|--help) print_help;;
99+ clean) delete_files;;
83100 download) download_files;;
84101 generate) run_generator;;
85102 * ) echo " Unknown argument" ; print_help;;
0 commit comments