Add support for shell parameter substitution modifiers#139
Add support for shell parameter substitution modifiers#139nthuemmel-scontain wants to merge 1 commit intoallan2:masterfrom
Conversation
|
Thanks for this detailed PR. Tasks for review:
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! |
Though the issues - and demand for such functionality - seem to be there ;)
I don't think full POSIX-shell compliance should be a goal either, especially regarding the security implications of spawning arbitrary subshells. However, some features, like default values in variable substitutions, do not have these implications and are simply nice-to-have. As long as these features are properly documented and maintainable, it still makes sense to support them without full POSIX-shell compliance, from my perspective. |
|
@nthuemmel-scontain, thank you for the detailed reply. I'm going to sit on this for now, update the API, and then come back to this potential feature. #19 related |
Docker Compose uses this. E.g. in a The Docker Compose interpolation syntax is often very useful to construct values. |
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:
${VAR:-default}or${VAR-default})${VAR:?}or${VAR?})${VAR:+replacement}or${VAR+replacement})