erlware / relx

Sane, simple release creation for Erlang
http://erlware.github.io/relx
Apache License 2.0
697 stars 232 forks source link

Fix path variables quoting for Windows #730

Closed venimus closed 5 years ago

venimus commented 5 years ago

Release will not properly work if installation (and/or bindir) includes spaces. For instance if the release is installed in C:\Program Files and werl.exe is bundled.

Many commands are executed without quotes thus as a side-effect, path with spaces will be threated as separate command arguments (instead of a single path argument). ie C:\Program Files\werl.exe will be threated from the shell as 2 arguments: C:\Program and Files\werl.exe.

Background: Quoting in Windows shell does not work as in other systems. When setting a variable if the quotes are after = they will be included in the value if both varname and value are surrounded by quotes this will escape the whole assignment so the command is properly executed (as set could have some flags and options in addition to the value). so set "var=foo /d" will result in a variable %var% with a value foo /d while set var="foo /d" will result in a variable %var% with a value "foo /d" at last (without quotes) set var=foo /d will result to set /d var=foo which will probably not what is expected (thus set commands are quoted)

Similarly unquoted variables with spaces (in this case a windows path) will be threated as arguments if they include spaces. However we can avoid quoting every variable if we use the trick above that puts the quotes in the value itself.

Fixes #731

ferd commented 5 years ago

This seemed to have no negative impact on my computer. Commands already worked (or kept failing the same, something is weird on my windows laptop).

I'd at least expect that the node name/hostname combo contains no spaces, though, because domain names aren't allowed spaces afaict, but I guess there's no harm in adding them.

venimus commented 5 years ago

I'd at least expect that the node name/hostname combo contains no spaces

I added those for consistency, as the other command already has them. I guess i had to remove those from the ping. So seems the quotes were actually included in the cookie value (and test failed).

venimus commented 5 years ago

@tsloughter @ferd could you please review this.

To reproduce the bug werl.exe/erl.exe should be located in a path with spaces and extended script will throw an error