Plan 9 from Bell Labs’s /usr/web/sources/contrib/steve/rc/from

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


#!/bin/rc

mbox=mbox
if ( ! ~ $#* 0 )
	mbox=$1

switch($mbox){
case /*
	;
case *
	mbox=/mail/box/$user/$mbox
}

if ( ! test -r $mbox ){
	echo from: $mbox - cannot read
	exit 'read fail'
}

sed -n '
	/^From /,/^$/ {
		/^From: /{
			s/.*"([^"]+)".*/\1/
			s/.*<([^>]+)>.*/\1/
			s/From: //
			y/#/-/
			s/$/                               /
			s/^(................................).*/\1/
			s/^/FROM/
			H
		}
		/^Subject: /{
			s/^Subject: //
			y/#/-/
			s/^/SUBJ/
			H
		}
		/^$/{
			x
			s/^FROM([^}]*)\n^SUBJ([^}]*)/\1\2/
			s/^SUBJ([^}]*)\n^FROM([^}]*)/\2\1/
			s/^FROM([^}]*)/\1/
			s/\n//
			p
			d
			h
		}

	}' $mbox

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].