Compare commits

..

57 Commits

Author SHA1 Message Date
bd5e1671fc _ 2023-04-18 14:00:48 +02:00
62e887cfbd _ 2023-04-18 13:30:17 +02:00
3e7dcd1ba9 fix: heredoc work without global 2023-04-17 12:16:41 +00:00
9ab9c06593 Merge remote-tracking branch 'refs/remotes/origin/master' 2023-04-17 10:45:10 +00:00
2f6daa4ce5 fix: signal double prompt 2023-04-17 10:41:54 +00:00
b502364a67 _ 2023-04-14 19:14:31 +02:00
0b56e95868 _ 2023-04-14 16:17:35 +02:00
882a39fc94 Merge branch 'master' of https://git.chauvet.pro/starnakin/42_minishell 2023-04-14 15:54:27 +02:00
59d9ed3514 Enfin 2023-04-14 15:54:13 +02:00
058c96849b fix: signal gestion 2023-04-14 13:05:08 +00:00
37bd3efc98 fix: change sigint to sigdef 2023-04-14 12:41:59 +00:00
425fbd15cd _ 2023-04-14 14:16:09 +02:00
d3fa573054 core: add prototype of ft_split_charset_quoted 2023-04-14 11:53:17 +00:00
227d16ca53 fix: split \t in redirection 2023-04-13 13:26:52 +00:00
91ef62d8f9 core: use charset split 2023-04-11 17:01:19 +00:00
d06eb570fc OUBLIE PAS D'ENLEVER LE MAIN DANS FT_SPLIT_CHARSET.C 2023-04-11 18:49:41 +02:00
1ef3fa115e split 2023-04-11 17:49:02 +02:00
10db23e4ef CAMILLE BOUFON 2023-04-11 17:26:49 +02:00
a6a0293095 fix: ctrl + c is now support in heredoc and in normal mode 2023-04-11 13:03:42 +00:00
a48da783dd etienne fait mois des en fants 2023-04-07 15:17:45 +00:00
be1f7ebf8c clean: norm 2023-04-07 15:12:48 +00:00
e65a9f32c0 Correction 2023-04-07 13:26:05 +02:00
8a2eb85dc6 fix: signal and \t 2023-04-07 11:09:59 +00:00
5d482fc65a fix: signal 2023-04-05 15:35:52 +00:00
e0fb7f1fd0 clean: remove trash file 2023-04-05 14:16:20 +02:00
404fcaa15f fix: heredoc signal 2023-04-05 14:13:56 +02:00
fe535a21f0 fix: no exit when ft_exit return -2 2023-04-05 12:32:34 +02:00
8a245f0dd8 bozo_exit 2023-04-05 12:31:05 +02:00
f93fed5cdd _ 2023-04-05 12:24:20 +02:00
d99aa39070 Merge branch 'master' of https://git.chauvet.pro/starnakin/minishell 2023-04-05 12:21:59 +02:00
f0afd69bf6 ntm 2023-04-05 12:21:46 +02:00
5cbb6f078d fix: put old exit code to ft_exit 2023-04-05 12:20:36 +02:00
b3e9a23f32 _ 2023-04-05 12:17:16 +02:00
b1805834ec Les mendarines Lecler, en vrai ça va, Camille est aigris mais propre, en tout cas hâte Nathan se lève 2023-04-04 22:03:30 +02:00
0d231a062d fix: error messgae 2023-04-04 15:00:19 +02:00
10413e500b fix: old redirection are now closed beforce set new 2023-04-04 14:51:34 +02:00
760b8b644e clean: norm 2023-04-04 13:56:57 +02:00
fdfe1c8b95 fix: redirection file == redirection sign 2023-04-04 13:56:21 +02:00
0bf045d4ab KAN RP SEX CHATGPT SUR 2023-04-04 13:46:32 +02:00
7e0bbd1203 5 schtroumpf noir rencontre la schtroumpfette que se passe t-il? 2023-03-31 20:45:06 +02:00
b96b617e09 fix: leak fd 2023-03-31 18:49:12 +02:00
f6617e07c7 fix: leak fd 2023-03-31 18:48:19 +02:00
a7e75bb163 fix: all fds is now in childreen 2023-03-31 16:36:15 +02:00
d9ae113b94 fix: heredoc fd not closed 2023-03-31 15:32:21 +02:00
88d955fddc fix: heredoc ctrl + d close fd 2023-03-31 15:29:06 +02:00
68c945ae05 clean: norm 2023-03-31 15:25:26 +02:00
8af6b42642 fix: invalid read 'echo sfdsdfsd cchauvet' 2023-03-31 15:23:58 +02:00
46fe9caded fix: heredoc work now 2023-03-31 15:23:10 +02:00
1e00fee53c Merge branch 'master' of https://git.chauvet.pro/starnakin/minishell 2023-03-31 15:04:44 +02:00
4dc8793eec Jour 83: Armand essaye de trouver des bugs sur mes builtins parfait, j'ai envie de lui casser le cul avec ma teube de 32cm mais je me retiens 2023-03-31 15:04:28 +02:00
f66ab7790e fix: 'echo '> >> < * ? [ ] | ; [ ] || && ( ) & # $ <<'' stop segfault now 2023-03-30 16:06:34 +02:00
41bbe2bc0b fix: quote closed verif 2023-03-30 15:43:57 +02:00
3374d21cad Merge branch 'master' of git.chauvet.pro:starnakin/42_minishell 2023-03-30 15:21:54 +02:00
94f55af0be Mon builtins est parfait, tout personne disant l'inverse mérité la pénitence à vie et faire tomber le savon 2023-03-30 15:16:21 +02:00
6f3b1ab918 fix: execve failed 2023-03-30 14:30:13 +02:00
6a81705b98 Merge branch 'master' of https://git.chauvet.pro/starnakin/minishell 2023-03-30 13:56:38 +02:00
27b8874f75 Tient Adrien aufaite comment va ton ptit frère yummi 2023-03-30 13:56:16 +02:00
48 changed files with 502 additions and 520 deletions

View File

@ -1,4 +1,4 @@
UTILS_SRC = utils/ft_is_in_quote.c utils/ft_strncpy.c utils/ft_strreplace.c utils/ft_strnchr.c utils/ft_split_quoted.c utils/ft_strshift.c utils/ft_quote_remover.c utils/ft_str_is_empty.c utils/ft_atoi_check.c ./utils/ft_get_executable.c ./utils/fd.c
UTILS_SRC = utils/ft_is_in_quote.c utils/ft_strncpy.c utils/ft_strreplace.c utils/ft_strnchr.c utils/ft_split_charset_quoted.c utils/ft_strshift.c utils/ft_quote_remover.c utils/ft_str_is_empty.c utils/ft_atoi_check.c ./utils/ft_get_executable.c ./utils/fd.c
BUILTINS_SRC = builtins/pwd.c \
builtins/export.c \

View File

@ -1,40 +0,0 @@
# Minishell
Minishell is a 42 School project that involves creating a minimalistic shell in C language. The shell should be able to handle basic commands, manage environment variables and implement several built-in functions.
## Features
- Prompt management (display, editing, history)
- Command execution (with or without arguments)
- Basic shell operations (pipes, redirections)
- Environment variables management (listing, setting, unsetting)
- Built-in functions management (echo, cd, env, exit, export, pwd, unset)
## Getting started
1. Clone this repository: `git clone https://github.com/<your_username>/minishell.git`
2. `cd` into the cloned directory: `cd minishell`
3. Run the `make` command to compile the program: `make`
4. Start the shell by running the executable: `./minishell`
## Usage
Once the shell is started, you can enter commands as you would with any other shell. The following are some examples of commands that can be executed:
- Display the working directory: `pwd`
- Change directory: `cd <directory_name>`
- Print the value of an environment variable: `echo $<variable_name>`
- Set an environment variable: `export <variable_name>=<value>`
- Unset an environment variable: `unset <variable_name>`
- Display a list of environment variables: `env`
- Exit the shell: `exit`
## Resources
- ![The project subject](./subject.pdf)
- The C library documentation for the standard library functions used in the program
- bash man
## Authors
This project was created by [Camille CHAUVET](mailto:camille@chauvet.pro) and [Xamora](mailto:ogame.xamora@42l.fr). If you have any questions or suggestions, feel free to contact us.

View File

