Make filename generation routine play nice with Russian and Unix

This commit is contained in:
Alexey Shpakovsky 2014-03-01 22:24:30 +01:00 committed by Aleksei Shpakovskii
parent b861d25a3a
commit 52f974c606

4
bb.sh
View file

@ -499,7 +499,11 @@ parse_file() {
title=$(echo "$line" | sed 's/<\/*p>//g')
filename="$(echo $title | tr [:upper:] [:lower:])"
filename="$(echo $filename | sed 's/\ /-/g')"
filename="$(echo $filename | sed 'y/йцукенгшщзхъфывапролджэячсмитьбю/jcukengsszh-fyvaproldzeahsmit-by/')"
filename="$(echo $filename | sed 'y/ЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ/jcukengsszh-fyvaproldzeahsmit-by/')"
filename="$(echo $filename | tr -dc '[:alnum:]-')" # html likes alphanumeric
filename="$(echo $filename | sed 's/^-*//')" # unix utilities are unhappy if filename starts with -
[ "$filename" ] || filename=$RANDOM # if filename gets empty, put something in it
filename="$filename.html"
content="$filename.tmp"