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 dotenv (Shell) #4922

Merged
merged 2 commits into from
Aug 24, 2020
Merged

Add support for dotenv (Shell) #4922

merged 2 commits into from
Aug 24, 2020

Conversation

smola
Copy link
Contributor

@smola smola commented Jul 10, 2020

Fixes #4873

  • Associate *.env, .env, .env.example and .flaskenv to Shell.

Add samples:

Description

dotenv files is a convention to use a subset of shell (commonly known as dotenv) to setup an environment.

The modern convention probably originates from the Ruby world in 2012 (see bkeepers/dotenv) and the supported syntax is roughly the following (although packages for different languages may support a more limited subset):

# comments
KEY=value
KEY="value"
export KEY=value
KEY=${variable}
KEY=$(command)

Anyway, you may find lots of samples in the wild using full Bash syntax (see the links to GitHub Search below).

Checklist:

You may find some counter-examples, but not with wide usage as far as I see:

Copy link
Contributor

@pchaigno pchaigno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nit below. Usage looks good, so LGTM otherwise!

@@ -0,0 +1,2 @@
# comment
export KEY=${ENV}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to find sample files from "real" applications here instead of using fixture files? Fixture files are not used to train the Bayesian classifier, so I'd really prefer to avoid them as much as possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pchaigno Ok, I'll add some!

@smola
Copy link
Contributor Author

smola commented Jul 11, 2020

Please, see the discussion the issue: #4873
Some languages may have syntax rules are not strictly a subset of Bash. At least for Node.js, where VAR={"some": "json"} is valid, but not in Bash (or any other mainstream shell). So we may still have some .env files with some highlighting errors after this change. Unfortunately, I don't see a better alternative, since using a dotenv-specific grammar may incorrectly highlight the files for many other languages that allow different extensions, or for bull Bash itself.

@smola
Copy link
Contributor Author

smola commented Jul 11, 2020

To add some more fun, the Ruby library supports YAML-like variables: https://github.com/bkeepers/dotenv/blob/master/spec/fixtures/yaml.env

@smola smola requested a review from pchaigno July 31, 2020 09:54
@lildude lildude merged commit d1aa5cd into github-linguist:master Aug 24, 2020
@lildude lildude changed the title add support for dotenv (Shell) Add support for dotenv (Shell) Aug 24, 2020
@smola smola deleted the dotenv branch August 27, 2020 14:05
sambacha pushed a commit to freight-trust/linguist that referenced this pull request Sep 4, 2020
@github-linguist github-linguist locked as resolved and limited conversation to collaborators Jun 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dotenv syntax highlighting support
3 participants