2

I have a terminal with the bash shell.

The terminal has the ICRNL flag set (so when the terminal sends a CR, it will be translated to LF, and then the LF will be sent to bash):

enter image description here

But I did a test that showed that bash will receive CR and not LF. Why is that?

The test I made is running hexdump in another terminal and make it read what the first terminal is sending.

5

When you run stty -a from the bash prompt, you see the terminal settings while bash is not reading a command line.

When bash is reading a command line, it changes some terminal settings, including icrnl (turned off, because bash wants raw input since it does its own input processing). Bash restores the original settings before running the command.

To see what the terminal settings are at the bash prompt, note which terminal this is, and run stty from another terminal. For example:

  1. In one terminal:

    bash-4.2$ tty
    /dev/pts/3
    bash-4.2$ 
    
  2. In another terminal:

    $ stty -a </dev/pts/3
    … -icrnl …
    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.