Github user pepov commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2985#discussion_r214952384
  
    --- Diff: 
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/bin/nifi-env.sh
 ---
    @@ -16,16 +16,38 @@
     #    limitations under the License.
     #
     
    +# By default this file will unconditionally override whatever environment 
variables you have set
    +# and set them to defaults defined here.
    +# If you want to define your own versions outside of this script please 
set the environment variable
    +# NIFI_OVERRIDE_NIFIENV to "true". That will then use whatever variables 
you used outside of
    +# this script.
    +
     # The java implementation to use.
     #export JAVA_HOME=/usr/java/jdk1.8.0/
     
    -export NIFI_HOME=$(cd "${SCRIPT_DIR}" && cd .. && pwd)
    +setOrDefault() {
    +  declare envvar="$1" default="$2"
    +
    +  local res="$envvar"
    +  if [ -z "$envvar" ] || [ "$NIFI_OVERRIDE_NIFIENV" != "true" ]
    --- End diff --
    
    Also it would cause problems with variables that has a meaning when set to 
an empty string, because that would be changed to the default value. 
    
    For posix shell we could use `(: "${somevar?}")` to check for the variable 
beeing set, but I beleive that should be done before calling the `setOrDefault` 
method.
    
    I'm not sure we have to be that careful, but at least if there is a good 
option to cover that use case we should do it.


---

Reply via email to