[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#249251: Broken prompt: "Install these packages without verification? [y/N]"



Package: apt
Version: 0.6.23
Tags: patch experimental

Hello!

I just noticed that, when installing a package which can't be
authenticated, the prompt whether one wants to really install it is
somewhat broken. The line is:

Install these packages without verification? [y/N]

I do not press Y here, just RETURN. It works as expected when entering Y
or N, but with only RETURN it installs instead of aborting as [y/N]
indicates.

Attached are two small patches which fix that:

1) apt-get.cc-YnPrompt-oldbehaviour.diff just fixes it.

2) apt-get.cc-YnPrompt.diff additionally accepts strings consisting only
of white-space to trigger the default action in YnPrompt. I find that
somewhat nicer.

Another suggestion would be adding a check for NOEXPR and return Default
if neither YESEXPR nor NOEXPR match, but on the other hand YnPrompt is
hardly ever used anyway... factoring those out from other tools might
make it more worthwhile :-)

Thanks!

47a48
> #include <ctype.h>
114c115
< bool YnPrompt()
---
> bool YnPrompt(bool Default = true)
128,129c129,134
<    if (strlen(response) == 0)
<       return true;
---
>    const char *I = response;
>    for (I = response; isspace(*I) && (*I != 0); ++I);
> 
>    if (*I == 0) {
>        return Default;
>    }
699c704
<       if (!YnPrompt())
---
>       if (!YnPrompt(false))
114c114
< bool YnPrompt()
---
> bool YnPrompt(bool Default = true)
129c129
<       return true;
---
>       return Default;
699c699
<       if (!YnPrompt())
---
>       if (!YnPrompt(false))

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: