[net.unix] A proposal

spaf@gatech.UUCP (Gene Spafford) (02/07/84)

I was looking through one of my archives on another system and
found the following.  I think there may be merit in the idea.
Anybody out there have any comments?

Begin Inserted Text:

# 366
From : PHIL REED                   To : USER FRIENDLIES
Subject : AN IDEA                Date : Wed. 12/09/81 10:56
Has anyone thought of grafting the pseudo-English parser of Zork
or other dungeon games onto a shell? Not only would it be a cheap
way to get the more natural syntax some people say they want,
it could provide a very amusing interface, and add glamour and
excitement to ordinary work:
 
% go to bin
you are in ~jon/bin. there are many files here.
% look
you are in ~jon/bin. the directory contains:
     date
     date.c
     readtape
     scramble
the only exit is up.
% use date to create tmp
done!
% take tmp
taken.
% open tmp
you open tmp to reveal:
     Tue. November 24, 1981 (2:00pm EST)
% take date.c
taken.
% look
you are in ~jon/bin. the directory contains:
     date
     readtape
     scramble
the only exit is up.
% inventory
you are carrying:
     date.c
     tmp
% goto src
you are in ~jon/src. there are many files here.
% drop date.c
dropped.
% throw tmp at printer
the printer catches your file, turns it into paper, and
leaves it in the basement.
% look
your are in ~jon/src. the directory contains:
     date.c
     scramble.c
     readtape.c
there are exits marked 'zshell' and 'secret'
as well as the path leading up.
% xyzzy
you are back in your home directory. there are many files here.
% run foo
the foo dumps core.
Oh dear! you seem to have gotten yourself killed.
% attack core with sdb
   .
   .
   .

(downloaded from the Original NorthStar BBS, run by Microstuf.)



End Inserted Text.

-- 
Off the Wall of Gene Spafford
The Clouds Project, School of ICS, Georgia Tech, Atlanta GA 30332
CSNet:	Spaf @ GATech		ARPA:	Spaf.GATech @ CSNet-Relay
uucp:	...!{akgua,allegra,rlgvax,sb1,unmvax,ulysses,ut-sally}!gatech!spaf

mauney@ncsu.UUCP (Jon Mauney) (02/08/84)

I am glad to see that my zshell proposal is still popular,
and has made it to all kinds of bulletin board systems.
However,  I notice that no credit is given to the author (me).
I wish that in the future people would give a short 
acknowledgment, such as:

	  This wonderful idea courtesy of
	  Jon (no middle name) Mauney
	  Assistant Professor of Computer Science
	  North Carolina State University
	  (who is available for consulting at
	   reasonable rates)

Thank you.
-- 

_Doctor_                           Jon Mauney,    mcnc!ncsu!mauney
\__Mu__/                           North Carolina State University

spaf@gatech.UUCP (Gene Spafford) (02/09/84)

I just got the following note in my mail; I believe in giving credit
where credit is due.

>    The original version of the 'adventure shell' proposal came from Jon
>    Mauney (sp?), while he was at the Univ. of Wisconsin.  (That's why the
>    directory used is "~jon".)  The article appeared in Human-Nets Digest. 
>    Jon is now at North Carolina State Univ. as a professor; ncsu!mauney.
>    
>    A version of this shell has recently been implemented by Barry Kircheval
>    (sp?), zehntel!barry.
>    
>    	Paul Lustgarten

>    	AT&T Bell Laboratories, Short Hills, NJ
>    	hlexa!pcl
>    
-- 
Off the Wall of Gene Spafford
The Clouds Project, School of ICS, Georgia Tech, Atlanta GA 30332
CSNet:	Spaf @ GATech		ARPA:	Spaf.GATech @ CSNet-Relay
uucp:	...!{akgua,allegra,rlgvax,sb1,unmvax,ulysses,ut-sally}!gatech!spaf

fair@dual.UUCP (Erik E. Fair) (02/13/84)

Actually, that's

Berry Kercheval
{ucbvax,ihnp4,tektronix,hplabs}!zehntel!berry

OK? (Paul, you should know better!)

	Erik E. Fair

	dual!fair@BERKELEY.ARPA
	{ucbvax,ihnp4,cbosgd,amd70,zehntel,fortune,unisoft,onyx,its}!dual!fair
	Dual Systems Corporation, Berkeley, California

gwyn%brl-vld@sri-unix.UUCP (02/23/84)

From:      Doug Gwyn (VLD/VMB) <gwyn@brl-vld>

