применить изменения к файлам (apply changes to files)
Обоснование (Rationale)
Some of the functionality in historical patch implementations was
not specified. The following documents those features present in
historical implementations that have not been specified.
A deleted piece of functionality was the '+'
pseudo-option
allowing an additional set of options and a patch file operand to
be given. This was seen as being insufficiently useful to
standardize.
In historical implementations, if the string "Prereq:"
appeared
in the header, the patch utility would search for the
corresponding version information (the string specified in the
header, delimited by <blank> characters or the beginning or end
of a line or the file) anywhere in the original file. This was
deleted as too simplistic and insufficiently trustworthy a
mechanism to standardize. For example, if:
Prereq: 1.2
were in the header, the presence of a delimited 1.2 anywhere in
the file would satisfy the prerequisite.
The following options were dropped from historical
implementations of patch as insufficiently useful to standardize:
-b
The -b
option historically provided a method for
changing the name extension of the backup file from the
default .orig
. This option has been modified and
retained in this volume of POSIX.1‐2017.
-F
The -F
option specified the number of lines of a
context diff to ignore when searching for a place to
install a patch.
-f
The -f
option historically caused patch not to request
additional information from the user.
-r
The -r
option historically provided a method of
overriding the extension of the reject file from the
default .rej
.
-s
The -s
option historically caused patch to work
silently unless an error occurred.
-x
The -x
option historically set internal debugging
flags.
In some file system implementations, the saving of a .orig
file
may produce unwanted results. In the case of 12, 13, or
14-character filenames (on file systems supporting 14-character
maximum filenames), the .orig
file overwrites the new file. The
reject file may also exceed this filename limit. It was
suggested, due to some historical practice, that a <tilde> ('~'
)
suffix be used instead of .orig
and some other character instead
of the .rej
suffix. This was rejected because it is not obvious
to the user which file is which. The suffixes .orig
and .rej
are
clearer and more understandable.
The -b
option has the opposite sense in some historical
implementations—do not save the .orig
file. The default case here
is not to save the files, making patch behave more consistently
with the other standard utilities.
The -w
option in early proposals was changed to -l
to match
historical practice.
The -N
option was included because without it, a non-interactive
application cannot reject previously applied patches. For
example, if a user is piping the output of diff into the patch
utility, and the user only wants to patch a file to a newer
version non-interactively, the -N
option is required.
Changes to the -l
option description were proposed to allow
matching across <newline> characters in addition to just <blank>
characters. Since this is not historical practice, and since some
ambiguities could result, it is suggested that future
developments in this area utilize another option letter, such as
-L
.
The -u
option of GNU patch has been added, along with support for
unified context formats.