Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Mark Lavi edited this page Jan 23, 2024 · 2 revisions

check_env is a test to check if environment variable(s) exist.

Choose from two methods:

  • Create or append to ~/.config/direnv/direnvrc a function with the contents below
  • Create ~/.config/direnv/lib/check_env.sh with the contents below
check_env() { local ret=0; for var in "$@"; do [[ -v $var ]] || { echo "$var is missing"; ret=1; }; done; return $ret; }

Usage

$ check_env HOME FOO BAR
FOO is missing
BAR is missing
$ echo $?
1

Clone this wiki locally

Morty Proxy This is a proxified and sanitized view of the page, visit original site.