diff --git a/apps/src/sh.c b/apps/src/sh.c index a9fdc90c..8e2f5f5a 100644 --- a/apps/src/sh.c +++ b/apps/src/sh.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -104,7 +105,18 @@ void command_execute(command* cmd) } if (child == 0) { - execv(cmd->buffer, NULL); + if (cmd->buffer[0] != '/' && access(cmd->buffer, F_OK) < 0) // FIXME: Race condition. + { + if (errno == ENOENT) + { // Try in /bin + char* buf = malloc(cmd->size + 6); + strlcpy(buf, "/bin/", 6); + strncat(buf, cmd->buffer, cmd->size); + execv(buf, NULL); + } + } + else + execv(cmd->buffer, NULL); perror(cmd->buffer); exit(127); }