mirror of
https://github.com/trueChristian/daily-scripture.git
synced 2025-01-24 21:08:24 +00:00
Adds more RANDOM
This commit is contained in:
parent
87b8a9595d
commit
dc5d24274c
24
src/today.sh
24
src/today.sh
@ -84,17 +84,19 @@ VERSION_DIR="$DIR/../scripture/${VERSION}"
|
|||||||
# only load if not already given
|
# only load if not already given
|
||||||
if [ -z "${TODAY_S_SCRIPTURE}" ]; then
|
if [ -z "${TODAY_S_SCRIPTURE}" ]; then
|
||||||
#████████████████████████████████████████████████████████████████ RANDOM ███
|
#████████████████████████████████████████████████████████████████ RANDOM ███
|
||||||
# set a random temp file
|
# set a random temp file
|
||||||
sort -R -k1 -b "${SORTED}" >"${TMP}"
|
sort -R -k1 -b "${SORTED}" >"${TMP}"
|
||||||
# get the first line
|
# get a random number between 1 and 1900
|
||||||
TODAY_S_SCRIPTURE=$(head -n 1 "${TMP}")
|
RANDOM_LINE=$((RANDOM % 1900 + 1))
|
||||||
# only if not a test
|
# get the line corresponding to the random number
|
||||||
if (("$DRY_RUN" == 0)); then
|
TODAY_S_SCRIPTURE=$(sed -n "${RANDOM_LINE}{p;q}" "${TMP}")
|
||||||
# remove the verse
|
# only if not a test
|
||||||
sed -i -e '1,1d' "${TMP}"
|
if (("$DRY_RUN" == 0)); then
|
||||||
# add to used verses
|
# remove the verse
|
||||||
[ -f "${USED}" ] && echo "$TODAY_S_SCRIPTURE" >>"${USED}" || echo "$TODAY_S_SCRIPTURE" >"${USED}"
|
sed -i -e "${RANDOM_LINE},${RANDOM_LINE}d" "${TMP}"
|
||||||
fi
|
# add to used verses
|
||||||
|
[ -f "${USED}" ] && echo "$TODAY_S_SCRIPTURE" >>"${USED}" || echo "$TODAY_S_SCRIPTURE" >"${USED}"
|
||||||
|
fi
|
||||||
|
|
||||||
#███████████████████████████████████████████████████ SIX MONTH RETENTION ███
|
#███████████████████████████████████████████████████ SIX MONTH RETENTION ███
|
||||||
# check test behaviour
|
# check test behaviour
|
||||||
|
Loading…
x
Reference in New Issue
Block a user