Make nested invocation harmless, inner call does nothing
parent
8ca85432be
commit
87647d8851
|
@ -65,7 +65,10 @@ import System.Console.Regions ( ConsoleRegion
|
||||||
, openConsoleRegion
|
, openConsoleRegion
|
||||||
, setConsoleRegion
|
, setConsoleRegion
|
||||||
)
|
)
|
||||||
import System.Exit ( exitWith )
|
import qualified System.Environment
|
||||||
|
import System.Exit ( exitSuccess
|
||||||
|
, exitWith
|
||||||
|
)
|
||||||
import System.IO ( Handle
|
import System.IO ( Handle
|
||||||
, hClose
|
, hClose
|
||||||
, hGetLine
|
, hGetLine
|
||||||
|
@ -351,10 +354,19 @@ main = B.mainFromCmdParser $ do
|
||||||
'-' : '-' : r -> r
|
'-' : '-' : r -> r
|
||||||
r -> r
|
r -> r
|
||||||
helpDesc <- B.peekCmdDesc
|
helpDesc <- B.peekCmdDesc
|
||||||
B.addCmdImpl $ if null rest
|
B.addCmdImpl $ do
|
||||||
then do
|
when (null rest) $ do
|
||||||
print $ B.ppHelpShallow helpDesc
|
print $ B.ppHelpShallow helpDesc
|
||||||
else withConcurrentOutput $ mask $ \restore -> do
|
exitSuccess
|
||||||
|
recursiveMay <- System.Environment.lookupEnv "IN_HXBRIEF"
|
||||||
|
case recursiveMay of
|
||||||
|
Just _ -> do
|
||||||
|
-- TODO: Arguably, we should do _something_ here, e.g. summarizing
|
||||||
|
-- and filtering etc.
|
||||||
|
P.callCommand rest
|
||||||
|
exitSuccess
|
||||||
|
Nothing -> pure ()
|
||||||
|
withConcurrentOutput $ mask $ \restore -> do
|
||||||
restore $ setLocaleEncoding utf8
|
restore $ setLocaleEncoding utf8
|
||||||
termWidthMay <- restore $ try Ansi.getTerminalSize <&> \case
|
termWidthMay <- restore $ try Ansi.getTerminalSize <&> \case
|
||||||
Left (_e :: IOException) -> Nothing
|
Left (_e :: IOException) -> Nothing
|
||||||
|
@ -423,10 +435,11 @@ main = B.mainFromCmdParser $ do
|
||||||
|
|
||||||
let mainBlock =
|
let mainBlock =
|
||||||
P.withCreateProcess
|
P.withCreateProcess
|
||||||
((P.shell rest) { P.std_in = P.CreatePipe
|
((P.shell ("IN_HXBRIEF=1 " ++ rest))
|
||||||
, P.std_out = P.CreatePipe
|
{ P.std_in = P.CreatePipe
|
||||||
, P.std_err = P.CreatePipe
|
, P.std_out = P.CreatePipe
|
||||||
}
|
, P.std_err = P.CreatePipe
|
||||||
|
}
|
||||||
)
|
)
|
||||||
$ \(Just inp) (Just out) (Just err) hdl -> do
|
$ \(Just inp) (Just out) (Just err) hdl -> do
|
||||||
A.withAsync (outHandler out) $ \outAsync ->
|
A.withAsync (outHandler out) $ \outAsync ->
|
||||||
|
|
Loading…
Reference in New Issue