X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=lib%2Fyesno.c;fp=lib%2Fyesno.c;h=81f77d1673b337074534f6de9c3f54b0b02a27aa;hb=20fcfc81ece044b8b0a6768ec6cf47be4e22a2e6;hp=3797679177bf13ed5c87e6ed62a355844b2da8aa;hpb=d57728a6ca2413a7c564d8b7bb13d9e5a5a180f3;p=debian%2Fgzip diff --git a/lib/yesno.c b/lib/yesno.c index 3797679..81f77d1 100644 --- a/lib/yesno.c +++ b/lib/yesno.c @@ -1,6 +1,6 @@ /* yesno.c -- read a yes/no response from stdin - Copyright (C) 1990, 1998, 2001, 2003-2013 Free Software Foundation, Inc. + Copyright (C) 1990, 1998, 2001, 2003-2016 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -42,7 +42,10 @@ yesno (void) yes = false; else { - response[response_len - 1] = '\0'; + /* Remove EOL if present as that's not part of the matched response, + and not matched by $ for example. */ + if (response[response_len - 1] == '\n') + response[response_len - 1] = '\0'; yes = (0 < rpmatch (response)); }