sfeed

Simple RSS and Atom feed parser
git clone https://git.sinitax.com/codemadness/sfeed
Log | Files | Refs | README | LICENSE | Upstream | sfeed.txt

commit 5934cb409782091b6d4481ceccf77e82832167ec
parent a9445184bb7b4975bc27e7b41e7bfd9f31f1c0ac
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Tue, 22 Mar 2022 09:45:34 +0100

sfeed_update: return status in _feed() function

This can be useful for scripts, for example the sfeed_update_xargs example
script in the README. This way the process can signal an error and xargs will
exit with the code 123:

	"One or more invocations of utility returned a nonzero exit status."

Diffstat:
Msfeed_update | 17+++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/sfeed_update b/sfeed_update @@ -105,7 +105,7 @@ _feed() { if ! fetch "${name}" "${feedurl}" "${sfeedfile}" > "${tmpfeedfile}.fetch"; then log_error "${name}" "FAIL (FETCH)" - return + return 1 fi # try to detect encoding (if not specified). if detecting the encoding fails assume utf-8. @@ -113,50 +113,51 @@ _feed() { if ! convertencoding "${name}" "${encoding}" "utf-8" < "${tmpfeedfile}.fetch" > "${tmpfeedfile}.utf8"; then log_error "${name}" "FAIL (ENCODING)" - return + return 1 fi rm -f "${tmpfeedfile}.fetch" # if baseurl is empty then use feedurl. if ! parse "${name}" "${feedurl}" "${basesiteurl:-${feedurl}}" < "${tmpfeedfile}.utf8" > "${tmpfeedfile}.tsv"; then log_error "${name}" "FAIL (PARSE)" - return + return 1 fi rm -f "${tmpfeedfile}.utf8" if ! filter "${name}" < "${tmpfeedfile}.tsv" > "${tmpfeedfile}.filter"; then log_error "${name}" "FAIL (FILTER)" - return + return 1 fi rm -f "${tmpfeedfile}.tsv" # new feed data is empty: no need for below stages. if [ ! -s "${tmpfeedfile}.filter" ]; then log "${name}" "OK" - return + return 0 fi if ! merge "${name}" "${sfeedfile}" "${tmpfeedfile}.filter" > "${tmpfeedfile}.merge"; then log_error "${name}" "FAIL (MERGE)" - return + return 1 fi rm -f "${tmpfeedfile}.filter" if ! order "${name}" < "${tmpfeedfile}.merge" > "${tmpfeedfile}.order"; then log_error "${name}" "FAIL (ORDER)" - return + return 1 fi rm -f "${tmpfeedfile}.merge" # copy if ! cp "${tmpfeedfile}.order" "${sfeedfile}"; then log_error "${name}" "FAIL (COPY)" - return + return 1 fi rm -f "${tmpfeedfile}.order" # OK log "${name}" "OK" + return 0 } # fetch and process a feed in parallel.