Filename extension | .shar |
---|---|
Type of format | Archive format, shell script |
In the Unix operating system, shar (an abbreviation of shell archive) is an archive format. A shar file is a shell script, and executing it will recreate the files. This is a type of self-extracting archive file. It can be created with the Unix shar utility. To extract the files, only the standard Unix Bourne shell sh is usually required.
Note that shar is not specified by the Single Unix Specification, so it is not formally a component of Unix, but a legacy utility.
Contents |
While the shar format has the advantage of being plain text, it poses a risk due to being executable;[1][2] for this reason the older and more general tar file format is usually preferred even for transferring text files. GNU provides its own version of shar in the GNU Sharutils collection.
unshar programs have been written for other operating systems but are not always reliable; shar files are shell scripts and can theoretically do anything that a shell script can do (including using incompatible features of enhanced or workalike shells), limiting their utility outside the Unix world.
The drawback of self-extracting shell scripts (any kind, not just shar) is that they rely on a particular implementation of programs; shell archives created with older versions of makeself,[3] for example the original Unreal Tournament for Linux installer, fails to run on bash 3.x due to a change in how missing arguments to trap
built-in command are handled.
In 1987, Michael Bednarek from The Melbourne Institute of Applied Economic and Social Research at the University of Melbourne developed a script for a similar purpose in the DIGITAL Command Language for the VMS operating system under the name "VMS_Shar version 2".[4]
The main purpose of this script was to allow the distribution of formatted program code through e-mail and Usenet newsgroups because:
Version 4 introduced the protection of trailing blanks using the TPU text editor editor which then became the main engine of the script. Version 5 protected control characters like TAB, ESC, BEL. In 1988, beginning with version 6, the script was then extended by James A. Gray from Xerox.[5] Starting with version 7, Andy Harper from King's College London continued the development;.[6] The current version (as of 2008) is 8.5 (1994)[7]
|