Comments (5)
Not sure if this is related or not but digging up from
https://stackoverflow.com/questions/2821043/allowed-characters-in-linux-environment-variable-names
https://pubs.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap08.html
we can see
Environment variable names used by the utilities in the Shell and Utilities volume of IEEE Std 1003.1-2001 consist solely of uppercase letters, digits, and the '_' (underscore) from the characters defined
so I assume it's then up to each shell implementation. E.g. in Bash
↳ bash --version
GNU bash, version 5.2.2(1)-release (aarch64-apple-darwin22.1.0)
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
↳ export MY-VAR="foobar"
-bash: export: `MY-VAR=foobar': not a valid identifier
↳ export MY_VAR="foobar"
from compose-go.
then i read the article wrong, i think we can close this. thanks for the effort
from compose-go.
You're both right!
Here's an expanded snippet from IEEE Std 1003.1, 2004 Edition :: 8.1 (emphasis mine):
These strings have the form name=value; names shall not contain the character '='. For values to be portable across systems conforming to IEEE Std 1003.1-2001, the value shall be composed of characters from the portable character set (except NUL and as indicated below). There is no meaning associated with the order of strings in the environment. If more than one string in a process' environment has the same name, the consequences are undefined.
Environment variable names used by the utilities in the Shell and Utilities volume of IEEE Std 1003.1-2001 consist solely of uppercase letters, digits, and the '_' (underscore) from the characters defined in Portable Character Set and do not begin with a digit. Other characters may be permitted by an implementation; applications shall tolerate the presence of such names
Currently, Compose MOSTLY behaves like a Shell - uppercase letters, digits, & _
. We do also allow .
as a valid character due to its prevalence in many Java frameworks for environment variable overrides.
I don't think we want to open up to all non-NUL but I could see allowing -
if a similar argument to .
can be made, i.e. there's widespread use of -
from popular frameworks/languages.
TL;DR Stick to alphanumeric + _
for compatibility purposes with Shell & other apps
from compose-go.
Agree, let's reopen this one, until there's some technical reason that prevent us to accept -
within environment variables
from compose-go.
TL;DR Stick to alphanumeric + _ for compatibility purposes with Shell & other apps
Looks like this rule of thumb has already been broken in #271. The justification being that .
was support in v1 which appears to be true for -
as the current "work-around" found online is to use v1.
from compose-go.
Related Issues (20)
- panic: runtime error: invalid memory address or nil pointer dereference when docker-compose.yaml empty HOT 2
- Add Usage into README
- Project name not checked when using ToConfigFiles HOT 1
- Target ports cannot be set to range when using long syntax HOT 5
- Regression: Decode errors are ignored
- Build error on override/merge.go line 129
- Environment copied before being mutated HOT 3
- Marshalling produces invalid compose file HOT 4
- Label cannot be set to empty value in v2 HOT 1
- Support URLs as config files
- Validation doesn't catch multiple services with the same container_name HOT 1
- Bug report: `panic: interface conversion: interface {} is string, not int` HOT 1
- Added validation for container_name broken with profiles HOT 1
- Selinux key in verbose bind mount not recognized despite being in schema HOT 2
- Label not added when lables field is not defined in `docker-compose.yml` HOT 1
- Recursion in getStatementStart could be a loop HOT 1
- WithOsEnv assumes wrongly that os.Environ() returns only strings containing an equal sign HOT 4
- Version warning message causing lots of churn amongst projects with minimal benefit HOT 3
- dotenv parser shows wrong line number after inheritance syntax HOT 1
- dotenv octal escape unexpected behavior HOT 2
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 compose-go.