Skip to content

Commit a2bd923

Browse files
committed
Replace some stdout output with stderr #820
@chrisdone see anything wrong with this?
1 parent b5224f8 commit a2bd923

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/main/Main.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ import System.Environment (getArgs, getProgName)
7474
import System.Exit
7575
import System.FileLock (lockFile, tryLockFile, unlockFile, SharedExclusive(Exclusive), FileLock)
7676
import System.FilePath (dropTrailingPathSeparator)
77-
import System.IO (hIsTerminalDevice, stderr, stdin, stdout, hSetBuffering, BufferMode(..))
77+
import System.IO (hIsTerminalDevice, stderr, stdin, stdout, hSetBuffering, BufferMode(..), hPutStrLn)
7878
import System.Process.Read
7979

8080
#if WINDOWS
@@ -325,7 +325,7 @@ main = withInterpreterArgs stackProgName $ \args isInterpreter -> do
325325
case eGlobalRun of
326326
Left (exitCode :: ExitCode) -> do
327327
when isInterpreter $
328-
putStrLn $ concat
328+
hPutStrLn stderr $ concat
329329
[ "\nIf you are trying to use "
330330
, stackProgName
331331
, " as a script interpreter, a\n'-- "
@@ -334,7 +334,7 @@ main = withInterpreterArgs stackProgName $ \args isInterpreter -> do
334334
, "\nSee https://github.com/commercialhaskell/stack/wiki/Script-interpreter" ]
335335
throwIO exitCode
336336
Right (global,run) -> do
337-
when (globalLogLevel global == LevelDebug) $ putStrLn versionString'
337+
when (globalLogLevel global == LevelDebug) $ hPutStrLn stderr versionString'
338338
run global `catch` \e -> do
339339
-- This special handler stops "stack: " from being printed before the
340340
-- exception
@@ -585,12 +585,12 @@ withUserFileLock dir act = do
585585
case fstTry of
586586
Just lk -> EL.finally (act lk) (liftIO $ unlockFile lk)
587587
Nothing ->
588-
do liftIO $ putStrLn $ "Failed to grab lock ("++show pth++
588+
do liftIO $ hPutStrLn stderr $ "Failed to grab lock ("++show pth++
589589
"); other stack instance running. Waiting..."
590590
EL.bracket (liftIO $ lockFile (toFilePath pth) Exclusive)
591591
(liftIO . unlockFile)
592592
(\lk -> do
593-
liftIO $ putStrLn "Lock acquired, proceeding."
593+
liftIO $ hPutStrLn stderr "Lock acquired, proceeding."
594594
act lk))
595595

596596
withConfigAndLock :: GlobalOpts

0 commit comments

Comments
 (0)