git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] remove unnecessary loop

From
JHJan Hudec <bulb@ucw.cz>
Date
May 8, 2007, 10:13 UTC
Message-ID
<20070508101317.GC9007@efreet.light.src>
In-Reply-To
<81b0412b0705080208x3713cbc1y3c870383b586c877@mail.gmail.com>
On Tue, May 08, 2007 at 11:08:35 +0200, Alex Riesen wrote:
Show 16 quoted lines
> On 5/8/07, Liu Yubao <yubao.liu@gmail.com> wrote:
> >+#ifdef __CYGWIN__
> >+               /*
> >+                * On cygwin, lstat("hello", &st) returns 0 when
> >+                * "hello.exe" exists, so test with open() again.
> >+                */
> >+               if (lstat(match, &st) && -1 != (fd = open(match, 
> >O_RDONLY))) {
> 
> This does not "test again" if lstat returns 0. If lstat returns 0
> (file stat info
> obtained) the open is not even called. Besides, cygwin lies not only about
> .exe but also about .lnk files.
> 
> P.S. Somehow I have the feeling that even if it is a stupidity in cygwin
> they will not fix it (nor will they admit it is a bug).

They will not. Because it is not a bug. It seems to be (part of) workaround to get programs written for unix work in windows.

One reason for such workaround I can think of is, that some programs try to find themselves and since their argv[0] often does NOT contain the extension, the stat has to succeed for them.

Using open here unfortunately won't work though, because:
 - For stale links open will fail, but the lstat should succeed. This does
   apply to cygwin, because cygwin emulates links.
 - I'd expect open to actually succeed in this case, because there are
   programs that don't only try to find themselves, but also open themselves,
   because they bundle some data.

Another problem is, that the file might exist or might be cygwin artefact and there does not seem to be an easy way to tell.

IMHO the described problem is harmless (you know the file does not exist, so you should have no reason to add it and nothing happens if you don't) and happens very rarely (adding binaries to version control is usually not a good idea), so I suggest to let this be, as the workaround can easily cause other problems.

-- 
						 Jan 'Bulb' Hudec <bulb@ucw.cz>
Previous: Alex RiesenNext: Alex Riesen
Message 5 of 9 in “remove unnecessary loop”
  1. remove unnecessary loopLiu Yubao, May 8, 2007
  2. Liu YubaoMay 8, 2007
  3. Junio C HamanoMay 8, 2007
  4. Alex RiesenMay 8, 2007
  5. Jan HudecMay 8, 2007
  6. Alex RiesenMay 8, 2007
  7. Eric BlakeMay 8, 2007
  8. Jan HudecMay 8, 2007
  9. Liu YubaoMay 9, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.