aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2023-01-24 16:46:01 +0000
committerKyle Evans <kevans@FreeBSD.org>2023-02-16 03:29:40 +0000
commitdfdc3b2e6541c941b51edd5e5ec575411e5be143 (patch)
tree4b2c21e87130589a4b0800f8c20aaa4a6c21cc5b
parent1dc1d45055a3e60dbe88dfb10abd9872a2677661 (diff)
downloadsrc-dfdc3b2e6541c941b51edd5e5ec575411e5be143.tar.gz
src-dfdc3b2e6541c941b51edd5e5ec575411e5be143.zip
patch: omit filename if the prompt was ignored
When a file is missing, patch(1) will prompt for a filename to try and patch it. If we're doing a dry-run, we'll output that the patch to the source file was either ignored/failed. If you ignore the prompt in a dry-run (i.e. just hit enter), we'll output: X out of X hunks ignored while patching (null) Let's improve the aesthetics a bit and just omit the last part if the prompt was ignored: X out of X hunks ignored Unfortunately we can't really test this without expect(1) because both force and batch mode will use the first best guess, which is wiped out by the "File to patch:" prompt. We could record the initially derived bestguess there and use *that*, but given that this is only possible in an interactive session I think it's fine to just omit the filename rather than adding a fair amount of complexity (which could also break other scenarios I haven't considered yet).. Reviewed by: des Sponsored by: Klara, Inc. (cherry picked from commit 7e688ed493482c5346d969e7667856d8ced8d87a)
-rw-r--r--usr.bin/patch/patch.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/usr.bin/patch/patch.c b/usr.bin/patch/patch.c
index a23fc82d3d90..48d3bd37fe5b 100644
--- a/usr.bin/patch/patch.c
+++ b/usr.bin/patch/patch.c
@@ -463,9 +463,13 @@ main(int argc, char *argv[])
if (!check_only)
say("%d out of %d hunks %s--saving rejects to %s\n",
failed, hunk, skip_rest_of_patch ? "ignored" : "failed", rejname);
- else
+ else if (filearg[0] != NULL)
say("%d out of %d hunks %s while patching %s\n",
failed, hunk, skip_rest_of_patch ? "ignored" : "failed", filearg[0]);
+ else
+ /* File prompt ignored, just note # hunks. */
+ say("%d out of %d hunks %s\n",
+ failed, hunk, skip_rest_of_patch ? "ignored" : "failed");
if (!check_only && move_file(TMPREJNAME, rejname) < 0)
trejkeep = true;
}