core: rebuild of parsing and the execution
This commit is contained in:
8
builtins/:wq
Normal file
8
builtins/:wq
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef BUILTINS_PRIVATE_H
|
||||
# define BUILTINS_PRIVATE_H
|
||||
# include <limits.h>
|
||||
# include "../libftx/libftx.h"
|
||||
# include "../env/env.h"
|
||||
# include "../utils/utils.h"
|
||||
char *get_pwd(int fd);
|
||||
#endif
|
14
builtins/builtins.h
Normal file
14
builtins/builtins.h
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef BUILTINS_H
|
||||
# define BUILTINS_H
|
||||
# include "../libftx/libft/list.h"
|
||||
|
||||
int echo(int fd, char **strs);
|
||||
int pwd(int fd);
|
||||
char *get_pwd(int fd);
|
||||
int print_env(t_list **env, int fd);
|
||||
int ft_export(t_list **env, char **args, int fd);
|
||||
int move_folder(char **args, int fd);
|
||||
int unset(t_list **env, char **args, int fd);
|
||||
int ft_exit(char **args);
|
||||
|
||||
#endif
|
8
builtins/builtins_private.h
Normal file
8
builtins/builtins_private.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef BUILTINS_PRIVATE_H
|
||||
# define BUILTINS_PRIVATE_H
|
||||
# include <limits.h>
|
||||
# include "../libftx/libftx.h"
|
||||
# include "../env/env.h"
|
||||
# include "../utils/utils.h"
|
||||
char *get_pwd(int fd);
|
||||
#endif
|
@ -10,7 +10,7 @@
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../minishell.h"
|
||||
#include "./builtins_private.h"
|
||||
|
||||
int move_folder(char **args, int fd)
|
||||
{
|
||||
@ -44,21 +44,3 @@ int move_folder(char **args, int fd)
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
|
||||
/*int main(int argc, char *argv[]) {
|
||||
char cwd[PATH_MAX];
|
||||
if (getcwd(cwd, sizeof(cwd)) != NULL) {
|
||||
printf("%s\n", cwd);
|
||||
} else {
|
||||
perror("getcwd() error");
|
||||
return 1;
|
||||
}
|
||||
move_folder(argv[1], 1);
|
||||
if (getcwd(cwd, sizeof(cwd)) != NULL) {
|
||||
printf("%s\n", cwd);
|
||||
} else {
|
||||
perror("getcwd() error");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}*/
|
||||
|
@ -10,7 +10,7 @@
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../minishell.h"
|
||||
#include "./builtins_private.h"
|
||||
|
||||
int is_space(char c)
|
||||
{
|
||||
|
@ -10,7 +10,7 @@
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../minishell.h"
|
||||
#include "./builtins_private.h"
|
||||
|
||||
int print_env(t_list **env, int fd)
|
||||
{
|
||||
|
@ -10,7 +10,7 @@
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../minishell.h"
|
||||
#include "./builtins_private.h"
|
||||
|
||||
static int error(int err, char *reason, char *problem)
|
||||
{
|
||||
@ -39,9 +39,3 @@ int ft_exit(char **args)
|
||||
return(error(err, "numeric argument required", args[0]));
|
||||
return ((ft_atoi(args[0]) % 256 + 256) % 256);
|
||||
}
|
||||
|
||||
/*int main(int argc, char *argv[])
|
||||
{
|
||||
(void)argc;
|
||||
return(ft_exit(argv + 1, 1));
|
||||
}*/
|
||||
|
@ -10,7 +10,7 @@
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../minishell.h"
|
||||
#include "./builtins_private.h"
|
||||
|
||||
static int error(char *str, int fd)
|
||||
{
|
||||
@ -65,7 +65,7 @@ int add_export(t_list **env, char *args, int fd, int *err)
|
||||
return (0);
|
||||
}
|
||||
|
||||
int export(t_list **env, char **args, int fd)
|
||||
int ft_export(t_list **env, char **args, int fd)
|
||||
{
|
||||
int err;
|
||||
int i;
|
||||
@ -82,13 +82,3 @@ int export(t_list **env, char **args, int fd)
|
||||
}
|
||||
return (err);
|
||||
}
|
||||
/*
|
||||
int main(int argc, char *argv[], char **env)
|
||||
{
|
||||
t_list **n_env;
|
||||
|
||||
(void)argc;
|
||||
n_env = init_env(env);
|
||||
export(n_env, argv + 1, 1);
|
||||
return (0);
|
||||
}*/
|
||||
|
@ -10,7 +10,7 @@
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../minishell.h"
|
||||
#include "./builtins_private.h"
|
||||
|
||||
int pwd(int fd)
|
||||
{
|
||||
|
@ -10,7 +10,7 @@
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../minishell.h"
|
||||
#include "./builtins_private.h"
|
||||
|
||||
int error(char *str, int fd)
|
||||
{
|
||||
|
Reference in New Issue
Block a user