X-Recipient: archive-cygwin AT delorie DOT com 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 Message-ID: <5113C886.9070904@redhat.com> Date: Thu, 07 Feb 2013 08:30:14 -0700 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 AT cygwin DOT com Subject: Re: stat() and tilde prefix (was bad bash tab completion) References: <5024B4D4 DOT 6080409 AT shaddybaddah DOT name> <50F395D5 DOT 4050201 AT shaddybaddah DOT name> <20130114061747 DOT GB16739 AT ednor DOT casa DOT cgf DOT cx> <20130114100002 DOT GA22039 AT calimero DOT vinschen DOT de> <50F417F9 DOT 8040108 AT shaddybaddah DOT name> <20130114161307 DOT GB8617 AT calimero DOT vinschen DOT de> <50F54C93 DOT 9090702 AT shaddybaddah DOT name> <511350F3 DOT 8040702 AT shaddybaddah DOT 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 AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , 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 ------enig2HMKXVFLBPULQDIIFCDAO Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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" -----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--