mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-08-01 12:41:52 -07:00
Don't bother checking executable bits of items in $PATH, yields a significant speed-up
This commit is contained in:
@@ -89,20 +89,12 @@ getCommands :: IO [String]
|
|||||||
getCommands = do
|
getCommands = do
|
||||||
p <- getEnv "PATH" `catch` const (return [])
|
p <- getEnv "PATH" `catch` const (return [])
|
||||||
let ds = split ':' p
|
let ds = split ':' p
|
||||||
fp d f = d ++ "/" ++ f
|
|
||||||
es <- forM ds $ \d -> do
|
es <- forM ds $ \d -> do
|
||||||
exists <- doesDirectoryExist d
|
exists <- doesDirectoryExist d
|
||||||
if exists
|
if exists
|
||||||
then getDirectoryContents d >>= filterM (isExecutable . fp d)
|
then getDirectoryContents d
|
||||||
else return []
|
else return []
|
||||||
return . uniqSort . concat $ es
|
return . uniqSort . filter ((/= '.') . head) . concat $ es
|
||||||
|
|
||||||
isExecutable :: FilePath ->IO Bool
|
|
||||||
isExecutable f = do
|
|
||||||
fe <- doesFileExist f
|
|
||||||
if fe
|
|
||||||
then fmap executable $ getPermissions f
|
|
||||||
else return False
|
|
||||||
|
|
||||||
split :: Eq a => a -> [a] -> [[a]]
|
split :: Eq a => a -> [a] -> [[a]]
|
||||||
split _ [] = []
|
split _ [] = []
|
||||||
|
Reference in New Issue
Block a user