Re: [PATCH] run-command: don't try to execute directories

2012-10-02 Thread Jeff King
On Tue, Oct 02, 2012 at 09:32:11PM +0200, Carlos Martín Nieto wrote: > >> @@ -101,8 +102,9 @@ static char *locate_in_PATH(const char *file) > >>} > >>strbuf_addstr(&buf, file); > >> > >> - if (!access(buf.buf, F_OK)) > >> + if (!stat(buf.buf, &st) && !S_

Re: [PATCH] run-command: don't try to execute directories

2012-10-02 Thread Junio C Hamano
c...@elego.de (Carlos Martín Nieto) writes: > How about something like this instead? We keep the access check and only > do the stat call when we have found something we want to look at. Sounds safer. Looking at the way the stat call is indented twice, I suspect that the variable can be defined

Re: [PATCH] run-command: don't try to execute directories

2012-10-02 Thread Carlos Martín Nieto
Junio C Hamano writes: > Carlos Martín Nieto writes: > >> When looking through $PATH to try to find an external command, >> locate_in_PATH doesn't check that it's trying to execute a file. Add a >> check to make sure we won't try to execute a directory. >> >> This also stops us from looking furt

Re: [PATCH] run-command: don't try to execute directories

2012-10-02 Thread Junio C Hamano
Carlos Martín Nieto writes: > When looking through $PATH to try to find an external command, > locate_in_PATH doesn't check that it's trying to execute a file. Add a > check to make sure we won't try to execute a directory. > > This also stops us from looking further and maybe finding that the >

[PATCH] run-command: don't try to execute directories

2012-10-02 Thread Carlos Martín Nieto
When looking through $PATH to try to find an external command, locate_in_PATH doesn't check that it's trying to execute a file. Add a check to make sure we won't try to execute a directory. This also stops us from looking further and maybe finding that the user meant an alias, as in the case where