@ -1,17 +1,17 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* minishell.h :+: :+: :+: */
/* bozoshell.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/14 13:45:30 by cchauvet #+# #+# */
/* Updated: 2023/03/28 16:03:54 by cchauvet ### ########.fr */
/* Updated: 2023/04/14 16:16:31 by erey-bet ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MINISHELL_H
# define MINISHELL_H
#ifndef BOZOSHELL_H
# define BOZOSHELL_H
# include "./env/env.h"
# include "./cmd/cmd.h"
# include "./parse/parse.h"
@ -24,6 +24,7 @@
# include "./utils/utils.h"
# include "./data/data.h"
# include "./signal/signal.h"
# include <stdio.h>
# include <readline/readline.h>
# include <readline/history.h>
# include <signal.h>

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/27 13:41:30 by cchauvet #+# #+# */
/* Updated: 2023/03/27 13:41:31 by cchauvet ### ########.fr */
/* Updated: 2023/04/18 12:57:36 by erey-bet ### ########.fr */
/* */
/* ************************************************************************** */
@ -16,11 +16,11 @@
int echo(int fd, char **strs);
int pwd(int fd);
char *get_pwd(int fd);
char *get_pwd(void);
int print_env(t_list **env, int fd);
int ft_export(t_list **env, char **args, int fd);
int move_folder(char **args, int fd);
int move_folder(char **args, t_list **env, int fd);
int unset(t_list **env, char **args, int fd);
int ft_exit(char **args);
int ft_exit(char **args, int err);
#endif

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/27 13:41:42 by cchauvet #+# #+# */
/* Updated: 2023/03/27 13:41:44 by cchauvet ### ########.fr */
/* Updated: 2023/04/18 12:57:25 by erey-bet ### ########.fr */
/* */
/* ************************************************************************** */
@ -17,6 +17,6 @@
# include "../env/env.h"
# include "../utils/utils.h"
char *get_pwd(int fd);
char *get_pwd(void);
#endif

View File

@ -6,33 +6,39 @@
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/20 14:27:36 by erey-bet #+# #+# */
/* Updated: 2023/03/21 13:16:24 by erey-bet ### ########.fr */
/* Updated: 2023/04/18 13:22:22 by erey-bet ### ########.fr */
/* */
/* ************************************************************************** */
#include "./builtins_private.h"
int make_move(char *path, int fd)
int make_move(char *path, t_list **env)
{
char *join;
char *old;
join = ft_strjoin("/", path);
join = ft_strfjoin(get_pwd(fd), join);
join = ft_strfjoin(get_pwd(), join);
old = get_pwd();
if (chdir(join) == 0)
{
set_value_by_key("OLDPWD", old, env);
set_value_by_key("PWD", get_pwd(), env);
free(join);
return (0);
}
free(old);
free(join);
write(2, "No such file or directory\n", 26);
write(2, "cd: No such file or directory\n", 30);
return (1);
}
int move_folder(char **args, int fd)
int move_folder(char **args, t_list **env)
{
char *path;
char *old;
if (args[1] != NULL || args[0] == NULL)
if (args[0] == NULL || args[1] != NULL)
{
write(2, "cd: Wrong number's argument\n", 28);
return (1);
@ -40,11 +46,17 @@ int move_folder(char **args, int fd)
path = args[0];
if (path[0] == '/' || ft_strncmp(path, "..", ft_strlen(path)) == 0)
{
old = get_pwd();
if (chdir(path) == 0)
{
set_value_by_key("OLDPWD", old, env);
set_value_by_key("PWD", get_pwd(), env);
return (0);
write(2, "No such file or directory\n", 26);
}
free(old);
write(2, "cd: No such file or directory\n", 30);
return (1);
}
else
return (make_move(path, fd));
return (make_move(path, env));
}

View File

@ -6,7 +6,7 @@
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/17 13:09:08 by erey-bet #+# #+# */
/* Updated: 2023/03/28 15:53:52 by cchauvet ### ########.fr */
/* Updated: 2023/04/11 14:57:00 by erey-bet ### ########.fr */
/* */
/* ************************************************************************** */
@ -26,7 +26,7 @@ int check_argument(char *str, int *check_backslash_n)
while (str[++i])
if (str[i] != '-' && str[i] != 'n')
return (1);
if (ft_strnstr(str, "n", ft_strlen(str)))
if (ft_strnstr(str, "n", ft_strlen(str)) && str[0] == '-')
*check_backslash_n = 1;
else
return (1);
@ -38,14 +38,16 @@ int echo(int fd, char **strs)
int check_backslash_n;
int check_start_write;
int i;
int y;
check_backslash_n = 0;
check_start_write = 0;
i = -1;
while (strs[++i])
{
while (is_space(*strs[i]))
strs[i]++;
y = -1;
while (is_space(strs[i][++y]))
;
if (check_start_write == 1
|| check_argument(strs[i], &check_backslash_n))
{

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/14 14:56:02 by cchauvet #+# #+# */
/* Updated: 2023/03/09 15:04:47 by erey-bet ### ########.fr */
/* Updated: 2023/03/30 15:15:04 by erey-bet ### ########.fr */
/* */
/* ************************************************************************** */
@ -19,7 +19,7 @@ int print_env(t_list **env, int fd)
current = *env;
while (current->next != NULL)
{
if (((t_env *)(current->content))->original)
if (((t_env *)(current->content))->value)
{
ft_putstr_fd(((t_env *)(current->content))->key, fd);
ft_putstr_fd("=", fd);
@ -30,12 +30,3 @@ int print_env(t_list **env, int fd)
}
return (0);
}
/*int main(int argc, char *argv[], char **env)
{
t_list **be;
be = init_env(env);
print_env(be, 1);
return (0);
}*/

View File

@ -6,7 +6,7 @@
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/24 10:17:59 by erey-bet #+# #+# */
/* Updated: 2023/03/10 14:52:22 by erey-bet ### ########.fr */
/* Updated: 2023/04/05 12:30:46 by erey-bet ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,7 +14,7 @@
static int error(int err, char *reason, char *problem)
{
ft_putstr_fd("minishell: exit ", 2);
ft_putstr_fd("bozoshell: bozo_exit ", 2);
if (problem != NULL)
{
ft_putstr_fd(problem, 2);
@ -24,22 +24,20 @@ static int error(int err, char *reason, char *problem)
return (err);
}
int ft_exit(char **args)
int ft_exit(char **args, int err)
{
int err;
if (args[0] == NULL)
{
write(1, "exit\n", 6);
return (0);
write(1, "bozo_exit\n", 10);
return (err);
}
err = ft_atoi_check(args[0]);
if (err == 1)
return (error(err, "numeric argument required", args[0]));
return (error(err, "bozo_exit: numeric argument required\n", args[0]));
if (args[1] != NULL)
return (error(1, "too many arguments", NULL));
return (error(-1, "bozo_exit: too many arguments\n", NULL));
if (err > 0)
return (error(err, "numeric argument required", args[0]));
return (error(err, "bozo_exit: numeric argument required\n", args[0]));
write(1, "exit\n", 6);
return ((ft_atoi(args[0]) % 256 + 256) % 256);
}

View File

@ -6,17 +6,21 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/14 14:27:08 by cchauvet #+# #+# */
/* Updated: 2023/03/30 13:04:53 by erey-bet ### ########.fr */
/* Updated: 2023/04/14 19:12:10 by erey-bet ### ########.fr */
/* */
/* ************************************************************************** */
#include "./builtins_private.h"
static int error(char *str)
static int error(char *str, char *to_free1, char *to_free2)
{
write(2, "bash: export: `", 15);
write(2, "bozoshell: export: `", 20);
write(2, str, ft_strlen(str));
write(2, "': not a valid identifier\n", 26);
if (to_free1 != NULL)
free(to_free1);
if (to_free2 != NULL)
free(to_free2);
return (1);
}
@ -27,17 +31,20 @@ void print_export(t_list **env, int fd)
current = *env;
while (current->next != NULL)
{
write(fd, "declare -x ", 11);
ft_putstr_fd(((t_env *)(current->content))->key, fd);
if (((t_env *)(current->content))->value != NULL)
if (ft_strcmp(((t_env *)(current->content))->key, "_"))
{
ft_putstr_fd("=", fd);
write(fd, "\"", 1);
ft_putstr_fd(((t_env *)(current->content))->value, fd);
write(fd, "\"\n", 2);
write(fd, "declare -x ", 11);
ft_putstr_fd(((t_env *)(current->content))->key, fd);
if (((t_env *)(current->content))->value != NULL)
{
ft_putstr_fd("=", fd);
write(fd, "\"", 1);
ft_putstr_fd(((t_env *)(current->content))->value, fd);
write(fd, "\"\n", 2);
}
else
write(fd, "\n", 2);
}
else
write(fd, "\n", 2);
current = current->next;
}
}
@ -71,7 +78,7 @@ int add_export(t_list **env, char *args)
if (ft_strchr(args, '=') != NULL)
{
if (set_key_value_export(env, args, &key, &value))
return (error(args));
return (error(args, key, NULL));
}
else
{
@ -80,10 +87,10 @@ int add_export(t_list **env, char *args)
if (value != NULL)
value = ft_strdup(value);
if (possible_key(key) == 2)
return (error(key));
return (error(key, key, value));
}
if (!possible_key(key))
return (error(args));
return (error(args, key, value));
create_value_by_key(key, value, env);
return (0);
}

View File

@ -6,7 +6,7 @@
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/17 16:09:11 by erey-bet #+# #+# */
/* Updated: 2023/03/09 20:00:19 by erey-bet ### ########.fr */
/* Updated: 2023/04/18 12:59:25 by erey-bet ### ########.fr */
/* */
/* ************************************************************************** */
@ -20,13 +20,13 @@ int pwd(int fd)
ft_putendl_fd(path, fd);
else
{
ft_putendl_fd("Error getcwd", fd);
ft_putendl_fd("Error getcwd", 2);
return (1);
}
return (0);
}
char *get_pwd(int fd)
char *get_pwd(void)
{
char *str;
@ -35,7 +35,7 @@ char *get_pwd(int fd)
return (str);
else
{
ft_putendl_fd("Error getcwd", fd);
ft_putendl_fd("Error getcwd", 2);
return (NULL);
}
}

