azagrebin commented on a change in pull request #11545:
URL: https://github.com/apache/flink/pull/11545#discussion_r411965414



##########
File path: flink-dist/src/main/flink-bin/bin/config.sh
##########
@@ -633,16 +633,29 @@ runBashJavaUtilsCmd() {
     echo "$output"
 }
 
-extractExecutionParams() {
-    local execution_config=$1
+extractExecutionResults() {
+    local output="$1"
+    local expected_lines="$2"
     local EXECUTION_PREFIX="BASH_JAVA_UTILS_EXEC_RESULT:"
+    local execution_results
 
-    if ! [[ $execution_config =~ ^${EXECUTION_PREFIX}.* ]]; then
-        echo "[ERROR] Unexpected result: $execution_config" 1>&2
-        echo "[ERROR] The last line of the BashJavaUtils outputs is expected 
to be the execution result, following the prefix '${EXECUTION_PREFIX}'" 1>&2
+    IFS=$'\n' execution_results=($(echo "${output}" | grep 
${EXECUTION_PREFIX}))
+    if [[ ${#execution_results[@]} != ${expected_lines} ]]; then
+        echo "[ERROR] The execution results has unexpected number of lines, 
expected: ${expected_lines}, actual: ${#execution_results[@]}." 1>&2
+        echo "[ERROR] An execution result line is expected following the 
prefix '${EXECUTION_PREFIX}'" 1>&2

Review comment:
       ```
   extractExecutionResults() {
       local output="$1"
       local expected_lines="$2"
       local EXECUTION_PREFIX="BASH_JAVA_UTILS_EXEC_RESULT:"
       local execution_results
       local num_lines
   
       execution_results=$(echo "${output}" | grep ${EXECUTION_PREFIX})
       num_lines=$(echo "${execution_results}" | wc -l)
       if [[ ${num_lines} -ne ${expected_lines} ]]; then
           echo "[ERROR] The execution result has unexpected number of lines, 
expected: ${expected_lines}, actual: ${num_lines}." 1>&2
           echo "[ERROR] An execution result line is expected to have the 
prefix '${EXECUTION_PREFIX}'" 1>&2
           echo "$output" 1>&2
           exit 1
       fi
   
       echo "${execution_results//${EXECUTION_PREFIX}/}"
   }
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to