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 /.
This commit is contained in:
Stephen Heumann 2014-12-03 23:02:15 -06:00
parent fb9b298ca4
commit dc2193b997

View File

@ -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;
}
}