update: functions done: echo + echo -n, pwd, exit with and without arguments / parser appears to work, test with commands and local files (only tested with ls -l)

This commit is contained in:
2025-08-04 00:38:53 +02:00
parent e89de4e20b
commit 3e7dd56340
14 changed files with 718 additions and 84 deletions

28
src/builtins/cd.c Normal file
View File

@@ -0,0 +1,28 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* cd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sede-san <sede-san@student.42madrid.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/08/01 11:09:13 by sede-san #+# #+# */
/* Updated: 2025/08/03 02:11:18 by sede-san ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
int cd_builtin(
int argc,
char const *argv[])
{
char *path;
if (argc == 1)
path = getenv("HOME");
else
path = (char *)argv[1];
if (chdir(path) != 0)
return (fprintf(stderr, "cd: %s\n", path), 1);
return (0);
}