You are not logged in.
Pages: 1
where do i ask to chnge pacman behavior ?
i whant that if i say "y" but in other language,
that pacman will promt me again and not exit like now.
ezik
Offline
There are cases where "Y" in another language is "n". So how would that work?
Offline
i don't know but it works in fedora
ezik
doesn't other language have different ascii or something else to differ them from english ?
or may be by checking the layout.
ezik
Last edited by shulamy (2016-12-17 15:44:24)
Offline
I am going to hazard a guess that what fedora does, and what you actually want, is to prompt again on invalid input. Currently, any unrecognized response is treated as a no.
Offline
i think you are right.
it's only a minor change in the existing if statement.
ezik
Offline
int confirm;
if(config->op_s_downloadonly) {
confirm = yesno(_("Proceed with download?"));
} else {
confirm = yesno(_("Proceed with installation?"));
}
if(!confirm) {
retval = 1;
goto cleanup;
}
ezik
Offline
I am going to hazard a guess that what fedora does, and what you actually want, is to prompt again on invalid input. Currently, any unrecognized response is treated as a no.
I've not been bit by this before, but I would have thought that invalid input would indeed result in reprompting (or error-out) rather than assuming a no or a default.
Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.
Offline
shulamy, to make it more consistent, you'd need to modify the question() function in util.c.
If there was tail recursion in C, I'd replace the `return 0` on the last line by a call to question() itself. But for that kind of stuff, recursion might cause issues, so using a do...while might make more sense?
/* presents a prompt and gets a Y/N answer */
__attribute__((format(printf, 2, 0)))
static int question(short preset, const char *format, va_list args)
{
char response[32];
int retval;
FILE *stream;
int fd_in = fileno(stdin);
if(config->noconfirm) {
stream = stdout;
} else {
/* Use stderr so questions are always displayed when redirecting output */
stream = stderr;
}
/* ensure all text makes it to the screen before we prompt the user */
fflush(stdout);
fflush(stderr);
do {
retval = -1;
fputs(config->colstr.colon, stream);
vfprintf(stream, format, args);
if(preset) {
fprintf(stream, " %s ", _("[Y/n]"));
} else {
fprintf(stream, " %s ", _("[y/N]"));
}
fputs(config->colstr.nocolor, stream);
fflush(stream);
if(config->noconfirm) {
fprintf(stream, "\n");
return preset;
}
flush_term_input(fd_in);
if(safe_fgets(response, sizeof(response), stdin)) {
size_t len = strtrim(response);
if(len == 0) {
return preset;
}
/* if stdin is piped, response does not get printed out, and as a result
* a \n is missing, resulting in broken output */
if(!isatty(fd_in)) {
fprintf(stream, "%s\n", response);
}
if(mbscasecmp(response, _("Y")) == 0 || mbscasecmp(response, _("YES")) == 0) {
retval = 1;
} else if(mbscasecmp(response, _("N")) == 0 || mbscasecmp(response, _("NO")) == 0) {
retval = 0;
}
}
} while(retval == -1);
return retval;
}
--edit--
Noticed I was working on an older commit of pacman, fixed.
--edit2--
Actually, I'm not quite sure if this is a good idea - if something goes wrong (e.g. invalid input piped into pacman), infinite loops might occur.
--edit3--
To avoid an infinite loop, pacman could abort after three invalid inputs. However, I'd say that implementing the aborting mechanism is pretty non-trivial, as pacman would still need to do cleanup work.
Last edited by ayekat (2016-12-23 15:30:16)
Offline
@ayekat - i will look into it when i have time
ezik
Offline
Pages: 1