From da2726ca7789f7b6edf85cee496f20fdc1332afc Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Tue, 22 Mar 2022 10:58:25 +0100 Subject: README: improve error handling in downloader example - Return exit code, which makes xargs return 123 when any of the downloads failed. - Write errors to stderr. - Write non-errors to stdout. --- README | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README b/README index 648e63e..db61a18 100644 --- a/README +++ b/README @@ -783,7 +783,7 @@ arguments are specified then the data is read from stdin. else s="$2" fi - printf '[%s]: %s: %s\n' "$(date +'%H:%M:%S')" "${s}" "$3" >&2 + printf '[%s]: %s: %s\n' "$(date +'%H:%M:%S')" "${s}" "$3" } # fetch(url, feedname) @@ -809,8 +809,8 @@ arguments are specified then the data is read from stdin. if [ "${feedname}" != "-" ]; then mkdir -p "${feedname}" if ! cd "${feedname}"; then - log "${feedname}" "${msg}: ${feedname}" "DIR FAIL" - exit 1 + log "${feedname}" "${msg}: ${feedname}" "DIR FAIL" >&2 + return 1 fi fi @@ -825,8 +825,10 @@ arguments are specified then the data is read from stdin. printf '%s\n' "${url}" >> "${cachefile}" ) 9>"${lockfile}" else - log "${feedname}" "${msg}" "FAIL" + log "${feedname}" "${msg}" "FAIL" >&2 + return 1 fi + return 0 } if [ "${SFEED_DOWNLOAD_CHILD}" = "1" ]; then -- cgit v1.2.3