evaluation done
This commit is contained in:
parent
0da6bb86c4
commit
df04c2fecc
8
Makefile
8
Makefile
@ -6,7 +6,7 @@
|
||||
# By: apommier <apommier@student.42.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2022/03/06 12:50:24 by apommier #+# #+# #
|
||||
# Updated: 2022/04/22 11:25:14 by apommier ### ########.fr #
|
||||
# Updated: 2022/04/23 13:33:48 by apommier ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
@ -41,15 +41,15 @@ SRCS = srcs/main.c\
|
||||
srcs/set_quote/set_var.c\
|
||||
|
||||
OBJS = ${SRCS:.c=.o}
|
||||
CC = clang
|
||||
CFLAGS = -Wall -Wextra -Werror -g
|
||||
CC = gcc
|
||||
CFLAGS = -Wall -Wextra -Werror -fcommon
|
||||
LIB = -lreadline
|
||||
RM = rm -rf
|
||||
LIBFT = ./libft
|
||||
|
||||
${NAME}: ${OBJS}
|
||||
@make bonus -C ${LIBFT}
|
||||
@${CC} ${LIB} ${OBJS} ${LIBFT}/libft.a -o ${NAME}
|
||||
${CC} ${OBJS} ${LIBFT}/libft.a -o ${NAME} -lreadline
|
||||
|
||||
all: ${NAME}
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/03/09 22:33:49 by apommier #+# #+# */
|
||||
/* Updated: 2022/04/22 13:01:36 by apommier ### ########.fr */
|
||||
/* Updated: 2022/04/23 13:37:53 by apommier ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -27,8 +27,8 @@
|
||||
# include <errno.h>
|
||||
# include <signal.h>
|
||||
# include <dirent.h>
|
||||
|
||||
int g_var;
|
||||
# include <readline/readline.h>
|
||||
# include <readline/history.h>
|
||||
|
||||
// Command Data Structure
|
||||
|
||||
@ -48,6 +48,8 @@ typedef struct s_simple {
|
||||
char *cmd;
|
||||
} t_s_cmd;
|
||||
|
||||
int g_var;
|
||||
|
||||
// Describes a complete command with the multiple pipes if any
|
||||
// and input/output redirection if any.
|
||||
typedef struct s_command {
|
||||
|
||||
@ -3,10 +3,10 @@
|
||||
/* ::: :::::::: */
|
||||
/* cd.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: sadjigui <sadjigui@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/03/21 18:30:26 by sadjigui #+# #+# */
|
||||
/* Updated: 2022/04/20 16:09:32 by sadjigui ### ########.fr */
|
||||
/* Updated: 2022/04/23 13:10:35 by apommier ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -15,11 +15,10 @@
|
||||
void add_one(t_s_cmd *cmd)
|
||||
{
|
||||
char p[1024];
|
||||
char *str;
|
||||
int i;
|
||||
|
||||
i = find_it(cmd->big_cmd->env, "PWD");
|
||||
str = getcwd(p, sizeof(p));
|
||||
getcwd(p, sizeof(p));
|
||||
free(cmd->big_cmd->env[i]);
|
||||
cmd->big_cmd->env[i] = ft_strjoin("PWD=", p);
|
||||
}
|
||||
@ -87,13 +86,10 @@ int check_dir(t_s_cmd *cmd)
|
||||
int open_directory(t_s_cmd *cmd)
|
||||
{
|
||||
char *p;
|
||||
int j;
|
||||
int i;
|
||||
|
||||
p = NULL;
|
||||
i = 0;
|
||||
if (find_it(cmd->big_cmd->env, "PWD") != -1)
|
||||
j = size_path(cmd->big_cmd->env);
|
||||
if (cmd->nb_args > 2)
|
||||
return (cd_error(cmd, "Minishell: cd: too many arguments", 1));
|
||||
if (!cmd->args[1])
|
||||
|
||||
@ -3,10 +3,10 @@
|
||||
/* ::: :::::::: */
|
||||
/* unset.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: sadjigui <sadjigui@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/03/11 18:26:29 by sadjigui #+# #+# */
|
||||
/* Updated: 2022/04/20 15:01:03 by sadjigui ### ########.fr */
|
||||
/* Updated: 2022/04/23 13:09:17 by apommier ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -42,10 +42,8 @@ void unset_variable(t_s_cmd *cmd, int i)
|
||||
int find_variable(char *variable, t_s_cmd *cmd)
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
|
||||
i = find_it(cmd->big_cmd->env, variable);
|
||||
j = 0;
|
||||
if (check_variable(variable) == 1)
|
||||
{
|
||||
ft_putstr_fd("Minishell: unset: `", 2);
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/03/06 13:27:11 by apommier #+# #+# */
|
||||
/* Updated: 2022/04/22 11:43:15 by apommier ### ########.fr */
|
||||
/* Updated: 2022/04/23 13:16:15 by apommier ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -73,6 +73,7 @@ int main(int ac, char **av, char **path)
|
||||
{
|
||||
char **env;
|
||||
|
||||
(void)av;
|
||||
if (!isatty(0))
|
||||
{
|
||||
printf("Not today\n");
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/03/09 12:33:30 by apommier #+# #+# */
|
||||
/* Updated: 2022/04/22 11:24:40 by apommier ### ########.fr */
|
||||
/* Updated: 2022/04/23 13:18:23 by apommier ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -14,9 +14,6 @@
|
||||
|
||||
void exit_shell(t_cmd *cmd, int ret)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
ft_putstr_fd("exit\n", 1);
|
||||
close (0);
|
||||
close (1);
|
||||
@ -32,7 +29,6 @@ void exit_shell(t_cmd *cmd, int ret)
|
||||
close(cmd->current_s_cmd->fd[1]);
|
||||
free_cmd(cmd);
|
||||
rl_clear_history();
|
||||
clear_history();
|
||||
cmd = 0;
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/03/08 15:19:42 by apommier #+# #+# */
|
||||
/* Updated: 2022/04/22 11:50:17 by apommier ### ########.fr */
|
||||
/* Updated: 2022/04/23 13:07:57 by apommier ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -16,9 +16,7 @@ t_s_cmd *set_s_cmd(char *line, int index)
|
||||
{
|
||||
t_s_cmd *s_cmd;
|
||||
char **split_line;
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
s_cmd = malloc(sizeof(t_s_cmd));
|
||||
if (!s_cmd)
|
||||
return (0);
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/04/09 23:58:21 by apommier #+# #+# */
|
||||
/* Updated: 2022/04/19 17:19:17 by apommier ### ########.fr */
|
||||
/* Updated: 2022/04/23 13:11:50 by apommier ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -85,17 +85,13 @@ int parse_quote(t_cmd *cmd)
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
char *swap;
|
||||
|
||||
i = -1;
|
||||
while (cmd->s_cmds[++i])
|
||||
{
|
||||
j = -1;
|
||||
while (cmd->s_cmds[i]->args[++j])
|
||||
{
|
||||
swap = cmd->s_cmds[i]->args[j];
|
||||
cmd->s_cmds[i]->args[j] = set_var(cmd, cmd->s_cmds[i]->args[j]);
|
||||
}
|
||||
if (!is_builtin(cmd->s_cmds[i]->args[0]))
|
||||
{
|
||||
cmd->s_cmds[i]->cmd = get_command(cmd->s_cmds[i]->args, cmd->path);
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/04/10 19:50:50 by apommier #+# #+# */
|
||||
/* Updated: 2022/04/19 16:15:11 by apommier ### ########.fr */
|
||||
/* Updated: 2022/04/23 13:11:27 by apommier ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -31,7 +31,7 @@ int next_quote(const char *s, int i)
|
||||
while (s[i] != '\'')
|
||||
i++;
|
||||
}
|
||||
else
|
||||
else if (double_quote)
|
||||
{
|
||||
while (s[i] != '"')
|
||||
i++;
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/04/19 14:46:01 by apommier #+# #+# */
|
||||
/* Updated: 2022/04/22 11:24:15 by apommier ### ########.fr */
|
||||
/* Updated: 2022/04/23 13:08:11 by apommier ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -17,9 +17,7 @@ char *set_heredoc(int index, char **in)
|
||||
char *nbr_file;
|
||||
char *file_name;
|
||||
int fd;
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
if (index)
|
||||
{
|
||||
nbr_file = ft_itoa(index + 1);
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/04/19 14:44:22 by apommier #+# #+# */
|
||||
/* Updated: 2022/04/22 11:43:15 by apommier ### ########.fr */
|
||||
/* Updated: 2022/04/23 13:08:35 by apommier ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -32,13 +32,10 @@ int check_access_input(t_s_cmd *cmd)
|
||||
char *set_input(char *line, t_s_cmd *cmd, int index)
|
||||
{
|
||||
int i;
|
||||
int word_index;
|
||||
|
||||
word_index = 0;
|
||||
i = index + 1;
|
||||
if (line[i] == '<')
|
||||
i++;
|
||||
word_index = i;
|
||||
while (line[i] == ' ' && line[i])
|
||||
i++;
|
||||
while ((line[i] != ' ' && line[i] != '<' && line[i] != '>') && line[i])
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/04/19 14:45:10 by apommier #+# #+# */
|
||||
/* Updated: 2022/04/22 13:02:24 by apommier ### ########.fr */
|
||||
/* Updated: 2022/04/23 13:08:53 by apommier ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -53,14 +53,11 @@ int check_access_output(t_s_cmd *cmd)
|
||||
char *set_output(char *line, t_s_cmd *cmd, int index)
|
||||
{
|
||||
int i;
|
||||
int word_index;
|
||||
|
||||
word_index = 0;
|
||||
i = index;
|
||||
i++;
|
||||
if (line[i] == '>')
|
||||
i++;
|
||||
word_index = i;
|
||||
while (line[i] == ' ' && line[i])
|
||||
i++;
|
||||
while ((line[i] != ' ' && line[i] != '<' && line[i] != '>') && line[i])
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/04/19 15:30:30 by apommier #+# #+# */
|
||||
/* Updated: 2022/04/22 11:43:15 by apommier ### ########.fr */
|
||||
/* Updated: 2022/04/23 13:12:16 by apommier ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
|
||||
void crtl_c(int num)
|
||||
{
|
||||
num = 0;
|
||||
(void)num;
|
||||
g_var = 130;
|
||||
printf("\n");
|
||||
rl_replace_line("", 0);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user