Teaching an Almost 40-year Old Unix about Backspace
virtuallyfun.com
virtuallyfun.com
So much knowledge has been forgotten.
This is exactly what DEL did in it's original incarnation. on early VT terminals it was effectively a macro that triggered BS+SPACE+BS.
Depending on the VT configuration you specified, hitting the Delete key (the one up there above your Enter key) would either send a basic BS(8), or DEL(127). This behaviour also existed in many early terminal apps for BBS type dial-up.
I would have said "to the right of", but then i am one of those dinosaurs that still use a desktop computer with a full width keyboard.
Amiga 500 use the left pointing arrow. Atari ST actually labeled it Backspace.
Yup I meant the 'Backspace' key that looks like this: <---
Not the 'Delete' key that says 'Delete' and is clustered with End/Home/Insert etc.
Interestingly, on Windows machines, The backspace key sends ASCII 8, but can send ASCII 127 if you press control+backspace.
The phenomenon of once common tribal knowledge becoming forgotten lore is so extensive that ESR put together a document compiling such knowledge for future generations called Things Every Hacker Once Knew: http://www.catb.org/esr/faqs/things-every-hacker-once-knew/
Nowadays you’re not going to understand how a terminal works unless you’re doing some very specialized work or you really want to understand that.
Young developers I’ve met are typically stuck on the treadmill learning things that change a lot (typically web).
printf(">");
read(0, ...);
I can only delete (DEL) chars that I've written, but not the ">". Who takes care of that, given that is not using readline?I guess it has to be the N_TTY line disc but I'm not sure how it works given that I can manually place the cursor where ever I want differently.
If you were to send cursor positioning sequences, instead of just ">", this would probably fall apart as the kernel's edit buffer and the terminal reality would be out of sync.
What you say is true, but even if your program doesn't see any input, you can (the kernel n_tty line discipline) edit the input (delete it).
So if I do print() read() print() read() the reads will only be able to edit what has been input since that particular syscall.
I'm sure this marriage will cras^H^H^H^Hthrive
I think the audience for such pun-level "humor" is down to single digits...
Oh, I think the audience size (IOW, those that get the joke) is fine, but I think the number that actually know the "why" of the punchline is pretty low. How old would one have to be to have ever run into a problem of BS/DEL not rendering properly on the receiving terminal? (At least my age, and I run in the "masters" category at local races.)
But to this point:
> There is some debate on whether BS or DEL is the correct character for terminals to send when the user presses the backspace key
These ASCII codes come from teletypes and BS really did just back up a space (I.e. you could over strike) just as LF really did advance the platen one line while not changing the column. DEL really did indicate that the previous character was to be ignored, more useful on paper tapes than printout.
Wow, I haven’t thought about paper tape in years...
The source code can be found on:
1. any distribution tape, V7 ships with its own code, 2. online, e.g. on http://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src
Ancient UNIX (Seventh Edition, including 32V, and prior) are permissively licensed under a BSD-style license[1].
I hope that helps.
Ancient UNIX (Seventh Edition, including 32V, and prior) are NOW permissively licensed under a BSD-style license[1]...
lest anyone learning about these things lose track of the Unix wars, UCB vs USL, and what really happened to Unix (aka it was forced to call itself BSD)