]> git.alsa-project.org Git - alsa-utils.git/commitdiff
Fix exit code
authorTakashi Iwai <tiwai@suse.de>
Mon, 31 Jan 2005 17:49:04 +0000 (17:49 +0000)
committerTakashi Iwai <tiwai@suse.de>
Mon, 31 Jan 2005 17:49:04 +0000 (17:49 +0000)
Fixed the exit code for invalid options.  Now returns 1.

alsactl/alsactl.c

index f6e4393ac180de294d755327cb1cd63ca8e111c7..b5833ebd17971e7d31f8779b0ced9004fc191ed0 100644 (file)
@@ -1463,7 +1463,6 @@ static int power(const char *argv[], int argc)
 
 int main(int argc, char *argv[])
 {
-       int morehelp;
        struct option long_option[] =
        {
                {"help", 0, NULL, 'h'},
@@ -1477,7 +1476,6 @@ int main(int argc, char *argv[])
        int res;
 
        command = argv[0];
-       morehelp = 0;
        while (1) {
                int c;
 
@@ -1485,8 +1483,8 @@ int main(int argc, char *argv[])
                        break;
                switch (c) {
                case 'h':
-                       morehelp++;
-                       break;
+                       help();
+                       return EXIT_SUCCESS;
                case 'f':
                        cfgfile = optarg;
                        break;
@@ -1500,17 +1498,14 @@ int main(int argc, char *argv[])
                        printf("alsactl version " SND_UTIL_VERSION_STR "\n");
                        return EXIT_SUCCESS;
                case '?':               // error msg already printed
-                       morehelp++;
+                       help();
+                       return EXIT_FAILURE;
                        break;
                default:                // should never happen
                        fprintf(stderr, 
                        "Invalid option '%c' (%d) not handled??\n", c, c);
                }
        }
-       if (morehelp) {
-               help();
-               return EXIT_SUCCESS;
-       }
        if (argc - optind <= 0) {
                fprintf(stderr, "alsactl: Specify command...\n");
                return 0;