Ver código fonte

mftest: usage with error

Scott Lahteine 3 anos atrás
pai
commit
60607ed18d
1 arquivos alterados com 13 adições e 13 exclusões
  1. 13
    13
      buildroot/bin/mftest

+ 13
- 13
buildroot/bin/mftest Ver arquivo

@@ -30,7 +30,6 @@ OPTIONS
30 30
   -v --verbose     Extra output for debugging.
31 31
 
32 32
 env shortcuts: tree due esp lin lpc|lpc8 lpc9 m128 m256|mega stm|f1 f4 f7 s6 teensy|t31|t32 t35|t36 t40|t41
33
-
34 33
 "
35 34
 }
36 35
 
@@ -58,47 +57,48 @@ while getopts 'abhmruvyn:t:-:' OFLAG; do
58 57
     h) EXIT_USAGE=1 ;;
59 58
     m) USE_MAKE=1 ; bugout "Using make with Docker..." ;;
60 59
     n) case "$OPTARG" in
61
-         *[!0-9]*) perror "option requires a number" $OFLAG ; EXIT_USAGE=1 ;;
60
+         *[!0-9]*) perror "option requires a number" $OFLAG ; EXIT_USAGE=2 ;;
62 61
                 *) CHOICE="$OPTARG" ; bugout "Got a number: $CHOICE" ;;
63 62
        esac
64 63
        ;;
65
-    r) REBUILD=1         ; bugout "Rebuilding previous..."    ;;
64
+    r) REBUILD=1         ; bugout "Rebuilding previous..." ;;
66 65
     t) TESTENV="$OPTARG" ; bugout "Got a target: $TESTENV" ;;
67
-    u) AUTO_BUILD=2      ; bugout "Auto-Upload target..."  ;;
66
+    u) AUTO_BUILD=2      ; bugout "Auto-Upload target..." ;;
68 67
     v) DEBUG=1           ; bugout "Debug ON" ;;
69
-    y) BUILD_YES='Y'     ; bugout "Build will initiate..."    ;;
68
+    y) BUILD_YES='Y'     ; bugout "Build will initiate..." ;;
70 69
     -) IFS="=" read -r ONAM OVAL <<< "$OPTARG"
71 70
        case "$ONAM" in
72 71
          help) [[ -z "$OVAL" ]] || perror "option can't take value $OVAL" $ONAM ; EXIT_USAGE=1 ;;
73 72
     autobuild) AUTO_BUILD=1 ; bugout "Auto-Build target..."  ;;
74 73
    autoupload) AUTO_BUILD=2 ; bugout "Auto-Upload target..." ;;
75 74
           env) case "$OVAL" in
76
-                 '') perror "option requires a value" $ONAM ; EXIT_USAGE=1 ;;
75
+                 '') perror "option requires a value" $ONAM ; EXIT_USAGE=2 ;;
77 76
                   *) TESTENV="$OVAL" ; bugout "Got a target: $TESTENV" ;;
78 77
                esac
79 78
                ;;
80 79
           num) case "$OVAL" in
81 80
                  [0-9]+) CHOICE="$OVAL" ; bugout "Got a number: $CHOICE" ;;
82
-                      *) perror "option requires a value" $ONAM ; EXIT_USAGE=1 ;;
81
+                      *) perror "option requires a value" $ONAM ; EXIT_USAGE=2 ;;
83 82
                esac
84 83
                ;;
85
-      rebuild) REBUILD=1      ; bugout "Rebuilding previous..."    ;;
86
-         make) USE_MAKE=1     ; bugout "Using make with Docker..." ;;
87
-debug|verbose) DEBUG=1        ; bugout "Debug ON" ;;
84
+      rebuild) REBUILD=1  ; bugout "Rebuilding previous..." ;;
85
+         make) USE_MAKE=1 ; bugout "Using make with Docker..." ;;
86
+debug|verbose) DEBUG=1    ; bugout "Debug ON" ;;
88 87
         build) case "$OVAL" in
89 88
                  ''|y|yes) BUILD_YES='Y' ;;
90 89
                      n|no) BUILD_YES='N' ;;
91
-                        *) perror "option value must be y, n, yes, or no" $ONAM ; EXIT_USAGE=1 ;;
90
+                        *) perror "option value must be y, n, yes, or no" $ONAM ; EXIT_USAGE=2 ;;
92 91
                esac
93 92
                bugout "Build will initiate? ($BUILD_YES)"
94 93
                ;;
95
-            *) perror "Unknown flag" "$OPTARG" ; EXIT_USAGE=1 ;;
94
+            *) perror "Unknown flag" "$OPTARG" ; EXIT_USAGE=2 ;;
96 95
        esac
97 96
        ;;
97
+    *) EXIT_USAGE=2 ;;
98 98
   esac
99 99
 done
100 100
 
101
-((EXIT_USAGE)) && { usage ; exit 1 ; }
101
+((EXIT_USAGE)) && { usage ; let EXIT_USAGE-- ; exit $EXIT_USAGE ; }
102 102
 
103 103
 if ((REBUILD)); then
104 104
   bugout "Rebuilding previous..."

Carregando…
Cancelar
Salvar