menuselect: exit non-zero in case of failure on --enable|disable options.

ASTERISK-29348

Change-Id: I77e3466435f5a51a57538b29addb68d811af238d
Signed-off-by: Jaco Kroon <jaco@uls.co.za>
This commit is contained in:
Jaco Kroon 2021-03-13 13:01:50 +02:00 committed by George Joseph
parent 7f29dd0a53
commit eff26ffe42
3 changed files with 11 additions and 2 deletions

View File

@ -0,0 +1,5 @@
Subject: menuselect
menuselect --enable, --disable, --enable-category and --disable-category will
now fail with a non-zero exit code instead of silently failing if an invalid
option or category is specified.

View File

@ -2120,6 +2120,7 @@ int main(int argc, char *argv[])
/* Reset options processing */
option_index = 0;
optind = 1;
res = 0;
while ((c = getopt_long(argc, argv, "", long_options, &option_index)) != -1) {
print_debug("Got option %c\n", c);
@ -2130,6 +2131,7 @@ int main(int argc, char *argv[])
set_member_enabled(mem);
} else {
fprintf(stderr, "'%s' not found\n", optarg);
res = 1;
}
}
break;
@ -2139,6 +2141,7 @@ int main(int argc, char *argv[])
set_all(cat, 1);
} else {
fprintf(stderr, "'%s' not found\n", optarg);
res = 1;
}
}
break;
@ -2153,6 +2156,7 @@ int main(int argc, char *argv[])
clear_member_enabled(mem);
} else {
fprintf(stderr, "'%s' not found\n", optarg);
res = 1;
}
}
break;
@ -2162,6 +2166,7 @@ int main(int argc, char *argv[])
set_all(cat, 0);
} else {
fprintf(stderr, "'%s' not found\n", optarg);
res = 1;
}
}
break;
@ -2176,7 +2181,6 @@ int main(int argc, char *argv[])
break;
}
}
res = 0;
}
if (!res) {

View File

@ -158,7 +158,7 @@ if [ $NO_MENUSELECT -eq 0 ] ; then
runner menuselect/menuselect `gen_mods disable $mod_disables` menuselect.makeopts
mod_enables="app_voicemail app_directory FILE_STORAGE"
mod_enables="app_voicemail app_directory"
mod_enables+=" res_mwi_external res_ari_mailboxes res_mwi_external_ami res_stasis_mailbox"
mod_enables+=" CORE-SOUNDS-EN-GSM MOH-OPSOUND-GSM EXTRA-SOUNDS-EN-GSM"
runner menuselect/menuselect `gen_mods enable $mod_enables` menuselect.makeopts