summaryrefslogtreecommitdiff
path: root/Utility/Path.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-08-02 07:47:50 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-08-02 07:50:13 -0400
commit9a038b4a9b62824646bf4e876ed9017a1128aa56 (patch)
tree1fb0f5ff59693b9190f5744a1b5806da67fc077b /Utility/Path.hs
parent112ce4f49c95022d1afe83bd31f4af35a01f877c (diff)
better ~/ handling
Diffstat (limited to 'Utility/Path.hs')
-rw-r--r--Utility/Path.hs8
1 files changed, 8 insertions, 0 deletions
diff --git a/Utility/Path.hs b/Utility/Path.hs
index 76fbc6c4a..209ff1b0f 100644
--- a/Utility/Path.hs
+++ b/Utility/Path.hs
@@ -132,6 +132,14 @@ runPreserveOrder a files = preserveOrder files <$> a files
myHomeDir :: IO FilePath
myHomeDir = homeDirectory <$> (getUserEntryForID =<< getEffectiveUserID)
+{- Converts paths in the home directory to use ~/ -}
+relHome :: FilePath -> IO String
+relHome path = do
+ home <- myHomeDir
+ return $ if dirContains home path
+ then "~/" ++ relPathDirToFile home path
+ else path
+
{- Checks if a command is available in PATH. -}
inPath :: String -> IO Bool
inPath command = getSearchPath >>= anyM indir