things
This commit is contained in:
parent
668bd06c17
commit
b6aed6ad78
4 changed files with 25 additions and 20 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jschaft <cecile.schaft@orange.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/06/03 12:02:45 by jschaft #+# #+# */
|
||||
/* Updated: 2024/07/03 18:57:09 by jschaft ### ########.fr */
|
||||
/* Updated: 2024/07/04 11:36:00 by mcolonna ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -86,8 +86,7 @@ int exec_builtin(t_env *env, t_call call)
|
|||
if (ft_strncmp(call.program, "unset", 6) == 0)
|
||||
exit (unset_builtin(env, call));
|
||||
if (ft_strncmp(call.program, "export", 6) == 0 && call.argc == 1)
|
||||
exit (export_print_builtin(variables_envp(env->variables,
|
||||
mem_subclass(fatal_error, env->mc_global))));
|
||||
exit (export_print_builtin(env, call));
|
||||
if (ft_strncmp(call.program, "pwd", 4) == 0)
|
||||
exit (pwd_builtin(env, call));
|
||||
if (ft_strncmp(call.program, "echo", 5) == 0)
|
||||
|
|
|
|||
|
|
@ -1,42 +1,48 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* export_print.c :+: :+: :+: */
|
||||
/* export_print_builtin.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jschaft <cecile.schaft@orange.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/07/03 18:57:19 by jschaft #+# #+# */
|
||||
/* Updated: 2024/07/03 18:58:53 by jschaft ### ########.fr */
|
||||
/* Updated: 2024/07/04 11:50:07 by mcolonna ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "include.h"
|
||||
|
||||
int export_print_builtin(char *const *envp)
|
||||
int export_print_builtin(t_env *env, t_call call)
|
||||
{
|
||||
int i;
|
||||
int i2;
|
||||
int i;
|
||||
int i2;
|
||||
const t_memclass mc = mem_subclass(fatal_error, env->mc_global);
|
||||
char *const *envp = variables_envp(env->variables, mc);
|
||||
char c[2];
|
||||
|
||||
i2 = 0;
|
||||
(void)call;
|
||||
i = 0;
|
||||
c[1] = '\0';
|
||||
while (envp[i])
|
||||
{
|
||||
printf("declare -x ");
|
||||
i2 = 0;
|
||||
print_str(fatal_error, 1, "declare -x ");
|
||||
while (envp[i][i2] != '=')
|
||||
{
|
||||
printf("%c", envp[i][i2]);
|
||||
c[0] = envp[i][i2];
|
||||
print_str(fatal_error, 1, c);
|
||||
i2++;
|
||||
}
|
||||
printf("=\"");
|
||||
print_str(fatal_error, 1, "=\"");
|
||||
i2++;
|
||||
while (envp[i][i2])
|
||||
{
|
||||
printf("%c", envp[i][i2]);
|
||||
c[0] = envp[i][i2];
|
||||
print_str(fatal_error, 1, c);
|
||||
i2++;
|
||||
}
|
||||
printf("\"\n");
|
||||
print_str(fatal_error, 1, "\"\n");
|
||||
i++;
|
||||
i2++;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue