Skip to content

Instantly share code, notes, and snippets.

@nbyouri
Last active August 28, 2015 22:49
Show Gist options
  • Save nbyouri/c82edc944eb8a169a26e to your computer and use it in GitHub Desktop.
Save nbyouri/c82edc944eb8a169a26e to your computer and use it in GitHub Desktop.
pkgin_check_cmd_before_updating
diff --git a/main.c b/main.c
index 06ad92b..eec68ae 100644
--- a/main.c
+++ b/main.c
@@ -122,7 +122,12 @@ main(int argc, char *argv[])
/* NOTREACHED */
}
- /* initializations */
+ /* initializations if a correct cmd is entered */
+ if ((ch = find_cmd(argv[0])) == -1) {
+ usage();
+ /* NOTREACHED */
+ }
+
/* enter chroot if -c specified */
if (chrootpath != NULL) {
@@ -170,9 +175,6 @@ main(int argc, char *argv[])
/* load preferred file */
load_preferred();
- /* find command index */
- ch = find_cmd(argv[0]);
-
/* we need packages lists for almost everything */
if (ch != PKG_UPDT_CMD) /* already loaded by update_db() */
init_global_pkglists();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment