This commit is contained in:
Loic Deridder
2025-01-15 13:41:40 +01:00
parent eedfe4a0ee
commit 0ec78ee34c
11 changed files with 182 additions and 48 deletions

View File

@@ -1,20 +1,36 @@
#include "../../includes/builtins.h"
int count_char(char *str)
{
int i;
int count;
i = 0;
count = 0;
while (str[i])
{
if (str[i] != ' ')
count++;
i++;
}
return (count);
}
void builtin_pwd(char *arg)
{
char *cwd;
if (ft_strlen(arg) > 3)
if (count_char(arg) > 3)
ft_putendl_fd("pwd: too many arguments", 2);
else
{
cwd = getcwd(NULL, 4096);
cwd = getcwd(NULL, 0);
if (cwd != NULL)
{
printf("%s\n", cwd);
free(cwd);
}
if (!cwd)
perror("pwd");
perror("pwd");
}
}