summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2018-02-18 15:39:29 +0100
committerHiltjo Posthuma <hiltjo@codemadness.org>2018-02-18 15:39:29 +0100
commitea4fc6a196202a7f69f66d9a720b3d645d8dc7fb (patch)
treeaea8d34dc81faf244472863b2e1cc6e7e57bf122
parent051bb63cd9c7e7a9861b9c3e82d993de13c39bba (diff)
sfeed_update: revert new merge logic
this requires more work without breaking the order in sfeed_html and other tools (top to bottom: new to oldest), vs sfeed_plain in tail mode: oldest to newest. There will also be improvements to the merge logic to reduce many writes in the future.
-rw-r--r--README1
-rwxr-xr-xsfeed_update12
2 files changed, 4 insertions, 9 deletions
diff --git a/README b/README
index a76641f..b5bbd03 100644
--- a/README
+++ b/README
@@ -74,7 +74,6 @@ Optional dependencies
- make(1) (for Makefile).
- POSIX sh(1),
used by sfeed_update(1) and sfeed_opml_export(1).
-- awk(1), used by sfeed_update(1).
- curl(1) binary: http://curl.haxx.se/ ,
used by sfeed_update(1), can be replaced with any tool like wget(1),
OpenBSD ftp(1).
diff --git a/sfeed_update b/sfeed_update
index 2977bdc..5e265a7 100755
--- a/sfeed_update
+++ b/sfeed_update
@@ -31,14 +31,10 @@ loadconfig() {
# merge raw files.
# merge(oldfile, newfile)
merge() {
- # unique check by id, title, link.
- # print only new entries in newfile.
- # order new items by timestamp (asc).
- (sed 's@^@O @' "$1"
- sed 's@^@N @' "$2") | \
- LC_ALL=C awk '!x[$7 " " $3 " " $4]++ && $1 == "N"' 2>/dev/null | \
- cut -f 2- | \
- sort -t ' ' -k1n,1
+ # unique sort by id, title, link.
+ # order by timestamp (desc).
+ (sort -t ' ' -u -k6,6 -k2,2 -k3,3 "$1" "$2" 2>/dev/null) |
+ sort -t ' ' -k1rn,1
}
# fetch a feed via HTTP/HTTPS etc.