clone --single: limit the fetch refspec to fetched branch
[git.git] / run-command.c
index 9c5a564ece033e8584be14c640f6a9995ecd1cff..f9922b9ecc8e4956e19d7143bb6cb6ef4d97abf8 100644 (file)
@@ -4,6 +4,10 @@
 #include "sigchain.h"
 #include "argv-array.h"
 
+#ifndef SHELL_PATH
+# define SHELL_PATH "/bin/sh"
+#endif
+
 struct child_to_clean {
        pid_t pid;
        struct child_to_clean *next;
@@ -135,6 +139,8 @@ int sane_execvp(const char *file, char * const argv[])
         */
        if (errno == EACCES && !strchr(file, '/'))
                errno = exists_in_PATH(file) ? EACCES : ENOENT;
+       else if (errno == ENOTDIR && !strchr(file, '/'))
+               errno = ENOENT;
        return -1;
 }
 
@@ -152,7 +158,11 @@ static const char **prepare_shell_cmd(const char **argv)
                die("BUG: shell command is empty");
 
        if (strcspn(argv[0], "|&;<>()$`\\\"' \t\n*?[#~=%") != strlen(argv[0])) {
+#ifndef WIN32
+               nargv[nargc++] = SHELL_PATH;
+#else
                nargv[nargc++] = "sh";
+#endif
                nargv[nargc++] = "-c";
 
                if (argc < 2)