Skip to content

Commit

Permalink
handling 'export' without argument case
Browse files Browse the repository at this point in the history
  • Loading branch information
VernihoraIvan committed Aug 2, 2024
1 parent 101b4b0 commit 4a2833c
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/env/additional_env.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: iverniho <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/27 17:12:47 by iverniho #+# #+# */
/* Updated: 2024/07/28 16:18:10 by iverniho ### ########.fr */
/* Updated: 2024/08/02 15:37:51 by iverniho ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -66,6 +66,19 @@ void copy_envp(t_mini *mini, char ***new_envp_array, char *new_env)
mini->envp = *new_envp_array;
}

void export_with_no_args(t_mini *mini)
{
int i;

i = -1;
while (mini->envp[++i])
{
ft_putstr_fd("declare -x ", STDOUT_FILENO);
ft_putstr_fd(mini->envp[i], STDOUT_FILENO);
ft_putchar_fd('\n', STDOUT_FILENO);
}
}

void mini_export(char **args, t_mini *mini)
{
char *key;
Expand All @@ -75,7 +88,7 @@ void mini_export(char **args, t_mini *mini)
char **new_envp_array;

if (ft_2d_array_len(args) < 2)
return ;
return (export_with_no_args(mini));
if ((!ft_strchr(*(args + 1), '=')) || (!check_after_equal(*(args + 1))))
if (add_env_key(*(args + 1), mini, ft_2d_array_len(mini->envp) + 1))
return ;
Expand Down

0 comments on commit 4a2833c

Please sign in to comment.