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

[ShellScript] Apply to .env #3496

Closed
wants to merge 1 commit into from
Closed

[ShellScript] Apply to .env #3496

wants to merge 1 commit into from

Conversation

scop
Copy link

@scop scop commented Oct 4, 2022

This commit makes us apply shell script syntax to *.env and .env files. These files are commonly used to store environment variables to be sourced or loaded otherwise, in shell syntax, often a simple subset of it.

This commit makes us apply shell script syntax to `*.env` and `.env`
files. These files are commonly used to store environment variables to
be sourced or loaded otherwise, in shell syntax, often a simple subset
of it.
Copy link
Collaborator

@jfcherng jfcherng left a comment

Choose a reason for hiding this comment

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

Make sense to my experience.

@@ -24,6 +25,7 @@ hidden_file_extensions:
- .bash_profile
- .bash_variables
- .bashrc
- .env
Copy link
Collaborator

Choose a reason for hiding this comment

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

I've also seen .env.local for environment variables which are only sourced for the local development environment. I'm not sure how common it is and whether it would be worth adding this as well?

Copy link
Author

Choose a reason for hiding this comment

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

No real opinion here, but if we go that route, other similar candidates for consideration would include .env.test, .env.ci, .env.dev, .env.development, .env.stg, .env.staging, .env.prod, and .env.production.

I suppose something like .env.* does not work here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I suppose something like .env.* does not work here?

No.

@jrappen
Copy link
Contributor

jrappen commented Oct 4, 2022

It's not "real" ShellScript, though:

@scop
Copy link
Author

scop commented Oct 4, 2022

It's not "real" ShellScript, though:

True. The linked examples are just some implementations, there are more, and there is not a single source of truth for these files. In absence of a dedicated syntax, in my opinion and experience they're in practice either actual shell syntax, or close enough that this association makes sense.

Even if there was a dedicated syntax, I'm not sure it would do better than ShellScript.

@jfcherng
Copy link
Collaborator

jfcherng commented Oct 4, 2022

Even if there was a dedicated syntax

https://packagecontrol.io/packages/DotENV

Maybe personally I won't call this one is better since I've some dedicate coloring rules for the built-in Bash syntax to have Bash looks great already.

No real opinion here, but if we go that route, other similar candidates for consideration would include .env.test, .env.ci, .env.dev, .env.development, .env.stg, .env.staging, .env.prod, and .env.production.

😄 https://github.com/zaynali53/DotENV/blob/58201ba2abbbe6a12b2f6d0595efea3b388c1e38/DotENV.tmLanguage#L7-L26

@frou
Copy link
Contributor

frou commented Oct 4, 2022

If adding more than 1, also consider .envrc for direnv, which is a fairly popular tool.

BTW that's an example of where the files truly are Bash scripts.

@deathaxe
Copy link
Collaborator

deathaxe commented Oct 5, 2022

I am uncertain whether we should add too common file extensions to core packages as it is easy to add custom extension bindings via "Always open with..." while its harder to get rid of those which are already pre-defined.

@scop
Copy link
Author

scop commented Oct 5, 2022

To be fair, my use case is to get env files colorised by bat, and I just submitted the change I planned here for consistency. Turns out I hadn't done my homework and they were actually already partially done in bat (using DotENV), so I submitted sharkdp/bat#2356 (and zaynali53/DotENV#17) instead.

Given that DotENV exists and is apparently quite popular, it might be prudent to skip doing this here. Leaving open in case there are other opinions, but I won't pursue this further.

@deathaxe deathaxe closed this Oct 8, 2022
@scop scop deleted the shellscript-env branch October 11, 2022 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants