download-unicode-files.sh 1003 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/bin/sh
  2. set -e
  3. data_files="UnicodeData.txt CaseFolding.txt EastAsianWidth.txt"
  4. emoji_files="emoji-data.txt"
  5. UNIDIR_DEFAULT=unicode
  6. DOWNLOAD_URL_BASE_DEFAULT='http://unicode.org/Public'
  7. if test x$1 = 'x--help' ; then
  8. echo 'Usage:'
  9. echo " $0[ TARGET_DIRECTORY[ URL_BASE]]"
  10. echo
  11. echo "Downloads files $files to TARGET_DIRECTORY."
  12. echo "Each file is downloaded from URL_BASE/\$filename."
  13. echo
  14. echo "Default target directory is $PWD/${UNIDIR_DEFAULT}."
  15. echo "Default URL base is ${DOWNLOAD_URL_BASE_DEFAULT}."
  16. fi
  17. UNIDIR=${1:-$UNIDIR_DEFAULT}
  18. DOWNLOAD_URL_BASE=${2:-$DOWNLOAD_URL_BASE_DEFAULT}
  19. for filename in $data_files ; do
  20. curl -L -o "$UNIDIR/$filename" "$DOWNLOAD_URL_BASE/UNIDATA/$filename"
  21. (
  22. cd "$UNIDIR"
  23. git add $filename
  24. )
  25. done
  26. for filename in $emoji_files ; do
  27. curl -L -o "$UNIDIR/$filename" "$DOWNLOAD_URL_BASE/UNIDATA/emoji/$filename"
  28. (
  29. cd "$UNIDIR"
  30. git add $filename
  31. )
  32. done
  33. (
  34. cd "$UNIDIR"
  35. git commit -m "Update unicode files" -- $files
  36. )