basho / node_package

RPM/Debian/FreeBSD/SmartOS/Solaris/OSX packaging templates for Erlang Nodes
Apache License 2.0
89 stars 63 forks source link

CLONE - Use backticks for command substitution. Fixes use on Solaris [JIRA: TOOLS-391] #205

Closed kesslerm closed 7 years ago

kesslerm commented 8 years ago

The default Solaris shell does not support command substitution with the '$(...)' bash syntax. Use backtick substitution instead.

In sed expressions the single quote character "'" can be escaped as "\x27". The double quote ('"') character can then be left unescaped.

ian-mi commented 7 years ago

$() notation is part of the POSIX standard. While /bin/sh on Solaris is not POSIX compatible, the beginning of this script switches to ksh in this case.

kesslerm commented 7 years ago

It appears that the failure occurs when the default Solaris shell sources the env.sh file, not during the execution of any code therein. The actual error message is

/opt/riak/bin/riak: syntax error at line 242: `ESCAPED_ARGS=$' unexpected

https://github.com/basho/node_package/blob/develop/priv/base/runner#L1-L8 shows that the env.sh file is sourced before there is a chance to pivot to ksh.

This situation is different in other scripts we use, such as https://github.com/basho/riak_ee/blob/develop/rel/files/riak-debug, which do not source external files. There the pivot happens right at the beginning of the script, which reloads itself into ksh.

bashopatricia commented 7 years ago

create jira issue

ian-mi commented 7 years ago

The exec call should still be called when the env.sh is sourced from runner, but in this case the ksh will be given the runner script and arguments. So in theory ksh env.sh should be sourced a second time under ksh with POSIX_SHELL set. This behaviour is also being relied upon to set PATH so I still don't understand what is happening.

However the changes themselves look good so I see no harm in merging this despite my confusion.

ian-mi commented 7 years ago

+1 8d556bf

Basho-JIRA commented 7 years ago

PR merged

_[posted via JIRA by Douglas Rohrer]_

Basho-JIRA commented 7 years ago

PR Merged

_[posted via JIRA by Douglas Rohrer]_