diff options
-rw-r--r-- | sensible-directory/src/SensibleDir.hs | 4 |
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 | |||
14 | import Control.Applicative | 14 | import Control.Applicative |
15 | import Data.List | 15 | import Data.List |
16 | 16 | ||
17 | -- | Returns True if "build" occurs as any component of the path of the running executable. | ||
17 | runningInBuildDir :: IO Bool | 18 | runningInBuildDir :: IO Bool |
18 | runningInBuildDir = any (=="build") . take 2 . reverse . splitDirectories . takeDirectory <$> getExecutablePath | 19 | runningInBuildDir = 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. | ||
20 | runningInCabalDir :: IO Bool | 22 | runningInCabalDir :: IO Bool |
21 | runningInCabalDir = any (==".cabal") . take 2 . reverse . splitDirectories . takeDirectory <$> getExecutablePath | 23 | runningInCabalDir = 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. | ||
23 | runningInSysBin = do | 26 | runningInSysBin = 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. | ||
33 | runningInLocalBin = do | 37 | runningInLocalBin = do |
34 | exedir <- splitDirectories . takeDirectory <$> getExecutablePath | 38 | exedir <- splitDirectories . takeDirectory <$> getExecutablePath |
35 | return $ | 39 | return $ |