public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Thomas Wolff <towo@towo.net>
To: cygwin@cygwin.com
Subject: Re: Symlink issue?
Date: Sun, 22 Aug 2021 02:40:59 +0200	[thread overview]
Message-ID: <2effc267-c2c7-f2e9-e01b-5490f5f37e9e@towo.net> (raw)
In-Reply-To: <4438dd5c-3575-4c4a-2ca5-869c2c6e9373@cornell.edu>



Am 21.08.2021 um 23:59 schrieb Ken Brown via Cygwin:
> On 8/21/2021 4:15 PM, Lavrentiev, Anton (NIH/NLM/NCBI) [C] via Cygwin 
> wrote:
>> Hi,
>>
>> Please consider the following Cygwin session:
>>
>> $ cd ~
>> $ pwd
>> /home/user
>> $ touch file
>> $ ls file
>> file
>> $ cygpath -w ~
>> C:\cygwin64\home\user
>> $ mkdir /cygdrive/g/cygwin/dir
>> $ ln -s /cygdrive/g/cygwin/dir ./dir
>> $ ls -l dir
>> ... dir -> /cygdrive/g/cygwin/dir/
>> $ cd dir
>> $ pwd
>> /home/user/dir
>> $ cygpath -w `pwd`
>> G:\cygwin\dir
>> $ ls -l ../fil<TAB>  (this expands to ../file but when Enter is hit):
>> ls: cannot access '../file': No such file or directory
>>
>> so basically "file" is not accessible with the relative dot-dot link,
>> even though somehow readline (bash completion) can figure it out and 
>> suggest
>> the correct completion.
>>
>> Is this a Cygwin bug?
>
> I don't think so.  I see identical behavior on Linux (using /tmp/dir 
> instead of /cygdrive/g/cygwin/dir).
>
> Pathname resolution proceeds from left to right, with symlinks 
> expanded as they are encountered.  See "Pathname resolution" in
>
> https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html
>
> When the CWD is /home/user/dir, the resolution of ../file goes like this:
>
> ../file = /home/user/dir/../file
>         = /cygdrive/g/cygwin/dir/../file
>         = /cygdrive/g/cygwin/file,
>
> which doesn't exist.
>
> I don't know why bash completion suggests something different.  My 
> guess (and it's only a guess) is that bash completion takes a shortcut 
> for performance reasons.
The symlink/.. confusion is a dreadful trap since Unix times.
Unfortunately, bash completion does not consider path resolution, so if 
any, it's a bash completion bug.
Thomas
>
> Ken
>


  reply	other threads:[~2021-08-22  0:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-21 20:15 Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2021-08-21 21:59 ` Ken Brown
2021-08-22  0:40   ` Thomas Wolff [this message]
2021-08-22  0:55     ` Brian Inglis
2021-08-23 19:00       ` L A Walsh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2effc267-c2c7-f2e9-e01b-5490f5f37e9e@towo.net \
    --to=towo@towo.net \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).