don't fail when PATH contains bad directories
This commit is contained in:
parent
7616ed9b8e
commit
ec9e06e33e
@ -342,11 +342,13 @@ getHledgerAddonCommands = map (drop (length progname + 1)) `fmap` getHledgerProg
|
||||
getHledgerProgramsInPath :: IO [String]
|
||||
getHledgerProgramsInPath = do
|
||||
pathdirs <- splitOn ":" `fmap` getEnv "PATH"
|
||||
pathexes <- concat `fmap` mapM getDirectoryContents pathdirs
|
||||
pathexes <- concat `fmap` mapM getDirectoryContentsSafe pathdirs
|
||||
return $ nub $ sort $ filter (isRight . parsewith hledgerprog) pathexes
|
||||
where
|
||||
hledgerprog = string progname >> char '-' >> many1 (letter <|> char '-') >> eof
|
||||
|
||||
getDirectoryContentsSafe d = getDirectoryContents d `catch` (\_ -> return [])
|
||||
|
||||
-- | Convert possibly encoded option values to regular unicode strings.
|
||||
decodeRawOpts = map (\(name,val) -> (name, fromPlatformString val))
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user