Created file for builtins and fixed a bug about expansion not working correctly

This commit is contained in:
Maix0 2024-08-10 19:50:26 +02:00
parent 1ecfba4340
commit 3f08544384
15 changed files with 243 additions and 429 deletions

View file

@ -1,36 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* env.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/07 14:22:50 by rparodi #+# #+# */
/* Updated: 2024/08/07 14:23:14 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "app/env.h"
#include "me/string/string.h"
#include "me/hash/hasher.h"
#include "me/hashmap/hashmap_env.h"
#include "me/mem/mem.h"
#include "me/str/str.h"
#include "me/str/str.h"
#include "me/str/str.h"
#include "me/types.h"
#include "me/vec/vec_str.h"
#include <cstddef>
#include <stdlib.h>
void env(t_str *envp)
{
size_t i;
i = 0;
while (envp[i] != NULL)
{
printf("%s\n", envp[i]);
i++;
}
}

View file

@ -1,36 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* export.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/07 14:13:41 by rparodi #+# #+# */
/* Updated: 2024/08/07 14:22:23 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "app/env.h"
#include "me/string/string.h"
#include "me/hash/hasher.h"
#include "me/hashmap/hashmap_env.h"
#include "me/mem/mem.h"
#include "me/str/str.h"
#include "me/str/str.h"
#include "me/str/str.h"
#include "me/types.h"
#include "me/vec/vec_str.h"
#include <cstddef>
#include <stdlib.h>
void export(t_str *envp)
{
size_t i;
i = 0;
while (envp[i] != NULL)
{
printf("%s\n", envp[i]);
i++;
}
}

View file

@ -1,45 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* pwd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/07 13:58:37 by rparodi #+# #+# */
/* Updated: 2024/08/07 14:07:39 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "app/env.h"
#include "me/string/string.h"
#include "me/hash/hasher.h"
#include "me/hashmap/hashmap_env.h"
#include "me/mem/mem.h"
#include "me/str/str.h"
#include "me/str/str.h"
#include "me/str/str.h"
#include "me/types.h"
#include "me/vec/vec_str.h"
#include <stdlib.h>
void pwd(void)
{
t_str str;
t_usize size;
size = 1024;
str = (t_str)mem_alloc((size + 1) * sizeof(t_i8));
if (str == NULL)
me_abort("Error allocating for pwd builtin");
while (getcwd(str, size) == NULL)
{
if (str)
free(str);
size *= 2;
str = (t_str)mem_alloc(sizeof(t_i8) * size);
if (str == NULL)
me_abort("Error allocating for pwd builtin");
}
printf("%s\n", str);
free(str);
}