Jump to content
 







Main menu
   


Navigation  



Main page
Contents
Current events
Random article
About Wikipedia
Contact us
Donate
 




Contribute  



Help
Learn to edit
Community portal
Recent changes
Upload file
 








Search  

































Create account

Log in
 









Create account
 Log in
 




Pages for logged out editors learn more  



Contributions
Talk
 



















Contents

   



(Top)
 


1 Details  





2 History and variants  





3 Similar formats  





4 See also  





5 References  





6 External links  














shar






Español

Italiano
Українська
 

Edit links
 









Article
Talk
 

















Read
Edit
View history
 








Tools
   


Actions  



Read
Edit
View history
 




General  



What links here
Related changes
Upload file
Special pages
Permanent link
Page information
Cite this page
Get shortened URL
Download QR code
Wikidata item
 




Print/export  



Download as PDF
Printable version
 
















Appearance
   

 






From Wikipedia, the free encyclopedia
 


shar
Original author(s)James Gosling
Developer(s)Various open-source and commercial developers
Operating systemUnix, Unix-like, VMS, Windows
TypeCommand
shar
Filename extension
.shar
Type of formatArchive format, shell script
Open format?Yes[1]

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").[2]

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

[edit]

While the shar format has the advantage of being plain text, it poses a risk due to being executable;[3] 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 may rely on a particular implementation of programs; shell archives created with older versions of makeself,[4] 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.

History and variants

[edit]

James Gosling is credited with writing the first version of the shar utility in 1982,[1]: §1  and also wrote an early example (allegedly 1978-79) of the concept in the form of this simple shell script:[5][6][7]

# 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:[8]

GNU shar 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.[9]

Similar formats

[edit]

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.[10] This was later maintained and extended by James A. Gray from Xerox,[11] and Andy Harper from King's College London.[12][13]

makeself (2001–) is a shell script that generates self-extracting tarballs (*.run, 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.[14]

See also

[edit]

References

[edit]
  1. ^ a b "GNU 'shar' utilities". gnu.org. Free Software Foundation. Retrieved 8 December 2019.
  • ^ "sharchive". ftp.informatik.rwth-aachen.de. Retrieved 2024-01-02.
  • ^ Apple (1993-06-06). "Mac OS X shar(1) Man Page". Apple. Archived from the original on 2009-11-07. Retrieved 2009-11-07.
  • ^ "makeself "trap" command fix". Svn.icculus.org. 2000-11-20. Archived from the original on 2012-07-14. Retrieved 2011-08-30.
  • ^ uw-beave!jim (April 2, 1983). "Re: program to separate xlisp distribution files". Newsgroupnet.sources. message-id:bnews.uw-beave.451. Retrieved March 27, 2017.
  • ^ "shar: a blast from the past". James Gosling: on the Java Road. Archived from the original on March 27, 2017. Retrieved 26 March 2017.
  • ^ An almost identical script, 'bundle', is described in "The UNIX Programming Environment", Kernighan and Pike, 1984, on page 97
  • ^ Dickey, Thomas E. "Comments on Shar/Utils". invisible-island.net.
  • ^ Native Win32 ports of some GNU utilities
  • ^ Michael Bednarek (9 June 1987). "shar (sort of) for VMS". Newsgroupcomp.os.vms. Usenet: 1261@murdu.OZ. Retrieved 2008-02-09.
  • ^ Jim Gray (8 May 1988). "VMS_SHARE V6.0". Newsgroupcomp.os.vms. Usenet: 880508-073131-5929@Xerox. Retrieved 2008-02-09.
  • ^ Andy Harper (6 July 1989). "VMS_SHARE version 7". Newsgroupcomp.os.vms. Usenet: 8907061417.AA16991@ucbvax.Berkeley.EDU. Retrieved 2008-02-09.
  • ^ Andy Harper (5 July 1995). "Announcing VMS_SHARE 8.5". Newsgroupvmsnet.sources.d. Usenet: 1994Jul5.164105.3667@bay.cc.kcl.ac.uk. Retrieved 2008-02-09.
  • ^ "makeself - Make self-extractable archives on Unix".
  • [edit]
    Retrieved from "https://en.wikipedia.org/w/index.php?title=Shar&oldid=1193219120"

    Categories: 
    Unix archivers and compression-related utilities
    Archive formats
    Hidden categories: 
    Articles with short description
    Short description is different from Wikidata
     



    This page was last edited on 2 January 2024, at 17:49 (UTC).

    Text is available under the Creative Commons Attribution-ShareAlike License 4.0; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.



    Privacy policy

    About Wikipedia

    Disclaimers

    Contact Wikipedia

    Code of Conduct

    Developers

    Statistics

    Cookie statement

    Mobile view



    Wikimedia Foundation
    Powered by MediaWiki