/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* utils_exec.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: mmoussou cmd)) return (0); if (cmd->cmd[0] == '.' && cmd->cmd[1] == '/') cmd->cmd = get_cmd_local_path(cmd->cmd, env); else if (cmd->cmd[0] != '/') { path = env_get_value("PATH", env); cmd->cmd = get_path(path, cmd->cmd); free(path); } if (!(cmd->cmd)) return (-1); return (0); } int check_file(char *cmd, char *input) { struct stat entry; int status; if (is_in_builtins(cmd)) return (0); status = stat(cmd, &entry); if (status) { printf("minishell : command not found: %s\n", input); return (1); } if (!S_ISDIR(entry.st_mode) && !access(cmd, X_OK)) return (0); if (S_ISDIR(entry.st_mode)) printf("minishell : %s is a directory.\n", input); else printf("minishell : command not found: %s\n", input); return (1); }