3

Probably a newby's question - I saw the command stty erase ^H in one of our log-in script and wanted to know what it does. Does it work on TCSH? or is it only applicable to KSH?

RonK
  • 241
  • 1
  • 5
  • 13

2 Answers2

4

From: man stty:

NAME
       stty - change and print terminal line settings
-- snip

   erase CHAR
          CHAR will erase the last character typed

This means that ^H (Ctrl-H) will be configured as control sequence to eliminate the last typed character.

Sven
  • 97,248
  • 13
  • 177
  • 225
  • Thanks, are there other alternatives than ^H? – RonK May 02 '11 at 10:22
  • 1
    Well, that's what the command is used for: To configure it to your liking. If you use `stty erase e`, the `e` key will delete characters, but you couldn't type an `e` anymore. Also, `^H` is pretty much the standard expected by admins, so I wouldn't change it if not necessary. – Sven May 02 '11 at 10:36
  • 1
    Thanks - so it binds the `^H` chacarcter (ASCII code: 8) to the `erase character` command (i.e. what you expect pushing the `backspace` key to perform. Any reason why this is something that needs to be explicitly done? Is it not the default on any Unix/Linux installation? – RonK May 02 '11 at 11:08
  • 1
    All this `tty` stuff comes from way back when people used serial lines to connect their (dumb) terminals to hosts and was enhanced over time to solve multiple issues when totally different and incompatible systems started to communicate which each other (BTW, tty stands for teletype...). Also, many things in a Unix/Linux system have no real default setting, but have to be configured at startup (often with customary "defaults"). – Sven May 02 '11 at 11:29
-1

Please correct if I'm wrong on below one:

stty erase ^? vs stty erase ^H vs stty erase

  • stty erase ^? -> if set this one backspace character will work.
  • stty erase ^H -> if set Ctrl+H work as backspace.
  • stty erase -> doesn't change any value maintain old one as it is.
Pierre.Vriens
  • 1,159
  • 34
  • 15
  • 19
Kiran
  • 1
  • ^? is Control-Backspace. ^H is typically sent by the backspace on US keyboards. As mentioned in a comment above, these are mostly legacy settings from the days of serial terminals when terminals weren't quite so standard. For fun, try typing 'stty -a' to see what all could be set. – Brandon Xavier Jul 10 '17 at 11:22
  • Yes, you are wrong. Your OS translates keycodes to character codes, your terminal emulator may apply further translations. The 'stty' cammnd sets up behaviours based on the characters it receives at the client. What these are on your keyboard is not defined by how the Unix host behaves. – symcbean Jul 10 '17 at 12:07