[Haskell-cafe] Simple shell scripts
Iavor Diatchki
iavor.diatchki at gmail.com
Mon Aug 27 20:08:18 CEST 2012
Hello,
this happens because "head" probably closes the file descriptor after 3
lines, and then the Haskell program tries to write to a closed handle
(i.e., it's stdout is not there anymore). The best thing to do depends on
the program. One fairly simple option would be to handle the exception, and
do something (perhaps ignore it).
-Iavor
On Mon, Aug 27, 2012 at 10:55 AM, Eric Tanter <etanter at dcc.uchile.cl> wrote:
> Hi,
>
> Here is a simple shell script (upper.hs):
>
> import Data.Char
> main = interact $ map toUpper
>
> which composes fine with other scripts:
>
> bash-3.2$ yes | head -n 3 | runghc upper.hs
> Y
> Y
> Y
>
> but not always:
>
> bash-3.2$ yes | runghc upper.hs | head -n 3
> Y
> Y
> Y
> <stdout>: hFlush: resource vanished (Broken pipe)
>
> Any idea why this error occurs/how to avoid it?
>
> (running just:
> yes | runghc upper.hs
> gives the expected infinite stream of Ys)
>
> Thanks!
>
> -- Éric
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120827/41f87fff/attachment.htm>
More information about the Haskell-Cafe
mailing list