xbps-install: make question() read the whole input line
reading only the first character would answer the next question() with the next character (unless you just pressed enter)
This commit is contained in:
parent
cfc8e0a580
commit
56aa77d51b
@ -41,22 +41,27 @@ static bool
|
||||
question(bool preset, const char *fmt, va_list ap)
|
||||
{
|
||||
int response;
|
||||
bool rv = false;
|
||||
|
||||
vfprintf(stderr, fmt, ap);
|
||||
if(preset)
|
||||
if (preset)
|
||||
fputs(" [Y/n] ", stderr);
|
||||
else
|
||||
fputs(" [y/N] ", stderr);
|
||||
|
||||
if ((response = fgetc(stdin)) != EOF) {
|
||||
response = fgetc(stdin);
|
||||
if (response == '\n')
|
||||
return preset;
|
||||
if (response == 'y' || response == 'Y')
|
||||
return true;
|
||||
if (response == 'n' || response == 'N')
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
rv = preset;
|
||||
else if (response == 'y' || response == 'Y')
|
||||
rv = true;
|
||||
else if (response == 'n' || response == 'N')
|
||||
rv = false;
|
||||
|
||||
/* read the rest of the line */
|
||||
while (response != EOF && response != '\n')
|
||||
response = fgetc(stdin);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool
|
||||
|
Loading…
Reference in New Issue
Block a user