View Single Post
Old Mar 15th, 2007, 8:02 PM   #1
Mad_guy
Hobbyist Programmer
 
Mad_guy's Avatar
 
Join Date: Oct 2004
Location: Sandstorm, Techno Club
Posts: 239
Rep Power: 4 Mad_guy is on a distinguished road
Send a message via AIM to Mad_guy Send a message via MSN to Mad_guy
Haskell fun: hsh -- a busybox spinoff in haskell

So I was trying to figure out exactly what to do with Haskell, as I wanted to experiance the language. I read Don Stewarts excellent "Programming Haskell" 3 part series and it lead me to try and write clones of unix commands in Haskell. So far my program implements roughly 11 commands.

Examples:
[austin@continuum ~]$ hsh -v
haskell hsh v0.4, compiled with ghc-6.6, on linux-i386
[austin@continuum ~]$ hsh cat < dummy.txt
hi
i'm austin
[austin@continuum ~]$ hsh tac < dummy.txt
i'm austin
hi
[austin@continuum ~]$ hsh wc < dummy.txt
2
[austin@continuum ~]$ hsh uname
Linux continuum 2.6.20-ARCH #1 SMP PREEMPT Sat Mar 10 10:12:25 CET 2007 i686
[austin@continuum ~]$ hsh whereis gcc
gcc: /usr/bin/gcc
[austin@continuum ~]$ hsh ls /tmp
...
[austin@continuum ~]$ echo -e "dont mess with me\ndue" | hsh grep "do"
dont mess with me
[austin@continuum ~]$

It also implements other commands such as rmdir, cp, rm, mv, mvdir (had to seperate the two), etc. (grep is my favorite.)

For anybody just wanting the source code:
http://paste.lisp.org/display/37726#4

If anybody would like to try it out, especially on other compilers (which I would appreciate,) you can get a source tarball here:
http://austin.youareinferior.net/scr...0070315.tar.gz (linux/bsd only)

If you try it, tell me what haskell compiler and version you use; I have only tested this on GHC 6.6 (so any hugs98 or nhc98 users are appreciated.) Compilation instructions are included in the README file, all you need is a Compiler and Cabal (I decided to try it for this and absolutely loved it as a build system. I wish more were like it.)


If anybody wants to try it but doesn't have a Haskell compiler, I'm not giving out binaries right now. I need to clean up the option code *a lot* (I figured out Haskell's Getopt, so I'll use that for the option code in the v0.5 release.) Otherwise, you wouldn't probably really know how to work it without looking at the source (at least that's how I feel.) If anybody wants to upload a .tar.gz with it in the topic, that'd be fine as well.
__________________
os: mac os 10.5.4
revision control: git
editor: emacs

site
Mad_guy is offline   Reply With Quote