stty -g output mapping to stty -a output

stty -g output mapping to stty -a output

Post by David Van Dy » Fri, 07 Jun 1991 01:52:40



Hi Netlanders,

I've got an easy one for you experienced folk.  I'm running on a UNISYS 5000/90
(Motorola 68020 based) with system V r3.2 UNIX.  My question is regarding
trying to understand the stty -g output.  Can anyone give me a clue as to
how I can map a string like "526:1805:4bd:3b:7f:1c:8:18:4:0:0:0:0:0" to
the appropriate flags (i.e. -parenb, -brkint, etc.) listed in TFM,
or is that not how the stty -g works?

E-mail to me, or postings to the net if you think its of general interest,
would be welcome.

Thanks in advance

 ==============================================================================
 || David P. Van*, Computer Programmer Analyst      || internet:         ||

 ||                                                     || uucp:             ||
 || The opinions expressed here are exclusively my      ||  uunet!spao!dpv   ||
 || own.  The A. O. does not accept any responsibility  || phone:            ||
 || for the contents herein.                            ||  (202) 786-6760   ||
 ==============================================================================

 
 
 

stty -g output mapping to stty -a output

Post by David J. MacKenz » Sat, 08 Jun 1991 09:22:41


Quote:> how I can map a string like "526:1805:4bd:3b:7f:1c:8:18:4:0:0:0:0:0" to
> the appropriate flags (i.e. -parenb, -brkint, etc.) listed in TFM,
> or is that not how the stty -g works?

stty -g is just a hex dump of the current values of the tty's `struct
termio[s]' members, in order, omitting c_line.  Separated by colons,
of course.

--


 
 
 

stty -g output mapping to stty -a output

Post by Chris Tor » Sat, 08 Jun 1991 15:23:14



Quote:(David J. MacKenzie) writes:
>stty -g is just a hex dump of the current values of the tty's `struct
>termio[s]' members, in order, omitting c_line.  Separated by colons,
>of course.

Oh?

% stty -g
-gfmt:iflag=2b22:oflag=7:cflag=5a00:lflag=5cb:cc=4,377,377,10,27,30,22,377,3,34,32,31,21,23,26,17,1,0,24,377:ispeed=9600:ospeed=9600:
%

The output from `stty -g' is entirely private to the implementation,
and may change from moment to moment.  The only constraint on it is that
a later stty with that output should restore the terminal modes (i.e.,
it has to contain enough information, in some arbitrary format, to do
this).

This is at least the second `stty -g' format that has been used on this
machine.  (A third produces `Bus error (core dumped)' at the moment,
but never mind that :-) .)
--
In-Real-Life: Chris Torek, Lawrence Berkeley Lab CSE/EE (+1 415 486 5427)

 
 
 

stty -g output mapping to stty -a output

Post by Alan P Barre » Wed, 12 Jun 1991 23:51:10




> The output from `stty -g' is entirely private to the implementation,
> and may change from moment to moment.  The only constraint on it is that
> a later stty with that output should restore the terminal modes (i.e.,
> it has to contain enough information, in some arbitrary format, to do
> this).

Ah, but how much later?  Is the output of one stty -g allowed to be kept
somewhere and fed to another stty later, after the implementation has
changed?  How often is the implementation allowed to change?  I can do a
{mv my-new-and-improved-stty /bin/stty} any time, and thereby change the
implementation of stty instantaneously.  Now what happens to the
remembered output of the old stty -g?  Is it still expected to work?  If
so then surely there _should_ be a standard format (or at least a
standard lowest common denominator).

If the format is not expected to work from one implementation to
another, then how can an application rely on being able to do
{flags=`stty -g`; blah blah blah; stty $flags}?  It seems that we cannot
rely even on {stty `stty -g`} because the implementation of stty could
change during the execution of the command.

--apb
Alan Barrett, Dept. of Electronic Eng., Univ. of Natal, Durban, South Africa

 
 
 

stty -g output mapping to stty -a output

Post by Guy Harr » Tue, 18 Jun 1991 09:35:14


Quote:>Ah, but how much later?  Is the output of one stty -g allowed to be kept
>somewhere and fed to another stty later, after the implementation has
>changed?

Probably not.  I wouldn't be surprised, for example, if the "stty -g"
output from System V prior to S5R4 wasn't acceptable to S5R4, as S5R4
has more tty driver state to save and restore, although the S5R4 "stty"
might be able to recognize when it's been handed old-style state
information and do something reasonable.

Quote:>How often is the implementation allowed to change?

I've never seen a manual page that specified that.

Quote:>I can do a {mv my-new-and-improved-stty /bin/stty} any time,
>and thereby change the implementation of stty instantaneously.

You could also do "rm /bin/*", given that you have permission to write
in "/bin" (or whatever "/bin" is a link to, if it is such), and change a
hell of a lot more than just the implementation of "stty"; the system
shouldn't necessarily be prepared for *everything* a
sufficiently-privileged user can do.

Quote:>Now what happens to the remembered output of the old stty -g?  Is it
>still expected to work?

I wouldn't assume it'd work; you, or whoever created the "new and
improved" "stty", would be best advised to try to make the "new and
improved" program deal with the old "stty -g" output format, but there's
not much that could enforce that.

Quote:>If the format is not expected to work from one implementation to
>another, then how can an application rely on being able to do
>{flags=`stty -g`; blah blah blah; stty $flags}?  It seems that we cannot
>rely even on {stty `stty -g`} because the implementation of stty could
>change during the execution of the command.

Yes, and some natural disaster could strike the computer center, too,
and level it to the ground.

You can't *rely* on somebody not screwing up and dropping in an
incompatible "stty" command while the system is still running, but you
can get a * mob together after it's been done and track the person
down; hopefully, that will act as a sufficient incentive to prevent
people from installing incompatible versions of "stty" - which is
probably quite unlikely to happen on 99 44/100% of all sites, at least
not without a new version of the OS being installed, which generally
requires the system to be shut down, and most applications that use
"stty -g" probably don't save the settings to a file and restore them
later.  Those that do may be screwed, but that's life.