Jeff King wrote: > That is the cost of using the mkpath convenience function (otherwise, > the compiler will complain that ".*" expects an int). We can do it > manually, but in practice, do you really expect your PATH environment > variable to overflow an int? I'd think a check like if (end - p > INT_MAX) die("holy cow your PATH is big"); would be good enough. Or even assert(end - p <= INT_MAX); if there is some environment limit I forgot about that makes that always true. >> /* >> * When a command can't be found because one of the directories >> * listed in $PATH is unsearchable, execvp reports EACCES, but >> * careful usability testing (read: analysis of occasional bug >> * reports) reveals that "No such file or directory" is more >> * intuitive. >> */ >> if (errno == EACCES && cannot_find_in_PATH(file)) >> errno = ENOENT; > > I think we can even simplify cannot_find to "!exists_in_PATH" to make > it even simpler. If it exists and execvp did not execute it, then it > must be non-executable (or there is a race condition :) ). Yeah, sounds good. With Junio's caveat, that makes: if (errno == EACCES && !strchr(file, '/')) errno = exists_in_PATH(file) ? EACCES : ENOENT; -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html