chiark / gitweb /
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)
committerSven Eden <yamakuzure@gmx.net>
Wed, 30 May 2018 05:50:10 +0000 (07:50 +0200)
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 c483d04715686403702bc973678a9b5058caad99..c350bc85e9474b80d35123a593f8cc3a5ed8d3d0 100644 (file)
@@ -129,7 +129,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;