Now you've done it!  I had the following lying around; it uses a couple
of local utilities "ask" and "pg" that you can easily supply.  I hacked
this out in an evening, so it could undoubtedly be improved.

========== ash.inst ==========


		Instructions for the Adventure shell

Welcome to the Adventure shell!  In this exploration of the UNIX file
system, I will act as your eyes and hands.  As you move around, I will
describe whatever is visible and will carry out your commands.  The
general form of a command is
	Verb Object Extra_stuff.
Most commands pay no attention to the "Extra_stuff", and many do not
need an "Object".  A typical command is
	get all
which picks up all files in the current "room" (directory).  You can
find out what you are carrying by typing the command
	inventory
The command "help" results in a full description of all commands that I
understand.  To quit the Adventure shell, type
	quit

There are UNIX monsters lurking in the background.  These are also
known as "commands with arguments".

Good luck!



========== ash.help ==========

I understand the following commands (synonyms in parentheses):

change OBJECT to NEW_NAME	changes the name of the object
clone OBJECT as NEW_NAME	duplicates the object
drop OBJECTS			leaves the objects in the room
enter (go) PASSAGE		takes the labeled passage
examine OBJECTS			describes the objects in detail
feed OBJECT to MONSTER		stuffs the object into a UNIX monster
get (take) OBJECTS		picks up the specified objects
gripe (bug)			report a problem with the Adventure shell
help				prints this summary
inventory (i)			tells what you are carrying
kill (destroy) OBJECTS		destroys the objects
look (l)			describes the room, including hidden objects
open (read) OBJECT		shows the contents of an object
quit (exit)			leaves the Adventure shell
resurrect OBJECTS		attempts to restore dead objects
steal OBJECT from MONSTER	obtains the object from a UNIX monster
throw OBJECT at daemon		feeds the object to the printer daemon
up				takes the overhead passage
wake MONSTER			awakens a UNIX monster
where (w)			tells you where you are
xyzzy				moves you to your home

========== ash ==========

#!/bin/sh
#	ash -- "Adventure shell"
#	last edit:	83/11/14	D A Gwyn
#	SCCS ID:	@(#)ash.sh	1.1

OPATH=$PATH

ASK=/vld/bin/ask
CAT=/vld/bin/pg
HELP=/vld/lib/ash.help
INST=/vld/lib/ash.inst
MAINT=gwyn@brl-vld
PATH=/usr/5bin:/bin:/usr/bin
export PATH

trap 'echo Ouch!' 2 3

cd
LIM=.limbo			# $HOME/$LIM contains "destroyed" objects
mkdir $LIM >&- 2>&-
KNAP=.knapsack			# $HOME/$KNAP contains objects being "carried"
if [ ! -d $KNAP ]
then	mkdir $KNAP >&- 2>&-
	if [ $? = 0 ]
	then	echo 'You found a discarded empty knapsack.'
	else	echo 'You have no knapsack to carry things in.'
		exit 1
	fi
else	echo 'One moment while I peek in your old knapsack...'
fi

kn=`echo \`ls -a $KNAP | sed -e '/^\.$/d' -e '/^\.\.$/d'\``

if $ASK 'Welcome to the Adventure shell!  Do you need instructions?'
then	$CAT < $INST
	echo 'Type a newline to continue: \c'
	read i
fi

