OSDN Git Service

[update] : Use exit code to check module
authorhayao <hayao@fascode.net>
Tue, 16 Mar 2021 07:13:44 +0000 (16:13 +0900)
committerhayao <hayao@fascode.net>
Tue, 16 Mar 2021 07:13:44 +0000 (16:13 +0900)
build.sh
tools/module.sh

index 07afe66..92ca29d 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -488,7 +488,8 @@ prepare_build() {
 
     local module_check
     module_check(){
-        if [[ ! "$(bash "${tools_dir}/module.sh" check "${1}")" = "correct" ]]; then
+        msg_debug "Checking ${1} module ..."
+        if ! bash "${tools_dir}/module.sh" check "${1}"; then
             msg_error "Module ${1} is not available." "1";
         fi
     }
index c6fa00d..4085c79 100755 (executable)
@@ -31,12 +31,15 @@ _help() {
     echo " General options:"
     echo "    -v | --version [ver]      Specifies the AlterISO version"
     echo "    -h | --help               This help message"
+    echo
+    echo " check exit code:"
+    echo "    0 (correct)  1 (incorrect)  2 (other)"
 }
 
 check(){
     if (( "${#}" == 0 )) || (( "${#}" >= 2 ));then
         _help
-        exit 1
+        exit 2
     fi
     local _version
     if [[ -f "${module_dir}/${1}/alteriso" ]]; then
@@ -46,10 +49,10 @@ check(){
             unset alteriso
         )"
         if (( "$(echo "${_version}" | cut -d "." -f 1)" == "$(echo "${alteriso_version}" | cut -d "." -f 1)" )); then
-            echo "correct"
+            exit 0
         fi
     else
-        echo "incorrect"
+        exit 1
     fi
 }