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

Allow for default value in ${localEnv:...} and ${containerEnv:...} #63

Closed
chrmarti opened this issue Jul 19, 2022 · 2 comments
Closed
Assignees
Labels
active proposal Still under discussion, collecting feedback
Milestone

Comments

@chrmarti
Copy link
Contributor

chrmarti commented Jul 19, 2022

Goal

String values in the devcontainer.json can contain ${localEnv:ENV_VAR} and ${containerEnv:ENV_VAR} placeholders which are replaced with the (either the local or the container) ENV_VAR environment variable's value at runtime. The goal is to allow for a default value to be specified as part of the syntax that will be used when the ENV_VAR is not set.

Proposal

The proposal is to add an optional default value separated by a second colon in the existing notation: ${localEnv:ENV_VAR:default_value} and ${containerEnv:ENV_VAR:default_value} and to replace the notation with the default value when there is no ENV_VAR environment variable at runtime. The existing behavior without a default value remains unchanged.

Notes

We have a PR from the community implementing this proposal: devcontainers/cli#51

@chrmarti chrmarti added proposal Still under discussion, collecting feedback active labels Jul 19, 2022
@chrmarti chrmarti added this to the July 2022 milestone Jul 19, 2022
@chrmarti chrmarti self-assigned this Jul 19, 2022
@chrmarti
Copy link
Contributor Author

chrmarti commented Jul 22, 2022

On the potential need to escape : when it is part of an environment variable name: I can't find a way to use : as part of an environment variable's name in Bash or /bin/sh. When spawning a process without shell, it is possible to use : in a variable name. Given the difficulty in using it (i.e., unsupported in common shells), I suggest we don't need to support it. /cc @jkeech

(REMOVED: The original ask was to use :- as the separator to align with common shell syntax. Updating to that.)

@chrmarti
Copy link
Contributor Author

Spec PR: #64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
active proposal Still under discussion, collecting feedback
Projects
None yet
Development

No branches or pull requests

2 participants