richmon@astrovax.UUCP (Michael Richmond) (07/19/85)
When I discovered that one cannot use the tilde escapes such as ~v or ~p while in mail on my 7300, I was somewhat upset, since I am such a bad typist that something always goes wrong. So I worked up the following short shell script to automatically put me in vi (or whatever editor is desired) when I invoke mail, and use the file thus created as the message. if test $# -lt 1 then /bin/mail else /usr/bin/vi /tmp/letter if test -s /tmp/letter then /bin/mail $1 $2 $3 < /tmp/letter /bin/rm /tmp/letter fi fi I put this script, called 'mail', in a directory before /bin in my $PATH. Things you might want to change are /usr/bin/vi for an editor of your choice; changing the line that removes /tmp/letter for one that appends it to a mail archive; or adding $4, $5 and more to the /bin/mail command line if you are in the habit of mailing to more than three persons at once. -- Michael Richmond Princeton University, Astrophysics {allegra,akgua,burl,cbosgd,decvax,ihnp4,noao,princeton,vax135}!astrovax!richmon
root@bu-cs.UUCP (Barry Shein) (07/21/85)
>From: richmon@astrovax.UUCP (Michael Richmond) >Subject: fix for lack of editor escape in mail on 7300 > > When I discovered that one cannot use the tilde escapes such as ~v or >~p while in mail on my 7300 ... So I worked up the following short >shell script to automatically put me in vi (or whatever editor is desired) >when I invoke mail, and use the file thus created as the message. A fine suggestion, but may I suggest a slight improvement, the following: if test $# -lt 1 then /bin/mail else tmpfile = /tmp/LET$$ /usr/bin/vi $tmpfile if test -s $tmpfile then /bin/mail $1 $2 $3 < $tmpfile /bin/rm $tmpfile fi fi Sets the shell variable 'tmpfile' to /tmp/LETnnnn where nnnn is the process id of the shell (eg. /tmp/LET579). Then if, for example, you pushed out of the editor and invoked this script again (say you suddenly realized you needed to ask someone else about something before finishing the letter) you wouldn't trash the original file (or if there were more than one user, etc.) Just a suggestion, also a general one when creating tmp files in shell scripts (warning: I didn't try the above, forgive slight errors, the point is that '$$' is a built-in variable with the pid of the shell executing the script which should be unique enough.) -Barry Shein, Boston University