Backspaces in Unix

178 views
Skip to first unread message

Saint Alfonzo

unread,
May 26, 2021, 7:00:44 AM5/26/21
to [PiDP-11]
Hello Community!

I am happy to join the conversation and say that I finally found time to build my PiDP-11 and am delighted with it. I am having such fun exploring all of the great software available for it and learning what it is capable of.

I hope you can help make my experience a bit easier. I noticed that I can’t get any of the Unices to support a regular, destructive backspace.
  • 211bsd allows backspace and then type over
  • unix5 and unix6 don’t recognize backspace at all
  • unix7, sysiii, and sysv seems to treat backspace as a line feed
The other OSes seem to recognize the backspace (either destructive or nondestructive). I also have no problem with backspace on my PiDP-8.

I typically ssh into my PiDP-11 from my Mac or Ubuntu machine, but have tried the following terminals. In all cases I can’t get backspace to work.
  • Mac Terminal
  • iTerm2 on Mac
  • Ubuntu terminal
  • PuTTY from Windows 
  • xterm from the Pi and Ubuntu
  • Termius from iPad
I have read that a common problem is that Unix needs to receive the backspace as ^? instead of ^H. So I tried configuring that in the terminals where possible, but it didn’t help.

Although it is of course still possible to work without it (just like they did back in the Teletype days), it makes exploring and experimenting very tedious.

Am I missing something to try? I am grateful for any suggestions.

Thanks!


PS -  My normal keyboard layout and locale is Swiss German. Not sure if that can affect this in any way. I tried setting to US Querty and didn’t notice any change.

a...@papnet.eu

unread,
May 26, 2021, 7:44:46 AM5/26/21
to [PiDP-11]
>    - 211bsd allows backspace and then type over
>    - unix5 and unix6 don’t recognize backspace at all
>    - unix7, sysiii, and sysv seems to treat backspace as a line feed

This means you're actually sending DEL/^? instead of BS/^H.
Traditionally DEL is the interrupt character but it was changed to ^C at
some point (though plan 9 still uses DEL).
So if you ever want to interrupt a program, press DEL, not ^C.

To find out what your terminal is sending, type ^V and then the literal
key. I set up my terminal emulator (xterm) to produce ^H on backspace
and ^? on delete for exactly this purpose (it just makes the most sense
it seems).


> I have read that a common problem is that Unix needs to receive the
> backspace as ^? instead of ^H. So I tried configuring that in the terminals
> where possible, but it didn’t help.

Assuming you actually have configured your terminal correctly,
that is probably because the default erase character is # and the
default kill character is @. Remember this comes from the time of
hardcopy terminals.
To set them to modern defaults use
        `stty erase <press backspace> kill <press ^U>`
To see what they've been set to, just use `stty` without arguments.

cheers,
aap

Johnny Billquist

unread,
May 26, 2021, 11:30:36 AM5/26/21
to pid...@googlegroups.com
This is a somewhat semi-recurring topic.

So let's get a few things clarified:

For output *to* a terminal, using ASCII, there are a bunch of control
characters that do different things.
BS (backspace, 0x08) will normally move the cursor one step to the left,
if not at the left edge. It does not affect the character under the cursor.
DEL (delete, 0x7f) normally do nothing.

When typing on a terminal, there is commonly a key marked with <- or <x]
or something similar above or near the enter/return key. This key on
every DEC terminal sends a DEL to the host computer. Many other
terminals also sends DEL, some sends BS, and some terminals even have it
configurable.
Most notably, the IBM PC usually sends a BS when hitting that key.


Now, next question is what happens at the host OS when receiving
different ASCII characters.
Pretty much all DEC operating systems ignore BS, or at most echo it.
Which means that if you send a BS, your cursor might actually move left,
but from the OS point of view, you have not deleted any of your input,
but have in fact added a BS to the line.
Most DEC operating systems use DEL to signify that you want to delete
the character most recently entered. Or delete to the left, if that
makes more sense.

Unix, traditionally, used # for this function (as mentioned below). But
since Unix was often run on DEC machines, there were often DEC, or DEC
compatible terminals involved as well, which commonly sent DEL. So Unix
sortof adopted DEL for deleting to the left as well, and usually
ignored, or just echoed BS just as DEC OSes did.

When the IBM PC became popular, a sudden shift towards using BS for
deleting to the left happened, which is where we are today.


Finally, within some Unix shells, there is some attempts at being nice
and accepting both BS and DEL in order to delete to the left, but that
does depend on which shell we are talking about.

With Unix, it is otherwise the case that you can actually define which
character you want to use to delete to the left. See stty(1).

