]> git.ipfire.org Git - people/ms/network.git/commitdiff
util: Log return code of commands only if something failed
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 21 Jul 2017 20:23:23 +0000 (22:23 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 21 Jul 2017 20:23:23 +0000 (22:23 +0200)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/functions/functions.util

index 28396f07e62d08b5ac7783c6601d5fe3d975015b..eb2b863f8a738b76ca2e4d58837742b9d7473506 100644 (file)
@@ -415,12 +415,14 @@ cmd() {
 
        log DEBUG "Running command: ${cmd}"
 
-       ${cmd}
-       local ret=$?
+       if ! ${cmd}; then
+               local ret=$?
 
-       log DEBUG "Returned with code '${ret}'"
+               log DEBUG "Returned with code '${ret}'"
+               return ${ret}
+       fi
 
-       return ${ret}
+       return ${EXIT_OK}
 }
 
 cmd_quiet() {