Are there any tests or examples of `${ENVVAR{-|?|+|:}...}` notation?
Are there any tests or examples of ${ENVVAR{-|?|+|:}...} notation?
This notation does not work for me as I expect. Before claiming it's a bug, I would take a look at tests or examples, if any.
That sounds like you want to request a feature. Here's the code: https://github.com/tonerdo/dotnet-env/blob/09e217511bc8ac7a603b4ad183e0cfd80c252c21/src/DotNetEnv/Parsers.cs#L208
I know that bash offers such a syntax, but idk if other .env parsers do. If you want to add the tests, the implementation probably wouldn't be too too hard, but it's definitely not a trivial addition.
Bash docs on this: https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html
Like I said, the reason of the post is that this interpolation is not working, basically at all. At this point it is known not working for me, so I wondered if there is any prove of it is actually working. Like tests or concrete example "if you do this you get this", not just docs.
E.g. this .env after loading (given ENVVAR is not set, USERNAME is set):
# value of ENVVAR if set and non-empty, otherwise exit with error
KEY1=${ENVVAR:?error}
KEY2=${ENVVAR?error}
KEY3=${USERNAME:?error}
KEY4=${USERNAME?error}
gives these env variables set
KEY1=${ENVVAR:?error}
KEY2=${ENVVAR?error}
KEY3=${USERNAME:?error}
KEY4=${USERNAME?error}
This looks unexpected. I expect KEY1 and KEY2 failing, KEY3 and KEY4 set to the user name.
@rogusdev Do you get the same result or am I doing something wrong?
Interpolation works great. You are just attempting to do advanced bash specific things that are not implemented in this lib at all, and so I pointed you at where you could add the feature if you want. I also called out that I don't know if other env libs have such a feature as well.
There are no docs for a thing that is not present. There is no bug because this is behaving as intended. If you want it to behave that way, I invite your PR to add that feature :)
Ah, I see, good. I do not need this, but users of my soft may expect advanced interpolation working. Because there are docs, actually: https://github.com/tonerdo/dotnet-env/blob/09e217511bc8ac7a603b4ad183e0cfd80c252c21/README.md?plain=1#L196-L209
I'm using this very handy library (many thanks!) in https://github.com/nightroman/PSRest And in my docs I send users to your docs. So they may be confused as I am, too. E.g. this help https://github.com/nightroman/PSRest/blob/main/docs/Import-RestDotEnv.md tells
PSRest reads .env files using DotNetEnv. See ".env file structure":
https://github.com/tonerdo/dotnet-env/blob/master/README.md#env-file-structure
and https://github.com/tonerdo/dotnet-env/blob/master/README.md#env-file-structure leads to confusing (not working) docs.
Huh, that is indeed interesting. I totally forgot about approving and merging that PR, which does indeed have tests: https://github.com/tonerdo/dotnet-env/pull/110/files#diff-cb9e6096ac3f2bba3805354c39d1ef1bb1dab4ab6e706fadf32b3c904565c688R138 I will have to dig deeper to see how that is implemented now that I am reminded of it.