summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Stein <jcs@cvs.openbsd.org>2024-03-22 19:22:24 +0000
committerJoshua Stein <jcs@cvs.openbsd.org>2024-03-22 19:22:24 +0000
commit78059f51ef6ad45fdd8e1f120b6e32f0b761054e (patch)
tree5bcf226b2fcf142a97979c317ecc494b20ed3d19
parenteb53faec80a62fb0daeab4383775407bb757bde5 (diff)
add "-V none" to prevent making any backups
from FreeBSD ok bluhm deraadt
-rw-r--r--usr.bin/patch/backupfile.c6
-rw-r--r--usr.bin/patch/patch.112
-rw-r--r--usr.bin/patch/patch.c11
3 files changed, 17 insertions, 12 deletions
diff --git a/usr.bin/patch/backupfile.c b/usr.bin/patch/backupfile.c
index ed0767762e0..3197d730359 100644
--- a/usr.bin/patch/backupfile.c
+++ b/usr.bin/patch/backupfile.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: backupfile.c,v 1.22 2020/10/12 13:58:27 naddy Exp $ */
+/* $OpenBSD: backupfile.c,v 1.23 2024/03/22 19:22:23 jcs Exp $ */
/*
* backupfile.c -- make Emacs style backup file names Copyright (C) 1990 Free
@@ -220,11 +220,11 @@ invalid_arg(const char *kind, const char *value, int problem)
}
static const char *backup_args[] = {
- "never", "simple", "nil", "existing", "t", "numbered", 0
+ "none", "never", "simple", "nil", "existing", "t", "numbered", 0
};
static enum backup_type backup_types[] = {
- simple, simple, numbered_existing,
+ none, simple, simple, numbered_existing,
numbered_existing, numbered, numbered
};
diff --git a/usr.bin/patch/patch.1 b/usr.bin/patch/patch.1
index f88192f4add..d16d72850a3 100644
--- a/usr.bin/patch/patch.1
+++ b/usr.bin/patch/patch.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: patch.1,v 1.36 2022/03/31 17:27:26 naddy Exp $
+.\" $OpenBSD: patch.1,v 1.37 2024/03/22 19:22:23 jcs Exp $
.\" Copyright 1986, Larry Wall
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -19,7 +19,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd $Mdocdate: March 31 2022 $
+.Dd $Mdocdate: March 22 2024 $
.Dt PATCH 1
.Os
.Sh NAME
@@ -37,7 +37,7 @@
.Op Fl o Ar out-file
.Op Fl p Ar strip-count
.Op Fl r Ar rej-name
-.Op Fl V Cm t | nil | never
+.Op Fl V Cm t | nil | never | none
.Op Fl x Ar number
.Op Fl z Ar backup-ext
.Op Fl Fl posix
@@ -289,8 +289,8 @@ Forces
.Nm
to interpret the patch file as a unified context diff (a unidiff).
.It Xo
-.Fl V Cm t | nil | never ,
-.Fl Fl version-control Cm t | nil | never
+.Fl V Cm t | nil | never | none ,
+.Fl Fl version-control Cm t | nil | never | none
.Xc
Causes the next argument to be interpreted as a method for creating
backup file names.
@@ -321,6 +321,8 @@ Make numbered backups of files that already have them,
simple backups of the others.
.It Cm never , simple
Always make simple backups.
+.It Cm none
+Do not make backups.
.El
.It Fl v , Fl Fl version
Causes
diff --git a/usr.bin/patch/patch.c b/usr.bin/patch/patch.c
index 1e926d1b6a5..96da0572381 100644
--- a/usr.bin/patch/patch.c
+++ b/usr.bin/patch/patch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: patch.c,v 1.75 2023/10/25 20:05:43 bluhm Exp $ */
+/* $OpenBSD: patch.c,v 1.76 2024/03/22 19:22:23 jcs Exp $ */
/*
* patch - a program to apply diffs to original files
@@ -109,6 +109,8 @@ static bool remove_empty_files = false;
/* true if -R was specified on command line. */
static bool reverse_flag_specified = false;
+static bool Vflag = false;
+
/* buffer holding the name of the rejected patch file. */
static char rejname[PATH_MAX];
@@ -255,7 +257,7 @@ main(int argc, char *argv[])
my_exit(2);
}
- if (backup_type == none) {
+ if (!Vflag) {
if ((v = getenv("PATCH_VERSION_CONTROL")) == NULL)
v = getenv("VERSION_CONTROL");
if (v != NULL || !posix)
@@ -641,6 +643,7 @@ get_some_switches(void)
break;
case 'V':
backup_type = get_version(optarg);
+ Vflag = true;
break;
#ifdef DEBUGGING
case 'x':
@@ -677,8 +680,8 @@ usage(void)
fprintf(stderr,
"usage: patch [-bCcEeflNnRstuv] [-B backup-prefix] [-D symbol] [-d directory]\n"
" [-F max-fuzz] [-i patchfile] [-o out-file] [-p strip-count]\n"
-" [-r rej-name] [-V t | nil | never] [-x number] [-z backup-ext]\n"
-" [--posix] [origfile [patchfile]]\n"
+" [-r rej-name] [-V t | nil | never | none] [-x number]\n"
+" [-z backup-ext] [--posix] [origfile [patchfile]]\n"
" patch <patchfile\n");
my_exit(2);
}