packages feed

setenv 0.1.0 → 0.1.1

raw patch · 4 files changed

+51/−14 lines, 4 filesdep +processdep −QuickCheckdep −hspecdep −setenv

Dependencies added: process

Dependencies removed: QuickCheck, hspec, setenv

Files

setenv.cabal view
@@ -1,8 +1,8 @@ name:             setenv-version:          0.1.0+version:          0.1.1 license:          MIT license-file:     LICENSE-copyright:        (c) 2012 Simon Hengel+copyright:        (c) 2012, 2013 Simon Hengel author:           Simon Hengel <sol@typeful.net> maintainer:       Simon Hengel <sol@typeful.net> category:         System@@ -35,9 +35,13 @@   hs-source-dirs:       test   main-is:-      Spec.hs+      -- NOTE: We can not use Spec.hs here, because hspec depends on setenv.+      -- So we can not depend on our inplace version of setenv here.  Just+      -- including src in hs-source-dirs does also not work, because this would+      -- require a condition for unix in the test-suite section, and older+      -- version of cabal-install failed if any package in the dependency chain+      -- uses a condition in a test-suite section.+      run.lhs   build-depends:       base-    , setenv-    , hspec >= 1.3-    , QuickCheck+    , process
src/System/SetEnv.hs view
@@ -4,6 +4,12 @@ , unsetEnv ) where +#if MIN_VERSION_base(4,7,0)++import System.Environment (setEnv, unsetEnv)++#else+ #ifdef mingw32_HOST_OS import GHC.Windows import Foreign.Safe@@ -32,11 +38,26 @@  -- | @setEnv name value@ sets the specified environment variable to @value@. ----- If @value@ is the empty string, the specified environment variable is--- removed from the environment.+-- On Windows setting an environment variable to the /empty string/ removes+-- that environment variable from the environment.  For the sake of+-- compatibility we adopt that behavior.  In particular --+-- @+-- setEnv name \"\"+-- @+--+-- has the same effect as+--+-- @+-- `unsetEnv` name+-- @+--+-- If you don't care about Windows support and want to set an environment+-- variable to the empty string use @System.Posix.Env.setEnv@ from the @unix@+-- package instead.+-- -- Throws `Control.Exception.IOException` if @name@ is the empty string or--- contains an equals character.+-- contains an equals sign. setEnv :: String -> String -> IO () setEnv key value_   | null value = unsetEnv key@@ -52,9 +73,12 @@     --     --  * On Windows setting an environment variable to the empty string     --    removes that environment variable.  A subsequent call to-    --    GetEnvironmentVariable will then return 0, but GetLastError will not-    --    be updates, and hence may not return ERROR_ENVVAR_NOT_FOUND.  This is-    --    at least true for observed this behavior with Windows XP SP 3.+    --    GetEnvironmentVariable will then return 0, but the calling thread's+    --    last-error code will not be updated, and hence a call to GetLastError+    --    may not return ERROR_ENVVAR_NOT_FOUND.  The failed lookup will then+    --    result in a random error instead of the expected+    --    `isDoesNotExistError` (this is at least true for Windows XP, SP 3).+    --    Explicitly calling `unsetEnv` prevents this.     value = takeWhile (/= '\NUL') value_  setEnv_ :: String -> String -> IO ()@@ -73,7 +97,7 @@ -- environment of the current process. -- -- Throws `Control.Exception.IOException` if @name@ is the empty string or--- contains an equals character.+-- contains an equals sign. unsetEnv :: String -> IO () #ifdef mingw32_HOST_OS unsetEnv key = withCWString key $ \k -> do@@ -86,4 +110,6 @@       throwGetLastError "unsetEnv" #else unsetEnv = Posix.unsetEnv+#endif+ #endif
− test/Spec.hs
@@ -1,1 +0,0 @@-{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
+ test/run.lhs view
@@ -0,0 +1,8 @@+#!/usr/bin/env runhaskell+> module Main (main) where+>+> import           System.Process+> import           System.Exit+>+> main :: IO ()+> main = rawSystem "cabal" ["install", "hspec"] >> rawSystem "runhaskell" ["-itest", "-isrc", "-optP-include", "-optPdist/build/autogen/cabal_macros.h", "test/Spec.hs"] >>= exitWith