You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@yetus.apache.org by aw...@apache.org on 2017/11/13 00:32:48 UTC

yetus git commit: YETUS-581. bash 3 throws syntax errors on coproc statements

Repository: yetus
Updated Branches:
  refs/heads/master 287e586b6 -> 2b91d243f


YETUS-581. bash 3 throws syntax errors on coproc statements

Signed-off-by: Sean Busbey <bu...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/yetus/repo
Commit: http://git-wip-us.apache.org/repos/asf/yetus/commit/2b91d243
Tree: http://git-wip-us.apache.org/repos/asf/yetus/tree/2b91d243
Diff: http://git-wip-us.apache.org/repos/asf/yetus/diff/2b91d243

Branch: refs/heads/master
Commit: 2b91d243f7afbe89ec558fe09b7e33f90e065ac4
Parents: 287e586
Author: Allen Wittenauer <aw...@apache.org>
Authored: Mon Nov 6 06:33:25 2017 -0800
Committer: Allen Wittenauer <aw...@apache.org>
Committed: Sun Nov 12 16:31:43 2017 -0800

----------------------------------------------------------------------
 precommit/coprocs.d/README.md          | 25 +++++++++
 precommit/coprocs.d/e_a_r_helper.sh    | 35 ++++++++++++
 precommit/coprocs.d/process_counter.sh | 48 +++++++++++++++++
 precommit/coprocs.d/reaper.sh          | 30 +++++++++++
 precommit/test-patch.sh                | 82 ++++++++---------------------
 5 files changed, 161 insertions(+), 59 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/yetus/blob/2b91d243/precommit/coprocs.d/README.md
----------------------------------------------------------------------
diff --git a/precommit/coprocs.d/README.md b/precommit/coprocs.d/README.md
new file mode 100755
index 0000000..e960cad
--- /dev/null
+++ b/precommit/coprocs.d/README.md
@@ -0,0 +1,25 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#############################
+##
+## bash v4+ coproc routines
+##
+#############################
+
+# bash v3 and lower will treat coproc commands as syntax errors
+# therefore, ALL functions which activate coprocs are located
+# here
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/yetus/blob/2b91d243/precommit/coprocs.d/e_a_r_helper.sh
----------------------------------------------------------------------
diff --git a/precommit/coprocs.d/e_a_r_helper.sh b/precommit/coprocs.d/e_a_r_helper.sh
new file mode 100755
index 0000000..3df8293
--- /dev/null
+++ b/precommit/coprocs.d/e_a_r_helper.sh
@@ -0,0 +1,35 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# SHELLDOC-IGNORE
+
+## @description helper function for echo_and_redirect
+## @audience private
+## @stability evolving
+## @replaceable no
+function e_a_r_helper
+{
+  declare logfile=$1
+  shift
+  declare params=("${@}")
+
+  echo "Launching yrr_coproc" >> "${COPROC_LOGFILE}"
+  # shellcheck disable=SC2034
+  coproc yrr_coproc {
+    ulimit -Su "${PROC_LIMIT}"
+    yetus_run_and_redirect "${logfile}" "${params[@]}"
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/yetus/blob/2b91d243/precommit/coprocs.d/process_counter.sh
----------------------------------------------------------------------
diff --git a/precommit/coprocs.d/process_counter.sh b/precommit/coprocs.d/process_counter.sh
new file mode 100755
index 0000000..4f944bb
--- /dev/null
+++ b/precommit/coprocs.d/process_counter.sh
@@ -0,0 +1,48 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# SHELLDOC-IGNORE
+
+function process_counter_coproc_start
+{
+  if [[ "${OSTYPE}" = Linux && "${DOCKERMODE}" = true ]]; then
+    # this is really only even remotely close to
+    # accurate under Docker, for the time being.
+
+    echo "Launching process_counter_coproc" >> "${COPROC_LOGFILE}"
+    # shellcheck disable=SC2034
+    coproc process_counter_coproc {
+      declare threadcount
+      declare maxthreadcount
+      declare cmd
+
+      sleep 2
+      while true; do
+        threadcount=$(ps -L -u "${USER_ID}" -o lwp 2>/dev/null | wc -l)
+        if [[ ${threadcount} -gt ${maxthreadcount} ]]; then
+          maxthreadcount="${threadcount}"
+          echo "${maxthreadcount}" > "${PATCH_DIR}/threadcounter.txt"
+        fi
+        read -r -t 2 cmd
+        case "${cmd}" in
+          exit)
+            exit 0
+          ;;
+        esac
+      done
+    }
+  fi
+}

http://git-wip-us.apache.org/repos/asf/yetus/blob/2b91d243/precommit/coprocs.d/reaper.sh
----------------------------------------------------------------------
diff --git a/precommit/coprocs.d/reaper.sh b/precommit/coprocs.d/reaper.sh
new file mode 100755
index 0000000..4674130
--- /dev/null
+++ b/precommit/coprocs.d/reaper.sh
@@ -0,0 +1,30 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# SHELLDOC-IGNORE
+
+function reaper_coproc_start
+{
+  if [[ "${REAPER_MODE}" != "off" ]]; then
+
+    echo "Launching reaper_coproc" >> "${COPROC_LOGFILE}"
+
+    # shellcheck disable=SC2034
+    coproc reaper_coproc {
+      reaper_coproc_func
+    }
+  fi
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/yetus/blob/2b91d243/precommit/test-patch.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.sh b/precommit/test-patch.sh
index b507101..eb7bb45 100755
--- a/precommit/test-patch.sh
+++ b/precommit/test-patch.sh
@@ -623,22 +623,6 @@ function compute_unidiff
   rm "${tmpfile}"
 }
 
-## @description helper function for echo_and_redirect
-## @audience private
-## @stability evolving
-## @replaceable no
-function e_a_r_helper
-{
-  declare logfile=$1
-  shift
-  declare params=("${@}")
-
-  # shellcheck disable=SC2034
-  coproc yrr_coproc {
-    ulimit -Su "${PROC_LIMIT}"
-    yetus_run_and_redirect "${logfile}" "${params[@]}"
-  }
-}
 
 ## @description  Print the command to be executing to the screen. Then
 ## @description  run the command, sending stdout and stderr to the given filename
@@ -685,7 +669,7 @@ function echo_and_redirect
     # if bash < 4 (e.g., OS X), just run it
     # the ulimit was set earlier
 
-    yetus_run_and_redirect "${logfile}" "${params[@]}"
+    yetus_run_and_redirect "${logfile}" "${@}"
   fi
 
 }
