diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,5 @@
 CFLAGS = -XScopedTypeVariables
+VERSION = 3.3.0
 
 default :: lib
 
@@ -6,24 +7,29 @@
 	cabal configure
 	cabal build
 	cabal haddock
-	cabal install
 
-build :: dist/build/libHShsshellscript-3.2.0.a
+install-user ::
+	cabal install --user
 
-dist/build/libHShsshellscript-3.2.0.a :: 
+install-global ::
+	sudo cabal install --global
+
+build :: dist/build/libHShsshellscript-$(VERSION).a
+
+dist/build/libHShsshellscript-$(VERSION).a :: 
 	cabal build
 
 dist ::
 	cabal sdist
 
 install-manual ::
-	mkdir -p /usr/local/share/hsshellscript/manual
-	cp -rv manual/* /usr/local/share/hsshellscript/manual
-	rm -f /usr/local/share/hsshellscript/manual/*~
+	sudo mkdir -p /usr/local/share/hsshellscript/manual
+	sudo cp -rv manual/* /usr/local/share/hsshellscript/manual
+	sudo rm -f /usr/local/share/hsshellscript/manual/*~
 
 uninstall-manual ::
-	rm -rf /usr/local/share/hsshellscript/manual
-	rmdir --ignore-fail-on-non-empty /usr/local/share/hsshellscript 
+	sudo rm -rf /usr/local/share/hsshellscript/manual
+	sudo rmdir --ignore-fail-on-non-empty /usr/local/share/hsshellscript 
 
 doc ::
 	cabal haddock
diff --git a/hsshellscript.cabal b/hsshellscript.cabal
--- a/hsshellscript.cabal
+++ b/hsshellscript.cabal
@@ -1,5 +1,5 @@
 Name:                hsshellscript
-Version:             3.2.0
+Version:             3.3.0
 Synopsis:            Haskell for Unix shell scripting tasks
 Description:         A Haskell-library for tasks which are usually done in
                      shell scripts. This includes parsing command line
@@ -15,7 +15,7 @@
 Copyright:           (c)2004-2011 by Volker Wysk
 Category:            System
 Build-type:          Simple
-Extra-source-files:  README, manual/*.html, manual/LICENSE, Makefile, test/*.hs
+Extra-source-files:  README, manual/*.html, manual/LICENSE, Makefile, test/*.hs, test/Makefile
 
 cabal-version:       >= 1.6
 
diff --git a/manual/install.html b/manual/install.html
--- a/manual/install.html
+++ b/manual/install.html
@@ -15,17 +15,24 @@
   Makefile, which further simplifies the installation.
 
 <p>In order to install, unpack the source distribution somewhere. Go to the
-  directory, and call <tt>make</tt>. This will compile and install the library,
-  locally, as a user package. The location of the API documentation
-  is <tt>~/.cabal/share/doc/hsshellscript-3.2.0/html/index.html</tt>.
+  directory, and call <tt>make</tt>. This will compile the library. If you want
+  to install it locally, in your user account, then do <tt>make
+  install-user</tt>. This calls <tt>cabal install --user</tt>. If you want to
+  install the library globally, do <tt>make install-global</tt>. You will be
+  prompted for the root password, which is needed in this case. This
+  calls <tt>sudo cabal install --global</tt>.
 
+<p>If installed as a user package, then the location of the API documentation
+  is <tt>~/.cabal/share/doc/hsshellscript-3.3.0/html/index.html</tt>. If it is
+  installed globaly, it
+  is <tt>/usr/local/share/doc/hsshellscript-3.3.0/html/index.html</tt>. 
+
 <p>Cabal's Simple Build Infrastructure doesn't provide any means to add extra
   documenation to a project. Therefore the user manual isn't installed by default.
   If you need it, you can just copy the "manual" directory anywhere you like,
   but the Makefile privides
   the make target <tt>install-manual</tt>, which copies the files to
   <tt>/usr/local/share/hsshellscript/manual</tt>.
-  "<tt>make</tt>" must be run as root.
 
 
 <p>Further information about the Cabal can be found here:
diff --git a/src/HsShellScript/ProcErr.chs b/src/HsShellScript/ProcErr.chs
--- a/src/HsShellScript/ProcErr.chs
+++ b/src/HsShellScript/ProcErr.chs
@@ -490,6 +490,10 @@
    /The exit code of q is silently ignored./ The process ID of the forked
    copy of @q@ isn't returned to the caller, so it's lost.
 
+   The pipe, which connects @p@ and @q@, is in /text mode/. This means that the 
+   output of @p@ is converted from Unicode to the system character set, which 
+   is determined by the environment variable @LANG@.
+
    See "HsShellScript#subr" and
    "HsShellScript#exec" for further details.
 
@@ -504,7 +508,7 @@
    >          )
    >     )
 
-   See 'subproc', '(=|-)', '(-|=)'.
+   See 'subproc', '(=|-)', '(-|=)', 'redirect'
 -}
 (-|-) :: IO a   -- ^ Action which won't be forked
       -> IO b   -- ^ Action which will be forked and connected with a pipe
@@ -530,6 +534,10 @@
    /The exit code of q is silently ignored./ The process ID of the forked
    copy of @q@ isn't returned to the caller, so it's lost.
 
+   The pipe, which connects @p@ and @q@, is in /text mode/. This means that the 
+   output of @p@ is converted from Unicode to the system character set, which 
+   is determined by the environment variable @LANG@.
+
    See "HsShellScript#subr" and
    "HsShellScript#exec" for further details.
 
@@ -564,6 +572,10 @@
    /The exit code of p is silently ignored./ The process ID of the forked
    copy of @q@ isn't returned to the caller, so it's lost.
 
+   The pipe, which connects @p@ and @q@, is in /text mode/. This means that the 
+   output of @p@ is converted from Unicode to the system character set, which 
+   is determined by the environment variable @LANG@.
+
    See "HsShellScript#subr" and
    "HsShellScript#exec" for further details.
 
@@ -597,6 +609,10 @@
    /The exit code of p is silently ignored./ The process ID of the forked
    copy of @q@ isn't returned to the caller, so it's lost.
 
+   The pipe, which connects @p@ and @q@, is in /text mode/. This means that the 
+   output of @p@ is converted from Unicode to the system character set, which 
+   is determined by the environment variable @LANG@.
+
    See "HsShellScript#subr" and
    "HsShellScript#exec" for further details.
 
@@ -647,6 +663,15 @@
 
 redirect_helper stdh mode io path = do
    h <- openFile path mode
+
+   -- The file in a redirection is accessed in /text mode/, If stdout or stderr
+   -- are redirected, this means that output is converted from ghc's Unicode to
+   -- the system character set. If stdin is redirected, this means that data
+   -- read from the file is converted from the system character set to ghc's
+   -- Unicode. The system character set is taken from the environment variable
+   -- LANG.
+   hSetBinaryMode h False
+
    res <- redirect stdh h io
    hClose h
    return res
@@ -658,9 +683,13 @@
 @exec@ functions know about this. See "HsShellScript#fdpipes" and
 "HsShellScript#exec" for details.
 
+The file is written in /text mode/. This means that the
+output is converted from Unicode to the system character set, which
+is determined by the environment variable @LANG@.
+
 Example:
 
->run "/some/program" [] ->- "/tmp/output"
+>runprog "/some/program" [] ->- "/tmp/output"
 
 Note: You can't redirect to @\"\/dev\/null\"@ this way, because GHC 6.4's @openFile@ throws an \"invalid argument\"
 IOError. (This may be a bug in the GHC 6.4 libraries). Use @->>-@ instead.
@@ -670,8 +699,8 @@
 (->-) :: IO a           -- ^ Action, whose output will be redirected
       -> FilePath       -- ^ File to redirect the output to
       -> IO a           -- ^ Result action
-(->-) =
-   redirect_helper stdout WriteMode
+(->-) io path =
+   redirect_helper stdout WriteMode io path
 
 
 {- | Redirect the standard output of the specified IO action to a file. If the file already exists, the output will be appended.
@@ -680,6 +709,10 @@
 @exec@ functions know about this. See "HsShellScript#fdpipes" and
 "HsShellScript#exec" for details.
 
+The file is written in /text mode/. This means that the
+output is converted from Unicode to the system character set, which
+is determined by the environment variable @LANG@.
+
 Example:
 
 >run "/some/noisy/program" [] ->>- "/dev/null"
@@ -689,8 +722,8 @@
 (->>-) :: IO a          -- ^ Action, whose output will be redirected
        -> FilePath      -- ^ File to redirect the output to
        -> IO a          -- ^ Result action
-(->>-) =
-   redirect_helper stdout AppendMode
+(->>-) io path =
+   redirect_helper stdout AppendMode io path
 
 
 {- | Redirect the standard error output of the specified IO action to a file. If the file already exists, it will be overwritten.
@@ -702,6 +735,10 @@
 Note: You can't redirect to @\"\/dev\/null\"@ this way, because GHC 6.4's @openFile@ throws an \"invalid argument\"
 IOError. (This may be a bug in the GHC 6.4 libraries). Use @=>>-@ instead.
 
+The file is written in /text mode/. This means that the
+output is converted from Unicode to the system character set, which
+is determined by the environment variable @LANG@.
+
 Example:
 
 >run "/path/to/foo" [] =>- "/tmp/errlog"
@@ -721,6 +758,10 @@
 @exec@ functions know about this. See "HsShellScript#fdpipes" and
 "HsShellScript#exec" for details.
 
+The file is written in /text mode/. This means that the
+output is converted from Unicode to the system character set, which
+is determined by the environment variable @LANG@.
+
 Example:
 
 >run "/some/program" [] =>>- "/dev/null"
@@ -745,6 +786,10 @@
 Note: You can't redirect to @\"\/dev\/null\"@ this way, because GHC 6.4's @openFile@ throws an \"invalid argument\"
 IOError. (This may be a bug in the GHC 6.4 libraries). Use @-&>>-@ instead.
 
+The file is written in /text mode/. This means that the
+output is converted from Unicode to the system character set, which
+is determined by the environment variable @LANG@.
+
 >(-&>-) io path = err_to_out io ->- path
 
 Example:
@@ -767,6 +812,10 @@
 "HsShellScript#fdpipes" and
 "HsShellScript#exec" for details.
 
+The file is written in /text mode/. This means that the
+output is converted from Unicode to the system character set, which
+is determined by the environment variable @LANG@.
+
 >(-&>>-) io path = (err_to_out >> io) ->>- path
 
 Example:
@@ -790,6 +839,10 @@
    "HsShellScript#fdpipes" and
 "HsShellScript#exec" for details.
 
+The file is read in /text mode/. This means that the input is converted from the
+system character set to Unicode. The system's character set is determined by the
+environment variable @LANG@.
+
 Example:
 
 @call (exec \"\/path\/to\/foo\" [] -\<- \"bar\")@
@@ -897,6 +950,8 @@
          do closeFd (if read then readend else writeend)
             let fd = if read then writeend else readend
             h <- System.Posix.fdToHandle fd
+            -- Use Text mode for the new handle by default.
+            hSetBinaryMode h False
             return (Just h)
 
 
@@ -927,6 +982,12 @@
 -- that no resources, which have been duplicated by the fork, cause problems.
 -- See "HsShellScript#subr" for details.
 --
+-- The pipe is set to /text mode/. This means that the Unicode characters in
+-- the text are converted to the system character set. If you need to pipe binary
+-- data, you should use @h_pipe_to@, and set the returned handle to binary
+-- mode. This is accomplished by @'hSetBinaryMode' h True@. The system
+-- character set is determined by the environment variable @LANG@.
+--
 -- Example:
 --
 -- >pipe_to "blah" (exec "/usr/bin/foo" ["bar"])
@@ -969,7 +1030,7 @@
 -- the returned file handle.
 --
 -- This gives you full control of the pipe, and of the forked process. But you
--- must cope with the child process by yourself. 
+-- must cope with the child process by yourself.
 --
 -- Unless you replace the child process, calling an @exec@ variant, the child
 -- should let the control flow leave the action normally.
@@ -990,6 +1051,11 @@
 -- corresponding @ProcessStatus@ is returned by @getProcessStatus@. See
 -- 'System.Posix.Process.getProcessStatus' for details.
 --
+-- The pipe is set to /text mode/. This means that the Unicode characters in the
+-- text are converted to the system character set. You can set the returned
+-- handle to binary mode, by calling @'hSetBinaryMode' handle True@. The system
+-- character set is determined by the environment variable @LANG@.
+--
 -- Example:
 --
 -- >(handle, pid) <- h_pipe_to $ exec "/usr/bin/foo" ["bar"]
@@ -1042,6 +1108,13 @@
 -- newline characters. The entire output of the action is returned. You might want
 -- to apply @chomp@ to the result.
 --
+-- The pipe is set to /text mode/. This means that the Unicode characters in the
+-- text, which is read from stdin, is converted from the system character set to
+-- Unicode. The system character set is determined by the environment variable
+-- @LANG@. If you need to read binary data from the forked process, you should use
+-- @h_pipe_from@ and set the returned handle to binary mode. This is
+-- accomplished by @'hSetBinaryMode' h True@.
+--
 -- Example:
 --
 -- >output <- pipe_from $ exec "/bin/mount" []
@@ -1116,6 +1189,13 @@
 -- newline characters. The entire error output of the action is returned. You might want
 -- to apply @chomp@ to the result.
 --
+-- The pipe is set to /text mode/. This means that the Unicode characters in the
+-- text, which is read from stdin, is converted from the system character set to
+-- Unicode. The system character set is determined by the environment variable
+-- @LANG@. If you need to read binary data from the forked process, you should use
+-- @h_pipe_from@ and set the returned handle to binary mode. This is
+-- accomplished by @'hSetBinaryMode' h True@.
+--
 -- Example:
 --
 -- >output <- pipe_from $ exec "/bin/mount" []
@@ -1156,7 +1236,7 @@
 -- the returned file handle.
 --
 -- This gives you full control of the pipe, and of the forked process. But you
--- must cope with the child process by yourself. 
+-- must cope with the child process by yourself.
 --
 -- When you call @getProcessStatus@ blockingly, you must first ensure that all
 -- data has been read, or close the handle. Otherwise you'll get a deadlock.
@@ -1178,6 +1258,13 @@
 -- @ArgError@, @ProcessStatus@, @RunError@, @IOError@ and @ExitCode@. Other
 -- exceptions result in the generic message, as produced by @show@.
 --
+-- The pipe is set to /text mode/. This means that the Unicode characters in the
+-- text, which is read from stdin, is converted from the system character set to
+-- Unicode. The system character set is determined by the environment variable
+-- @LANG@. If you need to read binary data from the forked process, you can set
+-- the returned handle to binary mode. This is accomplished by @'hSetBinaryMode'
+-- h True@.
+--
 -- Example:
 --
 -- >(h,pid) <- h_pipe_from $ exec "/usr/bin/foo" ["bar"]
@@ -1200,7 +1287,7 @@
 -- the returned file handle.
 --
 -- This gives you full control of the pipe, and of the forked process. But you
--- must cope with the child process by yourself. 
+-- must cope with the child process by yourself.
 --
 -- When you call @getProcessStatus@ blockingly, you must first ensure that all
 -- data has been read, or close the handle. Otherwise you'll get a deadlock.
@@ -1222,6 +1309,13 @@
 -- @ArgError@, @ProcessStatus@, @RunError@, @IOError@ and @ExitCode@. Other
 -- exceptions result in the generic message, as produced by @show@.
 --
+-- The pipe is set to /text mode/. This means that the Unicode characters in the
+-- text, which is read from stdin, is converted from the system character set to
+-- Unicode. The system character set is determined by the environment variable
+-- @LANG@. If you need to read binary data from the forked process, you can set
+-- the returned handle to binary mode. This is accomplished by @'hSetBinaryMode'
+-- h True@.
+--
 -- Example:
 --
 -- >(h,pid) <- h_pipe_from $ exec "/usr/bin/foo" ["bar"]
@@ -1240,7 +1334,7 @@
 -- | Run an IO action in a separate process, and read its standard output, The output
 -- is read lazily, as the returned string is evaluated. The child's output along
 -- with its process ID are returned.
--- 
+--
 -- This forks a child process, which executes the specified action. The output
 -- of the child is read lazily through a pipe, which connncts to its standard
 -- output. In case the child replaces the process by calling an @exec@ variant,
@@ -1261,17 +1355,17 @@
 -- descriptor, even when the pipe is closed on the child side. When you do that
 -- repeatedly, you may run out of file descriptors.
 --
--- Unless you're sure that your program will reach the string's end, you should 
+-- Unless you're sure that your program will reach the string's end, you should
 -- take care for it explicitly, by doing something like this:
 --
 -- >(output, pid) <- lazy_pipe_from (exec "\/usr\/bin\/foobar" [])
 -- >...
--- >seq (length output) (return ())   
+-- >seq (length output) (return ())
 --
 -- This will read the entire standard output of the child, even if it isn't
 -- needed. You can't cut the child process' output short, when you use
--- @lazy_pipe_from@. If you need to do this, you should use @h_pipe_from@, which 
--- gives you the handle, which can then be closed by 'System.IO.hClose', even 
+-- @lazy_pipe_from@. If you need to do this, you should use @h_pipe_from@, which
+-- gives you the handle, which can then be closed by 'System.IO.hClose', even
 -- if the child's output isn't completed:
 --
 -- >(h, pid) <- h_pipe_from io
@@ -1280,24 +1374,24 @@
 -- >output <- hGetContents h
 -- >...
 -- >-- Not eveyting read yet, but cut io short.
--- >hClose h   
+-- >hClose h
 -- >
 -- >-- Wait for io to finish, and detect errors
 -- >(Just ps) <- System.Posix.getProcessStatus True False pid
 -- >when (ps /= Exited ExitSuccess) $
 -- >   throw ps
---   
+--
 -- When you close the handle before all data has been read, then the child gets
 -- a @SIGPIPE@ signal.
--- 
+--
 -- After all the output has been read, you should call @getProcessStatus@ on the
 -- child's process ID, in order to detect errors. Be aware that you must
 -- evaluate the whole string, before calling @getProcessStatus@ blockingly, or
 -- you'll get a deadlock.
---   
--- You won't get an exception, if the child action exits in a way which 
--- indicates an error. Errors occur asynchronously, when the output string is 
--- evaluated. You must detect errors by yourself, by calling 
+--
+-- You won't get an exception, if the child action exits in a way which
+-- indicates an error. Errors occur asynchronously, when the output string is
+-- evaluated. You must detect errors by yourself, by calling
 -- 'System.Posix.Process.getProcessStatus'.
 --
 -- In case the action doesn't replace the child process with an external
@@ -1317,7 +1411,24 @@
 -- Unlike shells\' backquote feature, @lazy_pipe_from@ does not remove any trailing
 -- newline characters. The entire output of the action is returned. You might want
 -- to apply @chomp@ to the result.
---   
+--
+-- The pipe is set to /text mode/. This means that the Unicode characters in the
+-- text, which is read from the IO action's stdout, are converted from the system
+-- character set to Unicode. The system character set is determined by the
+-- environment variable @LANG@. If you need to read binary data from the forked
+-- process, you should use h_pipe_from and set the returned handle to binary mode.
+-- This is accomplished by @'hSetBinaryMode' h True@. Then you can lazily read 
+-- the output of the action from the handle.
+--
+-- Example: Lazily read binary data from an IO action. Don't forget to collect 
+-- the child process later, using @'System.Posix.getProcessStatus' True False pid@.
+--
+-- >(h, pid) <- h_pipe_from io
+-- >hSetBinaryMode h True
+-- >txt <- hGetContents h
+-- >...
+-- >(Just ps) <- System.Posix.getProcessStatus True False pid
+--
 -- See 'exec', 'pipe_to', 'pipe_from', 'h_pipe_from', 'lazy_pipe_from2', 'silently'.
 lazy_pipe_from :: IO a                          -- ^ Action to run as a separate process
                -> IO (String, ProcessID)        -- ^ The action's lazy output and the process ID of the child process
@@ -1327,11 +1438,10 @@
    return (txt, pid)
 
 
-
 -- | Run an IO action in a separate process, and read its standard error output, The output
 -- is read lazily, as the returned string is evaluated. The child's error output along
 -- with its process ID are returned.
--- 
+--
 -- This forks a child process, which executes the specified action. The error output
 -- of the child is read lazily through a pipe, which connncts to its standard error
 -- output. In case the child replaces the process by calling an @exec@ variant,
@@ -1352,17 +1462,17 @@
 -- descriptor, even when the pipe is closed on the child side. When you do that
 -- repeatedly, you may run out of file descriptors.
 --
--- Unless you're sure that your program will reach the string's end, you should 
+-- Unless you're sure that your program will reach the string's end, you should
 -- take care for it explicitly, by doing something like this:
 --
 -- >(errmsg, pid) <- lazy_pipe_from2 (exec "/usr/bin/foobar" [])
 -- >...
--- >seq (length errmsg) (return ())   
+-- >seq (length errmsg) (return ())
 --
 -- This will read the entire standard error output of the child, even if it isn't
 -- needed. You can't cut the child process' output short, when you use
--- @lazy_pipe_from@. If you need to do this, you should use @h_pipe_from@, which 
--- gives you the handle, which can then be closed by 'System.IO.hClose', even 
+-- @lazy_pipe_from@. If you need to do this, you should use @h_pipe_from@, which
+-- gives you the handle, which can then be closed by 'System.IO.hClose', even
 -- if the child's output isn't completed:
 --
 -- >(h, pid) <- h_pipe_from io
@@ -1371,24 +1481,24 @@
 -- >output <- hGetContents h
 -- >...
 -- >-- Not eveyting read yet, but cut io short.
--- >hClose h   
+-- >hClose h
 -- >
 -- >-- Wait for io to finish, and detect errors
 -- >(Just ps) <- System.Posix.getProcessStatus True False pid
 -- >when (ps /= Exited ExitSuccess) $
 -- >   throw ps
---   
+--
 -- When you close the handle before all data has been read, then the child gets
 -- a @SIGPIPE@ signal.
--- 
+--
 -- After all the output has been read, you should call @getProcessStatus@ on the
 -- child's process ID, in order to detect errors. Be aware that you must
 -- evaluate the whole string, before calling @getProcessStatus@ blockingly, or
 -- you'll get a deadlock.
---   
--- You won't get an exception, if the child action exits in a way which 
--- indicates an error. Errors occur asynchronously, when the output string is 
--- evaluated. You must detect errors by yourself, by calling 
+--
+-- You won't get an exception, if the child action exits in a way which
+-- indicates an error. Errors occur asynchronously, when the output string is
+-- evaluated. You must detect errors by yourself, by calling
 -- 'System.Posix.Process.getProcessStatus'.
 --
 -- In case the action doesn't replace the child process with an external
@@ -1406,10 +1516,34 @@
 -- then properly terminated, such that no resources, which have been duplicated
 -- by the fork, cause problems. See "HsShellScript#subr" for details.
 --
+-- The pipe is set to /text mode/. This means that the Unicode characters in the
+-- text, which is read from stdin, is converted from the system character set to
+-- Unicode. The system character set is determined by the environment variable
+-- @LANG@. If you need to read binary data from the forked process, you can set
+-- the returned handle to binary mode. This is accomplished by @'hSetBinaryMode'
+-- h True@.
+--
 -- Unlike shells\' backquote feature, @lazy_pipe_from@ does not remove any trailing
 -- newline characters. The entire output of the action is returned. You might want
 -- to apply @chomp@ to the result.
---   
+--
+-- The pipe is set to /text mode/. This means that the Unicode characters in the
+-- text, which is read from the IO action's stdout, are converted from the
+-- system character set to Unicode. The system character set is determined by
+-- the environment variable @LANG@. If you need to read binary data from the
+-- forked process' standard error output, you should use h_pipe_from2 and set
+-- the returned handle to binary mode. This is accomplished by @'hSetBinaryMode'
+-- h True@. Then you can lazily read the output of the action from the handle.
+--
+-- Example: Lazily read binary data from an IO action. Don't forget to collect 
+-- the child process later, using @'System.Posix.getProcessStatus' True False pid@.
+--
+-- >(h, pid) <- h_pipe_from2 io
+-- >hSetBinaryMode h True
+-- >txt <- hGetContents h
+-- >...
+-- >(Just ps) <- System.Posix.getProcessStatus True False pid
+--
 -- See 'exec', 'pipe_to', 'pipe_from2', 'h_pipe_from2', 'lazy_pipe_from', 'silently'.
 lazy_pipe_from2 :: IO a                          -- ^ Action to run as a separate process
                 -> IO (String, ProcessID)        -- ^ The action's lazy output and the process ID of the child process
@@ -1417,14 +1551,43 @@
    (_, _, Just h, pid) <- pipe_fork_dup io False False True
    txt <- hGetContents h
    return (txt, pid)
-   
 
 
+
 -- | Run an IO action as a separate process, and optionally connect to its
--- @stdin@, its @stdout@ and its @stderr@ output with
--- pipes.
+-- @stdin@, its @stdout@ and its @stderr@ output with pipes.
 --
--- See 'pipe_from', 'pipe_from2', 'pipe_to'.
+-- This forks a subprocess, which executes the specified action. The child\'s
+-- @ProcessID@ is returned. Some of the action\'s standard handles are made to
+-- connected to pipes, which the caller can use in order to communicate with the
+-- new child process. Which, this is determined by the first three arguments.
+--   
+-- You get full control of the pipes, and of the forked process. But you
+-- must cope with the child process by yourself.
+--
+-- Errors in the child process can only be detected by examining its process
+-- status (using 'System.Posix.Process.getProcessStatus'). If the child action
+-- throws an exception, an error message is printed on @stderr@, and the child
+-- process exits with a @ProcessStatus@ of @Exited (ExitFailure 1)@. The
+-- following exceptions are understood, and result in corresponding messages:
+-- @ArgError@, @ProcessStatus@, @RunError@, @IOError@ and @ExitCode@. Other
+-- exceptions result in the generic message, as produced by @show@.
+--
+-- Unless you replace the child process, calling an @exec@ variant, the child
+-- should let the control flow leave the action normally. It is then properly 
+-- take care of.
+--
+-- The pipes are set to /text mode/. When connecting to the child\'s @stdin@,
+-- this means that the Unicode characters in the Haskell side text are converted
+-- to the system character set. When reading from the child\'s @stdout@ or
+-- @stderr@, the text is converted from the system character set to Unicode in
+-- the Haskell-side strings. The system character set is determined by the
+-- environment variable @LANG@. If you need to read or write binary data, then
+-- this is no problem. Just call @'hSetBinaryMode' handle True@. This sets the
+-- corresponding pipe to binary mode.
+--
+-- See 'pipe_from', 'h_pipe_from', 'pipe_from2', 'h_pipe_from2', 'pipe_to', 
+-- 'h_pipe_to', 'lazy_pipe_from', 'lazy_pipe_from2'
 pipes :: IO a                   -- ^ Action to run in a new process
       -> Bool                   -- ^ Whether to make stdin pipe
       -> Bool                   -- ^ Whether to make stdout pipe
@@ -2215,54 +2378,6 @@
 
 instance Exception ProcessStatus
 
-
-
-{- ALT:
-
-------------------------------------------------------------------------------------------------------------------------------------------------------
--- Getting the file descriptor which is encapsulated inside a handle
-
-
--- This is a modified version of System.Posix.IO.handleToFd. The original function has the side effect of closing the handle. From the GHC
--- documentation:
---
--- "converting a Handle into an Fd effectively means
--- letting go of the Handle; it is put into a closed
--- state as a result."
---
--- The modified version does the same, but doesn't close the handle.
-
-handleToFd_noclose :: Handle            -- Handle, must be a @FileHandle@. Throws an @IOError@ when the handle is a @DuplexHandle@, or when the
-                                        -- handle doesn't incapsulate a file descriptor.
-                   -> IO Fd             -- The file descriptor inside of the handle.
-
-handleToFd_noclose h@(FileHandle _ m) = do
-  withHandle' "handleToFd_noclose" h m $
-     handleToFd'_noclose h
-
-handleToFd_noclose h@(DuplexHandle _ r w) =
-   ioError (System.IO.Error.ioeSetErrorString
-                 (System.IO.Error.mkIOError IllegalOperation "handleToFd_noclose" (Just h) Nothing)
-            "handle is a Duplex")
-
-
-handleToFd'_noclose :: Handle -> Handle__ -> IO (Handle__, Fd)
-
-handleToFd'_noclose h h_@Handle__{haType=_, ..} = do
-  case cast haDevice of
-    Nothing -> ioError (System.IO.Error.ioeSetErrorString
-                             (System.IO.Error.mkIOError IllegalOperation "handleToFd_noclose" (Just h) Nothing)
-                        "handle is not a file descriptor")
-    Just fd -> do
-       -- Removed code (2 lines) which would close the handle.
-       return (Handle__{haType=ClosedHandle,..}, Fd (FD.fdFD fd))
--}
-
-
-
-
-
-------------------------------------------------------------------------------------------------------------------------------------------------------
 
 #c
 /*
diff --git a/test/Makefile b/test/Makefile
new file mode 100644
--- /dev/null
+++ b/test/Makefile
@@ -0,0 +1,18 @@
+CFLAGS=-XDeriveDataTypeable
+
+% : %.o cteile.o ../dist/build/libHShsshellscript-3.3.0.a
+	ghc -o $@ $^ -package haskell2010 -package unix
+
+%.o : %.hs
+	ghc $(CFLAGS) -c $^
+
+%.o : %.c
+	ghc $(CFLAGS) -c $^
+
+%.hs : %.chs
+	-chmod u+w $@
+	c2hs  -o $@ $<
+	chmod u-w $@
+
+clean ::
+	rm *.hi *.o *~ 
diff --git a/test/redirect.hs b/test/redirect.hs
new file mode 100644
--- /dev/null
+++ b/test/redirect.hs
@@ -0,0 +1,6 @@
+import HsShellScript
+
+main = do 
+  putStrLn "-1-"
+  runprog "/bin/echo" ["äöü"] ->- "/tmp/redirect"
+  putStrLn "-2-"
