Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: dayano <dayano@student.42.fr> +#+ +:+ +#+ #
# By: ttsubo <ttsubo@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2025/04/03 12:55:20 by ttsubo #+# #+# #
# Updated: 2025/04/29 16:48:58 by dayano ### ########.fr #
# Updated: 2025/05/02 14:33:45 by ttsubo ### ########.fr #
# #
# **************************************************************************** #

Expand Down Expand Up @@ -87,8 +87,8 @@ $(foreach DIR,$(MODULE_DIRS), \

clean:
$(MAKE) -C $(FT_DIR) clean
find $(OBJ_DIR) -type f -name '*.o' -exec rm -f {} +
find $(OBJ_DIR) -type d -empty -not -name '.' -exec rmdir {} +
[ -d $(OBJ_DIR) ] && find $(OBJ_DIR) -type f -name '*.o' -exec rm -f {} + || true
[ -d $(OBJ_DIR) ] && find $(OBJ_DIR) -type d -empty -not -name '.' -exec rmdir {} + || true

fclean:
$(MAKE) -C $(FT_DIR) fclean
Expand Down
5 changes: 4 additions & 1 deletion src/builtin/export_exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: ttsubo <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/28 14:11:06 by ttsubo #+# #+# */
/* Updated: 2025/04/29 14:52:09 by ttsubo ### ########.fr */
/* Updated: 2025/05/01 14:04:19 by ttsubo ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -41,10 +41,13 @@ static int _append_value(char *key, char *value, t_minish *minish)
return (EXIT_FAILURE);
if (node->value)
join_str = ft_strjoin(node->value, value);
else
join_str = ft_strdup(value);
if (!join_str)
return (EXIT_FAILURE);
free(node->value);
node->value = join_str;
node->is_exported = 1;
return (EXIT_SUCCESS);
}

Expand Down
17 changes: 10 additions & 7 deletions src/initialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,28 @@
/* By: ttsubo <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/15 15:42:46 by dayano #+# #+# */
/* Updated: 2025/05/01 13:46:27 by ttsubo ### ########.fr */
/* Updated: 2025/05/02 14:11:51 by ttsubo ### ########.fr */
/* */
/* ************************************************************************** */

#include "main.h"

static int _split_key_value(char *env_val, char **key_out, char **val_out)
static int _set_envp(char *env_val, t_env *node)
{
size_t env_len;
size_t eq_pos;

if (!env_val || !node)
return (1);
env_len = ft_strlen(env_val);
eq_pos = ft_strlen_until(env_val, '=');
if (eq_pos == ft_strlen(env_val))
if (eq_pos == env_len)
return (1);
*key_out = ft_substr(env_val, 0, eq_pos);
*val_out = ft_substr(env_val, eq_pos + 1, env_len - eq_pos - 1);
if (!*key_out || !*val_out)
node->key = ft_substr(env_val, 0, eq_pos);
node->value = ft_substr(env_val, eq_pos + 1, env_len - eq_pos - 1);
if (!node->key || !node->value)
return (1);
node->is_exported = 1;
return (0);
}

Expand Down Expand Up @@ -68,7 +71,7 @@ static t_env *create_envp_list(char **envp)
node = ft_calloc(1, sizeof(t_env));
if (!node)
return (NULL);
if (_split_key_value(envp[i], &(node->key), &(node->value)))
if (_set_envp(envp[i], node))
return (_free_nodes(&head), _free_node(node), NULL);
node->next = NULL;
if (!head)
Expand Down
4 changes: 2 additions & 2 deletions tests/builtin/test_cd.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: ttsubo <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/14 11:33:50 by ttsubo #+# #+# */
/* Updated: 2025/04/14 12:34:48 by ttsubo ### ########.fr */
/* Updated: 2025/05/02 13:44:11 by ttsubo ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -21,7 +21,7 @@ int main(int argc, char **argv)
printf("cd %s\n", argv[1]);
getcwd(path, PATH_MAX);
printf("before:path=%s\n", path);
builtin_cd(argc, argv);
builtin_cd(argc, argv, NULL);
getcwd(path, PATH_MAX);
printf("after :path=%s\n", path);
return (0);
Expand Down
4 changes: 2 additions & 2 deletions tests/builtin/test_echo.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: ttsubo <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/15 11:39:28 by ttsubo #+# #+# */
/* Updated: 2025/04/15 12:24:20 by ttsubo ### ########.fr */
/* Updated: 2025/05/02 13:44:35 by ttsubo ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -50,7 +50,7 @@ int main(void)
continue ;
cmds = ft_split(line, ' ');
if (!ft_strncmp(cmds[0], "echo", 4))
builtin_echo(_count_words(cmds), cmds);
builtin_echo(_count_words(cmds), cmds, NULL);
cmds_free(cmds);
free(line);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/builtin/test_exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: ttsubo <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/14 14:48:09 by dayano #+# #+# */
/* Updated: 2025/04/18 22:00:46 by ttsubo ### ########.fr */
/* Updated: 2025/05/02 13:44:49 by ttsubo ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -29,7 +29,7 @@ int main(void)
if (strcmp("exit", line) == 0)
{
strings_line = ft_split(line, ' ');
if (builtin_exit(1, strings_line) == 1)
if (builtin_exit(1, strings_line, NULL) == 1)
{
printf("error\n");
free(line);
Expand Down
6 changes: 3 additions & 3 deletions tests/builtin/test_pwd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
/* ::: :::::::: */
/* test_pwd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dayano <dayano@student.42.fr> +#+ +:+ +#+ */
/* By: ttsubo <ttsubo@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/14 16:07:28 by dayano #+# #+# */
/* Updated: 2025/04/14 16:11:42 by dayano ### ########.fr */
/* Updated: 2025/05/02 13:45:05 by ttsubo ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -26,7 +26,7 @@ int main(int argc, char **argv)
i++;
}
printf("========================\n");
if (builtin_pwd(argc, argv))
if (builtin_pwd(argc, argv, NULL))
printf("error\n");
return (0);
}