Currently cygwin emulates* Linux (and most other POSIXish systems that
I'm aware of) by allowing the current directory to be removed:
tony@saturn ~/dev/perl/git
$ mkdir foo
tony@saturn ~/dev/perl/git
$ cd foo
tony@saturn ~/dev/perl/git/foo
$ rmdir ~/dev/perl/git/foo
but is inconsistent after that:
tony@saturn ~/dev/perl/git/foo
$ pwd
/home/tony/dev/perl/git/foo
tony@saturn ~/dev/perl/git/foo
$ cd ~/dev/perl/git/foo
bash: cd: /home/tony/dev/perl/git/foo: No such file or directory
tony@saturn ~/dev/perl/git/foo
$ cd ~/dev/perl/git
tony@saturn ~/dev/perl/git
$ ls foo
ls: cannot access 'foo': No such file or directory
The pwd isn't (only) the shell caching the current directory:
tony@saturn ~/dev/perl/git
$ cat 132648.c
#include <stdio.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
int main(void) {
char buf[1000]; /* keeping this simple */
if (mkdir("foo", 0700) < 0) {
perror("mkdir");
return 1;
}
if (chdir("foo") < 0) {
perror("chdir");
return 1;
}
if (rmdir("../foo") < 0) {
perror("rmdir");
return 1;
}
if (!getcwd(buf, sizeof(buf))) {
perror("getcwd");
return 1;
}
puts(buf);
return 0;
}
tony@saturn ~/dev/perl/git
$ cc -o132648.exe 132648.c
tony@saturn ~/dev/perl/git
$ ./132648
/home/tony/dev/perl/git/foo
On Linux that program outputs:
tony@mars:.../newlib/git$ ./132648
getcwd: No such file or directory
Is that inconsistency with other platforms intentional?
If it isn't, are there any plans to make it consistent with
Linux/other POSIX-like systems?