commit ceefac3e911b84c8aa8d215a3f7ec651aaeb4800
parent f0e0326248e3a8c148eea64f77a5a1f84cf8d80b
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Tue, 2 Mar 2021 13:13:19 +0100
README: workaround empty fields with *BSD xargs -0
Workaround it by setting the empty "middle" fields to some value. The last
field can be empty.
Some feeds were incorrectly using the wrong base URL if the `baseurl` field was
empty but the encoding field was set. So it incorrectly used the encoding field
instead.
Only now noticed some feeds were failing because the baseURL is validated since
commit f305b032bc19b4e81c0dd6c0398370028ea910ca and returning a non-zero exit
status.
This doesn't happen with GNU xargs, busybox or toybox xargs.
Affected (atleast): OpenBSD, NetBSD, FreeBSD and DragonFlyBSD xargs which share
similar code.
Simple way to reproduce the difference:
printf 'a\0\0c\0' | xargs -0 echo
Prints "a c" on *BSD.
Prints "a c" on GNU xargs (and some other implementations).
Diffstat:
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/README b/README
@@ -650,7 +650,14 @@ sfeed_update_xargs shellscript:
# feed(name, feedurl, basesiteurl, encoding)
feed() {
- printf '%s\0%s\0%s\0%s\0%s\0%s\0' "${config}" "${sfeedtmpdir}" "$1" "$2" "$3" "$4"
+ # workaround: *BSD xargs doesn't handle empty fields in the middle.
+ name="${1:-$$}"
+ feedurl="${2:-http://}"
+ basesiteurl="${3:-${feedurl}}"
+ encoding="$4"
+
+ printf '%s\0%s\0%s\0%s\0%s\0%s\0' "${config}" "${sfeedtmpdir}" \
+ "${name}" "${feedurl}" "${basesiteurl}" "${encoding}"
}
# fetch feeds and store in temporary directory.