<?xml version="1.0"?>
<paste-with-annotations>
  <paste>
    <number>
      <integer>37726</integer>
    </number>
    <user>
      <string>thoughtpolice</string>
    </user>
    <title>
      <string>hsh</string>
    </title>
    <contents>
      <string>-- hsh is a basic haskell shell, a tool written in haskell to mimic shell commands
-- in a basic form
[austin@midgar hsh]$ cat hsh.hs
-- hsh is a basic haskell shell, a tool written in haskell to mimic shell commands
-- in a basic form
module Main where
import System.Environment
import System.Directory
import System.Exit
import System.Info
import Data.Version
import Data.List
import Data.Maybe
import Text.Printf

-- main functions
main = getArgs &gt;&gt;= parse &gt;&gt; succeed

hshversion = printf &quot;haskell hsh v0.01, compiled with %s-%s, running on %s-%s&quot; 
            compilerName (showVersion compilerVersion) os arch &gt;&gt; succeed
usage      = printf &quot;usage: hsh [COMMANDS...] [OPTIONS]\n&quot;


succeed = exitWith ExitSuccess
failure = exitWith (ExitFailure 1)

-- parse functions
-- command options
parse (&quot;cat&quot;:xs)     = cat xs     &gt;&gt; succeed
parse (&quot;tac&quot;:xs)     = tac xs     &gt;&gt; succeed
parse (&quot;ls&quot;:xs)      = ls xs      &gt;&gt; succeed
parse (&quot;wc&quot;:xs)      = wc xs      &gt;&gt; succeed
parse (&quot;whereis&quot;:xs) = whereis xs &gt;&gt; succeed 
--help options and default cases
parse [&quot;-h&quot;]         = usage      &gt;&gt; succeed
parse [&quot;-v&quot;]         = hshversion &gt;&gt; succeed
parse (_:xs)         = usage      &gt;&gt; failure
parse []             = usage      &gt;&gt; failure



-- here are the shell command 'miniatures'

cat xs = interact id
tac xs = interact (unlines . reverse . lines)

ls []     = ls [&quot;.&quot;]
ls (x:xs) = do
              b &lt;- doesDirectoryExist x
              if b == True
                 then do
                       c &lt;- getDirectoryContents x
                       ls2 c
                 else do
                       printf &quot;ls err: directory '%s' does not exist\n&quot; x
                       failure

ls2 []     = succeed
ls2 (x:xs) = putStrLn (x) &gt;&gt; ls2 xs


count s = show (length s) ++ &quot;\n&quot;
wc xs   = interact (count . lines)

whereis (x:_) = do
                  f &lt;- findExecutable x
                  putStrLn (x ++ &quot;: &quot; ++ fromMaybe &quot;could not find executable&quot; f)</string>
    </contents>
    <universal-time>
      <integer>3382056132</integer>
    </universal-time>
    <channel>
      <string>None</string>
    </channel>
    <colorization-mode>
      <string>Haskell</string>
    </colorization-mode>
    <maybe-spam>
      <null/>
    </maybe-spam>
    <is-unicode>
      <null/>
    </is-unicode>
  </paste>
  <annotation>
    <number>
      <integer>4</integer>
    </number>
    <user>
      <string>thoughtpolice</string>
    </user>
    <title>
      <string>hsh v0.4</string>
    </title>
    <contents>
      <string>-- hsh is a basic haskell shell, a tool written in haskell to mimic shell commands
-- in a basic form
module Main where
import System.Environment
import System.Directory
import System.Exit
import System.Info
import System.Posix.Unistd
import Data.Version
import Data.List
import Data.Maybe
import Text.Printf
import Text.Regex

-- main functions
main = getArgs &gt;&gt;= parse &gt;&gt; succeed

hshversion = printf &quot;haskell hsh v0.4, compiled with %s-%s, running on %s-%s\n&quot; 
            compilerName (showVersion compilerVersion) os arch &gt;&gt; succeed
usage      = printf &quot;usage: hsh [COMMANDS...] [OPTIONS]\n&quot;


