Re: Simple shell scripts

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).

It's normal, and shells normally ignore it when programs in the middle of a pipeline die with SIGPIPE. Problem here is the Haskell runtime is itself intercepting the SIGPIPE and throwing a verbose Haskell exception.

Possibly the runtime should detect that stdout is a pipe and disable the usual SIGPIPE handler, or if it must run cleanup stuff then it should not print anything and it should after cleanup raise(SIGPIPE) on itself with the default SIGPIPE handler so the shell will react properly.

You might be able to do this yourself with (System.Posix.Signals.installHandler openEndedPipe Default Nothing).