From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19193 invoked by alias); 14 Jan 2013 05:21:45 -0000 Received: (qmail 19181 invoked by uid 22791); 14 Jan 2013 05:21:44 -0000 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 Received: from milton.worldispnetwork.com (HELO milton.worldispnetwork.com) (67.217.57.10) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 14 Jan 2013 05:21:36 +0000 Received: (qmail 26355 invoked by uid 399); 14 Jan 2013 05:21:18 -0000 Received: from c122-106-16-37.rivrw1.nsw.optusnet.com.au (HELO ?10.0.2.15?) (career@shaddybaddah.name@122.106.16.37) by milton.worldispnetwork.com with ESMTPAM; 14 Jan 2013 05:21:18 -0000 Message-ID: <50F395D5.4050201@shaddybaddah.name> Date: Mon, 14 Jan 2013 05:21:00 -0000 From: Shaddy Baddah User-Agent: Mozilla/5.0 (X11; Linux i686; rv:10.0.5) Gecko/20120624 Icedove/10.0.5 MIME-Version: 1.0 To: cygwin@cygwin.com Subject: stat() and tilde prefix (was bad bash tab completion) References: <5024B4D4.6080409@shaddybaddah.name> In-Reply-To: <5024B4D4.6080409@shaddybaddah.name> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com X-SW-Source: 2013-01/txt/msg00169.txt.bz2 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. (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 "", line 1, in 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