succeed = exitWith ExitSuccess
failure = exitWith (ExitFailure 1)

-- parse functions
-- command options
parse (&quot;cat&quot;:xs)        = cat xs       &gt;&gt; succeed
parse (&quot;tac&quot;:xs)        = tac xs       &gt;&gt; succeed
parse (&quot;ls&quot;:xs)         = ls xs        &gt;&gt; succeed
parse (&quot;wc&quot;:xs)         = wc xs        &gt;&gt; succeed
parse (&quot;rm&quot;:xs)         = rm xs        &gt;&gt; succeed
parse (&quot;rmdir&quot;:&quot;-r&quot;:xs) = recurmdir xs &gt;&gt; succeed
parse (&quot;rmdir&quot;:xs)      = rmdir xs     &gt;&gt; succeed
parse (&quot;whereis&quot;:xs)    = whereis xs   &gt;&gt; succeed
parse (&quot;mv&quot;:xs)         = mv xs        &gt;&gt; succeed
parse (&quot;mvdir&quot;:xs)      = mvdir xs     &gt;&gt; succeed
parse (&quot;cp&quot;:xs)         = cp xs        &gt;&gt; succeed 
parse (&quot;uname&quot;:xs)      = uname xs     &gt;&gt; succeed
parse (&quot;grep&quot;:x:_)      = grep x       &gt;&gt; succeed

--help options and default cases
parse [&quot;-h&quot;]         = usage      &gt;&gt; succeed
parse [&quot;-v&quot;]         = hshversion &gt;&gt; succeed
parse (_:xs)         = usage      &gt;&gt; failure
parse []             = usage      &gt;&gt; failure



-- here are the shell command 'miniatures'

cat xs = interact id
tac xs = interact (unlines . reverse . lines)

ls []     = ls [&quot;.&quot;]
ls (x:xs) = do
              b &lt;- doesDirectoryExist x
              if b == True
                 then do
                       c &lt;- getDirectoryContents x
                       ls2 c
                 else do
                       printf &quot;ls err: directory '%s' does not exist\n&quot; x
                       failure

ls2 []     = succeed
ls2 (x:xs) = putStrLn (x) &gt;&gt; ls2 xs


count s = show (length s) ++ &quot;\n&quot;
wc xs   = interact (count . lines)

whereis (x:_) = do
                  f &lt;- findExecutable x
                  putStrLn (x ++ &quot;: &quot; ++ fromMaybe &quot;could not find executable&quot; f)

rm []     = succeed
rm (x:xs) = removeFile x &gt;&gt; rm xs

rmdir []     = succeed
rmdir (x:xs) = removeDirectory x &gt;&gt; rmdir xs

recurmdir []     = succeed
recurmdir (x:xs) = removeDirectoryRecursive x &gt;&gt; recurmdir xs

mv []       = succeed
mv [_]      = putStrLn &quot;unmatched amount of options&quot; &gt;&gt; failure
mv (o:n:xs) = renameFile o n &gt;&gt; mv xs

mvdir []       = succeed
mvdir [_]      = putStrLn &quot;unmatched amount of options&quot; &gt;&gt; failure
mvdir (o:n:xs) = renameDirectory o n &gt;&gt; mvdir xs

cp []       = succeed
cp [_]      = putStrLn &quot;unmatched amount of options&quot; &gt;&gt; failure
cp (o:n:xs) = copyFile o n &gt;&gt; cp xs


uname _ = do
           s &lt;- getSystemID
           putStrLn (concat (intersperse &quot; &quot; [systemName s,nodeName s,release s,version s,machine s]))
           succeed

checkword x s = case z of
                  Nothing  -&gt; False
                  Just _   -&gt; True
               where
                z = matchRegex (mkRegex x) s

