Browse Source

fix to return codes of option.parse failures

Jaromil 3 years ago
parent
commit
7e70209e21
1 changed files with 8 additions and 5 deletions
  1. 8 5
      zuper

+ 8 - 5
zuper

@@ -936,8 +936,8 @@ option.parse() {
936 936
     fi
937 937
     unset discardme
938 938
     if ! zparseopts -M -E -D -Adiscardme ${every_opts}; then
939
-        _failure "Error parsing."
940
-        return 127
939
+        _failure "Command parses error."
940
+        return 1
941 941
     fi
942 942
     unset discardme
943 943
     subcommand=${1}
@@ -947,7 +947,8 @@ option.parse() {
947 947
 
948 948
     if [[ -z ${(k)option_subcommands[$subcommand]} ]]; then
949 949
         _warning "There's no such command \"::1 subcommand::\"." $subcommand
950
-        exitv=127 _failure "Please try -h for help."
950
+		_failure "Please try -h for help."
951
+		return 1
951 952
     fi
952 953
     argv=("${(@)oldstar}")
953 954
     unset oldstar
@@ -960,7 +961,8 @@ option.parse() {
960 961
         zparseopts -M -E -D -Aoption ${cmd_opts}
961 962
         if [[ $? != 0 ]]; then
962 963
             _warning "Some error occurred during option processing."
963
-            exitv=127 _failure "See \"sdk help\" for more info."
964
+            _failure "See \"sdk help\" for more info."
965
+			return 1
964 966
         fi
965 967
     fi
966 968
     #build option_params (array of arguments) and check if there are unrecognized options
@@ -972,7 +974,8 @@ option.parse() {
972 974
             continue #it shouldn't be appended to option_params
973 975
         elif [[ $arg[1] == '-'  ]]; then
974 976
             if [[ $ok == 0 ]]; then
975
-                exitv=127 _failure "Unrecognized option ::1 arg:: for subcommand ::2 subcommand::" $arg $subcommand
977
+                _failure "Unrecognized option ::1 arg:: for subcommand ::2 subcommand::" $arg $subcommand
978
+				return 1
976 979
             fi
977 980
         fi
978 981
         option_params+=$arg