Astuce: écouté Raoult

This commit is contained in:
Etienne Rey-bethbeder 2023-03-30 13:12:18 +02:00
parent a941a0138f
commit 471845b565
4 changed files with 13 additions and 12 deletions

View File

@ -6,7 +6,7 @@
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */ /* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/20 14:27:36 by erey-bet #+# #+# */ /* Created: 2023/02/20 14:27:36 by erey-bet #+# #+# */
/* Updated: 2023/03/13 15:11:07 by erey-bet ### ########.fr */ /* Updated: 2023/03/21 13:16:24 by erey-bet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -32,17 +32,12 @@ int move_folder(char **args, int fd)
{ {
char *path; char *path;
if (args[1] != NULL) if (args[1] != NULL || args[0] == NULL)
{ {
write(2, "cd: too many argument\n", 22); write(2, "cd: Wrong number's argument\n", 28);
return (1); return (1);
} }
path = args[0]; path = args[0];
if (!path)
{
write(2, "No such file or directory\n", 26);
return (1);
}
if (path[0] == '/' || ft_strncmp(path, "..", ft_strlen(path)) == 0) if (path[0] == '/' || ft_strncmp(path, "..", ft_strlen(path)) == 0)
{ {
if (chdir(path) == 0) if (chdir(path) == 0)

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/14 14:27:08 by cchauvet #+# #+# */ /* Created: 2023/02/14 14:27:08 by cchauvet #+# #+# */
/* Updated: 2023/03/13 13:23:56 by erey-bet ### ########.fr */ /* Updated: 2023/03/30 13:04:53 by erey-bet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

6
env/env1.c vendored
View File

@ -1,12 +1,12 @@
/* ************************************************************************** */ /* ************************************************************************** */
/* */ /* */
/* ::: :::::::: */ /* ::: :::::::: */
/* env.c :+: :+: :+: */ /* env1.c :+: :+: :+: */
/* +:+ +:+ +:+ */ /* +:+ +:+ +:+ */
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */ /* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/02 14:39:56 by erey-bet #+# #+# */ /* Created: 2023/02/02 14:39:56 by erey-bet #+# #+# */
/* Updated: 2023/03/09 19:01:05 by erey-bet ### ########.fr */ /* Updated: 2023/03/30 13:07:15 by erey-bet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -61,7 +61,9 @@ int set_value_by_key(char *key, char *value, t_list **head)
if (ft_strcmp(((t_env *)current->content)->key, key) == 0) if (ft_strcmp(((t_env *)current->content)->key, key) == 0)
{ {
free(((t_env *)current->content)->value); free(((t_env *)current->content)->value);
free(((t_env *)current->content)->key);
((t_env *)current->content)->value = value; ((t_env *)current->content)->value = value;
((t_env *)current->content)->key = key;
return (0); return (0);
} }
current = current->next; current = current->next;

6
env/env3.c vendored
View File

@ -6,7 +6,7 @@
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */ /* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/17 17:25:09 by erey-bet #+# #+# */ /* Created: 2023/02/17 17:25:09 by erey-bet #+# #+# */
/* Updated: 2023/03/09 19:58:55 by erey-bet ### ########.fr */ /* Updated: 2023/03/30 12:51:54 by erey-bet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -74,10 +74,14 @@ int delete_by_key(char *key, t_list **head)
{ {
if (ft_strcmp(((t_env *)current->content)->key, key) == 0) if (ft_strcmp(((t_env *)current->content)->key, key) == 0)
{ {
free(((t_env *)current->content)->key);
free(((t_env *)current->content)->value);
free(current->content);
if (last->next != NULL) if (last->next != NULL)
last->next = current->next; last->next = current->next;
else else
*head = current->next; *head = current->next;
free(current);
return (0); return (0);
} }
last = current; last = current;