summaryrefslogtreecommitdiff
path: root/README
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2022-03-22 10:58:25 +0100
committerHiltjo Posthuma <hiltjo@codemadness.org>2022-03-22 10:58:25 +0100
commitda2726ca7789f7b6edf85cee496f20fdc1332afc (patch)
treeab8ba54fb9bc567f479a6094f33320bacdb35112 /README
parent5934cb409782091b6d4481ceccf77e82832167ec (diff)
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.
Diffstat (limited to 'README')
-rw-r--r--README10
1 files 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