stty -g output mapping to stty -a output

Guy Harris guy at auspex.auspex.com
Mon Jun 17 10:35:14 AEST 1991


>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.

>How often is the implementation allowed to change?

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

>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.

>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.

>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 lynch 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.



More information about the Comp.unix.questions mailing list