summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2017-06-18 21:48:33 +0000
committerpfg <pfg@FreeBSD.org>2017-06-18 21:48:33 +0000
commitdbbb1b9d76ba048e531f35d5517057a50ed33719 (patch)
tree9c89b33c9f0817b536d7588b16c6e75aa21c2c4c
parent70c2560233fb44c48f9b75dbf481f8cd147286e6 (diff)
downloadFreeBSD-src-dbbb1b9d76ba048e531f35d5517057a50ed33719.zip
FreeBSD-src-dbbb1b9d76ba048e531f35d5517057a50ed33719.tar.gz
MFC r319676:
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)
-rw-r--r--usr.bin/patch/pch.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/usr.bin/patch/pch.c b/usr.bin/patch/pch.c
index 8aee8b2..92117bd 100644
--- a/usr.bin/patch/pch.c
+++ b/usr.bin/patch/pch.c
@@ -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");
OpenPOWER on IntegriCloud