-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from Hugothms/hugo
Final
- Loading branch information
Showing
16 changed files
with
176 additions
and
113 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 |
---|---|---|
|
@@ -11,3 +11,4 @@ minishell | |
# Makefile | ||
mini_tester/** | ||
minishell-tester/** | ||
mini_tester |
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
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: hthomas <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2020/05/04 09:33:37 by hthomas #+# #+# */ | ||
/* Updated: 2020/12/07 19:20:30 by hthomas ### ########.fr */ | ||
/* Updated: 2020/12/15 22:20:29 by hthomas ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -107,6 +107,11 @@ t_glob g_glob; | |
*/ | ||
char *ft_echo(t_list_cmd *args); | ||
char *ft_cd(t_list_cmd *args, t_list *env); | ||
char *ft_cd2(t_list_cmd *args, t_list *env, | ||
struct stat *stats); | ||
char *error_cd(char *arg, int err_status); | ||
int test_cd_home(t_list_cmd *args, t_list *env, | ||
struct stat *stats); | ||
char *ft_pwd(void); | ||
char *ft_export(t_list_cmd *args, t_list *env); | ||
void add_quote(char **tri); | ||
|
@@ -115,7 +120,7 @@ int have_equal(char *str); | |
void print_exp_err(char **key, char **value); | ||
char *ft_unset(t_list_cmd *args, t_list *env); | ||
char *ft_env(t_list *env); | ||
char *ft_exit(t_list_cmd *args, t_list *env); | ||
char *ft_exit(t_list_line *lst_line, t_list *env); | ||
void clear_env_lst(t_list *env); | ||
|
||
/* | ||
|
@@ -161,14 +166,14 @@ void delete_empty_elements(t_list_cmd **cmd); | |
void parse_error(char *input, t_list_line *lst_line); | ||
int print_synt_err(void); | ||
void print_prompt(void); | ||
void not_found(char *cmd); | ||
void not_found(t_list_line *lst_line, t_list *env); | ||
|
||
/* | ||
** exec_line.c | ||
*/ | ||
void exec_line(t_list_line *lst_line, t_list *env); | ||
t_list_cmd *reparse_var_env(t_list_cmd *cmd); | ||
char *exec_cmd(t_list_cmd *cmd, t_list *env); | ||
char *exec_cmd(t_list_line *lst_line, t_list *env); | ||
int make_and_exec_cmd(t_list_line *lst_line, t_list *env); | ||
t_list_cmd *split_add_back(t_list_cmd *cmd, | ||
void (*del)(t_list_cmd *), t_list_cmd *to_del); | ||
|
@@ -187,7 +192,7 @@ void set_env(char **envp, t_list **env); | |
** pipe.c | ||
*/ | ||
int create_pipe(t_list_line **lst_line, t_list \ | ||
*env, int fd_inold); | ||
*env, int fd_inold, int *nb_wait); | ||
|
||
/* | ||
** redirection.c | ||
|
@@ -197,7 +202,7 @@ int redirections(t_list_line *lst_line); | |
/* | ||
** searche_command.c | ||
*/ | ||
int search_command(t_list_cmd *cmd, t_list *env); | ||
int search_command(t_list_line *lst_line, t_list *env); | ||
|
||
/* | ||
** List | ||
|
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: hthomas <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2020/10/22 16:16:24 by vmoreau #+# #+# */ | ||
/* Updated: 2020/12/07 18:57:59 by hthomas ### ########.fr */ | ||
/* Updated: 2020/12/15 22:20:37 by hthomas ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -20,6 +20,7 @@ static void modif_oldpwd_pwd(t_list *env) | |
modif_var_env(env, "OLDPWD", &find_var_env(env, "PWD=")[4]); | ||
if (!pwd) | ||
{ | ||
ft_putstr_fd("No such file or directory\n", STDERR); | ||
free(pwd); | ||
pwd = ft_strdup(&find_var_env(env, "PWD=")[4]); | ||
pwd = ft_strjoin_free(pwd, "/.."); | ||
|
@@ -30,7 +31,7 @@ static void modif_oldpwd_pwd(t_list *env) | |
free(pwd); | ||
} | ||
|
||
static char *error_cd(char *arg, int err_status) | ||
char *error_cd(char *arg, int err_status) | ||
{ | ||
char *ret; | ||
|
||
|
@@ -75,7 +76,7 @@ static char *cd_oldpwd(t_list *env, t_list_cmd *arg, struct stat *stats) | |
return (ret); | ||
} | ||
|
||
static int test_cd_home(t_list_cmd *args, t_list *env, struct stat *stats) | ||
int test_cd_home(t_list_cmd *args, t_list *env, struct stat *stats) | ||
{ | ||
if (stat(&find_var_env(env, "HOME=")[5], stats) != 0) | ||
return (1); | ||
|
@@ -88,18 +89,13 @@ static int test_cd_home(t_list_cmd *args, t_list *env, struct stat *stats) | |
char *ft_cd(t_list_cmd *args, t_list *env) | ||
{ | ||
struct stat stats; | ||
char *ret; | ||
|
||
g_glob.exit = 0; | ||
if ((!args || !args->str)) | ||
{ | ||
if (chdir(&find_var_env(env, "HOME=")[5])) | ||
if (find_var_env(env, "HOME=") == NULL) | ||
return (error_cd("« HOME »", 3)); | ||
else if (find_var_env(env, "HOME=")[5] == '\0') | ||
return (ft_strdup("")); | ||
else if (test_cd_home(args, env, &stats)) | ||
return (error_cd(&find_var_env(env, "HOME=")[5], | ||
test_cd_home(args, env, &stats))); | ||
if ((ret = ft_cd2(args, env, &stats))) | ||
return (ret); | ||
} | ||
else if (c_lst_size(args) > 1) | ||
return (error_cd(args->str, 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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* ft_cd2.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: hthomas <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2020/12/15 22:17:31 by hthomas #+# #+# */ | ||
/* Updated: 2020/12/16 10:01:30 by hthomas ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "../includes/minishell.h" | ||
|
||
char *ft_cd2(t_list_cmd *args, t_list *env, struct stat *stats) | ||
{ | ||
if (chdir(&find_var_env(env, "HOME=")[5])) | ||
{ | ||
if (find_var_env(env, "HOME=") == NULL) | ||
return (error_cd("« HOME »", 3)); | ||
else if (find_var_env(env, "HOME=")[5] == '\0') | ||
return (ft_strdup("")); | ||
else if (test_cd_home(args, env, stats)) | ||
return (error_cd(&find_var_env(env, "HOME=")[5], | ||
test_cd_home(args, env, stats))); | ||
} | ||
return (NULL); | ||
} |
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
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: hthomas <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2020/10/22 16:16:36 by vmoreau #+# #+# */ | ||
/* Updated: 2020/12/07 19:05:39 by hthomas ### ########.fr */ | ||
/* Updated: 2020/12/15 21:48:32 by hthomas ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -20,10 +20,12 @@ int have_equal(char *str) | |
while (str[i]) | ||
{ | ||
if (str[i] == '=') | ||
{ | ||
if (i == 0) | ||
return (1); | ||
else | ||
return (i); | ||
} | ||
i++; | ||
} | ||
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 |
---|---|---|
|
@@ -6,12 +6,11 @@ | |
/* By: hthomas <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2020/10/22 16:16:41 by vmoreau #+# #+# */ | ||
/* Updated: 2020/12/07 19:02:23 by hthomas ### ########.fr */ | ||
/* Updated: 2020/12/15 21:49:42 by hthomas ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "../includes/minishell.h" | ||
#include <stdio.h> | ||
|
||
static char **catch_arg(t_list_cmd *args) | ||
{ | ||
|
@@ -44,7 +43,7 @@ static void lst_del_next_node(t_list *env, char *var) | |
tmp = env->next->next; | ||
free(env->next->content); | ||
free(env->next); | ||
env->next == NULL; | ||
env->next = NULL; | ||
env->next = tmp; | ||
break ; | ||
} | ||
|
@@ -69,7 +68,7 @@ char *ft_unset(t_list_cmd *args, t_list *env) | |
else | ||
{ | ||
g_glob.exit = 1; | ||
ft_putstr_fd("minishell: export: « ", STDERR); | ||
ft_putstr_fd("minishell: unset: « ", STDERR); | ||
ft_putstr_fd(var[i], STDERR); | ||
ft_putstr_fd(" » : not valid identifier\n", STDERR); | ||
} | ||
|
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
Oops, something went wrong.