View Single Post
Old 11-28-2014, 04:59 PM   #11
Riggs
Junior Member
Riggs began at the beginning.
 
Posts: 1
Karma: 10
Join Date: Nov 2014
Device: kobo
Tiny bugfix for epub_read.sh

Hi - I was looking for a quick way to view epub files at the command line, and found this - does just what I wanted. However, I got a load of syntax errors, from bc. I tracked it down to line 237:

j=$(echo "scale=0; k=($j+1)/1-$j; scale=10; if ($j >= 0) $j+k/2 else 0" | bc)

j starts at -1, which leads to a divide by 1--1 in the expression for k. It seems bc doesn't like '--'; adding brackets around the variable j solves the problem:

j=$(echo "scale=0; k=($j+1)/1-($j); scale=10; if ($j >= 0) $j+k/2 else 0" | bc)

Thanks
Riggs is offline   Reply With Quote