sfeed

simple feed reader - forked from git.codemadness.org/sfeed
git clone git://src.gearsix.net/sfeed
Log | Files | Refs | Atom | README | LICENSE

commit ddda48dac8e373f9bc0884ffeb84605925d988e5
parent 1b3f13b1ba5a3e40d4c9266f16091ad347aec333
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Mon, 25 Jan 2021 19:33:01 +0100

sfeed_update: separate code of parallel exection and feed() into a _feed() handler

This is useful to be able to reuse the code (together with using sfeed_update
as an included script, coming in the next commit).

Diffstat:
Msfeed_update | 29+++++++++++++++++------------
1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/sfeed_update b/sfeed_update @@ -79,17 +79,10 @@ order() { sort -t ' ' -k1rn,1 } -# fetch and parse feed. -# feed(name, feedurl, [basesiteurl], [encoding]) -feed() { - # wait until ${maxjobs} are finished: will stall the queue if an item - # is slow, but it is portable. - [ ${signo} -ne 0 ] && return - [ $((curjobs % maxjobs)) -eq 0 ] && wait - [ ${signo} -ne 0 ] && return - curjobs=$((curjobs + 1)) - - (name="$1" +# internal handler to fetch and process a feed. +# _feed(name, feedurl, [basesiteurl], [encoding]) +_feed() { + name="$1" feedurl="$2" basesiteurl="$3" encoding="$4" @@ -160,7 +153,19 @@ feed() { # OK log "${name}" "OK" - ) & +} + +# fetch and process a feed in parallel. +# feed(name, feedurl, [basesiteurl], [encoding]) +feed() { + # wait until ${maxjobs} are finished: will stall the queue if an item + # is slow, but it is portable. + [ ${signo} -ne 0 ] && return + [ $((curjobs % maxjobs)) -eq 0 ] && wait + [ ${signo} -ne 0 ] && return + curjobs=$((curjobs + 1)) + + _feed "$@" & } cleanup() {