diff options
author | Hiltjo Posthuma <hiltjo@codemadness.org> | 2022-03-22 09:45:34 +0100 |
---|---|---|
committer | Hiltjo Posthuma <hiltjo@codemadness.org> | 2022-03-22 09:45:34 +0100 |
commit | 5934cb409782091b6d4481ceccf77e82832167ec (patch) | |
tree | 3405aff4c53665e2b0984092d4cba06d9ffbae05 | |
parent | a9445184bb7b4975bc27e7b41e7bfd9f31f1c0ac (diff) |
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."
-rwxr-xr-x | sfeed_update | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/sfeed_update b/sfeed_update index f2c97ae..b9880c3 100755 --- 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. |