fix getenv + reuse non debug mode
This commit is contained in:
parent
2dace09a0d
commit
3cc7d380d1
2 changed files with 7 additions and 5 deletions
|
@ -12,7 +12,7 @@ import Pipes
|
||||||
import Prelude (String, lines)
|
import Prelude (String, lines)
|
||||||
import Protolude hiding (for, many, show, (<|>))
|
import Protolude hiding (for, many, show, (<|>))
|
||||||
import System.Console.Haskeline
|
import System.Console.Haskeline
|
||||||
-- import System.Environment (getEnvironment)
|
import System.Environment (getEnvironment)
|
||||||
import Text.Parsec (ParseError)
|
import Text.Parsec (ParseError)
|
||||||
|
|
||||||
import Lish.Eval
|
import Lish.Eval
|
||||||
|
@ -22,9 +22,8 @@ import Lish.Types
|
||||||
-- | Start an interactive lish shell
|
-- | Start an interactive lish shell
|
||||||
runLish :: IO ()
|
runLish :: IO ()
|
||||||
runLish = do
|
runLish = do
|
||||||
-- env <- toEnv <$> getEnvironment
|
env <- toEnv <$> getEnvironment
|
||||||
-- runInputT defaultSettings (mainLoop env)
|
runInputT defaultSettings (mainLoop env)
|
||||||
runInputT defaultSettings (mainLoop (toEnv []))
|
|
||||||
|
|
||||||
-- | System Environment -> LISH Env
|
-- | System Environment -> LISH Env
|
||||||
toEnv :: [(String,String)] -> Env
|
toEnv :: [(String,String)] -> Env
|
||||||
|
|
|
@ -63,7 +63,10 @@ getenv :: ReduceUnawareCommand
|
||||||
getenv ((Atom varname):[]) = do
|
getenv ((Atom varname):[]) = do
|
||||||
hm <- get
|
hm <- get
|
||||||
return $ fromMaybe Void (Map.lookup varname hm)
|
return $ fromMaybe Void (Map.lookup varname hm)
|
||||||
getenv _ = evalErr "getenv need on atom as argument"
|
getenv ((Str varname):[]) = do
|
||||||
|
hm <- get
|
||||||
|
return $ fromMaybe Void (Map.lookup varname hm)
|
||||||
|
getenv _ = evalErr "getenv need on atom or a string as argument"
|
||||||
|
|
||||||
-- | replace à la `sed s/old/new/g text`
|
-- | replace à la `sed s/old/new/g text`
|
||||||
replace :: ReduceUnawareCommand
|
replace :: ReduceUnawareCommand
|
||||||
|
|
Loading…
Reference in a new issue