compose-spec / compose-go

Reference library for parsing and loading Compose YAML files

Home Page:https://compose-spec.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

character '-' dash no longer valid environment variable

asyarif93 opened this issue · comments

got this error unexpected character "-" in variable name near "AIRFLOW_CONN_COMPOSER-WORKER-SAMPLE..."

afaik, specs for env is IEEE Std 1003.1-2001 - any printable character but = and NUL is valid

i'm not sure if the problems come from this lib or docker/compose

please close this issue if it's not relevant in this repository.

thank you

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"

then i read the article wrong, i think we can close this. thanks for the effort

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

Agree, let's reopen this one, until there's some technical reason that prevent us to accept - within environment variables

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.