[Asterisk-code-review] menuselect: exit non-zero in case of failure on --enable|disable opti... (asterisk[16])

Jaco Kroon asteriskteam at digium.com
Thu Mar 18 08:51:55 CDT 2021


Jaco Kroon has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/15643 )


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

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

ASTERISK-29348

Change-Id: I77e3466435f5a51a57538b29addb68d811af238d
Signed-off-by: Jaco Kroon <jaco at uls.co.za>
---
A doc/UPGRADE-staging/menuselect-could-fail.txt
M menuselect/menuselect.c
M tests/CI/buildAsterisk.sh
3 files changed, 11 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/43/15643/1

diff --git a/doc/UPGRADE-staging/menuselect-could-fail.txt b/doc/UPGRADE-staging/menuselect-could-fail.txt
new file mode 100644
index 0000000..e3e20ed
--- /dev/null
+++ b/doc/UPGRADE-staging/menuselect-could-fail.txt
@@ -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.
diff --git a/menuselect/menuselect.c b/menuselect/menuselect.c
index 2ef075f..615e29f 100644
--- a/menuselect/menuselect.c
+++ b/menuselect/menuselect.c
@@ -2120,6 +2120,7 @@
 		/* 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 @@
 						set_member_enabled(mem);
 					} else {
 						fprintf(stderr, "'%s' not found\n", optarg);
+						res = 1;
 					}
 				}
 				break;
@@ -2139,6 +2141,7 @@
 						set_all(cat, 1);
 					} else {
 						fprintf(stderr, "'%s' not found\n", optarg);
+						res = 1;
 					}
 				}
 				break;
@@ -2153,6 +2156,7 @@
 						clear_member_enabled(mem);
 					} else {
 						fprintf(stderr, "'%s' not found\n", optarg);
+						res = 1;
 					}
 				}
 				break;
@@ -2162,6 +2166,7 @@
 						set_all(cat, 0);
 					} else {
 						fprintf(stderr, "'%s' not found\n", optarg);
+						res = 1;
 					}
 				}
 				break;
@@ -2176,7 +2181,6 @@
 				break;
 			}
 		}
-		res = 0;
 	}
 
 	if (!res) {
diff --git a/tests/CI/buildAsterisk.sh b/tests/CI/buildAsterisk.sh
index 2deb549..d8bad70 100755
--- a/tests/CI/buildAsterisk.sh
+++ b/tests/CI/buildAsterisk.sh
@@ -158,7 +158,7 @@
 
 	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

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/15643
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I77e3466435f5a51a57538b29addb68d811af238d
Gerrit-Change-Number: 15643
Gerrit-PatchSet: 1
Gerrit-Owner: Jaco Kroon <jaco at uls.co.za>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210318/260f15c6/attachment.html>


More information about the asterisk-code-review mailing list