@@ -3053,48 +3037,26 @@ function distclean
 ## @replaceable  yes
 function start_coprocessors
 {
+
+  declare filename
+
   # Eventually, we might open this up for plugins
   # and other operating environments
   # but for now, this is private and only for us
 
   if [[ "${BASH_VERSINFO[0]}" -gt 3 ]]; then
 
-    determine_user
-
-    if [[ "${OSTYPE}" = Linux && "${DOCKERMODE}" = true ]]; then
+    for filename in "${BINDIR}/coprocs.d"/*; do
+      # shellcheck disable=SC1091
+      # shellcheck source=coprocs.d/process_counter.sh
+      . "${filename}"
+    done
 
-      # this is really only even remotely close to
-      # accurate under Docker, for the time being.
+    determine_user
 
-      # shellcheck disable=SC2034
-      coproc process_counter_coproc {
-        declare threadcount
-        declare maxthreadcount
-        declare cmd
+    process_counter_coproc_start
 
-        sleep 2
-        while true; do
-          threadcount=$(ps -L -u "${USER_ID}" -o lwp 2>/dev/null | wc -l)
-          if [[ ${threadcount} -gt ${maxthreadcount} ]]; then
-            maxthreadcount="${threadcount}"
-            echo "${maxthreadcount}" > "${PATCH_DIR}/threadcounter.txt"
-          fi
-          read -r -t 2 cmd
-          case "${cmd}" in
-            exit)
-              exit 0
-            ;;
-          esac
-        done
-      }
-    fi
-
-    if [[ "${REAPER_MODE}" != "off" ]]; then
-      # shellcheck disable=SC2034
-      coproc reaper_coproc {
-        reaper_coproc_func
-      }
-    fi
+    reaper_coproc_start
 
   fi
 }
@@ -3105,16 +3067,18 @@ function start_coprocessors
 ## @replaceable  yes
 function stop_coprocessors
 {
-  # shellcheck disable=SC2154
-  if [[ -n "${process_counter_coproc_PID}" ]]; then
-    # shellcheck disable=SC2086
-    echo exit >&${process_counter_coproc[1]}
-  fi
+  if [[ "${BASH_VERSINFO[0]}" -gt 3 ]]; then
+    # shellcheck disable=SC2154
+    if [[ -n "${process_counter_coproc_PID}" ]]; then
+      # shellcheck disable=SC2086
+      echo exit >&${process_counter_coproc[1]}
+    fi
 
-  #shellcheck disable=SC2154
-  if [[ -n "${reaper_coproc_PID}" ]]; then
-    # shellcheck disable=SC2086
-    echo exit >&${reaper_coproc[1]}
+    #shellcheck disable=SC2154
+    if [[ -n "${reaper_coproc_PID}" ]]; then
+      # shellcheck disable=SC2086
+      echo exit >&${reaper_coproc[1]}
+    fi
   fi
 }