delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/05/12/10:09:00

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/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
Date: Wed, 12 May 2004 16:08:35 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: bash: tab completion failure from (but not at) /
Message-ID: <20040512140835.GJ12030@cygbert.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <200405110629 DOT i4B6TlAX025137 AT mx3 DOT redhat DOT com>
Mime-Version: 1.0
In-Reply-To: <200405110629.i4B6TlAX025137@mx3.redhat.com>
User-Agent: Mutt/1.4.2i

On May 11 07:25, fergus AT bonhard DOT uklinux DOT net wrote:
> Just lately (all recent snapshots including 20040510) I'm noticing a failure
> with tab completion for pathnames beginning /. Thus, I would expect, and in
> the past have achieved
> 
> 	ls /ho<TAB> 
> 	ls /home/
> or
> 	md5sum /us<TAB>loc<TAB>
> 	md5sum /usr/local/
> 
> and so on.
> 
> Now, all I am getting from ls /ho<TAB> or md5sum /us<TAB> is a system beep
> (i.e. "error!" or some kind of uncertainty or ambiguity affecting bash's
> interpretation).
> 
> For pathnames starting elsewhere, there's not a problem. E.g. from HOME I
> can press
> 
> 	cd st<TAB>
> 	cd stash
> 
> or (cf. problem described above) if I actually *move* to / I can press
> 
> 	ls ho<TAB>
> 	ls home/
> or
> 	md5sum us<TAB>loc<TAB>
> 	md5sum usr/local/

I've tracked it down.  The problem is a combination of a tiny bug in the
new path handling code in Cygwin and a tiny bug in bash.

In bash, the path "/" is accidentally converted to "//" before it tries
to call opendir() on it.  On any other POSIX system, that doesn't matter
since "//" has no special meaning.  On Cygwin (or better, Windows), "//"
means the start of an SMB path.  The old path conversion code in Cygwin
had no problems with it, the new code uncovered both, the bug in Cygwin
and this bug in bash.  The Cygwin patch is already applied.

I've attached the patch to bash, which I applied to solve that issue.
Roland, would you mind to create a new bash version and eventually
send the patch upstream?


Corinna


--- bashline.c.ORIG     2004-05-12 16:03:50.821896000 +0200
+++ bashline.c  2004-05-12 15:51:13.906536800 +0200
@@ -2144,7 +2144,10 @@ bash_directory_completion_hook (dirname)
          return 1;
        }
       len1 = strlen (temp1);
-      if (temp1[len1 - 1] == '/')
+      /* temp1 is definitely an absolute pathname.  So if the length is
+         <= 2 and the path ends in a slash, it's either "/" or "//". 
+        In both cases, no further slash must be appended. */
+      if (len1 > 2 && temp1[len1 - 1] == '/')
        {
          len2 = strlen (temp2);
          temp2 = (char *)xrealloc (temp2, len2 + 2);



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

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

- Raw text -


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