summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sensible-directory/src/SensibleDir.hs4
1 files changed, 4 insertions, 0 deletions
diff --git a/sensible-directory/src/SensibleDir.hs b/sensible-directory/src/SensibleDir.hs
index 0133736d..4e55726d 100644
--- a/sensible-directory/src/SensibleDir.hs
+++ b/sensible-directory/src/SensibleDir.hs
@@ -14,12 +14,15 @@ import Control.Arrow
14import Control.Applicative 14import Control.Applicative
15import Data.List 15import Data.List
16 16
17-- | Returns True if "build" occurs as any component of the path of the running executable.
17runningInBuildDir :: IO Bool 18runningInBuildDir :: IO Bool
18runningInBuildDir = any (=="build") . take 2 . reverse . splitDirectories . takeDirectory <$> getExecutablePath 19runningInBuildDir = any (=="build") . take 2 . reverse . splitDirectories . takeDirectory <$> getExecutablePath
19 20
21-- | Returns True if ".cabal" occurs as any component of the path of the running executable.
20runningInCabalDir :: IO Bool 22runningInCabalDir :: IO Bool
21runningInCabalDir = any (==".cabal") . take 2 . reverse . splitDirectories . takeDirectory <$> getExecutablePath 23runningInCabalDir = any (==".cabal") . take 2 . reverse . splitDirectories . takeDirectory <$> getExecutablePath
22 24
25-- | Returns True if running executable is in /bin, /sbin, or /usr/bin, or /usr/sbin.
23runningInSysBin = do 26runningInSysBin = do
24 exedir <- splitDirectories . takeDirectory <$> getExecutablePath 27 exedir <- splitDirectories . takeDirectory <$> getExecutablePath
25 return $ 28 return $
@@ -30,6 +33,7 @@ runningInSysBin = do
30 ["usr","sbin"] -> True 33 ["usr","sbin"] -> True
31 _ -> False 34 _ -> False
32 35
36-- | Returns True if executable is within /usr/local/bin or /usr/local/sbin.
33runningInLocalBin = do 37runningInLocalBin = do
34 exedir <- splitDirectories . takeDirectory <$> getExecutablePath 38 exedir <- splitDirectories . takeDirectory <$> getExecutablePath
35 return $ 39 return $