grep x = interact (unlines . filter (checkword x) . lines)</string>
    </contents>
    <universal-time>
      <integer>3382727182</integer>
    </universal-time>
    <channel>
      <string>None</string>
    </channel>
    <colorization-mode>
      <string></string>
    </colorization-mode>
    <maybe-spam>
      <null/>
    </maybe-spam>
    <is-unicode>
      <null/>
    </is-unicode>
  </annotation>
  <annotation>
    <number>
      <integer>3</integer>
    </number>
    <user>
      <string>thoughtpolice</string>
    </user>
    <title>
      <string>hsh v0.3</string>
    </title>
    <contents>
      <string>-- hsh is a basic haskell shell, a tool written in haskell to mimic shell commands
-- in a basic form
module Main where
import System.Environment
import System.Directory
import System.Exit
import System.Info
import System.Posix.Unistd
import Data.Version
import Data.List
import Data.Maybe
import Text.Printf

-- main functions
main = getArgs &gt;&gt;= parse &gt;&gt; succeed

hshversion = printf &quot;haskell hsh v0.3, compiled with %s-%s, running on %s-%s\n&quot; 
            compilerName (showVersion compilerVersion) os arch &gt;&gt; succeed
usage      = printf &quot;usage: hsh [COMMANDS...] [OPTIONS]\n&quot;


succeed = exitWith ExitSuccess
failure = exitWith (ExitFailure 1)

-- parse functions
-- command options
parse (&quot;cat&quot;:xs)        = cat xs       &gt;&gt; succeed
parse (&quot;tac&quot;:xs)        = tac xs       &gt;&gt; succeed
parse (&quot;ls&quot;:xs)         = ls xs        &gt;&gt; succeed
parse (&quot;wc&quot;:xs)         = wc xs        &gt;&gt; succeed
parse (&quot;rm&quot;:xs)         = rm xs        &gt;&gt; succeed
parse (&quot;rmdir&quot;:&quot;-r&quot;:xs) = recurmdir xs &gt;&gt; succeed
parse (&quot;rmdir&quot;:xs)      = rmdir xs     &gt;&gt; succeed
parse (&quot;whereis&quot;:xs)    = whereis xs   &gt;&gt; succeed
parse (&quot;mv&quot;:xs)         = mv xs        &gt;&gt; succeed
parse (&quot;mvdir&quot;:xs)      = mvdir xs     &gt;&gt; succeed
parse (&quot;cp&quot;:xs)         = cp xs        &gt;&gt; succeed 
parse (&quot;uname&quot;:xs)      = uname xs     &gt;&gt; succeed
--help options and default cases
parse [&quot;-h&quot;]         = usage      &gt;&gt; succeed
parse [&quot;-v&quot;]         = hshversion &gt;&gt; succeed
parse (_:xs)         = usage      &gt;&gt; failure
parse []             = usage      &gt;&gt; failure



-- here are the shell command 'miniatures'

cat xs = interact id
tac xs = interact (unlines . reverse . lines)

ls []     = ls [&quot;.&quot;]
ls (x:xs) = do
              b &lt;- doesDirectoryExist x
              if b == True
                 then do
                       c &lt;- getDirectoryContents x
                       ls2 c
                 else do
                       printf &quot;ls err: directory '%s' does not exist\n&quot; x
                       failure

ls2 []     = succeed
ls2 (x:xs) = putStrLn (x) &gt;&gt; ls2 xs


count s = show (length s) ++ &quot;\n&quot;
wc xs   = interact (count . lines)

whereis (x:_) = do
                  f &lt;- findExecutable x
                  putStrLn (x ++ &quot;: &quot; ++ fromMaybe &quot;could not find executable&quot; f)

rm []     = succeed
rm (x:xs) = removeFile x &gt;&gt; rm xs

rmdir []     = succeed
rmdir (x:xs) = removeDirectory x &gt;&gt; rmdir xs

recurmdir []     = succeed
recurmdir (x:xs) = removeDirectoryRecursive x &gt;&gt; recurmdir xs

mv []       = succeed
mv [_]      = putStrLn &quot;unmatched amount of options&quot; &gt;&gt; failure
mv (o:n:xs) = renameFile o n &gt;&gt; mv xs

mvdir []       = succeed
mvdir [_]      = putStrLn &quot;unmatched amount of options&quot; &gt;&gt; failure
mvdir (o:n:xs) = renameDirectory o n &gt;&gt; mvdir xs

