comparison support/general/packmbox.sh @ 0:bce86c4163a3

Initial revision
author kono
date Mon, 18 Apr 2005 23:46:02 +0900
parents
children 441a2190cfae
comparison
equal deleted inserted replaced
-1:000000000000 0:bce86c4163a3
1 #! /bin/sh
2 # packmbox - pack an MH folder back into a UUCP-style mbox
3 # @(#)$Id$
4 #
5 # Defaults:
6 # `+folder' defaults to current folder
7 # `msgs' defaults to all
8 #
9 # Context:
10 # Current-Folder
11 #
12 # for simplicity (and speed) we don't parse command-line args (much)
13 case $#/$1 in
14 1/-h*) echo "syntax: packmbox [+folder] [msgs] [-help]" 1>&2; exit 0;;
15 esac
16
17 format="%(msg) From \
18 %<{return-path}%(putstr)%|\
19 %<(nonnull(mbox{from}))%(putstr)%|nobody%>@\
20 %<(nonnull(host{from}))%(putstr)%|nowhere%>%> \
21 %(day{date}) %(month{date}) %2(mday{date}) \
22 %02(hour{date}):%02(min{date}):%02(sec{date}) \
23 %(void(year{date}))%<(gt 100)%4(putnum)%|19%02(putnum)%>"
24
25 trap 'rm -f /tmp/packm$$; exit 1' 1 2 3 15
26
27 scan -noclear -noheader -noreverse -width 256 \
28 -format "${format}" $* >/tmp/packm$$
29 # tricky -- you must do this "cd" after scan has updated the context
30 cd `mhpath`
31
32 exec </tmp/packm$$
33 rm -f /tmp/packm$$
34 while read m f
35 do
36 echo "$f"
37 sed -e '/^From /s/^/>/' < $m
38 echo ""
39 done
40 exit