Coder Social home page Coder Social logo

Comments (4)

jsl avatar jsl commented on June 11, 2024

@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:

  1. Dotenv for Node.js has variable expansion as a separate module.
  2. Ruby dotenv does tilde expansion.
  3. 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.

jpvillaisaza avatar jpvillaisaza commented on June 11, 2024

@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.

habibalamin avatar habibalamin commented on June 11, 2024

I ran a test using the dotenvgem, 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.

CristhianMotoche avatar CristhianMotoche commented on June 11, 2024

I think we can close this issue, because of #42
Thanks a lot @habibalamin

from dotenv-hs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.