On Fri, 01 Nov 2024 23:07:31 +0000 "Sertonix" <[email protected]> wrote:
> In fd47f056765 (lineedit: print prompt and editing operations to stderr) > some output was left printing to stdout. This causes a race condition > between stderr and stdout which in some cases leads to output written in > the wrong places. > > Downstream issue: https://gitlab.alpinelinux.org/alpine/aports/-/issues/16566 > Fixes: fd47f056765 > > Signed-off-by: Sertonix <[email protected]> > --- > The implicit '\n' doesn't apply to stderr so it needed to be explicit. > > libbb/lineedit.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/libbb/lineedit.c b/libbb/lineedit.c > index 151208c1c..26f47f043 100644 > --- a/libbb/lineedit.c > +++ b/libbb/lineedit.c > @@ -451,7 +451,7 @@ static void put_cur_glyph_and_inc_cursor(void) > * have automargin (IOW: it is moving cursor to next line > * by itself (which is wrong for VT-10x terminals)), > * this will break things: there will be one extra empty line */ > - puts("\r"); /* + implicit '\n' */ > + fprintf(stderr, "\r\n"); You could use fputs here. > #else > /* VT-10x terminals don't wrap cursor to next line when last > char > * on the line is printed - cursor stays "over" this char. > @@ -1170,9 +1170,9 @@ static void showfiles(void) > ); > } > if (ENABLE_UNICODE_SUPPORT) > - puts(printable_string(matches[n])); > + fprintf(stderr, "%s\n", printable_string(matches[n])); You could use fputs here as well. > else > - puts(matches[n]); > + fprintf(stderr, "%s\n", matches[n]); Also here. And at this point you could probably save a few bytes by creating a fputs_stderr function. > } > } > Thanks for working on this. It has annoyed me every day since we updated to busybox 1.37. -nc _______________________________________________ busybox mailing list [email protected] https://lists.busybox.net/mailman/listinfo/busybox
