things
This commit is contained in:
parent
668bd06c17
commit
b6aed6ad78
4 changed files with 25 additions and 20 deletions
4
Makefile
4
Makefile
|
@ -5,8 +5,8 @@ SRCS = src/
|
||||||
# include directory
|
# include directory
|
||||||
INCLUDES = include/ libtf/ libft/
|
INCLUDES = include/ libtf/ libft/
|
||||||
# .c files in src/ without the extension
|
# .c files in src/ without the extension
|
||||||
CODE = main ask_command error path parse_command exec_command builtin builtin2 export_print\
|
CODE = main ask_command error path parse_command exec_command builtin builtin2 \
|
||||||
signals cool_readline variables parse_command_utils \
|
signals cool_readline variables parse_command_utils export_print_builtin \
|
||||||
parse_command_read_string parse_command_read_element variables_utils
|
parse_command_read_string parse_command_read_element variables_utils
|
||||||
# directories to 'make'
|
# directories to 'make'
|
||||||
LIBRARIES = libtf libft
|
LIBRARIES = libtf libft
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jschaft <cecile.schaft@orange.fr> +#+ +:+ +#+ */
|
/* By: jschaft <cecile.schaft@orange.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/04/23 14:15:12 by mcolonna #+# #+# */
|
/* Created: 2024/04/23 14:15:12 by mcolonna #+# #+# */
|
||||||
/* Updated: 2024/07/03 18:59:22 by jschaft ### ########.fr */
|
/* Updated: 2024/07/04 11:48:47 by mcolonna ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
@ -27,8 +27,8 @@ int echo_builtin(t_env *env, t_call call);
|
||||||
// Execute cd builtin
|
// Execute cd builtin
|
||||||
int cd_builtin(t_env *env, t_call call);
|
int cd_builtin(t_env *env, t_call call);
|
||||||
|
|
||||||
//Execute builtin with no arguments
|
// Execute export builtin with no arguments
|
||||||
int export_print_builtin(char *const *envp);
|
int export_print_builtin(t_env *env, t_call call);
|
||||||
|
|
||||||
// Execute export builtin
|
// Execute export builtin
|
||||||
int export_builtin(t_env *env, t_call call);
|
int export_builtin(t_env *env, t_call call);
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jschaft <cecile.schaft@orange.fr> +#+ +:+ +#+ */
|
/* By: jschaft <cecile.schaft@orange.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/06/03 12:02:45 by jschaft #+# #+# */
|
/* 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)
|
if (ft_strncmp(call.program, "unset", 6) == 0)
|
||||||
exit (unset_builtin(env, call));
|
exit (unset_builtin(env, call));
|
||||||
if (ft_strncmp(call.program, "export", 6) == 0 && call.argc == 1)
|
if (ft_strncmp(call.program, "export", 6) == 0 && call.argc == 1)
|
||||||
exit (export_print_builtin(variables_envp(env->variables,
|
exit (export_print_builtin(env, call));
|
||||||
mem_subclass(fatal_error, env->mc_global))));
|
|
||||||
if (ft_strncmp(call.program, "pwd", 4) == 0)
|
if (ft_strncmp(call.program, "pwd", 4) == 0)
|
||||||
exit (pwd_builtin(env, call));
|
exit (pwd_builtin(env, call));
|
||||||
if (ft_strncmp(call.program, "echo", 5) == 0)
|
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> +#+ +:+ +#+ */
|
/* By: jschaft <cecile.schaft@orange.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/07/03 18:57:19 by jschaft #+# #+# */
|
/* 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"
|
#include "include.h"
|
||||||
|
|
||||||
int export_print_builtin(char *const *envp)
|
int export_print_builtin(t_env *env, t_call call)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int i2;
|
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;
|
i = 0;
|
||||||
|
c[1] = '\0';
|
||||||
while (envp[i])
|
while (envp[i])
|
||||||
{
|
{
|
||||||
printf("declare -x ");
|
i2 = 0;
|
||||||
|
print_str(fatal_error, 1, "declare -x ");
|
||||||
while (envp[i][i2] != '=')
|
while (envp[i][i2] != '=')
|
||||||
{
|
{
|
||||||
printf("%c", envp[i][i2]);
|
c[0] = envp[i][i2];
|
||||||
|
print_str(fatal_error, 1, c);
|
||||||
i2++;
|
i2++;
|
||||||
}
|
}
|
||||||
printf("=\"");
|
print_str(fatal_error, 1, "=\"");
|
||||||
i2++;
|
i2++;
|
||||||
while (envp[i][i2])
|
while (envp[i][i2])
|
||||||
{
|
{
|
||||||
printf("%c", envp[i][i2]);
|
c[0] = envp[i][i2];
|
||||||
|
print_str(fatal_error, 1, c);
|
||||||
i2++;
|
i2++;
|
||||||
}
|
}
|
||||||
printf("\"\n");
|
print_str(fatal_error, 1, "\"\n");
|
||||||
i++;
|
i++;
|
||||||
i2++;
|
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue