Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
info -e: only return 0 if all the packages in the command line exists
Baptiste Daroussin committed 22 days ago
commit c2de9adae9028976929011bc1a2a240b99bb35b8
parent a25ae64
2 files changed +34 -6
modified src/info.c
@@ -190,7 +190,6 @@ exec_info(int argc, char **argv)
			break;
		case 'e':
			pkg_exists = true;
-
			retcode = 1;
			break;
		case 'E': /* ports compatibility */
			e_flag = true;
@@ -440,9 +439,10 @@ exec_info(int argc, char **argv)
				gotone = false;
				continue;
			}
-
			if (pkg_exists)
-
				retcode = EXIT_SUCCESS;
-
			else {
+
			if (pkg_exists) {
+
				if (retcode != EXIT_FAILURE)
+
					retcode = EXIT_SUCCESS;
+
			} else {
				if (json_array) {
					if (!json_first)
						printf(",");
@@ -455,8 +455,8 @@ exec_info(int argc, char **argv)
			retcode = EXIT_FAILURE;
		}

-
		if (retcode == EXIT_SUCCESS && !gotone && match != MATCH_ALL) {
-
			if (!quiet)
+
		if (!gotone && match != MATCH_ALL) {
+
			if (!quiet && !pkg_exists)
				warnx("No package(s) matching %s", argv[i]);
			retcode = EXIT_FAILURE;
		}
modified tests/frontend/info.sh
@@ -19,6 +19,7 @@ tests_init \
	info_prefix \
	info_quiet \
	info_exists \
+
	info_exists_multiple \
	info_not_found \
	info_no_args \
	info_glob \
@@ -205,6 +206,33 @@ info_exists_body() {
	    pkg info -e nonexistent
}

+
info_exists_multiple_body() {
+
	setup_pkg
+

+
	atf_check -s exit:0 sh ${RESOURCEDIR}/test_subr.sh new_pkg "other" "other" "1"
+
	atf_check -o ignore pkg register -M other.ucl
+

+
	# Both exist: exit 0
+
	atf_check \
+
		-s exit:0 \
+
		pkg info -e test other
+

+
	# First exists, second doesn't: exit 1
+
	atf_check \
+
		-s exit:1 \
+
		pkg info -e test nonexistent
+

+
	# First doesn't exist, second does: exit 1
+
	atf_check \
+
		-s exit:1 \
+
		pkg info -e nonexistent test
+

+
	# Neither exists: exit 1
+
	atf_check \
+
		-s exit:1 \
+
		pkg info -e nonexistent alsomissing
+
}
+

info_not_found_body() {
	setup_pkg