X-Recipient: archive-cygwin@delorie.com
X-Spam-Check-By: sourceware.org
Date: Wed, 4 Nov 2009 10:21:27 +0100
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: [1.7] Undocumented change in accessing by dos drive letters?
Message-ID: <20091104092127.GA31924@calimero.vinschen.de>
Reply-To: cygwin@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
References: <19183.9501.7117.656831@consult.pretender>  <4AEF316F.2070502@cygwin.com>  <416096c60911021258j27d49894kda1f835b3f487a3b@mail.gmail.com>  <4AF0E7FD.3060700@tlinx.org>  <416096c60911032219q4d7db00fr4612e55e7f2fe8c8@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <416096c60911032219q4d7db00fr4612e55e7f2fe8c8@mail.gmail.com>
User-Agent: Mutt/1.5.20 (2009-06-14)
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

On Nov  4 06:19, Andy Koppe wrote:
> 2009/11/4 Linda Walsh:
> >> C: and C:\ aren't the same thing in DOS/cmd.exe. C: means the current
> >> directory of the C drive, whereas C:\ means the root directory of the
> >> C drive. Within each cmd.exe session, each drive has its own current
> >> directory.
> >
> > ---
> >        Right.  That's a cmd.exe-ism  -- As Christofpher F. says,
> > it's not been true in Cygwin in a long time (I don't remember it being
> > true, ever, but I never tried using it to see if it was supported).
> 
> Fair enough. All the more reason to remove support for "C:" then.
> 
> Btw, C: still does work for cd, e.g. 'cd C:' or 'cd C:Users', both in
> bash and in zsh. How come?

Funny.  In tcsh it does not work.  The difference is in the strace
suggests that tcsh calls `chdir ("c:")':

  -csh 2372 chdir: dir 'c:'
  -csh 2372 normalize_posix_path: src c:
  -csh 2372 cwdstuff::get: posix /home/corinna
  -csh 2372 cwdstuff::get: (/home/corinna) = cwdstuff::get (0xD80808, 32768, 1, 0), errno 9
  -csh 2372 normalize_posix_path: /home/corinna/c: = normalize_posix_path (c:)
  -csh 2372 mount_info::conv_to_win32_path: conv_to_win32_path (/home/corinna/c:)

normalize_posix_path() only recognizes a DOS path if it starts with
"x:/", "x:\" or "\", so "c:" is not a DOS path, rather just some
arbitrary filename.  Therefore "c:" results in an absolute path of
"/home/corinna/c:", which doesn't exist.

And that's what happens in bash:

  bash 2516 mount_info::conv_to_posix_path: conv_to_posix_path (c:, no-keep-rel, no-add-slash)
  bash 2516 normalize_win32_path: C: = normalize_win32_path (c:)
  bash 2516 mount_info::conv_to_posix_path: /cygdrive/c = conv_to_posix_path (c:)

  [... bash calls stat to check if the dir exists ...]

  bash 2516 chdir: dir '/cygdrive/c'
  
So apparently bash calls cygwin_conv_path(CCP_WIN_A_TO_POSIX, ...), this
treats all incoming paths as Windows paths, the path is converted to a
POSIX path, then bash calls stat to check if the file is an existing
directory, and only then it calls chdir with the POSIX path.

I assume zsh is doing something similar.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
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

