validate: fix validation return code

Only return code for last checked file was returned. Now the highest
return code is returned for the list of files

Change-Id: I795e891b995eec121187778e4213f96e08d171b3
Signed-off-by: Milosz Wasilewski <milosz.wasilewski@linaro.org>
diff --git a/validate.py b/validate.py
index 30e7479..1e981b4 100755
--- a/validate.py
+++ b/validate.py
@@ -156,8 +156,9 @@
         exitcode = pep8_check(path, args.pep8_ignore)
     elif path.endswith(".php"):
         exitcode = validate_php(path)
-    else:
-        # try shellcheck by default
+    elif path.endswith(".sh") or \
+            path.endswith("sh-test-lib") or \
+            path.endswith("android-test-lib"):
         exitcode = validate_shell(path, args.shellcheck_ignore)
     return exitcode
 
@@ -166,14 +167,18 @@
     exitcode = 0
     if filelist is not None:
         for filename in filelist:
-            exitcode = validate_file(args, filename)
+            tmp_exitcode = validate_file(args, filename)
+            if tmp_exitcode != 0:
+                exitcode = 1
     else:
         for root, dirs, files in os.walk('.'):
             if not root.startswith("./.git"):
                 for name in files:
-                    exitcode = validate_file(
+                    tmp_exitcode = validate_file(
                         args,
                         root + "/" + name)
+                    if tmp_exitcode != 0:
+                        exitcode = 1
     return exitcode