Skip to content

Fix line endings in menu display output#3473

Merged
AjanZhong merged 3 commits into
u-root:mainfrom
jelischer:main
Dec 5, 2025
Merged

Fix line endings in menu display output#3473
AjanZhong merged 3 commits into
u-root:mainfrom
jelischer:main

Conversation

@jelischer
Copy link
Copy Markdown
Contributor

@jelischer jelischer commented Dec 4, 2025

This was committed before but accidentally included in a revert of another change. On some kinds of output (specifically serial ports) you need to move the 'cursor' back to the left hand side of the screen.

          it tends to
                      look a bit like
                                      stairs

Due to a different bug in the same code, the line for the prompt and the lines for the menu items can get intermixes in almost any order due to the fact that two different file descriptors are used for a single stream of data.

There are reasons for this but one needs to make sure that one stream is properly flushed out before the other starts sending data or hilarity ensues.

Signed-off-by: jelischer 58259690+jelischer@users.noreply.github.com

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.84%. Comparing base (7bc9fa7) to head (97bdbd3).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3473   +/-   ##
=======================================
  Coverage   61.84%   61.84%           
=======================================
  Files         637      637           
  Lines       43121    43124    +3     
=======================================
+ Hits        26667    26672    +5     
+ Misses      16454    16452    -2     
Flag Coverage Δ
.-amd64 90.90% <ø> (ø)
cmds/...-amd64 51.16% <ø> (-0.02%) ⬇️
integration/generic-tests/...-amd64 30.94% <100.00%> (+0.01%) ⬆️
integration/generic-tests/...-arm 33.06% <100.00%> (+0.01%) ⬆️
integration/generic-tests/...-arm64 30.12% <100.00%> (+0.08%) ⬆️
integration/gotests/...-amd64 62.34% <0.00%> (-0.01%) ⬇️
integration/gotests/...-arm 62.88% <0.00%> (-0.01%) ⬇️
integration/gotests/...-arm64 62.98% <0.00%> (-0.01%) ⬇️
pkg/...-amd64 60.31% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
everything 67.02% <100.00%> (+<0.01%) ⬆️
cmds/exp 32.82% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This was committed before but accidentally included in a revert of
another change. On some kinds of output (specifically serial ports)
you need to move the 'cursor' back to the left hand side of the
screen.
Otherwise
          it tends to
                      look a bit like
                                      stairs

Signed-off-by: jelischer <58259690+jelischer@users.noreply.github.com>
Under some environments the fact that the menu actually switches form
stdio to /dev/tty in the middle of processing actually matters.

This is done because in some environments the stdio devices don't
really handle input timeouts well, but the downside is that they
can be two very different data paths. When the file descriptor used
for the prompt is put into raw mode the buffering in the other file
descriptor is not notified so any data not flushed out remains
unflushed. The end result is that the prompt, sent out last can show up
on the screen at almost any place from the top to the bottom.

Since we can't just use the stdout device (if we trust the comments that
say that we can't) then the only other option is to force a flush on all
the data sent before the prompt (and throw in a tiny delay for safety).

Fixes: u-root#3426
Signed-off-by: jelischer <58259690+jelischer@users.noreply.github.com>
@jelischer
Copy link
Copy Markdown
Contributor Author

Here is another attempt to fix this issue.. this time I think we can do it without triggering the broken tests

@AjanZhong AjanZhong merged commit 95e4dda into u-root:main Dec 5, 2025
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants