Bash 进程替换用作选项值
Bash process substitution used as an option value
我正在尝试 运行
docker-compose --env-file <(cat file1.env <(echo -e "\n\n") file2.env) config
docker-compose
期望 --env-file
是一个文件。我需要使用(连接)两个文件。
运行 docker-compose --env-file file_any.env config
效果很好。
运行cat file1.env <(echo -e "\n\n") file2.env
分别输出有效结果
但它不适用于 docker-compose
。
我做错了什么?
您不需要额外的进程替换。外部进程替换捕获 所有 它包装的命令的标准输出,因此您不限于单个 cat
命令。
docker-compose --env-file <( cat file1.env; printf '\n\n'; cat file2.env) config
不幸的是,docker-compose
要求 --env-file
的参数是一个真实的文件。参数的值直接传递给 Environment.from_env_file
, which makes an explicit check via env_vars_from_file
:
def env_vars_from_file(filename, interpolate=True):
"""
Read in a line delimited file of environment variables.
"""
if not os.path.exists(filename):
raise EnvFileNotFound("Couldn't find env file: {}".format(filename))
<b>elif not os.path.isfile(filename):
raise EnvFileNotFound("{} is not a file.".format(filename))</b>
...
我正在尝试 运行
docker-compose --env-file <(cat file1.env <(echo -e "\n\n") file2.env) config
docker-compose
期望 --env-file
是一个文件。我需要使用(连接)两个文件。
运行 docker-compose --env-file file_any.env config
效果很好。
运行cat file1.env <(echo -e "\n\n") file2.env
分别输出有效结果
但它不适用于 docker-compose
。
我做错了什么?
您不需要额外的进程替换。外部进程替换捕获 所有 它包装的命令的标准输出,因此您不限于单个 cat
命令。
docker-compose --env-file <( cat file1.env; printf '\n\n'; cat file2.env) config
不幸的是,docker-compose
要求 --env-file
的参数是一个真实的文件。参数的值直接传递给 Environment.from_env_file
, which makes an explicit check via env_vars_from_file
:
def env_vars_from_file(filename, interpolate=True):
"""
Read in a line delimited file of environment variables.
"""
if not os.path.exists(filename):
raise EnvFileNotFound("Couldn't find env file: {}".format(filename))
<b>elif not os.path.isfile(filename):
raise EnvFileNotFound("{} is not a file.".format(filename))</b>
...