From 486dcc2da09017b09eeb82001bf0d2cdba5043d0 Mon Sep 17 00:00:00 2001 From: Svyatoslav Gryaznov Date: Wed, 6 Jul 2016 15:43:07 +0300 Subject: Set newline format to `stdout` too --- src/Main.hs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Main.hs b/src/Main.hs index 73ec12a..d481517 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -121,15 +121,18 @@ file sa conf mfp = do Right ok -> write contents $ unlines ok where write old new = case mfp of - Nothing -> putStr new - Just _ | not (saInPlace sa) -> putStr new + Nothing -> putStrNewline new + Just _ | not (saInPlace sa) -> putStrNewline new Just path | not (null new) && old /= new -> IO.withFile path IO.WriteMode $ \h -> do - let nl = configNewline conf - let mode = IO.NewlineMode IO.nativeNewline nl - IO.hSetNewlineMode h mode + setNewlineMode h IO.hPutStr h new _ -> return () + setNewlineMode h = do + let nl = configNewline conf + let mode = IO.NewlineMode IO.nativeNewline nl + IO.hSetNewlineMode h mode + putStrNewline txt = setNewlineMode IO.stdout >> putStr txt readUTF8File :: FilePath -> IO String readUTF8File fp = -- cgit v1.2.3