chiark / gitweb /
remove unused variable
[elogind.git] / src / systemctl / systemctl.c
index 1ab27336d7097fc05c12cd8ef367f3871cd2a142..d1f68754a91a5c957eb45c7ceb73ba8e838ae615 100644 (file)
@@ -3743,10 +3743,10 @@ static int show_all(
 }
 
 static int cat(sd_bus *bus, char **args) {
+        _cleanup_free_ char *unit = NULL, *n = NULL;
         int r = 0;
         char **name;
-
-        _cleanup_free_ char *unit = NULL, *n = NULL;
+        bool first = true;
 
         assert(bus);
         assert(args);
@@ -3754,9 +3754,9 @@ static int cat(sd_bus *bus, char **args) {
         pager_open_if_enabled();
 
         STRV_FOREACH(name, args+1) {
-                _cleanup_free_ char *fragment_path = NULL;
+                _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
                 _cleanup_strv_free_ char **dropin_paths = NULL;
-                sd_bus_error error;
+                _cleanup_free_ char *fragment_path = NULL;
                 char **path;
 
                 n = unit_name_mangle(*name);
@@ -3797,9 +3797,18 @@ static int cat(sd_bus *bus, char **args) {
                         continue;
                 }
 
+                if (first)
+                        first = false;
+                else
+                        puts("");
+
                 if (!isempty(fragment_path)) {
-                        fprintf(stdout, "# %s\n", fragment_path);
+                        printf("%s# %s%s\n",
+                               ansi_highlight_blue(),
+                               fragment_path,
+                               ansi_highlight_off());
                         fflush(stdout);
+
                         r = sendfile_full(STDOUT_FILENO, fragment_path);
                         if (r < 0) {
                                 log_warning("Failed to cat %s: %s", fragment_path, strerror(-r));
@@ -3808,10 +3817,11 @@ static int cat(sd_bus *bus, char **args) {
                 }
 
                 STRV_FOREACH(path, dropin_paths) {
-                        fprintf(stdout,   "%s# %s\n",
-                                isempty(fragment_path) && path == dropin_paths ? "" : "\n",
-                                *path);
+                        printf("%s# %s\n",
+                               isempty(fragment_path) && path == dropin_paths ? "" : "\n",
+                               *path);
                         fflush(stdout);
+
                         r = sendfile_full(STDOUT_FILENO, *path);
                         if (r < 0) {
                                 log_warning("Failed to cat %s: %s", *path, strerror(-r));
@@ -3820,7 +3830,7 @@ static int cat(sd_bus *bus, char **args) {
                 }
         }
 
-        return r;
+        return r < 0 ? r : 0;
 }
 
 static int show(sd_bus *bus, char **args) {
@@ -4766,7 +4776,7 @@ static int unit_is_enabled(sd_bus *bus, char **args) {
                                         "GetUnitFileState",
                                         &error,
                                         &reply,
-                                        "s", name);
+                                        "s", *name);
                         if (r < 0) {
                                 log_error("Failed to get unit file state for %s: %s", *name, bus_error_message(&error, r));
                                 return r;
@@ -4834,7 +4844,8 @@ static int systemctl_help(void) {
                "     --root=PATH      Enable unit files in the specified root directory\n"
                "  -n --lines=INTEGER  Number of journal entries to show\n"
                "  -o --output=STRING  Change journal output mode (short, short-monotonic,\n"
-               "                      verbose, export, json, json-pretty, json-sse, cat)\n\n"
+               "                      verbose, export, json, json-pretty, json-sse, cat)\n"
+               "     --plain          Print unit dependencies as a list instead of a tree\n\n"
                "Unit Commands:\n"
                "  list-units [PATTERN...]         List loaded units\n"
                "  list-sockets [PATTERN...]       List loaded sockets ordered by address\n"