This repository has been archived by the owner on Nov 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alexandra Quesada
committed
Nov 10, 2022
1 parent
7534ba6
commit 4f81482
Showing
19 changed files
with
209 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: mcombeau <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2021/11/22 13:53:06 by mcombeau #+# #+# */ | ||
/* Updated: 2022/09/25 14:52:20 by mcombeau ### ########.fr */ | ||
/* Updated: 2022/11/10 00:57:38 by alexa ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -20,7 +20,8 @@ | |
|
||
int ft_isspace(int c) | ||
{ | ||
if (c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '\v' || c == '\f') | ||
if (c == ' ' || c == '\t' || c == '\n' || c == '\r' | ||
|| c == '\v' || c == '\f') | ||
return (c); | ||
return (0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,14 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* replace_var.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: alexa <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/11/10 00:51:45 by alexa #+# #+# */ | ||
/* Updated: 2022/11/10 00:51:47 by alexa ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "minishell.h" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,14 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* var_expander_utils.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: alexa <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/11/10 00:52:09 by alexa #+# #+# */ | ||
/* Updated: 2022/11/10 00:52:18 by alexa ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "minishell.h" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* parse_user_input.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: alexa <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/11/10 00:01:18 by alexa #+# #+# */ | ||
/* Updated: 2022/11/10 00:01:22 by alexa ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "minishell.h" | ||
|
||
static bool input_is_space(char *input) | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,14 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* cmd_lst_utils.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: alexa <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/11/10 00:22:15 by alexa #+# #+# */ | ||
/* Updated: 2022/11/10 00:22:18 by alexa ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "minishell.h" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* cmd_lst_utils_cleanup.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: alexa <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/11/10 00:21:24 by alexa #+# #+# */ | ||
/* Updated: 2022/11/10 00:21:27 by alexa ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "minishell.h" | ||
|
||
void lst_delone_cmd(t_command *lst, void (*del)(void *)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* create_commands.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: alexa <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/11/10 00:16:58 by alexa #+# #+# */ | ||
/* Updated: 2022/11/10 00:17:32 by alexa ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "minishell.h" | ||
|
||
static void prep_no_arg_commands(t_data *data) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,30 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* fill_args_default.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: alexa <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/11/10 00:05:49 by alexa #+# #+# */ | ||
/* Updated: 2022/11/10 00:45:21 by alexa ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "minishell.h" | ||
|
||
int count_arguments(t_token *temp) | ||
{ | ||
int i; | ||
|
||
i = 0; | ||
while (temp && (temp->type == WORD || temp->type == VAR)) | ||
{ | ||
i++; | ||
temp = temp->next; | ||
} | ||
return (i); | ||
} | ||
|
||
/* | ||
** This function fills the array of arguments of the last_cmd by default mode: | ||
** - It allocates the array of arguments thanks to the count_args function | ||
|
@@ -10,16 +35,13 @@ | |
int create_args_default_mode(t_token **token_node, t_command *last_cmd) | ||
{ | ||
int i; | ||
int nb_args; | ||
t_token *temp; | ||
|
||
i = 0; | ||
temp = *token_node; | ||
while (temp->type == WORD || temp->type == VAR) | ||
{ | ||
i++; | ||
temp = temp->next; | ||
} | ||
last_cmd->args = malloc(sizeof(char *) * (i + 2)); | ||
nb_args = count_arguments(temp); | ||
last_cmd->args = malloc(sizeof(char *) * (nb_args + 2)); | ||
if (!last_cmd->args) | ||
return (FAILURE); | ||
temp = *token_node; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,14 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* fill_args_echo.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: alexa <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/11/10 00:02:55 by alexa #+# #+# */ | ||
/* Updated: 2022/11/10 00:03:12 by alexa ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "minishell.h" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* fill_args_echo_utils.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: alexa <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/11/10 00:10:11 by alexa #+# #+# */ | ||
/* Updated: 2022/11/10 00:11:41 by alexa ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "minishell.h" | ||
|
||
/* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* parse_append.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: alexa <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/11/10 00:06:46 by alexa #+# #+# */ | ||
/* Updated: 2022/11/10 00:08:37 by alexa ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "minishell.h" | ||
|
||
/* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* parse_heredoc.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: alexa <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/11/10 00:09:01 by alexa #+# #+# */ | ||
/* Updated: 2022/11/10 00:09:19 by alexa ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "minishell.h" | ||
|
||
/* get_heredoc: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* parse_heredoc_utils.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: alexa <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/11/10 00:09:37 by alexa #+# #+# */ | ||
/* Updated: 2022/11/10 00:09:40 by alexa ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "minishell.h" | ||
|
||
/* make_str_from_tab: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* parse_input.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: alexa <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/11/10 00:20:39 by alexa #+# #+# */ | ||
/* Updated: 2022/11/10 00:20:42 by alexa ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "minishell.h" | ||
|
||
/* INPUT -> REDIR_IN (<) | ||
|
@@ -7,13 +19,6 @@ | |
The general format for redirecting input is: [n]<word | ||
Source : https://www.gnu.org/software/bash/manual/bash.html#Redirections | ||
Exemple : sort < mylist.txt => on trie dans l'ordre alphabetique le contenu qui se | ||
trouve dans "mylist.txt". | ||
wc -l < test.txt => affiche le nb de lignes dans le fichier test | ||
Probleme car avec ECHO ça marche différemment : | ||
https://unix.stackexchange.com/questions/63658/redirecting-the-content-of-a-file-to-the-command-echo) | ||
*/ | ||
|
||
bool remove_old_file_ref(t_io_fds *io, bool infile) | ||
|
@@ -41,15 +46,6 @@ bool remove_old_file_ref(t_io_fds *io, bool infile) | |
return (true); | ||
} | ||
|
||
/* | ||
static void display_error(t_command *cmd, char *infile) | ||
{ | ||
cmd->error = errno; | ||
cmd->err_msg = ft_strdup(strerror(errno)); | ||
printf("bash: %s: %s\n", infile, cmd->err_msg); | ||
} | ||
*/ | ||
|
||
/* open_infile: | ||
* Opens an infile. If an infile was already set, frees it | ||
* and overwrites it. If a previous infile open failed (file does | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* parse_pipe.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: alexa <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/11/10 00:22:49 by alexa #+# #+# */ | ||
/* Updated: 2022/11/10 00:22:52 by alexa ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "minishell.h" | ||
|
||
// ex : echo bonjour | wc -l | ||
/* | ||
une commande deja cree : pour echo bonjour | ||
on arrive au pipe : on doit creer une nouvelle commande | ||
puis creer une aure commande | ||
*/ | ||
void parse_pipe(t_command **cmd, t_token **token_lst) | ||
{ | ||
t_command *last_cmd; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* parse_trunc.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: alexa <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/11/10 00:16:18 by alexa #+# #+# */ | ||
/* Updated: 2022/11/10 00:16:26 by alexa ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "minishell.h" | ||
|
||
/* | ||
|
@@ -87,4 +99,4 @@ exemple : grep test > test.txt test1.txt | |
*si line commence par un TRUNC (>) il faut creer la liste chainee, | ||
et faire condition existence cmd + fonction pour corriger ca | ||
*/ | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* parse_word.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: alexa <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/11/10 00:21:47 by alexa #+# #+# */ | ||
/* Updated: 2022/11/10 00:22:01 by alexa ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "minishell.h" | ||
|
||
static bool contains_space(char *str) | ||
|