fixed some norme

This commit is contained in:
mdev9
2024-03-23 19:26:10 +01:00
parent 19bf6c24ff
commit aed056ae87
12 changed files with 62 additions and 62 deletions

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */ /* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/05 18:20:21 by marde-vr #+# #+# */ /* Created: 2024/03/05 18:20:21 by marde-vr #+# #+# */
/* Updated: 2024/03/23 17:57:20 by tomoron ### ########.fr */ /* Updated: 2024/03/23 19:21:57 by marde-vr ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */ /* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/05 18:22:15 by marde-vr #+# #+# */ /* Created: 2024/03/05 18:22:15 by marde-vr #+# #+# */
/* Updated: 2024/03/22 14:07:57 by tomoron ### ########.fr */ /* Updated: 2024/03/23 19:22:20 by marde-vr ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */ /* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/07 16:04:11 by tomoron #+# #+# */ /* Created: 2024/02/07 16:04:11 by tomoron #+# #+# */
/* Updated: 2024/03/22 13:34:06 by tomoron ### ########.fr */ /* Updated: 2024/03/23 19:20:54 by marde-vr ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -26,7 +26,6 @@ void exit_bt(t_msh *msh)
int exit_code; int exit_code;
int cmd_count; int cmd_count;
cur_cmd = msh->cmds->next; cur_cmd = msh->cmds->next;
ft_printf("exit\n"); ft_printf("exit\n");
if (cur_cmd && cur_cmd->next && cur_cmd->next->type == ARG if (cur_cmd && cur_cmd->next && cur_cmd->next->type == ARG
@ -37,8 +36,7 @@ void exit_bt(t_msh *msh)
} }
else else
{ {
if (cur_cmd && cur_cmd->type == ARG if (cur_cmd && cur_cmd->type == ARG && !ft_strisnbr(cur_cmd->token))
&& !ft_strisnbr(cur_cmd->token))
numeric_arg_err(cur_cmd->token, &exit_code); numeric_arg_err(cur_cmd->token, &exit_code);
else if (cur_cmd && cur_cmd->type == ARG) else if (cur_cmd && cur_cmd->type == ARG)
exit_code = (unsigned char)ft_atoi(cur_cmd->token); exit_code = (unsigned char)ft_atoi(cur_cmd->token);

View File

@ -6,11 +6,12 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */ /* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/18 18:29:20 by marde-vr #+# #+# */ /* Created: 2024/02/18 18:29:20 by marde-vr #+# #+# */
/* Updated: 2024/03/23 19:06:08 by tomoron ### ########.fr */ /* Updated: 2024/03/23 19:22:48 by marde-vr ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "minishell.h" #include "minishell.h"
void print_env_declare(t_env *env) void print_env_declare(t_env *env)
{ {
while (env) while (env)
@ -45,8 +46,8 @@ int ft_export(t_msh *msh)
cmd = msh->cmds; cmd = msh->cmds;
if (cmd && (!cmd->next || (cmd->next && cmd->next->type != ARG))) if (cmd && (!cmd->next || (cmd->next && cmd->next->type != ARG)))
print_env_declare(msh->env); print_env_declare(msh->env);
if(cmd && cmd->next && cmd->next->type == ARG && (!cmd->next->next || if (cmd && cmd->next && cmd->next->type == ARG && (!cmd->next->next
(cmd->next->next && cmd->next->next->type != ARG))) || (cmd->next->next && cmd->next->next->type != ARG)))
{ {
arg = cmd->next->token; arg = cmd->next->token;
len = 0; len = 0;
@ -94,9 +95,9 @@ void delete_from_env(t_env *env, char *name)
*/ */
int ft_unset(t_msh *msh) int ft_unset(t_msh *msh)
{ {
/*
t_cmd *cmd; t_cmd *cmd;
/*
cmd = msh->cmds; cmd = msh->cmds;
tmp_env = msh->env; tmp_env = msh->env;
prev = 0; prev = 0;

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */ /* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/17 02:54:36 by tomoron #+# #+# */ /* Created: 2024/02/17 02:54:36 by tomoron #+# #+# */
/* Updated: 2024/03/23 18:35:04 by tomoron ### ########.fr */ /* Updated: 2024/03/23 19:23:28 by marde-vr ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */ /* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/26 20:20:31 by marde-vr #+# #+# */ /* Created: 2024/02/26 20:20:31 by marde-vr #+# #+# */
/* Updated: 2024/03/23 10:21:07 by marde-vr ### ########.fr */ /* Updated: 2024/03/23 19:23:09 by marde-vr ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -87,6 +87,7 @@ void get_here_doc_input(t_msh *msh, char *eof)
void handle_here_doc(t_msh *msh, char *eof) void handle_here_doc(t_msh *msh, char *eof)
{ {
char *here_doc_file; char *here_doc_file;
int pid;
here_doc_file = get_tmp_file_name(msh); here_doc_file = get_tmp_file_name(msh);
msh->in_fd = open(here_doc_file, O_CREAT | O_RDWR, 0644); msh->in_fd = open(here_doc_file, O_CREAT | O_RDWR, 0644);
@ -98,7 +99,6 @@ void handle_here_doc(t_msh *msh, char *eof)
eof = ft_strjoin_free(eof, "\n", 1); eof = ft_strjoin_free(eof, "\n", 1);
if (!eof) if (!eof)
ft_exit(msh, 1); ft_exit(msh, 1);
/* /*
get_here_doc_input(msh, eof); get_here_doc_input(msh, eof);
close(msh->in_fd); close(msh->in_fd);
@ -109,8 +109,7 @@ void handle_here_doc(t_msh *msh, char *eof)
ft_exit(msh, 1); ft_exit(msh, 1);
} }
}*/ }*/
pid = fork();
int pid = fork();
if (pid == 0) if (pid == 0)
get_here_doc_input(msh, eof); get_here_doc_input(msh, eof);
else else

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */ /* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/02 21:59:20 by tomoron #+# #+# */ /* Created: 2024/02/02 21:59:20 by tomoron #+# #+# */
/* Updated: 2024/03/23 16:38:10 by tomoron ### ########.fr */ /* Updated: 2024/03/23 19:24:40 by marde-vr ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -90,7 +90,8 @@ int main(int argc, char **argv, char **envp)
commands = (char *)1; commands = (char *)1;
init_minishell(&msh, argc, argv, envp); init_minishell(&msh, argc, argv, envp);
msh->aliases = alias_add_back(msh->aliases, ft_strdup("ls"), ft_strdup("ls --color=auto")); msh->aliases = alias_add_back(msh->aliases,
ft_strdup("ls"), ft_strdup("ls --color=auto"));
while (msh->env && commands) while (msh->env && commands)
{ {
prompt = get_prompt(msh->env); prompt = get_prompt(msh->env);

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */ /* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/09 15:26:01 by tomoron #+# #+# */ /* Created: 2024/02/09 15:26:01 by tomoron #+# #+# */
/* Updated: 2024/03/20 18:46:00 by tomoron ### ########.fr */ /* Updated: 2024/03/23 19:23:50 by marde-vr ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "minishell.h" #include "minishell.h"

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */ /* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/21 21:47:15 by marde-vr #+# #+# */ /* Created: 2024/02/21 21:47:15 by marde-vr #+# #+# */
/* Updated: 2024/03/22 15:45:44 by tomoron ### ########.fr */ /* Updated: 2024/03/23 19:24:52 by marde-vr ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */ /* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/05 18:17:25 by marde-vr #+# #+# */ /* Created: 2024/03/05 18:17:25 by marde-vr #+# #+# */
/* Updated: 2024/03/23 17:28:05 by tomoron ### ########.fr */ /* Updated: 2024/03/23 19:25:38 by marde-vr ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -30,6 +30,7 @@ void close_pipe_fds(t_msh *msh, int i)
void execute_command(t_msh *msh, char **cmd_args, int i) void execute_command(t_msh *msh, char **cmd_args, int i)
{ {
char **env; char **env;
if (msh->cmds->token && (!ft_strcmp(msh->cmds->token, "cd") if (msh->cmds->token && (!ft_strcmp(msh->cmds->token, "cd")
|| !ft_strcmp(msh->cmds->token, "alias") || !ft_strcmp(msh->cmds->token, "alias")
|| !ft_strcmp(msh->cmds->token, "unalias") || !ft_strcmp(msh->cmds->token, "unalias")

View File

@ -3,10 +3,10 @@
/* ::: :::::::: */ /* ::: :::::::: */
/* signal_handler.c :+: :+: :+: */ /* signal_handler.c :+: :+: :+: */
/* +:+ +:+ +:+ */ /* +:+ +:+ +:+ */
/* By: tomoron <marvin@42.fr> +#+ +:+ +#+ */ /* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/22 14:31:13 by tomoron #+# #+# */ /* Created: 2024/03/22 14:31:13 by tomoron #+# #+# */
/* Updated: 2024/03/22 19:53:02 by tomoron ### ########.fr */ /* Updated: 2024/03/23 19:21:24 by marde-vr ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@ -6,7 +6,7 @@
/* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */ /* By: marde-vr <marde-vr@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/05 18:19:26 by marde-vr #+# #+# */ /* Created: 2024/03/05 18:19:26 by marde-vr #+# #+# */
/* Updated: 2024/03/23 19:02:06 by tomoron ### ########.fr */ /* Updated: 2024/03/23 19:21:13 by marde-vr ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */