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

Add support for shell parameter substitution modifiers #139

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nthuemmel-scontain
Copy link

This adds support for the basic shell parameter substitution modifiers (which make sense for this crate), as described in https://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06_02

Namely, it adds the following features:

  • Use default values if a variable is unset or empty (${VAR:-default} or ${VAR-default})
  • Error out of a variable is unset or empty (${VAR:?} or ${VAR?})
  • Replace value if a variable is set (${VAR:+replacement} or ${VAR+replacement})

@allan2
Copy link
Owner

allan2 commented Jan 9, 2025

Thanks for this detailed PR.

Tasks for review:

  • See if dotenv libraries in other languages, such as Ruby and go, support this functionality.
  • POSIX-shell compliance is not a current goal of this library. I'd see if there is anything else not POSIX-compliant currently implemented, to see if it should be a goal.

If you or anyone has time to help with those tasks, that would be great. Otherwise, I will start looking into it in a week!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants