]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
path-util: don't insert duplicate "/" in path_make_absolute_cwd() 7910/head
authorLennart Poettering <lennart@poettering.net>
Wed, 17 Jan 2018 10:17:55 +0000 (11:17 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 17 Jan 2018 10:17:55 +0000 (11:17 +0100)
When the working directory is "/" it's prettier not to insert a second
"/" in the path, even though it is technically correct.

src/basic/path-util.c

index 666f48cfc331145d4cecca46954c5331f2b1a6f8..df946293858ed871c16b8d6bed22860a2143bb78 100644 (file)
@@ -127,7 +127,10 @@ int path_make_absolute_cwd(const char *p, char **ret) {
                 if (r < 0)
                         return r;
 
-                c = strjoin(cwd, "/", p);
+                if (endswith(cwd, "/"))
+                        c = strjoin(cwd, p);
+                else
+                        c = strjoin(cwd, "/", p);
         }
         if (!c)
                 return -ENOMEM;