View File

@ -6,7 +6,7 @@
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/22 13:28:27 by erey-bet #+# #+# */
/* Updated: 2023/02/23 15:49:21 by erey-bet ### ########.fr */
/* Updated: 2023/04/07 12:46:28 by erey-bet ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,9 +14,9 @@
int error(char *str, int fd)
{
write(fd, "bash: unset: `", 14);
write(fd, "bozoshell: unset: `", 19);
write(fd, str, ft_strlen(str));
write(fd, "': not a valid identifier", 25);
write(fd, "': not a valid identifier\n", 26);
return (1);
}

View File

@ -6,11 +6,14 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/15 14:18:21 by cchauvet #+# #+# */
/* Updated: 2023/02/21 22:27:28 by cchauvet ### ########.fr */
/* Updated: 2023/04/17 11:57:07 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "cmd.h"
#include "cmd_private.h"
#include "../signal/signal.h"
#include <signal.h>
void ft_cmddel(void *ptr)
{
@ -31,3 +34,40 @@ void ft_cmddel(void *ptr)
close(content->fd_out[1]);
free(content);
}
void ft_cmdcloser(void *ptr)
{
t_cmd *cmd;
cmd = ptr;
ft_closer(cmd->fd_in);
ft_closer(cmd->fd_out);
}
void ft_cmdwaiter(void *ptr)
{
t_cmd *cmd;
int exit_status;
cmd = ptr;
if (cmd->executable != NULL && cmd->own_cmd == 0
&& cmd->pid != -1 && cmd->fd_in[0] != -2 && cmd->fd_out[0] != -2)
{
waitpid(cmd->pid, &exit_status, 0);
if (WIFSIGNALED(exit_status))
{
if (exit_status == 131)
{
ft_printf("Quit (core dumped)");
*ft_get_exit_code() = 131;
}
else
*ft_get_exit_code() = 130;
ft_printf("\n");
}
else
*ft_get_exit_code() = WEXITSTATUS(exit_status);
}
signal(SIGINT, ft_ctrlc);
signal(SIGQUIT, SIG_IGN);
}

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/28 15:47:01 by cchauvet #+# #+# */
/* Updated: 2023/03/28 15:47:02 by cchauvet ### ########.fr */
/* Updated: 2023/04/07 15:03:53 by alouis-j ### ########.fr */
/* */
/* ************************************************************************** */
@ -26,5 +26,7 @@ typedef struct s_cmd
} t_cmd;
void ft_cmddel(void *content);
void ft_cmdwaiter(void *content);
void ft_cmdcloser(void *ptr);
#endif

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/28 15:50:23 by cchauvet #+# #+# */
/* Updated: 2023/03/28 15:50:24 by cchauvet ### ########.fr */
/* Updated: 2023/03/31 16:33:24 by alouis-j ### ########.fr */
/* */
/* ************************************************************************** */
@ -17,4 +17,5 @@
# include "./cmd.h"
# include "../libftx/libftx.h"
# include "../data/data.h"
# include "../utils/utils.h"
#endif

View File

@ -6,16 +6,16 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/27 13:42:09 by cchauvet #+# #+# */
/* Updated: 2023/03/27 13:42:58 by cchauvet ### ########.fr */
/* Updated: 2023/04/05 14:48:30 by alouis-j ### ########.fr */
/* */
/* ************************************************************************** */
#include "./data_private.h"
#include "data.h"
t_data *ft_get_data(void)
int *ft_get_exit_code(void)
{
static t_data data;
static int exit_code;
return (&data);
return (&exit_code);
}

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/27 13:43:39 by cchauvet #+# #+# */
/* Updated: 2023/03/27 13:43:40 by cchauvet ### ########.fr */
/* Updated: 2023/04/05 14:45:23 by alouis-j ### ########.fr */
/* */
/* ************************************************************************** */
@ -18,10 +18,9 @@ typedef struct s_data
{
t_list **env;
t_list **cmds;
int exit_code;
int child_pid;
int *exit_code;
} t_data;
t_data *ft_get_data(void);
int *ft_get_exit_code(void);
#endif

1
env/env.h vendored
View File

@ -20,7 +20,6 @@ typedef struct s_env
{
char *key;
char *value;
bool original;
} t_env;
char *ft_env_filler(t_data *data, const char *str);

16
env/env1.c vendored
View File

@ -6,7 +6,7 @@
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/02 14:39:56 by erey-bet #+# #+# */
/* Updated: 2023/03/30 13:07:15 by erey-bet ### ########.fr */
/* Updated: 2023/04/18 13:57:38 by erey-bet ### ########.fr */
/* */
/* ************************************************************************** */
@ -34,7 +34,11 @@ void add_sort(t_list **head, t_env *var)
}
}
if (current->next == NULL)
{
current->next = ft_calloc(1, sizeof(t_list));
if (!current->next)
return ;
}
}
char *get_value_by_key(char *key, t_list **head)
@ -61,9 +65,7 @@ int set_value_by_key(char *key, char *value, t_list **head)
if (ft_strcmp(((t_env *)current->content)->key, key) == 0)
{
free(((t_env *)current->content)->value);
free(((t_env *)current->content)->key);
((t_env *)current->content)->value = value;
((t_env *)current->content)->key = key;
return (0);
}
current = current->next;
@ -76,13 +78,15 @@ int create_value_by_key(char *key, char *value, t_list **head)
t_env *content;
if (set_value_by_key(key, value, head) == 0)
{
free(key);
return (0);
}
content = ft_calloc(1, sizeof(t_env));
if (content == NULL)
return (1);
content->key = key;
content->value = value;
content->original = 0;
add_sort(head, content);
return (0);
}
@ -98,7 +102,10 @@ t_list **init_env(char **env)
return (NULL);
*head = ft_calloc(1, sizeof(t_list));
if (*head == NULL)
{
free(head);
return (NULL);
}
i = -1;
while (env[++i])
{
@ -107,7 +114,6 @@ t_list **init_env(char **env)
return (NULL);
var->key = get_key(env[i]);
var->value = get_value(env[i]);
var->original = 1;
add_sort(head, var);
}
return (head);

2
env/env2.c vendored
View File

@ -6,7 +6,7 @@
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/09 19:59:03 by erey-bet #+# #+# */
/* Updated: 2023/03/09 19:59:10 by erey-bet ### ########.fr */
/* Updated: 2023/04/18 13:26:31 by erey-bet ### ########.fr */
/* */
/* ************************************************************************** */

5
env/env3.c vendored
View File

