Skip to content

Commit

Permalink
Rewrite some arithmetic expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
na-- committed Nov 16, 2017
1 parent c367937 commit 0112256
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -223,20 +223,20 @@ is_isbn_valid() {
if [[ "$i" == "9" && "$number" == "X" ]]; then
number=10
fi
(( sum = sum + (number * ( 10 - i )) ))
sum=$(( sum + (number * ( 10 - i )) ))
done
if [ "$((sum % 11))" == "0" ]; then
if (( sum % 11 == 0 )); then
return 0
fi
elif [ "${#isbn}" == "13" ]; then
if [[ "${isbn:0:3}" = "978" || "${isbn:0:3}" = "979" ]]; then
for i in {0..12..2}; do
(( sum = sum + ${isbn:$i:1} ))
sum=$(( sum + ${isbn:$i:1} ))
done
for i in {1..11..2}; do
(( sum = sum + (${isbn:$i:1} * 3) ))
sum=$(( sum + (${isbn:$i:1} * 3) ))
done
if [ "$((sum % 10))" == "0" ]; then
if (( sum % 10 == 0 )); then
return 0
fi
fi
Expand Down Expand Up @@ -449,7 +449,7 @@ ocr_file() {
while (( page <= num_pages )); do
if [[ "$OCR_ONLY_FIRST_LAST_PAGES" == false ]] ||
(( page <= ${ocr_first_pages:-0} )) ||
((page > num_pages - ${ocr_last_pages:-0} ));
(( page > num_pages - ${ocr_last_pages:-0} ));
then
tmp_file=$(mktemp)
tmp_file_txt=$(mktemp --suffix='.txt')
Expand Down

0 comments on commit 0112256

Please sign in to comment.