patch: if reading fails, do not go into infinite loop asking for a filename.

This can happen if no tty is available.

Obtained from:	OpenBSD (CVS rev 1.54)
MFC after:	5 days
This commit is contained in:
Pedro F. Giffuni 2017-06-08 03:15:08 +00:00
parent 864092bcaa
commit 12300d3aa0
1 changed files with 4 additions and 2 deletions

View File

@ -216,8 +216,10 @@ there_is_another_patch(void)
filearg[0] = fetchname(buf, &exists, 0);
}
if (!exists) {
ask("No file found--skip this patch? [n] ");
if (*buf != 'y')
int def_skip = *bestguess == '\0';
ask("No file found--skip this patch? [%c] ",
def_skip ? 'y' : 'n');
if (*buf == 'n' || (!def_skip && *buf != 'y'))
continue;
if (verbose)
say("Skipping patch...\n");