Skip to content

Commit 0d38d49

Browse files
dfndr-1tianon
authored andcommitted
Better ENV variables handling.
In case when env contain variables with newlines, the variables substitution script fails, trying to use non-existent variables. See nginx#560 for more details. Co-authored-by: Tianon Gravi <[email protected]>
1 parent 4680ae8 commit 0d38d49

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

entrypoint/20-envsubst-on-templates.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ auto_envsubst() {
1616
local output_dir="${NGINX_ENVSUBST_OUTPUT_DIR:-/etc/nginx/conf.d}"
1717

1818
local template defined_envs relative_path output_path subdir
19-
defined_envs=$(printf '${%s} ' $(env | cut -d= -f1))
19+
defined_envs=$(printf '${%s} ' $(xargs -0n1 -a /proc/self/environ sh -c 'echo "$@" | grep -oEm1 "^[^=]+"' --));
2020
[ -d "$template_dir" ] || return 0
2121
if [ ! -w "$output_dir" ]; then
2222
entrypoint_log "$ME: ERROR: $template_dir exists, but $output_dir is not writable"

0 commit comments

Comments
 (0)