pwd/exit
This commit is contained in:
20
srcs/builtins/pwd.c
Normal file
20
srcs/builtins/pwd.c
Normal file
@@ -0,0 +1,20 @@
|
||||
#include "../../includes/builtins.h"
|
||||
|
||||
void builtin_pwd(char *arg)
|
||||
{
|
||||
char *cwd;
|
||||
|
||||
if (ft_strlen(arg) > 3)
|
||||
ft_putendl_fd("pwd: too many arguments", 2);
|
||||
else
|
||||
{
|
||||
cwd = getcwd(NULL, 4096);
|
||||
if (cwd != NULL)
|
||||
{
|
||||
printf("%s\n", cwd);
|
||||
free(cwd);
|
||||
}
|
||||
if (!cwd)
|
||||
perror("pwd");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user