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 :: IO [String]
 | 
				
			||||||
getHledgerProgramsInPath = do
 | 
					getHledgerProgramsInPath = do
 | 
				
			||||||
  pathdirs <- splitOn ":" `fmap` getEnv "PATH"
 | 
					  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
 | 
					  return $ nub $ sort $ filter (isRight . parsewith hledgerprog) pathexes
 | 
				
			||||||
    where
 | 
					    where
 | 
				
			||||||
      hledgerprog = string progname >> char '-' >> many1 (letter <|> char '-') >> eof
 | 
					      hledgerprog = string progname >> char '-' >> many1 (letter <|> char '-') >> eof
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					getDirectoryContentsSafe d = getDirectoryContents d `catch` (\_ -> return [])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- | Convert possibly encoded option values to regular unicode strings.
 | 
					-- | Convert possibly encoded option values to regular unicode strings.
 | 
				
			||||||
decodeRawOpts = map (\(name,val) -> (name, fromPlatformString val))
 | 
					decodeRawOpts = map (\(name,val) -> (name, fromPlatformString val))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user