Comments (4)
@jpvillaisaza I think that this is a good initiative. Thanks for opening this issue. We should think about how other libraries implement this sort of feature, and think critically about the best way to proceed.
I noticed that:
- Dotenv for Node.js has variable expansion as a separate module.
- Ruby dotenv does tilde expansion.
- Python has notes about possible POSIX-compliant variable expansion.
I agree with the general idea of adding functionality to the dotenv templates. However, we may just want to proceed slowly, and based on standards wherever possible so that we don't introduce something that we regret later. We may also want to separate the notion of path expansion from full POSIX-compliant variable expansion and consider those two separately.
What do you think?
from dotenv-hs.
@jsl Yes, sounds good. I saw the issue for the Python one before opening this issue. I don't have experience with this library (use or development), so I can start taking a look and we can add notes here to think of the best way.
from dotenv-hs.
I ran a test using the dotenv
gem, and I think their implementation is sensible. Given how many different implementations of dotenv
there are in different languages, I think a standard may be useful to codify.
.env
file:
START='this is a test' # test with spaces
REFERENCE_TO_START=$START
UNQUOTED_REFERENCE=$HOME
UNQUOTED_REFERENCE_WITH_EXTRA=$HOME_abc
UNQUOTED_REFERENCE_WITH_BRACES=${HOME}
UNQUOTED_REFERENCE_WITH_BRACES_AND_EXTRA=${HOME}_abc
SINGLE_QUOTED_REFERENCE='$HOME'
SINGLE_QUOTED_REFERENCE_WITH_EXTRA='$HOME_abc'
SINGLE_QUOTED_REFERENCE_WITH_BRACES='${HOME}'
SINGLE_QUOTED_REFERENCE_WITH_BRACES_AND_EXTRA='${HOME}_abc'
DOUBLE_QUOTED_REFERENCE="$HOME"
DOUBLE_QUOTED_REFERENCE_WITH_EXTRA="$HOME_abc"
DOUBLE_QUOTED_REFERENCE_WITH_BRACES="${HOME}"
DOUBLE_QUOTED_REFERENCE_WITH_BRACES_AND_EXTRA="${HOME}_abc"
UNQUOTED_SHELL_INTERPOLATION_WITH_PARENS=$(whoami)
UNQUOTED_SHELL_INTERPOLATION_WITH_BACKTICKS=`whoami`
UNQUOTED_SHELL_INTERPOLATION_WITH_PARENS_AND_EXTRA=$(whoami)_abc
UNQUOTED_SHELL_INTERPOLATION_WITH_BACKTICKS_AND_EXTRA=`whoami`_abc
SINGLE_QUOTED_SHELL_INTERPOLATION_WITH_PARENS='$(whoami)'
SINGLE_QUOTED_SHELL_INTERPOLATION_WITH_BACKTICKS='`whoami`'
SINGLE_QUOTED_SHELL_INTERPOLATION_WITH_PARENS_AND_EXTRA='$(whoami)_abc'
SINGLE_QUOTED_SHELL_INTERPOLATION_WITH_BACKTICKS_AND_EXTRA='`whoami`_abc'
DOUBLE_QUOTED_SHELL_INTERPOLATION_WITH_PARENS="$(whoami)"
DOUBLE_QUOTED_SHELL_INTERPOLATION_WITH_BACKTICKS="`whoami`"
DOUBLE_QUOTED_SHELL_INTERPOLATION_WITH_PARENS_AND_EXTRA="$(whoami)_abc"
DOUBLE_QUOTED_SHELL_INTERPOLATION_WITH_BACKTICKS_AND_EXTRA="`whoami`_abc"
Output of each variable (puts "VARIABLE: #{ENV['VARIABLE']}"
):
START: this is a test
REFERENCE_TO_START: this is a test
UNQUOTED_REFERENCE: /Users/Habib
UNQUOTED_REFERENCE_WITH_EXTRA:
UNQUOTED_REFERENCE_WITH_BRACES: /Users/Habib
UNQUOTED_REFERENCE_WITH_BRACES_AND_EXTRA: /Users/Habib_abc
SINGLE_QUOTED_REFERENCE: $HOME
SINGLE_QUOTED_REFERENCE_WITH_EXTRA: $HOME_abc
SINGLE_QUOTED_REFERENCE_WITH_BRACES: ${HOME}
SINGLE_QUOTED_REFERENCE_WITH_BRACES_AND_EXTRA: ${HOME}_abc
DOUBLE_QUOTED_REFERENCE: /Users/Habib
DOUBLE_QUOTED_REFERENCE_WITH_EXTRA:
DOUBLE_QUOTED_REFERENCE_WITH_BRACES: /Users/Habib
DOUBLE_QUOTED_REFERENCE_WITH_BRACES_AND_EXTRA: /Users/Habib_abc
UNQUOTED_SHELL_INTERPOLATION_WITH_PARENS: Habib
UNQUOTED_SHELL_INTERPOLATION_WITH_BACKTICKS: `whoami`
UNQUOTED_SHELL_INTERPOLATION_WITH_PARENS_AND_EXTRA: Habib_abc
UNQUOTED_SHELL_INTERPOLATION_WITH_BACKTICKS_AND_EXTRA: `whoami`_abc
SINGLE_QUOTED_SHELL_INTERPOLATION_WITH_PARENS: $(whoami)
SINGLE_QUOTED_SHELL_INTERPOLATION_WITH_BACKTICKS: `whoami`
SINGLE_QUOTED_SHELL_INTERPOLATION_WITH_PARENS_AND_EXTRA: $(whoami)_abc
SINGLE_QUOTED_SHELL_INTERPOLATION_WITH_BACKTICKS_AND_EXTRA: `whoami`_abc
DOUBLE_QUOTED_SHELL_INTERPOLATION_WITH_PARENS: Habib
DOUBLE_QUOTED_SHELL_INTERPOLATION_WITH_BACKTICKS: `whoami`
DOUBLE_QUOTED_SHELL_INTERPOLATION_WITH_PARENS_AND_EXTRA: Habib_abc
DOUBLE_QUOTED_SHELL_INTERPOLATION_WITH_BACKTICKS_AND_EXTRA: `whoami`_abc
from dotenv-hs.
I think we can close this issue, because of #42
Thanks a lot @habibalamin
from dotenv-hs.
Related Issues (20)
- Fix static file generation on CI HOT 1
- Verbose option (for CLI and command) HOT 4
- Allow/Forbid duplicated env variables in file HOT 2
- `loadFile` return value HOT 3
- Release GH Action fails but doesn't stop the workflow
- Make parsing function available in cabal package HOT 5
- Add a flag to allow verification of environment variables before program execution HOT 2
- Introduce a .dotenv.config file to store and read flags for Dotenv CLI HOT 1
- Add All Contributors HOT 1
- Support optparse-applicative 0.18 HOT 2
- How to provide JSON as a value to the env var HOT 5
- Release 0.11.0.2 to Hackage? HOT 3
- Review warnings on Publish Release HOT 6
- Be able to do variable substitution when the content is inside quotes HOT 1
- Parse content that starts with curly brackets HOT 2
- Document .env search behavior in Cabal monorepo HOT 4
- Add basic use case or example HOT 1
- Rename `master` branch to `main`
- parseFile doesn't seem to escape characters as expected HOT 3
- Use `kleidukos/get-tested` and include GHC supported versions in cabal file
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dotenv-hs.