From 75828696e7145adc09179111a0d631b9a09963a4 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Sat, 17 Aug 2024 22:59:04 +0800 Subject: [PATCH] 'findExecutable' "" should return Nothing, like on linux Fixes #180 --- System/Directory/Internal/Windows.hsc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/System/Directory/Internal/Windows.hsc b/System/Directory/Internal/Windows.hsc index a0a5cbf3..5fefb9ec 100644 --- a/System/Directory/Internal/Windows.hsc +++ b/System/Directory/Internal/Windows.hsc @@ -409,9 +409,12 @@ canonicalizePathSimplify path = pure path searchPathEnvForExes :: OsString -> IO (Maybe OsPath) -searchPathEnvForExes (OsString binary) = - (OsString <$>) <$> - Win32.searchPath Nothing binary (Just (getOsString exeExtension)) +searchPathEnvForExes (OsString binary) = search `catch` \e -> + if ioeGetErrorType e == InvalidArgument + then pure Nothing + else throwIO e + where + search = (OsString <$>) <$> Win32.searchPath Nothing binary (Just (getOsString exeExtension)) findExecutablesLazyInternal :: ([OsPath] -> OsString -> ListT IO OsPath) -> OsString