1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

prompt: display 'n' for EOF

When EOF is detect - it could be either 'Ctrl+C'
or empty stdin.

For Ctrl+C there is visual ^C sign.
For EOF print 'n' so decision is clear in debug print.
This commit is contained in:
Zdenek Kabelac 2014-07-07 21:03:15 +02:00
parent 39cb8aa3ab
commit baf825331c

View File

@ -883,7 +883,7 @@ void display_name_error(name_error_t name_error)
*/
char yes_no_prompt(const char *prompt, ...)
{
int c = 0, ret = 0;
int c = 0, ret = 0, cb = 0;
va_list ap;
sigint_allow();
@ -903,6 +903,7 @@ char yes_no_prompt(const char *prompt, ...)
if ((c = getchar()) == EOF) {
ret = 'n'; /* SIGINT */
cb = 1;
break;
}
@ -918,6 +919,9 @@ char yes_no_prompt(const char *prompt, ...)
sigint_restore();
if (cb && !sigint_caught())
fputc(ret, stderr);
if (c != '\n')
fputc('\n', stderr);