# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: package/.../metamail/15_mm-2.7-csh.patch
# Copyright (C) 2004 - 2006 The T2 SDE Project
# Copyright (C) 1998 - 2003 Clifford Wolf
#
# More information can be found in the files COPYING and README.
#
# This patch file is dual-licensed. It is available under the license the
# patched project is licensed under, as long as it is an OpenSource license
# as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
# of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
# --- SDE-COPYRIGHT-NOTE-END ---

--- mm2.7/src/metamail/mailto.c.cshfix	Sat Oct 25 09:50:36 1997
+++ mm2.7/src/metamail/mailto.c	Sat Oct 25 09:51:03 1997
@@ -200,9 +200,12 @@
 }
 
 TildeHelp() {
-    char *pager = getenv("PAGER");
     char TmpName[100], CmdBuf[150];
+    char *pager;
     FILE *fp;
+
+    if ((pager = getenv("METAMAIL_PAGER")) == NULL)
+    	pager = getenv("PAGER");
 
     strcpy(TmpName, tmpname());
     fp = fopen(TmpName, "w");
--- mm2.7/src/bin/showexternal.cshfix	Sat Oct 25 09:45:05 1997
+++ mm2.7/src/bin/showexternal	Sat Oct 25 09:46:25 1997
@@ -19,6 +19,9 @@
 if (! $?METAMAIL_TMPDIR) then
     set METAMAIL_TMPDIR=/tmp
 endif
+if (! $?METAMAIL_PAGER) then
+    set METAMAIL_PAGER=more
+endif
 if (! $?FTP) then
     set FTP=ftp
 endif
@@ -27,11 +30,19 @@
     echo "Usage: showexternal body-file access-type name [site [directory [mode [server]]]]"
     exit -1
 endif
-set bodyfile=$1
+# Check argument integrity. Don't trust mail headers
+switch ("$1$2$3$4$5$6$7")
+case "*[ 	]*":
+	echo "Illegal white space in arguments -- possibly a mail bomb?!"
+	echo "Command was:"
+	echo \'$0\' \'$1\' \'$2\' \'$3\' \'$4\' \'$5\' \'$6\' \'$7\'
+	exit 2
+endsw
+set bodyfile="$1"
 set atype=`echo $2 | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
 set name=$3
 if ($#argv > 3) then
-    set site=$4
+    set site="$4"
 else 
     set site=""
 endif
@@ -41,12 +52,12 @@
     set dir=""
 endif
 if ($#argv > 5) then
-    set mode=$6
+    set mode="$6"
 else
     set mode=""
 endif
 if ($#argv > 6) then
-    set server=$7
+    set server="$7"
 else
     set server=""
 endif
@@ -96,7 +107,7 @@
 
 !
 	sed -e 1,/^\$/d < $bodyfile >> ${METAMAIL_TMPDIR}/ext.junk.$$
-	more ${METAMAIL_TMPDIR}/ext.junk.$$
+	${METAMAIL_PAGER} ${METAMAIL_TMPDIR}/ext.junk.$$
 	rm ${METAMAIL_TMPDIR}/ext.junk.$$
 	breaksw
     default:
--- mm2.7/src/bin/showpartial.cshfix	Sat Oct 25 09:46:37 1997
+++ mm2.7/src/bin/showpartial	Sat Oct 25 09:47:24 1997
@@ -11,14 +11,14 @@
     echo "Usage:  showpartial file id partnum totalnum"
     exit -1
 endif
-set file=$1
+set file="$1"
 # This next line is because message-id can contain weird chars
 set id=`echo $2 | tr -d  \!\$\&\*\(\)\|\'\"\;\/\<\>\\` 
 @ partnum = $3
 if ($#argv == 3 || $4 == "") then
     set totalnum=-1
 else
-    @ totalnum = $4
+    @ totalnum = "$4"
 endif
 
 if (! -d  $TREEROOT)  then
--- mm2.7/src/bin/sun-message.csh.cshfix	Sat Oct 25 09:49:16 1997
+++ mm2.7/src/bin/sun-message.csh	Sat Oct 25 09:50:15 1997
@@ -8,6 +8,10 @@
 mkdir /tmp/decode.$$
 cd /tmp/decode.$$
 
+if (! $?METAMAIL_PAGER) then
+    set METAMAIL_PAGER=more
+endif
+
 if ($2 == "uuencode") then
     uudecode $1
 
@@ -37,7 +41,7 @@
 	    cd /tmp; /bin/rm -rf /tmp/decode.$$
 	    exit 0
 	else if ($ans == 1) then
-	    more $fn
+	    ${METAMAIL_PAGER} $fn
 	else if ($ans == 2) then
 	    set nfn = ""
 	    echo -n "Save as: $HOME/"
@@ -53,7 +57,7 @@
 	set defans = "3"
     end
 else
-    more $1
+    ${METAMAIL_PAGER} $1
 endif