When I try: $ stty raw -echo
on my Terminal (Bash on OS X 10.6). It does stringe things and it's like the terminal hang there. Then I lookup the manual:
stty — set the options for a terminal device interface
raw (-raw)
If set, change the modes of the terminal so that no input or
output processing is performed. If unset, change the modes of the terminal to some reasonable state that performs input and output processing. Note that since the terminal driver no longer has a single RAW bit, it is not possible to intuit what flags were set prior to setting raw. This means that unsetting raw may not put back all the setting that were previously in effect. To set the terminal into a raw state and then accurately restore it, the following shell code is recommended:save_state=$(stty -g) stty raw ... stty "$save_state"
echo (-echo)
Echo back (do not echo back) every character typed.
So it's supposed to turn the Terminal in raw mode then return what I type in as is? Could someone please explain what does this command do? And what is the difference when an argument has dash, e.g. raw
and -raw
? Are they mean the samething? Is there any resource I could learn this?
Firstly, the dash means "disable" a setting. So this enables echoing:
stty echo
This disables it:
stty -echo
When you disable it, your typing is not echoed back to you, which is why it seems as if the terminal is hanging. Try stty -echo
then type ls
and press return - you will still see the output of ls
.
The raw
setting means that the input and output is not processed, just sent straight through. Processing can be things like ignoring certain characters, translating characters into other characters, allowing interrupt signals etc. So with stty raw
you can't hit Ctrl-C to end a process, for example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With