home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam    

UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 41.4 How UNIX Handles TAB Characters Chapter 41
Terminal and Serial Line Settings
Next: 41.6 Using sleep to Keep Port Settings
 

41.5 Why Some Systems Backspace over Prompts

[One curiosity that some people notice is that on BSD systems, you can't backspace over shell prompts, but on System V, you can go right back to the edge of your screen or window, erasing the prompt. Brandon Allberry explains that here. -TOR ]

You can make the BSD system behave like the System V one with stty old . But I don't think that's what you want....

The System V terminal driver ( 42.1 ) makes no assumptions about the sanity or configuration of the terminal, and therefore doesn't try to get fancy with echoing. It can be annoying at times to see the system acting so stupidly, but it won't suddenly act up on you.

The BSD tty driver makes the assumption that the terminal is behaving sanely, and that nothing is playing games with escape sequences, etc., so it can get away with assuming how to stop at the prompt. To this end, it echoes control characters in "uparrow format" [like ^A for CTRL-a- JP  ] and assumes you have the stty tabs setting correct for the terminal ( stty tabs only if the terminal has 8-character hardware tabs set, otherwise stty -tabs ). But it also requires various other trickery (such as stty tilde to compensate for old Hazeltine terminals that use ~ instead of the ASCII ESC character) to stay in sync with strange terminals.

The BSD method mostly works, but has some drawbacks: for example, on a DEC-compatible terminal I sometimes have to echo a control character ( 41.9 ) to get the terminal to display ASCII instead of graphics characters. Under System V, this is convenient: it can be done by typing the control character at the shell command line, then backspace, then RETURN to redisplay the prompt as something other than Greek. Under BSD I have to resort to cat ( 25.2 ) . Also, while BSD will echo "typed" control characters in uparrow format, it won't help you if a backgrounded program splatters control characters at the terminal. (Well, you can stty tostop ( 12.7 ) , but sometimes you "want" that behavior from some particular backgrounded program: a status message, for example.)

Programs like ksh and tcsh also do "smart" echoing. They have the same problems, plus an additional one: the BSD tty driver can tell when another program scribbles on the terminal while doing a line-buffered read and automatically redisplays the input line after the next keystroke. A user program has no way to find out about such scribbling, however, so you can get into a decidedly non-WYSIWYG situation despite every attempt by the program to make things look right. At least System V is honest in not promising anything.

Such are the problems with non-regulated access by a multi-tasking system to a non-multiplexed device like a terminal, and such are the possible solutions. You choose the one that works best in your particular situation.

- BA in comp.unix.misc on Usenet, 12 October 1991


Previous: 41.4 How UNIX Handles TAB Characters UNIX Power Tools Next: 41.6 Using sleep to Keep Port Settings
41.4 How UNIX Handles TAB Characters Book Index 41.6 Using sleep to Keep Port Settings

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System










??????????????@Mail.ru