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

    https://github.com/apache/nifi/pull/2746#discussion_r191668440
  
    --- Diff: nifi-toolkit/nifi-toolkit-assembly/src/main/resources/bin/cli.sh 
---
    @@ -111,8 +111,7 @@ run() {
        export NIFI_TOOLKIT_HOME="$NIFI_TOOLKIT_HOME"
     
        umask 0077
    -   "${JAVA}" -cp "${CLASSPATH}" ${JAVA_OPTS:--Xms128m -Xmx256m} 
org.apache.nifi.toolkit.cli.CLIMain "$@"
    -   return $?
    +   exec "${JAVA}" -cp "${CLASSPATH}" ${JAVA_OPTS:--Xms128m -Xmx256m} 
org.apache.nifi.toolkit.cli.CLIMain "$@"
    --- End diff --
    
    exec is typically used for redirecting file descriptors for the current 
shell, the redirection errors should refer to that. Otherwise the return code 
of the program is not modified, since exec gets out of the way as soon as the 
program is started so that the return code is not manipulated in any way.
    
    ```sh
    # start a container 
    docker run --rm -ti debian bash
    
    # setup a file to exit with the input argument
    cat <<EOF > test.sh
    #!/bin/bash
    
    exit \$1
    EOF
    chmod +x test.sh
    
    # observe that exit codes are preserved
    for i in 0 1 2 3; do sh -c "exec ./test.sh $i"; echo $?; done
    ```


---

Reply via email to