-
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
Showing
24 changed files
with
158 additions
and
125 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
Build information, patch level is incremented at compilation. | ||
|
||
RELEASE = 1 | ||
VERSION = 0 | ||
PATCH = 15 | ||
VERSION = 1 | ||
PATCH = 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,7 +6,7 @@ | |
/* By: user42 <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2019/08/04 14:09:42 by fcatusse #+# #+# */ | ||
/* Updated: 2020/05/19 15:50:17 by fcatusse ### ########.fr */ | ||
/* Updated: 2020/05/24 16:57:25 by fcatusse ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -74,6 +74,8 @@ int64_t last_cmd_back(t_read *term, ssize_t i); | |
char *get_home_value(t_core *shell); | ||
void goto_reverse(t_read *term, const char *buff_tmp); | ||
void walking_history(const char *buff, t_read *term, t_lst **history); | ||
ssize_t get_history_value(char *var); | ||
ssize_t check_exp_error(t_lst *w, ssize_t n); | ||
|
||
/* | ||
** SUBPROMPT/MULTILINE | ||
|
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
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: arsciand <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2020/01/27 15:06:02 by fcatusse #+# #+# */ | ||
/* Updated: 2020/05/21 09:28:39 by fcatusse ### ########.fr */ | ||
/* Updated: 2020/05/30 18:57:14 by fcatusse ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
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: user42 <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2019/11/05 19:05:56 by fcatusse #+# #+# */ | ||
/* Updated: 2020/05/21 09:07:56 by fcatusse ### ########.fr */ | ||
/* Updated: 2020/05/30 18:57:31 by fcatusse ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -128,6 +128,6 @@ int8_t select_specifier(t_core *shell, char **av) | |
while (replace_pattern(shell, pat, rep) == SUCCESS) | ||
; | ||
ft_strdel(&pat); | ||
print_and_exec(shell, STDIN_FILENO); | ||
print_and_exec(shell, STDERR_FILENO); | ||
return (SUCCESS); | ||
} |
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,47 +6,43 @@ | |
/* By: arsciand <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2020/01/20 17:50:06 by mpivet-p #+# #+# */ | ||
/* Updated: 2020/05/23 19:40:01 by arsciand ### ########.fr */ | ||
/* Updated: 2020/05/28 15:51:53 by fcatusse ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "sh42.h" | ||
#include <unistd.h> | ||
|
||
static int32_t get_opt_test(size_t argc, char **argv, int8_t diff) | ||
static int32_t get_opt_test(char *str) | ||
{ | ||
static char *op[NB_TESTBLT] = {"-b", "-c", "-d", "-e", "-f", "-g", "-L" | ||
, "-p", "-r", "-S", "-s", "-u", "-w", "-x", "-z", "=", "!=", "-eq" | ||
, "-ne", "-ge", "-lt", "-le"}; | ||
size_t i; | ||
|
||
i = 0; | ||
if (argc > 2 + (size_t)diff && argv[2 + (size_t)diff]) | ||
while (i < NB_TESTBLT) | ||
{ | ||
while (i < NB_TESTBLT) | ||
{ | ||
if (ft_strcmp(op[i], argv[((i <= Z_UNATEST) ? 1 : 2) + diff]) == 0) | ||
return ((int32_t)i); | ||
i++; | ||
} | ||
if (ft_strcmp(op[i], str) == 0) | ||
return ((int32_t)i); | ||
i++; | ||
} | ||
return (FAILURE); | ||
} | ||
|
||
static void parse_testblt_handler | ||
(char **argv, int8_t diff, int64_t num, u_int8_t status) | ||
{ | ||
num = atol(argv[1] + diff); | ||
if (status ^ TEST_INT_EXP) | ||
if (status == TEST_INT_EXP) | ||
ft_dprintf(2, "42sh: test: %s: integer expression expected\n" | ||
, num != SUCCESS | ||
, (ft_atol(argv[1 + diff], &num) != SUCCESS) | ||
? argv[1 + diff] : argv[3 + diff]); | ||
else if (status ^ TEST_ARG) | ||
else if (status == TEST_ARG) | ||
ft_dprintf(STDERR_FILENO, "42sh: test: too many arguments\n"); | ||
else if (status ^ TEST_BIN) | ||
else if (status == TEST_BIN) | ||
ft_dprintf(STDERR_FILENO, "42sh: test: %s: %s operator expected\n" | ||
, argv[1 + diff], "binary"); | ||
else if (status ^ TEST_UNA) | ||
else if (status == TEST_UNA) | ||
ft_dprintf(STDERR_FILENO, "42sh: test: %s: %s operator expected\n" | ||
, argv[1 + diff], "unary"); | ||
} | ||
|
@@ -57,28 +53,26 @@ static int8_t parse_testblt | |
int64_t num; | ||
|
||
num = 0; | ||
if ((*opt = get_opt_test(argc, argv, diff)) > DIFF_BINTEST | ||
&& ((argc > 2 + (size_t)diff && (num = atol(argv[1 + diff])) != SUCCESS) | ||
|| (argc > 3 + (size_t)diff | ||
&& ft_atol(argv[3 + diff], &num) != SUCCESS))) | ||
{ | ||
parse_testblt_handler(argv, diff, num, TEST_INT_EXP); | ||
return (FAILURE); | ||
} | ||
if ((argc > 4 + (size_t)diff && *opt > Z_UNATEST) | ||
|| (argc > 3 + (size_t)diff && *opt <= Z_UNATEST && *opt >= 0)) | ||
{ | ||
if ((int)argc > 4 + diff) | ||
parse_testblt_handler(argv, diff, num, TEST_ARG); | ||
return (FAILURE); | ||
} | ||
if (*opt < 0 || (*opt > Z_UNATEST && argc < 4 + (size_t)diff) | ||
|| (*opt <= Z_UNATEST && *opt >= 0 && argc > 3 + (size_t)diff)) | ||
else if ((int)argc == 4 + diff) | ||
{ | ||
parse_testblt_handler(argv, diff, num, | ||
(*opt <= Z_UNATEST) ? TEST_BIN : TEST_UNA); | ||
return (FAILURE); | ||
if ((*opt = get_opt_test(argv[2 + diff])) == FAILURE | ||
|| *opt <= Z_UNATEST) | ||
parse_testblt_handler(argv, diff, num, TEST_BIN); | ||
else if (*opt >= EQ_BINTEST && *opt <= LE_BINTEST | ||
&& (ft_atol(argv[1 + diff], &num) != SUCCESS | ||
|| ft_atol(argv[3 + diff], &num) != SUCCESS)) | ||
parse_testblt_handler(argv, diff, num, TEST_INT_EXP); | ||
else | ||
return (SUCCESS); | ||
} | ||
return (SUCCESS); | ||
else if ((int)argc == 3 + diff | ||
&& (*opt = get_opt_test(argv[1 + diff])) == FAILURE) | ||
parse_testblt_handler(argv, diff, num, TEST_UNA); | ||
else | ||
return (SUCCESS); | ||
return (FAILURE); | ||
} | ||
|
||
static int8_t comp_tests(const char *s1, const char *s2, int32_t opt) | ||
|
@@ -91,11 +85,10 @@ static int8_t comp_tests(const char *s1, const char *s2, int32_t opt) | |
return (((ft_strcmp(s1, s2) == 0) | ||
? 1 : 0) ^ (int8_t)(DIFF_BINTEST - opt)); | ||
} | ||
ft_dprintf(STDERR_FILENO, "s1 = |%s| , s2 = |%s|\n", s1, s2); | ||
n1 = atol(s1); | ||
ft_dprintf(STDERR_FILENO, "?\n"); | ||
n2 = atol(s2); | ||
ft_dprintf(STDERR_FILENO, "?\n"); | ||
if (!s1 || !s2) | ||
return (1); | ||
ft_atol(s1, &n1); | ||
ft_atol(s2, &n2); | ||
if (opt == EQ_BINTEST || opt == NE_BINTEST) | ||
return ((n1 == n2) ^ (int8_t)(NE_BINTEST - opt)); | ||
if (opt == GE_BINTEST || opt == LT_BINTEST) | ||
|
@@ -109,32 +102,21 @@ int8_t builtin_test(t_core *shell, t_process *process) | |
{ | ||
int32_t opt; | ||
size_t argc; | ||
int diff; | ||
int8_t diff; | ||
|
||
(void)shell; | ||
argc = ft_tablen(process->av); | ||
diff = (argc > 1 && process->av[1] | ||
&& ft_strcmp(process->av[1], "!") == 0) ? 1 : 0; | ||
ft_dprintf(STDERR_FILENO, "DIFF= |%d|\n", diff); | ||
&& ft_strcmp(process->av[1], "!") == 0) ? 1 : 0; | ||
if (argc < 3 + (size_t)diff) | ||
{ | ||
return (((argc < 2 + (size_t)diff | ||
|| process->av[1 + diff][0] == 0) ? 1 : 0) ^ diff); | ||
} | ||
parse_testblt(argc, process->av, diff, &opt); | ||
if (parse_testblt(argc, process->av, diff, &opt) == FAILURE) | ||
return (2); | ||
if (opt <= Z_UNATEST && opt != FAILURE) | ||
return (path_tests(process->av[2 + diff], opt) ^ diff); | ||
if (opt != FAILURE) | ||
{ | ||
if (!process->av[3 + diff]) | ||
{ | ||
ft_dprintf(STDERR_FILENO, | ||
"BREF REVOIR LE PARSING ERREUR ET AJOUTER LA PROTECTION\n42sh: test: %s: unary operator expected\n", process->av[1 + diff]); | ||
return (0); | ||
} | ||
ft_dprintf(STDERR_FILENO, "s2?????? = |%s|\n", process->av[3 + diff]); | ||
return (comp_tests(process->av[1 + diff] | ||
return (comp_tests(process->av[1 + diff] | ||
, process->av[3 + diff], opt) ^ diff); | ||
} | ||
return (2); | ||
} |
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: user42 <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2019/07/09 14:36:52 by fcatusse #+# #+# */ | ||
/* Updated: 2020/05/21 13:35:17 by fcatusse ### ########.fr */ | ||
/* Updated: 2020/05/28 08:47:29 by fcatusse ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
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: fcatusse <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2020/05/05 12:40:04 by fcatusse #+# #+# */ | ||
/* Updated: 2020/05/14 16:36:07 by fcatusse ### ########.fr */ | ||
/* Updated: 2020/05/28 15:24:46 by fcatusse ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
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: user42 <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2019/10/01 17:26:51 by fcatusse #+# #+# */ | ||
/* Updated: 2020/05/12 11:14:13 by fcatusse ### ########.fr */ | ||
/* Updated: 2020/05/30 18:10:13 by fcatusse ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -16,8 +16,8 @@ | |
|
||
static void add_builtin_lst(t_auto_comp *ac, const char *cmd) | ||
{ | ||
static char *blt_names[14] = {"set", "unset", "export", "exit", "cd" | ||
, "echo", "pwd", "type", "fg", "jobs", "bg", "hash", "fc", "test"}; | ||
static char *blt_names[14] = {"set ", "unset ", "export ", "exit ", "cd " | ||
, "echo ", "pwd ", "type ", "fg ", "jobs ", "bg ", "hash ", "fc ", "test "}; | ||
size_t i; | ||
|
||
i = 0; | ||
|
@@ -37,10 +37,12 @@ static void add_builtin_lst(t_auto_comp *ac, const char *cmd) | |
static void fill_bin_lst(char *input, t_auto_comp *ac, char **path) | ||
{ | ||
struct dirent *data; | ||
char *tmp; | ||
DIR *dir; | ||
ssize_t i; | ||
|
||
i = -1; | ||
tmp = NULL; | ||
while (path[++i] && is_dir(path[i])) | ||
{ | ||
dir = opendir(path[i]); | ||
|
@@ -49,10 +51,12 @@ static void fill_bin_lst(char *input, t_auto_comp *ac, char **path) | |
if ((!*input || ft_isstart(data->d_name, input)) | ||
&& is_a_blt(data->d_name) == -1 && !ft_isstart(data->d_name, ".")) | ||
{ | ||
ft_lstappend(&ac->lst, ft_lstnew(data->d_name, | ||
sizeof(char) * (ft_strlen(data->d_name) + 1))); | ||
tmp = ft_strjoin(data->d_name, " "); | ||
ft_lstappend(&ac->lst, ft_lstnew(tmp, | ||
sizeof(char) * (ft_strlen(tmp) + 1))); | ||
ac->lst_size++; | ||
ac->max_len = get_max_len(ac->max_len, ft_strlen(data->d_name)); | ||
ac->max_len = get_max_len(ac->max_len, ft_strlen(tmp)); | ||
ft_strdel(&tmp); | ||
} | ||
} | ||
closedir(dir); | ||
|
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: fcatusse <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2020/05/05 16:32:18 by fcatusse #+# #+# */ | ||
/* Updated: 2020/05/12 17:37:38 by fcatusse ### ########.fr */ | ||
/* Updated: 2020/05/28 08:19:12 by fcatusse ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
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: arsciand <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2019/10/10 15:13:52 by fcatusse #+# #+# */ | ||
/* Updated: 2020/05/14 17:11:05 by fcatusse ### ########.fr */ | ||
/* Updated: 2020/05/29 11:46:32 by fcatusse ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -19,7 +19,16 @@ u_int8_t last_is_slash(char *str) | |
|
||
i = ft_strlen(str); | ||
if (str[i - 1] != '/') | ||
{ | ||
if (str[i - 1] == '.') | ||
{ | ||
if (i >= 2 && str[i - 2] == '.') | ||
return (FALSE); | ||
else | ||
return (TRUE); | ||
} | ||
return (FALSE); | ||
} | ||
return (TRUE); | ||
} | ||
|
||
|
Oops, something went wrong.