-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrepm.old
More file actions
executable file
·53 lines (39 loc) · 1.44 KB
/
Copy pathgrepm.old
File metadata and controls
executable file
·53 lines (39 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/sh
# GREPM - A WRAPPER FOR GREPMAIL UTILIZING MUTT
# grepm-0.5
# written 1998-11-xx by Moritz Barsnick <barsnick@gmx.net>
# updated 1998-12-22: added "-m" option for grepmail
# added "exit 1" to trap
# updated 1999-01-04: added check for empty "mailbox" (don't open mutt)
# added messages
# added umask (to keep others from reading your messages)
# updated 1999-01-19: added trap for SIGPIPE (any other suggestions?)
# updated 1999-07-05: added $TMPDIR; we're still subject to races ($TMPFILE
# might exist)
PROGNAME=`basename "$0"`
TMPDIR=${TMPDIR-/tmp}
MAILER="mutt -f"
umask 077
if [ $# -lt 1 ]; then
echo 1>&2 "Usage: ${PROGNAME} arguments"
exit 1
fi
TMPFILE="${TMPDIR}/grepmail-output.$$"
# I _would_ check this with "-e", but not all /bin/sh's understand it
# so this is just a kludge
if [ -f ${TMPFILE} -o -d ${TMPFILE} -o -w ${TMPFILE} ]; then
echo 1>&2 "Temporary file ${TMPFILE} exists for some reason! Aborting."
exit 1
fi
trap "rm -f ${TMPFILE}; exit 1" 1 2 3 13 15
echo 1>&2 "Running \"grepmail -m $@\""
grepmail -m $@ > "${TMPFILE}" &
# if [ `wc -c "${TMPFILE}" | awk '{print $1}'` -gt 0 ]; then
echo 1>&2 "Calling [${MAILER} \"${TMPFILE}\"] on results file (${TMPFILE})."
sleep 2
${MAILER} "${TMPFILE}"
# ${MAILER} "${TMPFILE}"
#else
# echo 1>&2 "No matches."
#fi
rm -f "${TMPFILE}" && echo 1>&2 "Deleted results file (${TMPFILE})."