/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* utils_2.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: mea +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/05/06 13:15:59 by narnaud #+# #+# */ /* Updated: 2022/05/16 08:19:28 by narnaud ### ########.fr */ /* */ /* ************************************************************************** */ #include "minishell.h" int file_error(char *cmd, char *file, char *msg) { ft_putstr_fd("Minishell: ", 2); ft_putstr_fd(cmd, 2); ft_putstr_fd(": ", 2); ft_putstr_fd(file, 2); ft_putstr_fd(": ", 2); ft_putstr_fd(msg, 2); ft_putchar_fd('\n', 2); return (0); } int is_valid_identifier(char *ident) { int i; i = 0; if (ft_isalpha(ident[0]) || ident[0] == '_') { while (ident[i]) { if (!ft_isalpha(ident[i]) && !ft_isdigit(ident[i] && ident[i] != '_')) { ft_putstr_fd("export: not an identifier: ", 2); ft_putstr_fd(ident, 2); ft_putchar_fd('\n', 2); return (0); } i++; } return (1); } ft_putstr_fd("export: not an identifier: ", 2); ft_putstr_fd(ident, 2); ft_putchar_fd('\n', 2); return (0); }