Skip to content

Commit ec763c5

Browse files
committedJul 21, 2017
Fix commands cannot be executed on OS/2
1. Executables can be executed without .exe 2. Path separator on OS/2 is ;. Plus, use the shell specified by users, first. modified: run-command.c
1 parent c2b6f07 commit ec763c5

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed
 

‎run-command.c

+16-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,18 @@ int is_executable(const char *name)
123123

124124
if (stat(name, &st) || /* stat, not lstat */
125125
!S_ISREG(st.st_mode))
126+
#ifndef __OS2__
126127
return 0;
128+
#else
129+
{
130+
/* Check name.exe as well */
131+
static struct strbuf buf = STRBUF_INIT;
132+
133+
strbuf_reset(&buf);
134+
strbuf_addf(&buf, "%s.exe", name);
135+
return (!stat(buf.buf, &st) && S_ISREG(st.st_mode)) ? S_IXUSR : 0;
136+
}
137+
#endif
127138

128139
#if defined(GIT_WINDOWS_NATIVE) || defined(__OS2__)
129140
/*
@@ -185,7 +196,7 @@ static char *locate_in_PATH(const char *file)
185196
return NULL;
186197

187198
while (1) {
188-
const char *end = strchrnul(p, ':');
199+
const char *end = strchrnul(p, PATH_SEP);
189200

190201
strbuf_reset(&buf);
191202

@@ -389,7 +400,11 @@ static void prepare_cmd(struct argv_array *out, const struct child_process *cmd)
389400
* Add SHELL_PATH so in the event exec fails with ENOEXEC we can
390401
* attempt to interpret the command with 'sh'.
391402
*/
403+
#ifndef __OS2__
392404
argv_array_push(out, SHELL_PATH);
405+
#else
406+
argv_array_push(out, wrapped_getenv_for_os2("GIT_SHELL"));
407+
#endif
393408

394409
if (cmd->git_cmd) {
395410
argv_array_push(out, "git");

0 commit comments

Comments
 (0)