@ -6,7 +6,7 @@
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/17 17:25:09 by erey-bet #+# #+# */
/* Updated: 2023/03/30 12:51:54 by erey-bet ### ########.fr */
/* Updated: 2023/04/07 13:21:54 by erey-bet ### ########.fr */
/* */
/* ************************************************************************** */
@ -70,6 +70,7 @@ int delete_by_key(char *key, t_list **head)
t_list *current;
current = *head;
last = NULL;
while (current->next != NULL)
{
if (ft_strcmp(((t_env *)current->content)->key, key) == 0)
@ -77,7 +78,7 @@ int delete_by_key(char *key, t_list **head)
free(((t_env *)current->content)->key);
free(((t_env *)current->content)->value);
free(current->content);
if (last->next != NULL)
if (last && last->next)
last->next = current->next;
else
*head = current->next;

8
env/env_fill.c vendored
View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/16 16:29:08 by cchauvet #+# #+# */
/* Updated: 2023/03/29 19:06:44 by cchauvet ### ########.fr */
/* Updated: 2023/04/05 15:09:46 by alouis-j ### ########.fr */
/* */
/* ************************************************************************** */
@ -31,7 +31,7 @@ static char *ft_getkey(const char *str)
key = ft_strndup(str + 1, i - 1);
}
if (key == NULL)
ft_eprintf("minishell: malloc failed\n");
ft_eprintf("bozoshell: malloc failed\n");
return (key);
}
@ -40,7 +40,7 @@ static char *ft_getvalue(t_data *data, char *key)
char *value;
if (ft_strcmp(key, "?") == 0)
value = ft_itoa(data->exit_code);
value = ft_itoa(*data->exit_code);
else if (ft_strcmp(key, "$") == 0)
value = ft_strdup("PID");
else if (key[0] == '\0')
@ -54,7 +54,7 @@ static char *ft_getvalue(t_data *data, char *key)
value = ft_strdup(value);
}
if (value == NULL)
ft_eprintf("minishell: malloc failed\n");
ft_eprintf("bozoshell: malloc failed\n");
return (value);
}

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/21 12:45:16 by cchauvet #+# #+# */
/* Updated: 2023/03/29 18:53:35 by cchauvet ### ########.fr */
/* Updated: 2023/04/18 13:00:08 by erey-bet ### ########.fr */
/* */
/* ************************************************************************** */
@ -23,48 +23,47 @@ static int ft_execute_own_cmd(t_data *data, t_cmd *cmd)
else if (ft_strcmp(cmd->executable, "export") == 0)
return_code = ft_export(data->env, cmd->args + 1, cmd->fd_out[0]);
else if (ft_strcmp(cmd->executable, "cd") == 0)
return_code = (move_folder(cmd->args + 1, cmd->fd_out[0]));
return_code = (move_folder(cmd->args + 1, data->env, cmd->fd_out[0]));
else if (ft_strcmp(cmd->executable, "unset") == 0)
return_code = (unset(data->env, cmd->args, cmd->fd_out[0]));
else if (ft_strcmp(cmd->executable, "echo") == 0)
return_code = (echo(cmd->fd_out[0], cmd->args + 1));
else
{
return_code = ft_exit(cmd->args + 1);
return_code = ft_exit(cmd->args + 1, *data->exit_code);
if (return_code >= 0)
{
data->exit_code = return_code;
return (-1);
*data->exit_code = return_code;
return (-2);
}
}
data->exit_code = return_code;
*data->exit_code = return_code;
return (return_code);
}
static bool ft_executor(t_cmd *cmd, char **env, int fd)
static bool ft_executor(t_data *data, t_cmd *cmd, char **env)
{
if (cmd->fd_in[0] == -1 || cmd->fd_out[0] == -1 || cmd->executable == NULL)
return (0);
cmd->pid = fork();
ft_get_data()->child_pid = cmd->pid;
if (cmd->pid == -1)
return (1);
if (cmd->pid == 0)
{
signal(SIGQUIT, SIG_DFL);
signal(SIGINT, SIG_DFL);
dup2(cmd->fd_in[0], 0);
dup2(cmd->fd_out[0], 1);
if (fd != -1)
close(fd);
ft_closer(cmd->fd_in);
ft_closer(cmd->fd_out);
ft_lstiter(*data->cmds, ft_cmdcloser);
execve(cmd->executable, cmd->args, env);
ft_eprintf("minishell: permission denied: %s\n", cmd->executable);
return (1);
}
signal(SIGQUIT, SIG_IGN);
signal(SIGINT, SIG_IGN);
return (0);
}
static int ft_cmd_executor(t_data *data, t_cmd *cmd, int fd)
static int ft_cmd_executor(t_data *data, t_cmd *cmd)
{
int exit_code;
char **env;
@ -74,7 +73,7 @@ static int ft_cmd_executor(t_data *data, t_cmd *cmd, int fd)
exit_code = ft_execute_own_cmd(data, cmd);
ft_closer(cmd->fd_in);
ft_closer(cmd->fd_out);
if (exit_code == -1)
if (exit_code == -2)
return (1);
}
else
@ -82,7 +81,7 @@ static int ft_cmd_executor(t_data *data, t_cmd *cmd, int fd)
env = env_to_strs(data->env);
if (env == NULL)
return (1);
exit_code = ft_executor(cmd, env, fd);
exit_code = ft_executor(data, cmd, env);
ft_closer(cmd->fd_in);
ft_closer(cmd->fd_out);
ft_freer_tab_ultimate(1, env);
@ -112,7 +111,7 @@ int ft_cmds_executor(t_data *data)
}
if (content->fd_in[0] == -2 || content->fd_out[0] == -2)
ft_mega_closer(content->fd_in, content->fd_out);
else if (ft_cmd_executor(data, content, fds[0]))
else if (ft_cmd_executor(data, content))
return (1);
current = current->next;
}

View File

