bug fix env -i && cd error message

This commit is contained in:
Tanguy MAZE
2020-02-14 12:22:35 +01:00
parent 7db099a010
commit b9c1a344b2
6 changed files with 31 additions and 10 deletions

View File

@@ -25,8 +25,8 @@ int cmd_cd_update_env(char *path, t_env **env, char opt)
if (getcwd(p_path, 4096) == NULL || (oldpwd = ft_strdup(pwd->val)) == NULL
|| ft_realpath(path, &c_path) == NULL)
return (put_error_cd2(path, "error"));
if (ft_envupdate("PWD", *env, ((opt == 'P') ? p_path : c_path)) == NULL
|| ft_envupdate("OLDPWD", *env, oldpwd) == NULL)
if (cd_updateenv("PWD", ((opt == 'P') ? p_path : c_path), env) == NULL
|| cd_updateenv("OLDPWD", oldpwd, env) == NULL)
{
ft_strdel(&oldpwd);
ft_strdel(&c_path);

View File

@@ -78,14 +78,15 @@ int cleanup(char **argv, t_env *env)
return (0);
}
int main(void)
int main(int ac , char **av, char **envp)
{
extern char **environ;
char **argv;
t_env *env;
char *cmd;
if ((env = env2lst(environ)) == NULL)
(void)ac;
(void)av;
if ((env = env2lst(envp)) == NULL)
return (2);
while (1)
{