chiark / gitweb /
systemctl: fix counting in list-units output
[elogind.git] / src / systemctl.c
index ffb4f73873f269d23d04ad7d42593cfcb7a03615..a03769034b7d8bfcd732bef8c37f869ea29c4d7c 100644 (file)
@@ -265,7 +265,7 @@ static bool output_show_job(const struct unit_info *u) {
 }
 
 static void output_units_list(const struct unit_info *unit_infos, unsigned c) {
-        unsigned active_len, sub_len, job_len;
+        unsigned active_len, sub_len, job_len, n_shown = 0;
         const struct unit_info *u;
 
         active_len = sizeof("ACTIVE")-1;
@@ -300,6 +300,8 @@ static void output_units_list(const struct unit_info *unit_infos, unsigned c) {
                 if (!output_show_job(u))
                         continue;
 
+                n_shown++;
+
                 if (!streq(u->load_state, "loaded") &&
                     !streq(u->load_state, "banned")) {
                         on_loaded = ansi_highlight(true);
@@ -352,9 +354,9 @@ static void output_units_list(const struct unit_info *unit_infos, unsigned c) {
                        "JOB    = Pending job for the unit.\n");
 
                 if (arg_all)
-                        printf("\n%u units listed.\n", c);
+                        printf("\n%u units listed.\n", n_shown);
                 else
-                        printf("\n%u units listed. Pass --all to see inactive units, too.\n", c);
+                        printf("\n%u units listed. Pass --all to see inactive units, too.\n", n_shown);
         }
 }
 
@@ -3939,7 +3941,7 @@ static int systemctl_help(void) {
                "     --global        Enable/disable unit files globally\n"
                "     --no-reload     When enabling/disabling unit files, don't reload daemon\n"
                "                     configuration\n"
-               "     --force         When enabling unit files, override existing symlinks\n"
+               "  -f --force         When enabling unit files, override existing symlinks\n"
                "                     When shutting down, execute action immediately\n"
                "     --defaults      When disabling unit files, remove default symlinks only\n\n"
                "Commands:\n"
@@ -4068,7 +4070,6 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
                 ARG_ORDER,
                 ARG_REQUIRE,
                 ARG_FULL,
-                ARG_FORCE,
                 ARG_NO_RELOAD,
                 ARG_DEFAULTS
         };
@@ -4089,7 +4090,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
                 { "quiet",     no_argument,       NULL, 'q'           },
                 { "order",     no_argument,       NULL, ARG_ORDER     },
                 { "require",   no_argument,       NULL, ARG_REQUIRE   },
-                { "force",     no_argument,       NULL, ARG_FORCE     },
+                { "force",     no_argument,       NULL, 'f'           },
                 { "no-reload", no_argument,       NULL, ARG_NO_RELOAD },
                 { "defaults",  no_argument,       NULL, ARG_DEFAULTS  },
                 { NULL,        0,                 NULL, 0             }
@@ -4100,7 +4101,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
         assert(argc >= 0);
         assert(argv);
 
-        while ((c = getopt_long(argc, argv, "ht:p:aq", options, NULL)) >= 0) {
+        while ((c = getopt_long(argc, argv, "ht:p:aqf", options, NULL)) >= 0) {
 
                 switch (c) {
 
@@ -4174,7 +4175,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
                         arg_quiet = true;
                         break;
 
-                case ARG_FORCE:
+                case 'f':
                         arg_force = true;
                         break;