Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
agetty: use CTRL+C to erase username
aggety(8) from the beginning ignores ^C (the small exception was between 2.32 and 2.34 when this char has been misinterpreted). This patch forces agetty to interpret ^C like ^U, it means to erase the user's input and wait for a completely new username. The small difference is that for ^C it does not set 'kill character'. This change does not affect serial lines where ^C is still ignored like in previous decades. I'd like to avoid any regression as I have no clue if any serial lines do not send this control char in some context ... Fixes: #1399 References: #1046 Signed-off-by: Karel Zak <kzak@redhat.com>
- Loading branch information
6eb1c01
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I presume this is correct, I found it harder to follow the flow of control. Is there a cleaner way to do the same thing?
6eb1c01
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean the readability of the change? It would be possible to create a separate
case
for CTRL+C and duplicate the code that we use to delete the username, but I do not like duplicate code :-)6eb1c01
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the change makes the code harder for me to follow.
I also don't like duplication; it means having to be careful to keep them in sync in the future. There may be a way to arrange the flow without duplication, but I don't see a good one. Right now, it is not clear that ^C is supposed to be the same as ^U, with each running different code first.
If the three lines of shared code are too small to put in a function, but too large to duplicate, perhaps this is one of the rare times where
goto
is warranted?6eb1c01
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although I am reluctant to suggest it, I think duplication of those three lines is the best solution. It is not ideal, but it will help future maintainers to understand what the code is trying to do.