Johnny
> * 211bsd allows backspace and then type over
> * unix5 and unix6 don’t recognize backspace at all
> * unix7, sysiii, and sysv seems to treat backspace as a line feed
>
> The other OSes seem to recognize the backspace (either destructive
> or nondestructive). I also have no problem with backspace on my PiDP-8.
>
> I typically ssh into my PiDP-11 from my Mac or Ubuntu machine, but
> have tried the following terminals. In all cases I can’t get
> backspace to work.
>
> * Mac Terminal
> * iTerm2 on Mac
> * Ubuntu terminal
> * PuTTY from Windows
> * xterm from the Pi and Ubuntu
> * Termius from iPad
>
> I have read that a common problem is that Unix needs to receive the
> backspace as ^? instead of ^H. So I tried configuring that in the
> terminals where possible, but it didn’t help.
>
> Although it is of course still possible to work without it (just
> like they did back in the Teletype days), it makes exploring and
> experimenting very tedious.
>
> Am I missing something to try? I am grateful for any suggestions.
>
> Thanks!
>
>
> PS -  My normal keyboard layout and locale is Swiss German. Not sure
> if that can affect this in any way. I tried setting to US Querty and
> didn’t notice any change.
>
> --
> You received this message because you are subscribed to the Google
> Groups "[PiDP-11]" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to pidp-11+u...@googlegroups.com
> <mailto:pidp-11+u...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pidp-11/ab40a1fe-a76d-42f8-9709-5e09d160cb4bn%40googlegroups.com
> <https://groups.google.com/d/msgid/pidp-11/ab40a1fe-a76d-42f8-9709-5e09d160cb4bn%40googlegroups.com?utm_medium=email&utm_source=footer>.

--
Johnny Billquist || "I'm on a bus
|| on a psychedelic trip
email: b...@softjar.se || Reading murder books
pdp is alive! || tryin' to stay hip" - B. Idol

Mike Katz

unread,
May 26, 2021, 2:21:21 PM5/26/21
to Johnny Billquist, pid...@googlegroups.com
I remember in the old hard copy terminal (teletype, decwriter, etc) days
you could setup your termcap to output a bs (move carriage one space to
the left) and then print an over-strike character (usually a # or X).
This got even more complicated if DEL was pressed more than once in a row.

For CRT terminals it was different.  Depending on the intelligence of
the terminal BS/DEL would be handled differently.

Very dumb terminals did not have a cursor left but only had carriage
return (return the cursor to the beginning of the line).  Deleting
anything would require the OS/Editor to send a carriage return followed
by sending the entire line minus the deleted character.

Some smarter terminal had a cursor left function (usually ASCII 0x08) so
they handled deleting the character at the end of the line by sending a
cursor left, a space and a cursor left again.
To delete a character in the middle of the line would require a cursor
left and then sending the remaining characters on that line.

The above 2 methods were very noticeable at low baud rates.

Even smarter terminals would have a true backspace and would move the
cursor 1 column to the left and delete the character under the cursor
and automatically shift the remainder of the line one column to the left
(if the cursor was not at the end of the text) in a single command sent
from the host (the command might be 1 or more characters).

Thanks for walk through memory lane and bringing back memories of
writing terminal drivers and termcap and ttytype.

Johnny Billquist

unread,
May 26, 2021, 6:25:49 PM5/26/21
to Mike Katz, pid...@googlegroups.com
On 2021-05-26 20:21, Mike Katz wrote:
> I remember in the old hard copy terminal (teletype, decwriter, etc) days
> you could setup your termcap to output a bs (move carriage one space to
> the left) and then print an over-strike character (usually a # or X).
> This got even more complicated if DEL was pressed more than once in a row.

Never seen that, but I guess almost anything is possible. The most
common behavior seemed to have been to output the deleted characters
when deleting them. Sometimes with a separator before and after
deleting. So you'd see something like:

> FOO\OOF\

if you typed "FOO" and then DEL three times. Then you have ^R that would
reprint the current line you were typing, so you could check that it now
matched what you actually wanted.

> For CRT terminals it was different.  Depending on the intelligence of
> the terminal BS/DEL would be handled differently.
>
> Very dumb terminals did not have a cursor left but only had carriage
> return (return the cursor to the beginning of the line).  Deleting
> anything would require the OS/Editor to send a carriage return followed
> by sending the entire line minus the deleted character.

I don't think I've ever seen a terminal dumb enough to not even have
backspace, but I guess it is possible. That, however, does not mean that
there weren't programs, or terminal definitions, that was a bit lacking,
causing such output anyway.

> Some smarter terminal had a cursor left function (usually ASCII 0x08) so
> they handled deleting the character at the end of the line by sending a
> cursor left, a space and a cursor left again.
> To delete a character in the middle of the line would require a cursor
> left and then sending the remaining characters on that line.

Right. Although very few situations back then allowed that you would be
deleting at the middle of a line. That was usually the domain of
editors. Eventually command line editing also became common, at which
point this became more relevant.

> The above 2 methods were very noticeable at low baud rates.

Definitely. :-)

> Even smarter terminals would have a true backspace and would move the
> cursor 1 column to the left and delete the character under the cursor
> and automatically shift the remainder of the line one column to the left
> (if the cursor was not at the end of the text) in a single command sent
> from the host (the command might be 1 or more characters).

Never heard of "true" backspace. Any and every terminal I know of today
still just moves the cursor non-destructive left at a BS.

However, smarter terminals also have escape sequence functions to delete
characters, which will do more or less what you describe. But it's not
done with the help of BS.
VT102 (or pretty much any ANSI-compatible terminal will have this for
example).

> Thanks for walk through memory lane and bringing back memories of
> writing terminal drivers and termcap and ttytype.

You're welcome. And for the record, I'm still using dumb terminals. :-)
Have a VT525 at my desk.

Johnny

Saint Alfonzo

unread,
May 28, 2021, 3:39:13 AM5/28/21
to [PiDP-11]
Thank you very much aap for the fast reply and the following tip:

> the default erase character is # and the
> default kill character is @

This is exactly the information that I needed. Reviewing the stty settings in the various OSes allowed me to reassign those values just as you suggested.

And thanks to everyone else for the additional background details.

Alphonzo
Reply all
Reply to author
Forward
0 new messages