patch (Unix)
| patch | |
|---|---|
A screenshot of using patch | |
| Original author | Larry Wall |
| Developers | Paul Eggert, Wayne Davison, David MacKenzie, Andreas Grünbacher |
| Initial release | May 24, 1985 |
| Operating system | Unix and Unix-like, Plan 9, MSX-DOS, Microsoft Windows |
| Platform | Cross-platform |
| Type | Command |
patch is a shell command that updates text files according to instructions in a separate file, called a patch file. The patch file is a text file that lists the differences between the input file and the desired content. The command is designed to support patch files created via diff. A user creates a patch file by running diff for two versions of a file (original and target) which produces a list of differences that patch can later use to generate the target file from the original file plus the patch file. The term patch is also a verb – meaning to apply a patch.
Developed by a programmer for other programmers, patch was frequently used for updating source code to a newer version. Because of this, many people came to associate patches with source code, whereas patches can in fact be applied to any text. Patched files do not accumulate any unneeded text, which is what some people perceive based on the English meaning of the word; patch is as capable of removing text as it is of adding it.
Patches described here should not be confused with binary patches, which, although can be conceptually similar, are distributed to update binary files comprising the program to a new release.
The original patch program was written by Larry Wall (who went on to create the Perl programming language) and posted to mod.sources (which later became comp.sources.unix) in May 1985. patch was added to XPG4, which later became POSIX. Wall's code remains the basis of "patch" programs provided in OpenBSD, FreeBSD, and schilytools. The Open Software Foundation, which merged into The Open Group, is said to have maintained a derived version. The GNU project/FSF maintains its patch, forked from the Larry Wall version. The repository is different from that of GNU diffutils, but the documentation is managed together. Originally written for Unix, the command has also been ported to Windows (via GnuWin32 and UnxUtils) and many other platforms. An implementation is part of ASCII's MSX-DOS2 Tools for MSX-DOS version 2.