mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-11-10 03:45:42 +01: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 main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int morehelp;
|
|
||||||
struct option long_option[] =
|
struct option long_option[] =
|
||||||
{
|
{
|
||||||
{"help", 0, NULL, 'h'},
|
{"help", 0, NULL, 'h'},
|
||||||
|
@ -1477,7 +1476,6 @@ int main(int argc, char *argv[])
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
command = argv[0];
|
command = argv[0];
|
||||||
morehelp = 0;
|
|
||||||
while (1) {
|
while (1) {
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
|
@ -1485,8 +1483,8 @@ int main(int argc, char *argv[])
|
||||||
break;
|
break;
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'h':
|
case 'h':
|
||||||
morehelp++;
|
help();
|
||||||
break;
|
return EXIT_SUCCESS;
|
||||||
case 'f':
|
case 'f':
|
||||||
cfgfile = optarg;
|
cfgfile = optarg;
|
||||||
break;
|
break;
|
||||||
|
@ -1500,17 +1498,14 @@ int main(int argc, char *argv[])
|
||||||
printf("alsactl version " SND_UTIL_VERSION_STR "\n");
|
printf("alsactl version " SND_UTIL_VERSION_STR "\n");
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
case '?': // error msg already printed
|
case '?': // error msg already printed
|
||||||
morehelp++;
|
help();
|
||||||
|
return EXIT_FAILURE;
|
||||||
break;
|
break;
|
||||||
default: // should never happen
|
default: // should never happen
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Invalid option '%c' (%d) not handled??\n", c, c);
|
"Invalid option '%c' (%d) not handled??\n", c, c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (morehelp) {
|
|
||||||
help();
|
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
|
||||||
if (argc - optind <= 0) {
|
if (argc - optind <= 0) {
|
||||||
fprintf(stderr, "alsactl: Specify command...\n");
|
fprintf(stderr, "alsactl: Specify command...\n");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue