mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-09-19 17:49:59 +02:00
Fix exit code
Fixed the exit code for invalid options. Now returns 1.
This commit is contained in:
parent
4cd2c00fb3
commit
ffa1ca09fe
1 changed files with 4 additions and 9 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue