From 0252cec56760e25dd8a81c0c85bf4f8e6a5a36b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sun, 8 Jan 2023 10:10:38 +0100 Subject: Look for core binary in PATH when invoked without path --- src/Wrapper.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Wrapper.hs b/src/Wrapper.hs index 64a2e0f..544e37c 100644 --- a/src/Wrapper.hs +++ b/src/Wrapper.hs @@ -1,5 +1,7 @@ module Main where +import Control.Monad + import GHC.Environment import System.Directory @@ -24,7 +26,7 @@ main = do callCommand "mount -t tmpfs tmpfs /run" epath <- takeDirectory <$> getExecutablePath -- directory containing executable - fpath <- map takeDirectory . take 1 <$> getFullArgs + fpath <- map takeDirectory . filter (any isPathSeparator) . take 1 <$> getFullArgs -- directory used for invocation, can differ from above for symlinked executable let dirs = concat @@ -36,5 +38,8 @@ main = do args <- getArgs mapM_ (\file -> executeFile file False args Nothing) =<< findExecutablesInDirectories dirs "erebos-tester-core" + when (null fpath) $ + mapM_ (\file -> executeFile file False args Nothing) =<< + findExecutables "erebos-tester-core" fail "core binary not found" -- cgit v1.2.3