From: Shaddy Baddah <lithium-cygwin@shaddybaddah.name>
To: cygwin@cygwin.com
Subject: stat() and tilde prefix (was bad bash tab completion)
Date: Mon, 14 Jan 2013 05:21:00 -0000 [thread overview]
Message-ID: <50F395D5.4050201@shaddybaddah.name> (raw)
In-Reply-To: <5024B4D4.6080409@shaddybaddah.name>
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
next prev parent reply other threads:[~2013-01-14 5:21 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-10 14:25 bad bash tab completion Shaddy Baddah
2012-08-10 16:54 ` Eric Blake
2013-01-14 5:21 ` Shaddy Baddah [this message]
2013-01-14 6:17 ` stat() and tilde prefix (was bad bash tab completion) Christopher Faylor
2013-01-14 12:23 ` Corinna Vinschen
2013-01-14 14:37 ` Shaddy Baddah
2013-01-14 16:13 ` Corinna Vinschen
2013-01-14 20:29 ` Stephan Mueller
2013-01-14 21:37 ` Ryan Johnson
2013-01-15 8:44 ` Corinna Vinschen
2013-01-15 12:33 ` Shaddy Baddah
2013-02-07 7:00 ` Shaddy Baddah
2013-02-07 15:32 ` Eric Blake
2013-02-07 16:10 ` Thomas Wolff
2013-02-07 16:24 ` Corinna Vinschen
2013-02-07 16:26 ` Christopher Faylor
2013-01-14 15:27 ` Christopher Faylor
2013-01-14 16:05 ` Corinna Vinschen
2013-01-14 17:00 ` Christopher Faylor
2013-01-14 22:15 ` Thomas Wolff
2013-01-15 8:56 ` Corinna Vinschen
2013-01-15 19:50 ` Andrey Repin
2013-01-15 20:03 ` Larry Hall (Cygwin)
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=50F395D5.4050201@shaddybaddah.name \
--to=lithium-cygwin@shaddybaddah.name \
--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).