diff options
| author | Roman Smrž <roman.smrz@seznam.cz> | 2025-12-10 21:45:45 +0100 |
|---|---|---|
| committer | Roman Smrž <roman.smrz@seznam.cz> | 2025-12-11 20:42:45 +0100 |
| commit | 6beba62d56ab31927ef1ad7671ab52800ba51103 (patch) | |
| tree | 90d4a8b9e3e91c1b838ae1717fca25c1aa1f8d12 /src/Job.hs | |
| parent | 72c83a013caed4f3f850731988734d125df6a720 (diff) | |
Accept literal text block for the ‘shell’ section
Changelog: Accept literal text block for the `shell` section
Diffstat (limited to 'src/Job.hs')
| -rw-r--r-- | src/Job.hs | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -38,6 +38,7 @@ import Data.Text qualified as T import Data.Text.IO qualified as T import System.Directory +import System.Environment import System.Exit import System.FilePath import System.FilePath.Glob @@ -424,14 +425,21 @@ runJob job uses checkoutPath jdir = do copyRecursive (aoutStorePath aout) target bracket (liftIO $ openFile (jdir </> "log") WriteMode) (liftIO . hClose) $ \logs -> do - forM_ (fromMaybe [] $ jobRecipe job) $ \p -> do + forM_ (fromMaybe [] $ jobRecipe job) $ \ep -> do + ( p, input ) <- case ep of + Left p -> return ( p, "" ) + Right script -> do + sh <- fromMaybe "/bin/sh" <$> liftIO (lookupEnv "SHELL") + return ( proc sh [], script ) (Just hin, _, _, hp) <- liftIO $ createProcess_ "" p { cwd = Just checkoutPath , std_in = CreatePipe , std_out = UseHandle logs , std_err = UseHandle logs } - liftIO $ hClose hin + liftIO $ void $ forkIO $ do + T.hPutStr hin input + hClose hin liftIO (waitForProcess hp) >>= \case ExitSuccess -> return () ExitFailure n |