diff mbox series

btrfs-progs: restore: Redirect looping prompt to stderr

Message ID 20200822080130.5910-1-raoul@bhatia.at
State New, archived
Headers show
Series btrfs-progs: restore: Redirect looping prompt to stderr | expand

Commit Message

Raoul Bhatia Aug. 22, 2020, 8:03 a.m. UTC
From: Raoul Bhatia <raoul@bhatia.at>

When initiating a btrfs restore, i.e. in verbose mode, it might be
helpful to redirect stdout to a log file.  stdout redirection to a file
is usually fully buffered, so the looping prompt is likely not flushed
to the log file for the user to notice.

Thus, btrfs restore might seem to hang, while it is actually waiting for
a user interaction.

To improve the user experience, send the looping prompt to (unbuffered)
stderr.

Signed-off-by: Raoul Bhatia <raoul@bhatia.at>
---
  cmds/restore.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

  	if (!ret || *ret == '\n' || tolower(*ret) == 'n')
diff mbox series

Patch

diff --git a/cmds/restore.c b/cmds/restore.c
index 858ac6ea..d7df383c 100644
--- a/cmds/restore.c
+++ b/cmds/restore.c
@@ -477,8 +477,8 @@  static enum loop_response ask_to_continue(const char 
*file)
  	char buf[16];
  	char *ret;

-	printf("We seem to be looping a lot on %s, do you want to keep going "
-	       "on ? (y/N/a): ", file);
+	fprintf(stderr, "We seem to be looping a lot on %s, "
+               "do you want to keep going on ? (y/N/a): ", file);
  again:
  	ret = fgets(buf, 16, stdin);