From 522252d18a2f50162e4c8e14829d427223c30e89 Mon Sep 17 00:00:00 2001 From: Wenjia Zhang Date: Thu, 21 Jan 2021 17:43:27 +0100 Subject: [PATCH] hsci: fix wrong return code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the current code, after the function check_pnetids() and the function verify_precon() are called, $? from each function is used twice successively. It is used for the first time in the condition of the IF statement, while for the second time as return code of the current function. In bash, $? can be used to get the return code, but only for the first time directly after the previous function is called. Afterwards, $? will be reset to "0". Thus, the right return code can not be get, if $? is used second time. To solve the problem, using $? for the second time should be avoided. Signed-off-by: Wenjia Zhang Signed-off-by: Jan Höppner --- hsci/hsci | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hsci/hsci b/hsci/hsci index bfdf947f..d1cf3b5a 100755 --- a/hsci/hsci +++ b/hsci/hsci @@ -146,7 +146,7 @@ function verify_precon { #Check PNETIDs check_pnetids if [ $? -ne 0 ]; then - return $? + return 1 fi return 0 @@ -175,7 +175,7 @@ function add_hsci { #### Verify preconditions verify_precon if [ $? -ne 0 ]; then - return $? + return 1 fi hsci_postfix="$(readlink /sys/class/net/$hsdev/device/cdev0 | tail -c5)"