sfeed_curses

[fork] sfeed (atom feed) reader
git clone https://hhvn.uk/sfeed_curses
git clone git://hhvn.uk/sfeed_curses
Log | Files | Refs | README | LICENSE

sfeed_markread (549B)


      1 #!/bin/sh
      2 # usage: $0 <read|unread>
      3 # input is the read / unread url per line.
      4 
      5 if test -z "$SFEED_URL_FILE"; then
      6 	echo "\$SFEED_URL_FILE must be set" >&2
      7 	exit 1
      8 fi
      9 
     10 case "$1" in
     11 read)
     12 	cat >> "$SFEED_URL_FILE";;
     13 unread)
     14 	tmp=$(mktemp)
     15 	trap "rm -f $tmp" EXIT
     16 	LC_CTYPE=C awk -F '\t' '
     17 	{ FILENR += (FNR == 1)	}
     18 	FILENR == 1 { urls[$0] = 1 }
     19 	FILENR == 2 { if (!urls[$0]) { print $0 } }
     20 	END { exit(FILENR != 2) }' \
     21 		"/dev/stdin" "$SFEED_URL_FILE" > "$tmp" && \
     22 		mv "$tmp" "$SFEED_URL_FILE"
     23 	;;
     24 *)
     25 	echo "$0 <read|unread>" >&2
     26 	exit 1
     27 	;;
     28 esac