#!/bin/sh
# This is a shell script. Feed it to sh.
echo '
Hi, and welcome to the pty test script.

As in installation, I'\''m not actually going to do anything.
I'\''ll just guide you through a few (non-comprehensive) tests.

Remember: Like all software, pty comes without warranty, to the extent
permitted by applicable law. Use it at your own risk.
'

echo '----- Press return to continue. ' | tr -d '\012'; read contline

echo '
First, just try % pty vi. You shouldn'\''t be able to tell the
difference between this and a normal vi; stopping and restarting should
work perfectly, as should normal typing.
'

echo '----- Press return to continue. ' | tr -d '\012'; read contline

echo '
Next, try % pty -0 tr \! \? | pty vi. This should work just like the
last vi, with the following differences: 1. Stopping will require two
^Zs, because csh idiotically doesn'\''t think a pipeline has stopped
when just its second component stops. 2. Exiting will require an extra
line to feed through tr, so that it gets a broken pipe; this is more
sensible than #1. 3. All exclamation points will be turned into question
marks. This has obvious applications. :w /dev/null helps to escape.
'

echo '----- Press return to continue. ' | tr -d '\012'; read contline

echo '
Continuing along the lines of how to stick annoying programs into a
pipe, try % pty -0 sed '\''s/foo/bar/g'\'' | more. (Remember that sed outputs
each line only after it receives the next.) Try the same thing without
pty.

Note that pty -0 can be abbreviated as condom.
'

echo '----- Press return to continue. ' | tr -d '\012'; read contline

echo '
Next, try using the replacement script program. % script. Type various
commands; try logging on to another terminal and using talk; observe
that you'\''re listed in /etc/utmp. Try the clones of tty, mesg, biff,
u, wall, who, lock. (Try them under a non-pty session too.)
'

echo '----- Press return to continue. ' | tr -d '\012'; read contline

echo '
Much of the fun of pty is in disconnecting and reconnecting sessions.
If you'\''re ambitious, try % sess sh. ^Z will get you out and back in.
Try sessname without an argument; try it with an argument. Try sesslist.
Finally, try $ disconnect, and go on to the next part of this script.
'

echo '----- Press return to continue. ' | tr -d '\012'; read contline

echo '
Although it looks like your sh session has finished, it'\''s actually
sitting in limbo, waiting for you to reconnect. You can still see it
under who, sesslist, or ps. Now try % sess reconnect q7  or whatever the
extension of the disconnected session is; you should be right back in.

You can try the same thing by actually hanging up your connection, then
logging in again and reconnecting.
'

echo '----- Press return to continue. ' | tr -d '\012'; read contline

echo '
For one final trick,
% sess sh
$ PS1=FOO.; disconnect
% sess sh
$ sesslist
...
$ PS1=BAR.; reconnect q7; disconnect
FOO.reconnect p4; disconnect
BAR.reconnect q7; disconnect
FOO.echo Neat, flipping right back and forth!
'

echo '----- Press return to continue. ' | tr -d '\012'; read contline

echo '
That'\''s it! Make sure the manual pages and programs are easily
accessible. To repeat a note from INSTALL:

If you make it through installation and testing and get pty running,
please send a note to the author, Dan Bernstein, on the Internet
at brnstnd@nyu.edu. Let him know your computer model, OS version, and
what changes you had to make. If you have any trouble, please also get
in touch with the author. If you have a different kind of system with
pseudo-terminal support that could use a pty port, the author would
love to hear about it.

Thanks!
'
