~kris/dots

srice

ref: 9f828eb14bdd54d2c4fd8a3b2c90253021df3152 srice/.local/bin/blog-rss-check -rwxr-xr-x 472 bytes
9f828eb1 — Kris Yotam mksh: backslash-escape commands in history hook to bypass module aliases (wc=tokei, tr=transmission-remote, cat=bat) 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/env sh
set -eu

if [ "$#" -eq 0 ]; then
  set -- $(find . -type f \( -name '*.xml' -o -name '*.atom' -o -name 'feed*' -o -name 'rss*' \) -not -path '*/node_modules/*' -not -path '*/.git/*')
fi

for f in "$@"; do
  [ -f "$f" ] || continue
  if command -v xmllint >/dev/null 2>&1; then
    xmllint --noout "$f" && printf 'ok %s\n' "$f"
  else
    python3 -c 'import sys, xml.etree.ElementTree as ET; ET.parse(sys.argv[1])' "$f" && printf 'ok %s\n' "$f"
  fi
done