sops
sops copied to clipboard
Quotes in env formatted file are handled unexpectedly when using exec-env
When using exec-env
on an env formatted file, quotes are included in the resulting environment variable.
secrets.env
:
secret1='foo'
secret2="bar"
$ sops exec-env secrets.env 'echo $secret1'
'foo'
$ sops exec-env secrets.env 'echo $secret2'
"bar"
I would expect that environment variables would be set as if the file was source
ed or the variables were defined manually.
$ secret1='foo'; echo $secret1
foo
$ secret2="bar"; echo $secret2
bar
I realize this probably isn't actually a bug and it makes sense that the environment variable is set to the literal value in the context of other formats, but I think there should be special handling for quotes when the env
format is used.
Is this expected? Is there a workaround besides defining dotenv files without quotes?
This is expected.
The dotenv file format sops implements is very simple, files are split by \n
, and every line can be one of the three forms:
- line is empty;
- starting with
#
: comment; - contains a
=
: everything before=
is the key, everything after the value; the literal string"\n"
in the value is converted to a newline.
According to this file format quotes are part of the value.