<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 &quot;pipe like&quot; 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 &quot;tail&quot; 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. &nbsp;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 ( (&gt;&gt;=^) )</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">&nbsp; res1 &lt;- test_shellrunStderrOk</font>
<br><font size=2 face="Courier New">&nbsp; runTestTT $ TestCase ( assertEqual
&quot;test1&quot; &quot;made it&quot; &nbsp;res1 )</font>
<br><font size=2 face="Courier New">&nbsp; where test_shellrunStderrOk
= do</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
runprocessStdErrAllowed' &quot;&quot; cmdPerlwarn</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
return &quot;made it&quot;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; cmdPerldie
= &nbsp;&quot; perl -e 'die \&quot;error\&quot;' &quot;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; cmdPerlwarn
= &quot; perl -e 'warn \&quot;blee\&quot;' &quot;</font>
<br>
<br><font size=2 face="Courier New">-- works on linux, windows</font>
<br><font size=2 face="Courier New">test2 = pipeTo &quot;tail -n2&quot;</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 &quot;ssh `whoami`@localhost
'tail -n2'&quot;</font>
<br>
<br><font size=2 face="Courier New">pipeTo cmd = do</font>
<br><font size=2 face="Courier New">&nbsp; res2 &lt;- test_shellrunPipeinLike</font>
<br><font size=2 face="Courier New">&nbsp; runTestTT $ TestCase ( assertEqual
( &quot;pipe to, cmd: &quot; ++ cmd) (show l) res2 )</font>
<br><font size=2 face="Courier New">&nbsp; where test_shellrunPipeinLike
= do</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
runprocessStdErrAllowed' (unlines $ map show [1..l]) ( cmd )</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&gt;&gt;=^ filter (not . ( == '\n') )</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; l = 1000</font>
<br>
<br><font size=2 face="Courier New">runprocessStdErrAllowed' inp s = do</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; (ih,oh,eh,pid) &lt;-
runInteractiveCommand s</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; so &lt;- hGetContents
oh</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; se &lt;- hGetContents
eh</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; hPutStrLn ih inp</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; hClose ih</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; ex &lt;- waitForProcess
pid</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; case ex of</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; ExitFailure
e &nbsp; &nbsp; &nbsp;-&gt; fail $ &quot;shell command &quot; ++ s ++ &quot;\nFailed
with status: &quot; ++ show e</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; _ &nbsp;
| otherwise &nbsp; &nbsp; -&gt; 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>