5 int is_cmd(char **path, char **builtin, const char *p)
11 struct stat stat_buff = { 0 };
12 char command[PATH_MAX + 1] = { 0 };
13 char buff[PATH_MAX + 1] = { 0 };
21 if (p[i] != ' ' && p[i] != '\t' && p[i] != '>')
30 /* check first if it's a shell buitin */
33 for (i = 0; builtin[i] != NULL; i++) {
34 if (!strcmp(builtin[i], command))
39 if (stat(command, &stat_buff) || !S_ISREG(stat_buff.st_mode)) {
41 for (i = 0; path[i] != NULL; i++) {
43 sprintf(buff, "%s/%s", path[i], command);
45 if (!stat(buff, &stat_buff) && S_ISREG(stat_buff.st_mode)) {
47 if (!access(buff, X_OK)) {
56 if (!access(command, X_OK))
60 return yes ? 0 : ECMDNOTFOUND;