Plan 9 from Bell Labs’s /usr/web/sources/contrib/nemo/root/acme/msgs/M

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!/bin/rc
rfork e
if (~ $#* 0){
	echo usage: M cmd [msgs] >[1=2]
	echo 'cmd=arch|spam|inbox|rm|print|list|mime|reply'
	exit usage
}
cmd=$1
shift

if (~ $#* 0){
	msgs=`{cat /tmp/msgs.$user | 
		grep '.*/[0-9]*/(.\.)?[0-9]*(/.*)?$' |
		sed -e 's|((.*/)?[0-9]*/(.\.)?[0-9]*)(/.*)?|\1|'}
}
if not
	msgs=`{for (x) echo $x | sed -e 's|((.*/)?[0-9][0-9]*/(.\.)?[0-9][0-9]*)(/.*)?|\1|g'}

if (~ $#INBOX 0)
	INBOX=/mail/box/$user/msgs
for (m in $msgs){
	if (! test -e $m)
		if (test -e $INBOX/$m)
			m=$INBOX/$m
	if(test -e $m)
		switch($cmd){
		case a arch
			aname=`{echo $m | sed 's,/(.\.)?([0-9]*)$,/a.\2,'}
			~ $m $aname || mv $m $aname
		case s spam
			aname=`{echo $m | sed 's,/(.\.)?([0-9]*)$,/s.\2,'}
			~ $m $aname || mv $m $aname
		case i inbox
			aname=`{echo $m | sed 's,/(.\.)?([0-9]*)$,/\2,'}
			~ $m $aname || mv $m $aname
		case d rm
			echo rm -r $m
		case m mime
			if (test -e $m/*.*)
				echo $m/*.*
			if (test -d $m/[0-9]*)
				echo $m/[0-9]*
		case l list
			echo $m
		case p print
			echo $m
			cat $m/text
		case r reply
			rfork n
			upas/fs -p -f $m/raw
			rt=`{cat /mail/fs/mbox/1/replyto}
			f=`{cat /mail/fs/mbox/1/from}
			cc=`{cat /mail/fs/mbox/1/cc /mail/fs/mbox/1/to}
			sub=`{cat /mail/fs/mbox/1/subject}
			{
			if (~ $#rt 0)
				echo To: $f
			if not
				echo To: $rt
			if (! ~ $#cc 0)
				echo Cc: $cc
			echo Subject: $sub
			echo Replying: $m/raw
			echo
			q '> ' $m/text
			} > /mail/box/$user/out/Out.$pid
			unmount /mail/fs
			if(! ~$#file 0 &&  ~ $#panel 0){
				panel=`{ls -d /mnt/ui/appl/*ox*/*tree*|sed 1q}
				if(~ $#panel 0)
					echo look /mail/box/$user/out/Out.$pid 
				if not
					echo look /mail/box/$user/out/Out.$pid > $panel/ctl
			}
			if not {
				plumb /mail/box/$user/out/Out.$pid
				echo edit and remove '"Out."' from the file name 
			}
		case *
			echo usage: M 'arch|rm|cp' [msgs] >[1=2]
			exit usage
		}
}

exit ''


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.