alexkarle.com

Source for alexkarle.com
git clone git://git.alexkarle.com/alexkarle.com.git
Log | Files | Refs | README | LICENSE

commit ba8123ac135f63b444196b6cdbf28ca0d1a7eeb9 (patch)
parent aebddb09f067953ff62f9276ab6e252c64c20148
Author: Alex Karle <alex@alexkarle.com>
Date:   Mon,  3 Jan 2022 18:01:52 -0500

atom: Add support for Linux atom.xml generation

Turns out `date` is rather different between BSD and GNU... RIP.
This is a half-hearted attempt (I mean Linux != GNU) to support Linux
(all my Linux systems use GNU coreutils).

Diffstat:
Mbin/genatom.sh | 11+++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/bin/genatom.sh b/bin/genatom.sh @@ -6,6 +6,14 @@ REPO=$(dirname "$(dirname "$0")") POSTS=$(grep '^- ../..' "$REPO/www/blog/index.txt" | sed 's#.*/blog/\([^)]*\).*#\1#') +ARCH="$(uname)" +parsedate() { + case "$ARCH" in + Linux) date +%F --date="$1" ;; + *) date -juf"%b %d, %Y" +%F "$1" ;; # assume *BSD + esac +} + cat <<HEADER <?xml version="1.0" encoding="utf-8"?> <feed xmlns="http://www.w3.org/2005/Atom"> @@ -23,8 +31,7 @@ for post in $POSTS; do src="$REPO/www/blog/$p.txt" [ "$p" = "index" ] && continue - d=$(date -juf"%b %d, %Y" +%F \ - "$(grep '^_Published' "$src" | sed 's/_Published: \([^_]*\)_/\1/')") + d=$(parsedate "$(grep '^_Published' "$src" | sed 's/_Published: \([^_]*\)_/\1/')") if [ -z "$printed_update" ]; then printed_update=1 printf " %s\n" "<updated>${d}T00:00:00Z</updated>"