[Haskell] ANNOUNCE: HsUnix 1.0.1 - Haskell for Unix Shell Scripting

Andrew Pimlott andrew at pimlott.net
Mon Feb 9 13:52:31 EST 2004

On Mon, Feb 09, 2004 at 07:16:09PM +0100, Volker Wysk wrote:
>   main = mainwrapper $
>      call (execp "cat" ["nosuchfile"] -|- execp "echo" ["hello"])
> This happens to work right. The error is reported via a dynamic exception:
>   ~/src/hsunix/build $ ./test2
>   cat: nosuchfilehello
>   : No such file or directory
>   Process error. process status = Exited (ExitFailure 1)
> However, when using pipes, the exitcode of only one of the involved
> processes can be monitored.

Let me give my frank opinion that, even though it's how shell
scripts have always worked, this should be considered broken.  It is
rather a pain to fix, as you can't implement it in the usual
straightforward way.  You have to fork all subprocesses from the
main process, and do extra work to share the pipes.  If you don't
want to use filehandles extravagantly, you have to do additional
work.  I essentially wrote a mini-OS layer that wraps all fork,
pipe, and open calls, and tries (in a fairly dumb but usually
effective way) to allocate filehandles efficiently.  I can share if
you'd like.  (I found this exercise gave great insight into the
"worse is better" philosophy.)

If you don't change this behavior, at least document it prominently
as a robustness sink!  :-)


More information about the Haskell mailing list