@ -6,12 +6,14 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/28 15:45:53 by cchauvet #+# #+# */
/* Updated: 2023/03/29 18:55:22 by cchauvet ### ########.fr */
/* Updated: 2023/04/05 15:15:56 by alouis-j ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef EXECUTION_PRIVATE_H
# define EXECUTION_PRIVATE_H
# include <signal.h>
# include "../signal/signal.h"
# include "../data/data.h"
# include "../libftx/libftx.h"
# include "../cmd/cmd.h"

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/15 13:35:50 by cchauvet #+# #+# */
/* Updated: 2023/03/29 16:53:15 by cchauvet ### ########.fr */
/* Updated: 2023/03/31 15:22:21 by alouis-j ### ########.fr */
/* */
/* ************************************************************************** */
@ -20,7 +20,7 @@ static int ft_replace(char **str, size_t i)
free(*str);
if (temp == NULL)
{
ft_eprintf("minishell: malloc failed\n");
ft_eprintf("bozoshell: malloc failed\n");
return (1);
}
*str = temp;
@ -40,7 +40,7 @@ static char *ft_spacer_after(const char *str)
{
while (ft_is_in_quote(out, i - 1))
i++;
if (out[i] == '\0')
if (out[i - 1] == '\0' || out[i] == '\0')
break ;
if (ft_is_in("><|", out[i - 1]))
{
@ -66,7 +66,7 @@ static char *ft_spacer_before(const char *str)
i = -1;
while (out[++i] != '\0')
{
while (ft_is_in_quote(out, i))
while (ft_is_in_quote(out, i + 1))
i++;
if (out[i] == '\0')
break ;

Binary file not shown.

69
main.c
View File

@ -6,14 +6,18 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/16 15:16:14 by cchauvet #+# #+# */
/* Updated: 2023/03/30 13:12:41 by cchauvet ### ########.fr */
/* Updated: 2023/04/18 12:59:43 by erey-bet ### ########.fr */
/* */
/* ************************************************************************** */
#include "data/data.h"
#include "env/env.h"
#include "libftx/libft/libft.h"
#include "libftx/libft/list.h"
#include "libftx/libftx.h"
#include "minishell.h"
#include "bozoshell.h"
#include "signal/signal.h"
#include <stdlib.h>
static char *ft_get_user_input(void)
{
@ -21,14 +25,14 @@ static char *ft_get_user_input(void)
char *prompt;
char *pwd;
pwd = get_pwd(2);
pwd = get_pwd();
if (pwd == NULL)
return (NULL);
prompt = ft_strmerger(2, pwd, "$ ");
free(pwd);
if (prompt == NULL)
{
ft_eprintf("minishell: malloc failed\n");
ft_eprintf("bozoshell: malloc failed\n");
return (NULL);
}
line = readline(prompt);
@ -40,35 +44,6 @@ static char *ft_get_user_input(void)
return (line);
}
static void ft_cmds_waiter(t_data *data)
{
t_list *current;
t_cmd *cmd;
int exit_status;
current = *data->cmds;
while (current != NULL)
{
cmd = current->content;
if (cmd->executable != NULL && cmd->own_cmd == 0
&& cmd->pid != -1 && cmd->fd_in[0] != -2 && cmd->fd_out[0] != -2)
{
waitpid(cmd->pid, &exit_status, 0);
if (WIFSIGNALED(exit_status))
{
if (WTERMSIG(exit_status) == SIGKILL)
data->exit_code = 131;
else
data->exit_code = 130;
}
else
data->exit_code = WEXITSTATUS(exit_status);
}
current = current->next;
}
data->child_pid = 0;
}
static int ft_minishell(t_data *data, char *line)
{
char *line_clean;
@ -86,26 +61,25 @@ static int ft_minishell(t_data *data, char *line)
free(line_clean);
if (ft_cmds_executor(data) == 1)
return (1);
ft_cmds_waiter(data);
ft_lstiter(*data->cmds, ft_cmdwaiter);
ft_lstclear(data->cmds, ft_cmddel);
return (0);
}
int ft_init_data(t_data *data, char **env)
{
data->exit_code = 0;
data->child_pid = 0;
data->exit_code = ft_get_exit_code();
data->cmds = malloc(sizeof(t_cmd *));
if (data->cmds == NULL)
{
ft_eprintf("minishell: malloc failed\n");
ft_eprintf("bozoshell: malloc failed\n");
return (1);
}
*data->cmds = NULL;
data->env = init_env(env);
if (data->env == NULL)
{
ft_eprintf("minishell: malloc failed\n");
ft_eprintf("bozoshell: malloc failed\n");
free(data->cmds);
return (1);
}
@ -114,29 +88,28 @@ int ft_init_data(t_data *data, char **env)
int main(int ac, char **av, char **env)
{
t_data *data;
t_data data;
char *line;
(void) ac;
(void) av;
signal(SIGINT, ft_ctrlc);
signal(SIGQUIT, ft_quit);
data = ft_get_data();
if (ft_init_data(data, env))
signal(SIGQUIT, SIG_IGN);
if (ft_init_data(&data, env))
return (1);
line = ft_get_user_input();
while (line != NULL)
{
if (ft_minishell(data, line) == 1)
if (ft_minishell(&data, line) == 1)
break ;
free(line);
line = ft_get_user_input();
if (line == NULL)
break ;
}
ft_lstclear(data->cmds, ft_cmddel);
free(data->cmds);
ft_lstclear(data->env, env_del);
free(data->env);
return (data->exit_code);
ft_lstclear(data.cmds, ft_cmddel);
free(data.cmds);
ft_lstclear(data.env, env_del);
free(data.env);
return (*data.exit_code);
}

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/27 13:44:38 by cchauvet #+# #+# */
/* Updated: 2023/03/29 19:31:35 by cchauvet ### ########.fr */
/* Updated: 2023/04/11 16:17:19 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
@ -17,7 +17,7 @@ static int ft_args_parse(char *cmd_str, t_cmd *cmd)
char **tab;
size_t i;
tab = ft_split_quoted(cmd_str, ' ');
tab = ft_split_charset_quoted(cmd_str, "\t ");
if (tab == NULL)
return (1);
i = 0;
@ -80,10 +80,14 @@ int ft_cmd_parser(t_data *data, char *cmd_str)
cmd = ft_calloc(sizeof(t_cmd), 1);
if (cmd == NULL)
{
ft_eprintf("minishell: malloc failed\n");
ft_eprintf("bozoshell: malloc failed\n");
return (1);
}
if (ft_redirection(data, cmd, cmd_str))
{
ft_cmddel(cmd);
return (1);
}
ft_redirection(data, cmd, cmd_str);
if (ft_args_parse(cmd_str, cmd))
{
ft_cmddel(cmd);
@ -98,10 +102,10 @@ int ft_cmds_parser(t_data *data, const char *line)
char **tab;
ssize_t i;
tab = ft_split_quoted(line, '|');
tab = ft_split_charset_quoted(line, "|");
if (tab == NULL)
{
ft_eprintf("minishell: malloc failed\n");
ft_eprintf("bozoshell: malloc failed\n");
return (1);
}
i = -1;

View File

@ -6,20 +6,35 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/29 17:32:06 by cchauvet #+# #+# */
/* Updated: 2023/03/29 19:21:59 by cchauvet ### ########.fr */
/* Updated: 2023/04/17 11:15:38 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "./redirection_private.h"
#include <stdbool.h>
#include "../signal/signal.h"
#include <signal.h>
static bool ft_check_heredoc(t_data *data, t_cmd *cmd,
char *redirection_identifier, char *redirection)
{
int fd;
if (ft_strcmp(redirection_identifier, "<<") == 0)
{
cmd->fd_in[0] = ft_heredoc(data, redirection);
if (cmd->fd_in[0] == -2)
return (0);
signal(SIGINT, ft_ctrlc_heredoc);
fd = ft_heredoc(data, redirection);
signal(SIGINT, ft_ctrlc);
if (fd == -2)
return (1);
else
{
if (cmd->fd_in[0] > 2)
close(cmd->fd_in[0]);
cmd->fd_in[0] = fd;
}
}
return (0);
}
@ -27,14 +42,25 @@ static bool ft_check_heredoc(t_data *data, t_cmd *cmd,
static bool ft_check_infile(t_data *data, t_cmd *cmd,
char *redirection_identifier, char *redirection)
{
int fd;
if (ft_strcmp(redirection_identifier, "<") == 0)
{
if (cmd->fd_in[0] == -2)
return (0);
if (ft_file_is_readable(data, redirection))
cmd->fd_in[0] = open(redirection, O_RDONLY);
{
fd = open(redirection, O_RDONLY);
if (cmd->fd_in[0] > 2)
close(cmd->fd_in[0]);
cmd->fd_in[0] = fd;
}
else
{
if (cmd->fd_in[0] > 2)
close(cmd->fd_in[0]);
cmd->fd_in[0] = -2;
return (1);
return (0);
}
}
return (0);
@ -43,15 +69,26 @@ static bool ft_check_infile(t_data *data, t_cmd *cmd,
static bool ft_check_outfile(t_data *data, t_cmd *cmd,
char *redirection_identifier, char *redirection)
{
int fd;
if (ft_strcmp(redirection_identifier, ">") == 0)
{
if (cmd->fd_out[0] == -2)
return (0);
if (ft_file_is_writable(data, redirection))
cmd->fd_out[0] = open(redirection,
{
fd = open(redirection,
O_WRONLY | O_TRUNC | O_CREAT, 0644);
if (cmd->fd_out[0] > 2)
close(cmd->fd_out[0]);
cmd->fd_out[0] = fd;
}
else
{
if (cmd->fd_out[0] > 2)
close(cmd->fd_out[0]);
cmd->fd_out[0] = -2;
return (1);
return (0);
}
}
return (0);
@ -60,15 +97,25 @@ static bool ft_check_outfile(t_data *data, t_cmd *cmd,
static bool ft_check_outfile_append(t_data *data, t_cmd *cmd,
char *redirection_identifier, char *redirection)
{
int fd;
if (ft_strcmp(redirection_identifier, ">>") == 0)
{
if (ft_file_is_writable(data, redirection))
cmd->fd_out[0] = open(redirection,
if (cmd->fd_out[0] == -2)
return (0);
if (ft_file_is_appendable(data, redirection))
{
fd = open(redirection,
O_WRONLY | O_APPEND | O_CREAT, 0644);
if (cmd->fd_out[0] > 2)
close(cmd->fd_out[0]);
cmd->fd_out[0] = fd;
}
else
{
if (cmd->fd_out[0] > 2)
close(cmd->fd_out[0]);
cmd->fd_out[0] = -2;
return (1);
}
}
return (0);
@ -77,9 +124,28 @@ static bool ft_check_outfile_append(t_data *data, t_cmd *cmd,
bool ft_check_redirection(t_data *data, t_cmd *cmd,
char *redirection_identifier, char *redirection)
{
return (ft_check_heredoc(data, cmd, redirection_identifier, redirection)
|| ft_check_infile(data, cmd, redirection_identifier, redirection)
|| ft_check_outfile(data, cmd, redirection_identifier, redirection)
|| ft_check_outfile_append(data, cmd, redirection_identifier,
redirection));
char *str;
bool out;
if (ft_is_in("<>", redirection_identifier[0])
&& ft_is_in("<>", redirection[0]))
{
ft_eprintf("bozoshell: %s: invalid redirection file\n", redirection);
return (1);
}
str = ft_strdup(redirection);
if (str == NULL)
{
ft_eprintf("bozoshell: malloc failed\n");
return (1);
}
ft_quote_remover(str);
out = 0;
if (ft_check_heredoc(data, cmd, redirection_identifier, str)
|| ft_check_infile(data, cmd, redirection_identifier, str)
|| ft_check_outfile(data, cmd, redirection_identifier, str)
|| ft_check_outfile_append(data, cmd, redirection_identifier, str))
out = 1;
free(str);
return (out);
}

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/15 17:36:11 by cchauvet #+# #+# */
/* Updated: 2023/03/30 13:26:31 by cchauvet ### ########.fr */
/* Updated: 2023/04/05 15:12:41 by alouis-j ### ########.fr */
/* */
/* ************************************************************************** */
@ -20,15 +20,15 @@ int ft_file_is_readable(t_data *data, const char *path)
fd = open(path, O_RDONLY);
if (fd == -1)
{
data->exit_code = 1;
ft_eprintf("minishell: %s: No such file or directory\n", path);
*data->exit_code = 1;
ft_eprintf("bozoshell: %s: No such file or directory\n", path);
return (0);
}
readable = read(fd, "", 0);
if (readable == -1)
{
data->exit_code = 1;
ft_eprintf("minishell: %s: Permission denied\n", path);
*data->exit_code = 1;
ft_eprintf("bozoshell: %s: Permission denied\n", path);
return (0);
}
close(fd);
@ -43,15 +43,15 @@ int ft_file_is_writable(t_data *data, const char *path)
fd = open(path, O_WRONLY | O_TRUNC | O_CREAT, 0644);
if (fd == -1)
{
data->exit_code = 1;
ft_eprintf("minishell: %s: Permission denied\n", path);
*data->exit_code = 1;
ft_eprintf("bozoshell: %s: Permission denied\n", path);
return (0);
}
writeable = write(fd, "", 0);
if (writeable == -1)
{
data->exit_code = 1;
ft_eprintf("minishell: %s: Permission denied\n", path);
*data->exit_code = 1;
ft_eprintf("bozoshell: %s: Permission denied\n", path);
return (0);
}
close(fd);
@ -66,15 +66,15 @@ int ft_file_is_appendable(t_data *data, const char *path)
fd = open(path, O_WRONLY | O_APPEND | O_CREAT, 0644);
if (fd == -1)
{
data->exit_code = 1;
ft_eprintf("minishell: %s: Permission denied\n", path);
*data->exit_code = 1;
ft_eprintf("bozoshell: %s: Permission denied\n", path);
return (0);
}
writeable = write(fd, "", 0);
if (writeable == -1)
{
data->exit_code = 1;
ft_eprintf("minishell: %s: Permission denied\n", path);
*data->exit_code = 1;
ft_eprintf("bozoshell: %s: Permission denied\n", path);
return (0);
}
close(fd);

View File

@ -6,17 +6,23 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/17 15:36:26 by cchauvet #+# #+# */
/* Updated: 2023/03/29 16:37:05 by cchauvet ### ########.fr */
/* Updated: 2023/04/17 12:14:11 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "./redirection_private.h"
#include <readline/readline.h>
#include <unistd.h>
int *ft_get_heredoc(void)
static bool ft_fd_is_closed(int fd)
{
static int heredoc = -1;
int fd2;
return (&heredoc);
fd2 = dup(fd);
if (fd2 == -1)
return (1);
close(fd2);
return (0);
}
static int ft_format_and_write(t_data *data, const char *str, int fd)
@ -31,26 +37,29 @@ static int ft_format_and_write(t_data *data, const char *str, int fd)
return (0);
}
static int ft_heredoc2(t_data *data, char *stop, char *line, int fds[2])
int ft_heredoc2(t_data *data, char *line, char *stop, int fds[2])
{
line[ft_strlen(line) - 1] = '\0';
if (ft_strcmp(line, stop) == 0)
if (line == NULL)
{
free(line);
return (2);
if (ft_fd_is_closed(0))
{
close(fds[0]);
fds[0] = -2;
return (1);
}
else
{
ft_eprintf("\nbozoshell: warning: here-document at line 1%s",
"delimited by end-of-file (wanted `adfsd')\n");
return (1);
}
}
if (ft_strcmp(line, stop) == 0)
return (1);
if (ft_format_and_write(data, line, fds[1]))
{
ft_closer(fds);
free(line);
return (1);
}
free(line);
ft_printf("> ");
line = get_next_line(*ft_get_heredoc());
if (line == NULL && *ft_get_heredoc() == -1)
{
ft_closer(fds);
close(fds[0]);
fds[0] = -2;
return (1);
}
return (0);
@ -58,24 +67,27 @@ static int ft_heredoc2(t_data *data, char *stop, char *line, int fds[2])
int ft_heredoc(t_data *data, char *stop)
{
char *line;
int fds[2];
int return_code;
int stdin_bak;
char *line;
if (pipe(fds) == -1)
return (-1);
*ft_get_heredoc() = dup(0);
ft_printf("> ");
line = get_next_line(*ft_get_heredoc());
while (line != NULL)
stdin_bak = dup(0);
if (stdin_bak == -1)
return (1);
if (pipe(fds))
{
return_code = ft_heredoc2(data, stop, line, fds);
if (return_code == 2)
break ;
else if (return_code)
return (-2);
close(stdin_bak);
return (1);
}
line = readline("> ");
while (ft_heredoc2(data, line, stop, fds) == 0)
{
free(line);
line = readline("> ");
}
free(line);
close(fds[1]);
*ft_get_heredoc() = -1;
dup2(stdin_bak, 0);
close(stdin_bak);
return (fds[0]);
}

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/27 13:44:22 by cchauvet #+# #+# */
/* Updated: 2023/03/29 19:19:51 by cchauvet ### ########.fr */
/* Updated: 2023/04/13 13:26:06 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
@ -78,11 +78,15 @@ int ft_set_redirection(t_data *data, t_cmd *cmd, char **tab)
i = 0;
while (tab[i + 1] != NULL)
{
ft_quote_remover(tab[i + 1]);
if (ft_check_redirection(data, cmd, tab[i], tab[i + 1]))
return (1);
i++;
}
if (ft_is_in("<>", tab[i][0]))
{
ft_eprintf("bozoshell: %s: must be followed by a file\n", tab[i]);
return (1);
}
return (0);
}
@ -94,10 +98,10 @@ int ft_redirection(t_data *data, t_cmd *cmd, char *cmd_str)
cmd->fd_in[1] = -1;
cmd->fd_out[0] = -1;
cmd->fd_out[1] = -1;
tab = ft_split_quoted(cmd_str, ' ');
tab = ft_split_charset_quoted(cmd_str, " \t");
if (tab == NULL)
{
ft_eprintf("minishell: malloc failed\n");
ft_eprintf("bozoshell: malloc failed\n");
return (1);
}
ft_remove_redirection(cmd_str);

View File

@ -6,60 +6,31 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/28 15:59:01 by cchauvet #+# #+# */
/* Updated: 2023/03/28 16:09:37 by cchauvet ### ########.fr */
/* Updated: 2023/04/17 11:23:21 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "signal_private.h"
static void ft_new_line(void)
void ft_ctrlc_heredoc(int num)
{
close(0);
ft_putchar_fd('\n', 1);
(void) num;
}
void ft_ctrlc(int num)
{
rl_replace_line("", 0);
rl_on_new_line();
ft_putchar_fd('\n', 1);
rl_redisplay();
}
void ft_ctrlc(int num)
{
t_data *data;
if (num == SIGQUIT)
return ;
data = ft_get_data();
data->exit_code = 130;
if (*ft_get_heredoc() != -1)
{
close(*ft_get_heredoc());
*ft_get_heredoc() = -1;
}
else
{
if (data->child_pid > 1)
{
data->child_pid = 0;
ft_putchar_fd('\n', 1);
}
else
ft_new_line();
}
*ft_get_exit_code() = 130;
(void) num;
}
void ft_quit(int num)
{
t_data *data;
(void) num;
data = ft_get_data();
data->exit_code = 131;
if (data->child_pid > 1)
{
ft_printf("Quit (core dumped)\n");
data->child_pid = 0;
}
else
{
rl_replace_line("", 0);
rl_redisplay();
}
ft_printf("Quit (core dumped)\n");
}

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/28 16:02:31 by cchauvet #+# #+# */
/* Updated: 2023/03/28 16:03:11 by cchauvet ### ########.fr */
/* Updated: 2023/04/17 11:14:28 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
@ -15,5 +15,6 @@
void ft_quit(int num);
void ft_ctrlc(int num);
void ft_ctrlc_heredoc(int num);
#endif

View File

@ -6,13 +6,14 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/28 15:59:42 by cchauvet #+# #+# */
/* Updated: 2023/03/28 16:04:46 by cchauvet ### ########.fr */
/* Updated: 2023/04/05 15:05:00 by alouis-j ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef SIGNAL_PRIVATE_H
# define SIGNAL_PRIVATE_H
# include <signal.h>
# include <stdio.h>
# include <readline/readline.h>
# include <unistd.h>
# include "../libftx/libftx.h"

Binary file not shown.

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/21 13:00:05 by cchauvet #+# #+# */
/* Updated: 2023/03/30 12:45:18 by cchauvet ### ########.fr */
/* Updated: 2023/04/07 11:07:52 by alouis-j ### ########.fr */
/* */
/* ************************************************************************** */
@ -17,7 +17,7 @@ static int ft_quote_verif(const char *str)
{
if (ft_is_in_quote(str, ft_strlen(str)))
{
ft_eprintf("minishell: Quote is not closed\n");
ft_eprintf("bozoshell: Quote is not closed\n");
return (1);
}
else
@ -47,7 +47,7 @@ static int ft_pipe_is_alone(const char *str)
}
}
if (check == 0)
ft_eprintf("minishell: Pipe must be followed and %s",
ft_eprintf("bozoshell: Pipe must be followed and %s",
"preced by a command or redirection\n");
return (check == 0);
}
@ -70,7 +70,7 @@ static int ft_special_char_dub(const char *str)
if ((y > 2 && (str[i] == '>' || str[i] == '<'))
|| (y > 1 && str[i] == '|'))
{
ft_eprintf("minishell: too many %s in a row\n", str);
ft_eprintf("bozoshell: too many %s in a row\n", str);
return (1);
}
i = i + y;
@ -86,7 +86,7 @@ static int ft_empty_verif(const char *str)
size_t i;
i = 0;
while (str[i] == ' ')
while (str[i] == ' ' || str[i] == '\t')
i++;
return (str[i] == '\0');
}
@ -99,7 +99,7 @@ int ft_syntax_verif(t_data *data, const char *str)
|| ft_pipe_is_alone(str)
|| ft_special_char_dub(str))
{
data->exit_code = 2;
*data->exit_code = 2;
return (1);
}
return (0);

1
tester

Submodule tester deleted from 1c6111b2fd

View File

@ -6,7 +6,7 @@
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/21 08:21:05 by erey-bet #+# #+# */
/* Updated: 2023/02/28 13:52:13 by erey-bet ### ########.fr */
/* Updated: 2023/04/04 13:40:43 by erey-bet ### ########.fr */
/* */
/* ************************************************************************** */
@ -22,7 +22,7 @@ static int ft_isspace(char c)
int ft_atoi_check(const char *nptr)
{
long result;
int64_t result;
int sign;
while (ft_isspace(*nptr))
@ -37,9 +37,9 @@ int ft_atoi_check(const char *nptr)
result = 0;
while (*nptr >= '0' && *nptr <= '9')
{
result = result * 10 + *nptr++ - '0';
if ((result > 2147483647 && sign == 1)
|| (result > 2147483647 && sign == 1))
result = result * 10 + (*nptr++ - '0') * sign;
if ((result < 0 && sign == 1)
|| (result > 0 && sign == -1))
return (2);
}
if (*nptr--)

View File

@ -20,7 +20,7 @@ int ft_change_exit_code(t_data *data, int new_value)
exit_code_str = ft_itoa(new_value);
if (exit_code_str == NULL)
{
ft_eprintf("minishell: malloc failed\n");
ft_eprintf("bozoshell: malloc failed\n");
return (1);
}
return (0);

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/27 13:39:48 by cchauvet #+# #+# */
/* Updated: 2023/03/30 13:04:53 by cchauvet ### ########.fr */
/* Updated: 2023/04/05 15:09:29 by alouis-j ### ########.fr */
/* */
/* ************************************************************************** */
@ -19,20 +19,20 @@ char *ft_get_executable_with_path(t_data *data, const char *name)
if (access(name, F_OK) != 0)
{
data->exit_code = 127;
ft_eprintf("minishell: %s: No such file or directery\n", name);
*data->exit_code = 127;
ft_eprintf("bozoshell: %s: No such file or directery\n", name);
return (NULL);
}
if (access(name, X_OK) != 0)
{
data->exit_code = 126;
ft_eprintf("minishell: %s: permission denied\n", name);
*data->exit_code = 126;
ft_eprintf("bozoshell: %s: permission denied\n", name);
return (NULL);
}
path = ft_strdup(name);
if (path == NULL)
{
ft_eprintf("minishell: malloc failed\n");
ft_eprintf("bozoshell: malloc failed\n");
return (NULL);
}
return (path);
@ -46,14 +46,14 @@ static char **ft_get_paths(t_data *data, const char *name)
paths = get_value_by_key("PATH", data->env);
if (paths == NULL)
{
data->exit_code = 127;
ft_eprintf("minishell: %s: command not found\n", name);
*data->exit_code = 127;
ft_eprintf("bozoshell: %s: command not found\n", name);
return (NULL);
}
tab = ft_split(paths, ':');
if (tab == NULL)
{
ft_eprintf("minishell: malloc failed\n");
ft_eprintf("bozoshell: malloc failed\n");
return (NULL);
}
return (tab);
@ -66,7 +66,7 @@ static char *ft_file_is_executable(const char *path, const char *name)
out = ft_strmerger(3, path, "/", name);
if (out == NULL)
{
ft_eprintf("minishell: malloc failed\n");
ft_eprintf("bozoshell: malloc failed\n");
free(out);
return (NULL);
}
@ -97,8 +97,8 @@ static char *ft_get_executable_without_path(t_data *data, const char *name)
ft_freer_tab_ultimate(1, paths);
if (path == NULL)
{
data->exit_code = 127;
ft_eprintf("minishell: %s: command not found\n", name);
*data->exit_code = 127;
ft_eprintf("bozoshell: %s: command not found\n", name);
}
return (path);
}

View File

@ -3,39 +3,38 @@
/* ::: :::::::: */
/* ft_is_in_quote.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/21 12:59:34 by cchauvet #+# #+# */
/* Updated: 2023/03/27 15:32:44 by cchauvet ### ########.fr */
/* Created: 2023/03/30 15:39:25 by cchauvet #+# #+# */
/* Updated: 2023/03/30 15:52:10 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "utils.h"
#include <sys/types.h>
int ft_is_in_quote(const char *str, size_t n)
{
ssize_t i;
size_t i;
ssize_t start;
i = -1;
while (str[++i] != '\0' && i < (ssize_t) n)
start = -1;
i = 0;
while (str[i] != '\0')
{
if (str[i] == '\'')
if (i == n)
break ;
if (str[i] == '\"' || str[i] == '\'')
{
i++;
while (str[i] != '\'' && str[i] != '\0')
{
if (i == (ssize_t) n)
return (1);
i++;
}
}
if (str[i] == '"')
{
while (str[++i] != '"' && str[i] != '\0')
if (i == (ssize_t) n)
return (2);
if (start == -1)
start = i;
else if (str[i] == str[start])
start = -1;
}
i++;
}
return (0);
if (start == -1)
return (0);
if (str[start] == '\'')
return (1);
return (2);
}

View File

@ -0,0 +1,90 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_split_charset_quoted.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/11 14:50:26 by erey-bet #+# #+# */
/* Updated: 2023/04/14 15:53:49 by erey-bet ### ########.fr */
/* */
/* ************************************************************************** */
#include "utils.h"
int new_strs(char ***strs, const char *to_split, int *i, int *j)
{
if (ft_strlen((*strs)[(*i)]) <= 0)
return (0);
(*i)++;
(*j) = 0;
(*strs)[(*i)] = ft_calloc(sizeof(char),
(ft_strlen(to_split) + 1));
if (!(*strs)[(*i)])
return (1);
return (0);
}
int get_strs(const char *to_split, const char *charset, char ***strs, int *i)
{
int j;
int x;
int y;
int check;
x = -1;
j = 0;
while (to_split[++x])
{
y = -1;
check = 1;
while (charset[++y])
{
if (to_split[x] == charset[y] && !ft_is_in_quote(to_split, x))
{
check = 0;
if (new_strs(strs, to_split, i, &j))
return (1);
}
}
if (check)
(*strs)[(*i)][j++] = to_split[x];
}
return (0);
}
void free_set_null(char ***strs, int i)
{
if (ft_strlen((*strs)[i]) == 0)
{
free((*strs)[i]);
(*strs)[i] = NULL;
}
}
char **ft_split_charset_quoted(const char *to_split, const char *charset)
{
char **strs;
int i;
strs = ft_calloc(sizeof(char *), (ft_strlen(to_split) + 1));
if (!strs)
return (NULL);
i = 0;
strs[0] = ft_calloc(sizeof(char), (ft_strlen(to_split) + 1));
if (!strs[0])
{
free(strs);
return (NULL);
}
if (get_strs(to_split, charset, &strs, &i))
{
i = -1;
while (strs[++i])
free(strs[i]);
free(strs);
return (NULL);
}
free_set_null(&strs, i);
return (strs);
}

View File

@ -1,75 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_split_quoted.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/05 19:04:34 by cchauvet #+# #+# */
/* Updated: 2023/02/15 14:25:56 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "utils.h"
size_t ft_seglen_quoted(const char *str, char c)
{
size_t len;
size_t i;
len = 0;
i = 0;
while (str[i] != 0)
{
while ((str[i] == c || ft_is_in_quote(str, i)) && str[i] != 0)
i++;
if (str[i] != 0)
len++;
while ((str[i] != c || ft_is_in_quote(str, i)) && str[i] != 0)
i++;
}
return (len);
}
static char **ft_segsplitter(char **tab, size_t len, const char *s, char c)
{
size_t tab_index;
size_t let_i;
size_t start;
tab_index = 0;
let_i = 0;
start = 0;
if (tab == NULL || s == NULL)
return (NULL);
while (tab_index < len)
{
while ((s[let_i] == c || ft_is_in_quote(s, let_i)) && s[let_i] != 0)
let_i++;
start = let_i;
while ((s[let_i] != c || ft_is_in_quote(s, let_i)) && s[let_i] != 0)
let_i++;
tab[tab_index] = ft_substr(s, start, let_i - start);
if (tab[tab_index] == NULL)
return (ft_cancel((void *)tab, tab_index));
tab_index++;
}
return (tab);
}
char **ft_split_quoted(const char *s, char c)
{
size_t len;
char **tab;
if (s == NULL)
return (NULL);
len = ft_seglen_quoted(s, c);
tab = malloc((len + 1) * sizeof(char *));
if (tab == NULL)
return (NULL);
tab[len] = NULL;
if (ft_segsplitter(tab, len, s, c) == NULL)
return (NULL);
return (tab);
}

View File

@ -1,68 +0,0 @@
!_TAG_EXTRA_DESCRIPTION anonymous /Include tags for non-named objects like lambda/
!_TAG_EXTRA_DESCRIPTION fileScope /Include tags of file scope/
!_TAG_EXTRA_DESCRIPTION pseudo /Include pseudo tags/
!_TAG_EXTRA_DESCRIPTION subparser /Include tags generated by subparsers/
!_TAG_FIELD_DESCRIPTION epoch /the last modified time of the input file (only for F\/file kind tag)/
!_TAG_FIELD_DESCRIPTION file /File-restricted scoping/
!_TAG_FIELD_DESCRIPTION input /input file/
!_TAG_FIELD_DESCRIPTION name /tag name/
!_TAG_FIELD_DESCRIPTION pattern /pattern/
!_TAG_FIELD_DESCRIPTION typeref /Type and name of a variable or typedef/
!_TAG_FIELD_DESCRIPTION!C++ name /aliased names/
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_KIND_DESCRIPTION!C d,macro /macro definitions/
!_TAG_KIND_DESCRIPTION!C e,enumerator /enumerators (values inside an enumeration)/
!_TAG_KIND_DESCRIPTION!C f,function /function definitions/
!_TAG_KIND_DESCRIPTION!C g,enum /enumeration names/
!_TAG_KIND_DESCRIPTION!C h,header /included header files/
!_TAG_KIND_DESCRIPTION!C m,member /struct, and union members/
!_TAG_KIND_DESCRIPTION!C s,struct /structure names/
!_TAG_KIND_DESCRIPTION!C t,typedef /typedefs/
!_TAG_KIND_DESCRIPTION!C u,union /union names/
!_TAG_KIND_DESCRIPTION!C v,variable /variable definitions/
!_TAG_KIND_DESCRIPTION!C++ c,class /classes/
!_TAG_KIND_DESCRIPTION!C++ d,macro /macro definitions/
!_TAG_KIND_DESCRIPTION!C++ e,enumerator /enumerators (values inside an enumeration)/
!_TAG_KIND_DESCRIPTION!C++ f,function /function definitions/
!_TAG_KIND_DESCRIPTION!C++ g,enum /enumeration names/
!_TAG_KIND_DESCRIPTION!C++ h,header /included header files/
!_TAG_KIND_DESCRIPTION!C++ m,member /class, struct, and union members/
!_TAG_KIND_DESCRIPTION!C++ n,namespace /namespaces/
!_TAG_KIND_DESCRIPTION!C++ s,struct /structure names/
!_TAG_KIND_DESCRIPTION!C++ t,typedef /typedefs/
!_TAG_KIND_DESCRIPTION!C++ u,union /union names/
!_TAG_KIND_DESCRIPTION!C++ v,variable /variable definitions/
!_TAG_OUTPUT_EXCMD mixed /number, pattern, mixed, or combineV2/
!_TAG_OUTPUT_FILESEP slash /slash or backslash/
!_TAG_OUTPUT_MODE u-ctags /u-ctags or e-ctags/
!_TAG_OUTPUT_VERSION 0.0 /current.age/
!_TAG_PARSER_VERSION!C 0.0 /current.age/
!_TAG_PARSER_VERSION!C++ 0.0 /current.age/
!_TAG_PATTERN_LENGTH_LIMIT 96 /0 for no limit/
!_TAG_PROC_CWD /nfs/homes/cchauvet/42/minishell/utils/ //
!_TAG_PROGRAM_AUTHOR Universal Ctags Team //
!_TAG_PROGRAM_NAME Universal Ctags /Derived from Exuberant Ctags/
!_TAG_PROGRAM_URL https://ctags.io/ /official site/
!_TAG_PROGRAM_VERSION 6.0.0 //
!_TAG_ROLE_DESCRIPTION!C!header local /local header/
!_TAG_ROLE_DESCRIPTION!C!header system /system header/
!_TAG_ROLE_DESCRIPTION!C!macro undef /undefined/
!_TAG_ROLE_DESCRIPTION!C++!header local /local header/
!_TAG_ROLE_DESCRIPTION!C++!header system /system header/
!_TAG_ROLE_DESCRIPTION!C++!macro undef /undefined/
UTILS_H utils.h /^# define UTILS_H$/;" d
ft_atoi_check ft_atoi_check.c /^int ft_atoi_check(const char *nptr)$/;" f typeref:typename:int
ft_change_exit_code ft_change_exit_code.c /^int ft_change_exit_code(t_data *data, int new_value)$/;" f typeref:typename:int
ft_is_in_quote ft_is_in_quote.c /^int ft_is_in_quote(const char *str, size_t n)$/;" f typeref:typename:int
ft_isspace ft_atoi_check.c /^static int ft_isspace(char c)$/;" f typeref:typename:int file:
ft_printn ft_printn.c /^void ft_printn(const char *str, size_t n)$/;" f typeref:typename:void
ft_quote_remover ft_quote_remover.c /^char *ft_quote_remover(char *str)$/;" f typeref:typename:char *
ft_seglen_quoted ft_split_quoted.c /^size_t ft_seglen_quoted(const char *str, char c)$/;" f typeref:typename:size_t
ft_segsplitter ft_split_quoted.c /^static char **ft_segsplitter(char **tab, size_t len, const char *s, char c)$/;" f typeref:typename:char ** file:
ft_split_quoted ft_split_quoted.c /^char **ft_split_quoted(const char *s, char c)$/;" f typeref:typename:char **
ft_str_is_empty ft_str_is_empty.c /^int ft_str_is_empty(const char *str)$/;" f typeref:typename:int
ft_strnchr ft_strnchr.c /^ssize_t ft_strnchr(const char *str, char c)$/;" f typeref:typename:ssize_t
ft_strncpy ft_strncpy.c /^size_t ft_strncpy(char *dst, const char *src, size_t n)$/;" f typeref:typename:size_t
ft_strreplace ft_strreplace.c /^char *ft_strreplace(const char *str, const char *fill,$/;" f typeref:typename:char *
ft_strshift ft_strshift.c /^void ft_strshift(char *str, int shift)$/;" f typeref:typename:void

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/14 14:46:40 by cchauvet #+# #+# */
/* Updated: 2023/03/29 18:52:32 by cchauvet ### ########.fr */
/* Updated: 2023/04/11 16:55:16 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
@ -24,7 +24,7 @@ char *ft_strreplace(const char *str, const char *fill,
ssize_t ft_strnchr(const char *str, char c);
char *ft_getstr(const char *str, size_t n);
int ft_str_is_empty(const char *str);
char **ft_split_quoted(const char *s, char c);
char **ft_split_charset_quoted(const char *s, const char *charset);
void ft_strshift(char *str, int shift);
char *ft_quote_remover(char *str);
int ft_atoi_check(const char *nptr);

15
vsupp
View File

@ -1,15 +0,0 @@
{
readline
Memcheck:Leak
...
fun:readline
...
}
{
readline
Memcheck:Leak
...
fun:add_history
...
}