#!/bin/bash source_path=${1:-"$HOME/scripts/flightgear/source"} function xmlgetnext () { local IFS='>' read -d '<' TAG VALUE # by design, the first TAG/VALUE pair is empty # to avoid infinite loops at end of file parsing we return an error # the next time we find an empty TAG if test -z "$TAG"; then test ${xmlgetnext_firstentry:-1} -eq 1 && xmlgetnext_firstentry=0 || return 1; fi # process $TAG only if necessary local _TAG=$(printf '%q' $TAG) if test ${_TAG:0:1} = '$'; then TAG=$(tr '\n' ' ' <<< $TAG | sed 's/ */ /g; s/ *$//') fi } exit_trap () { rm $apixml } function showRSS () { echo -e "${1^^}\n${1//[[:alnum:]]/-}" revparse=$(git -C "$source_path/$1" rev-parse HEAD) wget -qO- https://sourceforge.net/p/flightgear/$1/feed | while xmlgetnext; do case "${TAG:0:1}" in ''|'?'|'!') continue;; /) property=${property%/*};; *) if test "${TAG: -1}" != '/'; then property+=/${TAG%% *} fi;; esac case "$property" in '/rss/channel/item/title') title=$VALUE ;; '/rss/channel/item/link') sha1=${VALUE/https:\/\/sourceforge.net\/p\/flightgear\/${1}\/ci\/} ;; '/rss/channel/item/pubDate') pubDate=$(date +'%e %B' -d "$VALUE") ;; esac if test "$TAG" = "/item"; then if test $revparse/ = $sha1; then title="* ${title}" else title=" ${title}" fi echo "$title (${pubDate/# })" fi done } cat << EOF $(showRSS simgear) $(showRSS flightgear) $(showRSS fgdata) EOF