2 # $MirOS: contrib/hosted/tg/getarticle,v 1.3 2012/11/20 19:52:38 tg Exp $
5 # Thorsten Glaser <tg@mirbsd.org>
7 # Provided that these terms and disclaimer and all copyright notices
8 # are retained or reproduced in an accompanying document, permission
9 # is granted to deal in this work without restriction, including un‐
10 # limited rights to use, publicly perform, distribute, sell, modify,
11 # merge, give away, or sublicence.
13 # This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
14 # the utmost extent permitted by applicable law, neither express nor
15 # implied; without malicious intent or gross negligence. In no event
16 # may a licensor, author or contributor be held liable for indirect,
17 # direct, other damage, loss, or other issues arising in any way out
18 # of dealing in the work, even if advised of the possibility of such
19 # damage or existence of a defect, except proven that it results out
20 # of said person’s immediate fault when using the work as intended.
22 # call this with one of:
23 # getarticle gmane.foo.bar 1234
24 # getarticle $message_id
25 # ensure ~/mail/x can be a unix/mbox format mail folder we append to
27 if (( $# == 2 )); then
28 printf 'mode reader\r\ngroup %s\r\narticle %d\r\nquit\r\n' "$1" "$2"
29 elif [[ $1 = */+([0-9]) ]]; then
30 printf 'mode reader\r\ngroup %s\r\narticle %d\r\nquit\r\n' "${1%/*}" "${1##*/}"
32 printf 'mode reader\r\narticle <%s>\r\nquit\r\n' "$1"
34 nc news.gmane.org 119 | sed -e $'s/\r$//' -e '1,/^[^0-9]/d' -e '/^\.$/,$d' | \
35 (date -u +'From MAILER-DAEMON %a %b %e %H:%M:%S %Y'; cat) >>~/mail/x