Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Shar (file format)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Unix file format}} {{Lowercase}} {{Infobox software | name = shar | logo = | screenshot = | screenshot size = | caption = | author = [[James Gosling]] | developer = Various [[open-source software|open-source]] and [[commercial software|commercial]] developers | released = | latest release version = | latest release date = | operating system = [[Unix]], [[Unix-like]], [[OpenVMS|VMS]], [[Microsoft Windows|Windows]] | genre = [[Command (computing)|Command]] | license = | website = }} {{Infobox file format | name = shar | icon = | logo = | screenshot = | caption = | extension = .shar | mime = | type code = | uniform type = | magic = | owner = | released = | latest release version = | latest release date = | genre = [[Archive format]], [[shell script]] | container for = | contained by = | extended from = | extended to = | standard = | url = | open = Yes<ref name=gnu /> }} In the [[Unix]] [[operating system]], '''shar''' (from "shell archive") is an [[archive format]] created with the Unix <code>shar</code> 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").<ref>{{ Cite web | access-date=2024-01-02 | title=sharchive | url=http://ftp.informatik.rwth-aachen.de/jargon300/sharchive.html | website=ftp.informatik.rwth-aachen.de }}</ref> 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== While the shar format has the advantage of being [[plain text]], it poses a risk due to being [[executable]];<ref>{{ Cite web | access-date=2009-11-07 | archive-date=2009-11-07 | archive-url=https://web.archive.org/web/20091107190211/http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man1/shar.1.html | author=Apple | date=1993-06-06 | publisher=Apple | title=Mac OS X shar(1) Man Page | url-status=dead | url=https://developer.apple.com/mac/library/DOCUMENTATION/Darwin/Reference/ManPages/man1/shar.1.html }}</ref> for this reason the older and more general [[Tar (file format)|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 may rely on a particular implementation of programs; shell archives created with older versions of ''makeself'',<ref>{{cite web |url=http://svn.icculus.org/loki_setup/trunk/makeself/makeself.sh?r1=303&r2=304 |archive-url=https://archive.today/20120714133930/http://svn.icculus.org/loki_setup/trunk/makeself/makeself.sh?r1=303&r2=304 |url-status=dead |archive-date=2012-07-14 |title=makeself "trap" command fix |publisher=Svn.icculus.org |date=2000-11-20 |access-date=2011-08-30 }}</ref> 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 <code>trap</code> [[shell builtin|built-in command]] are handled. ==History and variants== [[James Gosling]] is credited with writing the first version of the ''shar'' utility in 1982,<ref name=gnu>{{cite web|title=GNU 'shar' utilities|url=https://www.gnu.org/software/sharutils/manual/sharutils.html|website=gnu.org|publisher=Free Software Foundation|access-date=8 December 2019}}</ref>{{rp|at=Β§1}} and also wrote an early example (allegedly 1978-79) of the concept in the form of this simple shell script:<ref>{{ Cite newsgroup | access-date=March 27, 2017 | author=uw-beave!jim | date=April 2, 1983 | id=message-id:bnews.uw-beave.451|url=https://groups.google.com/forum/#!original/net.sources/HqA3E612vNg/vCiJELRlTGgJ | newsgroup=net.sources | title=Re: program to separate xlisp distribution files }}</ref><ref name=jag>{{cite web|title=shar: a blast from the past|url=https://blogs.oracle.com/jag/entry/shar_a_blast_from_the|website=James Gosling: on the Java Road|access-date=26 March 2017|archiveurl=https://web.archive.org/web/20170327173633/https://blogs.oracle.com/jag/entry/shar_a_blast_from_the|archivedate=March 27, 2017}}</ref><ref>An almost identical script, 'bundle', is described in "The UNIX Programming Environment", Kernighan and Pike, 1984, on page 97</ref> <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:<ref name="Dickey">{{cite web |last1=Dickey |first1=Thomas E. |title=Comments on Shar/Utils |url=https://invisible-island.net/personal/sharutils.html |website=invisible-island.net}}</ref> * ''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 (programming language)|C]] program. ** ''shar3'' (1989) by Warren Tucker. *** ''shar 3.49'' (1990) by Richard H. Gumpertz. Adds [[uuencode]] support. **** Current [[GNU]] ''sharutils''. [[GPLv3]], 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 [[C shell|csh]] script instead. Rarely used on Usenet. GNU {{code|shar}} is available as a separate package for [[Microsoft Windows]] as part of the [[UnxUtils]] collection of [[Native (computing)|native]] [[Windows API|Win32]] [[porting|ports]] of common [[GNU]] Unix-like utilities.<ref>[http://unxutils.sourceforge.net/ Native Win32 ports of some GNU utilities]</ref> ==Similar formats== A version of the same concept, but for the [[OpenVMS|VMS]] operating system, was written in 1987 by Michael Bednarek from [[The Melbourne Institute of Applied Economic and Social Research]] as a [[DIGITAL Command Language|DCL]] script, VMS_SHAR.COM.<ref>{{ Cite newsgroup | access-date = 2024-09-04 | author = Michael Bednarek | date = 9 June 1987 | message-id= 1261@murdu.OZ | newsgroup = comp.os.vms | title = shar (sort of) for VMS | url = https://groups.google.com/g/comp.os.vms/c/uLrc-7zo5iU/m/L7S0I8gjpJsJ }}</ref> This was later maintained and extended by James A. Gray from [[Xerox]],<ref>{{ Cite newsgroup | access-date = 2024-09-04 | author = Jim Gray | date = 8 May 1988 | message-id= 880508-073131-5929@Xerox | newsgroup = comp.os.vms | title = VMS_SHARE V6.0 | url = https://groups.google.com/g/comp.os.vms/c/aMlcSF1L5vU/m/08pfx38YqlEJ }}</ref> and Andy Harper from [[King's College London]].<ref>{{ Cite newsgroup | access-date = 2024-09-04 | author = Andy Harper | date = 7 July 1989 | message-id= 8907061417.AA16991@ucbvax.Berkeley.EDU | newsgroup = comp.os.vms | title = VMS_SHARE version 7 | url = https://groups.google.com/g/comp.os.vms/c/UCt6eBKcNwM/m/1Ra3iZe18xAJ }}</ref><ref>{{ Cite newsgroup | access-date = 2024-09-04 | author = Andy Harper | date = 6 July 1995 | message-id= 1994Jul5.164105.3667@bay.cc.kcl.ac.uk | newsgroup = vmsnet.sources.d | title = Announcing VMS_SHARE 8.5 | url = https://groups.google.com/g/vmsnet.sources.d/c/kNWtBG94U6g/m/Wp5CKqY-6swJ }}</ref> ''makeself'' (2001–) is a shell script that generates self-extracting [[tar (computing)|tarball]]s ({{code|*.run}}, {{code|application/x-makeself}}) 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.<ref name=makeself>{{cite web |title=makeself β Make self-extractable archives on Unix |url=https://makeself.io}}</ref> ==See also== * [[List of Unix commands]] ==References== {{Reflist}} ==External links== * {{Man|1|shar|ManKier}} * [https://archive.today/20121214142744/http://lib.stat.cmu.edu/general/shar Information about shar files (Carnegie Mellon)] * [https://www.gnu.org/software/sharutils/ GNU sharutils] {{Archive formats}} [[Category:Unix archivers and compression-related utilities]] [[Category:Archive formats]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Archive formats
(
edit
)
Template:Cite newsgroup
(
edit
)
Template:Cite web
(
edit
)
Template:Code
(
edit
)
Template:Infobox
(
edit
)
Template:Infobox file format
(
edit
)
Template:Infobox software
(
edit
)
Template:Lowercase
(
edit
)
Template:Main other
(
edit
)
Template:Man
(
edit
)
Template:Reflist
(
edit
)
Template:Rp
(
edit
)
Template:Short description
(
edit
)
Template:Template other
(
edit
)