[pacman-dev] noconfirm trivial bug - prompt printed but unused/unnecessary

Brendan Hide brendan at swiftspirit.co.za
Wed May 20 08:07:27 EDT 2009


Hi all

I'm still getting my head around git and pacman-dev's workflow - I know 
its not that complicated, just need a bit of time.

When using --noconfirm the prompt is presented (odd part) and the user 
(rightly) is not given an opportunity to confirm:
> [ brendan at swift : 12:36:40 : ~/src/pacman ]
> :) sudo pacman -Sc --noconfirm
> Cache directory: /var/cache/pacman/pkg/
> Do you want to remove outdated packages from cache? 
> [Y/n]                 <------
> removing old packages from cache... done.
> Database directory: /var/lib/pacman/
> Do you want to remove unused repositories? [Y/n]                 <------
> Database directory cleaned up
> [ brendan at swift : 12:36:57 : ~/src/pacman ]
> :)
Best fix I can think of is to just mention that we're using a default 
because the --noconfirm flag has been used. The alternative (which is 
less informative for the user) is to not present the prompt at all.

I've inserted 2 strings below. Assuming this is the right change to 
make, what else would I need to do to ensure that this is compatible 
with the i18n measures already in place?

util.c, lines 641-680:
> /* presents a prompt and gets a Y/N answer */
> static int question(short preset, char *fmt, va_list args)
> {
>         char response[32];
>         FILE *stream;
>
>         if(config->noconfirm) {
>                 stream = stdout;
>         } else {
>                 /* Use stderr so questions are always displayed when 
> redirecting output */
>                 stream = stderr;
>         }
>
>         vfprintf(stream, fmt, args);
>
>         if(preset) {
>                 fprintf(stream, " %s ", _("[Y/n]"));
>         } else {
>                 fprintf(stream, " %s ", _("[y/N]"));
>         }
>
>         if(config->noconfirm) {
>                 fprintf(stream, "\n");
Replace the 'fprintf(stream, "\n");' line above with something like:
                if(preset) {
                        fprintf(stream, "%s", _("noconfirm option set, 
defaulting to Yes\n"));
                } else {
                        fprintf(stream, "%s", _("noconfirm option set, 
defaulting to No\n"));
                }
>                 return(preset);
>         }
>
>         if(fgets(response, 32, stdin)) {
>                 strtrim(response);
>                 if(strlen(response) == 0) {
>                         return(preset);
>                 }
>
>                 if(!strcasecmp(response, _("Y")) || 
> !strcasecmp(response, _("YES"))) {
>                         return(1);
>                 } else if (!strcasecmp(response, _("N")) || 
> !strcasecmp(response, _("NO"))) {
>                         return(0);
>                 }
>         }
>         return(0);
> }
-- 

__________
Brendan Hide



More information about the pacman-dev mailing list