error_msg and soem norm
This commit is contained in:
parent
b4bb4c900e
commit
74bc47171f
53
sources.mk
53
sources.mk
@ -1,26 +1,27 @@
|
||||
VPATH = src:src/parser:src/environment:src/lexer:src/redirect:src/debug:src/token:src/signal:src/prompt:src/utils:src/expander:src/executor:src/builtin:
|
||||
SOURCES = parser_validate_command.c parser_get_arguments.c \
|
||||
parser_alloc_command.c parser_create_command.c parser_get_commands.c \
|
||||
environment_get.c environment_get_arr.c environment_free_list.c \
|
||||
environment_add.c environment_print.c environment_del.c \
|
||||
environment_free.c environment_parse.c lexer_new.c lexer_read_word.c \
|
||||
lexer_read_char.c lexer_parse_input.c lexer_parse_quotes.c \
|
||||
lexer_token_next.c redirect_get_inputs.c redirect_get_outputs.c \
|
||||
redirect_new.c redirect_valid_type.c redirect_new_error.c \
|
||||
redirect_process_heredoc.c print_freelist.c print_commands.c main.c \
|
||||
token_new.c token_char_convert.c token_parse.c token_type_convert.c \
|
||||
signal_init.c.c signal.c history_write.c prompt.c history_load.c \
|
||||
free_command_list.c free_minishell.c ft_lstnew_safe.c free_safe.c \
|
||||
free_lexer.c ft_free_arr_safe.c print_banner.c check_malloc.c \
|
||||
free_freelist.c ft_lstclear_safe.c ft_split_safe.c error_msg.c \
|
||||
free_token_list.c malloc_safe.c free_minishell_line.c \
|
||||
ft_strdup_safe.c free_token.c ft_substr_safe.c init_minishell.c \
|
||||
ft_strjoin_safe.c expander_allocate_memory.c expander_parse_string.c \
|
||||
expander_parse_variables.c expander_expand_dollar.c \
|
||||
expander_is_character.c expander_get_variable.c executor_open_fds.c \
|
||||
executor_count_fds.c executor_fork.c executor_absolute_path.c \
|
||||
executor_execute_pipeline.c executor_child.c executor_close_fds.c \
|
||||
executor_create_redirects.c executor_create_pipes.c builtin_export.c \
|
||||
simple_builtins.c builtin_router.c is_builtin.c builtin_unset.c \
|
||||
builtin_env.c builtin_cd.c builtin_pwd.c builtin_exit.c \
|
||||
builtin_echo.c \
|
||||
VPATH = src:src/prompt:src/utils:src/lexer:src/token:src/environment:src/executor:src/parser:src/signal:src/debug:src/expander:src/builtin:src/redirect:
|
||||
SOURCES = history_write.c history_load.c prompt.c check_malloc.c \
|
||||
free_command_list.c free_freelist.c free_lexer.c free_safe.c \
|
||||
free_token.c free_token_list.c ft_lstclear_safe.c ft_lstnew_safe.c \
|
||||
ft_strdup_safe.c ft_strjoin_safe.c malloc_safe.c \
|
||||
free_minishell_line.c ft_substr_safe.c error_msg.c ft_split_safe.c \
|
||||
init_minishell.c print_banner.c ft_free_arr_safe.c free_minishell.c \
|
||||
lexer_read_char.c lexer_new.c lexer_parse_input.c \
|
||||
lexer_parse_quotes.c lexer_read_word.c lexer_token_next.c token_new.c \
|
||||
token_char_convert.c token_parse.c token_type_convert.c \
|
||||
environment_del.c environment_free.c environment_get.c \
|
||||
environment_get_arr.c environment_free_list.c environment_parse.c \
|
||||
environment_print.c environment_add.c executor_close_fds.c \
|
||||
executor_open_fds.c executor_count_fds.c executor_create_pipes.c \
|
||||
executor_create_redirects.c executor_execute_pipeline.c \
|
||||
executor_fork.c executor_absolute_path.c executor_child.c \
|
||||
parser_alloc_command.c parser_create_command.c parser_get_arguments.c \
|
||||
parser_get_commands.c parser_validate_command.c signal.c \
|
||||
signal_init.c.c print_commands.c print_freelist.c \
|
||||
expander_expand_dollar.c expander_is_character.c \
|
||||
expander_parse_variables.c expander_get_variable.c \
|
||||
expander_allocate_memory.c expander_parse_string.c is_builtin.c \
|
||||
builtin_echo.c builtin_env.c builtin_router.c builtin_unset.c \
|
||||
simple_builtins.c builtin_cd.c builtin_exit.c builtin_export.c \
|
||||
builtin_pwd.c redirect_process_heredoc.c redirect_get_inputs.c \
|
||||
redirect_get_outputs.c redirect_new.c redirect_new_error.c \
|
||||
redirect_valid_type.c main.c \
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: qmennen <qmennen@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2025/02/20 11:32:59 by whaffman #+# #+# */
|
||||
/* Updated: 2025/03/01 12:54:28 by whaffman ######## odam.nl */
|
||||
/* Updated: 2025/03/03 14:08:02 by whaffman ######## odam.nl */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -37,7 +37,7 @@ int builtin_exit(t_minishell *msh, t_command *cmd)
|
||||
exit_status = ft_atoi(cmd->args[1]);
|
||||
}
|
||||
free_minishell(&msh);
|
||||
ft_putendl_fd("exit", STDERR_FILENO); //TODO stderr?
|
||||
ft_putendl_fd("exit", STDERR_FILENO);
|
||||
rl_clear_history();
|
||||
exit(exit_status);
|
||||
return (FAILURE);
|
||||
|
||||
33
src/main.c
33
src/main.c
@ -6,42 +6,11 @@
|
||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2025/02/04 16:19:22 by whaffman #+# #+# */
|
||||
/* Updated: 2025/03/02 22:11:40 by whaffman ######## odam.nl */
|
||||
/* Updated: 2025/03/03 14:25:02 by whaffman ######## odam.nl */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
#include "minishell.h"
|
||||
#include "utils.h"
|
||||
|
||||
// int main(int argc, char **argv, char **envp)
|
||||
// {
|
||||
// t_minishell *msh;
|
||||
|
||||
// (void)argc;
|
||||
// (void)argv;
|
||||
// print_banner();
|
||||
// history_load();
|
||||
// msh = init_minishell();
|
||||
// signal_init_minishell();
|
||||
// environment_parse(msh, envp);
|
||||
// while (TRUE)
|
||||
// {
|
||||
// msh->line = ft_prompt(msh);
|
||||
// if (msh->line == NULL)
|
||||
// break ;
|
||||
// msh->lexer = ft_lexer_new(msh);
|
||||
// msh->tokens = ft_parse_input(msh);
|
||||
// ft_lstiter(msh->tokens, token_print);
|
||||
// msh->commands = parser_get_commands(msh);
|
||||
// simple_builtins(msh);
|
||||
// free_minishell_line(msh);
|
||||
// }
|
||||
// ft_lstclear_safe(msh, &msh->commands, free_command_list);
|
||||
// free_minishell(&msh);
|
||||
// rl_clear_history();
|
||||
// return (EXIT_SUCCESS);
|
||||
// }
|
||||
|
||||
static void main_loop(t_minishell *msh)
|
||||
{
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2025/02/20 17:03:13 by whaffman #+# #+# */
|
||||
/* Updated: 2025/03/01 14:11:16 by whaffman ######## odam.nl */
|
||||
/* Updated: 2025/03/03 14:13:34 by whaffman ######## odam.nl */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -15,20 +15,28 @@
|
||||
|
||||
void error_msg(char *func, char *msg)
|
||||
{
|
||||
if (errno)
|
||||
if (func == NULL && msg == NULL && errno)
|
||||
{
|
||||
perror(RED BOLD SHELL_NAME RESET);
|
||||
errno = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ft_putstr_fd(RED BOLD SHELL_NAME RESET ": ", 2);
|
||||
ft_putstr_fd(RED BOLD SHELL_NAME RESET ": ", STDERR_FILENO);
|
||||
if (func != NULL)
|
||||
{
|
||||
ft_putstr_fd(func, 2);
|
||||
ft_putstr_fd(": ", 2);
|
||||
ft_putstr_fd(func, STDERR_FILENO);
|
||||
ft_putstr_fd(": ", STDERR_FILENO);
|
||||
}
|
||||
if (msg != NULL)
|
||||
ft_putstr_fd(msg, 2);
|
||||
ft_putstr_fd(msg, STDERR_FILENO);
|
||||
else
|
||||
ft_putstr_fd("general error", 2);
|
||||
ft_putstr_fd("\n", 2);
|
||||
ft_putstr_fd("general error", STDERR_FILENO);
|
||||
ft_putstr_fd("\n", STDERR_FILENO);
|
||||
if(DEBUG && errno)
|
||||
{
|
||||
perror(RED BOLD "DEBUG " SHELL_NAME RESET);
|
||||
errno = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user