Enhance evaluation of environment variables#426
Conversation
This patch addresses the following issues:
* When RELX_REPLACE_OS_VARS is set, evaluation of environment vars
is done by the shell rather than awk, this allows to use more
powerful notation of environment variables in sys.config and vm.args
(e.g. `-sname abc@${HOSTNAME,,}` or `{myapp, [{user, ${USER:-unknown}}]}`
* Using shell vars rather than unnecessarily forking awk/grep/etc
|
No, because there's a separate template script for windows: extended_bin_windows, which I haven't modified. The functionality of the two is not identical anyway. |
0621344 to
e1d3141
Compare
Add ability to also run shell commands contained in the sys.config.
E.g.:
# In this example the node name defaults to name of the release
# and can be overriden at run-time, appended with current year
$ head -1 vm.args
-sname ${NODE_NAME:-$REL_NAME}$(date +%Y)
# If the $NAME is 'abc2015', and hostname is 'MyHost', below the 'node'
# parameter gets set to 'Abc2015@myhost'
$ grep node sys.config
{node, $(echo ${NAME^})@${HOSTNAME,,}}
|
Sweet, I've wanted this but didn't know how to do it :) |
Enhance evaluation of environment variables
|
@saleyn crap, i'm only now testing this so I can cut a new version and it fails for me. For example: I get: Any idea? |
|
Aaah, on ubuntu sh is dash not bash. I guess we need to explicitly use bash. |
|
I reverted this PR. |
|
Actualy I believe I addressed this in this the #427 PR. In that PR the #!/bin/sh was changed to #!/bin/bash. I believe that in combination with this PR that should do it. Though I don't have a ubuntu handy to test this. |
|
We can't rely on |
|
Isn't it present in all UNIX's (event though it may not be the default shell)? The extended variable expansion is only meaningful in bash's context. |
|
Not BSDs i believe. |
|
Maybe then we could have an option in relx which shell to use when generating the script? |
|
So far this works great for me in Arch and Fedora. |
|
May be. I do want to have the option for a cuttlefish dependent start script, so this would be similar. |
This patch addresses the following issues:
is done by the shell rather than awk, this allows to use more
powerful notation of environment variables in sys.config and vm.args
(e.g.
-sname abc@${HOSTNAME,,}or{myapp, [{user, ${USER:-unknown}}]}