[sysadmin-bin: 68/168] Style: use 'a || exit 1' for "command must succeed"



commit 618a485a8b0d6ac873cbbfdd48fd5dd431412b8c
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Thu Mar 19 23:30:53 2009 -0400

    Style: use 'a || exit 1' for "command must succeed"
    
    There was a lot of:
    
     if ! x ; then
        exit 1
     fi
    
    Compact that to 'x || exit 1' for readability.

 gnome-pre-receive             |   14 +++-----------
 pre-receive-check-maintainers |    8 ++------
 pre-receive-check-po          |    8 ++------
 pre-receive-check-policy      |    8 ++------
 4 files changed, 9 insertions(+), 29 deletions(-)
---
diff --git a/gnome-pre-receive b/gnome-pre-receive
index 319b940..a5ad6b5 100755
--- a/gnome-pre-receive
+++ b/gnome-pre-receive
@@ -54,15 +54,7 @@ while read oldrev newrev refname; do
     # for each ref that is updated. This keeps things simple and
     # reliable and none of the scripts need all the refs at once.
 
-    if ! $BINDIR/pre-receive-check-policy $oldrev $newrev $refname ; then
-	exit 1
-    fi
-
-    if ! $BINDIR/pre-receive-check-maintainers $oldrev $newrev $refname ; then
-	exit 1
-    fi
-
-    if ! $BINDIR/pre-receive-check-po $oldrev $newrev $refname ; then
-	exit 1
-    fi
+    $BINDIR/pre-receive-check-policy $oldrev $newrev $refname || exit 1
+    $BINDIR/pre-receive-check-maintainers $oldrev $newrev $refname || exit 1
+    $BINDIR/pre-receive-check-po $oldrev $newrev $refname || exit 1
 done
diff --git a/pre-receive-check-maintainers b/pre-receive-check-maintainers
index 48fd76f..42e42f1 100755
--- a/pre-receive-check-maintainers
+++ b/pre-receive-check-maintainers
@@ -38,13 +38,9 @@ check_maintainers() {
 }
 
 if [ $# = 3 ] ; then
-    if ! check_maintainers $@ ; then
-	exit 1
-    fi
+    check_maintainers $@ || exit 1
 else
     while read oldrev newrev refname; do
-	if ! check_maintainers $oldrev $newrev $refname ; then
-	    exit 1
-	fi
+	check_maintainers $oldrev $newrev $refname || exit 1
     done
 fi
diff --git a/pre-receive-check-po b/pre-receive-check-po
index e9b10ea..373dbe1 100755
--- a/pre-receive-check-po
+++ b/pre-receive-check-po
@@ -131,13 +131,9 @@ if [ -e $GIT_DIR/pending ] ; then
 fi
 
 if [ $# = 3 ] ; then
-    if ! check_pos $@ ; then
-	exit 1
-    fi
+    check_pos $@ || exit 1
 else
     while read oldrev newrev refname; do
-	if ! check_pos $oldrev $newrev $refname ; then
-	    exit 1
-	fi
+	check_pos $oldrev $newrev $refname || exit 1
     done
 fi
diff --git a/pre-receive-check-policy b/pre-receive-check-policy
index 7a2c43a..e3bc1ed 100755
--- a/pre-receive-check-policy
+++ b/pre-receive-check-policy
@@ -183,14 +183,10 @@ EOF
 }
 
 if [ $# = 3 ] ; then
-    if ! check_ref_update $@ ; then
-	exit 1
-    fi
+    check_ref_update $@ || exit 1
 else
     while read oldrev newrev refname; do
-	if ! check_ref_update $oldrev $newrev $refname ; then
-	    exit 1
-	fi
+	check_ref_update $oldrev $newrev $refname || exit 1
     done
 fi
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]