Shar (file format)
Template:Short description Template:Lowercase title Template:Use dmy dates {{#invoke:Infobox|infobox}}Template:Template other {{#invoke:Check for unknown parameters|check|unknown=Template:Main other|preview=Page using Template:Infobox software with unknown parameter "_VALUE_"|ignoreblank=y| AsOf | author | background | bodystyle | caption | collapsetext | collapsible | developer | discontinued | engine | engines | genre | included with | language | language count | language footnote | latest preview date | latest preview version | latest release date | latest release version | latest_preview_date | latest_preview_version | latest_release_date | latest_release_version | licence | license | logo | logo alt | logo caption | logo class | logo size | logo title | logo upright | logo_alt | logo_caption | logo_class | logo_size | logo_title | logo_upright | middleware | module | name | operating system | operating_system | other_names | platform | programming language | programming_language | qid | released | replaced_by | replaces | repo | screenshot | screenshot alt | screenshot class | screenshot size | screenshot title | screenshot upright | screenshot_alt | screenshot_class | screenshot_size | screenshot_upright | service_name | size | standard | title | ver layout | website }}Template:Main other{{#invoke:Check for conflicting parameters|check | template = Template:Infobox software | cat = Template:Main other | logo size; logo_size | logo class; logo_class | logo alt; logo_alt | logo title; logo_title | logo caption; logo_caption | screenshot size; screenshot_size | screenshot upright; screenshot_upright | screenshot class; screenshot_class | screenshot alt; screenshot_alt | screenshot title; screenshot title | latest release version; latest_release_version | latest release date; latest_release_date | latest preview version; latest_preview_version | latest preview date; latest_preview_date | latest release version; latest_release_version | latest release date; latest_release_date | latest preview version; latest_preview_version | latest preview date; latest_preview_date | programming language; programming_language | operating system; operating_system }} Template:Infobox file format
In the Unix operating system, shar (from "shell archive") is an archive format created with the Unix shar utility. A shar file is a type of self-extracting archive, because it is a valid shell script, and executing it will recreate the files. To extract the files, only the standard Unix Bourne shell sh is usually required.
shar files are also sometimes called "sharchives" (from "/bin/sh archive").[1]
Note that the shar command is not specified by the Single UNIX Specification, so it is not formally a component of Unix, but a legacy utility.
Details
The shar format was developed before the advent of the MIME standard as a way to email one or more files, any of which could be text or binary. At the time, there was no portable way to reliably email a non-text file or a collection of files, e.g., a tar file format archive. Shar was also a common format for distributing software via Usenet, e.g., comp.sources.unix.
Today, MIME is the preferred method for emailing files as the shar format poses a risk due to being executable;[2]. For legacy reasons, GNU provides its own version of shar in the GNU Sharutils collection.
History and variants
James Gosling is credited with writing the first version of the shar utility in 1982,[3]Template:Rp and also wrote an early example (allegedly 1978–79) of the concept in the form of this simple shell script:[4][5][6]
<syntaxhighlight lang="bash">
- shar -- Shell archiver
AR=$1 shift for i do echo a - $i echo "echo x - $i" >>$AR echo "cat >$i <<'!Funky!Stuff!'" >>$AR cat $i >>$AR echo "!Funky!Stuff!" >>$AR done </syntaxhighlight>
The following variants of shar are known:[7]
- shar 1.x (1982) by Gosling. Public domain shell script.
- Current FreeBSD shar. 3-clause BSD license, shell script. Adds md5sum.
- shar2 or xshar (1988) by William Davidsen. Public domain, C program.
- cshar (1984) by Michael A. Thompson and Mark Smith, now lost to bitrot. C program.
- cshar (1988) by Rich Salz, C program. Likely influenced shar 3.49.
- ccshar (1996), a modification to output a csh script instead. Rarely used on Usenet.
GNU <syntaxhighlight lang="text" class="" style="" inline="1">shar</syntaxhighlight> is available as a separate package for Microsoft Windows as part of the UnxUtils collection of native Win32 ports of common GNU Unix-like utilities.[8]
Similar formats
A version of the same concept, but for the VMS operating system, was written in 1987 by Michael Bednarek from the Melbourne Institute of Applied Economic and Social Research as a DCL script, VMS_SHAR.COM.[9] This was later maintained and extended by James A. Gray from Xerox,[10] and Andy Harper from King's College London.[11][12]
makeself (2001–) is a shell script that generates self-extracting tarballs (<syntaxhighlight lang="text" class="" style="" inline="1">*.run</syntaxhighlight>, <syntaxhighlight lang="text" class="" style="" inline="1">application/x-makeself</syntaxhighlight>) using the same shell script header technique. Using tar precludes makeself from being used in plain text directly, but the better compression and other functionalities has made it more popular in the 21st century among software vendors seeking to package Linux software.[13]
See also
References
External links
- Template:Man
- {{#invoke:citation/CS1|citation
|CitationClass=web }}
- ↑ {{#invoke:citation/CS1|citation |CitationClass=web }}
- ↑ {{#invoke:citation/CS1|citation |CitationClass=web }}
- ↑ {{#invoke:citation/CS1|citation |CitationClass=web }}
- ↑ Template:Cite newsgroup
- ↑ {{#invoke:citation/CS1|citation |CitationClass=web }}
- ↑ An almost identical script, 'bundle', is described in The UNIX Programming Environment, Brian Kernighan & Rob Pike, 1984, p. 97
- ↑ {{#invoke:citation/CS1|citation |CitationClass=web }}
- ↑ Native Win32 ports of some GNU utilities
- ↑ Template:Cite newsgroup
- ↑ Template:Cite newsgroup
- ↑ Template:Cite newsgroup
- ↑ Template:Cite newsgroup
- ↑ {{#invoke:citation/CS1|citation |CitationClass=web }}