cp []       = succeed
cp [_]      = putStrLn &quot;unmatched amount of options&quot; &gt;&gt; failure
cp (o:n:xs) = copyFile o n &gt;&gt; cp xs


uname _ = do
           s &lt;- getSystemID
           putStrLn (concat (intersperse &quot; &quot; [systemName s,nodeName s,release s,version s,machine s]))
           succeed
</string>
    </contents>
    <universal-time>
      <integer>3382059110</integer>
    </universal-time>
    <channel>
      <string>None</string>
    </channel>
    <colorization-mode>
      <string></string>
    </colorization-mode>
    <maybe-spam>
      <null/>
    </maybe-spam>
    <is-unicode>
      <null/>
    </is-unicode>
  </annotation>
  <annotation>
    <number>
      <integer>2</integer>
    </number>
    <user>
      <string>thoughtpolice</string>
    </user>
    <title>
      <string>hsh v0.2</string>
    </title>
    <contents>
      <string>-- hsh is a basic haskell shell, a tool written in haskell to mimic shell commands
-- in a basic form
module Main where
import System.Environment
import System.Directory
import System.Exit
import System.Info
import Data.Version
import Data.List
import Data.Maybe
import Text.Printf

-- main functions
main = getArgs &gt;&gt;= parse &gt;&gt; succeed

hshversion = printf &quot;haskell hsh v0.01, compiled with %s-%s, running on %s-%s\n&quot; 
            compilerName (showVersion compilerVersion) os arch &gt;&gt; succeed
usage      = printf &quot;usage: hsh [COMMANDS...] [OPTIONS]\n&quot;


succeed = exitWith ExitSuccess
failure = exitWith (ExitFailure 1)

-- parse functions
-- command options
parse (&quot;cat&quot;:xs)        = cat xs       &gt;&gt; succeed
parse (&quot;tac&quot;:xs)        = tac xs       &gt;&gt; succeed
parse (&quot;ls&quot;:xs)         = ls xs        &gt;&gt; succeed
parse (&quot;wc&quot;:xs)         = wc xs        &gt;&gt; succeed
parse (&quot;rm&quot;:xs)         = rm xs        &gt;&gt; succeed
parse (&quot;rmdir&quot;:&quot;-r&quot;:xs) = recurmdir xs &gt;&gt; succeed
parse (&quot;rmdir&quot;:xs)      = rmdir xs     &gt;&gt; succeed
parse (&quot;whereis&quot;:xs)    = whereis xs   &gt;&gt; succeed
parse (&quot;mv&quot;:xs)         = mv xs        &gt;&gt; succeed
parse (&quot;mvdir&quot;:xs)      = mvdir xs     &gt;&gt; succeed
parse (&quot;cp&quot;:xs)         = cp xs        &gt;&gt; succeed 
--help options and default cases
parse [&quot;-h&quot;]         = usage      &gt;&gt; succeed
parse [&quot;-v&quot;]         = hshversion &gt;&gt; succeed
parse (_:xs)         = usage      &gt;&gt; failure
parse []             = usage      &gt;&gt; failure



-- here are the shell command 'miniatures'

cat xs = interact id
tac xs = interact (unlines . reverse . lines)

ls []     = ls [&quot;.&quot;]
ls (x:xs) = do
              b &lt;- doesDirectoryExist x
              if b == True
                 then do
                       c &lt;- getDirectoryContents x
                       ls2 c
                 else do
                       printf &quot;ls err: directory '%s' does not exist\n&quot; x
                       failure

ls2 []     = succeed
ls2 (x:xs) = putStrLn (x) &gt;&gt; ls2 xs


count s = show (length s) ++ &quot;\n&quot;
wc xs   = interact (count . lines)

whereis (x:_) = do
                  f &lt;- findExecutable x
                  putStrLn (x ++ &quot;: &quot; ++ fromMaybe &quot;could not find executable&quot; f)

rm []     = succeed
rm (x:xs) = removeFile x &gt;&gt; rm xs

rmdir []     = succeed
rmdir (x:xs) = removeDirectory x &gt;&gt; rmdir xs

