gio-tool-mount: Return early on fgets EOF

As per commit a5390002 we're exiting with error in case fgets failed,
however it could also fail because of EOF (like on ^D), so in such case
we can just return early treating it as a non-error.

Otherwise still exit with error.

Fixes: #2737
This commit is contained in:
Marco Trevisan (Treviño) 2022-08-30 16:10:04 +02:00
parent 695d6b4d8d
commit a0e71ff86f

View File

@ -113,7 +113,15 @@ prompt_for (const char *prompt, const char *default_value, gboolean echo)
#endif
if (!fgets (data, sizeof (data), stdin))
g_error ("Failed to read from standard input");
{
if (feof (stdin))
{
g_print ("\n");
return NULL;
}
g_error ("Failed to read from standard input");
}
#ifdef HAVE_TERMIOS_H
if (restore_flags)