]> diplodocus.org Git - nmh/blob - docs/historical/mh-6.8.5/support/general/packmbox.sh
Simplify folder_exists() to just testing stat(2)'s return value.
[nmh] / docs / historical / mh-6.8.5 / support / general / packmbox.sh
1 #! /bin/sh
2 # packmbox - pack an MH folder back into a UUCP-style mbox
3 # @(#)$Id: packmbox.sh,v 1.16 1992/02/14 17:05:31 jromine Exp $
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