exec
This commit is contained in:
@@ -6,43 +6,27 @@
|
||||
/* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/01/24 14:32:30 by lderidde #+# #+# */
|
||||
/* Updated: 2025/01/24 14:32:30 by lderidde ### ########.fr */
|
||||
/* Updated: 2025/01/28 10:38:07 by lderidde ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#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)
|
||||
int builtin_pwd(char **arg)
|
||||
{
|
||||
char *cwd;
|
||||
|
||||
if (count_char(arg) > 3)
|
||||
ft_putendl_fd("pwd: too many arguments", 2);
|
||||
else
|
||||
(void)arg;
|
||||
cwd = getcwd(NULL, 0);
|
||||
if (cwd != NULL)
|
||||
{
|
||||
cwd = getcwd(NULL, 0);
|
||||
if (cwd != NULL)
|
||||
{
|
||||
printf("%s\n", cwd);
|
||||
free(cwd);
|
||||
}
|
||||
if (!cwd)
|
||||
perror("pwd");
|
||||
ft_printf("%s\n", cwd);
|
||||
free(cwd);
|
||||
return (0);
|
||||
}
|
||||
else
|
||||
{
|
||||
perror("pwd");
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user