Explorar o código

unbreak return code compatiblity

Thomas Lotterer %!s(int64=22) %!d(string=hai) anos
pai
achega
d3306d30c2
Modificáronse 1 ficheiros con 7 adicións e 6 borrados
  1. 7 6
      openpkg/openpkg.sh

+ 7 - 6
openpkg/openpkg.sh

@@ -239,14 +239,15 @@ if [ ".$cmd_path" = . ]; then
     exit 1
 fi
 
-#   execute command
+#   execute command and save return code
 eval "$cmd_shell $cmd_path \${1+\"\$@\"}"
+rc=$?
 
 #   execution result check and graceful termination
-if [ $? -ne 0 ]; then
-    echo "openpkg:ERROR: Command \"$cmd\" failed (return code was $?)" 1>&2
-    exit $?
-else
-    exit 0
+if [ $rc -ne 0 ]; then
+    echo "openpkg:ERROR: Command \"$cmd\" failed (return code was $rc)" 1>&2
 fi
 
+#   exit and pass cmd return code to caller
+exit $rc
+