#!/bin/sh -e # noffle/leafnode queue lister/editor/remover for the hours # before we connect our modem # Copyright : http://www.fsf.org/copyleft/gpl.html # Author : Dan Jacobson -- http://jidanni.org/ # Created On : Tue Jun 25 06:03:53 2002 # Last Modified On: Wed Apr 27 09:13:12 2005 # Update Count : 138 : ${headers_to_check=From|Newsgroups|Subject|Date} test $outgoing_news_dir||case $0 in #leafnode users: rename this file I guess *leafnode*) outgoing_news_dir=/var/spool/news/out.going;; *) outgoing_news_dir=/var/spool/noffle/outgoing/;; esac case $1 in -\?|--help)exec echo 'edit -e; remove -r; multiple -m; view -v';;esac while getopts vmre option do case $option in v)readonly mode=view;; m)multiple_messages=y;; r)readonly mode=REMOVE;; e)readonly mode=edit;; \?)exit 94;; esac shift $(($OPTIND - 1)) done test $# -ne 0 && { echo $0: odd arg $@, try --help 1>&2; exit 49;} case $mode in view);; "")test $multiple_messages &&{ echo $0: need -e\|r 1>&2; exit 4;}; mode=list;; *) test -w $outgoing_news_dir|| { echo $0: _you_ can\'t mess with articles in $outgoing_news_dir 1>&2 exit 34;} esac cd $outgoing_news_dir a=`find . -type f ! -empty` test "$a" ||{ echo $0: No articles found; exit;} set -- `ls -tr $a` #test $# -ne 1 -o $mode = list && awk 'BEGIN{n=1};FNR==1&&NR!=1{print""};/^('"$headers_to_check"'): /{print n,$0} /^$/{print n,"File: '$outgoing_news_dir'"FILENAME;n++;nextfile}' $@ #but "." looks bad case $mode in list) exit;; esac; #still ask, even if one message, less scary... so commenting out: #if test $# -eq 1 #then # case $mode in # view ) ${PAGER:-cat} $1;; # REMOVE) mv -v $1 /tmp;; # edit ) ${EDITOR:-editor} $1;; # esac # exit #fi echo : ${multiple_messages=n}; set -u while read -p "$mode which message? " message do case "$message" in "")break;; #beats 'select' *[^0-9]*)echo $0: $message: invalid choice 1>&2; exit 37;; esac case $mode in view ) ${PAGER:-cat} ${!message};; REMOVE) mv -v ${!message} /tmp;; edit ) ${EDITOR:-editor} ${!message};; esac test $multiple_messages = y||break #mostly one done #From: Matthias Andree 10/02 #Re: Bug#167837: leafnode: newsq should mention its sorting method on manpage #Cc: Debian Bug Tracking System #The newsq output is in natural directory order -- ls -U -- and will be #documented in the newsq man page. #I am refusing to change the current behaviour. #[Dan says: OK, never mind newsq then.]