path-util: don't insert duplicate "/" in path_make_absolute_cwd()
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 666f48c..df94629 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;