From dc2193b997ea207c3489d9173027c2d9e9ba9623 Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Wed, 3 Dec 2014 23:02:15 -0600 Subject: [PATCH] Translate colons to slashes in the current path name, for compatibility with Unix-style usage. As an exception, the translation isn't done if there is a directory name containing a /. --- libbb/xgetcwd.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libbb/xgetcwd.c b/libbb/xgetcwd.c index 71720d323..a437eaf84 100644 --- a/libbb/xgetcwd.c +++ b/libbb/xgetcwd.c @@ -38,6 +38,16 @@ xrealloc_getcwd_or_warn(char *cwd) return NULL; } cwd = xrealloc(cwd, strlen(cwd) + 1); +#ifdef __GNO__ + /* Translate path to use slashes (unless it contains a directory + * name with a slash in it). This increases compatibility with + * scripts that expect paths to be in the normal Unix style. */ + if (strchr(cwd, '/') == NULL) { + char *ch = cwd; + while ((ch = strchr(ch, ':')) != NULL) + *ch = '/'; + } +#endif return cwd; } }