Mail Archives: cygwin/2013/01/14/16:29:51
X-Recipient: | archive-cygwin AT delorie DOT com
|
X-SWARE-Spam-Status: | No, hits=2.8 required=5.0 tests=AWL,BAYES_00,BOTNET,FROM_12LTRDOM,KHOP_DNSBL_BUMP,KHOP_THREADED,RCVD_IN_MSPIKE_BL,RCVD_IN_MSPIKE_L3
|
X-Spam-Check-By: | sourceware.org
|
Message-ID: | <50F395D5.4050201@shaddybaddah.name>
|
Date: | Mon, 14 Jan 2013 16:21:25 +1100
|
From: | Shaddy Baddah <lithium-cygwin AT shaddybaddah DOT name>
|
User-Agent: | Mozilla/5.0 (X11; Linux i686; rv:10.0.5) Gecko/20120624 Icedove/10.0.5
|
MIME-Version: | 1.0
|
To: | cygwin AT cygwin DOT com
|
Subject: | stat() and tilde prefix (was bad bash tab completion)
|
References: | <5024B4D4 DOT 6080409 AT shaddybaddah DOT name>
|
In-Reply-To: | <5024B4D4.6080409@shaddybaddah.name>
|
X-IsSubscribed: | yes
|
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
|
Note-from-DJ: | This may be spam
|
Hi,
On 10 Aug 2012 17:14, Shaddy Baddah wrote:
> I've been having this problem with bash for about half a year now. I
> can't remember the specific upgrade that caused it, but that's around
> the time frame.
>
> So the issue is with tab completion, and looks something like this:
>
> snapshot 1:
>
> $ cd ~/../
>
> snapshot 2 (after tab-tab):
>
> $ cd \~/../
>
> snapshot 3 (after further tab-tab):
>
> $ cd \~/../
> .ssh/ tmp/ workarea/
>
> My main problem is with snapshot 2. By my understanding, the path that
> bash has modified to is no longer a valid path. snapshot 3, and further
> actions from there back it up, because bash is no longer looking in the
> right place.
>
> I have tried this with bash-completions disabled, and the same thing
> happens.
</snip>
(see http://cygwin.com/ml/cygwin/2012-08/msg00226.html)
Sorry to drag this old email up, but it gives context to what I am about
to write.
In investigating this, I believe the issue I am having is due to how
stat() handles tilde prefixed paths. On linux we see:
linux$ $ python -c 'import os; print os.stat("~/..")'
Traceback (most recent call last):
File "<string>", line 1, in <module>
OSError: [Errno 2] No such file or directory: '~/..'
and on cygwin we see:
cygwin$ python -c 'import os; print os.stat("~/..")'
posix.stat_result(st_mode=16832, st_ino=562949953496729L,
st_dev=4174909669L, st_nlink=1, st_uid=42037, st_gid=10513, st_size=0L,
st_atime=1357616166, st_mtime=1357616166, st_ctime=1357616166)
This make sense as the reason in the context of the bash code which
handles the tab-completion. It is escaping the path as it thinks it
references an actual valid posix path (according to my understanding
that the tilde has no special meaning to the posix api):
http://git.savannah.gnu.org/cgit/bash.git/tree/bashline.c?id=509a4430ae72aec10896713435e84f5b27675763#n3480
/* XXX -- check for standalone tildes here and backslash-quote
them */
if (s == text && *s == '~' && file_exists (text))
*r++ = '\\';
where file_exists() just wraps stat():
http://git.savannah.gnu.org/cgit/bash.git/tree/general.c?id=509a4430ae72aec10896713435e84f5b27675763#n537
int
file_exists (fn)
char *fn;
{
struct stat sb;
return (stat (fn, &sb) == 0);
}
Going back through various Cygwin dll versions, I see that stat() has
behaved in this way since as early as 1.7.6 if not earlier. I am unsure
if previous versions of bash had special handling for this stat()
behaviour, so it may be that bash has behaved this way for quite a while
longer that I had detected.
Can this be fixed? It seems like a change that may be tricky for other
applications?
--
Regards,
Shaddy
--
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 -