Closed cdegroot closed 5 years ago
Distillery now requires Bash, right
#!/usr/bin/env bash
VMARGS_PATH="$1"
VM_ARGS="$(cat "$VMARGS_PATH")"
COOKIE_REGEX="^-setcookie (.+)$"
if [[ "$VM_ARGS" =~ $COOKIE_REGEX ]]; then
echo "Cookie - ${BASH_REMATCH[1]} -"
fi
$ cat vmargs-1
-setcookie foobar
$ cat vmargs-2
-setcookie foo bar baz
./test.sh vmargs-1
Cookie - foobar -
$ ./test.sh vmargs-2
Cookie - foo bar baz -
Thanks @evadne! I'll have to run some experiments to see if we run into any issues with expansions down the line - setting COOKIE
is the easy part, the problem is what happens when COOKIE
is expanded, which with some env vars in these scripts can happen more than once - word splitting can cause some real pain in those cases.
Steps to reproduce
Use
-setcookie something with spaces
or-setcookie "something with spaces"
and run describe on the resulting release - only the first word is taken, due tohttps://github.com/bitwalker/distillery/blob/master/priv/libexec/config.sh#L200
Two solutions:
Document this behaviour
Switch to something that won't just take the first word, like:
The latter solution has its own problems because vm.args requires quoting:
and the above sed construct does not remove these quotes. That's simple enough to add, of course, but then you get in the hot waters of escaped double quotes inside the cookie... As I don't know enough about what Erlang does with vm.args, I've elected to open an Issue instead of a PR and let smarter people than I decide.