Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document using || to provide default for empty environment variable #2545

Merged
merged 1 commit into from
Dec 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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')
Comment on lines -1648 to +1652
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why removing the documentation of env_var()?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

env(…) has been around for a while now, and is a shorter alias of env_var, so I figure I'd update that part of the docs to use the shorter version.


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
Loading