definition: |
execAndRemove :: ReplState -> String -> String -> IO Int execAndRemove rst executable execcmd = do writeVerboseInfo rst 2 $ "Executing: " ++ execcmd let scriptfile = executable ++ ".sh" let shellscript = shellScript scriptfile writeFile scriptfile shellscript writeVerboseInfo rst 3 $ "...with shell script:\n" ++ shellscript ecx <- system $ "/bin/sh " ++ scriptfile unless (ecx == 0) $ writeVerboseInfo rst 1 $ "Execution terminated with exit status: " ++ show ecx unlessKeepFiles rst $ do removeFileIfExists scriptfile removeFileIfExists executable return ecx where shellScript scriptfile = unlines [ "#!/bin/sh" , "cleanup_mainfiles() {" , " ECODE=$?" , " # change exit code 130 (Ctrl-C) to 1 to avoid exit of REPL:" , " if [ $ECODE -eq 130 ] ; then ECODE=1 ; fi" , (if keepFiles rst then "" else " /bin/rm -f " ++ executable ++ " " ++ scriptfile ++ " && ") ++ " exit $ECODE" , "}" , "trap 'cleanup_mainfiles' 1 2 3 6" , execcmd , "######################## end of script ###################" ] |
demand: |
no demanded arguments |
deterministic: |
deterministic operation |
documentation: |
-- Invokes a command (third argument) and removes the executable (second -- argument) after execution (unless `keepfiles` option is set). -- In order to support the deletion of the executable event after Ctrl-C, -- the execution is wrapped into a shell which traps interrupts. |
failfree: |
(_, _, _) |
indeterministic: |
referentially transparent operation |
infix: |
no fixity defined |
iotype: |
{(_,_,_) |-> _} |
name: |
execAndRemove |
precedence: |
no precedence defined |
result-values: |
_ |
signature: |
REPL.State.ReplState -> String -> String -> Prelude.IO Prelude.Int |
solution-complete: |
operation might suspend on free variables |
terminating: |
possibly non-terminating |
totally-defined: |
possibly non-reducible on same data term |