Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add stty -onlcr to cartesi-init #36

Merged
merged 1 commit into from
Mar 8, 2024
Merged

Conversation

diegonehab
Copy link
Contributor

The expected behavior of the emulator is to pass through new-line control-characters directly from the inside to the outside. On the outside, if the output of the emulator is connected to a file, there should be no addition of a carriage-return. If, however, the output is connected to a terminal, the terminal itself will have been configured to add the carriage-return on its own.

In other words, we expect the following command to have the output shown

cartesi-machine.lua --no-init-splash --quiet -- echo | xxd
00000000: 0a                                       .

Instead, what we see before this PR (but when using a yet-to-be-released kernel linked to opensbi-1.3.1-ctsi-2) is

cartesi-machine.lua --no-init-splash --quiet -- echo | xxd
00000000: 0d0a                                     ..

This is because the terminal inside the emulator is configured with onlcr, so it is adding the carriage-return whenever it sees a new-line.

The PR configures the terminal with -onlcr so this doesn't happen.

Interestingly, prior to opensbi-1.3.1-ctsi-2, opensbi itself was adding yet another carriage-return on its own, whenever it saw a new-line sent to the legacy putchar we use with HTIF console. So the output was

cartesi-machine.lua --no-init-splash --quiet -- echo | xxd
00000000: 0d0d 0a                                  ...

@diegonehab diegonehab added the bug Something isn't working label Mar 8, 2024
@diegonehab diegonehab requested review from edubart and vfusco March 8, 2024 15:24
@diegonehab diegonehab self-assigned this Mar 8, 2024
@diegonehab diegonehab merged commit e4fd683 into main Mar 8, 2024
3 checks passed
@diegonehab diegonehab deleted the feature/fix-raw-terminal branch March 8, 2024 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants