Author: pfg
Date: Thu Jun  8 03:15:08 2017
New Revision: 319676
URL: https://svnweb.freebsd.org/changeset/base/319676

Log:
  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

Modified:
  head/usr.bin/patch/pch.c

Modified: head/usr.bin/patch/pch.c
==============================================================================
--- head/usr.bin/patch/pch.c    Thu Jun  8 02:44:34 2017        (r319675)
+++ head/usr.bin/patch/pch.c    Thu Jun  8 03:15:08 2017        (r319676)
@@ -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");
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to