diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | src/cd.c | 14 |
2 files changed, 18 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog index 5f033df..2155764 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-10-13 Eric Blake <eblake@redhat.com> + + * cd: support drive letters on Cygwin. + 2014-10-08 Herbert Xu <herbert@gondor.apana.org.au> * Split unquoted $@/$* correctly when IFS is set but empty. diff --git a/src/cd.c b/src/cd.c index 2d9d4b5..a4e024d 100644 --- a/src/cd.c +++ b/src/cd.c @@ -38,6 +38,9 @@ #include <string.h> #include <unistd.h> #include <limits.h> +#ifdef __CYGWIN__ +#include <sys/cygwin.h> +#endif /* * The cd and pwd commands. @@ -194,6 +197,17 @@ updatepwd(const char *dir) char *cdcomppath; const char *lim; +#ifdef __CYGWIN__ + /* On cygwin, thanks to drive letters, some absolute paths do + not begin with slash; but cygwin includes a function that + forces normalization to the posix form */ + char pathbuf[PATH_MAX]; + if (cygwin_conv_path(CCP_WIN_A_TO_POSIX | CCP_RELATIVE, dir, pathbuf, + sizeof(pathbuf)) < 0) + sh_error("can't normalize %s", dir); + dir = pathbuf; +#endif + cdcomppath = sstrdup(dir); STARTSTACKSTR(new); if (*dir != '/') { |