fix: lib: don't use $PAGER when TERM=dumb
This commit is contained in:
parent
7a636dd428
commit
bb5d473955
@ -126,9 +126,11 @@ pprint' = pPrintOpt CheckColorTty prettyopts'
|
|||||||
-- "Avoid using pshow, pprint, dbg* in the code below to prevent infinite loops." (?)
|
-- "Avoid using pshow, pprint, dbg* in the code below to prevent infinite loops." (?)
|
||||||
|
|
||||||
-- | Display the given text on the terminal, using the user's $PAGER if the text is taller
|
-- | Display the given text on the terminal, using the user's $PAGER if the text is taller
|
||||||
-- than the current terminal and stdout is interactive.
|
-- than the current terminal and stdout is interactive and TERM is not "dumb".
|
||||||
pager :: String -> IO ()
|
pager :: String -> IO ()
|
||||||
pager s = printOrPage $ pack s
|
pager s = do
|
||||||
|
dumbterm <- (== Just "dumb") <$> lookupEnv "TERM"
|
||||||
|
(if dumbterm then putStrLn else printOrPage . pack) s
|
||||||
|
|
||||||
-- Command line arguments
|
-- Command line arguments
|
||||||
|
|
||||||
@ -163,6 +165,7 @@ outputFileOption =
|
|||||||
-- with an argument other than "-", using unsafePerformIO.
|
-- with an argument other than "-", using unsafePerformIO.
|
||||||
hasOutputFile :: Bool
|
hasOutputFile :: Bool
|
||||||
hasOutputFile = outputFileOption `notElem` [Nothing, Just "-"]
|
hasOutputFile = outputFileOption `notElem` [Nothing, Just "-"]
|
||||||
|
-- XXX shouldn't we check that stdout is interactive. instead ?
|
||||||
|
|
||||||
-- ANSI colour
|
-- ANSI colour
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user