diff options
author | Pedro F. Giffuni <pfg@FreeBSD.org> | 2017-06-08 03:15:08 +0000 |
---|---|---|
committer | Pedro F. Giffuni <pfg@FreeBSD.org> | 2017-06-08 03:15:08 +0000 |
commit | 12300d3aa0168f532d29242ce9a47afb630a348c (patch) | |
tree | 4721923b002b3c798d1d3bfd9a7d867751bd32d8 /usr.bin/patch | |
parent | 864092bcaa5aed15e40ab347d4dabe4060c11f4b (diff) | |
download | src-12300d3aa0168f532d29242ce9a47afb630a348c.tar.gz src-12300d3aa0168f532d29242ce9a47afb630a348c.zip |
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
Notes
Notes:
svn path=/head/; revision=319676
Diffstat (limited to 'usr.bin/patch')
-rw-r--r-- | usr.bin/patch/pch.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/usr.bin/patch/pch.c b/usr.bin/patch/pch.c index e12e833d54ef..95853b507ee2 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"); |