recurmdir []     = succeed
recurmdir (x:xs) = removeDirectoryRecursive x &gt;&gt; recurmdir xs

mv []       = succeed
mv [_]      = putStrLn &quot;unmatched amount of options&quot; &gt;&gt; failure
mv (o:n:xs) = renameFile o n &gt;&gt; mv xs

mvdir []       = succeed
mvdir [_]      = putStrLn &quot;unmatched amount of options&quot; &gt;&gt; failure
mvdir (o:n:xs) = renameDirectory o n &gt;&gt; mvdir xs

cp []       = succeed
cp [_]      = putStrLn &quot;unmatched amount of options&quot; &gt;&gt; failure
cp (o:n:xs) = copyFile o n &gt;&gt; cp xs</string>
    </contents>
    <universal-time>
      <integer>3382058008</integer>
    </universal-time>
    <channel>
      <string>None</string>
    </channel>
    <colorization-mode>
      <string></string>
    </colorization-mode>
    <maybe-spam>
      <null/>
    </maybe-spam>
    <is-unicode>
      <null/>
    </is-unicode>
  </annotation>
  <annotation>
    <number>
      <integer>1</integer>
    </number>
    <user>
      <string>thoughtpolice</string>
    </user>
    <title>
      <string>hsh</string>
    </title>
    <contents>
      <string>-- hsh is a basic haskell shell, a tool written in haskell to mimic shell commands
-- in a basic form
module Main where
import System.Environment
import System.Directory
import System.Exit
import System.Info
import Data.Version
import Data.List
import Data.Maybe
import Text.Printf

-- main functions
main = getArgs &gt;&gt;= parse &gt;&gt; succeed

hshversion = printf &quot;haskell hsh v0.01, compiled with %s-%s, running on %s-%s&quot; 
            compilerName (showVersion compilerVersion) os arch &gt;&gt; succeed
usage      = printf &quot;usage: hsh [COMMANDS...] [OPTIONS]\n&quot;


succeed = exitWith ExitSuccess
failure = exitWith (ExitFailure 1)

-- parse functions
-- command options
parse (&quot;cat&quot;:xs)     = cat xs     &gt;&gt; succeed
parse (&quot;tac&quot;:xs)     = tac xs     &gt;&gt; succeed
parse (&quot;ls&quot;:xs)      = ls xs      &gt;&gt; succeed
parse (&quot;wc&quot;:xs)      = wc xs      &gt;&gt; succeed
parse (&quot;whereis&quot;:xs) = whereis xs &gt;&gt; succeed 
--help options and default cases
parse [&quot;-h&quot;]         = usage      &gt;&gt; succeed
parse [&quot;-v&quot;]         = hshversion &gt;&gt; succeed
parse (_:xs)         = usage      &gt;&gt; failure
parse []             = usage      &gt;&gt; failure



-- here are the shell command 'miniatures'

cat xs = interact id
tac xs = interact (unlines . reverse . lines)

ls []     = ls [&quot;.&quot;]
ls (x:xs) = do
              b &lt;- doesDirectoryExist x
              if b == True
                 then do
                       c &lt;- getDirectoryContents x
                       ls2 c
                 else do
                       printf &quot;ls err: directory '%s' does not exist\n&quot; x
                       failure

ls2 []     = succeed
ls2 (x:xs) = putStrLn (x) &gt;&gt; ls2 xs


count s = show (length s) ++ &quot;\n&quot;
wc xs   = interact (count . lines)

whereis (x:_) = do
                  f &lt;- findExecutable x
                  putStrLn (x ++ &quot;: &quot; ++ fromMaybe &quot;could not find executable&quot; f)</string>
    </contents>
    <universal-time>
      <integer>3382056179</integer>
    </universal-time>
    <channel>
      <string>None</string>
    </channel>
    <colorization-mode>
      <string></string>
    </colorization-mode>
    <maybe-spam>
      <null/>
    </maybe-spam>
    <is-unicode>
      <null/>
    </is-unicode>
  </annotation>
</paste-with-annotations>