ruki 2 éve
szülő
commit
f1ca85debc
1 módosított fájl, 34 hozzáadás és 8 törlés
  1. 34 8
      configure

+ 34 - 8
configure

@@ -234,11 +234,22 @@ option()
     local description=${2}
     local default=${3}
     _xmake_sh_options="${_xmake_sh_options} ${name}"
+    _map_set "options" "${name}_name" "${name}"
     _map_set "options" "${name}_description" "${description}"
     _map_set "options" "${name}_default" "${default}"
 }
 _map "options"
 
+# has the given option?
+_has_option()
+{
+    local name=${1}
+    if _map_has "options" "${name}_name"; then
+        return 0
+    fi
+    return 1
+}
+
 # get the given option value
 _get_option()
 {
@@ -399,7 +410,7 @@ Directory and file names:
   --bindir=DIR            Install binaries in PREFIX/DIR
                           ['"${xmake_sh_default_bindir}"']
 '
-  exit 10
+    exit 1
 }
 
 # show xmake.sh version
@@ -417,17 +428,32 @@ _show_version()
     echo '   👉  Manual: https://xmake.io/#/getting_started     '
     echo '   🙏  Donate: https://xmake.io/#/sponsor             '
     echo '                                                      '
+    exit 2
 }
 
 # parse input arguments
+_handle_option()
+{
+    local name=${1}
+    name=${name#*--}
+    if test "x${name}" = "xhelp"; then
+        _show_usage
+        return 0
+    elif test "x${name}" = "xversion"; then
+        _show_version
+        return 0
+    elif _has_option "${name}"; then
+        echo "${name}"
+        return 0
+    fi
+    return 1
+}
 while test $# != 0; do
-    case "$1" in
-    --help) _show_usage ;;
-    --version) _show_version ; exit 2 ;;
-    --) shift; break ;;
-    *) _die "Unknown option: $1" ;;
-    esac
-    shift
+    if _handle_option ${1}; then
+        shift
+    else
+        _die "Unknown option: $1"
+    fi
 done
 
 # load targets