Shar Mountains
   HOME

TheInfoList



OR:

In the
Unix Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, an ...
operating system An operating system (OS) is system software that manages computer hardware, software resources, and provides common services for computer programs. Time-sharing operating systems schedule tasks for efficient use of the system and may also i ...
, shar (an abbreviation of ''shell archive'') is an
archive format In computing, an archive file is a computer file that is composed of one or more files along with metadata. Archive files are used to collect multiple data files together into a single file for easier portability and storage, or simply to compress ...
created with the Unix shar utility. A shar file is a type of
self-extracting archive A self-extracting archive (SFX or SEA) is a computer executable program which contains compressed data in an archive file combined with machine-executable program instructions to extract this information on a compatible operating system and ...
, because it is a valid shell script, and executing it will recreate the files. To extract the files, only the standard
Unix Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, an ...
Bourne shell ''sh'' is usually required. 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 In computing, plain text is a loose term for data (e.g. file contents) that represent only characters of readable material but not its graphical representation nor other objects (floating-point numbers, images, etc.). It may also include a limit ...
, it poses a risk due to being executable; for this reason the older and more general
tar file format In computing, tar is a computer software utility for collecting many files into one archive file, often referred to as a tarball, for distribution or backup purposes. The name is derived from "tape archive", as it was originally developed to ...
is usually preferred even for transferring text files.
GNU GNU () is an extensive collection of free software (383 packages as of January 2022), which can be used as an operating system or can be used in parts with other operating systems. The use of the completed GNU tools led to the family of operat ...
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'', for example, the original ''
Unreal Tournament ''Unreal Tournament'' is a first-person arena shooter video game developed by Epic Games and Digital Extremes. The second installment in the '' Unreal'' series, it was first published by GT Interactive in 1999 for Microsoft Windows, and late ...
'' 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.


History and variants

James Gosling James Gosling (born May 19, 1955) is a Canadian computer scientist, best known as the founder and lead designer behind the Java programming language. Gosling was elected a member of the National Academy of Engineering in 2004 for the conception ...
is credited with writing the first version of the ''shar'' utility in 1982, and also wrote an early example (allegedly 1978-79) of the concept in the form of this simple shell script: # 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 The following variants of ''shar'' are known: * ''shar 1.x'' (1982) by Gosling.
Public domain The public domain (PD) consists of all the creative work to which no exclusive intellectual property rights apply. Those rights may have expired, been forfeited, expressly waived, or may be inapplicable. Because those rights have expired, ...
shell script. ** Current FreeBSD ''shar''.
3-clause BSD license BSD licenses are a family of permissive free software licenses, imposing minimal restrictions on the use and distribution of covered software. This is in contrast to copyleft licenses, which have share-alike requirements. The original BSD lice ...
, shell script. Adds md5sum. * ''shar2'' or ''xshar'' (1988) by William Davidsen. Public domain, C program. ** ''shar3'' (1989) by Warren Tucker. *** ''shar 3.49'' (1990) by Richard H. Gumpertz. Adds uuencode support. **** Current
GNU GNU () is an extensive collection of free software (383 packages as of January 2022), which can be used as an operating system or can be used in parts with other operating systems. The use of the completed GNU tools led to the family of operat ...
''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 csh script instead. Rarely used on Usenet. GNU is available as a separate package for Microsoft Windows as part of the
UnxUtils UnxUtils is a collection of ports of common GNU Unix-like utilities to native Win32, with executables only depending on the Microsoft C- runtime msvcrt.dll. The collection was last updated externally on April 15, 2003, by Karl M. Syring. The mo ...
collection of native
Win32 The Windows API, informally WinAPI, is Microsoft's core set of application programming interfaces (APIs) available in the Microsoft Windows operating systems. The name Windows API collectively refers to several different platform implementations th ...
ports A port is a maritime facility comprising one or more wharves or loading areas, where ships load and discharge cargo and passengers. Although usually situated on a sea coast or estuary, ports can also be found far inland, such as H ...
of common
GNU GNU () is an extensive collection of free software (383 packages as of January 2022), which can be used as an operating system or can be used in parts with other operating systems. The use of the completed GNU tools led to the family of operat ...
Unix-like utilities.


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. This was later maintained and extended by James A. Gray from
Xerox Xerox Holdings Corporation (; also known simply as Xerox) is an American corporation that sells print and electronic document, digital document products and services in more than 160 countries. Xerox is headquartered in Norwalk, Connecticut (ha ...
, and Andy Harper from King's College London. ''makeself'' (2001–) is a shell script that generates self-extracting tarballs (, ) 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.


See also

*
List of Unix commands This is a list of Unix commands as specified by IEEE Std 1003.1-2008, which is part of the Single UNIX Specification (SUS). These commands can be found on Unix operating systems and most Unix-like operating systems. List See also * List of G ...


References


External links

*
Information about shar files (Carnegie Mellon)GNU sharutils
{{Archive formats Unix archivers and compression-related utilities Archive formats