wiz=false
cha=false
prev=$LIM
while sh -c true
do	room=`pwd`
	if [ $room != $prev ]
	then	if [ $room = $HOME ]
		then	echo 'You are in your own home.  \c'
		else	echo "You have entered $room.  \c"
		fi
		exs=
		obs=
		hexs=
		hobs=
		f=false
		for i in `ls -a`
		do	case $i in
			.|..)	;;
			.*)	if [ -f $i ]
				then	hobs="$hobs $i"
				elif [ -d $i ]
				then	hexs="$hexs $i"
				else	f=true
				fi
				;;
			*)	if [ -f $i ]
				then	obs="$obs $i"
				elif [ -d $i ]
				then	exs="$exs $i"
				else	f=true
				fi
				;;
			esac
		done
		if [ "$obs" ]
		then	echo 'This room contains:'
			echo $obs | tr ' ' '\012' | pr -5 -t -w75
		else	echo 'The room looks empty.'
		fi
		if [ "$exs" ]
		then	echo 'There are exits labeled:'
			echo $exs | tr ' ' '\012' | pr -5 -t -w75
			echo 'as well as a passage overhead.'
		else	echo 'There is a passage overhead.'
		fi
		if sh -c $f
		then	echo 'There are shadowy figures in the corner.'
		fi
		prev=$room
	fi

	echo '-\b> \c'			# prompt
	read verb obj x
	if [ $? != 0 ]
	then	verb=quit		# EOF
	fi

	case $verb in
	change)		if [ "$obj" ]
			then	echo " $obs $hobs " | fgrep " $obj " >&- 2>&-
				if [ $? = 0 ]
				then	set -- $x
					case "$1" in
					to)	if [ "$2" ]
						then	if [ -f $2 ]
							then	echo "You must destroy $2 first."
								set --
							fi
							if [ "$2" ]
							then	if mv $obj $2 >&- 2>&-
								then	echo "The $obj shimmers and turns into $2."
									obs=`echo $2 $obs '' | sed -e "s/ $obj / /" -e 's/ $//'`
								else	echo "There is a cloud of smoke but the $obj is unchanged."
								fi
							fi
						else	echo 'To what?'
						fi
						;;
					*)	echo "Change $obj to what?"
						;;
					esac
				else	echo " $kn " | fgrep " $obj " >&- 2>&-
					if [ $? = 0 ]
					then	echo 'You must drop it first.'
					else	echo "I see no $obj here."
					fi
				fi
			else	echo 'Change what?'
			fi
			;;
	clone)		if [ "$obj" ]
			then	echo " $obs $hobs " | fgrep " $obj " >&- 2>&-
				if [ $? = 0 ]
				then	if [ ! -r $obj ]
					then	echo "The $obj does not wish to be cloned."
					else	set -- $x
						case "$1" in
						as)	if [ "$2" ]
							then	if [ -f $2 ]
								then	echo "You must destroy $2 first."
								else	if cp $obj $2 >&- 2>&-
									then	echo "Poof!  When the smoke clears, you see the new $2."
										obs="$obs $2"
									else	echo 'You hear a dull thud but no clone appears.'
									fi
								fi
							else	echo 'As what?'
							fi
							;;
						*)	echo "Clone $obj as what?"
							;;
						esac
					fi
				else	echo " $kn " | fgrep " $obj " >&- 2>&-
					if [ $? = 0 ]
					then	echo 'You must drop it first.'
					else	echo "I see no $obj here."
					fi
				fi
			else	echo 'Clone what?'
			fi
			;;
	drop)		if [ "$obj" ]
			then	for it in $obj $x
				do	echo " $kn " | fgrep " $it " >&- 2>&-
					if [ $? = 0 ]
					then	if [ -w $it ]
						then	echo "You must destroy $it first."
						else	if mv $HOME/$KNAP/$it $it >&- 2>&-
							then	echo "$it: dropped."
								kn=`echo '' $kn '' | sed -e "s/ $it / /" -e 's/^ //' -e 's/ $//'`
								obs=`echo $it $obs`
							else	echo "The $it is caught in your knapsack."
							fi
						fi
					else	echo "You're not carrying the $it!"
					fi
				done
			else	echo 'Drop what?'
			fi
			;;
	enter|go)	if [ "$obj" ]
			then	if [ $obj != up ]
				then	echo " $exs $hexs " | fgrep " $obj " >&- 2>&-
					if [ $? = 0 ]
					then	if [ -x $obj ]
						then	if cd $obj
							then	echo 'You squeeze through the passage.'
							else	echo "You can't go that direction."
							fi
						else	echo 'An invisible force blocks your way.'
						fi
					else	echo 'I see no such passage.'
					fi
				else	if cd ..
					then	echo 'You struggle upwards.'
					else	echo "You can't reach that high."
					fi
				fi
			else	echo 'Which passage?'
			fi
			;;
	examine)	if [ "$obj" ]
			then	if [ $obj = all ]
				then	$obj=`echo $obs $exs`
					x=
				fi
				for it in $obj $x
				do	echo " $obs $hobs $exs $hexs " | fgrep " $it " >&- 2>&-
					if [ $? = 0 ]
					then	echo "Upon close inspection of the $it, you see:"
						ls -ld $it 2>&-
						if [ $? != 0 ]
						then	echo "-- when you look directly at the $it, it vanishes."
						fi
					else	echo " $kn " | fgrep " $it " >&- 2>&-
						if [ $? = 0 ]
						then	echo 'You must drop it first.'
						else	echo "I see no $it here."
						fi
					fi
				done
			else	echo 'Examine what?'
			fi
			;;
	feed)		if [ "$obj" ]
			then	echo " $obs $hobs " | fgrep " $obj " >&- 2>&-
				if [ $? = 0 ]
				then	set -- $x
					case "$1" in
					to)	if [ "$2" ]
						then	shift
							if env PATH=$OPATH $* <$obj 2>&-
							then	echo "The $1 monster devours your $obj."
								if rm -f $obj >&- 2>&-
								then	obs=`echo '' $obs '' | sed -e "s/ $obj / /" -e 's/^ //' -e 's/ $//'`
								else	echo 'But he spits it back up.'
								fi
							else	echo "The $1 monster holds his nose in disdain."
							fi
						else	echo 'To what?'
						fi
						;;
					*)	echo "Feed $obj to what?"
						;;
					esac
				else	echo " $kn " | fgrep " $obj " >&- 2>&-
					if [ $? = 0 ]
					then	echo 'You must drop it first.'
					else	echo "I see no $obj here."
					fi
				fi
			else	echo 'Feed what?'
			fi
			;;
	get|take)	if [ "$obj" ]
			then	if [ $obj = all ]
				then	obj="$obs"
					x=
				fi
				for it in $obj $x
				do	echo " $obs $hobs " | fgrep " $it " >&- 2>&-
					if [ $? = 0 ]
					then	echo " $kn " | fgrep " $it " >&- 2>&-
						if [ $? = 0 ]
						then	echo 'You already have one.'
						else	if mv $it $HOME/$KNAP/$it >&- 2>&-
							then	echo "$it: taken."
								kn="$it $kn"
								obs=`echo '' $obs '' | sed -e "s/ $it / /" -e 's/^ //' -e 's/ $//'`
							else	echo "The $it is too heavy."
							fi
						fi
					else	echo "I see no $it here."
					fi
				done
			else	echo 'Get what?'
			fi
			;;
	gripe|bug)	echo 'Please describe the problem and your situation at the time it failed.\nEnd the bug report with a line containing just a Ctrl-D.'
			cat | mail $MAINT -s 'ash bug'
			echo 'Thank you!'
			;;
	help)		$CAT < $HELP
			;;
	inventory|i)	if [ "$kn" ]
			then	echo 'Your knapsack contains:'
				echo $kn | tr ' ' '\012' | pr -5 -t -w75
			else	echo 'You are poverty-stricken.'
			fi
			;;
	kill|destroy)	if [ "$obj" ]
			then	if [ $obj = all ]
				then	x=
					if $ASK "Do you really want to attempt to $verb them all?"
					then	obj=`echo $obs`
					else	echo 'Chicken!'
						obj=
					fi
				fi
				for it in $obj $x
				do	echo " $obs $hobs " | fgrep " $it " >&- 2>&-
					if [ $? = 0 ]
					then	if mv $it $HOME/$LIM <&- >&- 2>&-
						then	if [ $verb = kill ]
							then	echo "The $it cannot defend himself; he dies."
							else	echo "You have destroyed the $it; it vanishes."
							fi
							obs=`echo '' $obs '' | sed -e "s/ $it / /" -e 's/^ //' -e 's/ $//'`
						else	if [ $verb = kill ]
							then	echo "Your feeble blows are no match for the $it."
							else	echo "The $it is indestructible."
							fi
						fi
					else	echo " $kn " | fgrep " $it " >&- 2>&-
						if [ $? = 0 ]
						then	echo "You must drop the $it first."
							found=false
						else	echo "I see no $it here."
						fi
					fi
				done
			else	echo 'Kill what?'
			fi
			;;
	look|l)		obs=`echo $obs $hobs`
			hobs=
			if [ "$obs" ]
			then	echo 'The room contains:'
				echo $obs | tr ' ' '\012' | pr -5 -t -w75
			else	echo 'The room is empty.'
			fi
			exs=`echo $exs $hexs`
			hexs=
			if [ "$exs" ]
			then	echo 'There are exits plainly labeled:'
				echo $exs | tr ' ' '\012' | pr -5 -t -w75
				echo 'and a passage directly overhead.'
			else	echo 'The only exit is directly overhead.'
			fi
			;;
	magic)		if [ "$obj" = mode ]
			then	if sh -c $cha
				then	echo 'You had your chance and you blew it.'
				else	if $ASK 'Are you a wizard?'
					then	echo 'Prove it!  Say the magic word: \c'
						read obj
						if [ "$obj" = armadillo ]
						then	echo 'Yes, master!!'
							wiz=true
						else	echo "Foo, you're nothing but a charlatan!"
							cha=true
						fi
					else	echo "I didn't think so."
					fi
				fi
			else	echo 'Nice try.'
			fi
			;;
	open|read)	if [ "$obj" ]
			then	echo " $obs $hobs " | fgrep " $obj " >&- 2>&-
				if [ $? = 0 ]
				then	if [ -r $obj ]
					then	if [ -s $obj ]
						then	echo "Opening the $obj reveals:"
							$CAT < $obj 2>&-
							if [ $? != 0 ]
							then	echo '-- oops, you lost the contents!'
							fi
						else	echo "There is nothing inside the $obj."
						fi
					else	echo "You do not have the proper tools to open the $obj."
					fi
				else	echo " $kn " | fgrep " $obj " >&- 2>&-
					if [ $? = 0 ]
					then	echo 'You must drop it first.'
						found=false
					else	echo "I see no $obj here."
					fi
				fi
			else	echo 'Open what?'
			fi
			;;
	quit|exit)	if $ASK 'Do you really want to quit now?'
			then	if [ "$kn" ]
				then	echo 'The contents of your knapsack will still be there next time.'
				fi
				rm -rf $HOME/$LIM
				echo 'See you later!'
				exit 0
			fi
			;;
	resurrect)	if [ "$obj" ]
			then	for it in $obj $x
				do	echo " $obs $hobs " | fgrep " $it " >&- 2>&-
					if [ $? = 0 ]
					then	echo "The $it is already alive and well."
					else	if mv $HOME/$LIM/$it $it <&- >&- 2>&-
						then	echo "The $it staggers to his feet."
							obs=`echo $it $obs`
						else	echo "There are sparks but no $it appears."
						fi
					fi
				done
			else	echo 'Resurrect what?'
			fi
			;;
	steal)		if [ "$obj" ]
			then	echo " $obs $hobs " | fgrep " $obj " >&- 2>&-
				if [ $? = 0 ]
				then	echo 'There is already one here.'
				else	set -- $x
					case "$1" in
					from)	if [ "$2" ]
						then	shift
							if env PATH=$OPATH $* >$obj 2>&-
							then	echo "The $1 monster drops the $obj."
								obs=`echo $obj $obs`
							else	echo "The $1 monster runs away as you approach."
								rm -f $obj >&- 2>&-
							fi
						else	echo 'From what?'
						fi
						;;
					*)	echo "Steal $obj from what?"
						;;
					esac
				fi
			else	echo 'Steal what?'
			fi
			;;
	throw)		if [ "$obj" ]
			then	echo " $obs $hobs " | fgrep " $obj " >&- 2>&-
				if [ $? = 0 ]
				then	set -- $x
					case "$1" in
					at)	case "$2" in
						daemon)	if sh -c "lpr -r $obj"
							then	echo "The daemon catches the $obj, turns it into paper,\nand leaves it in the basket."
								obs=`echo '' $obs '' | sed -e "s/ $obj / /" -e 's/^ //' -e 's/ $//'`
							else	echo "The daemon is nowhere to be found."
							fi
							;;
						*)	echo 'At what?'
							;;
						esac
						;;
					*)	echo "Throw $obj at what?"
						;;
					esac
				else	echo " $kn " | fgrep " $obj " >&- 2>&-
					if [ $? = 0 ]
					then	echo 'It is in your knapsack.'
						found=false
					else	echo "I see no $obj here."
					fi
				fi
			else	echo 'Throw what?'
			fi
			;;
	u|up)		if cd ..
			then	echo 'You pull yourself up a level.'
			else	echo "You can't reach that high."
			fi
			;;
	wake)		if [ "$obj" ]
			then	echo "You awaken the $obj monster:"
				env PATH=$OPATH $obj $x
				echo 'The monster slithers back into the darkness.'
			else	echo 'Wake what?'
			fi
			;;
	w|where)	echo "You are in $room."
			;;
	xyzzy)		if cd
			then	echo 'A strange feeling comes over you.'
			else	echo 'Your spell fizzles out.'
			fi
			;;
	*)		if [ "$verb" ]
			then	if sh -c $wiz
				then	env PATH=$OPATH $verb $obj $x
				else	echo "I don't know how to \"$verb\"."
					echo 'Type "help" for assistance.'
				fi
			else	echo 'Say something!'
			fi
			;;
	esac
done