Add -i option (SUSv3) to patch(1). This allows one to specify a

patch file on command line instead of stdin.

Submitted by:	Joseph Mallett <jmallett@xMach.org>
MFC after:	1 month
This commit is contained in:
Mike Barcroft 2002-02-08 02:05:32 +00:00
parent 045e854101
commit 80db0611da
2 changed files with 17 additions and 3 deletions

View File

@ -116,6 +116,12 @@ option; if that file already exists, it is backed up first.
If
.I patchfile
is omitted, or is a hyphen, the patch will be read from standard input.
If a
\fB\-i\fP
argument is specified, the filename following it will be used, instead of
standard input. You may specify only one
\fB\-i\fP
directive.
.PP
Upon startup, patch will attempt to determine the type of the diff listing,
unless over-ruled by a
@ -320,6 +326,11 @@ Note that a larger fuzz factor increases the odds of a faulty patch.
The default fuzz factor is 2, and it may not be set to more than
the number of lines of context in the context diff, ordinarily 3.
.TP 5
.B "\-i patchfile"
tells
.I patch
to apply \fBpatchfile\fP instead of stdin.
.TP 5
.B "\-I, \-\-index-first"
forces
.I patch
@ -453,7 +464,7 @@ causes
.I patch
to print out its revision header and patch level.
.TP 5
.B "\-V method, \-\-version\-\-control=method"
.B "\-V method, \-\-version\-control=method"
causes
.B method
to be interpreted as a method for creating

View File

@ -450,7 +450,7 @@ reinitialize_almost_everything()
fatal1("you may not change to a different patch file\n");
}
static char *shortopts = "-b:B:cCd:D:eEfF:IlnNo:p::r:RsStuvV:x:";
static char *shortopts = "-b:B:cCd:D:eEfF:i:IlnNo:p::r:RsStuvV:x:";
static struct option longopts[] =
{
{"suffix", 1, NULL, 'b'},
@ -540,6 +540,9 @@ get_some_switches()
case 'F':
maxfuzz = atoi(optarg);
break;
case 'i':
filearg[1] = savestr(optarg);
break;
case 'I':
index_first = TRUE;
break;
@ -601,7 +604,7 @@ Usage: %s [options] [origfile [patchfile]] [+ [options] [origfile]]...\n",
fprintf(stderr, "\
Options:\n\
[-cCeEflnNRsStuv] [-b backup-ext] [-B backup-prefix] [-d directory]\n\
[-D symbol] [-F max-fuzz] [-o out-file] [-p[strip-count]]\n\
[-D symbol] [-F max-fuzz] [-i patchfile] [-o out-file] [-p[strip-count]]\n\
[-r rej-name] [-V {numbered,existing,simple}] [--check] [--context]\n\
[--prefix=backup-prefix] [--suffix=backup-ext] [--ifdef=symbol]\n\
[--directory=directory] [--ed] [--fuzz=max-fuzz] [--force] [--batch]\n\