<br><font size=2 face="sans-serif">Maybe this is by design, but I just
thought I would point this behavior out and ask for comment.</font>
<br>
<br><font size=2 face="sans-serif">test1 merely shows that runInteractiveCommand
reacts differently to perl warnings than perl errors. Okay, maybe the inconsistency
in that case is due to perl and not haskell.</font>
<br>
<br><font size=2 face="sans-serif">test2 behaves the same on win and nix.
This is "pipe like" in that the ouptut of a command (which could
be the result of a shell call, but just as easily be the return of a haskell
function) gets fed into a shell command. In this case, if the shell command
is simply "tail" the behavior is consistent from win to nix.</font>
<br>
<br><font size=2 face="sans-serif">test3 shows that the behavior stops
being consistent if ssh enters the picture. (piping to tail via ssh). again,
maybe this is due to ssh and not haskell.</font>
<br>
<br><font size=2 face="sans-serif">however... note however that on windows</font>
<br>
<br><font size=2 face="Courier New">ghc -e 'mapM_ ( putStrLn . show ) [1..1000]
' | ssh `whoami`@localhost 'tail -n2'</font>
<br>
<br><font size=2 face="sans-serif">works fine. so it's not *just*
ssh, but ssh in conjuction with runInteractiveCommand which seems to cause
problems</font>
<br>
<br><font size=2 face="sans-serif">FWIW, using 10 lines instead of 1000
still hangs on windows.</font>
<br>
<br><font size=2 face="sans-serif">Is there a way to code up shell pipelike
behavior in a more portable way?</font>
<br>
<br><font size=2 face="Courier New">curious what the cafe thinks...</font>
<br>
<br><font size=2 face="Courier New">thomas.</font>
<br>
<br><font size=2 face="Courier New">import Test.HUnit</font>
<br><font size=2 face="Courier New">import Misc ( (>>=^) )</font>
<br><font size=2 face="Courier New">import System.Process</font>
<br><font size=2 face="Courier New">import System.IO</font>
<br><font size=2 face="Courier New">import System.Exit</font>
<br>
<br><font size=2 face="Courier New">-- works on linux, error on windows</font>
<br>
<br><font size=2 face="Courier New">test1 = do </font>
<br><font size=2 face="Courier New"> res1 <- test_shellrunStderrOk</font>
<br><font size=2 face="Courier New"> runTestTT $ TestCase ( assertEqual
"test1" "made it" res1 )</font>
<br><font size=2 face="Courier New"> where test_shellrunStderrOk
= do</font>
<br><font size=2 face="Courier New">
runprocessStdErrAllowed' "" cmdPerlwarn</font>
<br><font size=2 face="Courier New">
return "made it"</font>
<br><font size=2 face="Courier New"> cmdPerldie
= " perl -e 'die \"error\"' "</font>
<br><font size=2 face="Courier New"> cmdPerlwarn
= " perl -e 'warn \"blee\"' "</font>
<br>
<br><font size=2 face="Courier New">-- works on linux, windows</font>
<br><font size=2 face="Courier New">test2 = pipeTo "tail -n2"</font>
<br>
<br><font size=2 face="Courier New">-- works on linux, hangs on windows</font>
<br><font size=2 face="Courier New">test3 = pipeTo "ssh `whoami`@localhost
'tail -n2'"</font>
<br>
<br><font size=2 face="Courier New">pipeTo cmd = do</font>
<br><font size=2 face="Courier New"> res2 <- test_shellrunPipeinLike</font>
<br><font size=2 face="Courier New"> runTestTT $ TestCase ( assertEqual
( "pipe to, cmd: " ++ cmd) (show l) res2 )</font>
<br><font size=2 face="Courier New"> where test_shellrunPipeinLike
= do</font>
<br><font size=2 face="Courier New">
runprocessStdErrAllowed' (unlines $ map show [1..l]) ( cmd )</font>
<br><font size=2 face="Courier New">
>>=^ filter (not . ( == '\n') )</font>
<br><font size=2 face="Courier New"> l = 1000</font>
<br>
<br><font size=2 face="Courier New">runprocessStdErrAllowed' inp s = do</font>
<br><font size=2 face="Courier New"> (ih,oh,eh,pid) <-
runInteractiveCommand s</font>
<br><font size=2 face="Courier New"> so <- hGetContents
oh</font>
<br><font size=2 face="Courier New"> se <- hGetContents
eh</font>
<br><font size=2 face="Courier New"> hPutStrLn ih inp</font>
<br><font size=2 face="Courier New"> hClose ih</font>
<br><font size=2 face="Courier New"> ex <- waitForProcess
pid</font>
<br><font size=2 face="Courier New"> case ex of</font>
<br><font size=2 face="Courier New"> ExitFailure
e -> fail $ "shell command " ++ s ++ "\nFailed
with status: " ++ show e</font>
<br><font size=2 face="Courier New"> _
| otherwise -> return so</font>
<br>
<br>
<br>
<span style="font-family:sans-serif,helvetica; font-size:10pt; color:#000000">---</span><br>
<br>
<span style="font-family:sans-serif,helvetica; font-size:10pt; color:#000000">This e-mail may contain confidential and/or privileged information. If you </span><br>
<span style="font-family:sans-serif,helvetica; font-size:10pt; color:#000000">are not the intended recipient (or have received this e-mail in error) </span><br>
<span style="font-family:sans-serif,helvetica; font-size:10pt; color:#000000">please notify the sender immediately and destroy this e-mail. Any </span><br>
<span style="font-family:sans-serif,helvetica; font-size:10pt; color:#000000">unauthorized copying, disclosure or distribution of the material in this </span><br>
<span style="font-family:sans-serif,helvetica; font-size:10pt; color:#000000">e-mail is strictly forbidden.</span><br>