diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2017-06-11 05:42:19 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2017-06-11 05:42:19 +0300 |
commit | 714fc992181311d88adb35cb59d766abbbc59811 (patch) | |
tree | b39ada56cf9db63f35c929073a555aa45e31086b /src | |
parent | refactoring (diff) | |
download | windows-env-714fc992181311d88adb35cb59d766abbbc59811.tar.gz windows-env-714fc992181311d88adb35cb59d766abbbc59811.zip |
delenv: ignore missing variables
Diffstat (limited to '')
-rw-r--r-- | src/WindowsEnv/Environment.hs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/WindowsEnv/Environment.hs b/src/WindowsEnv/Environment.hs index 9a42748..c194cbe 100644 --- a/src/WindowsEnv/Environment.hs +++ b/src/WindowsEnv/Environment.hs @@ -34,13 +34,13 @@ module WindowsEnv.Environment ) where import Control.Monad.Trans.Class (lift) -import Control.Monad.Trans.Except (ExceptT(..)) +import Control.Monad.Trans.Except (ExceptT(..), catchE, throwE) import Data.List (intercalate) import Data.List.Split (splitOn) import Foreign.Marshal.Alloc (allocaBytes) import Foreign.Storable (sizeOf) import System.Directory (doesDirectoryExist) -import System.IO.Error (catchIOError) +import System.IO.Error (catchIOError, isDoesNotExistError) import qualified System.Win32.Types as WinAPI import qualified WindowsEnv.Registry as Registry @@ -92,9 +92,13 @@ engrave profile name value = do wipe :: Profile -> VarName -> ExceptT IOError IO () wipe profile name = do - ret <- Registry.deleteValue (profileKeyPath profile) name + ret <- Registry.deleteValue (profileKeyPath profile) name `catchE` ignoreIfMissing lift notifyEnvironmentUpdate return ret + where + ignoreIfMissing e + | isDoesNotExistError e = return () + | otherwise = throwE e pathSep :: String pathSep = ";" |