mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +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:
parent
39cb8aa3ab
commit
baf825331c
@ -883,7 +883,7 @@ void display_name_error(name_error_t name_error)
|
|||||||
*/
|
*/
|
||||||
char yes_no_prompt(const char *prompt, ...)
|
char yes_no_prompt(const char *prompt, ...)
|
||||||
{
|
{
|
||||||
int c = 0, ret = 0;
|
int c = 0, ret = 0, cb = 0;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
sigint_allow();
|
sigint_allow();
|
||||||
@ -903,6 +903,7 @@ char yes_no_prompt(const char *prompt, ...)
|
|||||||
|
|
||||||
if ((c = getchar()) == EOF) {
|
if ((c = getchar()) == EOF) {
|
||||||
ret = 'n'; /* SIGINT */
|
ret = 'n'; /* SIGINT */
|
||||||
|
cb = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -918,6 +919,9 @@ char yes_no_prompt(const char *prompt, ...)
|
|||||||
|
|
||||||
sigint_restore();
|
sigint_restore();
|
||||||
|
|
||||||
|
if (cb && !sigint_caught())
|
||||||
|
fputc(ret, stderr);
|
||||||
|
|
||||||
if (c != '\n')
|
if (c != '\n')
|
||||||
fputc('\n', stderr);
|
fputc('\n', stderr);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user