You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2020/02/09 13:51:44 UTC

[incubator-nuttx] branch master updated: tools/checkpatch.sh: make sure fail get the real return error value

This is an automated email from the ASF dual-hosted git repository.

gnutt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new f4d8c18  tools/checkpatch.sh: make sure fail get the real return error value
f4d8c18 is described below

commit f4d8c184b004ead0b4e9ca4e7a33f8c2bdf31039
Author: liuhaitao <li...@xiaomi.com>
AuthorDate: Sun Feb 9 11:08:26 2020 +0800

    tools/checkpatch.sh: make sure fail get the real return error value
    
    Do not use pipeline way and make sure fail to record the real exit error value.
---
 tools/checkpatch.sh | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/tools/checkpatch.sh b/tools/checkpatch.sh
index 574b9d7..2aaf188 100755
--- a/tools/checkpatch.sh
+++ b/tools/checkpatch.sh
@@ -18,6 +18,8 @@
 
 TOOLDIR=$(dirname $0)
 
+fail=0
+
 usage() {
   echo "USAGE: ${0} [options] [list|-]"
   echo ""
@@ -31,19 +33,18 @@ usage() {
 }
 
 check_file() {
-  $TOOLDIR/nxstyle $@ 2>&1
+  $TOOLDIR/nxstyle $@
+  ret=$?
+  if [ $ret != 0 ]; then
+    fail=$ret
+  fi
 }
 
 check_ranges() {
-  local fail=0
-
   while read; do
     if [[ $REPLY =~ \+\+\+\ (b/)?([^[:blank:]]+).* ]]; then
       if [ "$ranges" != "" ]; then
         check_file $ranges $path 2>&1
-        if [ $? != 0 ]; then
-          fail=1
-        fi
       fi
       path=${BASH_REMATCH[2]}
       ranges=""
@@ -53,12 +54,6 @@ check_ranges() {
   done
   if [ "$ranges" != "" ]; then
     check_file $ranges $path 2>&1
-    if [ $? != 0 ]; then
-      fail=1
-    fi
-  fi
-  if [ $fail = 1 ]; then
-    exit 1
   fi
 }
 
@@ -68,12 +63,14 @@ check_patch() {
     exit 1
   fi
   git apply $1
-  cat $1 | check_ranges
+  diffs=`cat $1`
+  check_ranges <<< "$diffs"
   git apply -R $1
 }
 
 check_commit() {
-  git show $1 | check_ranges
+  diffs=`git show $1`
+  check_ranges <<< "$diffs"
 }
 
 make -C $TOOLDIR -f Makefile.host nxstyle 1>/dev/null
@@ -124,5 +121,7 @@ for commit in $commits; do
 done
 
 for file in $files; do
-  check_file $file
+  check_file $file 2>&1
 done
+
+exit $fail