export builtin bugfix

now check frst char before split
return error even if argument first char is '='
This commit is contained in:
LuckyLaszlo
2021-12-21 22:42:01 +01:00
parent 638dbbaf9c
commit b51535cdbc

View File

@@ -6,7 +6,7 @@
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);