]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl: format unit file and dropin paths as clickable links in status output 8767/head
authorLennart Poettering <lennart@poettering.net>
Thu, 19 Apr 2018 15:54:25 +0000 (17:54 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 19 Apr 2018 16:04:26 +0000 (18:04 +0200)
src/systemctl/systemctl.c

index b5352068bdb9faa58b7483c16197c82f15079d11..bcf5babb42eff69f3128ef97f6f71e78e15d878d 100644 (file)
@@ -3954,11 +3954,11 @@ static void print_status_info(
                 UnitStatusInfo *i,
                 bool *ellipsized) {
 
-        ExecStatusInfo *p;
+        char since1[FORMAT_TIMESTAMP_RELATIVE_MAX], *s1, since2[FORMAT_TIMESTAMP_MAX], *s2;
         const char *active_on, *active_off, *on, *off, *ss;
+        _cleanup_free_ char *formatted_path = NULL;
+        ExecStatusInfo *p;
         usec_t timestamp;
-        char since1[FORMAT_TIMESTAMP_RELATIVE_MAX], *s1;
-        char since2[FORMAT_TIMESTAMP_MAX], *s2;
         const char *path;
         char **t, **t2;
         int r;
@@ -3993,7 +3993,9 @@ static void print_status_info(
         } else
                 on = off = "";
 
-        path = i->source_path ? i->source_path : i->fragment_path;
+        path = i->source_path ?: i->fragment_path;
+        if (path && terminal_urlify_path(path, NULL, &formatted_path) >= 0)
+                path = formatted_path;
 
         if (i->load_error != 0)
                 printf("   Loaded: %s%s%s (Reason: %s)\n",
@@ -4021,6 +4023,9 @@ static void print_status_info(
                 char ** dropin;
 
                 STRV_FOREACH(dropin, i->dropin_paths) {
+                        _cleanup_free_ char *dropin_formatted = NULL;
+                        const char *df;
+
                         if (!dir || last) {
                                 printf(dir ? "           " :
                                              "  Drop-In: ");
@@ -4040,7 +4045,12 @@ static void print_status_info(
 
                         last = ! (*(dropin + 1) && startswith(*(dropin + 1), dir));
 
-                        printf("%s%s", basename(*dropin), last ? "\n" : ", ");
+                        if (terminal_urlify_path(*dropin, basename(*dropin), &dropin_formatted) >= 0)
+                                df = dropin_formatted;
+                        else
+                                df = *dropin;
+
+                        printf("%s%s", df, last ? "\n" : ", ");
                 }
         }