merge
This commit is contained in:
commit
88598b049a
37 changed files with 282 additions and 247 deletions
|
|
@ -6,14 +6,14 @@
|
|||
# By: wescande <wescande@student.42.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2016/08/29 21:32:58 by wescande #+# #+# #
|
||||
# Updated: 2017/03/19 15:14:11 by gwojda ### ########.fr #
|
||||
# Updated: 2017/03/20 12:04:31 by wescande ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
NAME = 42sh
|
||||
|
||||
CC = gcc
|
||||
FLAGS = -Wall -Wextra -Werror -g
|
||||
FLAGS = -Wall -Wextra -Werror -fvisibility=hidden
|
||||
D_FLAGS = -g
|
||||
|
||||
DELTA = $$(echo "$$(tput cols)-47"|bc)
|
||||
|
|
@ -40,6 +40,7 @@ builtin/builtin_hash.c\
|
|||
builtin/builtin_history.c\
|
||||
builtin/builtin_math.c\
|
||||
builtin/builtin_read.c\
|
||||
builtin/builtin_return_status.c\
|
||||
builtin/builtin_setenv.c\
|
||||
builtin/builtin_unset.c\
|
||||
builtin/builtin_unsetenv.c\
|
||||
|
|
@ -302,7 +303,8 @@ NB = $(words $(SRC_BASE))
|
|||
INDEX = 0
|
||||
|
||||
all :
|
||||
@make $(NAME)
|
||||
@make -C $(LIBFT_DIR)
|
||||
@make -j $(NAME)
|
||||
|
||||
$(NAME): $(LIBFT_LIB) $(OBJ_DIR) $(OBJS)
|
||||
@$(CC) $(OBJS) -o $(NAME) \
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/14 22:59:57 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/17 18:59:55 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/20 12:51:23 by wescande ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -20,6 +20,7 @@
|
|||
# define BT_EXPORT_LP (1 << 0)
|
||||
|
||||
t_execf *is_builtin(t_process *p);
|
||||
int builtin_return_status(int ret, int status);
|
||||
int builtin_export(const char *path, char *const av[], char *const envp[]);
|
||||
int builtin_unset(const char *path, char *const av[], char *const envp[]);
|
||||
int builtin_env(const char *path, char *const argv[], char *const envp[]);
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
/* ::: :::::::: */
|
||||
/* builtin_read.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/20 15:02:39 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/15 19:13:26 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/20 15:34:47 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -40,7 +40,8 @@ struct s_read
|
|||
char *input;
|
||||
};
|
||||
|
||||
int builtin_read(const char *path, char *const av[], char *const envp[]);
|
||||
int builtin_read(const char *path, char *const av[],
|
||||
char *const envp[]);
|
||||
|
||||
int bt_read_init(t_read *data, char **av);
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/27 20:29:56 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/20 14:05:18 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/20 15:34:20 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -140,6 +140,7 @@ struct s_exec
|
|||
};
|
||||
|
||||
int exec_reset(void);
|
||||
int do_the_muther_forker(t_process *p);
|
||||
int process_setgroup(t_process *p, pid_t pid);
|
||||
void process_setsig(void);
|
||||
void process_reset(t_process *p);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: sbenning <sbenning@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/08 16:34:51 by sbenning #+# #+# */
|
||||
/* Updated: 2017/03/15 18:47:56 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/20 12:33:06 by gwojda ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/23 10:35:44 by gwojda #+# #+# */
|
||||
/* Updated: 2017/03/17 17:24:03 by gwojda ### ########.fr */
|
||||
/* Updated: 2017/03/20 12:32:15 by gwojda ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -57,9 +57,6 @@
|
|||
|
||||
# define CORRUPT 1
|
||||
|
||||
//# define STR data_singleton()->line.input
|
||||
//# define POS data_singleton()->line.pos
|
||||
|
||||
# define ERROR_CNTL_R 1
|
||||
|
||||
typedef struct s_list_history
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/01 12:15:50 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/20 15:10:24 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/20 15:34:41 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -61,9 +61,6 @@ struct s_rvwords
|
|||
int type;
|
||||
};
|
||||
|
||||
/* extern t_rvwords g_rvwords[]; */
|
||||
/* extern int (*g_lexer[])(t_list **alst, t_lexer *lexer); */
|
||||
|
||||
int ft_post_tokenize(t_list **alst, char **str);
|
||||
|
||||
t_token *token_init();
|
||||
|
|
@ -79,7 +76,8 @@ void token_print(t_list *lst);
|
|||
|
||||
int reduce_parens(t_list **alst, char *str);
|
||||
int bquotes_expand(t_list **alst);
|
||||
char *command_getoutput(char *command, char *const av[], char **env, int pipe_mode);
|
||||
char *command_getoutput(char *command);
|
||||
int command_setoutput(char *const av[], char **env);
|
||||
|
||||
int ft_is_delim(char c);
|
||||
int ft_is_delim_list(char c);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
# By: jhalford <jack@crans.org> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2017/02/07 16:09:36 by jhalford #+# #+# #
|
||||
# Updated: 2017/03/18 14:15:35 by gwojda ### ########.fr #
|
||||
# Updated: 2017/03/20 12:05:06 by wescande ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
|
|
@ -207,7 +207,7 @@ all:
|
|||
$(NAME): $(OBJ_DIR) $(OBJS)
|
||||
@$(AR) $(NAME) $(OBJS)
|
||||
@ranlib $(NAME)
|
||||
@strip -x $(NAME)
|
||||
@# @strip -x $(NAME)
|
||||
@printf "\r\033[48;5;15;38;5;25m✅ MAKE $(NAME)\033[0m\033[K\n"
|
||||
|
||||
$(OBJ_DIR)%.o: $(SRC_DIR)%.c | $(OBJ_DIR)
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
/* ::: :::::::: */
|
||||
/* bt_read_term.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/25 16:02:05 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/15 21:23:41 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/20 14:23:46 by gwojda ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/03 11:57:53 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/16 14:17:57 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/20 12:54:02 by wescande ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -81,14 +81,14 @@ int builtin_cd(const char *path,
|
|||
opts = CDOPT_L;
|
||||
i = builtin_cd_opts(av, &opts);
|
||||
if (!(target = builtin_cd_special(av + i, envp)))
|
||||
return (1);
|
||||
return (builtin_return_status(0, 1));
|
||||
cwd = getcwd(NULL, 0);
|
||||
builtin_setenv(path, (char*[4]){"setenv", "OLDPWD", cwd, NULL}, envp);
|
||||
free(cwd);
|
||||
if (chdir(target))
|
||||
{
|
||||
ft_dprintf(2, CDERR_1, target);
|
||||
return (1);
|
||||
return (builtin_return_status(0, 1));
|
||||
}
|
||||
else if (target != av[i])
|
||||
ft_printf("%s\n", target);
|
||||
|
|
@ -97,5 +97,5 @@ int builtin_cd(const char *path,
|
|||
free(cwd);
|
||||
if (!ft_strcmp(*(av + i), "-"))
|
||||
free(target);
|
||||
return (0);
|
||||
return (builtin_return_status(0, 0));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/28 14:21:41 by jhalford #+# #+# */
|
||||
/* Updated: 2017/01/20 00:10:31 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/20 14:40:00 by wescande ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -25,5 +25,5 @@ int builtin_echo(const char *path, char *const av[], char *const envp[])
|
|||
ft_putchar(' ');
|
||||
}
|
||||
ft_putchar('\n');
|
||||
return (0);
|
||||
return (builtin_return_status(0, 0));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,11 +6,12 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/28 14:14:20 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/19 17:43:24 by wescande ### ########.fr */
|
||||
/* Updated: 2017/03/20 15:02:31 by wescande ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
#define US_ENV "env [-i] [-u name] [name=value]... [utility [argument...]]"
|
||||
|
||||
static int env_usage(int arg_miss, char c)
|
||||
{
|
||||
|
|
@ -18,7 +19,7 @@ static int env_usage(int arg_miss, char c)
|
|||
ft_dprintf(2, "{red}env: option requires an argument -- u{eoc}\n");
|
||||
else if (c)
|
||||
ft_dprintf(2, "{red}env: illegal option -- %c{eoc}\n", c);
|
||||
ft_dprintf(2, "usage: env [-i] [-u name] ... [name=value] ... cmd\n");
|
||||
ft_dprintf(2, "usage: %s\n", US_ENV);
|
||||
return (1);
|
||||
}
|
||||
|
||||
|
|
@ -86,18 +87,21 @@ static int env_treat_flag(char ***custom_env, char *const *arg[])
|
|||
return (0);
|
||||
}
|
||||
|
||||
int builtin_env(const char *path, char *const argv[], char *const envp[])
|
||||
int builtin_env(const char *path,
|
||||
char *const argv[], char *const envp[])
|
||||
{
|
||||
char **env;
|
||||
pid_t pid;
|
||||
|
||||
(void)path;
|
||||
pid = 0;
|
||||
if (!argv || ft_strcmp(*argv, "env"))
|
||||
return (env_usage(0, 0));
|
||||
return (builtin_return_status(0, env_usage(0, 0)));
|
||||
env = ft_sstrdup((char **)envp);
|
||||
if (env_treat_flag(&env, &argv))
|
||||
{
|
||||
ft_sstrfree(env);
|
||||
return (1);
|
||||
return (builtin_return_status(0, 1));
|
||||
}
|
||||
if (!*argv)
|
||||
{
|
||||
|
|
@ -106,7 +110,7 @@ int builtin_env(const char *path, char *const argv[], char *const envp[])
|
|||
ft_putchar('\n');
|
||||
}
|
||||
else
|
||||
command_getoutput(NULL, argv, env, 0);
|
||||
pid = command_setoutput(argv, env);
|
||||
ft_tabdel(&env);
|
||||
return (0);
|
||||
return (builtin_return_status(pid, 0));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/28 14:28:41 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/20 11:37:51 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/20 14:17:40 by gwojda ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -30,10 +30,8 @@ int builtin_exit(const char *path, char *const av[], char *const envp[])
|
|||
data_singleton()->argv[0]);
|
||||
return (0);
|
||||
}
|
||||
if (av && av[1])
|
||||
status = ft_atoi(av[1]);
|
||||
else
|
||||
status = ft_atoi(ft_getenv(data_singleton()->env, "?"));
|
||||
status = (av && av[1]) ?
|
||||
ft_atoi(av[1]) : ft_atoi(ft_getenv(data_singleton()->env, "?"));
|
||||
if (SH_IS_INTERACTIVE(data_singleton()->opts))
|
||||
tcsetattr(STDIN, TCSANOW, &data_singleton()->jobc.shell_tmodes);
|
||||
job_hup_all();
|
||||
|
|
|
|||
|
|
@ -6,13 +6,13 @@
|
|||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/02/15 11:39:37 by gwojda #+# #+# */
|
||||
/* Updated: 2017/03/18 11:46:32 by gwojda ### ########.fr */
|
||||
/* Updated: 2017/03/20 14:44:02 by wescande ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
static t_cliopts export_opts[] =
|
||||
static t_cliopts g_export_opts[] =
|
||||
{
|
||||
{'p', NULL, BT_EXPORT_LP, 0, NULL},
|
||||
{0, NULL, 0, 0, NULL},
|
||||
|
|
@ -44,25 +44,22 @@ int builtin_export(
|
|||
(void)envp;
|
||||
(void)path;
|
||||
data.flag = 0;
|
||||
if (cliopts_get((char**)av, export_opts, &data))
|
||||
if (cliopts_get((char**)av, g_export_opts, &data))
|
||||
ft_perror();
|
||||
if (data.flag & BT_EXPORT_LP)
|
||||
return (bt_export_print());
|
||||
return (builtin_return_status(0, bt_export_print()));
|
||||
av = data.av_data;
|
||||
while (*av)
|
||||
{
|
||||
if ((equal = ft_strchr(*av, '=')))
|
||||
{
|
||||
equal = ft_strchr(*av, '=');
|
||||
if (equal)
|
||||
*equal = 0;
|
||||
builtin_setenv("internal", (char*[]){"global", *av, equal + 1}, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
equal = ft_getenv(data_singleton()->local_var, *av);
|
||||
equal ? equal++ : equal;
|
||||
builtin_setenv("internal", (char*[]){"global", *av, equal}, NULL);
|
||||
}
|
||||
builtin_unsetenv("internal", (char*[]){"local", *av, NULL}, NULL);
|
||||
av++;
|
||||
}
|
||||
return (0);
|
||||
return (builtin_return_status(0, 0));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/02/18 16:37:43 by gwojda #+# #+# */
|
||||
/* Updated: 2017/02/18 16:51:43 by gwojda ### ########.fr */
|
||||
/* Updated: 2017/03/20 14:03:30 by wescande ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -43,8 +43,8 @@ int builtin_hash(const char *path, char *const av[], char *const envp[])
|
|||
|
||||
(void)path;
|
||||
(void)envp;
|
||||
if (ft_hash_opt(av))
|
||||
return (0);
|
||||
if (!av || ft_hash_opt(av))
|
||||
return (builtin_return_status(0, 1));
|
||||
i = 0;
|
||||
while (i < MAX_HASH)
|
||||
{
|
||||
|
|
@ -52,5 +52,5 @@ int builtin_hash(const char *path, char *const av[], char *const envp[])
|
|||
ft_hash_lst_print(g_hash[i]);
|
||||
++i;
|
||||
}
|
||||
return (0);
|
||||
return (builtin_return_status(0, 0));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/24 14:54:53 by gwojda #+# #+# */
|
||||
/* Updated: 2017/02/20 20:30:18 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/20 14:04:02 by wescande ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ int builtin_history(const char *path, char *const av[], char *const envp[])
|
|||
head = data_singleton()->line.list_end;
|
||||
len = 1;
|
||||
if (!head)
|
||||
return (0);
|
||||
return (builtin_return_status(0, 0));
|
||||
if (head && !head->str)
|
||||
head = head->next;
|
||||
while (head && head->str)
|
||||
|
|
@ -34,5 +34,5 @@ int builtin_history(const char *path, char *const av[], char *const envp[])
|
|||
++len;
|
||||
head = head->next;
|
||||
}
|
||||
return (0);
|
||||
return (builtin_return_status(0, 0));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/17 18:54:00 by ariard #+# #+# */
|
||||
/* Updated: 2017/03/17 19:59:42 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/20 14:45:09 by wescande ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
static int error_msg(char *msg)
|
||||
{
|
||||
ft_dprintf(2, "{red}%s{eoc}", msg);
|
||||
return (-1);
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int init_math(char **var, char **value, char **operator,
|
||||
|
|
@ -96,20 +96,19 @@ int builtin_math(const char *path, char *const av[], char *const envp[])
|
|||
(void)path;
|
||||
(void)envp;
|
||||
if (!av || !av[1] || !av[2] || !av[3] || av[4])
|
||||
return (error_msg(MATHERR_0));
|
||||
return (builtin_return_status(0, error_msg(MATHERR_0)));
|
||||
init_math(&var, &value, &operator, &operand);
|
||||
var = av[1];
|
||||
if (get_value(var, &value) == -1)
|
||||
return (-1);
|
||||
if (get_value(var, &value))
|
||||
return (builtin_return_status(0, 1));
|
||||
operator = av[2];
|
||||
if (!(ft_strlen(operator) == 1 && (operator[0] == '+' || operator[0] == '-'
|
||||
|| operator[0] == '/' || operator[0] == '*' || operator[0] == '%')))
|
||||
return (error_msg(MATHERR_2));
|
||||
if (ft_strlen(operator) != 1 || !(ft_strchr("+-/*%", operator[0])))
|
||||
return (builtin_return_status(0, error_msg(MATHERR_2)));
|
||||
operand = av[3];
|
||||
if (!ft_stris(operand, &ft_isdigit))
|
||||
return (error_msg(MATHERR_3));
|
||||
if (do_math(&value, operator, operand) == -1)
|
||||
return (-1);
|
||||
builtin_setenv("setenv", (char *[]){"local", var, value, 0}, data_singleton()->local_var);
|
||||
return (0);
|
||||
return (builtin_return_status(0, error_msg(MATHERR_3)));
|
||||
if (do_math(&value, operator, operand))
|
||||
return (builtin_return_status(0, 1));
|
||||
builtin_setenv("setenv", (char *[]){"local", var, value, 0}, NULL);
|
||||
return (builtin_return_status(0, 0));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,14 +3,16 @@
|
|||
/* ::: :::::::: */
|
||||
/* builtin_read.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/20 15:01:45 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/20 12:41:43 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/20 15:34:56 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
#define US_READ "read [-ers] [-u fd] [-t timeout] [-p prompt]"
|
||||
#define US_READ_1 "[-n nchars] [-d delim] [name ...]"
|
||||
|
||||
t_cliopts g_read_opts[] =
|
||||
{
|
||||
|
|
@ -26,8 +28,7 @@ t_cliopts g_read_opts[] =
|
|||
|
||||
void bt_read_usage(void)
|
||||
{
|
||||
ft_dprintf(2, "{red}read: usage: read [-ers] [-u fd] [-t timeout]");
|
||||
ft_dprintf(2, " [-p prompt] [-n nchars] [-d delim] [name ...]{eoc}\n");
|
||||
ft_dprintf(2, "usage: read %s %s\n", US_READ, US_READ_1);
|
||||
}
|
||||
|
||||
int bt_read_init(t_read *data, char **av)
|
||||
|
|
@ -117,5 +118,5 @@ int builtin_read(const char *path, char *const av[], char *const envp[])
|
|||
bt_read_usage();
|
||||
if (ret != 2)
|
||||
bt_read_exit(&data);
|
||||
return (ret);
|
||||
return (builtin_return_status(0, ret));
|
||||
}
|
||||
|
|
|
|||
19
42sh/src/builtin/builtin_return_status.c
Normal file
19
42sh/src/builtin/builtin_return_status.c
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* builtin_return_status.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/20 12:48:04 by wescande #+# #+# */
|
||||
/* Updated: 2017/03/20 12:49:18 by wescande ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
int builtin_return_status(int ret, int status)
|
||||
{
|
||||
set_exitstatus(status, 1);
|
||||
return (ret);
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/28 14:25:17 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/20 12:57:59 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/20 15:35:09 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -39,10 +39,9 @@ int builtin_setenv(const char *path,
|
|||
{
|
||||
char ***env;
|
||||
|
||||
(void)envp;
|
||||
(void)path;
|
||||
if (!av || !av[0])
|
||||
return (1);
|
||||
return (builtin_return_status(0, 1));
|
||||
if (ft_strcmp(av[0], "local") == 0)
|
||||
env = &data_singleton()->local_var;
|
||||
else
|
||||
|
|
@ -53,6 +52,6 @@ int builtin_setenv(const char *path,
|
|||
ft_putchar('\n');
|
||||
}
|
||||
else
|
||||
return (assign_var(av, env));
|
||||
return (0);
|
||||
assign_var(av, env);
|
||||
return (envp ? builtin_return_status(0, 0) : 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/02/15 11:43:34 by gwojda #+# #+# */
|
||||
/* Updated: 2017/02/15 11:58:22 by gwojda ### ########.fr */
|
||||
/* Updated: 2017/03/20 14:27:43 by wescande ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -14,5 +14,13 @@
|
|||
|
||||
int builtin_unset(const char *path, char *const av[], char *const envp[])
|
||||
{
|
||||
char *tmp;
|
||||
char **av_tmp;
|
||||
|
||||
tmp = av[0];
|
||||
av_tmp = (char **)av;
|
||||
av_tmp[0] = "local";
|
||||
builtin_unsetenv(path, av, envp);
|
||||
av_tmp[0] = tmp;
|
||||
return (builtin_unsetenv(path, av, envp));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/28 14:29:17 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/18 11:47:53 by gwojda ### ########.fr */
|
||||
/* Updated: 2017/03/20 14:40:05 by wescande ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -35,5 +35,5 @@ int builtin_unsetenv(const char *path, char *const av[], char *const envp[])
|
|||
}
|
||||
i++;
|
||||
}
|
||||
return (0);
|
||||
return (builtin_return_status(0, 0));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/10/15 13:27:14 by alao #+# #+# */
|
||||
/* Updated: 2017/03/19 15:34:38 by gwojda ### ########.fr */
|
||||
/* Updated: 2017/03/20 14:41:04 by gwojda ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -22,7 +22,8 @@ static int c_chevron(t_comp *c)
|
|||
|
||||
pos = c->ircmd;
|
||||
if (pos >= ft_strlen(c->rcmd))
|
||||
pos = ft_strlen(c->rcmd) - (ft_strlen(data_singleton()->line.input) - pos);
|
||||
pos = ft_strlen(c->rcmd) - (ft_strlen(data_singleton()->line.input)
|
||||
- pos);
|
||||
while (pos)
|
||||
{
|
||||
if (c->rcmd[pos] == '<' || c->rcmd[pos] == '>')
|
||||
|
|
|
|||
|
|
@ -6,27 +6,16 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/13 22:21:19 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/20 10:35:14 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/20 14:57:26 by wescande ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
|
||||
int do_the_muther_forker(t_process *p)
|
||||
{
|
||||
pid_t pid;
|
||||
|
||||
if (IS_PIPESINGLE(*p) && p->type != PROCESS_FILE && p->type != PROCESS_SUBSHELL)
|
||||
{
|
||||
if (process_redirect(p))
|
||||
{
|
||||
set_exitstatus(1, 1);
|
||||
return (0);
|
||||
}
|
||||
set_exitstatus(p->map.launch(p), 1);
|
||||
return (0);
|
||||
}
|
||||
if ((pid = fork()) == -1)
|
||||
{
|
||||
ft_dprintf(3, "{red}%s: internal fork error{eoc}\n", SHELL_NAME);
|
||||
|
|
@ -34,6 +23,8 @@ int do_the_muther_forker(t_process *p)
|
|||
}
|
||||
else if (pid)
|
||||
return (pid);
|
||||
if (!p)
|
||||
return (pid);
|
||||
DG("START OF FORK");
|
||||
if (process_redirect(p))
|
||||
exit (1);
|
||||
|
|
@ -45,13 +36,28 @@ int do_the_muther_forker(t_process *p)
|
|||
exit(p->map.launch(p));
|
||||
}
|
||||
|
||||
static int do_the_fork_if_i_have_to(t_process *p)
|
||||
{
|
||||
if (IS_PIPESINGLE(*p)
|
||||
&& p->type != PROCESS_FILE && p->type != PROCESS_SUBSHELL)
|
||||
{
|
||||
if (process_redirect(p))
|
||||
{
|
||||
set_exitstatus(1, 1);
|
||||
return (0);
|
||||
}
|
||||
return (p->map.launch(p));
|
||||
}
|
||||
return (do_the_muther_forker(p));
|
||||
}
|
||||
|
||||
int process_launch(t_process *p)
|
||||
{
|
||||
pid_t pid;
|
||||
|
||||
DG("p->type=%i", p->type);
|
||||
p->state = PROCESS_RUNNING;
|
||||
if (!(pid = do_the_muther_forker(p)))
|
||||
if (!(pid = do_the_fork_if_i_have_to(p)))
|
||||
{
|
||||
DG("launcher did not fork!");
|
||||
process_resetfds(p);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/28 14:25:17 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/20 12:58:31 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/20 15:35:33 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -32,7 +32,6 @@ void set_exitstatus(int status, int override)
|
|||
}
|
||||
}
|
||||
astatus = ft_itoa(exitval);
|
||||
builtin_setenv("setenv", (char*[]){"setenv", "?", astatus, 0},
|
||||
data_singleton()->env);
|
||||
builtin_setenv("setenv", (char*[]){"setenv", "?", astatus, 0}, NULL);
|
||||
ft_strdel(&astatus);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/14 19:44:25 by wescande #+# #+# */
|
||||
/* Updated: 2017/03/19 17:42:45 by wescande ### ########.fr */
|
||||
/* Updated: 2017/03/20 15:10:40 by wescande ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -49,11 +49,12 @@ static char *manage_command(char *const av_cmd[])
|
|||
return (command);
|
||||
}
|
||||
|
||||
static void execute_command(char *command, char *const av[], char **env)
|
||||
static void execute_command(char *const av[], char **env)
|
||||
{
|
||||
t_list *token;
|
||||
t_btree *ast;
|
||||
t_data *data;
|
||||
char *command;
|
||||
|
||||
token = NULL;
|
||||
ast = NULL;
|
||||
|
|
@ -61,7 +62,7 @@ static void execute_command(char *command, char *const av[], char **env)
|
|||
data->env = env;
|
||||
data->opts &= ~SH_INTERACTIVE;
|
||||
data->opts &= ~SH_OPTS_JOBC;
|
||||
command = command ? command : manage_command(av);
|
||||
command = manage_command(av);
|
||||
DG("command is %s", command);
|
||||
if (do_lexer_routine(&token, command))
|
||||
{
|
||||
|
|
@ -78,27 +79,37 @@ static void execute_command(char *command, char *const av[], char **env)
|
|||
exit(data_singleton()->parser.state == SUCCESS && ft_exec(&ast) < 0);
|
||||
}
|
||||
|
||||
char *command_getoutput(char *command, char *const av[], char **env, int pipe_mode)
|
||||
char *command_getoutput(char *command)
|
||||
{
|
||||
int ret;
|
||||
int pid;
|
||||
int fds[2];
|
||||
char **av;
|
||||
|
||||
if (!command && !av)
|
||||
if (!command)
|
||||
return (NULL);
|
||||
if (pipe_mode)
|
||||
pipe(fds);
|
||||
if (!(pid = fork()))
|
||||
{
|
||||
if (pipe_mode)
|
||||
if (!(pid = do_the_muther_forker(NULL)))
|
||||
{
|
||||
close(fds[PIPE_READ]);
|
||||
dup2_close(fds[PIPE_WRITE], STDOUT);
|
||||
}
|
||||
execute_command(command, av, env);
|
||||
av = ft_sstradd(NULL, data_singleton()->argv[0]);
|
||||
av = ft_sstradd(av, "-c");
|
||||
av = ft_sstradd(av, command);
|
||||
execve(data_singleton()->argv[0], av, data_singleton()->env);
|
||||
exit(1);
|
||||
}
|
||||
waitpid(pid, &ret, WUNTRACED);
|
||||
if (pipe_mode)
|
||||
return (manage_output(fds));
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
int command_setoutput(char *const av[], char **env)
|
||||
{
|
||||
int pid;
|
||||
|
||||
if (!av)
|
||||
return (0);
|
||||
if (!(pid = do_the_muther_forker(NULL)))
|
||||
execute_command(av, env);
|
||||
return (pid);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/02/17 17:47:53 by wescande #+# #+# */
|
||||
/* Updated: 2017/03/19 17:33:11 by wescande ### ########.fr */
|
||||
/* Updated: 2017/03/20 15:10:32 by wescande ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ static char *get_output(char *command)
|
|||
char *output;
|
||||
int len;
|
||||
|
||||
if (!(output = command_getoutput(command, NULL, data_singleton()->env, 1)))
|
||||
if (!(output = command_getoutput(command)))
|
||||
return (NULL);
|
||||
len = ft_strlen(output);
|
||||
while (output[--len] == '\n')
|
||||
|
|
@ -80,18 +80,6 @@ static char *get_output(char *command)
|
|||
return (output);
|
||||
}
|
||||
|
||||
static char *treat_str(t_bquote *me, char *sta)
|
||||
{
|
||||
if (sta && *me->str == '\n'
|
||||
&& !is_char_esc(me->esc, CH(*me->wk)[0], me->str))
|
||||
*me->str = ';';
|
||||
if (sta && *me->str == '\n'
|
||||
&& is_char_esc(me->esc, CH(*me->wk)[0], me->str))
|
||||
*me->str = ' ';
|
||||
return (*me->str == '`' && !sta
|
||||
&& !is_char_esc(me->esc2, CH(*me->wk)[0], me->str) ? me->str : sta);
|
||||
}
|
||||
|
||||
static int search_bquote(t_bquote *me)
|
||||
{
|
||||
char *sta;
|
||||
|
|
@ -100,7 +88,8 @@ static int search_bquote(t_bquote *me)
|
|||
sta = NULL;
|
||||
while (*(++me->str))
|
||||
{
|
||||
sta = treat_str(me, sta);
|
||||
sta = *me->str == '`' && !sta
|
||||
&& !is_char_esc(me->esc2, CH(*me->wk)[0], me->str) ? me->str : sta;
|
||||
if (sta && *me->str == '`' && me->str != sta
|
||||
&& !is_char_esc(me->esc2, CH(*me->wk)[0], me->str))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/26 10:43:16 by gwojda #+# #+# */
|
||||
/* Updated: 2017/03/18 14:29:15 by gwojda ### ########.fr */
|
||||
/* Updated: 2017/03/20 14:09:01 by gwojda ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ static void ft_clear_prompt(size_t *pos, size_t srch_pos)
|
|||
ft_puttermcaps("cd");
|
||||
}
|
||||
|
||||
static int ft_surch_and_realloc(char **str, char **str_srch,
|
||||
static int search(char **str, char **str_srch,
|
||||
int ret, size_t *srch_pos)
|
||||
{
|
||||
if (!(*str_srch = ft_realloc_imput(*str_srch, ret, *srch_pos)))
|
||||
|
|
@ -51,7 +51,7 @@ static void ft_give_new_prompt(char *str_srch, size_t srch_pos)
|
|||
}
|
||||
}
|
||||
|
||||
static void ft_modify_str(char *str_srch, size_t srch_pos, char **str,
|
||||
static int ft_modify_str(char *str_srch, size_t srch_pos, char **str,
|
||||
size_t *pos)
|
||||
{
|
||||
ft_clear_prompt(pos, srch_pos);
|
||||
|
|
@ -63,6 +63,7 @@ static void ft_modify_str(char *str_srch, size_t srch_pos, char **str,
|
|||
ft_get_next_str(*str, pos);
|
||||
}
|
||||
free(str_srch);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int ft_surch_in_history(char **str, size_t *pos)
|
||||
|
|
@ -79,8 +80,7 @@ int ft_surch_in_history(char **str, size_t *pos)
|
|||
ft_give_new_prompt(str_srch, srch_pos);
|
||||
ret = 0;
|
||||
read(0, &ret, sizeof(int));
|
||||
if (ft_isprint(ret) &&
|
||||
ft_surch_and_realloc(str, &str_srch, ret, &srch_pos) < 0)
|
||||
if (ft_isprint(ret) && search(str, &str_srch, ret, &srch_pos) < 0)
|
||||
return (-1);
|
||||
else if (!ft_isprint(ret) && ret == 127 && srch_pos)
|
||||
{
|
||||
|
|
@ -92,6 +92,5 @@ int ft_surch_in_history(char **str, size_t *pos)
|
|||
else if (ret != 127 && !ft_isprint(ret))
|
||||
break ;
|
||||
}
|
||||
ft_modify_str(str_srch, srch_pos, str, pos);
|
||||
return (0);
|
||||
return (ft_modify_str(str_srch, srch_pos, str, pos));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
/* ::: :::::::: */
|
||||
/* builtin_fg.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/08 14:30:07 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/20 12:12:16 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/20 14:42:22 by gwojda ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/15 14:19:48 by gwojda #+# #+# */
|
||||
/* Updated: 2017/03/20 09:57:09 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/20 14:49:03 by gwojda ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -19,7 +19,11 @@ int readline(int has_prompt, char **input)
|
|||
if (!has_prompt)
|
||||
data_singleton()->line.prompt_size = 1;
|
||||
if (!SH_IS_INTERACTIVE(data_singleton()->opts))
|
||||
return ((ret = get_next_line(data_singleton()->fd, input)) >= 0 ? !ret : ret);
|
||||
{
|
||||
if ((ret = get_next_line(data_singleton()->fd, input)) >= 0)
|
||||
return (!ret);
|
||||
return (ret);
|
||||
}
|
||||
readline_init(has_prompt);
|
||||
ret = ft_read_stdin(input);
|
||||
if (ret < 0)
|
||||
|
|
@ -30,6 +34,7 @@ int readline(int has_prompt, char **input)
|
|||
ft_putchar('\n');
|
||||
if (has_prompt)
|
||||
ret = ft_history_parsing(has_prompt, input);
|
||||
ft_strdel(&data_singleton()->line.copy_tmp);
|
||||
if (tcsetattr(0, TCSANOW, ft_save_termios(0)) == -1)
|
||||
return (-1);
|
||||
return (ret);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/07 18:07:50 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/18 15:43:07 by gwojda ### ########.fr */
|
||||
/* Updated: 2017/03/20 14:44:51 by gwojda ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -17,7 +17,6 @@ void data_exit(void)
|
|||
t_data *data;
|
||||
|
||||
data = data_singleton();
|
||||
/* ft_strdel(&data->line.input); */
|
||||
ft_sstrfree(data->env);
|
||||
ft_sstrfree(data->local_var);
|
||||
ft_sstrfree(data->argv);
|
||||
|
|
|
|||
|
|
@ -6,13 +6,13 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/10 11:36:39 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/16 15:12:53 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/20 14:45:01 by gwojda ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
t_data *data_singleton()
|
||||
t_data *data_singleton(void)
|
||||
{
|
||||
static t_data *data = NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,9 +3,10 @@
|
|||
/* ::: :::::::: */
|
||||
/* main.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Updated: 2017/03/17 10:51:23 by gwojda ### ########.fr */
|
||||
/* Created: 2017/03/20 14:45:40 by gwojda #+# #+# */
|
||||
/* Updated: 2017/03/20 14:46:44 by gwojda ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/12 17:23:59 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/20 11:30:42 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/20 14:54:28 by gwojda ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -47,7 +47,8 @@ static int get_input_fd(t_data *data)
|
|||
ft_printf("{red}%s: %s: No such file or directory\n{eoc}",
|
||||
data->argv[0], file);
|
||||
else if (S_ISDIR(buf.st_mode))
|
||||
ft_printf("{red}%s: %s: is a directory\n{eoc}", data->argv[0], file);
|
||||
ft_printf("{red}%s: %s: is a directory\n{eoc}", data->argv[0],
|
||||
file);
|
||||
else if ((fds[PIPE_READ] = open(file, O_RDONLY | O_CLOEXEC)) < 0)
|
||||
ft_printf("{red}%s: %s: No such file or directory\n{eoc}",
|
||||
data->argv[0], file);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/02/24 18:41:50 by ariard #+# #+# */
|
||||
/* Updated: 2017/03/18 15:50:28 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/20 14:57:34 by gwojda ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/02/09 15:32:10 by ariard #+# #+# */
|
||||
/* Updated: 2017/03/15 16:33:57 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/20 14:59:23 by gwojda ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -227,7 +227,6 @@ int ft_read_stack(t_sym *stack)
|
|||
return (0);
|
||||
}
|
||||
|
||||
|
||||
int ft_show_heredoc_data(t_astnode *node)
|
||||
{
|
||||
t_redir *redir;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/18 17:13:31 by ariard #+# #+# */
|
||||
/* Updated: 2017/03/18 17:15:11 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/20 14:57:58 by gwojda ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue