download-unicode-files.sh 1018 B

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