turtle icon indicating copy to clipboard operation
turtle copied to clipboard

Check if an environment variable is set

Open 9999years opened this issue 1 year ago • 1 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

9999years avatar Feb 29 '24 00:02 9999years

Let me know if https://github.com/Gabriella439/turtle/pull/454 looks okay to you

Gabriella439 avatar Mar 02 '24 05:03 Gabriella439