aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Doxyfile2
-rw-r--r--Makefile12
-rw-r--r--include/ast.h73
-rw-r--r--include/eval.h28
-rw-r--r--include/minishell.h36
-rw-r--r--include/parse.h10
m---------libft0
-rw-r--r--src/ast.c18
-rw-r--r--src/builtin/builtin.c29
-rw-r--r--src/builtin/cd.c14
-rw-r--r--src/builtin/echo.c14
-rw-r--r--src/builtin/env.c14
-rw-r--r--src/builtin/exit.c16
-rw-r--r--src/builtin/export.c16
-rw-r--r--src/builtin/pwd.c14
-rw-r--r--src/builtin/unset.c14
-rw-r--r--src/env.c13
-rw-r--r--src/eval/eval.c32
-rw-r--r--src/eval/exec.c20
-rw-r--r--src/eval/pipe.c18
-rw-r--r--src/main.c4
-rw-r--r--src/parse/lexer.c2
-rw-r--r--src/parse/parse.c2
-rw-r--r--src/path.c16
-rw-r--r--src/utils.c12
26 files changed, 300 insertions, 130 deletions
diff --git a/.gitignore b/.gitignore
index 7c9865c..a4a5b81 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,4 @@ minishell
*.a
tags
doc/*
+tmp/*
diff --git a/Doxyfile b/Doxyfile
index 5678aa2..1bd10b9 100644
--- a/Doxyfile
+++ b/Doxyfile
@@ -829,7 +829,7 @@ WARN_LOGFILE =
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched.
-INPUT = src include libft/src libft/include
+INPUT = tmp
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
diff --git a/Makefile b/Makefile
index 338a2e6..9ea9988 100644
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@
# By: cacharle <marvin@42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/02/03 04:14:24 by cacharle #+# #+# #
-# Updated: 2020/02/27 17:58:16 by cacharle ### ########.fr #
+# Updated: 2020/04/01 18:08:25 by charles ### ########.fr #
# #
# **************************************************************************** #
@@ -24,12 +24,9 @@ SRCDIR = src
OBJDIR = obj
OBJDIRS = $(shell find $(SRCDIR) -type d | sed 's/src/$(OBJDIR)/')
-INCLUDEFILES = minishell.h
-INCLUDE = $(addprefix $(INCLUDEDIR)/, $(INCLUDEFILES))
+INCLUDE = $(shell find $(INCLUDEDIR) -name "*.h")
-SRCFILES = $(shell find $(SRCDIR) -name "*.c")
-SRC = $(SRCFILES)
-# SRC = $(addprefix $(SRCDIR)/, $(SRCFILES))
+SRC = $(shell find $(SRCDIR) -name "*.c")
OBJ = $(SRC:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
@@ -95,8 +92,11 @@ libft_fclean:
.PHONY: doc
doc:
+ mkdir -p tmp
+ for f in $(SRC) $(INCLUDE) $(shell find libft/src -name "*.c") $(shell find libft/include -name "*.h"); do mkdir -p tmp/`dirname $$f` && sed 's_^/\*$$_/**_' $$f > tmp/$$f; done
$(DOXYGEN) $(DOXYGEN_FILE)
.PHONY: doc_clean
doc_clean:
$(RM) -r $(DOC_DIR)
+ $(RM) -r tmp
diff --git a/include/ast.h b/include/ast.h
index 754956a..0d14779 100644
--- a/include/ast.h
+++ b/include/ast.h
@@ -1,7 +1,19 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ast.h :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/04/01 17:05:38 by charles #+# #+# */
+/* Updated: 2020/04/01 17:52:43 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
#ifndef AST_H
# define AST_H
-/**
+/*
** \file ast.h
** \brief AST structs
*/
@@ -11,7 +23,7 @@
# include "libft_mem.h"
# include "libft_util.h"
-/**
+/*
** \brief Separator type
** \param SEP_END Regular command end `;`
** \param SEP_PIPE Pipe output of left to right `|`
@@ -19,59 +31,60 @@
** \param SEP_OR Execute right if left status != 0 `||`
*/
-typedef enum
+typedef enum e_sep
{
SEP_END,
SEP_PIPE,
SEP_AND,
SEP_OR,
-} t_sep;
+} t_sep;
struct s_ast;
-/**
+/*
** \brief Line struct
** \param left AST to the left of separator
** \param right AST to the right of separator
** \param sep Type of separator
*/
-typedef struct
+typedef struct s_line
{
- struct s_ast *left;
- struct s_ast *right;
- t_sep sep;
-} t_line;
+ struct s_ast *left;
+ struct s_ast *right;
+ t_sep sep;
+} t_line;
-/**
+/*
** \brief Command struct
-** \param argv Array of string, all arguments beginning with executable name
+** \param argv Array of string,
+** all arguments beginning with executable name
** \param in STDIN redirection filename
** \param out STDOUT redirection filename
** \param is_append True if out redirection is append to file
*/
-typedef struct
+typedef struct s_cmd
{
- char **argv;
- char *in;
- char *out;
- bool is_append;
-} t_cmd;
+ char **argv;
+ char *in;
+ char *out;
+ bool is_append;
+} t_cmd;
-/**
+/*
** \brief AST node tag (type)
** \param TAG_CMD Command AST node
** \param TAG_LINE Line AST node
*/
-typedef enum
+typedef enum e_ast_tag
{
TAG_CMD,
TAG_LINE,
-} t_ast_tag;
+} t_ast_tag;
-/**
+/*
** \brief AST node struct
** \param tag Node tag
** \param data Union containning possible node data
@@ -79,17 +92,17 @@ typedef enum
** \param data::line Line struct
*/
-typedef struct s_ast
+typedef struct s_ast
{
- t_ast_tag tag;
+ t_ast_tag tag;
union
{
- t_line line;
- t_cmd cmd;
- } data;
-} t_ast;
+ t_line line;
+ t_cmd cmd;
+ } data;
+} t_ast;
-t_ast *ast_new(t_ast_tag tag, void *data);
-void ast_destroy(t_ast *ast);
+t_ast *ast_new(t_ast_tag tag, void *data);
+void ast_destroy(t_ast *ast);
#endif
diff --git a/include/eval.h b/include/eval.h
index 55cd497..31f729b 100644
--- a/include/eval.h
+++ b/include/eval.h
@@ -1,7 +1,19 @@
-#ifndef MS_EVAL_H
-# define MS_EVAL_H
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* eval.h :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/04/01 17:05:30 by charles #+# #+# */
+/* Updated: 2020/04/01 17:53:26 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
-/**
+#ifndef EVAL_H
+# define EVAL_H
+
+/*
** \file eval.h
** \brief Evaluation module
*/
@@ -9,23 +21,23 @@
# include "minishell.h"
# include "ast.h"
-/**
+/*
** \brief Evaluation state struct
*/
typedef struct
{
- int pipe_in[2]; // need stack pipe
+ int pipe_in[2];
int pipe_out[2];
t_path path;
t_env env;
} t_eval_state;
-/**
+/*
** \brief Evaluation status struct
*/
-typedef struct
+typedef struct s_eval_status
{
char *err;
int status;
@@ -42,7 +54,7 @@ int eval(t_eval_state *state, t_ast *ast);
*/
bool exec_is_path(char *path_str);
-bool exec_is_valid(char *exec_path);
+bool exec_is_valid(char *exec_path);
char *exec_search_path(t_path path, char *path_var, char *exec_name);
/*
diff --git a/include/minishell.h b/include/minishell.h
index a3970dd..b883fc2 100644
--- a/include/minishell.h
+++ b/include/minishell.h
@@ -6,15 +6,15 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/26 15:33:51 by cacharle #+# #+# */
-/* Updated: 2020/02/28 15:30:10 by cacharle ### ########.fr */
+/* Updated: 2020/04/01 17:54:36 by charles ### ########.fr */
/* */
/* ************************************************************************** */
-#include <stdio.h> // for debugging - dont remove
#ifndef MINISHELL_H
# define MINISHELL_H
+#include <stdio.h> // for debugging - dont remove
-/**
+/*
** \file minishell.h
** \brief Common header
*/
@@ -34,19 +34,19 @@
# include "libft_lst.h"
# include "libft_util.h"
-/**
+/*
** \brief Value of pipe entry if closed
*/
# define PIPE_CLOSED -1
-/**
+/*
** \brief Pipe write index
*/
# define PIPE_WRITE 1
-/**
+/*
** \brief Pipe read index
*/
@@ -74,33 +74,33 @@ char **env_to_array(t_env env);
** builtin*.c - directory with all builtin commands
*/
-/**
+/*
** \brief Type of a builtin main function
*/
typedef int (*t_builtin_func)(char **argv, t_env env);
-/**
+/*
** \brief Entry of builtin lookup array
** \param name Executable name of builtin
** \param func Associated function
*/
-struct s_builtin_entry
+struct s_builtin_entry
{
- char *name;
- t_builtin_func func;
+ char *name;
+ t_builtin_func func;
};
int builtin_dispatch_run(char **argv, t_env env);
bool builtin_check_exec_name(char *exec_name);
-int builtin_echo(char **argv, t_env env);
-int builtin_cd(char **argv, t_env env);
-int builtin_pwd(char **argv, t_env env);
-int builtin_export(char **argv, t_env env);
-int builtin_unset(char **argv, t_env env);
-int builtin_env(char **argv, t_env env);
-int builtin_exit(char **argv, t_env env);
+int builtin_echo(char **argv, t_env env);
+int builtin_cd(char **argv, t_env env);
+int builtin_pwd(char **argv, t_env env);
+int builtin_export(char **argv, t_env env);
+int builtin_unset(char **argv, t_env env);
+int builtin_env(char **argv, t_env env);
+int builtin_exit(char **argv, t_env env);
/*
** util.c - various utilitary functions
diff --git a/include/parse.h b/include/parse.h
index c9710d7..bc86230 100644
--- a/include/parse.h
+++ b/include/parse.h
@@ -1,22 +1,22 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
-/* parse.h :+: :+: :+: */
+/* parse.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/28 09:00:00 by cacharle #+# #+# */
-/* Updated: 2020/02/28 14:57:58 by cacharle ### ########.fr */
+/* Updated: 2020/04/01 17:49:45 by charles ### ########.fr */
/* */
/* ************************************************************************** */
-#ifndef MS_PARSE_H
-# define MS_PARSE_H
+#ifndef PARSE_H
+# define PARSE_H
# include "minishell.h"
# include "ast.h"
-/**
+/*
** \file parse.h
** \brief Input parsing and AST manipulation
**
diff --git a/libft b/libft
-Subproject dd5d60dc4cf8052feb00847f9b2276cf105b055
+Subproject 9316f2063255bd4a0abd5c38d4c065969a8980b
diff --git a/src/ast.c b/src/ast.c
index 12761ac..2393a95 100644
--- a/src/ast.c
+++ b/src/ast.c
@@ -1,11 +1,23 @@
-/**
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ast.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/04/01 17:05:42 by charles #+# #+# */
+/* Updated: 2020/04/01 17:05:44 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+/*
** \file ast.c
** \brief AST functions
*/
#include "ast.h"
-/**
+/*
** \brief Create a new AST node according to `tag`
** \param tag Tag of node
** \param data Pointer to node data (t_cmd or t_line)
@@ -30,7 +42,7 @@ t_ast *ast_new(t_ast_tag tag, void *data)
return (ast);
}
-/**
+/*
** \brief Destroy an AST node and all his child nodes
** \param ast AST to destroy
*/
diff --git a/src/builtin/builtin.c b/src/builtin/builtin.c
index 4889f9c..65e8cf4 100644
--- a/src/builtin/builtin.c
+++ b/src/builtin/builtin.c
@@ -1,15 +1,27 @@
-/**
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* builtin.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/04/01 17:11:01 by charles #+# #+# */
+/* Updated: 2020/04/01 17:46:48 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+/*
** \file builtin.c
** \brief Builtin functions
*/
#include "minishell.h"
-/**
+/*
** \brief Array storing builtin executable name and associated functions
*/
-static struct s_builtin_entry g_builtin_lookup[] = {
+static struct s_builtin_entry g_builtin_lookup[] = {
{"echo", builtin_echo},
{"cd", builtin_cd},
{"pwd", builtin_pwd},
@@ -19,14 +31,15 @@ static struct s_builtin_entry g_builtin_lookup[] = {
{"exit", builtin_exit},
};
-/**
+/*
** \brief Call builtin function associated with command name
-** \param argv Arguments to the builtin 'main', with argv[0] being the executable name
+** \param argv Arguments to the builtin 'main',
+** with argv[0] being the executable name
** \param env Environment Vector
** \return Builtin main return status
*/
-int builtin_dispatch_run(char **argv, t_env env)
+int builtin_dispatch_run(char **argv, t_env env)
{
size_t i;
@@ -40,13 +53,13 @@ int builtin_dispatch_run(char **argv, t_env env)
return (BUILTIN_NOT_FOUND);
}
-/**
+/*
** \brief Check if executable name is a builtin
** \param exec_name Executable name
** \return True if executable name is a builtin
*/
-bool builtin_check_exec_name(char *exec_name)
+bool builtin_check_exec_name(char *exec_name)
{
size_t i;
diff --git a/src/builtin/cd.c b/src/builtin/cd.c
index db629b0..dc88dae 100644
--- a/src/builtin/cd.c
+++ b/src/builtin/cd.c
@@ -1,4 +1,16 @@
-/**
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* cd.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/04/01 17:10:20 by charles #+# #+# */
+/* Updated: 2020/04/01 17:10:21 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+/*
** \file cd.c
** \brief `cd` builtin
*/
diff --git a/src/builtin/echo.c b/src/builtin/echo.c
index c9e8cc7..9b7a8f6 100644
--- a/src/builtin/echo.c
+++ b/src/builtin/echo.c
@@ -1,4 +1,16 @@
-/**
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* echo.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/04/01 17:10:47 by charles #+# #+# */
+/* Updated: 2020/04/01 17:10:48 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+/*
** \file echo.c
** \brief `echo` builtin
*/
diff --git a/src/builtin/env.c b/src/builtin/env.c
index 352e2c3..d3f4024 100644
--- a/src/builtin/env.c
+++ b/src/builtin/env.c
@@ -1,4 +1,16 @@
-/**
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* env.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/04/01 17:10:32 by charles #+# #+# */
+/* Updated: 2020/04/01 17:10:33 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+/*
** \file env.c
** \brief `env` builtin
*/
diff --git a/src/builtin/exit.c b/src/builtin/exit.c
index bd41f0f..1e6ec45 100644
--- a/src/builtin/exit.c
+++ b/src/builtin/exit.c
@@ -1,11 +1,23 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* exit.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/04/01 17:10:16 by charles #+# #+# */
+/* Updated: 2020/04/01 17:10:17 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
#include "minishell.h"
-/**
+/*
** \file exit.c
** \brief `exit` builtin
*/
-int builtin_exit(char **argv, t_env env)
+int builtin_exit(char **argv, t_env env)
{
(void)argv;
(void)env;
diff --git a/src/builtin/export.c b/src/builtin/export.c
index 1b148a9..8a62412 100644
--- a/src/builtin/export.c
+++ b/src/builtin/export.c
@@ -1,4 +1,16 @@
-/**
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* export.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/04/01 17:11:34 by charles #+# #+# */
+/* Updated: 2020/04/01 17:11:38 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+/*
** \file export.c
** \brief `export` builtin
*/
@@ -9,7 +21,5 @@ int builtin_export(char **argv, t_env env)
{
(void)argv;
(void)env;
- /* if (ft_htset(env, ) == NULL) */
- /* return (-1); */
return (0);
}
diff --git a/src/builtin/pwd.c b/src/builtin/pwd.c
index 6e0971f..ab0b1d8 100644
--- a/src/builtin/pwd.c
+++ b/src/builtin/pwd.c
@@ -1,4 +1,16 @@
-/**
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* pwd.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/04/01 17:10:40 by charles #+# #+# */
+/* Updated: 2020/04/01 17:10:40 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+/*
** \file pwd.c
** \brief `pwd` builtin
*/
diff --git a/src/builtin/unset.c b/src/builtin/unset.c
index 1fc5ce1..2ae6c27 100644
--- a/src/builtin/unset.c
+++ b/src/builtin/unset.c
@@ -1,4 +1,16 @@
-/**
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* unset.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/04/01 17:10:51 by charles #+# #+# */
+/* Updated: 2020/04/01 17:10:51 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+/*
** \file unset.c
** \brief `unset` builtin
*/
diff --git a/src/env.c b/src/env.c
index 00fbaaf..fc26876 100644
--- a/src/env.c
+++ b/src/env.c
@@ -1,29 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
-/* environment.c :+: :+: :+: */
+/* env.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/28 09:21:24 by cacharle #+# #+# */
-/* Updated: 2020/02/28 12:30:55 by cacharle ### ########.fr */
+/* Updated: 2020/04/01 17:03:50 by charles ### ########.fr */
/* */
/* ************************************************************************** */
-/**
+/*
** \file env.c
** \brief Environment hash table manipulation
*/
#include "minishell.h"
-/**
+/*
** \brief Number of buckets of an environment hash table
*/
#define MS_ENV_HT_SIZE 2048
-/**
+/*
** \brief Convert array of string to environment hash table
** \param envp array of string (each in the format `name=value`)
** \return Environment hash table or NULL on error
@@ -57,7 +57,7 @@ t_env env_from_array(char **envp)
return (env);
}
-/**
+/*
** \brief Convert environment to array of string
** \param env Environment hash table
** \return Array of string on NULL on error
@@ -66,6 +66,5 @@ t_env env_from_array(char **envp)
char **env_to_array(t_env env)
{
(void)env;
- // need ft_htlen
return (NULL);
}
diff --git a/src/eval/eval.c b/src/eval/eval.c
index d2fab39..c90618c 100644
--- a/src/eval/eval.c
+++ b/src/eval/eval.c
@@ -1,18 +1,30 @@
-/**
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* eval.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/04/01 17:05:21 by charles #+# #+# */
+/* Updated: 2020/04/01 17:09:36 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+/*
** \file eval.c
** \brief Evaluation of an AST
*/
#include "eval.h"
-/**
+/*
** \brief Evaluate a line
** \param state State of the evaluation
** \param line Line to evaluate
** \return Last Executed command status or -1 on error
*/
-static int eval_line(t_eval_state *state, t_line *line)
+static int eval_line(t_eval_state *state, t_line *line)
{
int status;
@@ -26,14 +38,14 @@ static int eval_line(t_eval_state *state, t_line *line)
return (eval(state, line->right));
}
-/**
+/*
** \brief Evaluate a command
** \param state Evaluation state
** \param cmd Command to evaluate
** \return Executable status or -1 on error
*/
-static int eval_cmd(t_eval_state *state, t_cmd *cmd)
+static int eval_cmd(t_eval_state *state, t_cmd *cmd)
{
int child_pid;
char *exec_path;
@@ -54,7 +66,7 @@ static int eval_cmd(t_eval_state *state, t_cmd *cmd)
pipe_setup_child(state->pipe_in, state->pipe_out);
if (is_builtin)
exit(builtin_dispatch_run(cmd->argv, state->env));
- else if (execve(exec_path, cmd->argv, NULL /*env_array*/) == -1)
+ else if (execve(exec_path, cmd->argv, NULL) == -1)
exit(EXIT_FAILURE);
exit(EXIT_SUCCESS);
}
@@ -62,19 +74,19 @@ static int eval_cmd(t_eval_state *state, t_cmd *cmd)
return (WEXITSTATUS(child_pid));
}
-/**
+/*
** \brief Evaluate an AST
** \param state State of the evaluation
** \param ast Abstract syntax tree to evaluate
** \return Executable status or -1 on error
*/
-int eval(t_eval_state *state, t_ast *ast)
+int eval(t_eval_state *state, t_ast *ast)
{
errno = 0;
if (ast->tag == TAG_LINE)
- return eval_line(state, &ast->data.line);
+ return (eval_line(state, &ast->data.line));
if (ast->tag == TAG_CMD)
- return eval_cmd(state, &ast->data.cmd);
+ return (eval_cmd(state, &ast->data.cmd));
return (-1);
}
diff --git a/src/eval/exec.c b/src/eval/exec.c
index 1ac9754..e41f994 100644
--- a/src/eval/exec.c
+++ b/src/eval/exec.c
@@ -1,11 +1,23 @@
-/**
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* exec.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/04/01 17:06:11 by charles #+# #+# */
+/* Updated: 2020/04/01 17:06:12 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+/*
** \file exec.c
** \brief Executable name and path
*/
#include "eval.h"
-/**
+/*
** \brief Check if executable name is already a path
** \param exec_name Executable name
** \return True if valid
@@ -18,7 +30,7 @@ bool exec_is_path(char *exec_name)
|| ft_strncmp(exec_name, "/", 1) == 0);
}
-/**
+/*
** \brief Check if executable path is valid
** \param exec_path Executable path
** \return True if valid
@@ -36,7 +48,7 @@ bool exec_is_valid(char *exec_path)
return (true);
}
-/**
+/*
** \brief Search executable name in path
** \param path Path hash table
** \param path_var Path environment string in case we need to update path
diff --git a/src/eval/pipe.c b/src/eval/pipe.c
index 897a5f2..125c013 100644
--- a/src/eval/pipe.c
+++ b/src/eval/pipe.c
@@ -1,11 +1,23 @@
-/**
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* pipe.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/04/01 17:05:58 by charles #+# #+# */
+/* Updated: 2020/04/01 17:05:59 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+/*
** \file pipe.c
** \brief Pipes setup
*/
#include "eval.h"
-/**
+/*
** \brief Setup STDIN and STDOUT pipe in the parent process
** \param cmd Command to setup
** \param pipe_in STDIN pipe
@@ -29,7 +41,7 @@ int pipe_setup_parent(t_cmd *cmd, int pipe_in[2], int pipe_out[2])
return (0);
}
-/**
+/*
** \brief Setup STDIN and STDOUT pipe in the child process
** \param pipe_in STDIN pipe
** \param pipe_out STDOUT pipe
diff --git a/src/main.c b/src/main.c
index 1e42b87..233333d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -10,7 +10,7 @@
/* */
/* ************************************************************************** */
-/**
+/*
** \file main.c
** \brief Minishell entrypoint
*/
@@ -19,7 +19,7 @@
#include "ast.h"
#include "eval.h"
-/**
+/*
** \brief Program entrypoint
** \param argc Number of arguments in `argv`
** \param argv Array of string, argument of the program
diff --git a/src/parse/lexer.c b/src/parse/lexer.c
index 57ecdf7..74a3bd4 100644
--- a/src/parse/lexer.c
+++ b/src/parse/lexer.c
@@ -1,4 +1,4 @@
-/**
+/*
** \file lexer.c
** \brief Lexer
*/
diff --git a/src/parse/parse.c b/src/parse/parse.c
index c99f0fe..ed1aa28 100644
--- a/src/parse/parse.c
+++ b/src/parse/parse.c
@@ -1,4 +1,4 @@
-/**
+/*
** \file parse.c
** \brief Parser
*/
diff --git a/src/path.c b/src/path.c
index 1136a7c..f1424cc 100644
--- a/src/path.c
+++ b/src/path.c
@@ -6,25 +6,26 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/27 15:51:01 by cacharle #+# #+# */
-/* Updated: 2020/02/28 12:33:31 by cacharle ### ########.fr */
+/* Updated: 2020/04/01 17:55:28 by charles ### ########.fr */
/* */
/* ************************************************************************** */
-/**
+/*
** \file path.c
** \brief Path hash table manipulation
*/
#include "minishell.h"
-/**
+/*
** \brief Number of buckets of a path hash table
*/
#define MS_PATH_HT_SIZE 8192
-/**
-** \brief Update `path` with all files in the directory named `dirname`.
+/*
+** \brief Update `path` with all files
+** in the directory named `dirname`.
** \param path Path hash table
** \param dirname directory name
** \return Same path or NULL on error
@@ -50,10 +51,11 @@ static t_path st_path_dir_update(t_path path, char *dirname)
return (path);
}
-/**
+/*
** \brief Update the path
** \param path Path hash table or NULL to create a new one
-** \param path_var PATH environment variable where each directory is separated by a ':'
+** \param path_var PATH environment variable where
+** each directory is separated by a ':'
** \return The updated/created path hash table or NULL on error
*/
diff --git a/src/utils.c b/src/utils.c
index 5989d71..1649199 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -1,26 +1,26 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
-/* util.c :+: :+: :+: */
+/* utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/28 11:56:31 by cacharle #+# #+# */
-/* Updated: 2020/02/28 11:57:30 by cacharle ### ########.fr */
+/* Updated: 2020/04/01 17:55:34 by charles ### ########.fr */
/* */
/* ************************************************************************** */
-/**
+/*
** \file utils.c
** \brief Various functions
*/
#include "minishell.h"
-/**
-** \brief Delete function for a entry containing a allocated key and value
+/*
+** \brief Delete function for a entry containing
+** an allocated key and value
** \param entry Hash table entry
-**
*/
void ht_del_str_entry(t_ftht_entry *entry)