Permalink
Browse files

Fix division by 0

Signed-off-by: Jan-Christoph Borchardt <hey@jancborchardt.net>
  • Loading branch information...
jancborchardt committed Jan 11, 2019
1 parent 0e3c80d commit 58a11d12d908399fa9f724b22dee93c4ad6fcce2
Showing with 1 addition and 2 deletions.
  1. +1 −2 randomblock.sh
@@ -35,11 +35,10 @@ $line" || {
arr[$i]="$line"
s=0;
}
done < $RANDOMFILE
done < "$RANDOMFILE"

# Choose index to be a random number from 0 to the length of the array
# Code from https://stackoverflow.com/a/2388555
# TODO: Catch division by 0
selectedblock=${arr[$RANDOM % ${#arr[@]} ]}

echo "$RANDOMFILE"

0 comments on commit 58a11d1

Please sign in to comment.