From 585d17d262efabce4a9a87f33f531ef9ab7c0e36 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Wed, 6 Mar 2019 12:00:50 +0000 Subject: win32: canonicalize path in chdir(2) Provide an implementation of chdir(2) which canonicalizes the path to resolve symlinks. Otherwise changing to a symlinked directory confuses 'ls -l' because it thinks '.' is a link rather than a directory. OTOH, using 'cd' in the shell to change to a symlinked directory now results in a mismatch between the shell's idea of where we are and what's displayed in the prompt. But upstream BusyBox does that too so it must be OK. --- win32/mingw.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'win32') diff --git a/win32/mingw.c b/win32/mingw.c index c42dbed97..b1a8b9711 100644 --- a/win32/mingw.c +++ b/win32/mingw.c @@ -1159,6 +1159,19 @@ int mingw_mkdir(const char *path, int mode UNUSED_PARAM) return ret; } +#undef chdir +int mingw_chdir(const char *dirname) +{ + int ret = -1; + char *realdir = xmalloc_realpath(dirname); + + if (realdir) { + ret = chdir(realdir); + free(realdir); + } + return ret; +} + #undef chmod int mingw_chmod(const char *path, int mode) { -- cgit v1.2.3-55-g6feb