From b51535cdbca6fa60fc93e8910954c574db36dfd7 Mon Sep 17 00:00:00 2001 From: LuckyLaszlo Date: Tue, 21 Dec 2021 22:42:01 +0100 Subject: [PATCH] export builtin bugfix now check frst char before split return error even if argument first char is '=' --- srcs/builtins/export.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/srcs/builtins/export.c b/srcs/builtins/export.c index 2d4e285..0709ae6 100644 --- a/srcs/builtins/export.c +++ b/srcs/builtins/export.c @@ -6,7 +6,7 @@ /* By: lperrey +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/12/03 13:36:54 by lperrey #+# #+# */ -/* Updated: 2021/12/06 03:19:30 by lperrey ### ########.fr */ +/* Updated: 2021/12/21 22:41:14 by lperrey ### ########.fr */ /* */ /* ************************************************************************** */ @@ -50,7 +50,8 @@ int export_var(char *arg) char **var_split; int ret; - ret = 0; + if (arg[0] != '_' && !ft_isalpha(arg[0])) + return (shell_error("export: ", arg, ERR_ID_STR, ERR_ID)); var_split = ft_split(arg, '='); if (!var_split) return (-1); @@ -60,6 +61,7 @@ int export_var(char *arg) ft_free_2d_arr(var_split); return (ERR_ID); } + ret = 0; if (ft_strchr(arg, '=')) ret = change_var_value(arg, var_split[0]); ft_free_2d_arr(var_split);