Gabriella439 / turtle

Shell programming, Haskell style

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Check if an environment variable is set

9999years opened this issue · comments

In Bash, it's very common to check if an environment is set and non-empty with [[ -n "${VAR:-}" ]]. We should provide helpers for this, like so:

hasEnv :: Text -> IO Bool
hasEnv = not . missingEnv

missingEnv :: Text -> IO Bool
missingEnv name = null $ fromMaybe "" $ need name

Let me know if #454 looks okay to you