Radish alpha
H
HardenedBSD Package Manager
Radicle
Git (anonymous pull)
Log in to clone via SSH
Return error when not found in search and delete
Baptiste Daroussin committed 14 years ago
commit b267e6318fd61532b076cc92967fd24791f2a659
parent 74fdf87958b5abc89f76f137edae6145f5ed91df
3 files changed +17 -6
modified pkg/delete.c
@@ -126,8 +126,13 @@ exec_delete(int argc, char **argv)

	/* check if we have something to deinstall */
	if (pkg_jobs_is_empty(jobs)) {
-
		printf("Nothing to do\n");
-
		retcode = 0;
+
		if (argc == 0) {
+
			printf("Nothing to do\n");
+
			retcode = EXIT_SUCCESS;
+
		} else {
+
			fprintf(stderr, "Package(s) not found\n");
+
			retcode = EXIT_FAILURE;
+
		}
		goto cleanup;
	}

modified pkg/install.c
@@ -125,8 +125,8 @@ exec_install(int argc, char **argv)
			printf("Nothing to do\n");
			retcode = EXIT_SUCCESS;
		} else {
-
			fprintf(stderr, "Package(s) not found in the repositories");
-
			retcode = EX_DATAERR;
+
			fprintf(stderr, "Package(s) not found in the repositories\n");
+
			retcode = EXIT_FAILURE;
		}
		goto cleanup;
	}
modified pkg/search.c
@@ -57,6 +57,7 @@ exec_search(int argc, char **argv)
	struct pkgdb *db = NULL;
	struct pkgdb_it *it = NULL;
	struct pkg *pkg = NULL;
+
	bool atleastone = false;

	while ((ch = getopt(argc, argv, "gxXcdr:fDsqop")) != -1) {
		switch (ch) {
@@ -123,14 +124,19 @@ exec_search(int argc, char **argv)
		return (1);
	}

-
	while ((retcode = pkgdb_it_next(it, &pkg, flags)) == EPKG_OK)
+
	while ((retcode = pkgdb_it_next(it, &pkg, flags)) == EPKG_OK) {
		print_info(pkg, opt);
+
		atleastone = true;
+
	}

	pkg_free(pkg);
	pkgdb_it_free(it);
	pkgdb_close(db);

-
	retcode = ((retcode == EPKG_OK) || (retcode == EPKG_END)) ? EX_OK : 1;
+
	if (!atleastone)
+
		retcode = EXIT_FAILURE;
+
	else
+
		retcode = ((retcode == EPKG_OK) || (retcode == EPKG_END)) ? EXIT_SUCCESS : EXIT_FAILURE;

	return (retcode);
}