Make nested invocation harmless, inner call does nothing
parent
8ca85432be
commit
87647d8851
|
@ -65,7 +65,10 @@ import System.Console.Regions ( ConsoleRegion
|
|||
, openConsoleRegion
|
||||
, setConsoleRegion
|
||||
)
|
||||
import System.Exit ( exitWith )
|
||||
import qualified System.Environment
|
||||
import System.Exit ( exitSuccess
|
||||
, exitWith
|
||||
)
|
||||
import System.IO ( Handle
|
||||
, hClose
|
||||
, hGetLine
|
||||
|
@ -351,10 +354,19 @@ main = B.mainFromCmdParser $ do
|
|||
'-' : '-' : r -> r
|
||||
r -> r
|
||||
helpDesc <- B.peekCmdDesc
|
||||
B.addCmdImpl $ if null rest
|
||||
then do
|
||||
B.addCmdImpl $ do
|
||||
when (null rest) $ do
|
||||
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
|
||||
termWidthMay <- restore $ try Ansi.getTerminalSize <&> \case
|
||||
Left (_e :: IOException) -> Nothing
|
||||
|
@ -423,7 +435,8 @@ main = B.mainFromCmdParser $ do
|
|||
|
||||
let mainBlock =
|
||||
P.withCreateProcess
|
||||
((P.shell rest) { P.std_in = P.CreatePipe
|
||||
((P.shell ("IN_HXBRIEF=1 " ++ rest))
|
||||
{ P.std_in = P.CreatePipe
|
||||
, P.std_out = P.CreatePipe
|
||||
, P.std_err = P.CreatePipe
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue