Skip to content

Instantly share code, notes, and snippets.

@videlalvaro
Created November 18, 2009 05:18
Show Gist options
  • Save videlalvaro/237580 to your computer and use it in GitHub Desktop.
Save videlalvaro/237580 to your computer and use it in GitHub Desktop.
http://twitter.com/janl brought me into attention about this interesting piece of code: http://www.davispj.com/2009/11/17/unix-in-python.html and this one: http://pwpwp.blogspot.com/2009/11/unix-in-14-lines-of-ruby-its-trivial.html which is implementing a barebones Unix like system in your favorite language
Here's my take on the game which is some pretty basic Haskell
You can run this code by calling runghc unix.lhs
> import System.IO
> main =
> putStrLn "You have no mail" >> loop
> where
> loop = putStr "$ " >> hFlush stdout >> getLine >>= doCommand
> where
> doCommand "uname" = putStrLn "Hunix 0.1" >> loop
> doCommand "halt" = return ()
> doCommand "" = putStrLn "$ " >> loop
> doCommand _ = putStrLn "command not found" >> loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment