From ffa1ca09fe0adbd3ab0d18db49b45bf265d75c0f Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 31 Jan 2005 17:49:04 +0000 Subject: [PATCH] Fix exit code Fixed the exit code for invalid options. Now returns 1. --- alsactl/alsactl.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/alsactl/alsactl.c b/alsactl/alsactl.c index f6e4393..b5833eb 100644 --- a/alsactl/alsactl.c +++ b/alsactl/alsactl.c @@ -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;