HsShellScript – Haskell for Unix Shell Scripting Tasks

This is the homepage of the HsShellScript library. It allows to use the Haskell language for tasks which are usually done by shell scripts.

Features

Command Line Arguments Parser
HsShellScript has facilities for managing command line arguments, which are easier to use than the GHC library GetOpt. Command line arguments are specified as lists of properties. HsShellScript builds on top of GHC's GetOpt, but hides it completely. Command line arguments handling has been added because GetOpt seemed too cumbersome.
Easy Interface to External Programs
Calling programs and recognizing errors (via exitcode or exception) is made more easy. There are front end functions for common programs, such as /bin/mv or /bin/chmod.
Analyzing Paths
Dealing with paths is not as trivial as it sounds. Take, for example ../foo.bar//./../baz/ (and split off the extension of the file name...). HsShellScript solves this thoroughly and provides functions for such tasks as splitting a path in directory and file name parts, splitting a path into path components, or syntactically normalising paths.
Redirecting Input and Output
HsShellScript defines operators like ->- and ->>- which work like redirection operators in shells.
Building Pipes
Reading the output of an external program, or piping the output of one program into the input of another, is almost as easy as in shells. HsShellScript provides corresponding operators.
Error Handling
Error handling is one thing which is done more thoroughly in HsShellScript than in shells. Failed programs won't be silently ignored. Exceptions are used for error handling. Non zero exit codes get thrown in the form of expressive RunError exceptions.
Quoting of Strings and Building Commands for Shells
Taking care of shell metacharacters usually isn't done right. HsShellScript provides functions for doing it safely.
Non-broken, Secure Functions for Creating Temporary Files and Directories
The standard C library has mkstemp, mktemp, tempnam, tmpfile and tmpnam, which are all broken, non-portable or unsuitable in some way.

Status

HsShellScript is mature, documented and maintained. Most parts have been tested in use by me since 2004. During that time, changes have mostly been bug fixes and quality improvements, as well as portings to new GHC versions (necessary because of incompatible changes). It should be pretty stable.

However, GHC is a moving target. Over time, there have been a lot of big changes, This always are error sources.

Distribution

The current version of HsShellScript is 3.3.1. It works with GHC-7.4.1, and should also work with later versions. It might work with GHC-7.2, but does not work with GHC-7.0.4 or older.

Please use the current version of GHC (writing this, this is 7.4.1). Older versions contain some serious bugs in conjunction with Unicode.

HsShellScript has been uploaded to Hackage. This means that you can easily install it, with the command cabal install hsshellscript. However, then you won't get the user manual. You can also install it using the source package below. Of course, you can always read the manual online, see "Documentation", below.

Maybe you get the following error message, when you try to unpack HsShellScript, using the command tar xfz hsshellscript-3.3.1.tar.gz:

tar: This does not look like a tar archive
tar: Skipping to next header
tar: Exiting with failure status due to previous errors

This is a bug in the browser, Iceweasel 3.5.16 in my case. Iceweasel is the Debian fork of Firefox. So Firefox should also be affected.

Because of this bug, the archives get compressed another time. You can use another browser (works with Konqueror), or in order to circumvent this problem, save the archive hsshellscript-3.3.1.tar.gz, and do:

mv hsshellscript-3.3.1.tar.gz hsshellscript-3.3.1.tar.gz.gz
gzip -d hsshellscript-3.3.1.tar.gz.gz

hsshellscript-3.3.1.tar.gz

Old Versions:
hsshellscript-3.3.0.tar.gz
hsshellscript-3.2.0.tar.gz
hsshellscript-3.1.0.tar.gz
hsshellscript-3.0.0.tar.gz
hsshellscript-2.8.0.tar.gz
hsshellscript-2.7.1.tar.gz
hsshellscript-2.7.0.tar.gz
hsshellscript-2.6.5.tar.gz
hsshellscript-2.6.4.tar.gz
hsshellscript-2.6.3.tar.gz
hsshellscript-2.6.2.tar.gz
hsshellscript-2.6.1.tar.gz
hsshellscript-2.6.0.tar.gz
hsshellscript-2.5.0.tar.gz
hsshellscript-2.3.0.tar.gz
hsshellscript-2.2.2.tar.gz
hsshellscript-2.2.1.tar.gz
hsshellscript-2.2.0.tar.gz
hsshellscript-2.1.0.tar.gz
hsshellscript-2.0.1.tar.gz
hsunix-1.7.0.tar.gz
hsunix-1.6.1.tar.gz

Changes

3.3.1(released 2012-09-30)
3.3.0(released 2012-09-30)
3.2.0(released 2012-08-28)
3.1.0(released 2012-04-02)
3.0.0 (released 2012-03-12)
2.8.0 (released 2010-01-29)
2.7.1 (released 2006-10-29)
2.7.0 (released 2006-10-21)
2.6.5 (released 2006-10-21)
2.6.4 (released 2006-10-20)
Some code, which is meant for version 2.7, slipped into this release (runprog etc.). These parts aren't quite ready for distribution. Please don't use.
2.6.3 (released 2006-08-14)
2.6.2 (released 2006-07-23)
2.6.1 (released 2006-07-21)
2.6.0 (released 2005-05-04)
2.5.0 (released 2005-04-12)
2.4.1 (released 2005-04-06)
(unuseable because of bugs in the GHC 6.4 libraries)
2.4.0 (released 2005-04-06)
(unuseable because of bugs in the GHC 6.4 libraries)
2.3.0 (released 2005-04-05)
2.2.2 (released 2005-03-17)
2.2.1 (released 2005-03-10)
2.2.0 (released 2005-02-27)
Lots of cleanup, much more solid, some new features, improved doumentation...
2.1.0 (released 2004-10-17)
2.0.1 (released 2004-09-21)
2.0.0 (released 2004-09-21)
1.7.0 (released 2004-09-17)
1.6.1
1.6.0
1.5.0
1.4.0
1.3.0
1.2.0
1.1.0
1.0.5
1.0.4

Documentation

User Manual
API documentation

Contributors

Volker Wysk <hsss volker-wysk de>
Main author
Gregory Wright <gwright antiope com>
Build on MacOS X, port for the Darwinport packaging system
Luis Francisco Araujo <araujo gentoo org>
Maintainer of the Gentoo package for HsShellScript.
Duncan Coutts <dcoutts gentoo org>
Helped to port to GHC 6.6 (build, package management)
(Insert an @-sign and a dot in the email addresses as necessary.)

Please send any bug reports, suggestions or questions to the main author.

License

This is free software, released under the GNU Lesser General Public License (LGPL), version 2.1, or any later version. A copy of the license is included in the user manual.

Related Links

The Glasgow Haskell Compiler
The Haskell Home Page
The Haskell Cabal, A Common Architecture for Building Applications and Tools


Last changed 2012-09-30