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, a ...
operating system
An operating system (OS) is system software that manages computer hardware, software resources, and provides common daemon (computing), services for computer programs.
Time-sharing operating systems scheduler (computing), schedule tasks for ef ...
, shar (an abbreviation of ''shell archive'') is an
archive format 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
A shell script is a computer program designed to be run by a Unix shell, a command-line interpreter. The various dialects of shell scripts are considered to be scripting languages. Typical operations performed by shell scripts include file manip ...
, 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, a ...
Bourne shell
The Bourne shell (sh) is a shell command-line interpreter for computer operating systems.
The Bourne shell was the default shell for Version 7 Unix. Unix-like systems continue to have /bin/sh—which will be the Bourne shell, or a symbolic link ...
''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 limi ...
, it poses a risk due to being
executable
In computing, executable code, an executable file, or an executable program, sometimes simply referred to as an executable or binary, causes a computer "to perform indicated tasks according to encoded instructions", as opposed to a data fil ...
; for this reason the older and more general
tar file format is usually preferred even for transferring text files.
GNU
GNU () is an extensive collection of free software
Free software or libre software is computer software distributed under terms that allow users to run the software for any purpose as well as to study, change, and distribute it and any ...
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 lat ...
'' 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
A shell script is a computer program designed to be run by a Unix shell, a command-line interpreter. The various dialects of shell scripts are considered to be scripting languages. Typical operations performed by shell scripts include file manip ...
.
** Current
FreeBSD
FreeBSD is a free and open-source Unix-like operating system descended from the Berkeley Software Distribution (BSD), which was based on Research Unix. The first version of FreeBSD was released in 1993. In 2005, FreeBSD was the most popular ...
''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 lic ...
, 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
Free software or libre software is computer software distributed under terms that allow users to run the software for any purpose as well as to study, change, and distribute it and any ...
''sharutils''.
GPLv3
The GNU General Public License (GNU GPL or simply GPL) is a series of widely used free software licenses that guarantee end users the four freedoms to run, study, share, and modify the software. The license was the first copyleft for general u ...
, C program.
* ''cshar'' (1984) by Michael A. Thompson and Mark Smith, now lost to bitrot. C program.
* ''cshar'' (1988) by
Rich Salz
InterNetNews (INN) is a Usenet news server package, originally released by Rich Salz in 1991, and presented at the Summer 1992 USENIX conference in San Antonio, Texas. It was the first news server with integrated NNTP functionality.
While p ...
, 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. ...
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 ...
ports of common
GNU
GNU () is an extensive collection of free software
Free software or libre software is computer software distributed under terms that allow users to run the software for any purpose as well as to study, change, and distribute it and any ...
Unix-like utilities.
Similar formats
A version of the same concept, but for the
VMS #REDIRECT VMS
{{redirect category shell, {{R from other capitalisation{{R from ambiguous page ...
operating system, was written in 1987 by Michael Bednarek from
as a
DCL
DCL or may refer to:
* 650 in Roman numerals, see 650 (disambiguation)
Computers
* Data Center Linux, see Open Source Development Labs
* Data Control Language, a subset of SQL
* Dialog Control Language, a language and interpreter within AutoC ...
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 digital document products and services in more than 160 countries. Xerox is headquartered in Norwalk, Connecticut (having moved from St ...
, 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