There is a statement
stty onlcr 0>&1
in rc.sysvinit file. What does exactly this line do? What's the reason for redirecting stdin to stdout?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.
Sign up to join this community$ man stty
...
* [-]onlcr
translate newline to carriage return-newline
...
and there's even a comment in the file, which you failed to mention:
# Set onlcr to avoid staircase effect.
So that should make it clear what the line does. stty
operates on stdin
by default, but this line changes output settings, so 0>&1
makes it work on stdout
. Which can actually matter if you've a box where the console stdout is hooked up to one serial port, and the console stdin input to some other source ...
Edit
stty
changes terminal parameters. To do so, it must issue system calls which operate on a file handle that correspond to a terminal. By default, this is stdin
, as the manpage says:
-F, --file=DEVICE
open and use the specified DEVICE instead of stdin
I'm not sure what kind of example would help you ...
stty
changes parameters for them?
If you type man stty
you'll get the documentation for stty
, which among other things says
[-]onlcr
translate newline to carriage return-newline
The reason for the redirection is that stty
operates on its stdin, but there's only stdout available at the time the command is run.