Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!pasteur!ames!amdcad!sun!ichthous!mcgrew From: mcgrew@ichthous.Sun.COM (Darin McGrew) Newsgroups: comp.mail.mh Subject: Re: Showing the first message in a sequence Message-ID: <101352@sun.Eng.Sun.COM> Date: 26 Apr 89 19:23:04 GMT References: <306@odi.UUCP> Sender: news@sun.Eng.Sun.COM Reply-To: mcgrew@sun.UUCP (Darin McGrew) Distribution: usa Organization: Sun Microsystems, Mountain View Lines: 56 In article <306@odi.UUCP> odi!benson@talcott.harvard.edu (Benson Margulies) writes: >I wanted a way to show the first unseen message in a folder... Here is my ~/bin/first script. It uses a feature in MH 6.5 pick; if -list is specified, and nothing matches, the pick command prints "0" so that other MH commands won't use their default message sequence. It also does all sorts of things to be MH-like. My script is basically the same as yours, except that it passes options to pick instead of passing options to show. This allows you to specify other folders besides the current folder, and all sorts of other things like that. Darin McGrew mcgrew@Sun.COM ------------------------- cut here ------------------------- #!/bin/sh CMD=`basename $0` unseen="`sed -n '/Unseen-Sequence: */s///p' $HOME/.mh_profile`" USAGE="syntax: $CMD [+folder] [msgs] [switches] msgs default is '$unseen'; must precede any switches switches see pick(1): " # # Do we show the first or the last match? # case "$CMD" in first) which=head;; last) which=tail;; *) echo "$CMD: must be invoked as 'first' or as 'last'" >&2 exit 1;; esac # # Do we need to specify the unseen sequence? # for i do case "$i" in -help) echo "$USAGE" >&2 pick -help >&2 exit 0;; -*) break;; +*) ;; *) unseen=;; esac done # # Show the first matching message # show `pick -list $unseen "$@" | $which -1` ------------------------- cut here -------------------------