Skip to content

Commit

Permalink
Document using || to provide default for empty environment variable (
Browse files Browse the repository at this point in the history
  • Loading branch information
casey authored Dec 22, 2024
1 parent 7909958 commit 206b089
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1645,11 +1645,11 @@ olleh := shell('import sys; print(sys.argv[2][::-1])', 'hello')

#### Environment Variables

- `env_var(key)` — Retrieves the environment variable with name `key`, aborting
- `env(key)` — Retrieves the environment variable with name `key`, aborting
if it is not present.

```just
home_dir := env_var('HOME')
home_dir := env('HOME')
test:
echo "{{home_dir}}"
Expand All @@ -1665,6 +1665,15 @@ $ just
- `env(key)`<sup>1.15.0</sup> — Alias for `env_var(key)`.
- `env(key, default)`<sup>1.15.0</sup> — Alias for `env_var_or_default(key, default)`.

A default can be substituted for an empty environment variable value with the
`||` operator, currently unstable:

```just
set unstable
foo := env('FOO') || 'DEFAULT_VALUE'
```

#### Invocation Information

- `is_dependency()` - Returns the string `true` if the current recipe is being
Expand Down

0 comments on commit 206b089

Please sign in to comment.