diff --git a/local/bin/sav-quotes b/local/bin/sav-quotes index 18da068..f37859d 100755 --- a/local/bin/sav-quotes +++ b/local/bin/sav-quotes @@ -10,12 +10,13 @@ list_srcs() { } save_from_src() { mkdir -p ${dest:h} - rm $dest + rm -f $dest for i in {1..5} do $src >> $dest - wc -l $dest + (( i < 5 )) && echo % >> $dest + wc -l $dest done strfile $dest } diff --git a/local/share/sav-quotes/get-xkcdb-quotes b/local/share/sav-quotes/get-xkcdb-quotes index 4daca26..7cb55f0 100755 --- a/local/share/sav-quotes/get-xkcdb-quotes +++ b/local/share/sav-quotes/get-xkcdb-quotes @@ -1,5 +1,11 @@ #!/usr/bin/env bash -dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +sum() { + declare -i acc + for i; do acc+=i; done + echo $acc +} -curl http://www.xkcdb.com/\?random1 | hxnormalize -i 0 -l 99999999999 -x | hxremove br | hxselect -cs '\n%\n' 'span.quote' | hxunent -exit ${PIPESTATUS[0]} +curl -s 'http://www.xkcdb.com/?random1' | + hxnormalize -i 0 -l 99999999999 -x | hxselect -cs '
\n%
\n' 'span.quote' | + html2text -b 0 | hxunent | sed '$d; s/ *$//' | sed '$d' +exit $(sum ${PIPESTATUS[*]})