pubsub_setup: return exit code, write errors to stderr, OK to stdout - pubsubhubbubblub - pubsubhubbub client implementation
HTML git clone git://git.codemadness.org/pubsubhubbubblub
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
DIR commit 14fe35c0d15bb77075e2a7bd225884510b431eba
DIR parent e62f5cc6b38cd2f629b639699678e248a456d3e1
HTML Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Sat, 28 May 2022 12:36:33 +0200
pubsub_setup: return exit code, write errors to stderr, OK to stdout
Diffstat:
M pubsub_setup | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
---
DIR diff --git a/pubsub_setup b/pubsub_setup
@@ -26,6 +26,11 @@ sha() {
# log(s)
log() {
+ echo "$1"
+}
+
+# log_error(s)
+log_error() {
echo "$1" >&2
}
@@ -54,7 +59,7 @@ subscribe() {
log "${mode} OK"
return 0
else
- log "${mode} FAIL"
+ log_error "${mode} FAIL"
return 1
fi
}
@@ -108,6 +113,7 @@ secret=$(cat "${f}" 2>/dev/null)
callback="${base}${feedname}/${token}"
+status=0
if test "${dosubscribe}" = "1"; then
f="config/${feedname}/hub"
if test -f "${f}"; then
@@ -120,6 +126,8 @@ if test "${dosubscribe}" = "1"; then
printf '%s\n' "${callback}" > "config/${feedname}/callback"
printf '%s\n' "${hub}" > "config/${feedname}/hub"
printf '%s\n' "${topic}" > "config/${feedname}/topic"
+ else
+ status=1
fi
fi
@@ -129,5 +137,9 @@ if test "${dounsubscribe}" = "1"; then
rm -f "config/${feedname}/callback"
rm -f "config/${feedname}/hub"
rm -f "config/${feedname}/topic"
+ else
+ status=1
fi
fi
+
+exit $status