merging
This commit is contained in:
commit
1f930ea7b0
9 changed files with 37 additions and 194 deletions
|
|
@ -1,10 +0,0 @@
|
||||||
42ShellTester.sh
|
|
||||||
README.md
|
|
||||||
file
|
|
||||||
lib
|
|
||||||
log
|
|
||||||
minishell_error
|
|
||||||
spec
|
|
||||||
support
|
|
||||||
tasks
|
|
||||||
tmp
|
|
||||||
|
|
@ -1,159 +0,0 @@
|
||||||
[31m[38;5;34m.[0m[31m[38;5;160mx[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;160mx[0m[31m[38;5;160mx[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;34m.[0m[31m[38;5;160mx[0m[31m[38;5;34m.[0m
|
|
||||||
|
|
||||||
----------------------------------------------------------------
|
|
||||||
|
|
||||||
[37;1m21sh/misc/002-simple-command-line[0m [31m[38;5;160m(FAILED)[0m
|
|
||||||
|
|
||||||
Description:
|
|
||||||
[38;5;239m The purpose of this test is to check that the Shell is able to execute a simple command line that contains separators `;`, pipes `|`, and a right redirection `>`.[0m
|
|
||||||
|
|
||||||
Before test:
|
|
||||||
[38;5;239m 01: rm -rf "./size"
|
|
||||||
02: rm -rf "TOKEN201703271859"
|
|
||||||
03: echo '^'$(echo TOKEN201703271859_FILE_TOKEN201703271859_STDOUT | wc -c)'$' > "./size"[0m
|
|
||||||
|
|
||||||
STDIN:
|
|
||||||
[38;5;239m 01: mkdir TOKEN201703271859 ; cd TOKEN201703271859 ; touch TOKEN201703271859_FILE ; ls -1 ; ls | cat | wc -c > TOKEN201703271859_STDOUT ; cat TOKEN201703271859_STDOUT[0m
|
|
||||||
|
|
||||||
STDOUT:
|
|
||||||
[31m[38;5;160m FAILURE expected_to match_regex `TOKEN201703271859_FILE$`[0m
|
|
||||||
[31m[38;5;160m FAILURE expected_to match_each_regex_of_file `./size`[0m
|
|
||||||
[38;5;239m (no output)[0m
|
|
||||||
|
|
||||||
STDERR:
|
|
||||||
[31m[38;5;34m SUCCESS expected_to be_empty[0m
|
|
||||||
[38;5;239m (no output)[0m
|
|
||||||
|
|
||||||
----------------------------------------------------------------
|
|
||||||
|
|
||||||
[37;1m21sh/redirections/outputs/truncating/multiple/004-together[0m [31m[38;5;160m(FAILED)[0m
|
|
||||||
|
|
||||||
Description:
|
|
||||||
[38;5;239m A right redirection can be associated to the twice outputs by using `&>...`, that means `redirect stdout and stderr to ...`.[0m
|
|
||||||
|
|
||||||
Before test:
|
|
||||||
[38;5;239m 01: rm -f "new_file_stderr_and_stdout"[0m
|
|
||||||
|
|
||||||
STDIN:
|
|
||||||
[38;5;239m 01: ./write_on_stdout_and_stderr TOKEN201703271859_1 TOKEN201703271859_2 &>new_file_stderr_and_stdout[0m
|
|
||||||
|
|
||||||
STDOUT:
|
|
||||||
[31m[38;5;160m FAILURE expected_to_not match_regex `TOKEN201703271859_1`[0m
|
|
||||||
[31m[38;5;34m SUCCESS expected_to_not match_regex `TOKEN201703271859_2`[0m
|
|
||||||
[38;5;239m 01: TOKEN201703271859_1[0m
|
|
||||||
|
|
||||||
STDERR:
|
|
||||||
[31m[38;5;34m SUCCESS expected_to_not match_regex `TOKEN201703271859_1`[0m
|
|
||||||
[31m[38;5;160m FAILURE expected_to_not match_regex `TOKEN201703271859_2`[0m
|
|
||||||
[38;5;239m 01: TOKEN201703271859_2[0m
|
|
||||||
|
|
||||||
MISC:
|
|
||||||
[31m[38;5;160m FAILURE expected_to create_file `new_file_stderr_and_stdout` matching_regex `TOKEN201703271859_1$`[0m
|
|
||||||
[31m[38;5;160m FAILURE expected_to create_file `new_file_stderr_and_stdout` matching_regex `TOKEN201703271859_2$`[0m
|
|
||||||
|
|
||||||
----------------------------------------------------------------
|
|
||||||
|
|
||||||
[37;1m21sh/redirections/outputs/truncating/multiple/005-together-with-whitespaces[0m [31m[38;5;160m(FAILED)[0m
|
|
||||||
|
|
||||||
Description:
|
|
||||||
[38;5;239m A right redirection can be associated to the twice outputs by using `&>...`, that means `redirect stdout and stderr to ...`.
|
|
||||||
In this test, we specify the file name in a separate field.[0m
|
|
||||||
|
|
||||||
Before test:
|
|
||||||
[38;5;239m 01: rm -f new_file_stderr_and_stdout[0m
|
|
||||||
|
|
||||||
STDIN:
|
|
||||||
[38;5;239m 01: ./write_on_stdout_and_stderr TOKEN201703271859_1 TOKEN201703271859_2 &> new_file_stderr_and_stdout[0m
|
|
||||||
|
|
||||||
STDOUT:
|
|
||||||
[31m[38;5;160m FAILURE expected_to_not match_regex `TOKEN201703271859_1`[0m
|
|
||||||
[31m[38;5;34m SUCCESS expected_to_not match_regex `TOKEN201703271859_2`[0m
|
|
||||||
[38;5;239m 01: TOKEN201703271859_1[0m
|
|
||||||
|
|
||||||
STDERR:
|
|
||||||
[31m[38;5;34m SUCCESS expected_to_not match_regex `TOKEN201703271859_1`[0m
|
|
||||||
[31m[38;5;160m FAILURE expected_to_not match_regex `TOKEN201703271859_2`[0m
|
|
||||||
[38;5;239m 01: TOKEN201703271859_2[0m
|
|
||||||
|
|
||||||
MISC:
|
|
||||||
[31m[38;5;160m FAILURE expected_to create_file `new_file_stderr_and_stdout` matching_regex `TOKEN201703271859_1$`[0m
|
|
||||||
[31m[38;5;160m FAILURE expected_to create_file `new_file_stderr_and_stdout` matching_regex `TOKEN201703271859_2$`[0m
|
|
||||||
|
|
||||||
----------------------------------------------------------------
|
|
||||||
|
|
||||||
[37;1m21sh/separators/semicolon/003-parse-error-empty-inline-command[0m [31m[38;5;160m(FAILED)[0m
|
|
||||||
|
|
||||||
Description:
|
|
||||||
[38;5;239m The purpose of this test is to check that using the simicolon separator `;` with empty commands results in error.[0m
|
|
||||||
|
|
||||||
STDIN:
|
|
||||||
[38;5;239m 01: ./write_on_stdout TOKEN201703271859 ; ; ./exit_with_status 42[0m
|
|
||||||
|
|
||||||
STDOUT:
|
|
||||||
[31m[38;5;34m SUCCESS expected_to be_empty[0m
|
|
||||||
[38;5;239m (no output)[0m
|
|
||||||
|
|
||||||
STDERR:
|
|
||||||
[31m[38;5;34m SUCCESS expected_to_not be_empty[0m
|
|
||||||
[31m[38;5;34m SUCCESS might match_regex `([Ss]yntax|[Pp]arse) error`[0m
|
|
||||||
[38;5;239m 01: syntax error near unexpected token `;'[0m
|
|
||||||
|
|
||||||
MISC:
|
|
||||||
[31m[38;5;34m SUCCESS expected_to_not exit_with_status `42`[0m
|
|
||||||
[31m[38;5;160m FAILURE expected_to_not exit_with_status `0`[0m
|
|
||||||
|
|
||||||
Total tests: 36
|
|
||||||
Total failed tests: 4
|
|
||||||
Total pending tests: 0
|
|
||||||
38;5;160m(FAILED)[0m
|
|
||||||
|
|
||||||
Description:
|
|
||||||
[38;5;239m A right redirection can be associated to the twice outputs by using `&>...`, that means `redirect stdout and stderr to ...`.
|
|
||||||
In this test, we specify the file name in a separate field.[0m
|
|
||||||
|
|
||||||
Before test:
|
|
||||||
[38;5;239m 01: rm -f new_file_stderr_and_stdout[0m
|
|
||||||
|
|
||||||
STDIN:
|
|
||||||
[38;5;239m 01: ./write_on_stdout_and_stderr TOKEN201703271859_1 TOKEN201703271859_2 &> new_file_stderr_and_stdout[0m
|
|
||||||
|
|
||||||
STDOUT:
|
|
||||||
[31m[38;5;160m FAILURE expected_to_not match_regex `TOKEN201703271859_1`[0m
|
|
||||||
[31m[38;5;34m SUCCESS expected_to_not match_regex `TOKEN201703271859_2`[0m
|
|
||||||
[38;5;239m 01: TOKEN201703271859_1[0m
|
|
||||||
|
|
||||||
STDERR:
|
|
||||||
[31m[38;5;34m SUCCESS expected_to_not match_regex `TOKEN201703271859_1`[0m
|
|
||||||
[31m[38;5;160m FAILURE expected_to_not match_regex `TOKEN201703271859_2`[0m
|
|
||||||
[38;5;239m 01: TOKEN201703271859_2[0m
|
|
||||||
|
|
||||||
MISC:
|
|
||||||
[31m[38;5;160m FAILURE expected_to create_file `new_file_stderr_and_stdout` matching_regex `TOKEN201703271859_1$`[0m
|
|
||||||
[31m[38;5;160m FAILURE expected_to create_file `new_file_stderr_and_stdout` matching_regex `TOKEN201703271859_2$`[0m
|
|
||||||
|
|
||||||
----------------------------------------------------------------
|
|
||||||
|
|
||||||
[37;1m21sh/separators/semicolon/003-parse-error-empty-inline-command[0m [31m[38;5;160m(FAILED)[0m
|
|
||||||
|
|
||||||
Description:
|
|
||||||
[38;5;239m The purpose of this test is to check that using the simicolon separator `;` with empty commands results in error.[0m
|
|
||||||
|
|
||||||
STDIN:
|
|
||||||
[38;5;239m 01: ./write_on_stdout TOKEN201703271859 ; ; ./exit_with_status 42[0m
|
|
||||||
|
|
||||||
STDOUT:
|
|
||||||
[31m[38;5;34m SUCCESS expected_to be_empty[0m
|
|
||||||
[38;5;239m (no output)[0m
|
|
||||||
|
|
||||||
STDERR:
|
|
||||||
[31m[38;5;34m SUCCESS expected_to_not be_empty[0m
|
|
||||||
[31m[38;5;34m SUCCESS might match_regex `([Ss]yntax|[Pp]arse) error`[0m
|
|
||||||
[38;5;239m 01: syntax error near unexpected token `;'[0m
|
|
||||||
|
|
||||||
MISC:
|
|
||||||
[31m[38;5;34m SUCCESS expected_to_not exit_with_status `42`[0m
|
|
||||||
[31m[38;5;160m FAILURE expected_to_not exit_with_status `0`[0m
|
|
||||||
|
|
||||||
Total tests: 36
|
|
||||||
Total failed tests: 4
|
|
||||||
Total pending tests: 0
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
jhalford
|
wescande
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/02/15 12:03:30 by alao #+# #+# */
|
/* Created: 2017/02/15 12:03:30 by alao #+# #+# */
|
||||||
/* Updated: 2017/03/28 09:10:54 by jhalford ### ########.fr */
|
/* Updated: 2017/03/28 16:13:46 by wescande ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/13 22:21:19 by jhalford #+# #+# */
|
/* Created: 2017/03/13 22:21:19 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/27 19:45:22 by jhalford ### ########.fr */
|
/* Updated: 2017/03/28 16:13:56 by wescande ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -16,12 +16,12 @@ int process_fork(t_process *p)
|
||||||
{
|
{
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
||||||
if (!p)
|
|
||||||
return (0);
|
|
||||||
if ((pid = fork()) == -1)
|
if ((pid = fork()) == -1)
|
||||||
exit(SH_ERR("fork(): %s", strerror(errno)));
|
exit(SH_ERR("fork(): %s", strerror(errno)));
|
||||||
else if (pid != 0)
|
else if (pid != 0)
|
||||||
return (pid);
|
return (pid);
|
||||||
|
if (!p)
|
||||||
|
return (0);
|
||||||
exec_destroy(&data_singleton()->exec);
|
exec_destroy(&data_singleton()->exec);
|
||||||
jobc_destroy(&data_singleton()->jobc);
|
jobc_destroy(&data_singleton()->jobc);
|
||||||
if ((pid = 1) && process_redirect(p) == 0)
|
if ((pid = 1) && process_redirect(p) == 0)
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/26 10:43:16 by gwojda #+# #+# */
|
/* Created: 2017/01/26 10:43:16 by gwojda #+# #+# */
|
||||||
/* Updated: 2017/03/20 14:09:01 by gwojda ### ########.fr */
|
/* Updated: 2017/03/28 12:22:12 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -61,6 +61,8 @@ static int ft_modify_str(char *str_srch, size_t srch_pos, char **str,
|
||||||
*str = ft_strdup(*str);
|
*str = ft_strdup(*str);
|
||||||
ft_current_str(*str, *pos);
|
ft_current_str(*str, *pos);
|
||||||
ft_get_next_str(*str, pos);
|
ft_get_next_str(*str, pos);
|
||||||
|
if ((*str)[*pos])
|
||||||
|
++(*pos);
|
||||||
}
|
}
|
||||||
free(str_srch);
|
free(str_srch);
|
||||||
return (0);
|
return (0);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/28 18:36:58 by jhalford #+# #+# */
|
/* Created: 2016/11/28 18:36:58 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/27 21:27:35 by gwojda ### ########.fr */
|
/* Updated: 2017/03/28 15:46:22 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -19,17 +19,16 @@ int lexer_dquote(t_list **alst, t_lexer *lexer)
|
||||||
token = (*alst)->content;
|
token = (*alst)->content;
|
||||||
token->type = token->type ? token->type : TK_WORD;
|
token->type = token->type ? token->type : TK_WORD;
|
||||||
if (lexer->str[lexer->pos] == '"')
|
if (lexer->str[lexer->pos] == '"')
|
||||||
|
get_lexer_stack(*lexer) == DQUOTE && (lexer->state = WORD) ?
|
||||||
|
pop(&lexer->stack) : push(&lexer->stack, DQUOTE) && 0;
|
||||||
|
else if (lexer->str[lexer->pos] == '\\')
|
||||||
{
|
{
|
||||||
if (get_lexer_stack(*lexer) == DQUOTE && (lexer->state = WORD))
|
if (lexer->str[++lexer->pos] == 0)
|
||||||
pop(&lexer->stack);
|
|
||||||
else
|
|
||||||
push(&lexer->stack, DQUOTE);
|
|
||||||
}
|
|
||||||
else if (lexer->str[lexer->pos] == '\\' && lexer->str[lexer->pos + 1] == 0)
|
|
||||||
{
|
|
||||||
lexer->pos++;
|
|
||||||
if (lexer->str[lexer->pos] == 0)
|
|
||||||
return (push(&lexer->stack, BACKSLASH) ? 0 : 0);
|
return (push(&lexer->stack, BACKSLASH) ? 0 : 0);
|
||||||
|
else if (lexer->str[lexer->pos] == '"')
|
||||||
|
token_append(token, lexer, 1, 1);
|
||||||
|
else
|
||||||
|
--lexer->pos;
|
||||||
}
|
}
|
||||||
else if (lexer->str[lexer->pos] == '`' && (lexer->state = BQUOTE))
|
else if (lexer->str[lexer->pos] == '`' && (lexer->state = BQUOTE))
|
||||||
return (lexer_lex(alst, lexer));
|
return (lexer_lex(alst, lexer));
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/15 14:19:48 by gwojda #+# #+# */
|
/* Created: 2016/12/15 14:19:48 by gwojda #+# #+# */
|
||||||
/* Updated: 2017/03/27 18:10:21 by gwojda ### ########.fr */
|
/* Updated: 2017/03/28 14:57:13 by wescande ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -20,6 +20,7 @@ int readline(int has_prompt, char **input)
|
||||||
data_singleton()->line.prompt_size = 1;
|
data_singleton()->line.prompt_size = 1;
|
||||||
if (!SH_IS_INTERACTIVE(data_singleton()->opts))
|
if (!SH_IS_INTERACTIVE(data_singleton()->opts))
|
||||||
{
|
{
|
||||||
|
ft_strdel(input);
|
||||||
if ((ret = get_next_line(data_singleton()->fd, input)) >= 0)
|
if ((ret = get_next_line(data_singleton()->fd, input)) >= 0)
|
||||||
return (!ret);
|
return (!ret);
|
||||||
return (ret);
|
return (ret);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/20 14:45:40 by gwojda #+# #+# */
|
/* Created: 2017/03/20 14:45:40 by gwojda #+# #+# */
|
||||||
/* Updated: 2017/03/28 07:46:57 by jhalford ### ########.fr */
|
/* Updated: 2017/03/28 16:14:10 by wescande ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -32,6 +32,22 @@ static int do_readline_routine(char **stream)
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int exec_instruction(t_btree **ast, char **stream)
|
||||||
|
{
|
||||||
|
t_data *data;
|
||||||
|
|
||||||
|
data = data_singleton();
|
||||||
|
if (SH_IS_INTERACTIVE(data->opts) && data->lexer.str)
|
||||||
|
ft_add_str_in_history(data->lexer.str);
|
||||||
|
else
|
||||||
|
ft_strdel(stream);
|
||||||
|
if (data->parser.state == SUCCESS && ft_exec(ast) < 0)
|
||||||
|
exit(1);
|
||||||
|
else if (data->parser.state != SUCCESS)
|
||||||
|
set_exitstatus(1, 1);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
static int handle_instruction(t_list **token, t_btree **ast)
|
static int handle_instruction(t_list **token, t_btree **ast)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
@ -52,13 +68,7 @@ static int handle_instruction(t_list **token, t_btree **ast)
|
||||||
else if (ret > 0)
|
else if (ret > 0)
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
if (SH_IS_INTERACTIVE(data->opts) && data->lexer.str)
|
return (exec_instruction(ast, &stream));
|
||||||
ft_add_str_in_history(data->lexer.str);
|
|
||||||
if (data->parser.state == SUCCESS && ft_exec(ast) < 0)
|
|
||||||
exit(1);
|
|
||||||
else if (data->parser.state != SUCCESS)
|
|
||||||
set_exitstatus(1, 1);
|
|
||||||
return (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int ac, char **av, char **env)
|
int main(int ac, char **av, char **env)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue