diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-03-04 16:22:04 +0100 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-03-04 16:22:04 +0100 |
| commit | e0ba9a82e11d9f23cf4eaed267b25021f98ae9f4 (patch) | |
| tree | 1edcce57ffac441288167283968c1dd6eef0e1e5 /src/environment.c | |
| parent | 5dc7a4036025bd7c3f997f08e2d9b14338c0e528 (diff) | |
| download | minishell-e0ba9a82e11d9f23cf4eaed267b25021f98ae9f4.tar.gz minishell-e0ba9a82e11d9f23cf4eaed267b25021f98ae9f4.tar.bz2 minishell-e0ba9a82e11d9f23cf4eaed267b25021f98ae9f4.zip | |
Fixing environment, Added env buitin
Diffstat (limited to 'src/environment.c')
| -rw-r--r-- | src/environment.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/environment.c b/src/environment.c index a39b246..90cac86 100644 --- a/src/environment.c +++ b/src/environment.c @@ -21,7 +21,7 @@ t_ftht *ms_environment_from_array(const char **envp) char *key; char *value; /* int equal_pos; */ - + if (envp == NULL) return (NULL); if ((environment = ft_htnew(MS_ENVIRONMENT_HT_SIZE)) == NULL) @@ -32,12 +32,14 @@ t_ftht *ms_environment_from_array(const char **envp) // free stuff on error if ((value = ft_strchr(envp[i], '=')) == NULL) return (NULL); - if ((key = ft_strndup(envp[i], ft_strspn(envp[i], "="))) == NULL) + if ((key = ft_strndup(envp[i], ft_strcspn(envp[i], "="))) == NULL) return (NULL); - if ((value = ft_strdup(value)) == NULL) + /* printf("%s -- %d\n", envp[i], strcspn(envp[i], "=")); */ + if ((value = ft_strdup(value + 1)) == NULL) return (NULL); if (ft_htset(environment, key, value, ms_ht_del_str_entry) == NULL) return (NULL); + free(key); } return (environment); } @@ -49,8 +51,3 @@ char **ms_environment_to_array(t_ftht *environment) return (NULL); } - -/* void ms_environment_destroy(t_ftht *environment) */ -/* { */ -/* ft_htdestroy(environment, ms_ht_del_str_entry); */ -/* } */ |
