⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch41_05.htm

📁 the unix power tools
💻 HTM
字号:
<HTML><!--Distributed by F --><HEAD><TITLE>[Chapter 41] 41.5 Why Some Systems Backspace over Prompts </TITLE><METANAME="DC.title"CONTENT="UNIX Power Tools"><METANAME="DC.creator"CONTENT="Jerry Peek, Tim O'Reilly &amp; Mike Loukides"><METANAME="DC.publisher"CONTENT="O'Reilly &amp; Associates, Inc."><METANAME="DC.date"CONTENT="1998-08-04T21:51:58Z"><METANAME="DC.type"CONTENT="Text.Monograph"><METANAME="DC.format"CONTENT="text/html"SCHEME="MIME"><METANAME="DC.source"CONTENT="1-56592-260-3"SCHEME="ISBN"><METANAME="DC.language"CONTENT="en-US"><METANAME="generator"CONTENT="Jade 1.1/O'Reilly DocBook 3.0 to HTML 4.0"><LINKREV="made"HREF="mailto:online-books@oreilly.com"TITLE="Online Books Comments"><LINKREL="up"HREF="ch41_01.htm"TITLE="41. Terminal and Serial Line Settings"><LINKREL="prev"HREF="ch41_04.htm"TITLE="41.4 How UNIX Handles TAB Characters "><LINKREL="next"HREF="ch41_06.htm"TITLE="41.6 Using sleep to Keep Port Settings "></HEAD><BODYBGCOLOR="#FFFFFF"TEXT="#000000"><DIVCLASS="htmlnav"><H1><IMGSRC="gifs/smbanner.gif"ALT="UNIX Power Tools"USEMAP="#srchmap"BORDER="0"></H1><MAPNAME="srchmap"><AREASHAPE="RECT"COORDS="0,0,466,58"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="467,0,514,18"HREF="jobjects/fsearch.htm"ALT="Search this book"></MAP><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch41_04.htm"TITLE="41.4 How UNIX Handles TAB Characters "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 41.4 How UNIX Handles TAB Characters "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><B><FONTFACE="ARIEL,HELVETICA,HELV,SANSERIF"SIZE="-1">Chapter 41<BR>Terminal and Serial Line Settings</FONT></B></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch41_06.htm"TITLE="41.6 Using sleep to Keep Port Settings "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 41.6 Using sleep to Keep Port Settings "BORDER="0"></A></TD></TR></TABLE>&nbsp;<HRALIGN="LEFT"WIDTH="515"TITLE="footer"></DIV><DIVCLASS="SECT1"><H2CLASS="sect1"><ACLASS="title"NAME="UPT-ART-6530">41.5 Why Some Systems Backspace over Prompts </A></H2><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-45785"></A><ACLASS="indexterm"NAME="AUTOID-45788"></A><ACLASS="indexterm"NAME="AUTOID-45791"></A>[One curiosity that some people notice is that on BSD systems, youcan't backspace over shell prompts, but on System V, you can goright back to the edge of your screen or window, erasing the prompt.Brandon Allberry explains that here. -TOR&nbsp;]</P><PCLASS="para">You can make the BSD system behave like the System V one with <EMCLASS="emphasis">stty old</EM>.ButI don't think that's what you want....</P><PCLASS="para">The System V<SPANCLASS="link">terminal driver (<ACLASS="linkend"HREF="ch42_01.htm#UPT-ART-1142"TITLE="Making Sense Out of the Terminal Mess ">42.1</A>)</SPAN>makes no assumptions about the sanity orconfiguration of the terminal, and therefore doesn't try to get fancy withechoing.It can be annoying at times to see the system acting so stupidly,but it won't suddenly act up on you.</P><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-45798"></A><ACLASS="indexterm"NAME="AUTOID-45801"></A>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 getaway with assuming how to stop at the prompt.To this end, it echoes controlcharacters in&quot;uparrow format&quot; [like <CODECLASS="literal">^A</CODE> for CTRL-a-<EMCLASS="emphasis">JP</EM>&nbsp;]and assumes you have the <EMCLASS="emphasis">stty tabs</EM> settingcorrect for the terminal (<CODECLASS="literal">stty tabs</CODE> only if the terminal has 8-characterhardware tabs set, otherwise <CODECLASS="literal">stty -tabs</CODE>).But it also requires variousother trickery (such as <CODECLASS="literal">stty tilde</CODE> to compensate for old Hazeltine terminals that use <CODECLASS="literal">~</CODE> instead of the ASCII ESC character) to stay in sync with strange terminals.</P><PCLASS="para">The BSD method mostly works, but has some drawbacks: for example, on aDEC-compatible terminal I sometimes have to<SPANCLASS="link">echo a control character (<ACLASS="linkend"HREF="ch41_09.htm"TITLE="Commands to Adjust Your Terminal ">41.9</A>)</SPAN>to getthe terminal to display ASCII instead of graphics characters.Under System V,this is convenient: it can be done by typing the control character at theshell command line, then backspace, then RETURN to redisplay the prompt assomething other than Greek.Under BSD I have to resort to<SPANCLASS="link"><EMCLASS="emphasis">cat</EM> (<ACLASS="linkend"HREF="ch25_02.htm"TITLE="Four Ways to Skin a cat ">25.2</A>)</SPAN>.Also,while BSD will echo &quot;typed&quot; control characters in uparrow format, it won'thelp you if a backgrounded program splatters control characters at theterminal.(Well, you can<SPANCLASS="link"><EMCLASS="emphasis">stty tostop</EM> (<ACLASS="linkend"HREF="ch12_07.htm"TITLE="Stop Background Output with stty tostop ">12.7</A>)</SPAN>,but sometimes you &quot;want&quot; thatbehavior from some particular backgrounded program: a status message, forexample.)</P><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-45817"></A><ACLASS="indexterm"NAME="AUTOID-45819"></A>Programs like <EMCLASS="emphasis">ksh</EM> and <EMCLASS="emphasis">tcsh</EM> also do &quot;smart&quot; echoing.They have the sameproblems, plus an additional one: the BSD tty driver can tell when anotherprogram scribbles on the terminal while doing a line-buffered read andautomatically redisplays the input line after the next keystroke.A userprogram has no way to find out about such scribbling, however, so you can getinto a decidedly non-WYSIWYG situation despite every attempt by the program tomake things look right.At least System V is honest in not promisinganything.</P><PCLASS="para">Such are the problems with non-regulated access by a multi-tasking system to anon-multiplexed device like a terminal, and such are the possible solutions.You choose the one that works best in your particular situation.</P><DIVCLASS="sect1info"><PCLASS="SECT1INFO">- <SPANCLASS="authorinitials">BA</SPAN> <SPANCLASS="bibliomisc">in <ACLASS="systemitem.newsgroup"HREF="news:comp.unix.misc">comp.unix.misc</A> on Usenet, 12 October 1991</SPAN></P></DIV></DIV><DIVCLASS="htmlnav"><P></P><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch41_04.htm"TITLE="41.4 How UNIX Handles TAB Characters "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 41.4 How UNIX Handles TAB Characters "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="book"HREF="index.htm"TITLE="UNIX Power Tools"><IMGSRC="gifs/txthome.gif"SRC="gifs/txthome.gif"ALT="UNIX Power Tools"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch41_06.htm"TITLE="41.6 Using sleep to Keep Port Settings "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 41.6 Using sleep to Keep Port Settings "BORDER="0"></A></TD></TR><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172">41.4 How UNIX Handles TAB Characters </TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="index"HREF="index/idx_0.htm"TITLE="Book Index"><IMGSRC="gifs/index.gif"SRC="gifs/index.gif"ALT="Book Index"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172">41.6 Using sleep to Keep Port Settings </TD></TR></TABLE><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><IMGSRC="gifs/smnavbar.gif"SRC="gifs/smnavbar.gif"USEMAP="#map"BORDER="0"ALT="The UNIX CD Bookshelf Navigation"><MAPNAME="map"><AREASHAPE="RECT"COORDS="0,0,73,21"HREF="../index.htm"ALT="The UNIX CD Bookshelf"><AREASHAPE="RECT"COORDS="74,0,163,21"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="164,0,257,21"HREF="../unixnut/index.htm"ALT="UNIX in a Nutshell"><AREASHAPE="RECT"COORDS="258,0,321,21"HREF="../vi/index.htm"ALT="Learning the vi Editor"><AREASHAPE="RECT"COORDS="322,0,378,21"HREF="../sedawk/index.htm"ALT="sed &amp; awk"><AREASHAPE="RECT"COORDS="379,0,438,21"HREF="../ksh/index.htm"ALT="Learning the Korn Shell"><AREASHAPE="RECT"COORDS="439,0,514,21"HREF="../lrnunix/index.htm"ALT="Learning the UNIX Operating System"></MAP></DIV></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -