Skip to content

Commit e9caa80

Browse files
authored
Merge pull request #14 from tortuetorche/patch-2
Fix environment variables who contains spaces in their value
2 parents 79d3b5e + e386126 commit e9caa80

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

psu

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ deploy() {
393393
if [ -n "$ENVIRONMENT_VARIABLES_FILE" ]; then
394394
local new_stack_envvars
395395
new_stack_envvars=$(env_file_to_json)
396-
stack_envvars="$(echo -n "${new_stack_envvars}${stack_envvars}" | jq -sjc 'add | unique_by(.name)')"
396+
stack_envvars="$(echo "${new_stack_envvars}${stack_envvars}" | jq -sjc 'add | unique_by(.name)')"
397397
fi
398398
local data_prefix="{\"Id\":\"$stack_id\",\"StackFileContent\":\""
399399
local data_suffix="\",\"Env\":"$stack_envvars",\"Prune\":$PORTAINER_PRUNE}"
@@ -470,7 +470,7 @@ undeploy() {
470470
# JSON string #
471471
###################################################
472472
env_file_to_json() {
473-
echo "$(env -i $(cat $ENVIRONMENT_VARIABLES_FILE) jq -n 'env | to_entries | map({name: .key, value: .value})')"
473+
echo "$(env -i sh -c "(unset \$(env | sed 's/=.*//'); set -a; . $(readlink -f $ENVIRONMENT_VARIABLES_FILE); set +a; jq -njc 'env | to_entries | map({name: .key, value: .value})')")"
474474
}
475475

476476
main "$@"

0 commit comments

Comments
 (0)