From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14932 invoked by alias); 7 Feb 2013 15:32:54 -0000 Received: (qmail 14919 invoked by uid 22791); 7 Feb 2013 15:32:53 -0000 X-SWARE-Spam-Status: No, hits=-10.3 required=5.0 tests=AWL,BAYES_00,KHOP_PGP_SIGNED,KHOP_RCVD_UNTRUST,KHOP_SPAMHAUS_DROP,KHOP_THREADED,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS,TW_YG X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 07 Feb 2013 15:32:43 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r17FWgLf012067 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 7 Feb 2013 10:32:43 -0500 Received: from [10.3.113.66] (ovpn-113-66.phx2.redhat.com [10.3.113.66]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r17FUEgO019944 for ; Thu, 7 Feb 2013 10:30:15 -0500 Message-ID: <5113C886.9070904@redhat.com> Date: Thu, 07 Feb 2013 15:32:00 -0000 From: Eric Blake User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: cygwin@cygwin.com Subject: Re: stat() and tilde prefix (was bad bash tab completion) References: <5024B4D4.6080409@shaddybaddah.name> <50F395D5.4050201@shaddybaddah.name> <20130114061747.GB16739@ednor.casa.cgf.cx> <20130114100002.GA22039@calimero.vinschen.de> <50F417F9.8040108@shaddybaddah.name> <20130114161307.GB8617@calimero.vinschen.de> <50F54C93.9090702@shaddybaddah.name> <511350F3.8040702@shaddybaddah.name> In-Reply-To: <511350F3.8040702@shaddybaddah.name> OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="----enig2HMKXVFLBPULQDIIFCDAO" 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-02/txt/msg00071.txt.bz2 ------enig2HMKXVFLBPULQDIIFCDAO Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-length: 2266 On 02/07/2013 12:00 AM, Shaddy Baddah wrote: > Please find the patch discussed attached. It probably needs to be a bit > more generic, maybe with some precompiler directives to limit it to > cygwin? Although if it is just for cygwin, perhaps it can just go in the > cygports patch? The build of bash has nothing to do with cygports; if I decide to take this, I will include something like it the next time I build bash for cygwin. >=20 > Do I need to put an "attn bash maintainer" on the subject line? Nah, I read the list. > *r++ =3D '\\'; > /* XXX -- check for standalone tildes here and backslash-quote the= m */ > - if (s =3D=3D text && *s =3D=3D '~' && file_exists (text)) > + if (s =3D=3D text && *s =3D=3D '~' && tilde_file_exists (text)) { No need to add the {} here. > *r++ =3D '\\'; > + } > *r++ =3D *s; > } > *r =3D '\0'; > diff --git a/general.c b/general.c > index fdadf1d..b279cbe 100644 > --- a/general.c > +++ b/general.c > @@ -544,6 +544,28 @@ file_exists (fn) > } >=20=20 > int > +tilde_file_exists (fn) This function is misnamed for what it does, which is attempt work around the fact that cygwin's handling of .. is not POSIX-compliant. I think a better fix would be to change file_exists() itself instead of adding a misnamed wrapper function; then bashline.c wouldn't even need patching. The string 'tilde' need not even be in the patch; what you are really after is a function that says that if '..' is found within a string being probed for existence, then add an additional check to see if the prefix of that string exists as a directory. But I don't mind experimenting with the idea - it remains to be seen whether people will complain that bash is noticeably slower because it takes time to double-check instead of rely on cygwin's non-POSIX shortcut. And the slowdown would only be on paths containing a '..'; I would NOT be checking for symlinks (even though symlinks containing .. are also being interpreted in a non-POSIX manner, it is much more expensive to second-guess if you have to check every name for being a symlink than it is to just check for literal ..). --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org ------enig2HMKXVFLBPULQDIIFCDAO Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" Content-length: 621 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.13 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJRE8iGAAoJEKeha0olJ0NqaVUH/2BUepEKjmhftRjN87QWOnQJ b8xCmk8V1uNAbsYoOL18ww5ZLMBtnilXaQypzDAEuFdU3J3UsGSbyyjrLwjN/OsG UtIDCEjBdT2ZZOqUMEVoTohrIwrGf7fMVwPDlskQWkn5pNYDjsVFec5gEeG+/Ph0 fRvi4jZVBYaDgbSMbLmlnzZGVQ/781g2Yh8SSmx5gZ0Ji2XjqOo+jf6UZw1pgcqi 3VUeG8IMlzomx/O0UAlmmhgIDNAijHRrDZXaypaxD2zGfxwMw9/adsy/E7Hh6qQr sc2mXbx4ulKS4F0cFVO3l0vk3xvDk2HTmJ6h4HLypIEWmANDF508gW7XYKBPGrg= =GHkp -----END PGP SIGNATURE----- ------enig2HMKXVFLBPULQDIIFCDAO--