ACC SHELL

Path : /proc/self/root/usr/bin/
File Upload :
Current File : //proc/self/root/usr/bin/sun-message

#!/bin/sh
#
#  This is sun-message.
#  It looks at $2 to figure out how to decode $1,
#  then gives the user a short menu of choices:
#    display, save or quit.

mkdir /tmp/decode.$$ || exit 1
cd /tmp/decode.$$

if [ -n "`type -p mktemp`" ] ; then
	fn=`mktemp uu.XXXXXX` || exit 1
else
	fn=uu.$$
	rm -f $fn
fi

if [ -n "$METAMAIL_PAGER" ]
then
	PAGER="$METAMAIL_PAGER"
fi

if test "$2" = "uuencode"
then 
	uudecode -o $fn < "$1"

	echo "The following file was uudecoded:"
	echo

	defans=1
	while :
	do
		ls -l
		fn=*

		echo
		echo "Please choose one:"
		echo
		echo "1 -- Display it as ASCII text"
		echo "2 -- Save it as a file"
		echo "3 -- Quit this menu"
		echo
		echo -n "Which do you prefer (1 - 3)? [$defans] "

		read ans
		if test -z "${ans:-}"
		then
			ans=$defans
		fi

		case $ans in
			1)	if [ -n "$PAGER" ] ; then
					$PAGER $fn
				else
					more   $fn
				fi
				;;
			2)	echo -n "Save as: $HOME/"
				read nfn
				if test ! -z "${nfn:-}"
				then
					/bin/cp $fn $HOME/$nfn
				else
					echo Not Saved.
				fi
				;;
			3)	rm $1
				cd /tmp
				/bin/rm -rf /tmp/decode.$$
				exit 0
				;;
			*)	echo Invalid choice. ;;
		esac
		defans=3
	done
else
	if [ -n "$PAGER" ] ; then
		$PAGER "$1"
	else
		more   "$1"
	fi
fi

ACC SHELL 2018