Hello community, here is the log from the commit of package ghc-dotenv for openSUSE:Factory checked in at 2017-06-04 01:57:08 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-dotenv (Old) and /work/SRC/openSUSE:Factory/.ghc-dotenv.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-dotenv" Sun Jun 4 01:57:08 2017 rev:2 rq:499692 version:0.3.3.0 Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-dotenv/ghc-dotenv.changes 2017-05-09 18:10:34.801895256 +0200 +++ /work/SRC/openSUSE:Factory/.ghc-dotenv.new/ghc-dotenv.changes 2017-06-04 01:57:09.386854524 +0200 @@ -1,0 +2,5 @@ +Thu May 18 09:52:30 UTC 2017 - [email protected] + +- Update to version 0.3.3.0 with cabal2obs. + +------------------------------------------------------------------- Old: ---- dotenv-0.3.1.0.tar.gz New: ---- dotenv-0.3.3.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-dotenv.spec ++++++ --- /var/tmp/diff_new_pack.iqyGg9/_old 2017-06-04 01:57:09.938776551 +0200 +++ /var/tmp/diff_new_pack.iqyGg9/_new 2017-06-04 01:57:09.942775986 +0200 @@ -19,7 +19,7 @@ %global pkg_name dotenv %bcond_with tests Name: ghc-%{pkg_name} -Version: 0.3.1.0 +Version: 0.3.3.0 Release: 0 Summary: Loads environment variables from dotenv files License: MIT ++++++ dotenv-0.3.1.0.tar.gz -> dotenv-0.3.3.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dotenv-0.3.1.0/CHANGELOG.md new/dotenv-0.3.3.0/CHANGELOG.md --- old/dotenv-0.3.1.0/CHANGELOG.md 2016-10-18 22:33:39.000000000 +0200 +++ new/dotenv-0.3.3.0/CHANGELOG.md 2017-05-09 22:11:22.000000000 +0200 @@ -1,3 +1,14 @@ +## MASTER + +## Dotenv 0.3.3.0 + +* Add support for variable expansion. Thanks to حبيب الامين (GitHub: habibalamin) for making this contribution. + +## Dotenv 0.3.2.0 + +* Add the option to pass arguments to the program passed to Dotenv. Thanks to + Oleg Grenrus (GitHub: phadej) for making this contribution. + ## Dotenv 0.3.1.0 * Made interface more polymorphic so the functions works in any instance of @@ -24,14 +35,14 @@ * Reverted change to Data.Text in favor of String, for maintaining compatibility with common Haskell system libraries. Added separate interface for parsing a file into tuples containing Data.Text values. Thanks to Daisuke Fujimura - (Github: fujimura). + (GitHub: fujimura). * Fixed parsing of CRLF characters for Windows users. ## Dotenv 0.2.0.0 (deprecated) * Changed public interfaces to use Data.Text. * Added function `parseFile` to read dotenv file without modifying the - environment. Thanks to Daisuke Fujimura (Github: fujimura) for making this + environment. Thanks to Daisuke Fujimura (GitHub: fujimura) for making this contribution. ## Dotenv 0.1.0.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dotenv-0.3.1.0/README.md new/dotenv-0.3.3.0/README.md --- old/dotenv-0.3.1.0/README.md 2016-06-27 09:06:07.000000000 +0200 +++ new/dotenv-0.3.3.0/README.md 2017-05-09 22:11:22.000000000 +0200 @@ -20,7 +20,7 @@ ## Installation In most cases you will just add `dotenv` to your cabal file. You can -also install the library and executable by invoking `cabal install dotenv`. +also install the library and executable by invoking `stack install dotenv`. ## Usage @@ -69,10 +69,17 @@ dotenv -f mydotenvfile myprogram ``` +Aditionally you can pass arguments and flags to the program passed to +Dotenv: + +``` +dotenv -f mydotenvfile myprogram -- --myflag myargument +``` + Hint: The `env` program in most Unix-like environments prints out the current environment settings. By invoking the program `env` in place of `myprogram` above you can see what the environment will look like -after evaluating multiple Dotenv files. +after evaluating multiple Dotenv files. ## Author @@ -84,4 +91,4 @@ ## Copyright -(C) 2015-2016 [Stack Builders Inc.](http://www.stackbuilders.com) +(C) 2015-2017 [Stack Builders Inc.](http://www.stackbuilders.com) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dotenv-0.3.1.0/app/Main.hs new/dotenv-0.3.3.0/app/Main.hs --- old/dotenv-0.3.1.0/app/Main.hs 2016-10-14 20:29:47.000000000 +0200 +++ new/dotenv-0.3.3.0/app/Main.hs 2017-05-02 21:11:56.000000000 +0200 @@ -17,8 +17,9 @@ data Options = Options { files :: [String] - , program :: String , overload :: Bool + , program :: String + , args :: [String] } deriving (Show) main :: IO () @@ -37,14 +38,18 @@ <> metavar "FILE" <> help "File to read for options" )) - <*> argument str (metavar "PROGRAM") - <*> switch ( long "overload" <> short 'o' <> help "Specify this flag to override existing variables" ) + <*> argument str (metavar "PROGRAM") + + <*> many (argument str (metavar "ARG")) + dotEnv :: MonadIO m => Options -> m () dotEnv opts = liftIO $ do mapM_ (loadFile (overload opts)) (files opts) - code <- system (program opts) + code <- system (program opts ++ programArguments) exitWith code + where + programArguments = concatMap (" " ++) (args opts) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dotenv-0.3.1.0/dotenv.cabal new/dotenv-0.3.3.0/dotenv.cabal --- old/dotenv-0.3.1.0/dotenv.cabal 2016-10-18 22:33:48.000000000 +0200 +++ new/dotenv-0.3.3.0/dotenv.cabal 2017-05-09 22:11:22.000000000 +0200 @@ -1,5 +1,5 @@ name: dotenv -version: 0.3.1.0 +version: 0.3.3.0 synopsis: Loads environment variables from dotenv files homepage: https://github.com/stackbuilders/dotenv-hs description: @@ -35,7 +35,7 @@ license-file: LICENSE author: Justin Leitgeb maintainer: [email protected] -copyright: 2015-2016 Stack Builders Inc. +copyright: 2015-2017 Stack Builders Inc. category: Configuration build-type: Simple extra-source-files: spec/fixtures/.dotenv @@ -70,6 +70,7 @@ library exposed-modules: Configuration.Dotenv , Configuration.Dotenv.Parse + , Configuration.Dotenv.ParsedVariable , Configuration.Dotenv.Text build-depends: base >=4.6 && <5.0 @@ -97,6 +98,7 @@ , Configuration.Dotenv , Configuration.Dotenv.Text , Configuration.Dotenv.Parse + , Configuration.Dotenv.ParsedVariable build-depends: base >=4.6 && <5.0 , base-compat >= 0.4 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dotenv-0.3.1.0/spec/Configuration/Dotenv/ParseSpec.hs new/dotenv-0.3.3.0/spec/Configuration/Dotenv/ParseSpec.hs --- old/dotenv-0.3.1.0/spec/Configuration/Dotenv/ParseSpec.hs 2016-10-17 20:47:28.000000000 +0200 +++ new/dotenv-0.3.3.0/spec/Configuration/Dotenv/ParseSpec.hs 2017-05-08 21:24:38.000000000 +0200 @@ -3,6 +3,9 @@ module Configuration.Dotenv.ParseSpec (main, spec) where import Configuration.Dotenv.Parse (configParser) +import Configuration.Dotenv.ParsedVariable (ParsedVariable(..), + VarValue(..), + VarFragment(..)) import Test.Hspec (it, describe, Spec, hspec) import Test.Hspec.Megaparsec (shouldParse, shouldFailOn) import Text.Megaparsec (ParseError, Dec, parse) @@ -13,29 +16,75 @@ spec :: Spec spec = describe "parse" $ do it "parses unquoted values" $ - parseConfig "FOO=bar" `shouldParse` [("FOO", "bar")] + parseConfig "FOO=bar" + `shouldParse` [ParsedVariable "FOO" (Unquoted [VarLiteral "bar"])] it "parses values with spaces around equal signs" $ do - parseConfig "FOO =bar" `shouldParse` [("FOO", "bar")] - parseConfig "FOO= bar" `shouldParse` [("FOO", "bar")] - parseConfig "FOO =\t bar" `shouldParse` [("FOO", "bar")] + parseConfig "FOO =bar" + `shouldParse` [ParsedVariable "FOO" (Unquoted [VarLiteral "bar"])] + parseConfig "FOO= bar" + `shouldParse` [ParsedVariable "FOO" (Unquoted [VarLiteral "bar"])] + parseConfig "FOO =\t bar" + `shouldParse` [ParsedVariable "FOO" (Unquoted [VarLiteral "bar"])] it "parses double-quoted values" $ - parseConfig "FOO=\"bar\"" `shouldParse` [("FOO", "bar")] + parseConfig "FOO=\"bar\"" + `shouldParse` [ParsedVariable "FOO" (DoubleQuoted [VarLiteral "bar"])] it "parses single-quoted values" $ - parseConfig "FOO='bar'" `shouldParse` [("FOO", "bar")] + parseConfig "FOO='bar'" + `shouldParse` [ParsedVariable "FOO" (SingleQuoted [VarLiteral "bar"])] it "parses escaped double quotes" $ parseConfig "FOO=\"escaped\\\"bar\"" - `shouldParse` [("FOO", "escaped\"bar")] + `shouldParse` [ParsedVariable "FOO" (DoubleQuoted [VarLiteral "escaped\"bar"])] it "supports CRLF line breaks" $ parseConfig "FOO=bar\r\nbaz=fbb" - `shouldParse` [("FOO", "bar"), ("baz", "fbb")] + `shouldParse` [ParsedVariable "FOO" (Unquoted [VarLiteral "bar"]), + ParsedVariable "baz" (Unquoted [VarLiteral "fbb"])] it "parses empty values" $ - parseConfig "FOO=" `shouldParse` [("FOO", "")] + parseConfig "FOO=" + `shouldParse` [ParsedVariable "FOO" (Unquoted [])] + + it "parses unquoted interpolated values" $ do + parseConfig "FOO=$HOME" + `shouldParse` [ParsedVariable "FOO" (Unquoted [VarInterpolation "HOME"])] + parseConfig "FOO=abc_$HOME" + `shouldParse` [ParsedVariable "FOO" (Unquoted [VarLiteral "abc_", + VarInterpolation "HOME"]) + ] + parseConfig "FOO=${HOME}" + `shouldParse` [ParsedVariable "FOO" (Unquoted [VarInterpolation "HOME"])] + parseConfig "FOO=abc_${HOME}" + `shouldParse` [ParsedVariable "FOO" (Unquoted [VarLiteral "abc_", + VarInterpolation "HOME"]) + ] + + it "parses double-quoted interpolated values" $ do + parseConfig "FOO=\"$HOME\"" + `shouldParse` [ParsedVariable "FOO" (DoubleQuoted [VarInterpolation "HOME"])] + parseConfig "FOO=\"abc_$HOME\"" + `shouldParse` [ParsedVariable "FOO" (DoubleQuoted [VarLiteral "abc_", + VarInterpolation "HOME"]) + ] + parseConfig "FOO=\"${HOME}\"" + `shouldParse` [ParsedVariable "FOO" (DoubleQuoted [VarInterpolation "HOME"])] + parseConfig "FOO=\"abc_${HOME}\"" + `shouldParse` [ParsedVariable "FOO" (DoubleQuoted [VarLiteral "abc_", + VarInterpolation "HOME"]) + ] + + it "parses single-quoted interpolated values as literals" $ do + parseConfig "FOO='$HOME'" + `shouldParse` [ParsedVariable "FOO" (SingleQuoted [VarLiteral "$HOME"])] + parseConfig "FOO='abc_$HOME'" + `shouldParse` [ParsedVariable "FOO" (SingleQuoted [VarLiteral "abc_$HOME"])] + parseConfig "FOO='${HOME}'" + `shouldParse` [ParsedVariable "FOO" (SingleQuoted [VarLiteral "${HOME}"])] + parseConfig "FOO='abc_${HOME}'" + `shouldParse` [ParsedVariable "FOO" (SingleQuoted [VarLiteral "abc_${HOME}"])] it "does not parse if line format is incorrect" $ do parseConfig `shouldFailOn` "lol$wut" @@ -43,46 +92,54 @@ parseConfig `shouldFailOn` "KEY\n=VALUE" it "expands newlines in quoted strings" $ - parseConfig "FOO=\"bar\nbaz\"" `shouldParse` [("FOO", "bar\nbaz")] + parseConfig "FOO=\"bar\nbaz\"" + `shouldParse` [ParsedVariable "FOO" (DoubleQuoted [VarLiteral "bar\nbaz"])] it "does not parse variables with hyphens in the name" $ parseConfig `shouldFailOn` "FOO-BAR=foobar" it "parses variables with \"_\" in the name" $ - parseConfig "FOO_BAR=foobar" `shouldParse` [("FOO_BAR", "foobar")] + parseConfig "FOO_BAR=foobar" + `shouldParse` [ParsedVariable "FOO_BAR" (Unquoted [VarLiteral "foobar"])] it "parses variables with digits after the first character" $ - parseConfig "FOO_BAR_12=foobar" `shouldParse` [("FOO_BAR_12", "foobar")] + parseConfig "FOO_BAR_12=foobar" + `shouldParse` [ParsedVariable "FOO_BAR_12" (Unquoted [VarLiteral "foobar"])] it "allows vertical spaces after a quoted variable" $ - parseConfig "foo='bar' " `shouldParse` [("foo", "bar")] + parseConfig "foo='bar' " + `shouldParse` [ParsedVariable "foo" (SingleQuoted [VarLiteral "bar"])] it "does not parse variable names beginning with a digit" $ parseConfig `shouldFailOn` "45FOO_BAR=foobar" it "strips unquoted values" $ - parseConfig "foo=bar " `shouldParse` [("foo", "bar")] + parseConfig "foo=bar " + `shouldParse` [ParsedVariable "foo" (Unquoted [VarLiteral "bar"])] it "ignores empty lines" $ parseConfig "\n \t \nfoo=bar\n \nfizz=buzz" - `shouldParse` [("foo", "bar"), ("fizz", "buzz")] + `shouldParse` [ParsedVariable "foo" (Unquoted [VarLiteral "bar"]), + ParsedVariable "fizz" (Unquoted [VarLiteral "buzz"])] it "ignores inline comments after unquoted arguments" $ - parseConfig "FOO=bar # this is foo" `shouldParse` [("FOO", "bar")] + parseConfig "FOO=bar # this is foo" + `shouldParse` [ParsedVariable "FOO" (Unquoted [VarLiteral "bar"])] it "ignores inline comments after quoted arguments" $ - parseConfig "FOO=\"bar\" # this is foo" `shouldParse` [("FOO", "bar")] + parseConfig "FOO=\"bar\" # this is foo" + `shouldParse` [ParsedVariable "FOO" (DoubleQuoted [VarLiteral "bar"])] it "allows \"#\" in quoted values" $ parseConfig "foo=\"bar#baz\" # comment" - `shouldParse` [("foo", "bar#baz")] + `shouldParse` [ParsedVariable "foo" (DoubleQuoted [VarLiteral "bar#baz"])] it "ignores comment lines" $ parseConfig "\n\t \n\n # HERE GOES FOO \nfoo=bar" - `shouldParse` [("foo", "bar")] + `shouldParse` [ParsedVariable "foo" (Unquoted [VarLiteral "bar"])] it "doesn't allow more configuration options after a quoted value" $ parseConfig `shouldFailOn` "foo='bar'baz='buz'" -parseConfig :: String -> Either (ParseError Char Dec) [(String, String)] +parseConfig :: String -> Either (ParseError Char Dec) [ParsedVariable] parseConfig = parse configParser "" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dotenv-0.3.1.0/spec/Configuration/DotenvSpec.hs new/dotenv-0.3.3.0/spec/Configuration/DotenvSpec.hs --- old/dotenv-0.3.1.0/spec/Configuration/DotenvSpec.hs 2016-10-18 22:33:39.000000000 +0200 +++ new/dotenv-0.3.3.0/spec/Configuration/DotenvSpec.hs 2017-05-08 21:24:38.000000000 +0200 @@ -8,6 +8,10 @@ import System.Environment (lookupEnv) import Control.Monad (liftM) +import Data.Maybe (fromMaybe) +#if !MIN_VERSION_base(4,8,0) +import Data.Functor ((<$>)) +#endif #if !MIN_VERSION_base(4,8,0) import Control.Applicative ((<$)) @@ -83,6 +87,15 @@ liftM (!! 1) (parseFile "spec/fixtures/.dotenv") `shouldReturn` ("UNICODE_TEST", "Manabí") + it "recognises environment variables" $ do + home <- fromMaybe "" <$> lookupEnv "HOME" + liftM (!! 2) (parseFile "spec/fixtures/.dotenv") `shouldReturn` + ("ENVIRONMENT", home) + + it "recognises previous variables" $ + liftM (!! 3) (parseFile "spec/fixtures/.dotenv") `shouldReturn` + ("PREVIOUS", "true") + describe "onMissingFile" $ after_ (unsetEnv "DOTENV") $ do context "when target file is present" $ it "loading works as usual" $ do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dotenv-0.3.1.0/spec/fixtures/.dotenv new/dotenv-0.3.3.0/spec/fixtures/.dotenv --- old/dotenv-0.3.1.0/spec/fixtures/.dotenv 2016-06-27 09:06:07.000000000 +0200 +++ new/dotenv-0.3.3.0/spec/fixtures/.dotenv 2017-05-08 21:24:38.000000000 +0200 @@ -1,2 +1,4 @@ DOTENV=true UNICODE_TEST=Manabí +ENVIRONMENT="$HOME" +PREVIOUS="$DOTENV" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dotenv-0.3.1.0/src/Configuration/Dotenv/Parse.hs new/dotenv-0.3.3.0/src/Configuration/Dotenv/Parse.hs --- old/dotenv-0.3.1.0/src/Configuration/Dotenv/Parse.hs 2016-10-17 20:47:28.000000000 +0200 +++ new/dotenv-0.3.3.0/src/Configuration/Dotenv/Parse.hs 2017-05-08 21:24:38.000000000 +0200 @@ -16,43 +16,60 @@ module Configuration.Dotenv.Parse (configParser) where +import Configuration.Dotenv.ParsedVariable import Control.Applicative import Control.Monad import Text.Megaparsec import Text.Megaparsec.String (Parser) import qualified Text.Megaparsec.Lexer as L +data QuoteType = SingleQuote | DoubleQuote + -- | Returns a parser for a Dotenv configuration file. Accepts key and value -- arguments separated by @=@. Comments in all positions are handled -- appropriately. -configParser :: Parser [(String, String)] +configParser :: Parser [ParsedVariable] configParser = between scn eof (sepEndBy1 envLine (eol <* scn)) -- | Parse a single environment variable assignment. -envLine :: Parser (String, String) -envLine = (,) <$> (lexeme variableName <* lexeme (char '=')) <*> lexeme value +envLine :: Parser ParsedVariable +envLine = ParsedVariable <$> (lexeme variableName <* lexeme (char '=')) <*> lexeme value -- | Variables must start with a letter or underscore, and may contain -- letters, digits or '_' character after the first character. -variableName :: Parser String +variableName :: Parser VarName variableName = ((:) <$> firstChar <*> many otherChar) <?> "variable name" where firstChar = char '_' <|> letterChar otherChar = firstChar <|> digitChar -- | Value: quoted or unquoted. -value :: Parser String +value :: Parser VarValue value = (quotedValue <|> unquotedValue) <?> "variable value" where - quotedValue = quotedWith '\'' <|> quotedWith '\"' - unquotedValue = many (noneOf "\'\" \t\n\r") + quotedValue = quotedWith SingleQuote <|> quotedWith DoubleQuote + unquotedValue = Unquoted <$> (many $ fragment "\'\" \t\n\r") -- | Parse a value quoted with given character. -quotedWith :: Char -> Parser String -quotedWith q = between (char q) (char q) (many $ escapedChar <|> normalChar) +quotedWith :: QuoteType -> Parser VarValue +quotedWith SingleQuote = SingleQuoted <$> (between (char '\'') (char '\'') $ many (literalValueFragment "\'\\")) +quotedWith DoubleQuote = DoubleQuoted <$> (between (char '\"') (char '\"') $ many (fragment "\"")) + +fragment :: [Char] -> Parser VarFragment +fragment charsToEscape = interpolatedValueFragment <|> literalValueFragment ('$' : '\\' : charsToEscape) + +interpolatedValueFragment :: Parser VarFragment +interpolatedValueFragment = VarInterpolation <$> + ((between (symbol "${") (symbol "}") variableName) <|> + (char '$' >> variableName)) + where + symbol = L.symbol sc + +literalValueFragment :: [Char] -> Parser VarFragment +literalValueFragment charsToEscape = VarLiteral <$> (some $ escapedChar <|> normalChar) where escapedChar = (char '\\' *> anyChar) <?> "escaped character" - normalChar = noneOf (q : "\\") <?> "unescaped character" + normalChar = noneOf charsToEscape <?> "unescaped character" ---------------------------------------------------------------------------- -- Boilerplate and whitespace setup diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dotenv-0.3.1.0/src/Configuration/Dotenv/ParsedVariable.hs new/dotenv-0.3.3.0/src/Configuration/Dotenv/ParsedVariable.hs --- old/dotenv-0.3.1.0/src/Configuration/Dotenv/ParsedVariable.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/dotenv-0.3.3.0/src/Configuration/Dotenv/ParsedVariable.hs 2017-05-08 21:24:38.000000000 +0200 @@ -0,0 +1,57 @@ +{-# LANGUAGE CPP #-} + +module Configuration.Dotenv.ParsedVariable (ParsedVariable(..), + VarName, + VarValue(..), + VarContents, + VarFragment(..), + interpolateParsedVariables) where + +import Control.Monad (foldM) +#if !MIN_VERSION_base(4,8,0) +import Data.Functor ((<$>)) +#endif +import Control.Applicative ((<|>)) +import System.Environment (lookupEnv) + +data ParsedVariable + = ParsedVariable VarName VarValue deriving (Show, Eq) + +type VarName = String + +data VarValue + = Unquoted VarContents + | SingleQuoted VarContents + | DoubleQuoted VarContents deriving (Show, Eq) + +type VarContents = [VarFragment] + +data VarFragment + = VarInterpolation String + | VarLiteral String deriving (Show, Eq) + +interpolateParsedVariables :: [ParsedVariable] -> IO [(String, String)] +interpolateParsedVariables = fmap reverse . foldM addInterpolated [] + +addInterpolated :: [(String, String)] -> ParsedVariable -> IO [(String, String)] +addInterpolated previous (ParsedVariable name value) = (: previous) <$> ((,) name <$> interpolate previous value) + +interpolate :: [(String, String)] -> VarValue -> IO String +interpolate _ (SingleQuoted contents) = return $ joinContents contents +interpolate previous (DoubleQuoted contents) = interpolateContents previous contents +interpolate previous (Unquoted contents) = interpolateContents previous contents + +interpolateContents :: [(String, String)] -> VarContents -> IO String +interpolateContents previous contents = concat <$> mapM (interpolateFragment previous) contents + +interpolateFragment :: [(String, String)] -> VarFragment -> IO String +interpolateFragment _ (VarLiteral value ) = return value +interpolateFragment previous (VarInterpolation varname) = fromPreviousOrEnv >>= maybe (return "") return + where + fromPreviousOrEnv = (lookup varname previous <|>) <$> lookupEnv varname + +joinContents :: VarContents -> String +joinContents = concatMap fragmentToString + where + fragmentToString (VarInterpolation value) = value + fragmentToString (VarLiteral value) = value diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dotenv-0.3.1.0/src/Configuration/Dotenv.hs new/dotenv-0.3.3.0/src/Configuration/Dotenv.hs --- old/dotenv-0.3.1.0/src/Configuration/Dotenv.hs 2016-10-18 22:33:39.000000000 +0200 +++ new/dotenv-0.3.3.0/src/Configuration/Dotenv.hs 2017-05-08 21:24:38.000000000 +0200 @@ -19,6 +19,7 @@ where import Configuration.Dotenv.Parse (configParser) +import Configuration.Dotenv.ParsedVariable (interpolateParsedVariables) import Control.Monad.Catch import Control.Monad.IO.Class (MonadIO(..)) import System.Environment (lookupEnv) @@ -60,7 +61,7 @@ case parse configParser f contents of Left e -> error $ "Failed to read file" ++ show e - Right options -> return options + Right options -> liftIO $ interpolateParsedVariables options applySetting :: MonadIO m => Bool -> (String, String) -> m () applySetting override (key, value) =
