delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2018/01/15/23:13:19

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:to:subject:message-id:mime-version
:content-type; q=dns; s=default; b=goXgT9GGsYd2gERGQcdtw80xApJbT
Aziiq/1T7s3dcbJT+ew9otp9ggMbXXDvAy97Ytr7r1+IbzyZi2IW2xeJMWnnza03
Qs9ugnv0zOSp3ZlH3dy5x/wn/Dj/wXbfZ+K+MqvHFv4wuandlHCIEpzaDBFltKdz
qEtU27IQ3Vx1KY=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:to:subject:message-id:mime-version
:content-type; s=default; bh=WrO/aGrpoOHcKPdh9NWhBrTAc/U=; b=hJP
l5hiAfhKr8NpWgrkTYPAYSG9i2QWZfckR4lInVqPKIModSBnNz9wDW2UR9AEl/t/
aWw+07x2kjPunyCQIBeP6tm8xiw2v6w9aOi8tWYqHAj5m5SEPiQ5Nkabp6B3Aek/
8e6QcjngL0b7TF5EHzGAYNrTFj9qlDyv3DJTX+tw=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=tony, Tony, U*tony, H*MI:help
X-HELO: mars.tony.develop-help.com
Date: Tue, 16 Jan 2018 15:13:02 +1100
From: Tony Cook <tony AT develop-help DOT com>
To: cygwin AT cygwin DOT com
Subject: deleted current directory behaviour
Message-ID: <20180116041301.trp2qwc2qexos7kp@mars.tony.develop-help.com>
MIME-Version: 1.0
User-Agent: NeoMutt/20170113 (1.7.2)
X-IsSubscribed: yes

Currently cygwin emulates* Linux (and most other POSIXish systems that
I'm aware of) by allowing the current directory to be removed:

tony AT saturn ~/dev/perl/git
$ mkdir foo

tony AT saturn ~/dev/perl/git
$ cd foo

tony AT saturn ~/dev/perl/git/foo
$ rmdir ~/dev/perl/git/foo

but is inconsistent after that:

tony AT saturn ~/dev/perl/git/foo
$ pwd
/home/tony/dev/perl/git/foo

tony AT saturn ~/dev/perl/git/foo
$ cd ~/dev/perl/git/foo
bash: cd: /home/tony/dev/perl/git/foo: No such file or directory

tony AT saturn ~/dev/perl/git/foo
$ cd ~/dev/perl/git

tony AT 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 AT 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 AT saturn ~/dev/perl/git
$ cc -o132648.exe 132648.c

tony AT saturn ~/dev/perl/git
$ ./132648
/home/tony/dev/perl/git/foo

On Linux that program outputs:

tony AT 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?

Note: I'm not requesting this be fixed.  I have perl test code that
needs to be skip the test with the current behaviour, or allow
execution if the behaviour is made more consistent.

Thanks,
Tony

If it matters:

tony AT saturn ~/dev/perl/git
$ uname -a
CYGWIN_NT-6.1-WOW saturn 2.9.0(0.318/5/3) 2017-09-12 10:41 i686 Cygwin

* Win32 doesn't allow removing the current directory:
  C:\Users\tony>.\132648
  rmdir: Permission denied

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019