On 21-Aug-1999, Heribert Schuetz <[EMAIL PROTECTED]> wrote:
> The appended patch to Hugs98 (to be applied in the src subdirectory)
> might be of some help for those who want to do shell scripting in
> Haskell. It modifies IO.openFile as follows:
> 
> - If the name of a file opened in ReadMode ends in "|", then the part
>   before the "|" is considered a program and its standard output is
>   read.
> 
> - If the name of a file opened in WriteMode begins with "|", then the
>   part after the "|" is considered a program and it is written to its
>   standard input.
> 
> Several Unix programs have such a behaviour.
>
> With the patch applied, you can do things like this:
> 
>   do h <- openFile "cat /etc/group|" ReadMode
>      h' <- openFile "|tr aeiou '*'" WriteMode
>      hGetContents h >>= hPutStr h'
>      hClose h
>      hClose h'

This is a convenient hack, but IMHO it is not suitable for inclusion
in the Haskell standard library, because it increases the risk of
security holes in Haskell applications.

A better alternative would be to provide a new function named
"openFileOrPipe" with this augmented functionality.

-- 
Fergus Henderson <[EMAIL PROTECTED]>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger [EMAIL PROTECTED]        |     -- the last words of T. S. Garp.


Reply via email to