Subject: RE: stty settings
From: [email-masked] (Bob McGowan)

7 Apr 1998 15:04:05 -0700
Message-ID: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain;
	charset="iso-8859-1"
To: [email-masked]
Cc: [email-masked]

Erwin,

I expect that the issue here is the differing worlds of UNIX and
Windows.  Short of rewritting the Windows console driver or modifying
each program to recognize these characters litterally, I don't think
this can be changed (though it might be done in the dll?).  This
explains the ^Z issue as well since it is used in the DOS/Win text mode
as a litteral end-of-file marker.  The stty command modifies the tty
driver parameters on a UNIX system and for many of the driver functions,
there are no equivalents in Widnows.

The following (longish) discussion and illustration gives some detail on
how things work in a UNIX environment.

On a UNIX system, the end of file is NOT a litteral character.  It is
defined as a read() of 0 bytes.  I would refer you to the UNIX man pages
for read() and to K&R's chapter on low level I/O.  So just what is ^D??
It is a character, used for tty input only, interpreted by the TTY
DRIVER, as an instruction to flush its input buffer (sometimes refered
to as a c-list, as I remember, for a list of characters).  You can
verify this on a UNIX box by logging in and running the cat command with
no arguments (it will read stdin and write stdout).  Type some
characters followed by a carriage return.  The tty driver does two
things with the carriage return.  First, it is replaced by a new line
character which is put in the buffer.  Then the driver "flushes" the
buffer, ie the data is passed to the cat program.  And cat sends the
input back to its output.  The driver now takes the new line character
and ADDS a carriage return character, so the cursor is positioned under
the output line, in column one.  Things should look like this:

$ cat
asdfasdfsadf
asdfasdfsadf
			<<< cursor is here in column 1
^

Now, type a string of characters and THEN a ^D (NO carriage return).
You will see what you just typed appear on the screen again, as output
from cat.  The difference is that the input and output lines are on the
same screen line AND the cursor is at the end of this line, NOT the
beginning of the next.  Note also that there is no shell prompt on the
screen.  Another ^D at this point will terminate the cat command and
return you to the shell prompt, with the prompt still on the same line.
This input would add the following to the above:

abcd321abcd321$
       ^        ^

where the first carat marks the repeated string (the cat output) and the
second shows where the cursor is now sitting, with the shell prompt (the
dollar sign and space) preceding it.

The apparent action of the ^D is different in the two cases.  But this
is only an apparent difference.  In both cases, the ^D was taken by the
driver as a "flush the buffer" instruction.  In the first case there was
something in the buffer and the cat command had a read() with >0 bytes.
In the second, the buffer was empty and the read() == 0 bytes, ie end of
file.  Also, the ^D was NOT passed up to the program, it was used
(consummed) by the driver.

I appologize for the length of the preceding, but I think it is
necessary background to understand where things are being done on the
UNIX side and why the stty command has so many undefined items.

----
Bob McGowan
i'm bobmcgow at xstor dot com
Storage Dimensions, Inc.

-----Original Message-----
From: Erwin Achermann [mailto:[email-masked]]
Sent: Saturday, April 04, 1998 4:26 AM
To: [email-masked]
Subject: stty settings

Howdy all, 

my stty settings are 

>stty -a
speed 38400 baud; rows 37; columns 80; line = 0;
intr = <undef>; quit = <undef>; erase = <undef>; kill = <undef>; eof =
<undef>;
eol = <undef>; eol2 = <undef>; start = <undef>; stop = <undef>; susp =
<undef>;
rprnt = <undef>; werase = <undef>; lnext = <undef>; flush = <undef>;
min = 0; time = 0;
-parenb -parodd cs8 -hupcl -cstopb -cread -clocal -crtscts
ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl -ixon
-ixoff
-iuclc -ixany -imaxbel
-opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0
vt0
ff0
isig icanon -iexten echo -echoe -echok -echonl -noflsh -tostop -echoctl
-echoke

"Oh well THAT's why ^d is not understood by my program", i thought. 
But when i try to set it explicitly: 
>stty eof ^d
stty: standard input: unable to perform all requested operations
/pccts/tutorial/rewrite 59>stty --version
stty (GNU sh-utils) 1.16

Can someone please explain what i am missing, is this also the reason
for Ctrl-Z not working as it used to in good ol' Unix??
How can i set those settings? Why is stty refusing to accept my
settings?

Cheers 
Erwin
-- 
Erwin Achermann                               Tel:      ++41 1 632 74 40
Institut fuer Wissenschaftliches Rechnen      Fax:      ++41 1 632 11 72
ETH Zentrum, IFW C29.2         mailto:[email-masked]  ICQ:4625051
CH-8092 Zuerich	               http://www.inf.ethz.ch/personal/acherman/
>  Perfection is reached, not when there is no longer anything to add, <
>  but when there is no longer anything to take away.                  <
>                                          -- Antoine de Saint-Exupery <
-
For help on using this list (especially unsubscribing), send a message
to
"[email-masked]" with one line of text: "help".
-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".