diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-08-07 15:09:31 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-08-07 15:09:31 +0200 |
commit | 85e83d4179e0a0e4d7c07aff750cab9478e461b9 (patch) | |
tree | 1eb28924de62c9348259b9012b8606d67008ad83 /src/b_export_mute.c | |
parent | Old style rewrite in progress (diff) | |
download | 42-minishell-85e83d4179e0a0e4d7c07aff750cab9478e461b9.tar.gz 42-minishell-85e83d4179e0a0e4d7c07aff750cab9478e461b9.tar.bz2 42-minishell-85e83d4179e0a0e4d7c07aff750cab9478e461b9.tar.xz 42-minishell-85e83d4179e0a0e4d7c07aff750cab9478e461b9.tar.zst 42-minishell-85e83d4179e0a0e4d7c07aff750cab9478e461b9.zip |
Forked builtins
Diffstat (limited to 'src/b_export_mute.c')
-rw-r--r-- | src/b_export_mute.c | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/src/b_export_mute.c b/src/b_export_mute.c new file mode 100644 index 0000000..eed7f60 --- /dev/null +++ b/src/b_export_mute.c @@ -0,0 +1,71 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* b_export_mute.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/14 17:19:27 by rbousset #+# #+# */ +/* Updated: 2020/02/14 17:19:29 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include <libft.h> +#include <stdlib.h> +#include <stdint.h> + +#include "b_export.h" +#include "b_export_next.h" +#include "d_enum.h" +#include "f_fail.h" +#include "s_destroy.h" +#include "s_lcom.h" +#include "s_lvars.h" +#include "s_struct.h" +#include "u_utils.h" +#include "u_vars.h" + +uint8_t + b_export_mute(char *args[], + t_msh *msh) +{ + /* TODO: norme */ + char **ptr; + char *varval; + char fmt[4096]; + t_bool next; + uint8_t r; + + if (args[0] == NULL) + return (0); + r = 0; + ptr = args; + while (*ptr != NULL) + { + next = FALSE; + if (check_valid_identifier(*ptr) == FALSE) + { + next = TRUE; + r = 1; + } + if (next == FALSE && check_equals(*ptr) == FALSE) + { + next = TRUE; + ft_sprintf(fmt, "$%s", *ptr); + varval = u_get_cstm_vr(fmt, msh); + if (varval != NULL) + { + ft_sprintf(fmt, "%s=%s", *ptr, varval); + b_add_to_env_from_globals(*ptr, fmt, msh); + ft_memdel((void*)&varval); + } + } + else if (next == FALSE && check_equals(*ptr) == TRUE) + { + b_export_with_equals(*ptr, msh); + } + ptr++; + } + /* TODO: finish export */ + return (r); +} |